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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
87 deletions
+82
-87
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++
+0
-0
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> {
private
:
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
)
{
return
builder
.
getList
(
_
::
Field
Size
::
POINTER
,
defaultValue
);
return
builder
.
getList
(
Element
Size
::
POINTER
,
defaultValue
);
}
inline
static
_
::
ListReader
getFromPointer
(
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
>
...
...
c++/src/capnp/dynamic.c++
View file @
5f07c032
...
...
@@ -67,32 +67,32 @@ inline uint64_t bitCast<uint64_t, double>(double value) {
return
result
;
}
_
::
Field
Size
elementSizeFor
(
schema
::
Type
::
Which
elementType
)
{
Element
Size
elementSizeFor
(
schema
::
Type
::
Which
elementType
)
{
switch
(
elementType
)
{
case
schema
:
:
Type
::
VOID
:
return
_
::
Field
Size
::
VOID
;
case
schema
:
:
Type
::
BOOL
:
return
_
::
Field
Size
::
BIT
;
case
schema
:
:
Type
::
INT8
:
return
_
::
Field
Size
::
BYTE
;
case
schema
:
:
Type
::
INT16
:
return
_
::
Field
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
INT32
:
return
_
::
Field
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
INT64
:
return
_
::
Field
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
UINT8
:
return
_
::
Field
Size
::
BYTE
;
case
schema
:
:
Type
::
UINT16
:
return
_
::
Field
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
UINT32
:
return
_
::
Field
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
UINT64
:
return
_
::
Field
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
FLOAT32
:
return
_
::
Field
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
FLOAT64
:
return
_
::
Field
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
TEXT
:
return
_
::
Field
Size
::
POINTER
;
case
schema
:
:
Type
::
DATA
:
return
_
::
Field
Size
::
POINTER
;
case
schema
:
:
Type
::
LIST
:
return
_
::
Field
Size
::
POINTER
;
case
schema
:
:
Type
::
ENUM
:
return
_
::
Field
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
STRUCT
:
return
_
::
Field
Size
::
INLINE_COMPOSITE
;
case
schema
:
:
Type
::
INTERFACE
:
return
_
::
Field
Size
::
POINTER
;
case
schema
:
:
Type
::
VOID
:
return
Element
Size
::
VOID
;
case
schema
:
:
Type
::
BOOL
:
return
Element
Size
::
BIT
;
case
schema
:
:
Type
::
INT8
:
return
Element
Size
::
BYTE
;
case
schema
:
:
Type
::
INT16
:
return
Element
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
INT32
:
return
Element
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
INT64
:
return
Element
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
UINT8
:
return
Element
Size
::
BYTE
;
case
schema
:
:
Type
::
UINT16
:
return
Element
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
UINT32
:
return
Element
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
UINT64
:
return
Element
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
FLOAT32
:
return
Element
Size
::
FOUR_BYTES
;
case
schema
:
:
Type
::
FLOAT64
:
return
Element
Size
::
EIGHT_BYTES
;
case
schema
:
:
Type
::
TEXT
:
return
Element
Size
::
POINTER
;
case
schema
:
:
Type
::
DATA
:
return
Element
Size
::
POINTER
;
case
schema
:
:
Type
::
LIST
:
return
Element
Size
::
POINTER
;
case
schema
:
:
Type
::
ENUM
:
return
Element
Size
::
TWO_BYTES
;
case
schema
:
:
Type
::
STRUCT
:
return
Element
Size
::
INLINE_COMPOSITE
;
case
schema
:
:
Type
::
INTERFACE
:
return
Element
Size
::
POINTER
;
case
schema
:
:
Type
::
ANY_POINTER
:
KJ_FAIL_ASSERT
(
"List(AnyPointer) not supported."
);
break
;
}
// Unknown type. Treat it as zero-size.
return
_
::
Field
Size
::
VOID
;
return
Element
Size
::
VOID
;
}
inline
_
::
StructSize
structSizeFromSchema
(
StructSchema
schema
)
{
...
...
@@ -1293,15 +1293,15 @@ Orphan<DynamicValue> DynamicList::Builder::disown(uint index) {
case
schema
:
:
Type
::
ENUM
:
{
auto
result
=
Orphan
<
DynamicValue
>
(
operator
[](
index
),
_
::
OrphanBuilder
());
switch
(
elementSizeFor
(
schema
.
whichElementType
()))
{
case
_
:
:
Field
Size
::
VOID
:
break
;
case
_
:
:
Field
Size
::
BIT
:
builder
.
setDataElement
<
bool
>
(
index
*
ELEMENTS
,
false
);
break
;
case
_
:
:
Field
Size
::
BYTE
:
builder
.
setDataElement
<
uint8_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
_
:
:
Field
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
_
:
:
Field
Size
::
EIGHT_BYTES
:
builder
.
setDataElement
<
uint64_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
_
:
:
Field
Size
::
POINTER
:
case
_
:
:
Field
Size
::
INLINE_COMPOSITE
:
case
Element
Size
:
:
VOID
:
break
;
case
Element
Size
:
:
BIT
:
builder
.
setDataElement
<
bool
>
(
index
*
ELEMENTS
,
false
);
break
;
case
Element
Size
:
:
BYTE
:
builder
.
setDataElement
<
uint8_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
Element
Size
:
:
TWO_BYTES
:
builder
.
setDataElement
<
uint16_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
Element
Size
:
:
FOUR_BYTES
:
builder
.
setDataElement
<
uint32_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
Element
Size
:
:
EIGHT_BYTES
:
builder
.
setDataElement
<
uint64_t
>
(
index
*
ELEMENTS
,
0
);
break
;
case
Element
Size
:
:
POINTER
:
case
Element
Size
:
:
INLINE_COMPOSITE
:
KJ_UNREACHABLE
;
}
return
kj
::
mv
(
result
);
...
...
c++/src/capnp/layout-test.c++
View file @
5f07c032
...
...
@@ -124,7 +124,7 @@ static void setupStruct(StructBuilder builder) {
{
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
());
list
.
setDataElement
<
int32_t
>
(
0
*
ELEMENTS
,
200
);
list
.
setDataElement
<
int32_t
>
(
1
*
ELEMENTS
,
201
);
...
...
@@ -146,11 +146,11 @@ static void setupStruct(StructBuilder builder) {
{
ListBuilder
list
=
builder
.
getPointerField
(
3
*
POINTERS
)
.
initList
(
Field
Size
::
POINTER
,
5
*
ELEMENTS
);
.
initList
(
Element
Size
::
POINTER
,
5
*
ELEMENTS
);
EXPECT_EQ
(
5
*
ELEMENTS
,
list
.
size
());
for
(
uint
i
=
0
;
i
<
5
;
i
++
)
{
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
());
for
(
uint
j
=
0
;
j
<=
i
;
j
++
)
{
element
.
setDataElement
<
uint16_t
>
(
j
*
ELEMENTS
,
500
+
j
);
...
...
@@ -181,7 +181,7 @@ static void checkStruct(StructBuilder builder) {
{
ListBuilder
list
=
builder
.
getPointerField
(
1
*
POINTERS
)
.
getList
(
Field
Size
::
FOUR_BYTES
,
nullptr
);
.
getList
(
Element
Size
::
FOUR_BYTES
,
nullptr
);
ASSERT_EQ
(
3
*
ELEMENTS
,
list
.
size
());
EXPECT_EQ
(
200
,
list
.
getDataElement
<
int32_t
>
(
0
*
ELEMENTS
));
EXPECT_EQ
(
201
,
list
.
getDataElement
<
int32_t
>
(
1
*
ELEMENTS
));
...
...
@@ -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
());
for
(
uint
i
=
0
;
i
<
5
;
i
++
)
{
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
());
for
(
uint
j
=
0
;
j
<=
i
;
j
++
)
{
EXPECT_EQ
(
500u
+
j
,
element
.
getDataElement
<
uint16_t
>
(
j
*
ELEMENTS
));
...
...
@@ -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
());
EXPECT_EQ
(
200
,
list
.
getDataElement
<
int32_t
>
(
0
*
ELEMENTS
));
EXPECT_EQ
(
201
,
list
.
getDataElement
<
int32_t
>
(
1
*
ELEMENTS
));
...
...
@@ -247,7 +247,7 @@ static void checkStruct(StructReader reader) {
{
ListReader
list
=
reader
.
getPointerField
(
2
*
POINTERS
)
.
getList
(
Field
Size
::
INLINE_COMPOSITE
,
nullptr
);
.
getList
(
Element
Size
::
INLINE_COMPOSITE
,
nullptr
);
ASSERT_EQ
(
4
*
ELEMENTS
,
list
.
size
());
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
StructReader
element
=
list
.
getStructElement
(
i
*
ELEMENTS
);
...
...
@@ -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
());
for
(
uint
i
=
0
;
i
<
5
;
i
++
)
{
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
());
for
(
uint
j
=
0
;
j
<=
i
;
j
++
)
{
EXPECT_EQ
(
500u
+
j
,
element
.
getDataElement
<
uint16_t
>
(
j
*
ELEMENTS
));
...
...
c++/src/capnp/layout.c++
View file @
5f07c032
This diff is collapsed.
Click to expand it.
c++/src/capnp/layout.h
View file @
5f07c032
...
...
@@ -78,11 +78,6 @@ class BuilderArena;
// =============================================================================
using
FieldSize
=
capnp
::
ElementSize
;
// Legacy typedef.
//
// TODO(cleanup): Replace all uses.
typedef
decltype
(
BITS
/
ELEMENTS
)
BitsPerElement
;
typedef
decltype
(
POINTERS
/
ELEMENTS
)
PointersPerElement
;
...
...
@@ -97,48 +92,48 @@ static constexpr BitsPerElement BITS_PER_ELEMENT_TABLE[8] = {
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
)];
}
inline
constexpr
PointersPerElement
pointersPerElement
(
Field
Size
size
)
{
return
size
==
Field
Size
::
POINTER
?
1
*
POINTERS
/
ELEMENTS
:
0
*
POINTERS
/
ELEMENTS
;
inline
constexpr
PointersPerElement
pointersPerElement
(
Element
Size
size
)
{
return
size
==
Element
Size
::
POINTER
?
1
*
POINTERS
/
ELEMENTS
:
0
*
POINTERS
/
ELEMENTS
;
}
template
<
size_t
size
>
struct
ElementSizeForByteSize
;
template
<>
struct
ElementSizeForByteSize
<
1
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
BYTE
;
};
template
<>
struct
ElementSizeForByteSize
<
2
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
TWO_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
4
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
FOUR_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
8
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
EIGHT_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
1
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
BYTE
;
};
template
<>
struct
ElementSizeForByteSize
<
2
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
TWO_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
4
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
FOUR_BYTES
;
};
template
<>
struct
ElementSizeForByteSize
<
8
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
EIGHT_BYTES
;
};
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().
CAPNP_KIND
(
T
)
==
Kind
::
PRIMITIVE
?
ElementSizeForByteSize
<
sizeof
(
T
)
>::
value
:
CAPNP_KIND
(
T
)
==
Kind
::
ENUM
?
Field
Size
::
TWO_BYTES
:
CAPNP_KIND
(
T
)
==
Kind
::
STRUCT
?
Field
Size
::
INLINE_COMPOSITE
:
CAPNP_KIND
(
T
)
==
Kind
::
ENUM
?
Element
Size
::
TWO_BYTES
:
CAPNP_KIND
(
T
)
==
Kind
::
STRUCT
?
Element
Size
::
INLINE_COMPOSITE
:
// Everything else is a pointer.
Field
Size
::
POINTER
;
Element
Size
::
POINTER
;
};
// Void and bool are special.
template
<>
struct
ElementSizeForType
<
Void
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
VOID
;
};
template
<>
struct
ElementSizeForType
<
bool
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
BIT
;
};
template
<>
struct
ElementSizeForType
<
Void
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
VOID
;
};
template
<>
struct
ElementSizeForType
<
bool
>
{
static
constexpr
ElementSize
value
=
Element
Size
::
BIT
;
};
// Lists and blobs are pointers, not structs.
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
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
POINTER
;
static
constexpr
ElementSize
value
=
Element
Size
::
POINTER
;
};
template
<>
struct
ElementSizeForType
<
Data
>
{
static
constexpr
FieldSize
value
=
Field
Size
::
POINTER
;
static
constexpr
ElementSize
value
=
Element
Size
::
POINTER
;
};
template
<
typename
T
>
inline
constexpr
Field
Size
elementSizeForType
()
{
inline
constexpr
Element
Size
elementSizeForType
()
{
return
ElementSizeForType
<
T
>::
value
;
}
...
...
@@ -287,7 +282,7 @@ public:
bool
isList
();
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
getListAnySize
(
const
word
*
defaultValue
);
template
<
typename
T
>
typename
T
::
Builder
getBlob
(
const
void
*
defaultValue
,
ByteCount
defaultSize
);
...
...
@@ -299,7 +294,7 @@ public:
// simple byte array for blobs.
StructBuilder
initStruct
(
StructSize
size
);
ListBuilder
initList
(
Field
Size
elementSize
,
ElementCount
elementCount
);
ListBuilder
initList
(
Element
Size
elementSize
,
ElementCount
elementCount
);
ListBuilder
initStructList
(
ElementCount
elementCount
,
StructSize
size
);
template
<
typename
T
>
typename
T
::
Builder
initBlob
(
ByteCount
size
);
// Init methods: Initialize the pointer to a newly-allocated object, discarding the existing
...
...
@@ -368,7 +363,7 @@ public:
bool
isList
()
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
;
template
<
typename
T
>
typename
T
::
Reader
getBlob
(
const
void
*
defaultValue
,
ByteCount
defaultSize
)
const
;
...
...
@@ -566,7 +561,7 @@ public:
inline
word
*
getLocation
()
{
// 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
;
}
else
{
return
reinterpret_cast
<
word
*>
(
ptr
);
...
...
@@ -616,14 +611,14 @@ private:
// 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.
Field
Size
elementSize
;
// The element size as a
Field
Size. This is only really needed to disambiguate INLINE_COMPOSITE
Element
Size
elementSize
;
// 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.
inline
ListBuilder
(
SegmentBuilder
*
segment
,
void
*
ptr
,
decltype
(
BITS
/
ELEMENTS
)
step
,
ElementCount
size
,
BitCount
structDataSize
,
WirePointerCount
structPointerCount
,
Field
Size
elementSize
)
Element
Size
elementSize
)
:
segment
(
segment
),
ptr
(
reinterpret_cast
<
byte
*>
(
ptr
)),
elementCount
(
size
),
step
(
step
),
structDataSize
(
structDataSize
),
structPointerCount
(
structPointerCount
),
elementSize
(
elementSize
)
{}
...
...
@@ -672,8 +667,8 @@ private:
// 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.
Field
Size
elementSize
;
// The element size as a
Field
Size. This is only really needed to disambiguate INLINE_COMPOSITE
Element
Size
elementSize
;
// 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.
int
nestingLimit
;
...
...
@@ -683,7 +678,7 @@ private:
inline
ListReader
(
SegmentReader
*
segment
,
const
void
*
ptr
,
ElementCount
elementCount
,
decltype
(
BITS
/
ELEMENTS
)
step
,
BitCount
structDataSize
,
WirePointerCount
structPointerCount
,
Field
Size
elementSize
,
int
nestingLimit
)
Element
Size
elementSize
,
int
nestingLimit
)
:
segment
(
segment
),
ptr
(
reinterpret_cast
<
const
byte
*>
(
ptr
)),
elementCount
(
elementCount
),
step
(
step
),
structDataSize
(
structDataSize
),
structPointerCount
(
structPointerCount
),
elementSize
(
elementSize
),
...
...
@@ -706,7 +701,7 @@ public:
static
OrphanBuilder
initStruct
(
BuilderArena
*
arena
,
StructSize
size
);
static
OrphanBuilder
initList
(
BuilderArena
*
arena
,
ElementCount
elementCount
,
Field
Size
elementSize
);
Element
Size
elementSize
);
static
OrphanBuilder
initStructList
(
BuilderArena
*
arena
,
ElementCount
elementCount
,
StructSize
elementSize
);
static
OrphanBuilder
initText
(
BuilderArena
*
arena
,
ByteCount
size
);
...
...
@@ -732,7 +727,7 @@ public:
StructBuilder
asStruct
(
StructSize
size
);
// 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
// INLINE_COMPOSITE -- use asStructList() instead.
...
...
@@ -744,7 +739,7 @@ public:
// Interpret as a blob, or throw an exception if not a blob.
StructReader
asStructReader
(
StructSize
size
)
const
;
ListReader
asListReader
(
Field
Size
elementSize
)
const
;
ListReader
asListReader
(
Element
Size
elementSize
)
const
;
#if !CAPNP_LITE
kj
::
Own
<
ClientHook
>
asCapability
()
const
;
#endif // !CAPNP_LITE
...
...
@@ -821,7 +816,7 @@ inline Data::Builder StructBuilder::getDataSectionAsBlob() {
inline
_
::
ListBuilder
StructBuilder
::
getPointerSectionAsList
()
{
return
_
::
ListBuilder
(
segment
,
pointers
,
pointerCount
*
BITS_PER_POINTER
/
ELEMENTS
,
pointerCount
*
(
1
*
ELEMENTS
/
POINTERS
),
0
*
BITS
,
1
*
POINTERS
,
Field
Size
::
POINTER
);
0
*
BITS
,
1
*
POINTERS
,
Element
Size
::
POINTER
);
}
template
<
typename
T
>
...
...
@@ -905,7 +900,7 @@ inline Data::Reader StructReader::getDataSectionAsBlob() {
inline
_
::
ListReader
StructReader
::
getPointerSectionAsList
()
{
return
_
::
ListReader
(
segment
,
pointers
,
pointerCount
*
(
1
*
ELEMENTS
/
POINTERS
),
pointerCount
*
BITS_PER_POINTER
/
ELEMENTS
,
0
*
BITS
,
1
*
POINTERS
,
Field
Size
::
POINTER
,
nestingLimit
);
0
*
BITS
,
1
*
POINTERS
,
Element
Size
::
POINTER
,
nestingLimit
);
}
template
<
typename
T
>
...
...
c++/src/capnp/list.h
View file @
5f07c032
...
...
@@ -302,7 +302,7 @@ private:
}
inline
static
_
::
ListReader
getFromPointer
(
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
>
...
...
@@ -406,14 +406,14 @@ struct List<List<T>, Kind::LIST> {
private
:
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
)
{
return
builder
.
getList
(
_
::
Field
Size
::
POINTER
,
defaultValue
);
return
builder
.
getList
(
Element
Size
::
POINTER
,
defaultValue
);
}
inline
static
_
::
ListReader
getFromPointer
(
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
>
...
...
@@ -504,14 +504,14 @@ struct List<T, Kind::BLOB> {
private
:
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
)
{
return
builder
.
getList
(
_
::
Field
Size
::
POINTER
,
defaultValue
);
return
builder
.
getList
(
Element
Size
::
POINTER
,
defaultValue
);
}
inline
static
_
::
ListReader
getFromPointer
(
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
>
...
...
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