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
24d5567c
Commit
24d5567c
authored
Aug 31, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug where DynamicValue::Builder was not assignable.
parent
a86b5f24
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
dynamic-test.c++
c++/src/capnp/dynamic-test.c++
+18
-0
dynamic.h
c++/src/capnp/dynamic.h
+2
-0
No files found.
c++/src/capnp/dynamic-test.c++
View file @
24d5567c
...
...
@@ -439,6 +439,24 @@ TEST(DynamicApi, SetDataFromText) {
EXPECT_EQ
(
data
(
"foo"
),
root
.
get
(
"dataField"
).
as
<
Data
>
());
}
TEST
(
DynamicApi
,
BuilderAssign
)
{
MallocMessageBuilder
builder
;
auto
root
=
builder
.
initRoot
<
DynamicStruct
>
(
Schema
::
from
<
TestAllTypes
>
());
// Declare upfront, assign later.
DynamicValue
::
Builder
value
;
DynamicStruct
::
Builder
structValue
=
nullptr
;
DynamicList
::
Builder
listValue
=
nullptr
;
value
=
root
.
get
(
"structField"
);
structValue
=
value
.
as
<
DynamicStruct
>
();
structValue
.
set
(
"int32Field"
,
123
);
value
=
root
.
init
(
"int32List"
,
1
);
listValue
=
value
.
as
<
DynamicList
>
();
listValue
.
set
(
0
,
123
);
}
}
// namespace
}
// namespace _ (private)
}
// namespace capnp
c++/src/capnp/dynamic.h
View file @
24d5567c
...
...
@@ -613,6 +613,8 @@ public:
inline
Builder
(
Builder
&
other
)
{
memcpy
(
this
,
&
other
,
sizeof
(
*
this
));
}
inline
Builder
(
Builder
&&
other
)
{
memcpy
(
this
,
&
other
,
sizeof
(
*
this
));
}
inline
Builder
&
operator
=
(
Builder
&
other
)
{
memcpy
(
this
,
&
other
,
sizeof
(
*
this
));
}
inline
Builder
&
operator
=
(
Builder
&&
other
)
{
memcpy
(
this
,
&
other
,
sizeof
(
*
this
));
}
static_assert
(
__has_trivial_copy
(
StructSchema
)
&&
__has_trivial_copy
(
ListSchema
),
"Assumptions made here do not hold."
);
// Hack: We know this type is trivially constructable but the use of DisallowConstCopy causes
...
...
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