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
b2496f3a
Commit
b2496f3a
authored
Feb 25, 2015
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix AnyStruct::getPointerSection(), which was totally broken and not tested.
parent
db268884
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
5 deletions
+19
-5
any-test.c++
c++/src/capnp/any-test.c++
+14
-0
any.h
c++/src/capnp/any.h
+2
-2
layout.h
c++/src/capnp/layout.h
+3
-3
No files found.
c++/src/capnp/any-test.c++
View file @
b2496f3a
...
...
@@ -162,6 +162,20 @@ TEST(Any, AnyStruct) {
// TODO: is there a higher-level API for this?
memcpy
(
sb
.
getDataSection
().
begin
(),
r
.
getDataSection
().
begin
(),
r
.
getDataSection
().
size
());
}
{
auto
ptrs
=
r
.
getPointerSection
();
EXPECT_EQ
(
"foo"
,
ptrs
[
0
].
getAs
<
Text
>
());
EXPECT_EQ
(
"bar"
,
kj
::
heapString
(
ptrs
[
1
].
getAs
<
Data
>
().
asChars
()));
EXPECT_EQ
(
"xyzzy"
,
ptrs
[
15
].
getAs
<
List
<
Text
>>
()[
1
]);
}
{
auto
ptrs
=
b
.
getPointerSection
();
EXPECT_EQ
(
"foo"
,
ptrs
[
0
].
getAs
<
Text
>
());
EXPECT_EQ
(
"bar"
,
kj
::
heapString
(
ptrs
[
1
].
getAs
<
Data
>
().
asChars
()));
EXPECT_EQ
(
"xyzzy"
,
ptrs
[
15
].
getAs
<
List
<
Text
>>
()[
1
]);
}
}
TEST
(
Any
,
AnyList
)
{
...
...
c++/src/capnp/any.h
View file @
b2496f3a
...
...
@@ -574,7 +574,7 @@ public:
inline
uint
size
()
{
return
_reader
.
size
()
/
ELEMENTS
;
}
template
<
typename
T
>
ReaderFor
<
T
>
as
()
{
// T must be List<U>.
// T must be List<U>.
return
ReaderFor
<
T
>
(
_reader
);
}
private
:
...
...
@@ -599,7 +599,7 @@ public:
inline
uint
size
()
{
return
_builder
.
size
()
/
ELEMENTS
;
}
template
<
typename
T
>
BuilderFor
<
T
>
as
()
{
// T must be List<U>.
// T must be List<U>.
return
BuilderFor
<
T
>
(
_builder
);
}
...
...
c++/src/capnp/layout.h
View file @
b2496f3a
...
...
@@ -826,7 +826,7 @@ inline Data::Builder StructBuilder::getDataSectionAsBlob() {
}
inline
_
::
ListBuilder
StructBuilder
::
getPointerSectionAsList
()
{
return
_
::
ListBuilder
(
segment
,
pointers
,
pointerCount
*
BITS_PER_POINTER
/
ELEMENTS
,
return
_
::
ListBuilder
(
segment
,
pointers
,
1
*
POINTERS
*
BITS_PER_POINTER
/
ELEMENTS
,
pointerCount
*
(
1
*
ELEMENTS
/
POINTERS
),
0
*
BITS
,
1
*
POINTERS
,
ElementSize
::
POINTER
);
}
...
...
@@ -911,8 +911,8 @@ inline Data::Reader StructReader::getDataSectionAsBlob() {
inline
_
::
ListReader
StructReader
::
getPointerSectionAsList
()
{
return
_
::
ListReader
(
segment
,
pointers
,
pointerCount
*
(
1
*
ELEMENTS
/
POINTERS
),
pointerCount
*
BITS_PER_POINTER
/
ELEMENT
S
,
0
*
BITS
,
1
*
POINTERS
,
ElementSize
::
POINTER
,
nestingLimit
);
1
*
POINTERS
*
BITS_PER_POINTER
/
ELEMENTS
,
0
*
BITS
,
1
*
POINTER
S
,
ElementSize
::
POINTER
,
nestingLimit
);
}
template
<
typename
T
>
...
...
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