Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
ee7c1b0c
Commit
ee7c1b0c
authored
Mar 15, 2015
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actually test weak pointers (and make them work).
parent
8b8f8a2f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
9 deletions
+49
-9
capability-test.c++
c++/src/capnp/capability-test.c++
+10
-0
node-translator.c++
c++/src/capnp/compiler/node-translator.c++
+1
-1
common.h
c++/src/kj/common.h
+19
-4
memory.h
c++/src/kj/memory.h
+19
-4
No files found.
c++/src/capnp/capability-test.c++
View file @
ee7c1b0c
...
@@ -884,6 +884,16 @@ TEST(Capability, CapabilityServerSet) {
...
@@ -884,6 +884,16 @@ TEST(Capability, CapabilityServerSet) {
EXPECT_TRUE
(
resolved1
);
EXPECT_TRUE
(
resolved1
);
EXPECT_TRUE
(
resolved2
);
EXPECT_TRUE
(
resolved2
);
// Check weak pointer.
{
auto
restored
=
KJ_ASSERT_NONNULL
(
client2Weak
->
get
());
EXPECT_EQ
(
&
server2
,
&
KJ_ASSERT_NONNULL
(
set2
.
getLocalServer
(
restored
).
wait
(
waitScope
)));
}
client2
=
nullptr
;
EXPECT_TRUE
(
client2Weak
->
get
()
==
nullptr
);
}
}
}
// namespace
}
// namespace
...
...
c++/src/capnp/compiler/node-translator.c++
View file @
ee7c1b0c
...
@@ -827,7 +827,7 @@ kj::Maybe<NodeTranslator::BrandedDecl> NodeTranslator::BrandedDecl::applyParams(
...
@@ -827,7 +827,7 @@ kj::Maybe<NodeTranslator::BrandedDecl> NodeTranslator::BrandedDecl::applyParams(
return
nullptr
;
return
nullptr
;
}
else
{
}
else
{
return
brand
->
setParams
(
kj
::
mv
(
params
),
body
.
get
<
Resolver
::
ResolvedDecl
>
().
kind
,
subSource
)
return
brand
->
setParams
(
kj
::
mv
(
params
),
body
.
get
<
Resolver
::
ResolvedDecl
>
().
kind
,
subSource
)
.
map
([
&
](
kj
::
Own
<
BrandScope
>&
scope
)
{
.
map
([
&
](
kj
::
Own
<
BrandScope
>&
&
scope
)
{
BrandedDecl
result
=
*
this
;
BrandedDecl
result
=
*
this
;
result
.
brand
=
kj
::
mv
(
scope
);
result
.
brand
=
kj
::
mv
(
scope
);
result
.
source
=
subSource
;
result
.
source
=
subSource
;
...
...
c++/src/kj/common.h
View file @
ee7c1b0c
...
@@ -1010,7 +1010,7 @@ public:
...
@@ -1010,7 +1010,7 @@ public:
}
}
template
<
typename
Func
>
template
<
typename
Func
>
auto
map
(
Func
&&
f
)
->
Maybe
<
decltype
(
f
(
instance
<
T
&>
()))
>
{
auto
map
(
Func
&&
f
)
&
->
Maybe
<
decltype
(
f
(
instance
<
T
&>
()))
>
{
if
(
ptr
==
nullptr
)
{
if
(
ptr
==
nullptr
)
{
return
nullptr
;
return
nullptr
;
}
else
{
}
else
{
...
@@ -1019,7 +1019,7 @@ public:
...
@@ -1019,7 +1019,7 @@ public:
}
}
template
<
typename
Func
>
template
<
typename
Func
>
auto
map
(
Func
&&
f
)
const
->
Maybe
<
decltype
(
f
(
instance
<
const
T
&>
()))
>
{
auto
map
(
Func
&&
f
)
const
&
->
Maybe
<
decltype
(
f
(
instance
<
const
T
&>
()))
>
{
if
(
ptr
==
nullptr
)
{
if
(
ptr
==
nullptr
)
{
return
nullptr
;
return
nullptr
;
}
else
{
}
else
{
...
@@ -1027,8 +1027,23 @@ public:
...
@@ -1027,8 +1027,23 @@ public:
}
}
}
}
// TODO(someday): Once it's safe to require GCC 4.8, use ref qualifiers to provide a version of
template
<
typename
Func
>
// map() that uses move semantics if *this is an rvalue.
auto
map
(
Func
&&
f
)
&&
->
Maybe
<
decltype
(
f
(
instance
<
T
&&>
()))
>
{
if
(
ptr
==
nullptr
)
{
return
nullptr
;
}
else
{
return
f
(
kj
::
mv
(
*
ptr
));
}
}
template
<
typename
Func
>
auto
map
(
Func
&&
f
)
const
&&
->
Maybe
<
decltype
(
f
(
instance
<
const
T
&&>
()))
>
{
if
(
ptr
==
nullptr
)
{
return
nullptr
;
}
else
{
return
f
(
kj
::
mv
(
*
ptr
));
}
}
private
:
private
:
_
::
NullableValue
<
T
>
ptr
;
_
::
NullableValue
<
T
>
ptr
;
...
...
c++/src/kj/memory.h
View file @
ee7c1b0c
...
@@ -269,7 +269,7 @@ public:
...
@@ -269,7 +269,7 @@ public:
}
}
template
<
typename
Func
>
template
<
typename
Func
>
auto
map
(
Func
&&
f
)
->
Maybe
<
decltype
(
f
(
instance
<
Own
<
T
>&>
()))
>
{
auto
map
(
Func
&&
f
)
&
->
Maybe
<
decltype
(
f
(
instance
<
Own
<
T
>&>
()))
>
{
if
(
ptr
==
nullptr
)
{
if
(
ptr
==
nullptr
)
{
return
nullptr
;
return
nullptr
;
}
else
{
}
else
{
...
@@ -278,7 +278,7 @@ public:
...
@@ -278,7 +278,7 @@ public:
}
}
template
<
typename
Func
>
template
<
typename
Func
>
auto
map
(
Func
&&
f
)
const
->
Maybe
<
decltype
(
f
(
instance
<
const
Own
<
T
>&>
()))
>
{
auto
map
(
Func
&&
f
)
const
&
->
Maybe
<
decltype
(
f
(
instance
<
const
Own
<
T
>&>
()))
>
{
if
(
ptr
==
nullptr
)
{
if
(
ptr
==
nullptr
)
{
return
nullptr
;
return
nullptr
;
}
else
{
}
else
{
...
@@ -286,8 +286,23 @@ public:
...
@@ -286,8 +286,23 @@ public:
}
}
}
}
// TODO(someday): Once it's safe to require GCC 4.8, use ref qualifiers to provide a version of
template
<
typename
Func
>
// map() that uses move semantics if *this is an rvalue.
auto
map
(
Func
&&
f
)
&&
->
Maybe
<
decltype
(
f
(
instance
<
Own
<
T
>&&>
()))
>
{
if
(
ptr
==
nullptr
)
{
return
nullptr
;
}
else
{
return
f
(
kj
::
mv
(
ptr
));
}
}
template
<
typename
Func
>
auto
map
(
Func
&&
f
)
const
&&
->
Maybe
<
decltype
(
f
(
instance
<
const
Own
<
T
>&&>
()))
>
{
if
(
ptr
==
nullptr
)
{
return
nullptr
;
}
else
{
return
f
(
kj
::
mv
(
ptr
));
}
}
private
:
private
:
Own
<
T
>
ptr
;
Own
<
T
>
ptr
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment