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
20272ec5
Commit
20272ec5
authored
Jun 01, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PRECOND -> REQUIRE
parent
5b65179c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
109 additions
and
112 deletions
+109
-112
capnproto-common.h
c++/src/capnproto/benchmark/capnproto-common.h
+1
-1
blob.h
c++/src/capnproto/blob.h
+5
-5
capnpc-capnp.c++
c++/src/capnproto/compiler/capnpc-capnp.c++
+9
-9
dynamic.c++
c++/src/capnproto/dynamic.c++
+0
-0
layout.c++
c++/src/capnproto/layout.c++
+14
-14
message.c++
c++/src/capnproto/message.c++
+4
-4
schema-loader.c++
c++/src/capnproto/schema-loader.c++
+4
-4
schema.c++
c++/src/capnproto/schema.c++
+18
-18
serialize-packed.c++
c++/src/capnproto/serialize-packed.c++
+3
-3
serialize.c++
c++/src/capnproto/serialize.c++
+2
-2
array.h
c++/src/kj/array.h
+6
-6
common.c++
c++/src/kj/common.c++
+2
-2
common.h
c++/src/kj/common.h
+11
-14
exception.c++
c++/src/kj/exception.c++
+1
-1
io.c++
c++/src/kj/io.c++
+1
-1
logging-test.c++
c++/src/kj/logging-test.c++
+1
-1
logging.h
c++/src/kj/logging.h
+10
-10
string.h
c++/src/kj/string.h
+1
-1
c++-header.mustache
compiler/src/c++-header.mustache
+16
-16
No files found.
c++/src/capnproto/benchmark/capnproto-common.h
View file @
20272ec5
...
...
@@ -181,7 +181,7 @@ struct UseScratch {
word
*
words
;
ScratchSpace
()
{
PRECOND
(
scratchCounter
<
6
,
"Too many scratch spaces needed at once."
);
REQUIRE
(
scratchCounter
<
6
,
"Too many scratch spaces needed at once."
);
words
=
scratchSpace
+
scratchCounter
++
*
SCRATCH_SIZE
;
}
~
ScratchSpace
()
{
...
...
c++/src/capnproto/blob.h
View file @
20272ec5
...
...
@@ -76,7 +76,7 @@ public:
inline
const
char
operator
[](
uint
index
)
const
{
return
bytes
[
index
];
}
inline
Reader
slice
(
uint
start
,
uint
end
)
const
{
KJ_I
NLINE_DPRECOND
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds slice."
);
KJ_I
REQUIRE
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds slice."
);
return
Reader
(
bytes
+
start
,
end
-
start
);
}
...
...
@@ -121,13 +121,13 @@ public:
inline
Reader
(
const
char
*
text
)
:
Data
::
Reader
(
text
,
strlen
(
text
))
{}
inline
Reader
(
char
*
text
)
:
Data
::
Reader
(
text
,
strlen
(
text
))
{}
inline
Reader
(
const
char
*
text
,
uint
size
)
:
Data
::
Reader
(
text
,
size
)
{
KJ_I
NLINE_DPRECOND
(
text
[
size
]
==
'\0'
,
"Text must be NUL-terminated."
);
KJ_I
REQUIRE
(
text
[
size
]
==
'\0'
,
"Text must be NUL-terminated."
);
}
template
<
typename
T
>
inline
Reader
(
const
T
&
other
)
:
Data
::
Reader
(
other
.
c_str
(),
other
.
size
())
{
// Primarily intended for converting from std::string.
KJ_I
NLINE_DPRECOND
(
data
()[
size
()]
==
'\0'
,
"Text must be NUL-terminated."
);
KJ_I
REQUIRE
(
data
()[
size
()]
==
'\0'
,
"Text must be NUL-terminated."
);
}
inline
const
char
*
c_str
()
const
{
return
data
();
}
...
...
@@ -164,7 +164,7 @@ public:
inline
char
&
operator
[](
uint
index
)
const
{
return
bytes
[
index
];
}
inline
Builder
slice
(
uint
start
,
uint
end
)
const
{
KJ_I
NLINE_DPRECOND
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds slice."
);
KJ_I
REQUIRE
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds slice."
);
return
Builder
(
bytes
+
start
,
end
-
start
);
}
...
...
@@ -183,7 +183,7 @@ public:
template
<
typename
T
>
inline
void
copyFrom
(
const
T
&
other
)
const
{
KJ_I
NLINE_DPRECOND
(
size
()
==
other
.
size
(),
"Sizes must match to copy."
);
KJ_I
REQUIRE
(
size
()
==
other
.
size
(),
"Sizes must match to copy."
);
memcpy
(
bytes
,
other
.
data
(),
other
.
size
());
}
inline
void
copyFrom
(
const
void
*
other
)
const
{
...
...
c++/src/capnproto/compiler/capnpc-capnp.c++
View file @
20272ec5
...
...
@@ -217,7 +217,7 @@ Text::Reader getUnqualifiedName(Schema schema) {
return
nested
.
getName
();
}
}
FAIL_
PRECOND
(
"A schema Node's supposed scope did not contain the node as a NestedNode."
);
FAIL_
REQUIRE
(
"A schema Node's supposed scope did not contain the node as a NestedNode."
);
return
"(?)"
;
}
...
...
@@ -365,22 +365,22 @@ TextBlob genValue(schema::Type::Reader type, schema::Value::Reader value, Schema
case
schema
:
:
Value
::
Body
::
TEXT_VALUE
:
return
text
(
DynamicValue
::
Reader
(
body
.
getTextValue
()));
case
schema
:
:
Value
::
Body
::
DATA_VALUE
:
return
text
(
DynamicValue
::
Reader
(
body
.
getDataValue
()));
case
schema
:
:
Value
::
Body
::
LIST_VALUE
:
{
PRECOND
(
type
.
getBody
().
which
()
==
schema
::
Type
::
Body
::
LIST_TYPE
,
"type/value mismatch"
);
REQUIRE
(
type
.
getBody
().
which
()
==
schema
::
Type
::
Body
::
LIST_TYPE
,
"type/value mismatch"
);
auto
value
=
body
.
getListValue
<
DynamicList
>
(
ListSchema
::
of
(
type
.
getBody
().
getListType
(),
scope
));
return
text
(
value
);
}
case
schema
:
:
Value
::
Body
::
ENUM_VALUE
:
{
PRECOND
(
type
.
getBody
().
which
()
==
schema
::
Type
::
Body
::
ENUM_TYPE
,
"type/value mismatch"
);
REQUIRE
(
type
.
getBody
().
which
()
==
schema
::
Type
::
Body
::
ENUM_TYPE
,
"type/value mismatch"
);
auto
enumNode
=
scope
.
getDependency
(
type
.
getBody
().
getEnumType
()).
asEnum
().
getProto
();
auto
enumType
=
enumNode
.
getBody
().
getEnumNode
();
auto
enumerants
=
enumType
.
getEnumerants
();
PRECOND
(
body
.
getEnumValue
()
<
enumerants
.
size
(),
REQUIRE
(
body
.
getEnumValue
()
<
enumerants
.
size
(),
"Enum value out-of-range."
,
body
.
getEnumValue
(),
enumNode
.
getDisplayName
());
return
text
(
enumerants
[
body
.
getEnumValue
()].
getName
());
}
case
schema
:
:
Value
::
Body
::
STRUCT_VALUE
:
{
PRECOND
(
type
.
getBody
().
which
()
==
schema
::
Type
::
Body
::
STRUCT_TYPE
,
"type/value mismatch"
);
REQUIRE
(
type
.
getBody
().
which
()
==
schema
::
Type
::
Body
::
STRUCT_TYPE
,
"type/value mismatch"
);
auto
value
=
body
.
getStructValue
<
DynamicStruct
>
(
scope
.
getDependency
(
type
.
getBody
().
getStructType
()).
asStruct
());
return
text
(
value
);
...
...
@@ -400,7 +400,7 @@ TextBlob genAnnotation(schema::Annotation::Reader annotation,
const
char
*
prefix
=
" "
,
const
char
*
suffix
=
""
)
{
auto
decl
=
schemaLoader
.
get
(
annotation
.
getId
());
auto
body
=
decl
.
getProto
().
getBody
();
PRECOND
(
body
.
which
()
==
schema
::
Node
::
Body
::
ANNOTATION_NODE
);
REQUIRE
(
body
.
which
()
==
schema
::
Node
::
Body
::
ANNOTATION_NODE
);
auto
annDecl
=
body
.
getAnnotationNode
();
return
text
(
prefix
,
"$"
,
nodeName
(
decl
,
scope
),
"("
,
...
...
@@ -468,12 +468,12 @@ TextBlob genDecl(Schema schema, Text::Reader name, uint64_t scopeId, Indent inde
auto
proto
=
schema
.
getProto
();
if
(
proto
.
getScopeId
()
!=
scopeId
)
{
// This appears to be an alias for something declared elsewhere.
FAIL_
PRECOND
(
"Aliases not implemented."
);
FAIL_
REQUIRE
(
"Aliases not implemented."
);
}
switch
(
proto
.
getBody
().
which
())
{
case
schema
:
:
Node
::
Body
::
FILE_NODE
:
FAIL_
PRECOND
(
"Encountered nested file node."
);
FAIL_
REQUIRE
(
"Encountered nested file node."
);
break
;
case
schema
:
:
Node
::
Body
::
STRUCT_NODE
:
{
auto
body
=
proto
.
getBody
().
getStructNode
();
...
...
@@ -578,7 +578,7 @@ TextBlob genNestedDecls(Schema schema, Indent indent) {
TextBlob
genFile
(
Schema
file
)
{
auto
proto
=
file
.
getProto
();
auto
body
=
proto
.
getBody
();
PRECOND
(
body
.
which
()
==
schema
::
Node
::
Body
::
FILE_NODE
,
"Expected a file node."
,
REQUIRE
(
body
.
which
()
==
schema
::
Node
::
Body
::
FILE_NODE
,
"Expected a file node."
,
(
uint
)
body
.
which
());
return
text
(
...
...
c++/src/capnproto/dynamic.c++
View file @
20272ec5
This diff is collapsed.
Click to expand it.
c++/src/capnproto/layout.c++
View file @
20272ec5
...
...
@@ -102,12 +102,12 @@ struct WirePointer {
}
KJ_ALWAYS_INLINE
(
WordCount
farPositionInSegment
()
const
)
{
D
PRECOND
(
kind
()
==
FAR
,
D
REQUIRE
(
kind
()
==
FAR
,
"positionInSegment() should only be called on FAR pointers."
);
return
(
offsetAndKind
.
get
()
>>
3
)
*
WORDS
;
}
KJ_ALWAYS_INLINE
(
bool
isDoubleFar
()
const
)
{
D
PRECOND
(
kind
()
==
FAR
,
D
REQUIRE
(
kind
()
==
FAR
,
"isDoubleFar() should only be called on FAR pointers."
);
return
(
offsetAndKind
.
get
()
>>
2
)
&
1
;
}
...
...
@@ -155,12 +155,12 @@ struct WirePointer {
}
KJ_ALWAYS_INLINE
(
void
set
(
FieldSize
es
,
ElementCount
ec
))
{
D
PRECOND
(
ec
<
(
1
<<
29
)
*
ELEMENTS
,
"Lists are limited to 2**29 elements."
);
D
REQUIRE
(
ec
<
(
1
<<
29
)
*
ELEMENTS
,
"Lists are limited to 2**29 elements."
);
elementSizeAndCount
.
set
(((
ec
/
ELEMENTS
)
<<
3
)
|
static_cast
<
int
>
(
es
));
}
KJ_ALWAYS_INLINE
(
void
setInlineComposite
(
WordCount
wc
))
{
D
PRECOND
(
wc
<
(
1
<<
29
)
*
WORDS
,
"Inline composite lists are limited to 2**29 words."
);
D
REQUIRE
(
wc
<
(
1
<<
29
)
*
WORDS
,
"Inline composite lists are limited to 2**29 words."
);
elementSizeAndCount
.
set
(((
wc
/
WORDS
)
<<
3
)
|
static_cast
<
int
>
(
FieldSize
::
INLINE_COMPOSITE
));
}
...
...
@@ -656,7 +656,7 @@ struct WireHelpers {
break
;
}
default
:
FAIL_
PRECOND
(
"Copy source message contained unexpected kind."
);
FAIL_
REQUIRE
(
"Copy source message contained unexpected kind."
);
break
;
}
...
...
@@ -796,7 +796,7 @@ struct WireHelpers {
static
KJ_ALWAYS_INLINE
(
ListBuilder
initListPointer
(
WirePointer
*
ref
,
SegmentBuilder
*
segment
,
ElementCount
elementCount
,
FieldSize
elementSize
))
{
D
PRECOND
(
elementSize
!=
FieldSize
::
INLINE_COMPOSITE
,
D
REQUIRE
(
elementSize
!=
FieldSize
::
INLINE_COMPOSITE
,
"Should have called initStructListPointer() instead."
);
BitCount
dataSize
=
dataBitsPerElement
(
elementSize
)
*
ELEMENTS
;
...
...
@@ -848,7 +848,7 @@ struct WireHelpers {
static
KJ_ALWAYS_INLINE
(
ListBuilder
getWritableListPointer
(
WirePointer
*
origRef
,
SegmentBuilder
*
origSegment
,
FieldSize
elementSize
,
const
word
*
defaultValue
))
{
D
PRECOND
(
elementSize
!=
FieldSize
::
INLINE_COMPOSITE
,
D
REQUIRE
(
elementSize
!=
FieldSize
::
INLINE_COMPOSITE
,
"Use getStructList{Element,Field}() for structs."
);
if
(
origRef
->
isNull
())
{
...
...
@@ -886,7 +886,7 @@ struct WireHelpers {
// Read the tag to get the actual element count.
WirePointer
*
tag
=
reinterpret_cast
<
WirePointer
*>
(
ptr
);
PRECOND
(
tag
->
kind
()
==
WirePointer
::
STRUCT
,
REQUIRE
(
tag
->
kind
()
==
WirePointer
::
STRUCT
,
"INLINE_COMPOSITE list with non-STRUCT elements not supported."
);
ptr
+=
POINTER_SIZE_IN_WORDS
;
...
...
@@ -1226,9 +1226,9 @@ struct WireHelpers {
}
else
{
word
*
ptr
=
followFars
(
ref
,
segment
);
PRECOND
(
ref
->
kind
()
==
WirePointer
::
LIST
,
REQUIRE
(
ref
->
kind
()
==
WirePointer
::
LIST
,
"Called getText{Field,Element}() but existing pointer is not a list."
);
PRECOND
(
ref
->
listRef
.
elementSize
()
==
FieldSize
::
BYTE
,
REQUIRE
(
ref
->
listRef
.
elementSize
()
==
FieldSize
::
BYTE
,
"Called getText{Field,Element}() but existing list pointer is not byte-sized."
);
// Subtract 1 from the size for the NUL terminator.
...
...
@@ -1263,9 +1263,9 @@ struct WireHelpers {
}
else
{
word
*
ptr
=
followFars
(
ref
,
segment
);
PRECOND
(
ref
->
kind
()
==
WirePointer
::
LIST
,
REQUIRE
(
ref
->
kind
()
==
WirePointer
::
LIST
,
"Called getData{Field,Element}() but existing pointer is not a list."
);
PRECOND
(
ref
->
listRef
.
elementSize
()
==
FieldSize
::
BYTE
,
REQUIRE
(
ref
->
listRef
.
elementSize
()
==
FieldSize
::
BYTE
,
"Called getData{Field,Element}() but existing list pointer is not byte-sized."
);
return
Data
::
Builder
(
reinterpret_cast
<
char
*>
(
ptr
),
ref
->
listRef
.
elementCount
()
/
ELEMENTS
);
...
...
@@ -1291,7 +1291,7 @@ struct WireHelpers {
if
(
ref
->
listRef
.
elementSize
()
==
FieldSize
::
INLINE_COMPOSITE
)
{
// Read the tag to get the actual element count.
WirePointer
*
tag
=
reinterpret_cast
<
WirePointer
*>
(
ptr
);
PRECOND
(
tag
->
kind
()
==
WirePointer
::
STRUCT
,
REQUIRE
(
tag
->
kind
()
==
WirePointer
::
STRUCT
,
"INLINE_COMPOSITE list with non-STRUCT elements not supported."
);
// First list element is at tag + 1 pointer.
...
...
@@ -1951,7 +1951,7 @@ ObjectReader StructReader::getObjectField(
}
const
word
*
StructReader
::
getUncheckedPointer
(
WirePointerCount
ptrIndex
)
const
{
PRECOND
(
segment
==
nullptr
,
"getUncheckedPointer() only allowed on unchecked messages."
);
REQUIRE
(
segment
==
nullptr
,
"getUncheckedPointer() only allowed on unchecked messages."
);
return
reinterpret_cast
<
const
word
*>
(
pointers
+
ptrIndex
);
}
...
...
c++/src/capnproto/message.c++
View file @
20272ec5
...
...
@@ -146,10 +146,10 @@ MallocMessageBuilder::MallocMessageBuilder(
kj
::
ArrayPtr
<
word
>
firstSegment
,
AllocationStrategy
allocationStrategy
)
:
nextSize
(
firstSegment
.
size
()),
allocationStrategy
(
allocationStrategy
),
ownFirstSegment
(
false
),
returnedFirstSegment
(
false
),
firstSegment
(
firstSegment
.
begin
())
{
PRECOND
(
firstSegment
.
size
()
>
0
,
"First segment size must be non-zero."
);
REQUIRE
(
firstSegment
.
size
()
>
0
,
"First segment size must be non-zero."
);
// Checking just the first word should catch most cases of failing to zero the segment.
PRECOND
(
*
reinterpret_cast
<
uint64_t
*>
(
firstSegment
.
begin
())
==
0
,
REQUIRE
(
*
reinterpret_cast
<
uint64_t
*>
(
firstSegment
.
begin
())
==
0
,
"First segment must be zeroed."
);
}
...
...
@@ -218,12 +218,12 @@ FlatMessageBuilder::FlatMessageBuilder(kj::ArrayPtr<word> array): array(array),
FlatMessageBuilder
::~
FlatMessageBuilder
()
{}
void
FlatMessageBuilder
::
requireFilled
()
{
PRECOND
(
getSegmentsForOutput
()[
0
].
end
()
==
array
.
end
(),
REQUIRE
(
getSegmentsForOutput
()[
0
].
end
()
==
array
.
end
(),
"FlatMessageBuilder's buffer was too large."
);
}
kj
::
ArrayPtr
<
word
>
FlatMessageBuilder
::
allocateSegment
(
uint
minimumSize
)
{
PRECOND
(
!
allocated
,
"FlatMessageBuilder's buffer was not large enough."
);
REQUIRE
(
!
allocated
,
"FlatMessageBuilder's buffer was not large enough."
);
allocated
=
true
;
return
array
;
}
...
...
c++/src/capnproto/schema-loader.c++
View file @
20272ec5
...
...
@@ -447,7 +447,7 @@ public:
CONTEXT
(
"checking compatibility with previously-loaded node of the same id"
,
existingNode
.
getDisplayName
());
D
PRECOND
(
existingNode
.
getId
()
==
replacement
.
getId
());
D
REQUIRE
(
existingNode
.
getId
()
==
replacement
.
getId
());
nodeName
=
existingNode
.
getDisplayName
();
compatibility
=
EQUIVALENT
;
...
...
@@ -1026,7 +1026,7 @@ internal::RawSchema* SchemaLoader::Impl::loadNative(const internal::RawSchema* n
if
(
slot
==
nullptr
)
{
slot
=
allocate
<
internal
::
RawSchema
>
();
}
else
if
(
slot
->
canCastTo
!=
nullptr
)
{
PRECOND
(
slot
->
canCastTo
==
nativeSchema
,
REQUIRE
(
slot
->
canCastTo
==
nativeSchema
,
"two different compiled-in type have the same type ID"
,
reader
.
getId
(),
reader
.
getDisplayName
(),
readMessageUnchecked
<
schema
::
Node
>
(
slot
->
canCastTo
->
encodedNode
).
getDisplayName
());
...
...
@@ -1079,7 +1079,7 @@ internal::RawSchema* SchemaLoader::Impl::loadEmpty(
case
schema
:
:
Node
::
Body
::
FILE_NODE
:
case
schema
:
:
Node
::
Body
::
CONST_NODE
:
case
schema
:
:
Node
::
Body
::
ANNOTATION_NODE
:
FAIL_
PRECOND
(
"Not a type."
);
FAIL_
REQUIRE
(
"Not a type."
);
break
;
}
...
...
@@ -1111,7 +1111,7 @@ SchemaLoader::~SchemaLoader() {}
Schema
SchemaLoader
::
get
(
uint64_t
id
)
const
{
internal
::
RawSchema
*
raw
=
impl
->
tryGet
(
id
);
PRECOND
(
raw
!=
nullptr
,
"no schema node loaded for id"
,
id
);
REQUIRE
(
raw
!=
nullptr
,
"no schema node loaded for id"
,
id
);
return
Schema
(
raw
);
}
...
...
c++/src/capnproto/schema.c++
View file @
20272ec5
...
...
@@ -51,33 +51,33 @@ Schema Schema::getDependency(uint64_t id) const {
}
}
FAIL_
PRECOND
(
"Requested ID not found in dependency table."
,
id
);
FAIL_
REQUIRE
(
"Requested ID not found in dependency table."
,
id
);
return
Schema
();
}
StructSchema
Schema
::
asStruct
()
const
{
PRECOND
(
getProto
().
getBody
().
which
()
==
schema
::
Node
::
Body
::
STRUCT_NODE
,
REQUIRE
(
getProto
().
getBody
().
which
()
==
schema
::
Node
::
Body
::
STRUCT_NODE
,
"Tried to use non-struct schema as a struct."
,
getProto
().
getDisplayName
());
return
StructSchema
(
raw
);
}
EnumSchema
Schema
::
asEnum
()
const
{
PRECOND
(
getProto
().
getBody
().
which
()
==
schema
::
Node
::
Body
::
ENUM_NODE
,
REQUIRE
(
getProto
().
getBody
().
which
()
==
schema
::
Node
::
Body
::
ENUM_NODE
,
"Tried to use non-enum schema as an enum."
,
getProto
().
getDisplayName
());
return
EnumSchema
(
raw
);
}
InterfaceSchema
Schema
::
asInterface
()
const
{
PRECOND
(
getProto
().
getBody
().
which
()
==
schema
::
Node
::
Body
::
INTERFACE_NODE
,
REQUIRE
(
getProto
().
getBody
().
which
()
==
schema
::
Node
::
Body
::
INTERFACE_NODE
,
"Tried to use non-interface schema as an interface."
,
getProto
().
getDisplayName
());
return
InterfaceSchema
(
raw
);
}
void
Schema
::
requireUsableAs
(
const
internal
::
RawSchema
*
expected
)
{
PRECOND
(
raw
==
expected
||
REQUIRE
(
raw
==
expected
||
(
raw
!=
nullptr
&&
expected
!=
nullptr
&&
raw
->
canCastTo
==
expected
),
"This schema is not compatible with the requested native type."
);
}
...
...
@@ -132,7 +132,7 @@ StructSchema::Member StructSchema::getMemberByName(Text::Reader name) const {
KJ_IF_MAYBE
(
member
,
findMemberByName
(
name
))
{
return
*
member
;
}
else
{
FAIL_
PRECOND
(
"struct has no such member"
,
name
);
FAIL_
REQUIRE
(
"struct has no such member"
,
name
);
}
}
...
...
@@ -142,7 +142,7 @@ kj::Maybe<StructSchema::Union> StructSchema::Member::getContainingUnion() const
}
StructSchema
::
Union
StructSchema
::
Member
::
asUnion
()
const
{
PRECOND
(
proto
.
getBody
().
which
()
==
schema
::
StructNode
::
Member
::
Body
::
UNION_MEMBER
,
REQUIRE
(
proto
.
getBody
().
which
()
==
schema
::
StructNode
::
Member
::
Body
::
UNION_MEMBER
,
"Tried to use non-union struct member as a union."
,
parent
.
getProto
().
getDisplayName
(),
proto
.
getName
());
return
Union
(
*
this
);
...
...
@@ -160,7 +160,7 @@ StructSchema::Member StructSchema::Union::getMemberByName(Text::Reader name) con
KJ_IF_MAYBE
(
member
,
findMemberByName
(
name
))
{
return
*
member
;
}
else
{
FAIL_
PRECOND
(
"union has no such member"
,
name
);
FAIL_
REQUIRE
(
"union has no such member"
,
name
);
}
}
...
...
@@ -178,7 +178,7 @@ EnumSchema::Enumerant EnumSchema::getEnumerantByName(Text::Reader name) const {
KJ_IF_MAYBE
(
enumerant
,
findEnumerantByName
(
name
))
{
return
*
enumerant
;
}
else
{
FAIL_
PRECOND
(
"enum has no such enumerant"
,
name
);
FAIL_
REQUIRE
(
"enum has no such enumerant"
,
name
);
}
}
...
...
@@ -196,7 +196,7 @@ InterfaceSchema::Method InterfaceSchema::getMethodByName(Text::Reader name) cons
KJ_IF_MAYBE
(
method
,
findMethodByName
(
name
))
{
return
*
method
;
}
else
{
FAIL_
PRECOND
(
"interface has no such method"
,
name
);
FAIL_
REQUIRE
(
"interface has no such method"
,
name
);
}
}
...
...
@@ -224,11 +224,11 @@ ListSchema ListSchema::of(schema::Type::Body::Which primitiveType) {
case
schema
:
:
Type
::
Body
::
ENUM_TYPE
:
case
schema
:
:
Type
::
Body
::
INTERFACE_TYPE
:
case
schema
:
:
Type
::
Body
::
LIST_TYPE
:
FAIL_
PRECOND
(
"Must use one of the other ListSchema::of() overloads for complex types."
);
FAIL_
REQUIRE
(
"Must use one of the other ListSchema::of() overloads for complex types."
);
break
;
case
schema
:
:
Type
::
Body
::
OBJECT_TYPE
:
FAIL_
PRECOND
(
"List(Object) not supported."
);
FAIL_
REQUIRE
(
"List(Object) not supported."
);
break
;
}
...
...
@@ -267,7 +267,7 @@ ListSchema ListSchema::of(schema::Type::Reader elementType, Schema context) {
return
of
(
of
(
body
.
getListType
(),
context
));
case
schema
:
:
Type
::
Body
::
OBJECT_TYPE
:
FAIL_
PRECOND
(
"List(Object) not supported."
);
FAIL_
REQUIRE
(
"List(Object) not supported."
);
return
ListSchema
();
}
...
...
@@ -276,31 +276,31 @@ ListSchema ListSchema::of(schema::Type::Reader elementType, Schema context) {
}
StructSchema
ListSchema
::
getStructElementType
()
const
{
PRECOND
(
nestingDepth
==
0
&&
elementType
==
schema
::
Type
::
Body
::
STRUCT_TYPE
,
REQUIRE
(
nestingDepth
==
0
&&
elementType
==
schema
::
Type
::
Body
::
STRUCT_TYPE
,
"ListSchema::getStructElementType(): The elements are not structs."
);
return
elementSchema
.
asStruct
();
}
EnumSchema
ListSchema
::
getEnumElementType
()
const
{
PRECOND
(
nestingDepth
==
0
&&
elementType
==
schema
::
Type
::
Body
::
ENUM_TYPE
,
REQUIRE
(
nestingDepth
==
0
&&
elementType
==
schema
::
Type
::
Body
::
ENUM_TYPE
,
"ListSchema::getEnumElementType(): The elements are not enums."
);
return
elementSchema
.
asEnum
();
}
InterfaceSchema
ListSchema
::
getInterfaceElementType
()
const
{
PRECOND
(
nestingDepth
==
0
&&
elementType
==
schema
::
Type
::
Body
::
INTERFACE_TYPE
,
REQUIRE
(
nestingDepth
==
0
&&
elementType
==
schema
::
Type
::
Body
::
INTERFACE_TYPE
,
"ListSchema::getInterfaceElementType(): The elements are not interfaces."
);
return
elementSchema
.
asInterface
();
}
ListSchema
ListSchema
::
getListElementType
()
const
{
PRECOND
(
nestingDepth
>
0
,
REQUIRE
(
nestingDepth
>
0
,
"ListSchema::getListElementType(): The elements are not lists."
);
return
ListSchema
(
elementType
,
nestingDepth
-
1
,
elementSchema
);
}
void
ListSchema
::
requireUsableAs
(
ListSchema
expected
)
{
PRECOND
(
elementType
==
expected
.
elementType
&&
nestingDepth
==
expected
.
nestingDepth
,
REQUIRE
(
elementType
==
expected
.
elementType
&&
nestingDepth
==
expected
.
nestingDepth
,
"This schema is not compatible with the requested native type."
);
elementSchema
.
requireUsableAs
(
expected
.
elementSchema
.
raw
);
}
...
...
c++/src/capnproto/serialize-packed.c++
View file @
20272ec5
...
...
@@ -39,8 +39,8 @@ size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) {
return
0
;
}
D
PRECOND
(
minBytes
%
sizeof
(
word
)
==
0
,
"PackedInputStream reads must be word-aligned."
);
D
PRECOND
(
maxBytes
%
sizeof
(
word
)
==
0
,
"PackedInputStream reads must be word-aligned."
);
D
REQUIRE
(
minBytes
%
sizeof
(
word
)
==
0
,
"PackedInputStream reads must be word-aligned."
);
D
REQUIRE
(
maxBytes
%
sizeof
(
word
)
==
0
,
"PackedInputStream reads must be word-aligned."
);
uint8_t
*
__restrict__
out
=
reinterpret_cast
<
uint8_t
*>
(
dst
);
uint8_t
*
const
outEnd
=
reinterpret_cast
<
uint8_t
*>
(
dst
)
+
maxBytes
;
...
...
@@ -190,7 +190,7 @@ void PackedInputStream::skip(size_t bytes) {
return
;
}
D
PRECOND
(
bytes
%
sizeof
(
word
)
==
0
,
"PackedInputStream reads must be word-aligned."
);
D
REQUIRE
(
bytes
%
sizeof
(
word
)
==
0
,
"PackedInputStream reads must be word-aligned."
);
kj
::
ArrayPtr
<
const
byte
>
buffer
=
inner
.
getReadBuffer
();
const
uint8_t
*
__restrict__
in
=
reinterpret_cast
<
const
uint8_t
*>
(
buffer
.
begin
());
...
...
c++/src/capnproto/serialize.c++
View file @
20272ec5
...
...
@@ -88,7 +88,7 @@ kj::ArrayPtr<const word> FlatArrayMessageReader::getSegment(uint id) {
}
kj
::
Array
<
word
>
messageToFlatArray
(
kj
::
ArrayPtr
<
const
kj
::
ArrayPtr
<
const
word
>>
segments
)
{
PRECOND
(
segments
.
size
()
>
0
,
"Tried to serialize uninitialized message."
);
REQUIRE
(
segments
.
size
()
>
0
,
"Tried to serialize uninitialized message."
);
size_t
totalSize
=
segments
.
size
()
/
2
+
1
;
...
...
@@ -237,7 +237,7 @@ kj::ArrayPtr<const word> InputStreamMessageReader::getSegment(uint id) {
// -------------------------------------------------------------------
void
writeMessage
(
kj
::
OutputStream
&
output
,
kj
::
ArrayPtr
<
const
kj
::
ArrayPtr
<
const
word
>>
segments
)
{
PRECOND
(
segments
.
size
()
>
0
,
"Tried to serialize uninitialized message."
);
REQUIRE
(
segments
.
size
()
>
0
,
"Tried to serialize uninitialized message."
);
internal
::
WireValue
<
uint32_t
>
table
[(
segments
.
size
()
+
2
)
&
~
size_t
(
1
)];
...
...
c++/src/kj/array.h
View file @
20272ec5
...
...
@@ -94,7 +94,7 @@ public:
inline
size_t
size
()
const
{
return
size_
;
}
inline
T
&
operator
[](
size_t
index
)
const
{
KJ_I
NLINE_DPRECOND
(
index
<
size_
,
"Out-of-bounds Array access."
);
KJ_I
REQUIRE
(
index
<
size_
,
"Out-of-bounds Array access."
);
return
ptr
[
index
];
}
...
...
@@ -108,11 +108,11 @@ public:
inline
T
&
back
()
{
return
*
(
ptr
+
size_
-
1
);
}
inline
ArrayPtr
<
T
>
slice
(
size_t
start
,
size_t
end
)
{
KJ_I
NLINE_DPRECOND
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds Array::slice()."
);
KJ_I
REQUIRE
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds Array::slice()."
);
return
ArrayPtr
<
T
>
(
ptr
+
start
,
end
-
start
);
}
inline
ArrayPtr
<
const
T
>
slice
(
size_t
start
,
size_t
end
)
const
{
KJ_I
NLINE_DPRECOND
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds Array::slice()."
);
KJ_I
REQUIRE
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds Array::slice()."
);
return
ArrayPtr
<
const
T
>
(
ptr
+
start
,
end
-
start
);
}
...
...
@@ -235,7 +235,7 @@ public:
inline
size_t
size
()
const
{
return
pos
-
ptr
;
}
inline
size_t
capacity
()
const
{
return
endPtr
-
ptr
;
}
inline
T
&
operator
[](
size_t
index
)
const
{
KJ_I
NLINE_DPRECOND
(
index
<
pos
-
ptr
,
"Out-of-bounds Array access."
);
KJ_I
REQUIRE
(
index
<
pos
-
ptr
,
"Out-of-bounds Array access."
);
return
ptr
[
index
];
}
...
...
@@ -266,7 +266,7 @@ public:
template
<
typename
...
Params
>
void
add
(
Params
&&
...
params
)
{
KJ_I
NLINE_DPRECOND
(
pos
<
endPtr
,
"Added too many elements to ArrayBuilder."
);
KJ_I
REQUIRE
(
pos
<
endPtr
,
"Added too many elements to ArrayBuilder."
);
ctor
(
*
pos
,
kj
::
fwd
<
Params
>
(
params
)...);
++
pos
;
}
...
...
@@ -286,7 +286,7 @@ public:
// arbitrary disposers with ArrayBuilder in the future, and anyway this check might catch bugs.
// Probably we should just create a new Vector-like data structure if we want to allow building
// of arrays without knowing the final size in advance.
KJ_I
NLINE_DPRECOND
(
pos
==
endPtr
,
"ArrayBuilder::finish() called prematurely."
);
KJ_I
REQUIRE
(
pos
==
endPtr
,
"ArrayBuilder::finish() called prematurely."
);
Array
<
T
>
result
(
reinterpret_cast
<
T
*>
(
ptr
),
pos
-
ptr
,
internal
::
HeapArrayDisposer
::
instance
);
ptr
=
nullptr
;
pos
=
nullptr
;
...
...
c++/src/kj/common.c++
View file @
20272ec5
...
...
@@ -27,8 +27,8 @@
namespace
kj
{
namespace
internal
{
void
inline
Precondition
Failure
(
const
char
*
file
,
int
line
,
const
char
*
expectation
,
const
char
*
macroArgs
,
const
char
*
message
)
{
void
inline
Require
Failure
(
const
char
*
file
,
int
line
,
const
char
*
expectation
,
const
char
*
macroArgs
,
const
char
*
message
)
{
if
(
message
==
nullptr
)
{
Log
::
fatalFault
(
file
,
line
,
Exception
::
Nature
::
PRECONDITION
,
expectation
,
macroArgs
);
}
else
{
...
...
c++/src/kj/common.h
View file @
20272ec5
...
...
@@ -113,24 +113,22 @@ typedef unsigned char byte;
namespace
internal
{
void
inline
Precondition
Failure
(
void
inline
Require
Failure
(
const
char
*
file
,
int
line
,
const
char
*
expectation
,
const
char
*
macroArgs
,
const
char
*
message
=
nullptr
)
KJ_NORETURN
;
}
// namespace internal
#define KJ_INLINE_PRECOND(condition, ...) \
if (KJ_EXPECT_TRUE(condition)); else ::kj::internal::inlinePreconditionFailure( \
#ifdef NDEBUG
#define KJ_IREQUIRE(condition, ...)
#else
#define KJ_IREQUIRE(condition, ...) \
if (KJ_EXPECT_TRUE(condition)); else ::kj::internal::inlineRequireFailure( \
__FILE__, __LINE__, #condition, #__VA_ARGS__, ##__VA_ARGS__)
// Version of
PRECOND
() which is safe to use in headers that are #included by users. Used to check
// Version of
REQUIRE
() which is safe to use in headers that are #included by users. Used to check
// preconditions inside inline methods. KJ_INLINE_DPRECOND is particularly useful in that
// it will be enabled depending on whether the application is compiled in debug mode rather than
// whether libkj is.
#ifdef NDEBUG
#define KJ_INLINE_DPRECOND(...)
#else
#define KJ_INLINE_DPRECOND KJ_INLINE_PRECOND
#endif
// #define KJ_STACK_ARRAY(type, name, size, minStack, maxStack)
...
...
@@ -501,7 +499,7 @@ public:
inline
size_t
size
()
const
{
return
size_
;
}
inline
T
&
operator
[](
size_t
index
)
const
{
KJ_I
NLINE_DPRECOND
(
index
<
size_
,
"Out-of-bounds ArrayPtr access."
);
KJ_I
REQUIRE
(
index
<
size_
,
"Out-of-bounds ArrayPtr access."
);
return
ptr
[
index
];
}
...
...
@@ -511,7 +509,7 @@ public:
inline
T
&
back
()
const
{
return
*
(
ptr
+
size_
-
1
);
}
inline
ArrayPtr
slice
(
size_t
start
,
size_t
end
)
const
{
KJ_I
NLINE_DPRECOND
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds ArrayPtr::slice()."
);
KJ_I
REQUIRE
(
start
<=
end
&&
end
<=
size_
,
"Out-of-bounds ArrayPtr::slice()."
);
return
ArrayPtr
(
ptr
+
start
,
end
-
start
);
}
...
...
@@ -578,9 +576,8 @@ To downcast(From* from) {
}
#if !KJ_NO_RTTI
KJ_INLINE_DPRECOND
(
from
==
nullptr
||
dynamic_cast
<
To
>
(
from
)
!=
nullptr
,
"Value cannot be downcast() to requested type."
);
KJ_IREQUIRE
(
from
==
nullptr
||
dynamic_cast
<
To
>
(
from
)
!=
nullptr
,
"Value cannot be downcast() to requested type."
);
#endif
return
static_cast
<
To
>
(
from
);
...
...
c++/src/kj/exception.c++
View file @
20272ec5
...
...
@@ -174,7 +174,7 @@ void ExceptionCallback::logMessage(StringPtr text) {
}
void
ExceptionCallback
::
useProcessWide
()
{
RECOVERABLE_
PRECOND
(
globalCallback
==
nullptr
,
RECOVERABLE_
REQUIRE
(
globalCallback
==
nullptr
,
"Can't register multiple global ExceptionCallbacks at once."
)
{
return
;
}
...
...
c++/src/kj/io.c++
View file @
20272ec5
...
...
@@ -217,7 +217,7 @@ void ArrayOutputStream::write(const void* src, size_t size) {
// Oh goody, the caller wrote directly into our buffer.
fillPos
+=
size
;
}
else
{
PRECOND
(
size
<=
(
size_t
)(
array
.
end
()
-
fillPos
),
REQUIRE
(
size
<=
(
size_t
)(
array
.
end
()
-
fillPos
),
"ArrayOutputStream's backing array was not large enough for the data written."
);
memcpy
(
fillPos
,
src
,
size
);
fillPos
+=
size
;
...
...
c++/src/kj/logging-test.c++
View file @
20272ec5
...
...
@@ -123,7 +123,7 @@ TEST(Logging, Log) {
"1 == 2; i = 123; hi; str = foo
\n
"
,
mockCallback
.
text
);
mockCallback
.
text
.
clear
();
EXPECT_THROW
(
PRECOND
(
1
==
2
,
i
,
"hi"
,
str
),
MockException
);
line
=
__LINE__
;
EXPECT_THROW
(
REQUIRE
(
1
==
2
,
i
,
"hi"
,
str
),
MockException
);
line
=
__LINE__
;
EXPECT_EQ
(
"fatal exception: "
+
fileLine
(
__FILE__
,
line
)
+
": precondition not met: expected "
"1 == 2; i = 123; hi; str = foo
\n
"
,
mockCallback
.
text
);
mockCallback
.
text
.
clear
();
...
...
c++/src/kj/logging.h
View file @
20272ec5
...
...
@@ -43,7 +43,7 @@
// are disabled. This macro should be used to check for bugs in the surrounding code and its
// dependencies, but NOT to check for invalid input.
//
// * `
PRECOND(condition, ...)`: Like `CHECK` but used to check preconditions -- i.e
. to validate
// * `
REQUIRE(condition, ...)`: Like `CHECK` but used to check preconditions -- e.g
. to validate
// parameters passed from a caller. A failure indicates that the caller is buggy.
//
// * `RECOVERABLE_CHECK(condition, ...) { ... }`: Like `CHECK` except that if exceptions are
...
...
@@ -51,7 +51,7 @@
// do whatever it can to fill in dummy values so that the code can continue executing, even if
// this means the eventual output will be garbage.
//
// * `RECOVERABLE_
PRECOND(condition, ...) { ... }`: Like `RECOVERABLE_CHECK` and `PRECOND
`.
// * `RECOVERABLE_
REQUIRE(condition, ...) { ... }`: Like `RECOVERABLE_CHECK` and `REQUIRE
`.
//
// * `VALIDATE_INPUT(condition, ...) { ... }`: Like `RECOVERABLE_PRECOND` but used to validate
// input that may have come from the user or some other untrusted source. Recoverability is
...
...
@@ -228,14 +228,14 @@ ArrayPtr<const char> KJ_STRINGIFY(Log::Severity severity);
#define CHECK(...) FAULT(LOCAL_BUG, __VA_ARGS__)
#define RECOVERABLE_CHECK(...) RECOVERABLE_FAULT(LOCAL_BUG, __VA_ARGS__)
#define
PRECOND
(...) FAULT(PRECONDITION, __VA_ARGS__)
#define RECOVERABLE_
PRECOND
(...) RECOVERABLE_FAULT(PRECONDITION, __VA_ARGS__)
#define
REQUIRE
(...) FAULT(PRECONDITION, __VA_ARGS__)
#define RECOVERABLE_
REQUIRE
(...) RECOVERABLE_FAULT(PRECONDITION, __VA_ARGS__)
#define VALIDATE_INPUT(...) RECOVERABLE_FAULT(INPUT, __VA_ARGS__)
#define FAIL_CHECK(...) CHECK(false, ##__VA_ARGS__)
#define FAIL_RECOVERABLE_CHECK(...) RECOVERABLE_CHECK(false, ##__VA_ARGS__)
#define FAIL_
PRECOND(...) PRECOND
(false, ##__VA_ARGS__)
#define FAIL_RECOVERABLE_
PRECOND(...) RECOVERABLE_PRECOND
(false, ##__VA_ARGS__)
#define FAIL_
REQUIRE(...) REQUIRE
(false, ##__VA_ARGS__)
#define FAIL_RECOVERABLE_
REQUIRE(...) RECOVERABLE_REQUIRE
(false, ##__VA_ARGS__)
#define FAIL_VALIDATE_INPUT(...) VALIDATE_INPUT(false, ##__VA_ARGS__)
#define SYSCALL(call, ...) \
...
...
@@ -274,14 +274,14 @@ ArrayPtr<const char> KJ_STRINGIFY(Log::Severity severity);
#define DLOG(...) do {} while (false)
#define DCHECK(...) do {} while (false)
#define RECOVERABLE_DCHECK(...) do {} while (false)
#define D
PRECOND
(...) do {} while (false)
#define RECOVERABLE_D
PRECOND
(...) do {} while (false)
#define D
REQUIRE
(...) do {} while (false)
#define RECOVERABLE_D
REQUIRE
(...) do {} while (false)
#else
#define DLOG LOG
#define DCHECK CHECK
#define RECOVERABLE_DCHECK RECOVERABLE_CHECK
#define D
PRECOND PRECOND
#define RECOVERABLE_D
PRECOND RECOVERABLE_PRECOND
#define D
REQUIRE REQUIRE
#define RECOVERABLE_D
REQUIRE RECOVERABLE_REQUIRE
#endif
template
<
typename
...
Params
>
...
...
c++/src/kj/string.h
View file @
20272ec5
...
...
@@ -365,7 +365,7 @@ inline const char* String::end() const { return content == nullptr ? nullptr : c
inline
String
::
String
(
char
*
value
,
size_t
size
,
const
ArrayDisposer
&
disposer
)
:
content
(
value
,
size
+
1
,
disposer
)
{
KJ_I
NLINE_DPRECOND
(
value
[
size
]
==
'\0'
,
"String must be NUL-terminated."
);
KJ_I
REQUIRE
(
value
[
size
]
==
'\0'
,
"String must be NUL-terminated."
);
}
inline
String
heapString
(
const
char
*
value
)
{
...
...
compiler/src/c++-header.mustache
View file @
20272ec5
...
...
@@ -309,8 +309,8 @@ inline {{unionFullName}}::Which {{unionFullName}}::Builder::which() {
{{#
fieldIsPrimitive
}}
inline
{{
fieldType
}}
{{
typeFullName
}}
::Reader::get
{{
fieldTitleCase
}}
() {
{{#
fieldUnion
}}
KJ_I
NLINE_DPRECOND
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
KJ_I
REQUIRE
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
{{/
fieldUnion
}}
return _reader.getDataField
<
{{
fieldType
}}
>
(
{{
fieldOffset
}}
* ::capnproto::ELEMENTS
{{
fieldDefaultMask
}}
);
...
...
@@ -318,8 +318,8 @@ inline {{fieldType}} {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
inline
{{
fieldType
}}
{{
typeFullName
}}
::Builder::get
{{
fieldTitleCase
}}
() {
{{#
fieldUnion
}}
KJ_I
NLINE_DPRECOND
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
KJ_I
REQUIRE
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
{{/
fieldUnion
}}
return _builder.getDataField
<
{{
fieldType
}}
>
(
{{
fieldOffset
}}
* ::capnproto::ELEMENTS
{{
fieldDefaultMask
}}
);
...
...
@@ -346,8 +346,8 @@ inline bool {{typeFullName}}::Builder::has{{fieldTitleCase}}() {
{{^
fieldIsGenericObject
}}
inline
{{
fieldType
}}
::Reader
{{
typeFullName
}}
::Reader::get
{{
fieldTitleCase
}}
() {
{{#
fieldUnion
}}
KJ_I
NLINE_DPRECOND
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
KJ_I
REQUIRE
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
{{/
fieldUnion
}}
return ::capnproto::internal::PointerHelpers
<
{{
fieldType
}}
>
::get(
_reader,
{{
fieldOffset
}}
* ::capnproto::POINTERS
{{#
fieldDefaultBytes
}}
,
...
...
@@ -356,8 +356,8 @@ inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
inline
{{
fieldType
}}
::Builder
{{
typeFullName
}}
::Builder::get
{{
fieldTitleCase
}}
() {
{{#
fieldUnion
}}
KJ_I
NLINE_DPRECOND
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
KJ_I
REQUIRE
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
{{/
fieldUnion
}}
return ::capnproto::internal::PointerHelpers
<
{{
fieldType
}}
>
::get(
_builder,
{{
fieldOffset
}}
* ::capnproto::POINTERS
{{#
fieldDefaultBytes
}}
,
...
...
@@ -413,8 +413,8 @@ inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(
template
<typename
T
>
inline typename T::Reader
{{
typeFullName
}}
::Reader::get
{{
fieldTitleCase
}}
() {
{{#
fieldUnion
}}
KJ_I
NLINE_DPRECOND
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
KJ_I
REQUIRE
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
{{/
fieldUnion
}}
return ::capnproto::internal::PointerHelpers
<T>
::get(
_reader,
{{
fieldOffset
}}
* ::capnproto::POINTERS);
...
...
@@ -423,8 +423,8 @@ inline typename T::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
template
<typename
T
>
inline typename T::Builder
{{
typeFullName
}}
::Builder::get
{{
fieldTitleCase
}}
() {
{{#
fieldUnion
}}
KJ_I
NLINE_DPRECOND
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
KJ_I
REQUIRE
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
{{/
fieldUnion
}}
return ::capnproto::internal::PointerHelpers
<T>
::get(
_builder,
{{
fieldOffset
}}
* ::capnproto::POINTERS);
...
...
@@ -433,8 +433,8 @@ inline typename T::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
template
<typename
T
,
typename
Param
>
inline typename T::Reader
{{
typeFullName
}}
::Reader::get
{{
fieldTitleCase
}}
(Param
&&
param) {
{{#
fieldUnion
}}
KJ_I
NLINE_DPRECOND
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
KJ_I
REQUIRE
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
{{/
fieldUnion
}}
return ::capnproto::internal::PointerHelpers
<T>
::getDynamic(
_reader,
{{
fieldOffset
}}
* ::capnproto::POINTERS, ::kj::fwd
<Param>
(param));
...
...
@@ -443,8 +443,8 @@ inline typename T::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}(Param&
template
<typename
T
,
typename
Param
>
inline typename T::Builder
{{
typeFullName
}}
::Builder::get
{{
fieldTitleCase
}}
(Param
&&
param) {
{{#
fieldUnion
}}
KJ_I
NLINE_DPRECOND
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
KJ_I
REQUIRE
(which() ==
{{
unionTitleCase
}}
::
{{
fieldUpperCase
}}
,
"Must check which() before get()ing a union member.");
{{/
fieldUnion
}}
return ::capnproto::internal::PointerHelpers
<T>
::getDynamic(
_builder,
{{
fieldOffset
}}
* ::capnproto::POINTERS, ::kj::fwd
<Param>
(param));
...
...
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