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
b731cf8f
Commit
b731cf8f
authored
May 13, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better check that schema matches exactly here.
parent
e5e34217
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
14 deletions
+8
-14
dynamic.c++
c++/src/capnproto/dynamic.c++
+4
-10
dynamic.h
c++/src/capnproto/dynamic.h
+4
-4
No files found.
c++/src/capnproto/dynamic.c++
View file @
b731cf8f
...
...
@@ -281,17 +281,11 @@ void DynamicUnion::Builder::setObjectDiscriminant(StructSchema::Member member) {
// =======================================================================================
void
DynamicStruct
::
Reader
::
verifyTypeId
(
uint64_t
id
)
{
VALIDATE_INPUT
(
id
==
schema
.
getProto
().
getId
(),
"Type mismatch when using DynamicStruct::Reader::as()."
)
{
// Go on with bad type ID.
}
void
DynamicStruct
::
Reader
::
verifySchema
(
StructSchema
expected
)
{
PRECOND
(
schema
==
expected
,
"Type mismatch when using DynamicStruct::Reader::as()."
);
}
void
DynamicStruct
::
Builder
::
verifyTypeId
(
uint64_t
id
)
{
VALIDATE_INPUT
(
id
==
schema
.
getProto
().
getId
(),
"Type mismatch when using DynamicStruct::Builder::as()."
)
{
// Go on with bad type ID.
}
void
DynamicStruct
::
Builder
::
verifySchema
(
StructSchema
expected
)
{
PRECOND
(
schema
==
expected
,
"Type mismatch when using DynamicStruct::Builder::as()."
);
}
DynamicValue
::
Reader
DynamicStruct
::
Reader
::
get
(
StructSchema
::
Member
member
)
{
...
...
c++/src/capnproto/dynamic.h
View file @
b731cf8f
...
...
@@ -267,7 +267,7 @@ private:
inline
Reader
(
StructSchema
schema
,
internal
::
StructReader
reader
)
:
schema
(
schema
),
reader
(
reader
)
{}
void
verify
TypeId
(
uint64_t
i
d
);
void
verify
Schema
(
StructSchema
expecte
d
);
static
DynamicValue
::
Reader
getImpl
(
internal
::
StructReader
reader
,
StructSchema
::
Member
member
);
...
...
@@ -344,7 +344,7 @@ private:
inline
Builder
(
StructSchema
schema
,
internal
::
StructBuilder
builder
)
:
schema
(
schema
),
builder
(
builder
)
{}
void
verify
TypeId
(
uint64_t
i
d
);
void
verify
Schema
(
StructSchema
expecte
d
);
static
DynamicValue
::
Builder
getImpl
(
internal
::
StructBuilder
builder
,
StructSchema
::
Member
member
);
...
...
@@ -858,14 +858,14 @@ template <typename T>
typename
T
::
Reader
DynamicStruct
::
Reader
::
as
()
{
static_assert
(
kind
<
T
>
()
==
Kind
::
STRUCT
,
"DynamicStruct::Reader::as<T>() can only convert to struct types."
);
verify
TypeId
(
typeId
<
T
>
());
verify
Schema
(
Schema
::
from
<
T
>
());
return
typename
T
::
Reader
(
reader
);
}
template
<
typename
T
>
typename
T
::
Builder
DynamicStruct
::
Builder
::
as
()
{
static_assert
(
kind
<
T
>
()
==
Kind
::
STRUCT
,
"DynamicStruct::Builder::as<T>() can only convert to struct types."
);
verify
TypeId
(
typeId
<
T
>
());
verify
Schema
(
Schema
::
from
<
T
>
());
return
typename
T
::
Builder
(
builder
);
}
...
...
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