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
5f07c032
Commit
5f07c032
authored
Nov 09, 2014
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mass-rename capnp::_::FieldSize -> capnp::ElementSize.
parent
9c54bce6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
179 additions
and
184 deletions
+179
-184
capability.h
c++/src/capnp/capability.h
+3
-3
dynamic.c++
c++/src/capnp/dynamic.c++
+30
-30
layout-test.c++
c++/src/capnp/layout-test.c++
+10
-10
layout.c++
c++/src/capnp/layout.c++
+97
-97
layout.h
c++/src/capnp/layout.h
+32
-37
list.h
c++/src/capnp/list.h
+7
-7
No files found.
c++/src/capnp/capability.h
View file @
5f07c032
...
@@ -564,14 +564,14 @@ struct List<T, Kind::INTERFACE> {
...
@@ -564,14 +564,14 @@ struct List<T, Kind::INTERFACE> {
private
:
private
:
inline
static
_
::
ListBuilder
initPointer
(
_
::
PointerBuilder
builder
,
uint
size
)
{
inline
static
_
::
ListBuilder
initPointer
(
_
::
PointerBuilder
builder
,
uint
size
)
{
return
builder
.
initList
(
_
::
Field
Size
::
POINTER
,
size
*
ELEMENTS
);
return
builder
.
initList
(
Element
Size
::
POINTER
,
size
*
ELEMENTS
);
}
}
inline
static
_
::
ListBuilder
getFromPointer
(
_
::
PointerBuilder
builder
,
const
word
*
defaultValue
)
{
inline
static
_
::
ListBuilder
getFromPointer
(
_
::
PointerBuilder
builder
,
const
word
*
defaultValue
)
{
return
builder
.
getList
(
_
::
Field
Size
::
POINTER
,
defaultValue
);
return
builder
.
getList
(
Element
Size
::
POINTER
,
defaultValue
);
}
}
inline
static
_
::
ListReader
getFromPointer
(
inline
static
_
::
ListReader
getFromPointer
(
const
_
::
PointerReader
&
reader
,
const
word
*
defaultValue
)
{
const
_
::
PointerReader
&
reader
,
const
word
*
defaultValue
)
{
return
reader
.
getList
(
_
::
Field
Size
::
POINTER
,
defaultValue
);
return
reader
.
getList
(
Element
Size
::
POINTER
,
defaultValue
);
}
}
template
<
typename
U
,
Kind
k
>
template
<
typename
U
,
Kind
k
>
...
...
c++/src/capnp/dynamic.c++
View file @
5f07c032
...
@@ -67,32 +67,32 @@ inline uint64_t bitCast<uint64_t, double>(double value) {
...
@@ -67,32 +67,32 @@ inline uint64_t bitCast<uint64_t, double>(double value) {
return
result
;
return
result
;
}
}
_
::
Field
Size
elementSizeFor
(
schema
::
Type
::
Which
elementType
)
{
Element
Size
elementSizeFor
(
schema
::
Type
::
Which
elementType
)
{
switch
(
elementType
)
{
switch
(
elementType
)
{
case
schema
:
:
Type
::
VOID
:
return
_
::
Field
Size
::
VOID
;
case
schema
:
:
Type
::
VOID
:
return
Element
Size
::
VOID
;
case
schema
:
:
Type
::
BOOL
:
return
_
::
Field
Size
::
BIT
;
case
schema
:
:
Type
::
BOOL
:
return
Element
Size
::
BIT
;
case
schema
:
:
Type
::
INT8
:
return
_
::
Field
Size
::
BYTE
;
case
schema
:
:
Type
::
INT8
:
return
Element
Size
::
BYTE
;
case
schema
:
:
Type
::
INT16
:
return
_
::
Field
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
INT16
:
return
Element
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
INT32
:
return
_
::
Field
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
INT32
:
return
Element
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
INT64
:
return
_
::
Field
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
INT64
:
return
Element
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
UINT8
:
return
_
::
Field
Size
::
BYTE
;
case
schema
:
:
Type
::
UINT8
:
return
Element
Size
::
BYTE
;
case
schema
:
:
Type
::
UINT16
:
return
_
::
Field
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
UINT16
:
return
Element
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
UINT32
:
return
_
::
Field
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
UINT32
:
return
Element
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
UINT64
:
return
_
::
Field
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
UINT64
:
return
Element
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
FLOAT32
:
return
_
::
Field
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
FLOAT32
:
return
Element
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
FLOAT64
:
return
_
::
Field
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
FLOAT64
:
return
Element
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
TEXT
:
return
_
::
Field
Size
::
POINTER
;
case
schema
:
:
Type
::
TEXT
:
return
Element
Size
::
POINTER
;
case
schema
:
:
Type
::
DATA
:
return
_
::
Field
Size
::
POINTER
;
case
schema
:
:
Type
::
DATA
:
return
Element
Size
::
POINTER
;
case
schema
:
:
Type
::
LIST
:
return
_
::
Field
Size
::
POINTER
;
case
schema
:
:
Type
::
LIST
:
return
Element
Size
::
POINTER
;
case
schema
:
:
Type
::
ENUM
:
return
_
::
Field
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
ENUM
:
return
Element
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
STRUCT
:
return
_
::
Field
Size
::
INLINE_COMPOSITE
;
case
schema
:
:
Type
::
STRUCT
:
return
Element
Size
::
INLINE_COMPOSITE
;
case
schema
:
:
Type
::
INTERFACE
:
return
_
::
Field
Size
::
POINTER
;
case
schema
:
:
Type
::
INTERFACE
:
return
Element
Size
::
POINTER
;
case
schema
:
:
Type
::
ANY_POINTER
:
KJ_FAIL_ASSERT
(
"List(AnyPointer) not supported."
);
break
;
case
schema
:
:
Type
::
ANY_POINTER
:
KJ_FAIL_ASSERT
(
"List(AnyPointer) not supported."
);
break
;
}
}
// Unknown type. Treat it as zero-size.
// Unknown type. Treat it as zero-size.
return
_
::
Field
Size
::
VOID
;
return
Element
Size
::
VOID
;
}
}
inline
_
::
StructSize
structSizeFromSchema
(
StructSchema
schema
)
{
inline
_
::
StructSize
structSizeFromSchema
(
StructSchema
schema
)
{
...
@@ -1293,15 +1293,15 @@ Orphan<DynamicValue> DynamicList::Builder::disown(uint index) {
...
@@ -1293,15 +1293,15 @@ Orphan<DynamicValue> DynamicList::Builder::disown(uint index) {
case
schema
:
:
Type
::
ENUM
:
{
case
schema
:
:
Type
::
ENUM
:
{
auto
result
=
Orphan
<
DynamicValue
>
(
operator
[](
index
),
_
::
OrphanBuilder
());
auto
result
=
Orphan
<
DynamicValue
>
(
operator
[](
index
),
_
::
OrphanBuilder
());
switch
(
elementSizeFor
(
schema
.
whichElementType
()))
{
switch
(
elementSizeFor
(
schema
.
whichElementType
()))
{
case
_
:
:
Field
Size
::
VOID
:
break
;
case
Element
Size
:
:
VOID
:
break
;
case
_
:
:
Field
Size
::
BIT
:
builder
.
setDataElement
<
bool
>
(
index
*
ELEMENTS
,
false
);
break
;
case
Element
Size
:
:
BIT
:
builder
.
setDataElement
<
bool
>
(
index
*
ELEMENTS
,
false
);
break
;
case
_
:
:
Field
Size
::
BYTE
:
builder
.
setDataElement
<
uint8_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
Element
Size
:
:
BYTE
:
builder
.
setDataElement
<
uint8_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
_
:
:
Field
Size
::
TWO_BYTES
:
builder
.
setDataElement
<
uint16_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
Element
Size
:
:
TWO_BYTES
:
builder
.
setDataElement
<
uint16_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
_
:
:
Field
Size
::
FOUR_BYTES
:
builder
.
setDataElement
<
uint32_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
Element
Size
:
:
FOUR_BYTES
:
builder
.
setDataElement
<
uint32_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
_
:
:
Field
Size
::
EIGHT_BYTES
:
builder
.
setDataElement
<
uint64_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
Element
Size
:
:
EIGHT_BYTES
:
builder
.
setDataElement
<
uint64_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
_
:
:
Field
Size
::
POINTER
:
case
Element
Size
:
:
POINTER
:
case
_
:
:
Field
Size
::
INLINE_COMPOSITE
:
case
Element
Size
:
:
INLINE_COMPOSITE
:
KJ_UNREACHABLE
;
KJ_UNREACHABLE
;
}
}
return
kj
::
mv
(
result
);
return
kj
::
mv
(
result
);
...
...
c++/src/capnp/layout-test.c++
View file @
5f07c032
...
@@ -124,7 +124,7 @@ static void setupStruct(StructBuilder builder) {
...
@@ -124,7 +124,7 @@ static void setupStruct(StructBuilder builder) {
{
{
ListBuilder
list
=
builder
.
getPointerField
(
1
*
POINTERS
)
ListBuilder
list
=
builder
.
getPointerField
(
1
*
POINTERS
)
.
initList
(
Field
Size
::
FOUR_BYTES
,
3
*
ELEMENTS
);
.
initList
(
Element
Size
::
FOUR_BYTES
,
3
*
ELEMENTS
);
EXPECT_EQ
(
3
*
ELEMENTS
,
list
.
size
());
EXPECT_EQ
(
3
*
ELEMENTS
,
list
.
size
());
list
.
setDataElement
<
int32_t
>
(
0
*
ELEMENTS
,
200
);
list
.
setDataElement
<
int32_t
>
(
0
*
ELEMENTS
,
200
);
list
.
setDataElement
<
int32_t
>
(
1
*
ELEMENTS
,
201
);
list
.
setDataElement
<
int32_t
>
(
1
*
ELEMENTS
,
201
);
...
@@ -146,11 +146,11 @@ static void setupStruct(StructBuilder builder) {
...
@@ -146,11 +146,11 @@ static void setupStruct(StructBuilder builder) {
{
{
ListBuilder
list
=
builder
.
getPointerField
(
3
*
POINTERS
)
ListBuilder
list
=
builder
.
getPointerField
(
3
*
POINTERS
)
.
initList
(
Field
Size
::
POINTER
,
5
*
ELEMENTS
);
.
initList
(
Element
Size
::
POINTER
,
5
*
ELEMENTS
);
EXPECT_EQ
(
5
*
ELEMENTS
,
list
.
size
());
EXPECT_EQ
(
5
*
ELEMENTS
,
list
.
size
());
for
(
uint
i
=
0
;
i
<
5
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
5
;
i
++
)
{
ListBuilder
element
=
list
.
getPointerElement
(
i
*
ELEMENTS
)
ListBuilder
element
=
list
.
getPointerElement
(
i
*
ELEMENTS
)
.
initList
(
Field
Size
::
TWO_BYTES
,
(
i
+
1
)
*
ELEMENTS
);
.
initList
(
Element
Size
::
TWO_BYTES
,
(
i
+
1
)
*
ELEMENTS
);
EXPECT_EQ
((
i
+
1
)
*
ELEMENTS
,
element
.
size
());
EXPECT_EQ
((
i
+
1
)
*
ELEMENTS
,
element
.
size
());
for
(
uint
j
=
0
;
j
<=
i
;
j
++
)
{
for
(
uint
j
=
0
;
j
<=
i
;
j
++
)
{
element
.
setDataElement
<
uint16_t
>
(
j
*
ELEMENTS
,
500
+
j
);
element
.
setDataElement
<
uint16_t
>
(
j
*
ELEMENTS
,
500
+
j
);
...
@@ -181,7 +181,7 @@ static void checkStruct(StructBuilder builder) {
...
@@ -181,7 +181,7 @@ static void checkStruct(StructBuilder builder) {
{
{
ListBuilder
list
=
builder
.
getPointerField
(
1
*
POINTERS
)
ListBuilder
list
=
builder
.
getPointerField
(
1
*
POINTERS
)
.
getList
(
Field
Size
::
FOUR_BYTES
,
nullptr
);
.
getList
(
Element
Size
::
FOUR_BYTES
,
nullptr
);
ASSERT_EQ
(
3
*
ELEMENTS
,
list
.
size
());
ASSERT_EQ
(
3
*
ELEMENTS
,
list
.
size
());
EXPECT_EQ
(
200
,
list
.
getDataElement
<
int32_t
>
(
0
*
ELEMENTS
));
EXPECT_EQ
(
200
,
list
.
getDataElement
<
int32_t
>
(
0
*
ELEMENTS
));
EXPECT_EQ
(
201
,
list
.
getDataElement
<
int32_t
>
(
1
*
ELEMENTS
));
EXPECT_EQ
(
201
,
list
.
getDataElement
<
int32_t
>
(
1
*
ELEMENTS
));
...
@@ -204,11 +204,11 @@ static void checkStruct(StructBuilder builder) {
...
@@ -204,11 +204,11 @@ static void checkStruct(StructBuilder builder) {
}
}
{
{
ListBuilder
list
=
builder
.
getPointerField
(
3
*
POINTERS
).
getList
(
Field
Size
::
POINTER
,
nullptr
);
ListBuilder
list
=
builder
.
getPointerField
(
3
*
POINTERS
).
getList
(
Element
Size
::
POINTER
,
nullptr
);
ASSERT_EQ
(
5
*
ELEMENTS
,
list
.
size
());
ASSERT_EQ
(
5
*
ELEMENTS
,
list
.
size
());
for
(
uint
i
=
0
;
i
<
5
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
5
;
i
++
)
{
ListBuilder
element
=
list
.
getPointerElement
(
i
*
ELEMENTS
)
ListBuilder
element
=
list
.
getPointerElement
(
i
*
ELEMENTS
)
.
getList
(
Field
Size
::
TWO_BYTES
,
nullptr
);
.
getList
(
Element
Size
::
TWO_BYTES
,
nullptr
);
ASSERT_EQ
((
i
+
1
)
*
ELEMENTS
,
element
.
size
());
ASSERT_EQ
((
i
+
1
)
*
ELEMENTS
,
element
.
size
());
for
(
uint
j
=
0
;
j
<=
i
;
j
++
)
{
for
(
uint
j
=
0
;
j
<=
i
;
j
++
)
{
EXPECT_EQ
(
500u
+
j
,
element
.
getDataElement
<
uint16_t
>
(
j
*
ELEMENTS
));
EXPECT_EQ
(
500u
+
j
,
element
.
getDataElement
<
uint16_t
>
(
j
*
ELEMENTS
));
...
@@ -238,7 +238,7 @@ static void checkStruct(StructReader reader) {
...
@@ -238,7 +238,7 @@ static void checkStruct(StructReader reader) {
}
}
{
{
ListReader
list
=
reader
.
getPointerField
(
1
*
POINTERS
).
getList
(
Field
Size
::
FOUR_BYTES
,
nullptr
);
ListReader
list
=
reader
.
getPointerField
(
1
*
POINTERS
).
getList
(
Element
Size
::
FOUR_BYTES
,
nullptr
);
ASSERT_EQ
(
3
*
ELEMENTS
,
list
.
size
());
ASSERT_EQ
(
3
*
ELEMENTS
,
list
.
size
());
EXPECT_EQ
(
200
,
list
.
getDataElement
<
int32_t
>
(
0
*
ELEMENTS
));
EXPECT_EQ
(
200
,
list
.
getDataElement
<
int32_t
>
(
0
*
ELEMENTS
));
EXPECT_EQ
(
201
,
list
.
getDataElement
<
int32_t
>
(
1
*
ELEMENTS
));
EXPECT_EQ
(
201
,
list
.
getDataElement
<
int32_t
>
(
1
*
ELEMENTS
));
...
@@ -247,7 +247,7 @@ static void checkStruct(StructReader reader) {
...
@@ -247,7 +247,7 @@ static void checkStruct(StructReader reader) {
{
{
ListReader
list
=
reader
.
getPointerField
(
2
*
POINTERS
)
ListReader
list
=
reader
.
getPointerField
(
2
*
POINTERS
)
.
getList
(
Field
Size
::
INLINE_COMPOSITE
,
nullptr
);
.
getList
(
Element
Size
::
INLINE_COMPOSITE
,
nullptr
);
ASSERT_EQ
(
4
*
ELEMENTS
,
list
.
size
());
ASSERT_EQ
(
4
*
ELEMENTS
,
list
.
size
());
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
StructReader
element
=
list
.
getStructElement
(
i
*
ELEMENTS
);
StructReader
element
=
list
.
getStructElement
(
i
*
ELEMENTS
);
...
@@ -260,11 +260,11 @@ static void checkStruct(StructReader reader) {
...
@@ -260,11 +260,11 @@ static void checkStruct(StructReader reader) {
}
}
{
{
ListReader
list
=
reader
.
getPointerField
(
3
*
POINTERS
).
getList
(
Field
Size
::
POINTER
,
nullptr
);
ListReader
list
=
reader
.
getPointerField
(
3
*
POINTERS
).
getList
(
Element
Size
::
POINTER
,
nullptr
);
ASSERT_EQ
(
5
*
ELEMENTS
,
list
.
size
());
ASSERT_EQ
(
5
*
ELEMENTS
,
list
.
size
());
for
(
uint
i
=
0
;
i
<
5
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
5
;
i
++
)
{
ListReader
element
=
list
.
getPointerElement
(
i
*
ELEMENTS
)
ListReader
element
=
list
.
getPointerElement
(
i
*
ELEMENTS
)
.
getList
(
Field
Size
::
TWO_BYTES
,
nullptr
);
.
getList
(
Element
Size
::
TWO_BYTES
,
nullptr
);
ASSERT_EQ
((
i
+
1
)
*
ELEMENTS
,
element
.
size
());
ASSERT_EQ
((
i
+
1
)
*
ELEMENTS
,
element
.
size
());
for
(
uint
j
=
0
;
j
<=
i
;
j
++
)
{
for
(
uint
j
=
0
;
j
<=
i
;
j
++
)
{
EXPECT_EQ
(
500u
+
j
,
element
.
getDataElement
<
uint16_t
>
(
j
*
ELEMENTS
));
EXPECT_EQ
(
500u
+
j
,
element
.
getDataElement
<
uint16_t
>
(
j
*
ELEMENTS
));
...
...
c++/src/capnp/layout.c++
View file @
5f07c032
...
@@ -199,8 +199,8 @@ struct WirePointer {
...
@@ -199,8 +199,8 @@ struct WirePointer {
struct
ListRef
{
struct
ListRef
{
WireValue
<
uint32_t
>
elementSizeAndCount
;
WireValue
<
uint32_t
>
elementSizeAndCount
;
KJ_ALWAYS_INLINE
(
Field
Size
elementSize
()
const
)
{
KJ_ALWAYS_INLINE
(
Element
Size
elementSize
()
const
)
{
return
static_cast
<
Field
Size
>
(
elementSizeAndCount
.
get
()
&
7
);
return
static_cast
<
Element
Size
>
(
elementSizeAndCount
.
get
()
&
7
);
}
}
KJ_ALWAYS_INLINE
(
ElementCount
elementCount
()
const
)
{
KJ_ALWAYS_INLINE
(
ElementCount
elementCount
()
const
)
{
return
(
elementSizeAndCount
.
get
()
>>
3
)
*
ELEMENTS
;
return
(
elementSizeAndCount
.
get
()
>>
3
)
*
ELEMENTS
;
...
@@ -209,7 +209,7 @@ struct WirePointer {
...
@@ -209,7 +209,7 @@ struct WirePointer {
return
elementCount
()
*
(
1
*
WORDS
/
ELEMENTS
);
return
elementCount
()
*
(
1
*
WORDS
/
ELEMENTS
);
}
}
KJ_ALWAYS_INLINE
(
void
set
(
Field
Size
es
,
ElementCount
ec
))
{
KJ_ALWAYS_INLINE
(
void
set
(
Element
Size
es
,
ElementCount
ec
))
{
KJ_DREQUIRE
(
ec
<
(
1
<<
29
)
*
ELEMENTS
,
"Lists are limited to 2**29 elements."
);
KJ_DREQUIRE
(
ec
<
(
1
<<
29
)
*
ELEMENTS
,
"Lists are limited to 2**29 elements."
);
elementSizeAndCount
.
set
(((
ec
/
ELEMENTS
)
<<
3
)
|
static_cast
<
int
>
(
es
));
elementSizeAndCount
.
set
(((
ec
/
ELEMENTS
)
<<
3
)
|
static_cast
<
int
>
(
es
));
}
}
...
@@ -217,7 +217,7 @@ struct WirePointer {
...
@@ -217,7 +217,7 @@ struct WirePointer {
KJ_ALWAYS_INLINE
(
void
setInlineComposite
(
WordCount
wc
))
{
KJ_ALWAYS_INLINE
(
void
setInlineComposite
(
WordCount
wc
))
{
KJ_DREQUIRE
(
wc
<
(
1
<<
29
)
*
WORDS
,
"Inline composite lists are limited to 2**29 words."
);
KJ_DREQUIRE
(
wc
<
(
1
<<
29
)
*
WORDS
,
"Inline composite lists are limited to 2**29 words."
);
elementSizeAndCount
.
set
(((
wc
/
WORDS
)
<<
3
)
|
elementSizeAndCount
.
set
(((
wc
/
WORDS
)
<<
3
)
|
static_cast
<
int
>
(
Field
Size
::
INLINE_COMPOSITE
));
static_cast
<
int
>
(
Element
Size
::
INLINE_COMPOSITE
));
}
}
};
};
...
@@ -521,20 +521,20 @@ struct WireHelpers {
...
@@ -521,20 +521,20 @@ struct WireHelpers {
}
}
case
WirePointer
:
:
LIST
:
{
case
WirePointer
:
:
LIST
:
{
switch
(
tag
->
listRef
.
elementSize
())
{
switch
(
tag
->
listRef
.
elementSize
())
{
case
Field
Size
:
:
VOID
:
case
Element
Size
:
:
VOID
:
// Nothing.
// Nothing.
break
;
break
;
case
Field
Size
:
:
BIT
:
case
Element
Size
:
:
BIT
:
case
Field
Size
:
:
BYTE
:
case
Element
Size
:
:
BYTE
:
case
Field
Size
:
:
TWO_BYTES
:
case
Element
Size
:
:
TWO_BYTES
:
case
Field
Size
:
:
FOUR_BYTES
:
case
Element
Size
:
:
FOUR_BYTES
:
case
Field
Size
:
:
EIGHT_BYTES
:
case
Element
Size
:
:
EIGHT_BYTES
:
memset
(
ptr
,
0
,
memset
(
ptr
,
0
,
roundBitsUpToWords
(
ElementCount64
(
tag
->
listRef
.
elementCount
())
*
roundBitsUpToWords
(
ElementCount64
(
tag
->
listRef
.
elementCount
())
*
dataBitsPerElement
(
tag
->
listRef
.
elementSize
()))
dataBitsPerElement
(
tag
->
listRef
.
elementSize
()))
*
BYTES_PER_WORD
/
BYTES
);
*
BYTES_PER_WORD
/
BYTES
);
break
;
break
;
case
Field
Size
:
:
POINTER
:
{
case
Element
Size
:
:
POINTER
:
{
uint
count
=
tag
->
listRef
.
elementCount
()
/
ELEMENTS
;
uint
count
=
tag
->
listRef
.
elementCount
()
/
ELEMENTS
;
for
(
uint
i
=
0
;
i
<
count
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
count
;
i
++
)
{
zeroObject
(
segment
,
reinterpret_cast
<
WirePointer
*>
(
ptr
)
+
i
);
zeroObject
(
segment
,
reinterpret_cast
<
WirePointer
*>
(
ptr
)
+
i
);
...
@@ -542,7 +542,7 @@ struct WireHelpers {
...
@@ -542,7 +542,7 @@ struct WireHelpers {
memset
(
ptr
,
0
,
POINTER_SIZE_IN_WORDS
*
count
*
BYTES_PER_WORD
/
BYTES
);
memset
(
ptr
,
0
,
POINTER_SIZE_IN_WORDS
*
count
*
BYTES_PER_WORD
/
BYTES
);
break
;
break
;
}
}
case
Field
Size
:
:
INLINE_COMPOSITE
:
{
case
Element
Size
:
:
INLINE_COMPOSITE
:
{
WirePointer
*
elementTag
=
reinterpret_cast
<
WirePointer
*>
(
ptr
);
WirePointer
*
elementTag
=
reinterpret_cast
<
WirePointer
*>
(
ptr
);
KJ_ASSERT
(
elementTag
->
kind
()
==
WirePointer
::
STRUCT
,
KJ_ASSERT
(
elementTag
->
kind
()
==
WirePointer
::
STRUCT
,
...
@@ -634,14 +634,14 @@ struct WireHelpers {
...
@@ -634,14 +634,14 @@ struct WireHelpers {
}
}
case
WirePointer
:
:
LIST
:
{
case
WirePointer
:
:
LIST
:
{
switch
(
ref
->
listRef
.
elementSize
())
{
switch
(
ref
->
listRef
.
elementSize
())
{
case
Field
Size
:
:
VOID
:
case
Element
Size
:
:
VOID
:
// Nothing.
// Nothing.
break
;
break
;
case
Field
Size
:
:
BIT
:
case
Element
Size
:
:
BIT
:
case
Field
Size
:
:
BYTE
:
case
Element
Size
:
:
BYTE
:
case
Field
Size
:
:
TWO_BYTES
:
case
Element
Size
:
:
TWO_BYTES
:
case
Field
Size
:
:
FOUR_BYTES
:
case
Element
Size
:
:
FOUR_BYTES
:
case
Field
Size
:
:
EIGHT_BYTES
:
{
case
Element
Size
:
:
EIGHT_BYTES
:
{
WordCount64
totalWords
=
roundBitsUpToWords
(
WordCount64
totalWords
=
roundBitsUpToWords
(
ElementCount64
(
ref
->
listRef
.
elementCount
())
*
ElementCount64
(
ref
->
listRef
.
elementCount
())
*
dataBitsPerElement
(
ref
->
listRef
.
elementSize
()));
dataBitsPerElement
(
ref
->
listRef
.
elementSize
()));
...
@@ -652,7 +652,7 @@ struct WireHelpers {
...
@@ -652,7 +652,7 @@ struct WireHelpers {
result
.
wordCount
+=
totalWords
;
result
.
wordCount
+=
totalWords
;
break
;
break
;
}
}
case
Field
Size
:
:
POINTER
:
{
case
Element
Size
:
:
POINTER
:
{
WirePointerCount
count
=
ref
->
listRef
.
elementCount
()
*
(
POINTERS
/
ELEMENTS
);
WirePointerCount
count
=
ref
->
listRef
.
elementCount
()
*
(
POINTERS
/
ELEMENTS
);
KJ_REQUIRE
(
boundsCheck
(
segment
,
ptr
,
ptr
+
count
*
WORDS_PER_POINTER
),
KJ_REQUIRE
(
boundsCheck
(
segment
,
ptr
,
ptr
+
count
*
WORDS_PER_POINTER
),
...
@@ -668,7 +668,7 @@ struct WireHelpers {
...
@@ -668,7 +668,7 @@ struct WireHelpers {
}
}
break
;
break
;
}
}
case
Field
Size
:
:
INLINE_COMPOSITE
:
{
case
Element
Size
:
:
INLINE_COMPOSITE
:
{
WordCount
wordCount
=
ref
->
listRef
.
inlineCompositeWordCount
();
WordCount
wordCount
=
ref
->
listRef
.
inlineCompositeWordCount
();
KJ_REQUIRE
(
boundsCheck
(
segment
,
ptr
,
ptr
+
wordCount
+
POINTER_SIZE_IN_WORDS
),
KJ_REQUIRE
(
boundsCheck
(
segment
,
ptr
,
ptr
+
wordCount
+
POINTER_SIZE_IN_WORDS
),
"Message contained out-of-bounds list pointer."
)
{
"Message contained out-of-bounds list pointer."
)
{
...
@@ -766,12 +766,12 @@ struct WireHelpers {
...
@@ -766,12 +766,12 @@ struct WireHelpers {
}
}
case
WirePointer
:
:
LIST
:
{
case
WirePointer
:
:
LIST
:
{
switch
(
src
->
listRef
.
elementSize
())
{
switch
(
src
->
listRef
.
elementSize
())
{
case
Field
Size
:
:
VOID
:
case
Element
Size
:
:
VOID
:
case
Field
Size
:
:
BIT
:
case
Element
Size
:
:
BIT
:
case
Field
Size
:
:
BYTE
:
case
Element
Size
:
:
BYTE
:
case
Field
Size
:
:
TWO_BYTES
:
case
Element
Size
:
:
TWO_BYTES
:
case
Field
Size
:
:
FOUR_BYTES
:
case
Element
Size
:
:
FOUR_BYTES
:
case
Field
Size
:
:
EIGHT_BYTES
:
{
case
Element
Size
:
:
EIGHT_BYTES
:
{
WordCount
wordCount
=
roundBitsUpToWords
(
WordCount
wordCount
=
roundBitsUpToWords
(
ElementCount64
(
src
->
listRef
.
elementCount
())
*
ElementCount64
(
src
->
listRef
.
elementCount
())
*
dataBitsPerElement
(
src
->
listRef
.
elementSize
()));
dataBitsPerElement
(
src
->
listRef
.
elementSize
()));
...
@@ -783,7 +783,7 @@ struct WireHelpers {
...
@@ -783,7 +783,7 @@ struct WireHelpers {
return
dstPtr
;
return
dstPtr
;
}
}
case
Field
Size
:
:
POINTER
:
{
case
Element
Size
:
:
POINTER
:
{
const
WirePointer
*
srcRefs
=
reinterpret_cast
<
const
WirePointer
*>
(
src
->
target
());
const
WirePointer
*
srcRefs
=
reinterpret_cast
<
const
WirePointer
*>
(
src
->
target
());
WirePointer
*
dstRefs
=
reinterpret_cast
<
WirePointer
*>
(
WirePointer
*
dstRefs
=
reinterpret_cast
<
WirePointer
*>
(
allocate
(
dst
,
segment
,
src
->
listRef
.
elementCount
()
*
allocate
(
dst
,
segment
,
src
->
listRef
.
elementCount
()
*
...
@@ -797,11 +797,11 @@ struct WireHelpers {
...
@@ -797,11 +797,11 @@ struct WireHelpers {
copyMessage
(
subSegment
,
dstRef
,
srcRefs
+
i
);
copyMessage
(
subSegment
,
dstRef
,
srcRefs
+
i
);
}
}
dst
->
listRef
.
set
(
Field
Size
::
POINTER
,
src
->
listRef
.
elementCount
());
dst
->
listRef
.
set
(
Element
Size
::
POINTER
,
src
->
listRef
.
elementCount
());
return
reinterpret_cast
<
word
*>
(
dstRefs
);
return
reinterpret_cast
<
word
*>
(
dstRefs
);
}
}
case
Field
Size
:
:
INLINE_COMPOSITE
:
{
case
Element
Size
:
:
INLINE_COMPOSITE
:
{
const
word
*
srcPtr
=
src
->
target
();
const
word
*
srcPtr
=
src
->
target
();
word
*
dstPtr
=
allocate
(
dst
,
segment
,
word
*
dstPtr
=
allocate
(
dst
,
segment
,
src
->
listRef
.
inlineCompositeWordCount
()
+
POINTER_SIZE_IN_WORDS
,
src
->
listRef
.
inlineCompositeWordCount
()
+
POINTER_SIZE_IN_WORDS
,
...
@@ -998,8 +998,8 @@ struct WireHelpers {
...
@@ -998,8 +998,8 @@ struct WireHelpers {
static
KJ_ALWAYS_INLINE
(
ListBuilder
initListPointer
(
static
KJ_ALWAYS_INLINE
(
ListBuilder
initListPointer
(
WirePointer
*
ref
,
SegmentBuilder
*
segment
,
ElementCount
elementCount
,
WirePointer
*
ref
,
SegmentBuilder
*
segment
,
ElementCount
elementCount
,
Field
Size
elementSize
,
BuilderArena
*
orphanArena
=
nullptr
))
{
Element
Size
elementSize
,
BuilderArena
*
orphanArena
=
nullptr
))
{
KJ_DREQUIRE
(
elementSize
!=
Field
Size
::
INLINE_COMPOSITE
,
KJ_DREQUIRE
(
elementSize
!=
Element
Size
::
INLINE_COMPOSITE
,
"Should have called initStructListPointer() instead."
);
"Should have called initStructListPointer() instead."
);
BitCount
dataSize
=
dataBitsPerElement
(
elementSize
)
*
ELEMENTS
;
BitCount
dataSize
=
dataBitsPerElement
(
elementSize
)
*
ELEMENTS
;
...
@@ -1042,20 +1042,20 @@ struct WireHelpers {
...
@@ -1042,20 +1042,20 @@ struct WireHelpers {
// Build the ListBuilder.
// Build the ListBuilder.
return
ListBuilder
(
segment
,
ptr
,
wordsPerElement
*
BITS_PER_WORD
,
elementCount
,
return
ListBuilder
(
segment
,
ptr
,
wordsPerElement
*
BITS_PER_WORD
,
elementCount
,
elementSize
.
data
*
BITS_PER_WORD
,
elementSize
.
pointers
,
elementSize
.
data
*
BITS_PER_WORD
,
elementSize
.
pointers
,
Field
Size
::
INLINE_COMPOSITE
);
Element
Size
::
INLINE_COMPOSITE
);
}
}
static
KJ_ALWAYS_INLINE
(
ListBuilder
getWritableListPointer
(
static
KJ_ALWAYS_INLINE
(
ListBuilder
getWritableListPointer
(
WirePointer
*
origRef
,
SegmentBuilder
*
origSegment
,
Field
Size
elementSize
,
WirePointer
*
origRef
,
SegmentBuilder
*
origSegment
,
Element
Size
elementSize
,
const
word
*
defaultValue
))
{
const
word
*
defaultValue
))
{
return
getWritableListPointer
(
origRef
,
origRef
->
target
(),
origSegment
,
elementSize
,
return
getWritableListPointer
(
origRef
,
origRef
->
target
(),
origSegment
,
elementSize
,
defaultValue
);
defaultValue
);
}
}
static
KJ_ALWAYS_INLINE
(
ListBuilder
getWritableListPointer
(
static
KJ_ALWAYS_INLINE
(
ListBuilder
getWritableListPointer
(
WirePointer
*
origRef
,
word
*
origRefTarget
,
SegmentBuilder
*
origSegment
,
Field
Size
elementSize
,
WirePointer
*
origRef
,
word
*
origRefTarget
,
SegmentBuilder
*
origSegment
,
Element
Size
elementSize
,
const
word
*
defaultValue
,
BuilderArena
*
orphanArena
=
nullptr
))
{
const
word
*
defaultValue
,
BuilderArena
*
orphanArena
=
nullptr
))
{
KJ_DREQUIRE
(
elementSize
!=
Field
Size
::
INLINE_COMPOSITE
,
KJ_DREQUIRE
(
elementSize
!=
Element
Size
::
INLINE_COMPOSITE
,
"Use getStructList{Element,Field}() for structs."
);
"Use getStructList{Element,Field}() for structs."
);
if
(
origRef
->
isNull
())
{
if
(
origRef
->
isNull
())
{
...
@@ -1083,9 +1083,9 @@ struct WireHelpers {
...
@@ -1083,9 +1083,9 @@ struct WireHelpers {
goto
useDefault
;
goto
useDefault
;
}
}
Field
Size
oldSize
=
ref
->
listRef
.
elementSize
();
Element
Size
oldSize
=
ref
->
listRef
.
elementSize
();
if
(
oldSize
==
Field
Size
::
INLINE_COMPOSITE
)
{
if
(
oldSize
==
Element
Size
::
INLINE_COMPOSITE
)
{
// The existing element size is INLINE_COMPOSITE, though we expected a list of primitives.
// The existing element size is INLINE_COMPOSITE, though we expected a list of primitives.
// The existing data must have been written with a newer version of the protocol. We
// The existing data must have been written with a newer version of the protocol. We
// therefore never need to upgrade the data in this case, but we do need to validate that it
// therefore never need to upgrade the data in this case, but we do need to validate that it
...
@@ -1101,11 +1101,11 @@ struct WireHelpers {
...
@@ -1101,11 +1101,11 @@ struct WireHelpers {
WirePointerCount
pointerCount
=
tag
->
structRef
.
ptrCount
.
get
();
WirePointerCount
pointerCount
=
tag
->
structRef
.
ptrCount
.
get
();
switch
(
elementSize
)
{
switch
(
elementSize
)
{
case
Field
Size
:
:
VOID
:
case
Element
Size
:
:
VOID
:
// Anything is a valid upgrade from Void.
// Anything is a valid upgrade from Void.
break
;
break
;
case
Field
Size
:
:
BIT
:
case
Element
Size
:
:
BIT
:
KJ_FAIL_REQUIRE
(
KJ_FAIL_REQUIRE
(
"Found struct list where bit list was expected; upgrading boolean lists to structs "
"Found struct list where bit list was expected; upgrading boolean lists to structs "
"is no longer supported."
)
{
"is no longer supported."
)
{
...
@@ -1113,17 +1113,17 @@ struct WireHelpers {
...
@@ -1113,17 +1113,17 @@ struct WireHelpers {
}
}
break
;
break
;
case
Field
Size
:
:
BYTE
:
case
Element
Size
:
:
BYTE
:
case
Field
Size
:
:
TWO_BYTES
:
case
Element
Size
:
:
TWO_BYTES
:
case
Field
Size
:
:
FOUR_BYTES
:
case
Element
Size
:
:
FOUR_BYTES
:
case
Field
Size
:
:
EIGHT_BYTES
:
case
Element
Size
:
:
EIGHT_BYTES
:
KJ_REQUIRE
(
dataSize
>=
1
*
WORDS
,
KJ_REQUIRE
(
dataSize
>=
1
*
WORDS
,
"Existing list value is incompatible with expected type."
)
{
"Existing list value is incompatible with expected type."
)
{
goto
useDefault
;
goto
useDefault
;
}
}
break
;
break
;
case
Field
Size
:
:
POINTER
:
case
Element
Size
:
:
POINTER
:
KJ_REQUIRE
(
pointerCount
>=
1
*
POINTERS
,
KJ_REQUIRE
(
pointerCount
>=
1
*
POINTERS
,
"Existing list value is incompatible with expected type."
)
{
"Existing list value is incompatible with expected type."
)
{
goto
useDefault
;
goto
useDefault
;
...
@@ -1132,7 +1132,7 @@ struct WireHelpers {
...
@@ -1132,7 +1132,7 @@ struct WireHelpers {
ptr
+=
dataSize
;
ptr
+=
dataSize
;
break
;
break
;
case
Field
Size
:
:
INLINE_COMPOSITE
:
case
Element
Size
:
:
INLINE_COMPOSITE
:
KJ_UNREACHABLE
;
KJ_UNREACHABLE
;
}
}
...
@@ -1141,18 +1141,18 @@ struct WireHelpers {
...
@@ -1141,18 +1141,18 @@ struct WireHelpers {
return
ListBuilder
(
segment
,
ptr
,
return
ListBuilder
(
segment
,
ptr
,
tag
->
structRef
.
wordSize
()
*
BITS_PER_WORD
/
ELEMENTS
,
tag
->
structRef
.
wordSize
()
*
BITS_PER_WORD
/
ELEMENTS
,
tag
->
inlineCompositeListElementCount
(),
tag
->
inlineCompositeListElementCount
(),
dataSize
*
BITS_PER_WORD
,
pointerCount
,
Field
Size
::
INLINE_COMPOSITE
);
dataSize
*
BITS_PER_WORD
,
pointerCount
,
Element
Size
::
INLINE_COMPOSITE
);
}
else
{
}
else
{
BitCount
dataSize
=
dataBitsPerElement
(
oldSize
)
*
ELEMENTS
;
BitCount
dataSize
=
dataBitsPerElement
(
oldSize
)
*
ELEMENTS
;
WirePointerCount
pointerCount
=
pointersPerElement
(
oldSize
)
*
ELEMENTS
;
WirePointerCount
pointerCount
=
pointersPerElement
(
oldSize
)
*
ELEMENTS
;
if
(
elementSize
==
Field
Size
::
BIT
)
{
if
(
elementSize
==
Element
Size
::
BIT
)
{
KJ_REQUIRE
(
oldSize
==
Field
Size
::
BIT
,
KJ_REQUIRE
(
oldSize
==
Element
Size
::
BIT
,
"Found non-bit list where bit list was expected."
)
{
"Found non-bit list where bit list was expected."
)
{
goto
useDefault
;
goto
useDefault
;
}
}
}
else
{
}
else
{
KJ_REQUIRE
(
oldSize
!=
Field
Size
::
BIT
,
KJ_REQUIRE
(
oldSize
!=
Element
Size
::
BIT
,
"Found bit list where non-bit list was expected."
)
{
"Found bit list where non-bit list was expected."
)
{
goto
useDefault
;
goto
useDefault
;
}
}
...
@@ -1200,9 +1200,9 @@ struct WireHelpers {
...
@@ -1200,9 +1200,9 @@ struct WireHelpers {
goto
useDefault
;
goto
useDefault
;
}
}
Field
Size
elementSize
=
ref
->
listRef
.
elementSize
();
Element
Size
elementSize
=
ref
->
listRef
.
elementSize
();
if
(
elementSize
==
Field
Size
::
INLINE_COMPOSITE
)
{
if
(
elementSize
==
Element
Size
::
INLINE_COMPOSITE
)
{
// Read the tag to get the actual element count.
// Read the tag to get the actual element count.
WirePointer
*
tag
=
reinterpret_cast
<
WirePointer
*>
(
ptr
);
WirePointer
*
tag
=
reinterpret_cast
<
WirePointer
*>
(
ptr
);
KJ_REQUIRE
(
tag
->
kind
()
==
WirePointer
::
STRUCT
,
KJ_REQUIRE
(
tag
->
kind
()
==
WirePointer
::
STRUCT
,
...
@@ -1213,7 +1213,7 @@ struct WireHelpers {
...
@@ -1213,7 +1213,7 @@ struct WireHelpers {
tag
->
structRef
.
wordSize
()
*
BITS_PER_WORD
/
ELEMENTS
,
tag
->
structRef
.
wordSize
()
*
BITS_PER_WORD
/
ELEMENTS
,
tag
->
inlineCompositeListElementCount
(),
tag
->
inlineCompositeListElementCount
(),
tag
->
structRef
.
dataSize
.
get
()
*
BITS_PER_WORD
,
tag
->
structRef
.
dataSize
.
get
()
*
BITS_PER_WORD
,
tag
->
structRef
.
ptrCount
.
get
(),
Field
Size
::
INLINE_COMPOSITE
);
tag
->
structRef
.
ptrCount
.
get
(),
Element
Size
::
INLINE_COMPOSITE
);
}
else
{
}
else
{
BitCount
dataSize
=
dataBitsPerElement
(
elementSize
)
*
ELEMENTS
;
BitCount
dataSize
=
dataBitsPerElement
(
elementSize
)
*
ELEMENTS
;
WirePointerCount
pointerCount
=
pointersPerElement
(
elementSize
)
*
ELEMENTS
;
WirePointerCount
pointerCount
=
pointersPerElement
(
elementSize
)
*
ELEMENTS
;
...
@@ -1255,9 +1255,9 @@ struct WireHelpers {
...
@@ -1255,9 +1255,9 @@ struct WireHelpers {
goto
useDefault
;
goto
useDefault
;
}
}
Field
Size
oldSize
=
oldRef
->
listRef
.
elementSize
();
Element
Size
oldSize
=
oldRef
->
listRef
.
elementSize
();
if
(
oldSize
==
Field
Size
::
INLINE_COMPOSITE
)
{
if
(
oldSize
==
Element
Size
::
INLINE_COMPOSITE
)
{
// Existing list is INLINE_COMPOSITE, but we need to verify that the sizes match.
// Existing list is INLINE_COMPOSITE, but we need to verify that the sizes match.
WirePointer
*
oldTag
=
reinterpret_cast
<
WirePointer
*>
(
oldPtr
);
WirePointer
*
oldTag
=
reinterpret_cast
<
WirePointer
*>
(
oldPtr
);
...
@@ -1276,7 +1276,7 @@ struct WireHelpers {
...
@@ -1276,7 +1276,7 @@ struct WireHelpers {
// Old size is at least as large as we need. Ship it.
// Old size is at least as large as we need. Ship it.
return
ListBuilder
(
oldSegment
,
oldPtr
,
oldStep
*
BITS_PER_WORD
,
elementCount
,
return
ListBuilder
(
oldSegment
,
oldPtr
,
oldStep
*
BITS_PER_WORD
,
elementCount
,
oldDataSize
*
BITS_PER_WORD
,
oldPointerCount
,
oldDataSize
*
BITS_PER_WORD
,
oldPointerCount
,
Field
Size
::
INLINE_COMPOSITE
);
Element
Size
::
INLINE_COMPOSITE
);
}
}
// The structs in this list are smaller than expected, probably written using an older
// The structs in this list are smaller than expected, probably written using an older
...
@@ -1321,7 +1321,7 @@ struct WireHelpers {
...
@@ -1321,7 +1321,7 @@ struct WireHelpers {
memset
(
oldPtr
,
0
,
oldStep
*
elementCount
*
BYTES_PER_WORD
/
BYTES
);
memset
(
oldPtr
,
0
,
oldStep
*
elementCount
*
BYTES_PER_WORD
/
BYTES
);
return
ListBuilder
(
origSegment
,
newPtr
,
newStep
*
BITS_PER_WORD
,
elementCount
,
return
ListBuilder
(
origSegment
,
newPtr
,
newStep
*
BITS_PER_WORD
,
elementCount
,
newDataSize
*
BITS_PER_WORD
,
newPointerCount
,
Field
Size
::
INLINE_COMPOSITE
);
newDataSize
*
BITS_PER_WORD
,
newPointerCount
,
Element
Size
::
INLINE_COMPOSITE
);
}
else
{
}
else
{
// We're upgrading from a non-struct list.
// We're upgrading from a non-struct list.
...
@@ -1330,13 +1330,13 @@ struct WireHelpers {
...
@@ -1330,13 +1330,13 @@ struct WireHelpers {
auto
oldStep
=
(
oldDataSize
+
oldPointerCount
*
BITS_PER_POINTER
)
/
ELEMENTS
;
auto
oldStep
=
(
oldDataSize
+
oldPointerCount
*
BITS_PER_POINTER
)
/
ELEMENTS
;
ElementCount
elementCount
=
oldRef
->
listRef
.
elementCount
();
ElementCount
elementCount
=
oldRef
->
listRef
.
elementCount
();
if
(
oldSize
==
Field
Size
::
VOID
)
{
if
(
oldSize
==
Element
Size
::
VOID
)
{
// Nothing to copy, just allocate a new list.
// Nothing to copy, just allocate a new list.
return
initStructListPointer
(
origRef
,
origSegment
,
elementCount
,
elementSize
);
return
initStructListPointer
(
origRef
,
origSegment
,
elementCount
,
elementSize
);
}
else
{
}
else
{
// Upgrading to an inline composite list.
// Upgrading to an inline composite list.
KJ_REQUIRE
(
oldSize
!=
Field
Size
::
BIT
,
KJ_REQUIRE
(
oldSize
!=
Element
Size
::
BIT
,
"Found bit list where struct list was expected; upgrading boolean lists to structs "
"Found bit list where struct list was expected; upgrading boolean lists to structs "
"is no longer supported."
)
{
"is no longer supported."
)
{
goto
useDefault
;
goto
useDefault
;
...
@@ -1345,7 +1345,7 @@ struct WireHelpers {
...
@@ -1345,7 +1345,7 @@ struct WireHelpers {
WordCount
newDataSize
=
elementSize
.
data
;
WordCount
newDataSize
=
elementSize
.
data
;
WirePointerCount
newPointerCount
=
elementSize
.
pointers
;
WirePointerCount
newPointerCount
=
elementSize
.
pointers
;
if
(
oldSize
==
Field
Size
::
POINTER
)
{
if
(
oldSize
==
Element
Size
::
POINTER
)
{
newPointerCount
=
std
::
max
(
newPointerCount
,
1
*
POINTERS
);
newPointerCount
=
std
::
max
(
newPointerCount
,
1
*
POINTERS
);
}
else
{
}
else
{
// Old list contains data elements, so we need at least 1 word of data.
// Old list contains data elements, so we need at least 1 word of data.
...
@@ -1367,7 +1367,7 @@ struct WireHelpers {
...
@@ -1367,7 +1367,7 @@ struct WireHelpers {
tag
->
structRef
.
set
(
newDataSize
,
newPointerCount
);
tag
->
structRef
.
set
(
newDataSize
,
newPointerCount
);
newPtr
+=
POINTER_SIZE_IN_WORDS
;
newPtr
+=
POINTER_SIZE_IN_WORDS
;
if
(
oldSize
==
Field
Size
::
POINTER
)
{
if
(
oldSize
==
Element
Size
::
POINTER
)
{
WirePointer
*
dst
=
reinterpret_cast
<
WirePointer
*>
(
newPtr
+
newDataSize
);
WirePointer
*
dst
=
reinterpret_cast
<
WirePointer
*>
(
newPtr
+
newDataSize
);
WirePointer
*
src
=
reinterpret_cast
<
WirePointer
*>
(
oldPtr
);
WirePointer
*
src
=
reinterpret_cast
<
WirePointer
*>
(
oldPtr
);
for
(
uint
i
=
0
;
i
<
elementCount
/
ELEMENTS
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
elementCount
/
ELEMENTS
;
i
++
)
{
...
@@ -1375,7 +1375,7 @@ struct WireHelpers {
...
@@ -1375,7 +1375,7 @@ struct WireHelpers {
dst
+=
newStep
/
WORDS_PER_POINTER
*
(
1
*
ELEMENTS
);
dst
+=
newStep
/
WORDS_PER_POINTER
*
(
1
*
ELEMENTS
);
++
src
;
++
src
;
}
}
}
else
if
(
oldSize
==
Field
Size
::
BIT
)
{
}
else
if
(
oldSize
==
Element
Size
::
BIT
)
{
word
*
dst
=
newPtr
;
word
*
dst
=
newPtr
;
char
*
src
=
reinterpret_cast
<
char
*>
(
oldPtr
);
char
*
src
=
reinterpret_cast
<
char
*>
(
oldPtr
);
for
(
uint
i
=
0
;
i
<
elementCount
/
ELEMENTS
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
elementCount
/
ELEMENTS
;
i
++
)
{
...
@@ -1398,7 +1398,7 @@ struct WireHelpers {
...
@@ -1398,7 +1398,7 @@ struct WireHelpers {
return
ListBuilder
(
origSegment
,
newPtr
,
newStep
*
BITS_PER_WORD
,
elementCount
,
return
ListBuilder
(
origSegment
,
newPtr
,
newStep
*
BITS_PER_WORD
,
elementCount
,
newDataSize
*
BITS_PER_WORD
,
newPointerCount
,
newDataSize
*
BITS_PER_WORD
,
newPointerCount
,
Field
Size
::
INLINE_COMPOSITE
);
Element
Size
::
INLINE_COMPOSITE
);
}
}
}
}
}
}
...
@@ -1414,7 +1414,7 @@ struct WireHelpers {
...
@@ -1414,7 +1414,7 @@ struct WireHelpers {
ref
,
segment
,
roundBytesUpToWords
(
byteSize
),
WirePointer
::
LIST
,
orphanArena
);
ref
,
segment
,
roundBytesUpToWords
(
byteSize
),
WirePointer
::
LIST
,
orphanArena
);
// Initialize the pointer.
// Initialize the pointer.
ref
->
listRef
.
set
(
Field
Size
::
BYTE
,
byteSize
*
(
1
*
ELEMENTS
/
BYTES
));
ref
->
listRef
.
set
(
Element
Size
::
BYTE
,
byteSize
*
(
1
*
ELEMENTS
/
BYTES
));
// Build the Text::Builder. This will initialize the NUL terminator.
// Build the Text::Builder. This will initialize the NUL terminator.
return
{
segment
,
Text
::
Builder
(
reinterpret_cast
<
char
*>
(
ptr
),
size
/
BYTES
)
};
return
{
segment
,
Text
::
Builder
(
reinterpret_cast
<
char
*>
(
ptr
),
size
/
BYTES
)
};
...
@@ -1450,7 +1450,7 @@ struct WireHelpers {
...
@@ -1450,7 +1450,7 @@ struct WireHelpers {
KJ_REQUIRE
(
ref
->
kind
()
==
WirePointer
::
LIST
,
KJ_REQUIRE
(
ref
->
kind
()
==
WirePointer
::
LIST
,
"Called getText{Field,Element}() but existing pointer is not a list."
);
"Called getText{Field,Element}() but existing pointer is not a list."
);
KJ_REQUIRE
(
ref
->
listRef
.
elementSize
()
==
Field
Size
::
BYTE
,
KJ_REQUIRE
(
ref
->
listRef
.
elementSize
()
==
Element
Size
::
BYTE
,
"Called getText{Field,Element}() but existing list pointer is not byte-sized."
);
"Called getText{Field,Element}() but existing list pointer is not byte-sized."
);
// Subtract 1 from the size for the NUL terminator.
// Subtract 1 from the size for the NUL terminator.
...
@@ -1465,7 +1465,7 @@ struct WireHelpers {
...
@@ -1465,7 +1465,7 @@ struct WireHelpers {
word
*
ptr
=
allocate
(
ref
,
segment
,
roundBytesUpToWords
(
size
),
WirePointer
::
LIST
,
orphanArena
);
word
*
ptr
=
allocate
(
ref
,
segment
,
roundBytesUpToWords
(
size
),
WirePointer
::
LIST
,
orphanArena
);
// Initialize the pointer.
// Initialize the pointer.
ref
->
listRef
.
set
(
Field
Size
::
BYTE
,
size
*
(
1
*
ELEMENTS
/
BYTES
));
ref
->
listRef
.
set
(
Element
Size
::
BYTE
,
size
*
(
1
*
ELEMENTS
/
BYTES
));
// Build the Data::Builder.
// Build the Data::Builder.
return
{
segment
,
Data
::
Builder
(
reinterpret_cast
<
byte
*>
(
ptr
),
size
/
BYTES
)
};
return
{
segment
,
Data
::
Builder
(
reinterpret_cast
<
byte
*>
(
ptr
),
size
/
BYTES
)
};
...
@@ -1501,7 +1501,7 @@ struct WireHelpers {
...
@@ -1501,7 +1501,7 @@ struct WireHelpers {
KJ_REQUIRE
(
ref
->
kind
()
==
WirePointer
::
LIST
,
KJ_REQUIRE
(
ref
->
kind
()
==
WirePointer
::
LIST
,
"Called getData{Field,Element}() but existing pointer is not a list."
);
"Called getData{Field,Element}() but existing pointer is not a list."
);
KJ_REQUIRE
(
ref
->
listRef
.
elementSize
()
==
Field
Size
::
BYTE
,
KJ_REQUIRE
(
ref
->
listRef
.
elementSize
()
==
Element
Size
::
BYTE
,
"Called getData{Field,Element}() but existing list pointer is not byte-sized."
);
"Called getData{Field,Element}() but existing list pointer is not byte-sized."
);
return
Data
::
Builder
(
reinterpret_cast
<
byte
*>
(
ptr
),
ref
->
listRef
.
elementCount
()
/
ELEMENTS
);
return
Data
::
Builder
(
reinterpret_cast
<
byte
*>
(
ptr
),
ref
->
listRef
.
elementCount
()
/
ELEMENTS
);
...
@@ -1549,13 +1549,13 @@ struct WireHelpers {
...
@@ -1549,13 +1549,13 @@ struct WireHelpers {
BuilderArena
*
orphanArena
=
nullptr
)
{
BuilderArena
*
orphanArena
=
nullptr
)
{
WordCount
totalSize
=
roundBitsUpToWords
(
value
.
elementCount
*
value
.
step
);
WordCount
totalSize
=
roundBitsUpToWords
(
value
.
elementCount
*
value
.
step
);
if
(
value
.
elementSize
!=
Field
Size
::
INLINE_COMPOSITE
)
{
if
(
value
.
elementSize
!=
Element
Size
::
INLINE_COMPOSITE
)
{
// List of non-structs.
// List of non-structs.
word
*
ptr
=
allocate
(
ref
,
segment
,
totalSize
,
WirePointer
::
LIST
,
orphanArena
);
word
*
ptr
=
allocate
(
ref
,
segment
,
totalSize
,
WirePointer
::
LIST
,
orphanArena
);
if
(
value
.
elementSize
==
Field
Size
::
POINTER
)
{
if
(
value
.
elementSize
==
Element
Size
::
POINTER
)
{
// List of pointers.
// List of pointers.
ref
->
listRef
.
set
(
Field
Size
::
POINTER
,
value
.
elementCount
);
ref
->
listRef
.
set
(
Element
Size
::
POINTER
,
value
.
elementCount
);
for
(
uint
i
=
0
;
i
<
value
.
elementCount
/
ELEMENTS
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
value
.
elementCount
/
ELEMENTS
;
i
++
)
{
copyPointer
(
segment
,
reinterpret_cast
<
WirePointer
*>
(
ptr
)
+
i
,
copyPointer
(
segment
,
reinterpret_cast
<
WirePointer
*>
(
ptr
)
+
i
,
value
.
segment
,
reinterpret_cast
<
const
WirePointer
*>
(
value
.
ptr
)
+
i
,
value
.
segment
,
reinterpret_cast
<
const
WirePointer
*>
(
value
.
ptr
)
+
i
,
...
@@ -1647,14 +1647,14 @@ struct WireHelpers {
...
@@ -1647,14 +1647,14 @@ struct WireHelpers {
orphanArena
);
orphanArena
);
case
WirePointer
:
:
LIST
:
{
case
WirePointer
:
:
LIST
:
{
Field
Size
elementSize
=
src
->
listRef
.
elementSize
();
Element
Size
elementSize
=
src
->
listRef
.
elementSize
();
KJ_REQUIRE
(
nestingLimit
>
0
,
KJ_REQUIRE
(
nestingLimit
>
0
,
"Message is too deeply-nested or contains cycles. See capnp::ReaderOptions."
)
{
"Message is too deeply-nested or contains cycles. See capnp::ReaderOptions."
)
{
goto
useDefault
;
goto
useDefault
;
}
}
if
(
elementSize
==
Field
Size
::
INLINE_COMPOSITE
)
{
if
(
elementSize
==
Element
Size
::
INLINE_COMPOSITE
)
{
WordCount
wordCount
=
src
->
listRef
.
inlineCompositeWordCount
();
WordCount
wordCount
=
src
->
listRef
.
inlineCompositeWordCount
();
const
WirePointer
*
tag
=
reinterpret_cast
<
const
WirePointer
*>
(
ptr
);
const
WirePointer
*
tag
=
reinterpret_cast
<
const
WirePointer
*>
(
ptr
);
ptr
+=
POINTER_SIZE_IN_WORDS
;
ptr
+=
POINTER_SIZE_IN_WORDS
;
...
@@ -1680,7 +1680,7 @@ struct WireHelpers {
...
@@ -1680,7 +1680,7 @@ struct WireHelpers {
return
setListPointer
(
dstSegment
,
dst
,
return
setListPointer
(
dstSegment
,
dst
,
ListReader
(
srcSegment
,
ptr
,
elementCount
,
wordsPerElement
*
BITS_PER_WORD
,
ListReader
(
srcSegment
,
ptr
,
elementCount
,
wordsPerElement
*
BITS_PER_WORD
,
tag
->
structRef
.
dataSize
.
get
()
*
BITS_PER_WORD
,
tag
->
structRef
.
dataSize
.
get
()
*
BITS_PER_WORD
,
tag
->
structRef
.
ptrCount
.
get
(),
Field
Size
::
INLINE_COMPOSITE
,
tag
->
structRef
.
ptrCount
.
get
(),
Element
Size
::
INLINE_COMPOSITE
,
nestingLimit
-
1
),
nestingLimit
-
1
),
orphanArena
);
orphanArena
);
}
else
{
}
else
{
...
@@ -1862,14 +1862,14 @@ struct WireHelpers {
...
@@ -1862,14 +1862,14 @@ struct WireHelpers {
static
KJ_ALWAYS_INLINE
(
ListReader
readListPointer
(
static
KJ_ALWAYS_INLINE
(
ListReader
readListPointer
(
SegmentReader
*
segment
,
const
WirePointer
*
ref
,
const
word
*
defaultValue
,
SegmentReader
*
segment
,
const
WirePointer
*
ref
,
const
word
*
defaultValue
,
Field
Size
expectedElementSize
,
int
nestingLimit
,
bool
checkElementSize
=
true
))
{
Element
Size
expectedElementSize
,
int
nestingLimit
,
bool
checkElementSize
=
true
))
{
return
readListPointer
(
segment
,
ref
,
ref
->
target
(),
defaultValue
,
return
readListPointer
(
segment
,
ref
,
ref
->
target
(),
defaultValue
,
expectedElementSize
,
nestingLimit
,
checkElementSize
);
expectedElementSize
,
nestingLimit
,
checkElementSize
);
}
}
static
KJ_ALWAYS_INLINE
(
ListReader
readListPointer
(
static
KJ_ALWAYS_INLINE
(
ListReader
readListPointer
(
SegmentReader
*
segment
,
const
WirePointer
*
ref
,
const
word
*
refTarget
,
SegmentReader
*
segment
,
const
WirePointer
*
ref
,
const
word
*
refTarget
,
const
word
*
defaultValue
,
Field
Size
expectedElementSize
,
int
nestingLimit
,
const
word
*
defaultValue
,
Element
Size
expectedElementSize
,
int
nestingLimit
,
bool
checkElementSize
=
true
))
{
bool
checkElementSize
=
true
))
{
if
(
ref
->
isNull
())
{
if
(
ref
->
isNull
())
{
useDefault
:
useDefault
:
...
@@ -1899,8 +1899,8 @@ struct WireHelpers {
...
@@ -1899,8 +1899,8 @@ struct WireHelpers {
goto
useDefault
;
goto
useDefault
;
}
}
Field
Size
elementSize
=
ref
->
listRef
.
elementSize
();
Element
Size
elementSize
=
ref
->
listRef
.
elementSize
();
if
(
elementSize
==
Field
Size
::
INLINE_COMPOSITE
)
{
if
(
elementSize
==
Element
Size
::
INLINE_COMPOSITE
)
{
decltype
(
WORDS
/
ELEMENTS
)
wordsPerElement
;
decltype
(
WORDS
/
ELEMENTS
)
wordsPerElement
;
ElementCount
size
;
ElementCount
size
;
...
@@ -1936,10 +1936,10 @@ struct WireHelpers {
...
@@ -1936,10 +1936,10 @@ struct WireHelpers {
// Check whether the size is compatible.
// Check whether the size is compatible.
switch
(
expectedElementSize
)
{
switch
(
expectedElementSize
)
{
case
Field
Size
:
:
VOID
:
case
Element
Size
:
:
VOID
:
break
;
break
;
case
Field
Size
:
:
BIT
:
case
Element
Size
:
:
BIT
:
KJ_FAIL_REQUIRE
(
KJ_FAIL_REQUIRE
(
"Found struct list where bit list was expected; upgrading boolean lists to structs "
"Found struct list where bit list was expected; upgrading boolean lists to structs "
"is no longer supported."
)
{
"is no longer supported."
)
{
...
@@ -1947,17 +1947,17 @@ struct WireHelpers {
...
@@ -1947,17 +1947,17 @@ struct WireHelpers {
}
}
break
;
break
;
case
Field
Size
:
:
BYTE
:
case
Element
Size
:
:
BYTE
:
case
Field
Size
:
:
TWO_BYTES
:
case
Element
Size
:
:
TWO_BYTES
:
case
Field
Size
:
:
FOUR_BYTES
:
case
Element
Size
:
:
FOUR_BYTES
:
case
Field
Size
:
:
EIGHT_BYTES
:
case
Element
Size
:
:
EIGHT_BYTES
:
KJ_REQUIRE
(
tag
->
structRef
.
dataSize
.
get
()
>
0
*
WORDS
,
KJ_REQUIRE
(
tag
->
structRef
.
dataSize
.
get
()
>
0
*
WORDS
,
"Expected a primitive list, but got a list of pointer-only structs."
)
{
"Expected a primitive list, but got a list of pointer-only structs."
)
{
goto
useDefault
;
goto
useDefault
;
}
}
break
;
break
;
case
Field
Size
:
:
POINTER
:
case
Element
Size
:
:
POINTER
:
// We expected a list of pointers but got a list of structs. Assuming the first field
// We expected a list of pointers but got a list of structs. Assuming the first field
// in the struct is the pointer we were looking for, we want to munge the pointer to
// in the struct is the pointer we were looking for, we want to munge the pointer to
// point at the first element's pointer section.
// point at the first element's pointer section.
...
@@ -1968,7 +1968,7 @@ struct WireHelpers {
...
@@ -1968,7 +1968,7 @@ struct WireHelpers {
}
}
break
;
break
;
case
Field
Size
:
:
INLINE_COMPOSITE
:
case
Element
Size
:
:
INLINE_COMPOSITE
:
break
;
break
;
}
}
}
}
...
@@ -1976,7 +1976,7 @@ struct WireHelpers {
...
@@ -1976,7 +1976,7 @@ struct WireHelpers {
return
ListReader
(
return
ListReader
(
segment
,
ptr
,
size
,
wordsPerElement
*
BITS_PER_WORD
,
segment
,
ptr
,
size
,
wordsPerElement
*
BITS_PER_WORD
,
tag
->
structRef
.
dataSize
.
get
()
*
BITS_PER_WORD
,
tag
->
structRef
.
dataSize
.
get
()
*
BITS_PER_WORD
,
tag
->
structRef
.
ptrCount
.
get
(),
Field
Size
::
INLINE_COMPOSITE
,
tag
->
structRef
.
ptrCount
.
get
(),
Element
Size
::
INLINE_COMPOSITE
,
nestingLimit
-
1
);
nestingLimit
-
1
);
}
else
{
}
else
{
...
@@ -1994,7 +1994,7 @@ struct WireHelpers {
...
@@ -1994,7 +1994,7 @@ struct WireHelpers {
}
}
if
(
checkElementSize
)
{
if
(
checkElementSize
)
{
if
(
elementSize
==
FieldSize
::
BIT
&&
expectedElementSize
!=
Field
Size
::
BIT
)
{
if
(
elementSize
==
ElementSize
::
BIT
&&
expectedElementSize
!=
Element
Size
::
BIT
)
{
KJ_FAIL_REQUIRE
(
KJ_FAIL_REQUIRE
(
"Found bit list where struct list was expected; upgrading boolean lists to structs "
"Found bit list where struct list was expected; upgrading boolean lists to structs "
"is no longer supported."
)
{
"is no longer supported."
)
{
...
@@ -2055,7 +2055,7 @@ struct WireHelpers {
...
@@ -2055,7 +2055,7 @@ struct WireHelpers {
goto
useDefault
;
goto
useDefault
;
}
}
KJ_REQUIRE
(
ref
->
listRef
.
elementSize
()
==
Field
Size
::
BYTE
,
KJ_REQUIRE
(
ref
->
listRef
.
elementSize
()
==
Element
Size
::
BYTE
,
"Message contains list pointer of non-bytes where text was expected."
)
{
"Message contains list pointer of non-bytes where text was expected."
)
{
goto
useDefault
;
goto
useDefault
;
}
}
...
@@ -2108,7 +2108,7 @@ struct WireHelpers {
...
@@ -2108,7 +2108,7 @@ struct WireHelpers {
goto
useDefault
;
goto
useDefault
;
}
}
KJ_REQUIRE
(
ref
->
listRef
.
elementSize
()
==
Field
Size
::
BYTE
,
KJ_REQUIRE
(
ref
->
listRef
.
elementSize
()
==
Element
Size
::
BYTE
,
"Message contains list pointer of non-bytes where data was expected."
)
{
"Message contains list pointer of non-bytes where data was expected."
)
{
goto
useDefault
;
goto
useDefault
;
}
}
...
@@ -2135,7 +2135,7 @@ StructBuilder PointerBuilder::getStruct(StructSize size, const word* defaultValu
...
@@ -2135,7 +2135,7 @@ StructBuilder PointerBuilder::getStruct(StructSize size, const word* defaultValu
return
WireHelpers
::
getWritableStructPointer
(
pointer
,
segment
,
size
,
defaultValue
);
return
WireHelpers
::
getWritableStructPointer
(
pointer
,
segment
,
size
,
defaultValue
);
}
}
ListBuilder
PointerBuilder
::
initList
(
Field
Size
elementSize
,
ElementCount
elementCount
)
{
ListBuilder
PointerBuilder
::
initList
(
Element
Size
elementSize
,
ElementCount
elementCount
)
{
return
WireHelpers
::
initListPointer
(
pointer
,
segment
,
elementCount
,
elementSize
);
return
WireHelpers
::
initListPointer
(
pointer
,
segment
,
elementCount
,
elementSize
);
}
}
...
@@ -2143,7 +2143,7 @@ ListBuilder PointerBuilder::initStructList(ElementCount elementCount, StructSize
...
@@ -2143,7 +2143,7 @@ ListBuilder PointerBuilder::initStructList(ElementCount elementCount, StructSize
return
WireHelpers
::
initStructListPointer
(
pointer
,
segment
,
elementCount
,
elementSize
);
return
WireHelpers
::
initStructListPointer
(
pointer
,
segment
,
elementCount
,
elementSize
);
}
}
ListBuilder
PointerBuilder
::
getList
(
Field
Size
elementSize
,
const
word
*
defaultValue
)
{
ListBuilder
PointerBuilder
::
getList
(
Element
Size
elementSize
,
const
word
*
defaultValue
)
{
return
WireHelpers
::
getWritableListPointer
(
pointer
,
segment
,
elementSize
,
defaultValue
);
return
WireHelpers
::
getWritableListPointer
(
pointer
,
segment
,
elementSize
,
defaultValue
);
}
}
...
@@ -2273,7 +2273,7 @@ StructReader PointerReader::getStruct(const word* defaultValue) const {
...
@@ -2273,7 +2273,7 @@ StructReader PointerReader::getStruct(const word* defaultValue) const {
return
WireHelpers
::
readStructPointer
(
segment
,
ref
,
defaultValue
,
nestingLimit
);
return
WireHelpers
::
readStructPointer
(
segment
,
ref
,
defaultValue
,
nestingLimit
);
}
}
ListReader
PointerReader
::
getList
(
Field
Size
expectedElementSize
,
const
word
*
defaultValue
)
const
{
ListReader
PointerReader
::
getList
(
Element
Size
expectedElementSize
,
const
word
*
defaultValue
)
const
{
const
WirePointer
*
ref
=
pointer
==
nullptr
?
&
zero
.
pointer
:
pointer
;
const
WirePointer
*
ref
=
pointer
==
nullptr
?
&
zero
.
pointer
:
pointer
;
return
WireHelpers
::
readListPointer
(
return
WireHelpers
::
readListPointer
(
segment
,
ref
,
defaultValue
,
expectedElementSize
,
nestingLimit
);
segment
,
ref
,
defaultValue
,
expectedElementSize
,
nestingLimit
);
...
@@ -2282,7 +2282,7 @@ ListReader PointerReader::getList(FieldSize expectedElementSize, const word* def
...
@@ -2282,7 +2282,7 @@ ListReader PointerReader::getList(FieldSize expectedElementSize, const word* def
ListReader
PointerReader
::
getListAnySize
(
const
word
*
defaultValue
)
const
{
ListReader
PointerReader
::
getListAnySize
(
const
word
*
defaultValue
)
const
{
const
WirePointer
*
ref
=
pointer
==
nullptr
?
&
zero
.
pointer
:
pointer
;
const
WirePointer
*
ref
=
pointer
==
nullptr
?
&
zero
.
pointer
:
pointer
;
return
WireHelpers
::
readListPointer
(
return
WireHelpers
::
readListPointer
(
segment
,
ref
,
defaultValue
,
Field
Size
::
VOID
/* dummy */
,
nestingLimit
,
false
);
segment
,
ref
,
defaultValue
,
Element
Size
::
VOID
/* dummy */
,
nestingLimit
,
false
);
}
}
template
<>
template
<>
...
@@ -2580,7 +2580,7 @@ OrphanBuilder OrphanBuilder::initStruct(BuilderArena* arena, StructSize size) {
...
@@ -2580,7 +2580,7 @@ OrphanBuilder OrphanBuilder::initStruct(BuilderArena* arena, StructSize size) {
}
}
OrphanBuilder
OrphanBuilder
::
initList
(
OrphanBuilder
OrphanBuilder
::
initList
(
BuilderArena
*
arena
,
ElementCount
elementCount
,
Field
Size
elementSize
)
{
BuilderArena
*
arena
,
ElementCount
elementCount
,
Element
Size
elementSize
)
{
OrphanBuilder
result
;
OrphanBuilder
result
;
ListBuilder
builder
=
WireHelpers
::
initListPointer
(
ListBuilder
builder
=
WireHelpers
::
initListPointer
(
result
.
tagAsPtr
(),
nullptr
,
elementCount
,
elementSize
,
arena
);
result
.
tagAsPtr
(),
nullptr
,
elementCount
,
elementSize
,
arena
);
...
@@ -2677,7 +2677,7 @@ OrphanBuilder OrphanBuilder::referenceExternalData(BuilderArena* arena, Data::Re
...
@@ -2677,7 +2677,7 @@ OrphanBuilder OrphanBuilder::referenceExternalData(BuilderArena* arena, Data::Re
OrphanBuilder
result
;
OrphanBuilder
result
;
result
.
tagAsPtr
()
->
setKindForOrphan
(
WirePointer
::
LIST
);
result
.
tagAsPtr
()
->
setKindForOrphan
(
WirePointer
::
LIST
);
result
.
tagAsPtr
()
->
listRef
.
set
(
Field
Size
::
BYTE
,
data
.
size
()
*
ELEMENTS
);
result
.
tagAsPtr
()
->
listRef
.
set
(
Element
Size
::
BYTE
,
data
.
size
()
*
ELEMENTS
);
result
.
segment
=
arena
->
addExternalSegment
(
words
);
result
.
segment
=
arena
->
addExternalSegment
(
words
);
// const_cast OK here because we will check whether the segment is writable when we try to get
// const_cast OK here because we will check whether the segment is writable when we try to get
...
@@ -2699,7 +2699,7 @@ StructBuilder OrphanBuilder::asStruct(StructSize size) {
...
@@ -2699,7 +2699,7 @@ StructBuilder OrphanBuilder::asStruct(StructSize size) {
return
result
;
return
result
;
}
}
ListBuilder
OrphanBuilder
::
asList
(
Field
Size
elementSize
)
{
ListBuilder
OrphanBuilder
::
asList
(
Element
Size
elementSize
)
{
KJ_DASSERT
(
tagAsPtr
()
->
isNull
()
==
(
location
==
nullptr
));
KJ_DASSERT
(
tagAsPtr
()
->
isNull
()
==
(
location
==
nullptr
));
ListBuilder
result
=
WireHelpers
::
getWritableListPointer
(
ListBuilder
result
=
WireHelpers
::
getWritableListPointer
(
...
@@ -2745,7 +2745,7 @@ StructReader OrphanBuilder::asStructReader(StructSize size) const {
...
@@ -2745,7 +2745,7 @@ StructReader OrphanBuilder::asStructReader(StructSize size) const {
segment
,
tagAsPtr
(),
location
,
nullptr
,
kj
::
maxValue
);
segment
,
tagAsPtr
(),
location
,
nullptr
,
kj
::
maxValue
);
}
}
ListReader
OrphanBuilder
::
asListReader
(
Field
Size
elementSize
)
const
{
ListReader
OrphanBuilder
::
asListReader
(
Element
Size
elementSize
)
const
{
KJ_DASSERT
(
tagAsPtr
()
->
isNull
()
==
(
location
==
nullptr
));
KJ_DASSERT
(
tagAsPtr
()
->
isNull
()
==
(
location
==
nullptr
));
return
WireHelpers
::
readListPointer
(
return
WireHelpers
::
readListPointer
(
segment
,
tagAsPtr
(),
location
,
nullptr
,
elementSize
,
kj
::
maxValue
);
segment
,
tagAsPtr
(),
location
,
nullptr
,
elementSize
,
kj
::
maxValue
);
...
@@ -2780,7 +2780,7 @@ void OrphanBuilder::truncate(ElementCount size, bool isText) {
...
@@ -2780,7 +2780,7 @@ void OrphanBuilder::truncate(ElementCount size, bool isText) {
}
}
// TODO(soon): Implement truncation of all sizes.
// TODO(soon): Implement truncation of all sizes.
KJ_ASSERT
(
ref
->
listRef
.
elementSize
()
==
Field
Size
::
BYTE
,
KJ_ASSERT
(
ref
->
listRef
.
elementSize
()
==
Element
Size
::
BYTE
,
"Not implemented: truncate non-blob."
);
"Not implemented: truncate non-blob."
);
auto
oldSize
=
ref
->
listRef
.
elementCount
();
auto
oldSize
=
ref
->
listRef
.
elementCount
();
...
...
c++/src/capnp/layout.h
View file @
5f07c032
...
@@ -78,11 +78,6 @@ class BuilderArena;
...
@@ -78,11 +78,6 @@ class BuilderArena;
// =============================================================================
// =============================================================================
using
FieldSize
=
capnp
::
ElementSize
;
// Legacy typedef.
//
// TODO(cleanup): Replace all uses.
typedef
decltype
(
BITS
/
ELEMENTS
)
BitsPerElement
;
typedef
decltype
(
BITS
/
ELEMENTS
)
BitsPerElement
;
typedef
decltype
(
POINTERS
/
ELEMENTS
)
PointersPerElement
;
typedef
decltype
(
POINTERS
/
ELEMENTS
)
PointersPerElement
;
...
@@ -97,48 +92,48 @@ static constexpr BitsPerElement BITS_PER_ELEMENT_TABLE[8] = {
...
@@ -97,48 +92,48 @@ static constexpr BitsPerElement BITS_PER_ELEMENT_TABLE[8] = {
0
*
BITS
/
ELEMENTS
0
*
BITS
/
ELEMENTS
};
};
inline
constexpr
BitsPerElement
dataBitsPerElement
(
Field
Size
size
)
{
inline
constexpr
BitsPerElement
dataBitsPerElement
(
Element
Size
size
)
{
return
_
::
BITS_PER_ELEMENT_TABLE
[
static_cast
<
int
>
(
size
)];
return
_
::
BITS_PER_ELEMENT_TABLE
[
static_cast
<
int
>
(
size
)];
}
}
inline
constexpr
PointersPerElement
pointersPerElement
(
Field
Size
size
)
{
inline
constexpr
PointersPerElement
pointersPerElement
(
Element
Size
size
)
{
return
size
==
Field
Size
::
POINTER
?
1
*
POINTERS
/
ELEMENTS
:
0
*
POINTERS
/
ELEMENTS
;
return
size
==
Element
Size
::
POINTER
?
1
*
POINTERS
/
ELEMENTS
:
0
*
POINTERS
/
ELEMENTS
;
}
}
template
<
size_t
size
>
struct
ElementSizeForByteSize
;
template
<
size_t
size
>
struct
ElementSizeForByteSize
;
template
<>
struct
ElementSizeForByteSize
<
1
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
BYTE
;
};
template
<>
struct
ElementSizeForByteSize
<
1
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
BYTE
;
};
template
<>
struct
ElementSizeForByteSize
<
2
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
TWO_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
2
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
TWO_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
4
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
FOUR_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
4
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
FOUR_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
8
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
EIGHT_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
8
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
EIGHT_BYTES
;
};
template
<
typename
T
>
struct
ElementSizeForType
{
template
<
typename
T
>
struct
ElementSizeForType
{
static
constexpr
Field
Size
value
=
static
constexpr
Element
Size
value
=
// Primitive types that aren't special-cased below can be determined from sizeof().
// Primitive types that aren't special-cased below can be determined from sizeof().
CAPNP_KIND
(
T
)
==
Kind
::
PRIMITIVE
?
ElementSizeForByteSize
<
sizeof
(
T
)
>::
value
:
CAPNP_KIND
(
T
)
==
Kind
::
PRIMITIVE
?
ElementSizeForByteSize
<
sizeof
(
T
)
>::
value
:
CAPNP_KIND
(
T
)
==
Kind
::
ENUM
?
Field
Size
::
TWO_BYTES
:
CAPNP_KIND
(
T
)
==
Kind
::
ENUM
?
Element
Size
::
TWO_BYTES
:
CAPNP_KIND
(
T
)
==
Kind
::
STRUCT
?
Field
Size
::
INLINE_COMPOSITE
:
CAPNP_KIND
(
T
)
==
Kind
::
STRUCT
?
Element
Size
::
INLINE_COMPOSITE
:
// Everything else is a pointer.
// Everything else is a pointer.
Field
Size
::
POINTER
;
Element
Size
::
POINTER
;
};
};
// Void and bool are special.
// Void and bool are special.
template
<>
struct
ElementSizeForType
<
Void
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
VOID
;
};
template
<>
struct
ElementSizeForType
<
Void
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
VOID
;
};
template
<>
struct
ElementSizeForType
<
bool
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
BIT
;
};
template
<>
struct
ElementSizeForType
<
bool
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
BIT
;
};
// Lists and blobs are pointers, not structs.
// Lists and blobs are pointers, not structs.
template
<
typename
T
,
bool
b
>
struct
ElementSizeForType
<
List
<
T
,
b
>>
{
template
<
typename
T
,
bool
b
>
struct
ElementSizeForType
<
List
<
T
,
b
>>
{
static
constexpr
FieldSize
value
=
Field
Size
::
POINTER
;
static
constexpr
ElementSize
value
=
Element
Size
::
POINTER
;
};
};
template
<>
struct
ElementSizeForType
<
Text
>
{
template
<>
struct
ElementSizeForType
<
Text
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
POINTER
;
static
constexpr
ElementSize
value
=
Element
Size
::
POINTER
;
};
};
template
<>
struct
ElementSizeForType
<
Data
>
{
template
<>
struct
ElementSizeForType
<
Data
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
POINTER
;
static
constexpr
ElementSize
value
=
Element
Size
::
POINTER
;
};
};
template
<
typename
T
>
template
<
typename
T
>
inline
constexpr
Field
Size
elementSizeForType
()
{
inline
constexpr
Element
Size
elementSizeForType
()
{
return
ElementSizeForType
<
T
>::
value
;
return
ElementSizeForType
<
T
>::
value
;
}
}
...
@@ -287,7 +282,7 @@ public:
...
@@ -287,7 +282,7 @@ public:
bool
isList
();
bool
isList
();
StructBuilder
getStruct
(
StructSize
size
,
const
word
*
defaultValue
);
StructBuilder
getStruct
(
StructSize
size
,
const
word
*
defaultValue
);
ListBuilder
getList
(
Field
Size
elementSize
,
const
word
*
defaultValue
);
ListBuilder
getList
(
Element
Size
elementSize
,
const
word
*
defaultValue
);
ListBuilder
getStructList
(
StructSize
elementSize
,
const
word
*
defaultValue
);
ListBuilder
getStructList
(
StructSize
elementSize
,
const
word
*
defaultValue
);
ListBuilder
getListAnySize
(
const
word
*
defaultValue
);
ListBuilder
getListAnySize
(
const
word
*
defaultValue
);
template
<
typename
T
>
typename
T
::
Builder
getBlob
(
const
void
*
defaultValue
,
ByteCount
defaultSize
);
template
<
typename
T
>
typename
T
::
Builder
getBlob
(
const
void
*
defaultValue
,
ByteCount
defaultSize
);
...
@@ -299,7 +294,7 @@ public:
...
@@ -299,7 +294,7 @@ public:
// simple byte array for blobs.
// simple byte array for blobs.
StructBuilder
initStruct
(
StructSize
size
);
StructBuilder
initStruct
(
StructSize
size
);
ListBuilder
initList
(
Field
Size
elementSize
,
ElementCount
elementCount
);
ListBuilder
initList
(
Element
Size
elementSize
,
ElementCount
elementCount
);
ListBuilder
initStructList
(
ElementCount
elementCount
,
StructSize
size
);
ListBuilder
initStructList
(
ElementCount
elementCount
,
StructSize
size
);
template
<
typename
T
>
typename
T
::
Builder
initBlob
(
ByteCount
size
);
template
<
typename
T
>
typename
T
::
Builder
initBlob
(
ByteCount
size
);
// Init methods: Initialize the pointer to a newly-allocated object, discarding the existing
// Init methods: Initialize the pointer to a newly-allocated object, discarding the existing
...
@@ -368,7 +363,7 @@ public:
...
@@ -368,7 +363,7 @@ public:
bool
isList
()
const
;
bool
isList
()
const
;
StructReader
getStruct
(
const
word
*
defaultValue
)
const
;
StructReader
getStruct
(
const
word
*
defaultValue
)
const
;
ListReader
getList
(
Field
Size
expectedElementSize
,
const
word
*
defaultValue
)
const
;
ListReader
getList
(
Element
Size
expectedElementSize
,
const
word
*
defaultValue
)
const
;
ListReader
getListAnySize
(
const
word
*
defaultValue
)
const
;
ListReader
getListAnySize
(
const
word
*
defaultValue
)
const
;
template
<
typename
T
>
template
<
typename
T
>
typename
T
::
Reader
getBlob
(
const
void
*
defaultValue
,
ByteCount
defaultSize
)
const
;
typename
T
::
Reader
getBlob
(
const
void
*
defaultValue
,
ByteCount
defaultSize
)
const
;
...
@@ -566,7 +561,7 @@ public:
...
@@ -566,7 +561,7 @@ public:
inline
word
*
getLocation
()
{
inline
word
*
getLocation
()
{
// Get the object's location.
// Get the object's location.
if
(
elementSize
==
Field
Size
::
INLINE_COMPOSITE
)
{
if
(
elementSize
==
Element
Size
::
INLINE_COMPOSITE
)
{
return
reinterpret_cast
<
word
*>
(
ptr
)
-
POINTER_SIZE_IN_WORDS
;
return
reinterpret_cast
<
word
*>
(
ptr
)
-
POINTER_SIZE_IN_WORDS
;
}
else
{
}
else
{
return
reinterpret_cast
<
word
*>
(
ptr
);
return
reinterpret_cast
<
word
*>
(
ptr
);
...
@@ -616,14 +611,14 @@ private:
...
@@ -616,14 +611,14 @@ private:
// The struct properties to use when interpreting the elements as structs. All lists can be
// The struct properties to use when interpreting the elements as structs. All lists can be
// interpreted as struct lists, so these are always filled in.
// interpreted as struct lists, so these are always filled in.
Field
Size
elementSize
;
Element
Size
elementSize
;
// The element size as a
Field
Size. This is only really needed to disambiguate INLINE_COMPOSITE
// The element size as a
Element
Size. This is only really needed to disambiguate INLINE_COMPOSITE
// from other types when the overall size is exactly zero or one words.
// from other types when the overall size is exactly zero or one words.
inline
ListBuilder
(
SegmentBuilder
*
segment
,
void
*
ptr
,
inline
ListBuilder
(
SegmentBuilder
*
segment
,
void
*
ptr
,
decltype
(
BITS
/
ELEMENTS
)
step
,
ElementCount
size
,
decltype
(
BITS
/
ELEMENTS
)
step
,
ElementCount
size
,
BitCount
structDataSize
,
WirePointerCount
structPointerCount
,
BitCount
structDataSize
,
WirePointerCount
structPointerCount
,
Field
Size
elementSize
)
Element
Size
elementSize
)
:
segment
(
segment
),
ptr
(
reinterpret_cast
<
byte
*>
(
ptr
)),
:
segment
(
segment
),
ptr
(
reinterpret_cast
<
byte
*>
(
ptr
)),
elementCount
(
size
),
step
(
step
),
structDataSize
(
structDataSize
),
elementCount
(
size
),
step
(
step
),
structDataSize
(
structDataSize
),
structPointerCount
(
structPointerCount
),
elementSize
(
elementSize
)
{}
structPointerCount
(
structPointerCount
),
elementSize
(
elementSize
)
{}
...
@@ -672,8 +667,8 @@ private:
...
@@ -672,8 +667,8 @@ private:
// The struct properties to use when interpreting the elements as structs. All lists can be
// The struct properties to use when interpreting the elements as structs. All lists can be
// interpreted as struct lists, so these are always filled in.
// interpreted as struct lists, so these are always filled in.
Field
Size
elementSize
;
Element
Size
elementSize
;
// The element size as a
Field
Size. This is only really needed to disambiguate INLINE_COMPOSITE
// The element size as a
Element
Size. This is only really needed to disambiguate INLINE_COMPOSITE
// from other types when the overall size is exactly zero or one words.
// from other types when the overall size is exactly zero or one words.
int
nestingLimit
;
int
nestingLimit
;
...
@@ -683,7 +678,7 @@ private:
...
@@ -683,7 +678,7 @@ private:
inline
ListReader
(
SegmentReader
*
segment
,
const
void
*
ptr
,
inline
ListReader
(
SegmentReader
*
segment
,
const
void
*
ptr
,
ElementCount
elementCount
,
decltype
(
BITS
/
ELEMENTS
)
step
,
ElementCount
elementCount
,
decltype
(
BITS
/
ELEMENTS
)
step
,
BitCount
structDataSize
,
WirePointerCount
structPointerCount
,
BitCount
structDataSize
,
WirePointerCount
structPointerCount
,
Field
Size
elementSize
,
int
nestingLimit
)
Element
Size
elementSize
,
int
nestingLimit
)
:
segment
(
segment
),
ptr
(
reinterpret_cast
<
const
byte
*>
(
ptr
)),
elementCount
(
elementCount
),
:
segment
(
segment
),
ptr
(
reinterpret_cast
<
const
byte
*>
(
ptr
)),
elementCount
(
elementCount
),
step
(
step
),
structDataSize
(
structDataSize
),
step
(
step
),
structDataSize
(
structDataSize
),
structPointerCount
(
structPointerCount
),
elementSize
(
elementSize
),
structPointerCount
(
structPointerCount
),
elementSize
(
elementSize
),
...
@@ -706,7 +701,7 @@ public:
...
@@ -706,7 +701,7 @@ public:
static
OrphanBuilder
initStruct
(
BuilderArena
*
arena
,
StructSize
size
);
static
OrphanBuilder
initStruct
(
BuilderArena
*
arena
,
StructSize
size
);
static
OrphanBuilder
initList
(
BuilderArena
*
arena
,
ElementCount
elementCount
,
static
OrphanBuilder
initList
(
BuilderArena
*
arena
,
ElementCount
elementCount
,
Field
Size
elementSize
);
Element
Size
elementSize
);
static
OrphanBuilder
initStructList
(
BuilderArena
*
arena
,
ElementCount
elementCount
,
static
OrphanBuilder
initStructList
(
BuilderArena
*
arena
,
ElementCount
elementCount
,
StructSize
elementSize
);
StructSize
elementSize
);
static
OrphanBuilder
initText
(
BuilderArena
*
arena
,
ByteCount
size
);
static
OrphanBuilder
initText
(
BuilderArena
*
arena
,
ByteCount
size
);
...
@@ -732,7 +727,7 @@ public:
...
@@ -732,7 +727,7 @@ public:
StructBuilder
asStruct
(
StructSize
size
);
StructBuilder
asStruct
(
StructSize
size
);
// Interpret as a struct, or throw an exception if not a struct.
// Interpret as a struct, or throw an exception if not a struct.
ListBuilder
asList
(
Field
Size
elementSize
);
ListBuilder
asList
(
Element
Size
elementSize
);
// Interpret as a list, or throw an exception if not a list. elementSize cannot be
// Interpret as a list, or throw an exception if not a list. elementSize cannot be
// INLINE_COMPOSITE -- use asStructList() instead.
// INLINE_COMPOSITE -- use asStructList() instead.
...
@@ -744,7 +739,7 @@ public:
...
@@ -744,7 +739,7 @@ public:
// Interpret as a blob, or throw an exception if not a blob.
// Interpret as a blob, or throw an exception if not a blob.
StructReader
asStructReader
(
StructSize
size
)
const
;
StructReader
asStructReader
(
StructSize
size
)
const
;
ListReader
asListReader
(
Field
Size
elementSize
)
const
;
ListReader
asListReader
(
Element
Size
elementSize
)
const
;
#if !CAPNP_LITE
#if !CAPNP_LITE
kj
::
Own
<
ClientHook
>
asCapability
()
const
;
kj
::
Own
<
ClientHook
>
asCapability
()
const
;
#endif // !CAPNP_LITE
#endif // !CAPNP_LITE
...
@@ -821,7 +816,7 @@ inline Data::Builder StructBuilder::getDataSectionAsBlob() {
...
@@ -821,7 +816,7 @@ inline Data::Builder StructBuilder::getDataSectionAsBlob() {
inline
_
::
ListBuilder
StructBuilder
::
getPointerSectionAsList
()
{
inline
_
::
ListBuilder
StructBuilder
::
getPointerSectionAsList
()
{
return
_
::
ListBuilder
(
segment
,
pointers
,
pointerCount
*
BITS_PER_POINTER
/
ELEMENTS
,
return
_
::
ListBuilder
(
segment
,
pointers
,
pointerCount
*
BITS_PER_POINTER
/
ELEMENTS
,
pointerCount
*
(
1
*
ELEMENTS
/
POINTERS
),
pointerCount
*
(
1
*
ELEMENTS
/
POINTERS
),
0
*
BITS
,
1
*
POINTERS
,
Field
Size
::
POINTER
);
0
*
BITS
,
1
*
POINTERS
,
Element
Size
::
POINTER
);
}
}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -905,7 +900,7 @@ inline Data::Reader StructReader::getDataSectionAsBlob() {
...
@@ -905,7 +900,7 @@ inline Data::Reader StructReader::getDataSectionAsBlob() {
inline
_
::
ListReader
StructReader
::
getPointerSectionAsList
()
{
inline
_
::
ListReader
StructReader
::
getPointerSectionAsList
()
{
return
_
::
ListReader
(
segment
,
pointers
,
pointerCount
*
(
1
*
ELEMENTS
/
POINTERS
),
return
_
::
ListReader
(
segment
,
pointers
,
pointerCount
*
(
1
*
ELEMENTS
/
POINTERS
),
pointerCount
*
BITS_PER_POINTER
/
ELEMENTS
,
pointerCount
*
BITS_PER_POINTER
/
ELEMENTS
,
0
*
BITS
,
1
*
POINTERS
,
Field
Size
::
POINTER
,
nestingLimit
);
0
*
BITS
,
1
*
POINTERS
,
Element
Size
::
POINTER
,
nestingLimit
);
}
}
template
<
typename
T
>
template
<
typename
T
>
...
...
c++/src/capnp/list.h
View file @
5f07c032
...
@@ -302,7 +302,7 @@ private:
...
@@ -302,7 +302,7 @@ private:
}
}
inline
static
_
::
ListReader
getFromPointer
(
inline
static
_
::
ListReader
getFromPointer
(
const
_
::
PointerReader
&
reader
,
const
word
*
defaultValue
)
{
const
_
::
PointerReader
&
reader
,
const
word
*
defaultValue
)
{
return
reader
.
getList
(
_
::
Field
Size
::
INLINE_COMPOSITE
,
defaultValue
);
return
reader
.
getList
(
Element
Size
::
INLINE_COMPOSITE
,
defaultValue
);
}
}
template
<
typename
U
,
Kind
k
>
template
<
typename
U
,
Kind
k
>
...
@@ -406,14 +406,14 @@ struct List<List<T>, Kind::LIST> {
...
@@ -406,14 +406,14 @@ struct List<List<T>, Kind::LIST> {
private
:
private
:
inline
static
_
::
ListBuilder
initPointer
(
_
::
PointerBuilder
builder
,
uint
size
)
{
inline
static
_
::
ListBuilder
initPointer
(
_
::
PointerBuilder
builder
,
uint
size
)
{
return
builder
.
initList
(
_
::
Field
Size
::
POINTER
,
size
*
ELEMENTS
);
return
builder
.
initList
(
Element
Size
::
POINTER
,
size
*
ELEMENTS
);
}
}
inline
static
_
::
ListBuilder
getFromPointer
(
_
::
PointerBuilder
builder
,
const
word
*
defaultValue
)
{
inline
static
_
::
ListBuilder
getFromPointer
(
_
::
PointerBuilder
builder
,
const
word
*
defaultValue
)
{
return
builder
.
getList
(
_
::
Field
Size
::
POINTER
,
defaultValue
);
return
builder
.
getList
(
Element
Size
::
POINTER
,
defaultValue
);
}
}
inline
static
_
::
ListReader
getFromPointer
(
inline
static
_
::
ListReader
getFromPointer
(
const
_
::
PointerReader
&
reader
,
const
word
*
defaultValue
)
{
const
_
::
PointerReader
&
reader
,
const
word
*
defaultValue
)
{
return
reader
.
getList
(
_
::
Field
Size
::
POINTER
,
defaultValue
);
return
reader
.
getList
(
Element
Size
::
POINTER
,
defaultValue
);
}
}
template
<
typename
U
,
Kind
k
>
template
<
typename
U
,
Kind
k
>
...
@@ -504,14 +504,14 @@ struct List<T, Kind::BLOB> {
...
@@ -504,14 +504,14 @@ struct List<T, Kind::BLOB> {
private
:
private
:
inline
static
_
::
ListBuilder
initPointer
(
_
::
PointerBuilder
builder
,
uint
size
)
{
inline
static
_
::
ListBuilder
initPointer
(
_
::
PointerBuilder
builder
,
uint
size
)
{
return
builder
.
initList
(
_
::
Field
Size
::
POINTER
,
size
*
ELEMENTS
);
return
builder
.
initList
(
Element
Size
::
POINTER
,
size
*
ELEMENTS
);
}
}
inline
static
_
::
ListBuilder
getFromPointer
(
_
::
PointerBuilder
builder
,
const
word
*
defaultValue
)
{
inline
static
_
::
ListBuilder
getFromPointer
(
_
::
PointerBuilder
builder
,
const
word
*
defaultValue
)
{
return
builder
.
getList
(
_
::
Field
Size
::
POINTER
,
defaultValue
);
return
builder
.
getList
(
Element
Size
::
POINTER
,
defaultValue
);
}
}
inline
static
_
::
ListReader
getFromPointer
(
inline
static
_
::
ListReader
getFromPointer
(
const
_
::
PointerReader
&
reader
,
const
word
*
defaultValue
)
{
const
_
::
PointerReader
&
reader
,
const
word
*
defaultValue
)
{
return
reader
.
getList
(
_
::
Field
Size
::
POINTER
,
defaultValue
);
return
reader
.
getList
(
Element
Size
::
POINTER
,
defaultValue
);
}
}
template
<
typename
U
,
Kind
k
>
template
<
typename
U
,
Kind
k
>
...
...
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