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
abf4ed59
Commit
abf4ed59
authored
May 25, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support Clang compiler.
parent
eeae230c
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
158 additions
and
102 deletions
+158
-102
Makefile.ekam
c++/Makefile.ekam
+6
-0
capnpc-capnp.c++
c++/src/capnproto/compiler/capnpc-capnp.c++
+2
-1
dynamic.c++
c++/src/capnproto/dynamic.c++
+28
-28
dynamic.h
c++/src/capnproto/dynamic.h
+8
-7
exception.h
c++/src/capnproto/exception.h
+1
-1
generated-header-support.h
c++/src/capnproto/generated-header-support.h
+11
-1
io.c++
c++/src/capnproto/io.c++
+1
-1
layout.h
c++/src/capnproto/layout.h
+12
-14
list.h
c++/src/capnproto/list.h
+4
-4
logging.c++
c++/src/capnproto/logging.c++
+1
-1
macros.h
c++/src/capnproto/macros.h
+24
-2
message.h
c++/src/capnproto/message.h
+2
-2
schema-loader.c++
c++/src/capnproto/schema-loader.c++
+7
-7
schema.h
c++/src/capnproto/schema.h
+2
-1
serialize-snappy-test.c++
c++/src/capnproto/serialize-snappy-test.c++
+22
-22
serialize.c++
c++/src/capnproto/serialize.c++
+2
-2
type-safety.h
c++/src/capnproto/type-safety.h
+4
-4
util.h
c++/src/capnproto/util.h
+2
-2
c++-header.mustache
compiler/src/c++-header.mustache
+1
-1
c++-source.mustache
compiler/src/c++-source.mustache
+18
-1
No files found.
c++/Makefile.ekam
View file @
abf4ed59
...
@@ -17,6 +17,12 @@ continuous-opt:
...
@@ -17,6 +17,12 @@ continuous-opt:
continuous-opt3
:
continuous-opt3
:
CXX
=
g++-4.7
CXXFLAGS
=
'-std=gnu++0x -O3 -DNDEBUG -Wall'
LIBS
=
'-lz -pthread'
$(EKAM)
-j6
-c
-n
:51315
CXX
=
g++-4.7
CXXFLAGS
=
'-std=gnu++0x -O3 -DNDEBUG -Wall'
LIBS
=
'-lz -pthread'
$(EKAM)
-j6
-c
-n
:51315
continuous-clang
:
CXX
=
clang++
CXXFLAGS
=
'-fno-caret-diagnostics -std=c++1y -g -Wall'
LIBS
=
'-lz -pthread'
$(EKAM)
-j6
-c
-n
:51315
continuous-clang-opt
:
CXX
=
clang++
CXXFLAGS
=
'-fno-caret-diagnostics -std=c++11 -O2 -DNDEBUG -Wall'
LIBS
=
'-lz -pthread'
$(EKAM)
-j6
-c
-n
:51315
clean
:
clean
:
rm
-rf
bin lib tmp
rm
-rf
bin lib tmp
c++/src/capnproto/compiler/capnpc-capnp.c++
View file @
abf4ed59
...
@@ -579,7 +579,8 @@ TextBlob genNestedDecls(Schema schema, Indent indent) {
...
@@ -579,7 +579,8 @@ TextBlob genNestedDecls(Schema schema, Indent indent) {
TextBlob
genFile
(
Schema
file
)
{
TextBlob
genFile
(
Schema
file
)
{
auto
proto
=
file
.
getProto
();
auto
proto
=
file
.
getProto
();
auto
body
=
proto
.
getBody
();
auto
body
=
proto
.
getBody
();
PRECOND
(
body
.
which
()
==
schema
::
Node
::
Body
::
FILE_NODE
,
"Expected a file node."
,
body
.
which
());
PRECOND
(
body
.
which
()
==
schema
::
Node
::
Body
::
FILE_NODE
,
"Expected a file node."
,
(
uint
)
body
.
which
());
return
text
(
return
text
(
"# "
,
proto
.
getDisplayName
(),
"
\n
"
,
"# "
,
proto
.
getDisplayName
(),
"
\n
"
,
...
...
c++/src/capnproto/dynamic.c++
View file @
abf4ed59
...
@@ -37,18 +37,18 @@ inline T bitCast(U value) {
...
@@ -37,18 +37,18 @@ inline T bitCast(U value) {
static_assert
(
sizeof
(
T
)
==
sizeof
(
U
),
"Size must match."
);
static_assert
(
sizeof
(
T
)
==
sizeof
(
U
),
"Size must match."
);
return
value
;
return
value
;
}
}
template
<>
//
template <>
inline
float
bitCast
<
float
,
uint32_t
>
(
uint32_t
value
)
{
//
inline float bitCast<float, uint32_t>(uint32_t value) {
float
result
;
//
float result;
memcpy
(
&
result
,
&
value
,
sizeof
(
value
));
//
memcpy(&result, &value, sizeof(value));
return
result
;
//
return result;
}
//
}
template
<>
//
template <>
inline
double
bitCast
<
double
,
uint64_t
>
(
uint64_t
value
)
{
//
inline double bitCast<double, uint64_t>(uint64_t value) {
double
result
;
//
double result;
memcpy
(
&
result
,
&
value
,
sizeof
(
value
));
//
memcpy(&result, &value, sizeof(value));
return
result
;
//
return result;
}
//
}
template
<>
template
<>
inline
uint32_t
bitCast
<
uint32_t
,
float
>
(
float
value
)
{
inline
uint32_t
bitCast
<
uint32_t
,
float
>
(
float
value
)
{
uint32_t
result
;
uint32_t
result
;
...
@@ -454,7 +454,7 @@ DynamicStruct::Builder DynamicStruct::Builder::getObject(
...
@@ -454,7 +454,7 @@ DynamicStruct::Builder DynamicStruct::Builder::getObject(
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
DynamicStruct
::
Builder
();
return
DynamicStruct
::
Builder
();
}
}
DynamicList
::
Builder
DynamicStruct
::
Builder
::
getObject
(
DynamicList
::
Builder
DynamicStruct
::
Builder
::
getObject
(
...
@@ -473,7 +473,7 @@ DynamicList::Builder DynamicStruct::Builder::getObject(
...
@@ -473,7 +473,7 @@ DynamicList::Builder DynamicStruct::Builder::getObject(
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
DynamicList
::
Builder
();
return
DynamicList
::
Builder
();
}
}
Text
::
Builder
DynamicStruct
::
Builder
::
getObjectAsText
(
StructSchema
::
Member
member
)
{
Text
::
Builder
DynamicStruct
::
Builder
::
getObjectAsText
(
StructSchema
::
Member
member
)
{
...
@@ -491,7 +491,7 @@ Text::Builder DynamicStruct::Builder::getObjectAsText(StructSchema::Member membe
...
@@ -491,7 +491,7 @@ Text::Builder DynamicStruct::Builder::getObjectAsText(StructSchema::Member membe
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
Text
::
Builder
();
return
Text
::
Builder
();
}
}
Data
::
Builder
DynamicStruct
::
Builder
::
getObjectAsData
(
StructSchema
::
Member
member
)
{
Data
::
Builder
DynamicStruct
::
Builder
::
getObjectAsData
(
StructSchema
::
Member
member
)
{
...
@@ -509,7 +509,7 @@ Data::Builder DynamicStruct::Builder::getObjectAsData(StructSchema::Member membe
...
@@ -509,7 +509,7 @@ Data::Builder DynamicStruct::Builder::getObjectAsData(StructSchema::Member membe
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
Data
::
Builder
();
return
Data
::
Builder
();
}
}
...
@@ -529,7 +529,7 @@ DynamicStruct::Builder DynamicStruct::Builder::initObject(
...
@@ -529,7 +529,7 @@ DynamicStruct::Builder DynamicStruct::Builder::initObject(
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
DynamicStruct
::
Builder
();
return
DynamicStruct
::
Builder
();
}
}
DynamicList
::
Builder
DynamicStruct
::
Builder
::
initObject
(
DynamicList
::
Builder
DynamicStruct
::
Builder
::
initObject
(
...
@@ -548,7 +548,7 @@ DynamicList::Builder DynamicStruct::Builder::initObject(
...
@@ -548,7 +548,7 @@ DynamicList::Builder DynamicStruct::Builder::initObject(
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
DynamicList
::
Builder
();
return
DynamicList
::
Builder
();
}
}
Text
::
Builder
DynamicStruct
::
Builder
::
initObjectAsText
(
StructSchema
::
Member
member
,
uint
size
)
{
Text
::
Builder
DynamicStruct
::
Builder
::
initObjectAsText
(
StructSchema
::
Member
member
,
uint
size
)
{
...
@@ -566,7 +566,7 @@ Text::Builder DynamicStruct::Builder::initObjectAsText(StructSchema::Member memb
...
@@ -566,7 +566,7 @@ Text::Builder DynamicStruct::Builder::initObjectAsText(StructSchema::Member memb
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
Text
::
Builder
();
return
Text
::
Builder
();
}
}
Data
::
Builder
DynamicStruct
::
Builder
::
initObjectAsData
(
StructSchema
::
Member
member
,
uint
size
)
{
Data
::
Builder
DynamicStruct
::
Builder
::
initObjectAsData
(
StructSchema
::
Member
member
,
uint
size
)
{
...
@@ -584,7 +584,7 @@ Data::Builder DynamicStruct::Builder::initObjectAsData(StructSchema::Member memb
...
@@ -584,7 +584,7 @@ Data::Builder DynamicStruct::Builder::initObjectAsData(StructSchema::Member memb
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
Data
::
Builder
();
return
Data
::
Builder
();
}
}
...
@@ -660,7 +660,7 @@ DynamicValue::Reader DynamicStruct::Reader::getImpl(
...
@@ -660,7 +660,7 @@ DynamicValue::Reader DynamicStruct::Reader::getImpl(
case schema::Type::Body::discrim##_TYPE: \
case schema::Type::Body::discrim##_TYPE: \
return DynamicValue::Reader(reader.getDataField<type>( \
return DynamicValue::Reader(reader.getDataField<type>( \
field.getOffset() * ELEMENTS, \
field.getOffset() * ELEMENTS, \
bitCast<
typename internal::MaskType<type>::Type
>(dval.get##titleCase##Value())));
bitCast<
internal::Mask<type>
>(dval.get##titleCase##Value())));
HANDLE_TYPE
(
BOOL
,
Bool
,
bool
)
HANDLE_TYPE
(
BOOL
,
Bool
,
bool
)
HANDLE_TYPE
(
INT8
,
Int8
,
int8_t
)
HANDLE_TYPE
(
INT8
,
Int8
,
int8_t
)
...
@@ -729,7 +729,7 @@ DynamicValue::Reader DynamicStruct::Reader::getImpl(
...
@@ -729,7 +729,7 @@ DynamicValue::Reader DynamicStruct::Reader::getImpl(
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
nullptr
;
return
nullptr
;
}
}
...
@@ -752,7 +752,7 @@ DynamicValue::Builder DynamicStruct::Builder::getImpl(
...
@@ -752,7 +752,7 @@ DynamicValue::Builder DynamicStruct::Builder::getImpl(
case schema::Type::Body::discrim##_TYPE: \
case schema::Type::Body::discrim##_TYPE: \
return DynamicValue::Builder(builder.getDataField<type>( \
return DynamicValue::Builder(builder.getDataField<type>( \
field.getOffset() * ELEMENTS, \
field.getOffset() * ELEMENTS, \
bitCast<
typename internal::MaskType<type>::Type
>(dval.get##titleCase##Value())));
bitCast<
internal::Mask<type>
>(dval.get##titleCase##Value())));
HANDLE_TYPE
(
BOOL
,
Bool
,
bool
)
HANDLE_TYPE
(
BOOL
,
Bool
,
bool
)
HANDLE_TYPE
(
INT8
,
Int8
,
int8_t
)
HANDLE_TYPE
(
INT8
,
Int8
,
int8_t
)
...
@@ -832,7 +832,7 @@ DynamicValue::Builder DynamicStruct::Builder::getImpl(
...
@@ -832,7 +832,7 @@ DynamicValue::Builder DynamicStruct::Builder::getImpl(
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
return
nullptr
;
return
nullptr
;
}
}
DynamicStruct
::
Builder
DynamicStruct
::
Builder
::
getObjectImpl
(
DynamicStruct
::
Builder
DynamicStruct
::
Builder
::
getObjectImpl
(
...
@@ -964,12 +964,12 @@ void DynamicStruct::Builder::setImpl(
...
@@ -964,12 +964,12 @@ void DynamicStruct::Builder::setImpl(
return
;
return
;
}
}
FAIL_RECOVERABLE_PRECOND
(
"can't set field of unknown type"
,
type
.
which
());
FAIL_RECOVERABLE_PRECOND
(
"can't set field of unknown type"
,
(
uint
)
type
.
which
());
return
;
return
;
}
}
}
}
FAIL_CHECK
(
"switch() missing case."
,
member
.
getProto
().
getBody
().
which
());
FAIL_CHECK
(
"switch() missing case."
,
(
uint
)
member
.
getProto
().
getBody
().
which
());
}
}
DynamicValue
::
Builder
DynamicStruct
::
Builder
::
initImpl
(
DynamicValue
::
Builder
DynamicStruct
::
Builder
::
initImpl
(
...
@@ -992,7 +992,7 @@ DynamicValue::Builder DynamicStruct::Builder::initImpl(
...
@@ -992,7 +992,7 @@ DynamicValue::Builder DynamicStruct::Builder::initImpl(
return
initFieldAsDataImpl
(
builder
,
member
,
size
);
return
initFieldAsDataImpl
(
builder
,
member
,
size
);
default
:
default
:
FAIL_PRECOND
(
FAIL_PRECOND
(
"init() with size is only valid for list, text, or data fields."
,
type
.
which
());
"init() with size is only valid for list, text, or data fields."
,
(
uint
)
type
.
which
());
break
;
break
;
}
}
break
;
break
;
...
@@ -1245,7 +1245,7 @@ void DynamicList::Builder::set(uint index, DynamicValue::Reader value) {
...
@@ -1245,7 +1245,7 @@ void DynamicList::Builder::set(uint index, DynamicValue::Reader value) {
return
;
return
;
}
}
FAIL_RECOVERABLE_PRECOND
(
"can't set element of unknown type"
,
schema
.
whichElementType
());
FAIL_RECOVERABLE_PRECOND
(
"can't set element of unknown type"
,
(
uint
)
schema
.
whichElementType
());
}
}
DynamicValue
::
Builder
DynamicList
::
Builder
::
init
(
uint
index
,
uint
size
)
{
DynamicValue
::
Builder
DynamicList
::
Builder
::
init
(
uint
index
,
uint
size
)
{
...
...
c++/src/capnproto/dynamic.h
View file @
abf4ed59
...
@@ -277,7 +277,7 @@ private:
...
@@ -277,7 +277,7 @@ private:
static
DynamicValue
::
Reader
getImpl
(
internal
::
StructReader
reader
,
StructSchema
::
Member
member
);
static
DynamicValue
::
Reader
getImpl
(
internal
::
StructReader
reader
,
StructSchema
::
Member
member
);
template
<
typename
T
>
template
<
typename
T
,
Kind
K
>
friend
struct
internal
::
PointerHelpers
;
friend
struct
internal
::
PointerHelpers
;
friend
class
DynamicUnion
::
Reader
;
friend
class
DynamicUnion
::
Reader
;
friend
class
DynamicObject
;
friend
class
DynamicObject
;
...
@@ -287,7 +287,8 @@ private:
...
@@ -287,7 +287,8 @@ private:
friend
class
MessageBuilder
;
friend
class
MessageBuilder
;
template
<
typename
T
,
::
capnproto
::
Kind
k
>
template
<
typename
T
,
::
capnproto
::
Kind
k
>
friend
struct
::
capnproto
::
ToDynamic_
;
friend
struct
::
capnproto
::
ToDynamic_
;
friend
String
internal
::
debugString
(
StructReader
reader
,
const
RawSchema
&
schema
);
friend
String
internal
::
debugString
(
internal
::
StructReader
reader
,
const
internal
::
RawSchema
&
schema
);
};
};
class
DynamicStruct
::
Builder
{
class
DynamicStruct
::
Builder
{
...
@@ -382,7 +383,7 @@ private:
...
@@ -382,7 +383,7 @@ private:
static
Data
::
Builder
initFieldAsDataImpl
(
static
Data
::
Builder
initFieldAsDataImpl
(
internal
::
StructBuilder
builder
,
StructSchema
::
Member
field
,
uint
size
);
internal
::
StructBuilder
builder
,
StructSchema
::
Member
field
,
uint
size
);
template
<
typename
T
>
template
<
typename
T
,
Kind
k
>
friend
struct
internal
::
PointerHelpers
;
friend
struct
internal
::
PointerHelpers
;
friend
class
DynamicUnion
::
Builder
;
friend
class
DynamicUnion
::
Builder
;
friend
struct
DynamicList
;
friend
struct
DynamicList
;
...
@@ -421,7 +422,7 @@ private:
...
@@ -421,7 +422,7 @@ private:
Reader
(
ListSchema
schema
,
internal
::
ListReader
reader
)
:
schema
(
schema
),
reader
(
reader
)
{}
Reader
(
ListSchema
schema
,
internal
::
ListReader
reader
)
:
schema
(
schema
),
reader
(
reader
)
{}
template
<
typename
T
>
template
<
typename
T
,
Kind
k
>
friend
struct
internal
::
PointerHelpers
;
friend
struct
internal
::
PointerHelpers
;
friend
struct
DynamicStruct
;
friend
struct
DynamicStruct
;
friend
class
DynamicObject
;
friend
class
DynamicObject
;
...
@@ -463,7 +464,7 @@ private:
...
@@ -463,7 +464,7 @@ private:
Builder
(
ListSchema
schema
,
internal
::
ListBuilder
builder
)
:
schema
(
schema
),
builder
(
builder
)
{}
Builder
(
ListSchema
schema
,
internal
::
ListBuilder
builder
)
:
schema
(
schema
),
builder
(
builder
)
{}
template
<
typename
T
>
template
<
typename
T
,
Kind
k
>
friend
struct
internal
::
PointerHelpers
;
friend
struct
internal
::
PointerHelpers
;
friend
struct
DynamicStruct
;
friend
struct
DynamicStruct
;
template
<
typename
T
,
::
capnproto
::
Kind
k
>
template
<
typename
T
,
::
capnproto
::
Kind
k
>
...
@@ -855,14 +856,14 @@ struct DynamicValue::Builder::AsImpl<T, Kind::LIST> {
...
@@ -855,14 +856,14 @@ struct DynamicValue::Builder::AsImpl<T, Kind::LIST> {
template
<
typename
T
>
template
<
typename
T
>
struct
DynamicObject
::
AsImpl
<
T
,
Kind
::
STRUCT
>
{
struct
DynamicObject
::
AsImpl
<
T
,
Kind
::
STRUCT
>
{
static
T
apply
(
DynamicObject
value
)
{
static
T
apply
(
DynamicObject
value
)
{
return
value
.
as
(
Schema
::
from
<
T
>
()).
as
<
T
>
();
return
value
.
as
(
Schema
::
from
<
T
>
()).
template
as
<
T
>
();
}
}
};
};
template
<
typename
T
>
template
<
typename
T
>
struct
DynamicObject
::
AsImpl
<
T
,
Kind
::
LIST
>
{
struct
DynamicObject
::
AsImpl
<
T
,
Kind
::
LIST
>
{
static
T
apply
(
DynamicObject
value
)
{
static
T
apply
(
DynamicObject
value
)
{
return
value
.
as
(
Schema
::
from
<
T
>
()).
as
<
T
>
();
return
value
.
as
(
Schema
::
from
<
T
>
()).
template
as
<
T
>
();
}
}
};
};
...
...
c++/src/capnproto/exception.h
View file @
abf4ed59
...
@@ -114,7 +114,7 @@ private:
...
@@ -114,7 +114,7 @@ private:
mutable
Array
<
char
>
whatBuffer
;
mutable
Array
<
char
>
whatBuffer
;
};
};
class
Stringifier
;
struct
Stringifier
;
ArrayPtr
<
const
char
>
operator
*
(
const
Stringifier
&
,
Exception
::
Nature
nature
);
ArrayPtr
<
const
char
>
operator
*
(
const
Stringifier
&
,
Exception
::
Nature
nature
);
ArrayPtr
<
const
char
>
operator
*
(
const
Stringifier
&
,
Exception
::
Durability
durability
);
ArrayPtr
<
const
char
>
operator
*
(
const
Stringifier
&
,
Exception
::
Durability
durability
);
...
...
c++/src/capnproto/generated-header-support.h
View file @
abf4ed59
...
@@ -36,7 +36,7 @@ class MessageBuilder; // So that it can be declared a friend.
...
@@ -36,7 +36,7 @@ class MessageBuilder; // So that it can be declared a friend.
template
<
typename
T
,
Kind
k
=
kind
<
T
>
()
>
template
<
typename
T
,
Kind
k
=
kind
<
T
>
()
>
struct
ToDynamic_
;
// Defined in dynamic.h, needs to be declared as everyone's friend.
struct
ToDynamic_
;
// Defined in dynamic.h, needs to be declared as everyone's friend.
class
DynamicStruct
;
// So that it can be declared a friend.
struct
DynamicStruct
;
// So that it can be declared a friend.
namespace
internal
{
namespace
internal
{
...
@@ -195,6 +195,9 @@ inline constexpr uint64_t typeId() { return internal::TypeIdFor<T>::typeId; }
...
@@ -195,6 +195,9 @@ inline constexpr uint64_t typeId() { return internal::TypeIdFor<T>::typeId; }
template <> struct RawSchemaFor<type> { \
template <> struct RawSchemaFor<type> { \
static inline const RawSchema& getSchema() { return schemas::s_##id; } \
static inline const RawSchema& getSchema() { return schemas::s_##id; } \
}
}
#define CAPNPROTO_DEFINE_ENUM(type) \
constexpr Kind KindOf<type>::kind; \
constexpr uint64_t TypeIdFor<type>::typeId;
#define CAPNPROTO_DECLARE_STRUCT(type, id, dataWordSize, pointerCount, preferredElementEncoding) \
#define CAPNPROTO_DECLARE_STRUCT(type, id, dataWordSize, pointerCount, preferredElementEncoding) \
template <> struct KindOf<type> { static constexpr Kind kind = Kind::STRUCT; }; \
template <> struct KindOf<type> { static constexpr Kind kind = Kind::STRUCT; }; \
template <> struct StructSizeFor<type> { \
template <> struct StructSizeFor<type> { \
...
@@ -205,11 +208,18 @@ inline constexpr uint64_t typeId() { return internal::TypeIdFor<T>::typeId; }
...
@@ -205,11 +208,18 @@ inline constexpr uint64_t typeId() { return internal::TypeIdFor<T>::typeId; }
template <> struct RawSchemaFor<type> { \
template <> struct RawSchemaFor<type> { \
static inline const RawSchema& getSchema() { return schemas::s_##id; } \
static inline const RawSchema& getSchema() { return schemas::s_##id; } \
}
}
#define CAPNPROTO_DEFINE_STRUCT(type) \
constexpr Kind KindOf<type>::kind; \
constexpr StructSize StructSizeFor<type>::value; \
constexpr uint64_t TypeIdFor<type>::typeId;
#define CAPNPROTO_DECLARE_INTERFACE(type, id) \
#define CAPNPROTO_DECLARE_INTERFACE(type, id) \
template <> struct KindOf<type> { static constexpr Kind kind = Kind::INTERFACE; }; \
template <> struct KindOf<type> { static constexpr Kind kind = Kind::INTERFACE; }; \
template <> struct TypeIdFor<type> { static constexpr uint64_t typeId = 0x##id; }; \
template <> struct TypeIdFor<type> { static constexpr uint64_t typeId = 0x##id; }; \
template <> struct RawSchemaFor<type> { \
template <> struct RawSchemaFor<type> { \
static inline const RawSchema& getSchema() { return schemas::s_##id; } \
static inline const RawSchema& getSchema() { return schemas::s_##id; } \
}
}
#define CAPNPROTO_DEFINE_INTERFACE(type) \
constexpr Kind KindOf<type>::kind; \
constexpr uint64_t TypeIdFor<type>::typeId;
#endif // CAPNPROTO_GENERATED_HEADER_SUPPORT_H_
#endif // CAPNPROTO_GENERATED_HEADER_SUPPORT_H_
c++/src/capnproto/io.c++
View file @
abf4ed59
...
@@ -265,7 +265,7 @@ void FdOutputStream::write(const void* buffer, size_t size) {
...
@@ -265,7 +265,7 @@ void FdOutputStream::write(const void* buffer, size_t size) {
}
}
void
FdOutputStream
::
write
(
ArrayPtr
<
const
ArrayPtr
<
const
byte
>>
pieces
)
{
void
FdOutputStream
::
write
(
ArrayPtr
<
const
ArrayPtr
<
const
byte
>>
pieces
)
{
CAPNPROTO_STACK_ARRAY
(
struct
iovec
,
iov
,
pieces
.
size
(),
128
);
CAPNPROTO_STACK_ARRAY
(
struct
iovec
,
iov
,
pieces
.
size
(),
1
6
,
1
28
);
for
(
uint
i
=
0
;
i
<
pieces
.
size
();
i
++
)
{
for
(
uint
i
=
0
;
i
<
pieces
.
size
();
i
++
)
{
// writev() interface is not const-correct. :(
// writev() interface is not const-correct. :(
...
...
c++/src/capnproto/layout.h
View file @
abf4ed59
...
@@ -42,8 +42,8 @@ class StructBuilder;
...
@@ -42,8 +42,8 @@ class StructBuilder;
class
StructReader
;
class
StructReader
;
class
ListBuilder
;
class
ListBuilder
;
class
ListReader
;
class
ListReader
;
class
ObjectBuilder
;
struct
ObjectBuilder
;
class
ObjectReader
;
struct
ObjectReader
;
struct
WirePointer
;
struct
WirePointer
;
struct
WireHelpers
;
struct
WireHelpers
;
class
SegmentReader
;
class
SegmentReader
;
...
@@ -100,18 +100,16 @@ enum class FieldSize: uint8_t {
...
@@ -100,18 +100,16 @@ enum class FieldSize: uint8_t {
typedef
decltype
(
BITS
/
ELEMENTS
)
BitsPerElement
;
typedef
decltype
(
BITS
/
ELEMENTS
)
BitsPerElement
;
typedef
decltype
(
POINTERS
/
ELEMENTS
)
PointersPerElement
;
typedef
decltype
(
POINTERS
/
ELEMENTS
)
PointersPerElement
;
namespace
internal
{
static
constexpr
BitsPerElement
BITS_PER_ELEMENT_TABLE
[
8
]
=
{
static
constexpr
BitsPerElement
BITS_PER_ELEMENT_TABLE
[
8
]
=
{
0
*
BITS
/
ELEMENTS
,
0
*
BITS
/
ELEMENTS
,
1
*
BITS
/
ELEMENTS
,
1
*
BITS
/
ELEMENTS
,
8
*
BITS
/
ELEMENTS
,
8
*
BITS
/
ELEMENTS
,
16
*
BITS
/
ELEMENTS
,
16
*
BITS
/
ELEMENTS
,
32
*
BITS
/
ELEMENTS
,
32
*
BITS
/
ELEMENTS
,
64
*
BITS
/
ELEMENTS
,
64
*
BITS
/
ELEMENTS
,
0
*
BITS
/
ELEMENTS
,
0
*
BITS
/
ELEMENTS
,
0
*
BITS
/
ELEMENTS
0
*
BITS
/
ELEMENTS
};
};
}
inline
constexpr
BitsPerElement
dataBitsPerElement
(
FieldSize
size
)
{
inline
constexpr
BitsPerElement
dataBitsPerElement
(
FieldSize
size
)
{
return
internal
::
BITS_PER_ELEMENT_TABLE
[
static_cast
<
int
>
(
size
)];
return
internal
::
BITS_PER_ELEMENT_TABLE
[
static_cast
<
int
>
(
size
)];
...
...
c++/src/capnproto/list.h
View file @
abf4ed59
...
@@ -266,7 +266,7 @@ private:
...
@@ -266,7 +266,7 @@ private:
}
}
template
<
typename
U
,
Kind
k
>
template
<
typename
U
,
Kind
k
>
friend
class
List
;
friend
struct
List
;
template
<
typename
U
,
Kind
K
>
template
<
typename
U
,
Kind
K
>
friend
struct
internal
::
PointerHelpers
;
friend
struct
internal
::
PointerHelpers
;
};
};
...
@@ -359,7 +359,7 @@ private:
...
@@ -359,7 +359,7 @@ private:
}
}
template
<
typename
U
,
Kind
k
>
template
<
typename
U
,
Kind
k
>
friend
class
List
;
friend
struct
List
;
template
<
typename
U
,
Kind
K
>
template
<
typename
U
,
Kind
K
>
friend
struct
internal
::
PointerHelpers
;
friend
struct
internal
::
PointerHelpers
;
};
};
...
@@ -457,7 +457,7 @@ private:
...
@@ -457,7 +457,7 @@ private:
}
}
template
<
typename
U
,
Kind
k
>
template
<
typename
U
,
Kind
k
>
friend
class
List
;
friend
struct
List
;
template
<
typename
U
,
Kind
K
>
template
<
typename
U
,
Kind
K
>
friend
struct
internal
::
PointerHelpers
;
friend
struct
internal
::
PointerHelpers
;
};
};
...
@@ -546,7 +546,7 @@ private:
...
@@ -546,7 +546,7 @@ private:
}
}
template
<
typename
U
,
Kind
k
>
template
<
typename
U
,
Kind
k
>
friend
class
List
;
friend
struct
List
;
template
<
typename
U
,
Kind
K
>
template
<
typename
U
,
Kind
K
>
friend
struct
internal
::
PointerHelpers
;
friend
struct
internal
::
PointerHelpers
;
};
};
...
...
c++/src/capnproto/logging.c++
View file @
abf4ed59
...
@@ -54,7 +54,7 @@ enum DescriptionStyle {
...
@@ -54,7 +54,7 @@ enum DescriptionStyle {
static
Array
<
char
>
makeDescription
(
DescriptionStyle
style
,
const
char
*
code
,
int
errorNumber
,
static
Array
<
char
>
makeDescription
(
DescriptionStyle
style
,
const
char
*
code
,
int
errorNumber
,
const
char
*
macroArgs
,
ArrayPtr
<
Array
<
char
>>
argValues
)
{
const
char
*
macroArgs
,
ArrayPtr
<
Array
<
char
>>
argValues
)
{
ArrayPtr
<
const
char
>
argNames
[
argValues
.
size
()]
;
CAPNPROTO_STACK_ARRAY
(
ArrayPtr
<
const
char
>
,
argNames
,
argValues
.
size
(),
8
,
64
)
;
if
(
argValues
.
size
()
>
0
)
{
if
(
argValues
.
size
()
>
0
)
{
size_t
index
=
0
;
size_t
index
=
0
;
...
...
c++/src/capnproto/macros.h
View file @
abf4ed59
...
@@ -31,7 +31,11 @@
...
@@ -31,7 +31,11 @@
#warning "Did you forget to enable C++11? Make sure to pass -std=gnu++11 to GCC."
#warning "Did you forget to enable C++11? Make sure to pass -std=gnu++11 to GCC."
#endif
#endif
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
#if __clang__
#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 2)
#warning "Cap'n Proto requires at least Clang 3.2."
#endif
#elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
#warning "Cap'n Proto requires at least GCC 4.7."
#warning "Cap'n Proto requires at least GCC 4.7."
#endif
#endif
#endif
#endif
...
@@ -61,6 +65,13 @@ namespace internal {
...
@@ -61,6 +65,13 @@ namespace internal {
#endif
#endif
#define CAPNPROTO_NORETURN __attribute__((noreturn));
#define CAPNPROTO_NORETURN __attribute__((noreturn));
#define CAPNPROTO_UNUSED __attribute__((unused));
#if __clang__
#define CAPNPROTO_UNUSED_FOR_CLANG __attribute__((unused));
#else
#define CAPNPROTO_UNUSED_FOR_CLANG
#endif
void
inlinePreconditionFailure
(
void
inlinePreconditionFailure
(
const
char
*
file
,
int
line
,
const
char
*
expectation
,
const
char
*
macroArgs
,
const
char
*
file
,
int
line
,
const
char
*
expectation
,
const
char
*
macroArgs
,
...
@@ -82,7 +93,17 @@ void inlinePreconditionFailure(
...
@@ -82,7 +93,17 @@ void inlinePreconditionFailure(
// Allocate an array, preferably on the stack, unless it is too big. On GCC this will use
// Allocate an array, preferably on the stack, unless it is too big. On GCC this will use
// variable-sized arrays. For other compilers we could just use a fixed-size array.
// variable-sized arrays. For other compilers we could just use a fixed-size array.
#define CAPNPROTO_STACK_ARRAY(type, name, size, maxStack) \
#if __clang__
#define CAPNPROTO_STACK_ARRAY(type, name, size, minStack, maxStack) \
size_t name##_size = (size); \
bool name##_isOnStack = name##_size <= (minStack); \
type name##_stack[minStack]; \
::capnproto::Array<type> name##_heap = name##_isOnStack ? \
nullptr : newArray<type>(name##_size); \
::capnproto::ArrayPtr<type> name = name##_isOnStack ? \
arrayPtr(name##_stack, name##_size) : name##_heap
#else
#define CAPNPROTO_STACK_ARRAY(type, name, size, minStack, maxStack) \
size_t name##_size = (size); \
size_t name##_size = (size); \
bool name##_isOnStack = name##_size <= (maxStack); \
bool name##_isOnStack = name##_size <= (maxStack); \
type name##_stack[name##_isOnStack ? size : 0]; \
type name##_stack[name##_isOnStack ? size : 0]; \
...
@@ -90,6 +111,7 @@ void inlinePreconditionFailure(
...
@@ -90,6 +111,7 @@ void inlinePreconditionFailure(
nullptr : newArray<type>(name##_size); \
nullptr : newArray<type>(name##_size); \
::capnproto::ArrayPtr<type> name = name##_isOnStack ? \
::capnproto::ArrayPtr<type> name = name##_isOnStack ? \
arrayPtr(name##_stack, name##_size) : name##_heap
arrayPtr(name##_stack, name##_size) : name##_heap
#endif
}
// namespace internal
}
// namespace internal
...
...
c++/src/capnproto/message.h
View file @
abf4ed59
...
@@ -171,7 +171,7 @@ private:
...
@@ -171,7 +171,7 @@ private:
void
setRootInternal
(
internal
::
StructReader
reader
);
void
setRootInternal
(
internal
::
StructReader
reader
);
internal
::
StructBuilder
getRoot
(
internal
::
StructSize
size
);
internal
::
StructBuilder
getRoot
(
internal
::
StructSize
size
);
friend
struct
SchemaLoader
;
// for a dirty hack, see schema-loader.c++.
friend
class
SchemaLoader
;
// for a dirty hack, see schema-loader.c++.
};
};
template
<
typename
RootType
>
template
<
typename
RootType
>
...
@@ -207,7 +207,7 @@ void copyToUnchecked(Reader&& reader, ArrayPtr<word> uncheckedBuffer);
...
@@ -207,7 +207,7 @@ void copyToUnchecked(Reader&& reader, ArrayPtr<word> uncheckedBuffer);
// otherwise an exception will be thrown.
// otherwise an exception will be thrown.
template
<
typename
Type
>
template
<
typename
Type
>
typename
Type
::
Reader
defaultValue
();
static
typename
Type
::
Reader
defaultValue
();
// Get a default instance of the given struct or list type.
// Get a default instance of the given struct or list type.
//
//
// TODO(cleanup): Find a better home for this function?
// TODO(cleanup): Find a better home for this function?
...
...
c++/src/capnproto/schema-loader.c++
View file @
abf4ed59
...
@@ -84,7 +84,7 @@ public:
...
@@ -84,7 +84,7 @@ public:
nodeName
=
node
.
getDisplayName
();
nodeName
=
node
.
getDisplayName
();
dependencies
.
clear
();
dependencies
.
clear
();
CONTEXT
(
"validating schema node"
,
nodeName
,
node
.
getBody
().
which
());
CONTEXT
(
"validating schema node"
,
nodeName
,
(
uint
)
node
.
getBody
().
which
());
switch
(
node
.
getBody
().
which
())
{
switch
(
node
.
getBody
().
which
())
{
case
schema
:
:
Node
::
Body
::
FILE_NODE
:
case
schema
:
:
Node
::
Body
::
FILE_NODE
:
...
@@ -211,9 +211,9 @@ private:
...
@@ -211,9 +211,9 @@ private:
}
}
}
}
CAPNPROTO_STACK_ARRAY
(
bool
,
sawCodeOrder
,
members
.
size
(),
256
);
CAPNPROTO_STACK_ARRAY
(
bool
,
sawCodeOrder
,
members
.
size
(),
32
,
256
);
memset
(
sawCodeOrder
.
begin
(),
0
,
sawCodeOrder
.
size
()
*
sizeof
(
sawCodeOrder
[
0
]));
memset
(
sawCodeOrder
.
begin
(),
0
,
sawCodeOrder
.
size
()
*
sizeof
(
sawCodeOrder
[
0
]));
CAPNPROTO_STACK_ARRAY
(
bool
,
sawOrdinal
,
ordinalCount
,
256
);
CAPNPROTO_STACK_ARRAY
(
bool
,
sawOrdinal
,
ordinalCount
,
32
,
256
);
memset
(
sawOrdinal
.
begin
(),
0
,
sawOrdinal
.
size
()
*
sizeof
(
sawOrdinal
[
0
]));
memset
(
sawOrdinal
.
begin
(),
0
,
sawOrdinal
.
size
()
*
sizeof
(
sawOrdinal
[
0
]));
uint
index
=
0
;
uint
index
=
0
;
...
@@ -265,7 +265,7 @@ private:
...
@@ -265,7 +265,7 @@ private:
"Schema invalid: Union discriminant out-of-bounds."
);
"Schema invalid: Union discriminant out-of-bounds."
);
auto
uMembers
=
u
.
getMembers
();
auto
uMembers
=
u
.
getMembers
();
CAPNPROTO_STACK_ARRAY
(
bool
,
uSawCodeOrder
,
uMembers
.
size
(),
256
);
CAPNPROTO_STACK_ARRAY
(
bool
,
uSawCodeOrder
,
uMembers
.
size
(),
32
,
256
);
memset
(
uSawCodeOrder
.
begin
(),
0
,
uSawCodeOrder
.
size
()
*
sizeof
(
uSawCodeOrder
[
0
]));
memset
(
uSawCodeOrder
.
begin
(),
0
,
uSawCodeOrder
.
size
()
*
sizeof
(
uSawCodeOrder
[
0
]));
uint
subIndex
=
0
;
uint
subIndex
=
0
;
...
@@ -285,7 +285,7 @@ private:
...
@@ -285,7 +285,7 @@ private:
void
validate
(
schema
::
EnumNode
::
Reader
enumNode
)
{
void
validate
(
schema
::
EnumNode
::
Reader
enumNode
)
{
auto
enumerants
=
enumNode
.
getEnumerants
();
auto
enumerants
=
enumNode
.
getEnumerants
();
CAPNPROTO_STACK_ARRAY
(
bool
,
sawCodeOrder
,
enumerants
.
size
(),
256
);
CAPNPROTO_STACK_ARRAY
(
bool
,
sawCodeOrder
,
enumerants
.
size
(),
32
,
256
);
memset
(
sawCodeOrder
.
begin
(),
0
,
sawCodeOrder
.
size
()
*
sizeof
(
sawCodeOrder
[
0
]));
memset
(
sawCodeOrder
.
begin
(),
0
,
sawCodeOrder
.
size
()
*
sizeof
(
sawCodeOrder
[
0
]));
uint
index
=
0
;
uint
index
=
0
;
...
@@ -302,7 +302,7 @@ private:
...
@@ -302,7 +302,7 @@ private:
void
validate
(
schema
::
InterfaceNode
::
Reader
interfaceNode
)
{
void
validate
(
schema
::
InterfaceNode
::
Reader
interfaceNode
)
{
auto
methods
=
interfaceNode
.
getMethods
();
auto
methods
=
interfaceNode
.
getMethods
();
CAPNPROTO_STACK_ARRAY
(
bool
,
sawCodeOrder
,
methods
.
size
(),
256
);
CAPNPROTO_STACK_ARRAY
(
bool
,
sawCodeOrder
,
methods
.
size
(),
32
,
256
);
memset
(
sawCodeOrder
.
begin
(),
0
,
sawCodeOrder
.
size
()
*
sizeof
(
sawCodeOrder
[
0
]));
memset
(
sawCodeOrder
.
begin
(),
0
,
sawCodeOrder
.
size
()
*
sizeof
(
sawCodeOrder
[
0
]));
uint
index
=
0
;
uint
index
=
0
;
...
@@ -422,7 +422,7 @@ private:
...
@@ -422,7 +422,7 @@ private:
auto
node
=
readMessageUnchecked
<
schema
::
Node
>
(
existing
->
encodedNode
);
auto
node
=
readMessageUnchecked
<
schema
::
Node
>
(
existing
->
encodedNode
);
VALIDATE_SCHEMA
(
node
.
getBody
().
which
()
==
expectedKind
,
VALIDATE_SCHEMA
(
node
.
getBody
().
which
()
==
expectedKind
,
"expected a different kind of node for this ID"
,
"expected a different kind of node for this ID"
,
id
,
expectedKind
,
node
.
getBody
().
which
(),
node
.
getDisplayName
());
id
,
(
uint
)
expectedKind
,
(
uint
)
node
.
getBody
().
which
(),
node
.
getDisplayName
());
dependencies
.
insert
(
std
::
make_pair
(
id
,
existing
));
dependencies
.
insert
(
std
::
make_pair
(
id
,
existing
));
return
;
return
;
}
}
...
...
c++/src/capnproto/schema.h
View file @
abf4ed59
...
@@ -124,7 +124,8 @@ private:
...
@@ -124,7 +124,8 @@ private:
return
StructSchema
(
&
internal
::
rawSchema
<
T
>
());
return
StructSchema
(
&
internal
::
rawSchema
<
T
>
());
}
}
friend
class
Schema
;
friend
class
Schema
;
friend
String
internal
::
debugString
(
StructReader
reader
,
const
RawSchema
&
schema
);
friend
String
internal
::
debugString
(
internal
::
StructReader
reader
,
const
internal
::
RawSchema
&
schema
);
};
};
class
StructSchema
::
Member
{
class
StructSchema
::
Member
{
...
...
c++/src/capnproto/serialize-snappy-test.c++
View file @
abf4ed59
...
@@ -119,28 +119,28 @@ private:
...
@@ -119,28 +119,28 @@ private:
std
::
string
::
size_type
readPos
;
std
::
string
::
size_type
readPos
;
};
};
struct
DisplayByteArray
{
//
struct DisplayByteArray {
DisplayByteArray
(
const
std
::
string
&
str
)
//
DisplayByteArray(const std::string& str)
:
data
(
reinterpret_cast
<
const
uint8_t
*>
(
str
.
data
())),
size
(
str
.
size
())
{}
//
: data(reinterpret_cast<const uint8_t*>(str.data())), size(str.size()) {}
DisplayByteArray
(
const
std
::
initializer_list
<
uint8_t
>&
list
)
//
DisplayByteArray(const std::initializer_list<uint8_t>& list)
:
data
(
list
.
begin
()),
size
(
list
.
size
())
{}
//
: data(list.begin()), size(list.size()) {}
//
const
uint8_t
*
data
;
//
const uint8_t* data;
size_t
size
;
//
size_t size;
};
//
};
//
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
DisplayByteArray
&
bytes
)
{
//
std::ostream& operator<<(std::ostream& os, const DisplayByteArray& bytes) {
os
<<
"{ "
;
//
os << "{ ";
for
(
size_t
i
=
0
;
i
<
bytes
.
size
;
i
++
)
{
//
for (size_t i = 0; i < bytes.size; i++) {
if
(
i
>
0
)
{
//
if (i > 0) {
os
<<
", "
;
//
os << ", ";
}
//
}
os
<<
(
uint
)
bytes
.
data
[
i
];
//
os << (uint)bytes.data[i];
}
//
}
os
<<
" }"
;
//
os << " }";
//
return
os
;
//
return os;
}
//
}
TEST
(
Snappy
,
RoundTrip
)
{
TEST
(
Snappy
,
RoundTrip
)
{
TestMessageBuilder
builder
(
1
);
TestMessageBuilder
builder
(
1
);
...
...
c++/src/capnproto/serialize.c++
View file @
abf4ed59
...
@@ -252,7 +252,7 @@ void writeMessage(OutputStream& output, ArrayPtr<const ArrayPtr<const word>> seg
...
@@ -252,7 +252,7 @@ void writeMessage(OutputStream& output, ArrayPtr<const ArrayPtr<const word>> seg
table
[
segments
.
size
()
+
1
].
set
(
0
);
table
[
segments
.
size
()
+
1
].
set
(
0
);
}
}
ArrayPtr
<
const
byte
>
pieces
[
segments
.
size
()
+
1
]
;
CAPNPROTO_STACK_ARRAY
(
ArrayPtr
<
const
byte
>
,
pieces
,
segments
.
size
()
+
1
,
4
,
32
)
;
pieces
[
0
]
=
arrayPtr
(
reinterpret_cast
<
byte
*>
(
table
),
sizeof
(
table
));
pieces
[
0
]
=
arrayPtr
(
reinterpret_cast
<
byte
*>
(
table
),
sizeof
(
table
));
for
(
uint
i
=
0
;
i
<
segments
.
size
();
i
++
)
{
for
(
uint
i
=
0
;
i
<
segments
.
size
();
i
++
)
{
...
@@ -260,7 +260,7 @@ void writeMessage(OutputStream& output, ArrayPtr<const ArrayPtr<const word>> seg
...
@@ -260,7 +260,7 @@ void writeMessage(OutputStream& output, ArrayPtr<const ArrayPtr<const word>> seg
reinterpret_cast
<
const
byte
*>
(
segments
[
i
].
end
()));
reinterpret_cast
<
const
byte
*>
(
segments
[
i
].
end
()));
}
}
output
.
write
(
arrayPtr
(
pieces
,
segments
.
size
()
+
1
)
);
output
.
write
(
pieces
);
}
}
// =======================================================================================
// =======================================================================================
...
...
c++/src/capnproto/type-safety.h
View file @
abf4ed59
...
@@ -449,7 +449,7 @@ inline constexpr ArrayPtr<T> arrayPtr(T* begin, T* end) {
...
@@ -449,7 +449,7 @@ inline constexpr ArrayPtr<T> arrayPtr(T* begin, T* end) {
return
ArrayPtr
<
T
>
(
begin
,
end
);
return
ArrayPtr
<
T
>
(
begin
,
end
);
}
}
inline
constexpr
ArrayPtr
<
const
char
>
arrayPtr
(
const
char
*
s
)
{
inline
ArrayPtr
<
const
char
>
arrayPtr
(
const
char
*
s
)
{
// Use this function to construct an ArrayPtr from a NUL-terminated string, especially a literal.
// Use this function to construct an ArrayPtr from a NUL-terminated string, especially a literal.
return
arrayPtr
(
s
,
strlen
(
s
));
return
arrayPtr
(
s
,
strlen
(
s
));
}
}
...
@@ -963,8 +963,8 @@ inline constexpr auto operator*(UnitRatio<Number1, Unit2, Unit> ratio,
...
@@ -963,8 +963,8 @@ inline constexpr auto operator*(UnitRatio<Number1, Unit2, Unit> ratio,
// =======================================================================================
// =======================================================================================
// Raw memory types and measures
// Raw memory types and measures
class
byte
{
uint8_t
content
;
CAPNPROTO_DISALLOW_COPY
(
byte
);
public
:
byte
()
=
default
;
};
class
byte
{
uint8_t
content
CAPNPROTO_UNUSED_FOR_CLANG
;
CAPNPROTO_DISALLOW_COPY
(
byte
);
public
:
byte
()
=
default
;
};
class
word
{
uint64_t
content
;
CAPNPROTO_DISALLOW_COPY
(
word
);
public
:
word
()
=
default
;
};
class
word
{
uint64_t
content
CAPNPROTO_UNUSED_FOR_CLANG
;
CAPNPROTO_DISALLOW_COPY
(
word
);
public
:
word
()
=
default
;
};
// byte and word are opaque types with sizes of 8 and 64 bits, respectively. These types are useful
// byte and word are opaque types with sizes of 8 and 64 bits, respectively. These types are useful
// only to make pointer arithmetic clearer. Since the contents are private, the only way to access
// only to make pointer arithmetic clearer. Since the contents are private, the only way to access
// them is to first reinterpret_cast to some other pointer type.
// them is to first reinterpret_cast to some other pointer type.
...
@@ -978,7 +978,7 @@ class word { uint64_t content; CAPNPROTO_DISALLOW_COPY(word); public: word() = d
...
@@ -978,7 +978,7 @@ class word { uint64_t content; CAPNPROTO_DISALLOW_COPY(word); public: word() = d
static_assert
(
sizeof
(
byte
)
==
1
,
"uint8_t is not one byte?"
);
static_assert
(
sizeof
(
byte
)
==
1
,
"uint8_t is not one byte?"
);
static_assert
(
sizeof
(
word
)
==
8
,
"uint64_t is not 8 bytes?"
);
static_assert
(
sizeof
(
word
)
==
8
,
"uint64_t is not 8 bytes?"
);
namespace
internal
{
class
BitLabel
;
class
ElementLabel
;
class
WirePointer
;
}
namespace
internal
{
class
BitLabel
;
class
ElementLabel
;
struct
WirePointer
;
}
#ifndef CAPNPROTO_DEBUG_TYPES
#ifndef CAPNPROTO_DEBUG_TYPES
#define CAPNPROTO_DEBUG_TYPES 1
#define CAPNPROTO_DEBUG_TYPES 1
...
...
c++/src/capnproto/util.h
View file @
abf4ed59
...
@@ -209,7 +209,7 @@ struct Stringifier {
...
@@ -209,7 +209,7 @@ struct Stringifier {
template
<
typename
T
>
template
<
typename
T
>
Array
<
char
>
operator
*
(
const
Array
<
T
>&
arr
)
const
;
Array
<
char
>
operator
*
(
const
Array
<
T
>&
arr
)
const
;
};
};
static
constexpr
Stringifier
STR
;
static
constexpr
Stringifier
STR
=
Stringifier
()
;
CappedArray
<
char
,
sizeof
(
unsigned
short
)
*
4
>
hex
(
unsigned
short
i
);
CappedArray
<
char
,
sizeof
(
unsigned
short
)
*
4
>
hex
(
unsigned
short
i
);
CappedArray
<
char
,
sizeof
(
unsigned
int
)
*
4
>
hex
(
unsigned
int
i
);
CappedArray
<
char
,
sizeof
(
unsigned
int
)
*
4
>
hex
(
unsigned
int
i
);
...
@@ -230,7 +230,7 @@ Array<char> str(Params&&... params) {
...
@@ -230,7 +230,7 @@ Array<char> str(Params&&... params) {
template
<
typename
T
>
template
<
typename
T
>
Array
<
char
>
strArray
(
T
&&
arr
,
const
char
*
delim
)
{
Array
<
char
>
strArray
(
T
&&
arr
,
const
char
*
delim
)
{
size_t
delimLen
=
strlen
(
delim
);
size_t
delimLen
=
strlen
(
delim
);
decltype
(
STR
*
arr
[
0
])
pieces
[
arr
.
size
()]
;
CAPNPROTO_STACK_ARRAY
(
decltype
(
STR
*
arr
[
0
]),
pieces
,
arr
.
size
(),
8
,
32
)
;
size_t
size
=
0
;
size_t
size
=
0
;
for
(
size_t
i
=
0
;
i
<
arr
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
arr
.
size
();
i
++
)
{
if
(
i
>
0
)
size
+=
delimLen
;
if
(
i
>
0
)
size
+=
delimLen
;
...
...
compiler/src/c++-header.mustache
View file @
abf4ed59
...
@@ -185,7 +185,7 @@ private:
...
@@ -185,7 +185,7 @@ private:
friend struct ::capnproto::ToDynamic_;
friend struct ::capnproto::ToDynamic_;
template
<typename
T
,
::capnproto::Kind
k
>
template
<typename
T
,
::capnproto::Kind
k
>
friend struct ::capnproto::internal::PointerHelpers;
friend struct ::capnproto::internal::PointerHelpers;
friend
struct
::capnproto::MessageBuilder;
friend
class
::capnproto::MessageBuilder;
};
};
{{! ------------------------------------------------------------------------------------------- }}
{{! ------------------------------------------------------------------------------------------- }}
...
...
compiler/src/c++-source.mustache
View file @
abf4ed59
...
@@ -74,6 +74,23 @@ const ::capnproto::internal::RawSchema s_{{schemaId}} = {
...
@@ -74,6 +74,23 @@ const ::capnproto::internal::RawSchema s_{{schemaId}} = {
};
};
{{/
typeSchema
}}
{{/
typeSchema
}}
{{/
fileTypes
}}
{{/
fileTypes
}}
} // namespace schemas
} // namespace schemas
namespace internal {
{{#
fileTypes
}}
{{#
typeStructOrUnion
}}
{{#
typeStruct
}}
CAPNPROTO_DEFINE_STRUCT(
::
{{#
fileNamespaces
}}{{
namespaceName
}}
::
{{/
fileNamespaces
}}{{
typeFullName
}}
);
{{#
structNestedEnums
}}
CAPNPROTO_DEFINE_ENUM(
::
{{#
fileNamespaces
}}{{
namespaceName
}}
::
{{/
fileNamespaces
}}{{
typeFullName
}}
::
{{
enumName
}}
);
{{/
structNestedEnums
}}
{{/
typeStruct
}}
{{/
typeStructOrUnion
}}
{{/
fileTypes
}}
{{#
fileEnums
}}
CAPNPROTO_DEFINE_ENUM(
::
{{#
fileNamespaces
}}{{
namespaceName
}}
::
{{/
fileNamespaces
}}{{
enumName
}}
);
{{/
fileEnums
}}
} // namespace internal
} // namespace capnproto
} // namespace capnproto
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