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
de33baaf
Commit
de33baaf
authored
May 06, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify more after removing inline types.
parent
7197456b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
12 deletions
+34
-12
layout-test.c++
c++/src/capnproto/layout-test.c++
+12
-8
layout.c++
c++/src/capnproto/layout.c++
+0
-0
layout.h
c++/src/capnproto/layout.h
+0
-0
type-safety.h
c++/src/capnproto/type-safety.h
+9
-0
CxxGenerator.hs
compiler/src/CxxGenerator.hs
+9
-1
c++-header.mustache
compiler/src/c++-header.mustache
+4
-3
No files found.
c++/src/capnproto/layout-test.c++
View file @
de33baaf
...
...
@@ -102,7 +102,8 @@ static const AlignedData<2> SUBSTRUCT_DEFAULT = {{0,0,0,0,1,0,0,0, 0,0,0,0,0,0,
static
const
AlignedData
<
2
>
STRUCTLIST_ELEMENT_SUBSTRUCT_DEFAULT
=
{{
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}};
static
constexpr
StructSize
STRUCTLIST_ELEMENT_SIZE
(
1
*
WORDS
,
1
*
REFERENCES
,
8
*
BYTES
);
static
constexpr
StructSize
STRUCTLIST_ELEMENT_SIZE
(
1
*
WORDS
,
1
*
REFERENCES
,
FieldSize
::
INLINE_COMPOSITE
);
static
void
setupStruct
(
StructBuilder
builder
)
{
builder
.
setDataField
<
uint64_t
>
(
0
*
ELEMENTS
,
0x1011121314151617ull
);
...
...
@@ -120,7 +121,7 @@ static void setupStruct(StructBuilder builder) {
{
StructBuilder
subStruct
=
builder
.
initStructField
(
0
*
REFERENCES
,
StructSize
(
1
*
WORDS
,
0
*
REFERENCES
,
8
*
BYTES
));
0
*
REFERENCES
,
StructSize
(
1
*
WORDS
,
0
*
REFERENCES
,
FieldSize
::
EIGHT_
BYTES
));
subStruct
.
setDataField
<
uint32_t
>
(
0
*
ELEMENTS
,
123
);
}
...
...
@@ -139,7 +140,8 @@ static void setupStruct(StructBuilder builder) {
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
StructBuilder
element
=
list
.
getStructElement
(
i
*
ELEMENTS
,
STRUCTLIST_ELEMENT_SIZE
);
element
.
setDataField
<
int32_t
>
(
0
*
ELEMENTS
,
300
+
i
);
element
.
initStructField
(
0
*
REFERENCES
,
StructSize
(
1
*
WORDS
,
0
*
REFERENCES
,
8
*
BYTES
))
element
.
initStructField
(
0
*
REFERENCES
,
StructSize
(
1
*
WORDS
,
0
*
REFERENCES
,
FieldSize
::
EIGHT_BYTES
))
.
setDataField
<
int32_t
>
(
0
*
ELEMENTS
,
400
+
i
);
}
}
...
...
@@ -174,7 +176,8 @@ static void checkStruct(StructBuilder builder) {
{
StructBuilder
subStruct
=
builder
.
getStructField
(
0
*
REFERENCES
,
StructSize
(
1
*
WORDS
,
0
*
REFERENCES
,
8
*
BYTES
),
SUBSTRUCT_DEFAULT
.
words
);
0
*
REFERENCES
,
StructSize
(
1
*
WORDS
,
0
*
REFERENCES
,
FieldSize
::
EIGHT_BYTES
),
SUBSTRUCT_DEFAULT
.
words
);
EXPECT_EQ
(
123u
,
subStruct
.
getDataField
<
uint32_t
>
(
0
*
ELEMENTS
));
}
...
...
@@ -193,7 +196,8 @@ static void checkStruct(StructBuilder builder) {
StructBuilder
element
=
list
.
getStructElement
(
i
*
ELEMENTS
,
STRUCTLIST_ELEMENT_SIZE
);
EXPECT_EQ
(
300
+
i
,
element
.
getDataField
<
int32_t
>
(
0
*
ELEMENTS
));
EXPECT_EQ
(
400
+
i
,
element
.
getStructField
(
0
*
REFERENCES
,
StructSize
(
1
*
WORDS
,
0
*
REFERENCES
,
8
*
BYTES
),
element
.
getStructField
(
0
*
REFERENCES
,
StructSize
(
1
*
WORDS
,
0
*
REFERENCES
,
FieldSize
::
EIGHT_BYTES
),
STRUCTLIST_ELEMENT_SUBSTRUCT_DEFAULT
.
words
)
.
getDataField
<
int32_t
>
(
0
*
ELEMENTS
));
}
...
...
@@ -272,7 +276,7 @@ TEST(WireFormat, StructRoundTrip_OneSegment) {
word
*
rootLocation
=
segment
->
allocate
(
1
*
WORDS
);
StructBuilder
builder
=
StructBuilder
::
initRoot
(
segment
,
rootLocation
,
StructSize
(
2
*
WORDS
,
4
*
REFERENCES
,
16
*
BYTES
));
segment
,
rootLocation
,
StructSize
(
2
*
WORDS
,
4
*
REFERENCES
,
FieldSize
::
INLINE_COMPOSITE
));
setupStruct
(
builder
);
// word count:
...
...
@@ -308,7 +312,7 @@ TEST(WireFormat, StructRoundTrip_OneSegmentPerAllocation) {
word
*
rootLocation
=
segment
->
allocate
(
1
*
WORDS
);
StructBuilder
builder
=
StructBuilder
::
initRoot
(
segment
,
rootLocation
,
StructSize
(
2
*
WORDS
,
4
*
REFERENCES
,
16
*
BYTES
));
segment
,
rootLocation
,
StructSize
(
2
*
WORDS
,
4
*
REFERENCES
,
FieldSize
::
INLINE_COMPOSITE
));
setupStruct
(
builder
);
// Verify that we made 15 segments.
...
...
@@ -345,7 +349,7 @@ TEST(WireFormat, StructRoundTrip_MultipleSegmentsWithMultipleAllocations) {
word
*
rootLocation
=
segment
->
allocate
(
1
*
WORDS
);
StructBuilder
builder
=
StructBuilder
::
initRoot
(
segment
,
rootLocation
,
StructSize
(
2
*
WORDS
,
4
*
REFERENCES
,
16
*
BYTES
));
segment
,
rootLocation
,
StructSize
(
2
*
WORDS
,
4
*
REFERENCES
,
FieldSize
::
INLINE_COMPOSITE
));
setupStruct
(
builder
);
// Verify that we made 6 segments.
...
...
c++/src/capnproto/layout.c++
View file @
de33baaf
This diff is collapsed.
Click to expand it.
c++/src/capnproto/layout.h
View file @
de33baaf
This diff is collapsed.
Click to expand it.
c++/src/capnproto/type-safety.h
View file @
de33baaf
...
...
@@ -353,6 +353,15 @@ public:
unit1PerUnit2
/
other
.
unit1PerUnit2
);
}
template
<
typename
OtherNumber
>
inline
decltype
(
Number
(
1
)
/
OtherNumber
(
1
))
operator
/
(
UnitRatio
<
OtherNumber
,
Unit1
,
Unit2
>
other
)
const
{
return
unit1PerUnit2
/
other
.
unit1PerUnit2
;
}
inline
bool
operator
==
(
UnitRatio
other
)
const
{
return
unit1PerUnit2
==
other
.
unit1PerUnit2
;
}
inline
bool
operator
!=
(
UnitRatio
other
)
const
{
return
unit1PerUnit2
!=
other
.
unit1PerUnit2
;
}
private
:
Number
unit1PerUnit2
;
...
...
compiler/src/CxxGenerator.hs
View file @
de33baaf
...
...
@@ -379,8 +379,16 @@ structContext parent desc = mkStrContext context where
context
"structFields"
=
MuList
$
map
(
fieldContext
context
)
$
structFields
desc
context
"structUnions"
=
MuList
$
map
(
unionContext
context
)
$
structUnions
desc
context
"structDataSize"
=
MuVariable
$
dataSectionWordSize
$
structDataSize
desc
context
"structDataBytes"
=
MuVariable
(
div
(
dataSectionBits
(
structDataSize
desc
))
8
)
context
"structReferenceCount"
=
MuVariable
$
structPointerCount
desc
context
"structPreferredListEncoding"
=
case
(
structDataSize
desc
,
structPointerCount
desc
)
of
(
DataSectionWords
0
,
0
)
->
MuVariable
"VOID"
(
DataSection1
,
0
)
->
MuVariable
"BYTE"
(
DataSection8
,
0
)
->
MuVariable
"BYTE"
(
DataSection16
,
0
)
->
MuVariable
"TWO_BYTES"
(
DataSection32
,
0
)
->
MuVariable
"FOUR_BYTES"
(
DataSectionWords
1
,
0
)
->
MuVariable
"EIGHT_BYTES"
(
DataSectionWords
0
,
1
)
->
MuVariable
"REFERENCE"
_
->
MuVariable
"INLINE_COMPOSITE"
context
"structNestedEnums"
=
MuList
$
map
(
enumContext
context
)
[
m
|
DescEnum
m
<-
structMembers
desc
]
context
"structNestedStructs"
=
...
...
compiler/src/c++-header.mustache
View file @
de33baaf
...
...
@@ -68,9 +68,10 @@ struct {{typeFullName}} {
{{/
structNestedEnums
}}
static constexpr ::capnproto::internal::StructSize STRUCT_SIZE =
::capnproto::internal::StructSize(
{{
structDataSize
}}
* ::capnproto::WORDS,
{{
structReferenceCount
}}
* ::capnproto::REFERENCES,
{{
structDataBytes
}}
* ::capnproto::BYTES);
::capnproto::internal::StructSize(
{{
structDataSize
}}
* ::capnproto::WORDS,
{{
structReferenceCount
}}
* ::capnproto::REFERENCES,
::capnproto::internal::FieldSize::
{{
structPreferredListEncoding
}}
);
{{/
typeStruct
}}
{{#
typeUnion
}}
...
...
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