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
07b979a3
Commit
07b979a3
authored
May 13, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Dynamic API.
parent
08d73bef
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
63 additions
and
10 deletions
+63
-10
Makefile.am
c++/Makefile.am
+6
-0
dynamic-test.c++
c++/src/capnproto/dynamic-test.c++
+0
-0
dynamic.c++
c++/src/capnproto/dynamic.c++
+0
-0
dynamic.h
c++/src/capnproto/dynamic.h
+0
-0
layout.c++
c++/src/capnproto/layout.c++
+14
-7
layout.h
c++/src/capnproto/layout.h
+1
-1
schema.c++
c++/src/capnproto/schema.c++
+24
-0
schema.h
c++/src/capnproto/schema.h
+16
-0
CxxGenerator.hs
compiler/src/CxxGenerator.hs
+1
-1
WireFormat.hs
compiler/src/WireFormat.hs
+1
-1
No files found.
c++/Makefile.am
View file @
07b979a3
...
...
@@ -49,6 +49,8 @@ includecapnp_HEADERS = \
src/capnproto/layout.h
\
src/capnproto/list.h
\
src/capnproto/message.h
\
src/capnproto/schema.h
\
src/capnproto/dynamic.h
\
src/capnproto/io.h
\
src/capnproto/serialize.h
\
src/capnproto/serialize-packed.h
\
...
...
@@ -73,6 +75,8 @@ libcapnproto_a_SOURCES= \
src/capnproto/layout.c++
\
src/capnproto/list.c++
\
src/capnproto/message.c++
\
src/capnproto/schema.c++
\
src/capnproto/dynamic.c++
\
src/capnproto/io.c++
\
src/capnproto/serialize.c++
\
src/capnproto/serialize-packed.c++
...
...
@@ -117,6 +121,8 @@ capnproto_test_SOURCES = \
src/capnproto/logging-test.c++
\
src/capnproto/layout-test.c++
\
src/capnproto/message-test.c++
\
src/capnproto/schema-test.c++
\
src/capnproto/dynamic-test.c++
\
src/capnproto/encoding-test.c++
\
src/capnproto/serialize-test.c++
\
src/capnproto/serialize-packed-test.c++
\
...
...
c++/src/capnproto/dynamic-test.c++
View file @
07b979a3
This diff is collapsed.
Click to expand it.
c++/src/capnproto/dynamic.c++
View file @
07b979a3
This diff is collapsed.
Click to expand it.
c++/src/capnproto/dynamic.h
View file @
07b979a3
This diff is collapsed.
Click to expand it.
c++/src/capnproto/layout.c++
View file @
07b979a3
...
...
@@ -427,7 +427,8 @@ struct WireHelpers {
word
*
ptr
;
if
(
ref
->
isNull
())
{
if
(
defaultValue
==
nullptr
)
{
if
(
defaultValue
==
nullptr
||
reinterpret_cast
<
const
WireReference
*>
(
defaultValue
)
->
isNull
())
{
ptr
=
allocate
(
ref
,
segment
,
size
.
total
(),
WireReference
::
STRUCT
);
ref
->
structRef
.
set
(
size
);
}
else
{
...
...
@@ -508,7 +509,8 @@ struct WireHelpers {
word
*
ptr
;
if
(
ref
->
isNull
())
{
if
(
defaultValue
==
nullptr
)
{
if
(
defaultValue
==
nullptr
||
reinterpret_cast
<
const
WireReference
*>
(
defaultValue
)
->
isNull
())
{
return
ListBuilder
();
}
ptr
=
copyMessage
(
segment
,
ref
,
defaultRef
);
...
...
@@ -619,7 +621,8 @@ struct WireHelpers {
word
*
ptr
;
if
(
ref
->
isNull
())
{
if
(
defaultValue
==
nullptr
)
{
if
(
defaultValue
==
nullptr
||
reinterpret_cast
<
const
WireReference
*>
(
defaultValue
)
->
isNull
())
{
return
ObjectBuilder
();
}
else
{
ptr
=
copyMessage
(
segment
,
ref
,
reinterpret_cast
<
const
WireReference
*>
(
defaultValue
));
...
...
@@ -668,7 +671,8 @@ struct WireHelpers {
if
(
ref
==
nullptr
||
ref
->
isNull
())
{
useDefault
:
if
(
defaultValue
==
nullptr
)
{
if
(
defaultValue
==
nullptr
||
reinterpret_cast
<
const
WireReference
*>
(
defaultValue
)
->
isNull
())
{
return
StructReader
(
nullptr
,
nullptr
,
nullptr
,
0
*
BITS
,
0
*
REFERENCES
,
0
*
BITS
,
std
::
numeric_limits
<
int
>::
max
());
}
...
...
@@ -714,7 +718,8 @@ struct WireHelpers {
const
word
*
ptr
;
if
(
ref
==
nullptr
||
ref
->
isNull
())
{
useDefault
:
if
(
defaultValue
==
nullptr
)
{
if
(
defaultValue
==
nullptr
||
reinterpret_cast
<
const
WireReference
*>
(
defaultValue
)
->
isNull
())
{
return
ListReader
();
}
segment
=
nullptr
;
...
...
@@ -874,7 +879,8 @@ struct WireHelpers {
const
void
*
defaultValue
,
ByteCount
defaultSize
))
{
if
(
ref
==
nullptr
||
ref
->
isNull
())
{
useDefault
:
if
(
defaultValue
==
nullptr
)
{
if
(
defaultValue
==
nullptr
||
reinterpret_cast
<
const
WireReference
*>
(
defaultValue
)
->
isNull
())
{
defaultValue
=
""
;
}
return
Text
::
Reader
(
reinterpret_cast
<
const
char
*>
(
defaultValue
),
defaultSize
/
BYTES
);
...
...
@@ -973,7 +979,8 @@ struct WireHelpers {
const
word
*
ptr
;
if
(
ref
==
nullptr
||
ref
->
isNull
())
{
useDefault
:
if
(
defaultValue
==
nullptr
)
{
if
(
defaultValue
==
nullptr
||
reinterpret_cast
<
const
WireReference
*>
(
defaultValue
)
->
isNull
())
{
return
ObjectReader
();
}
segment
=
nullptr
;
...
...
c++/src/capnproto/layout.h
View file @
07b979a3
...
...
@@ -647,7 +647,7 @@ struct ObjectBuilder {
ObjectBuilder
()
:
kind
(
ObjectKind
::
NULL_POINTER
),
structBuilder
()
{}
ObjectBuilder
(
StructBuilder
structBuilder
)
:
kind
(
ObjectKind
::
STRUCT
),
structBuilder
(
structBuilder
)
{}
ObjectBuilder
(
ListBuilder
listBuilder
Builder
)
ObjectBuilder
(
ListBuilder
listBuilder
)
:
kind
(
ObjectKind
::
LIST
),
listBuilder
(
listBuilder
)
{}
};
...
...
c++/src/capnproto/schema.c++
View file @
07b979a3
...
...
@@ -122,6 +122,12 @@ Maybe<StructSchema::Member> StructSchema::findMemberByName(Text::Reader name) co
return
findSchemaMemberByName
(
raw
,
name
,
0
,
getMembers
());
}
StructSchema
::
Member
StructSchema
::
getMemberByName
(
Text
::
Reader
name
)
const
{
Maybe
<
StructSchema
::
Member
>
member
=
findMemberByName
(
name
);
PRECOND
(
member
!=
nullptr
,
"struct has no such member"
,
name
);
return
*
member
;
}
Maybe
<
StructSchema
::
Union
>
StructSchema
::
Member
::
getContainingUnion
()
const
{
if
(
unionIndex
==
0
)
return
nullptr
;
return
parent
.
getMembers
()[
unionIndex
-
1
].
asUnion
();
...
...
@@ -142,6 +148,12 @@ Maybe<StructSchema::Member> StructSchema::Union::findMemberByName(Text::Reader n
return
findSchemaMemberByName
(
parent
.
raw
,
name
,
index
+
1
,
getMembers
());
}
StructSchema
::
Member
StructSchema
::
Union
::
getMemberByName
(
Text
::
Reader
name
)
const
{
Maybe
<
StructSchema
::
Member
>
member
=
findMemberByName
(
name
);
PRECOND
(
member
!=
nullptr
,
"struct has no such member"
,
name
);
return
*
member
;
}
// -------------------------------------------------------------------
EnumSchema
::
EnumerantList
EnumSchema
::
getEnumerants
()
const
{
...
...
@@ -152,6 +164,12 @@ Maybe<EnumSchema::Enumerant> EnumSchema::findEnumerantByName(Text::Reader name)
return
findSchemaMemberByName
(
raw
,
name
,
0
,
getEnumerants
());
}
EnumSchema
::
Enumerant
EnumSchema
::
getEnumerantByName
(
Text
::
Reader
name
)
const
{
Maybe
<
EnumSchema
::
Enumerant
>
enumerant
=
findEnumerantByName
(
name
);
PRECOND
(
enumerant
!=
nullptr
,
"enum has no such enumerant"
,
name
);
return
*
enumerant
;
}
// -------------------------------------------------------------------
InterfaceSchema
::
MethodList
InterfaceSchema
::
getMethods
()
const
{
...
...
@@ -162,6 +180,12 @@ Maybe<InterfaceSchema::Method> InterfaceSchema::findMethodByName(Text::Reader na
return
findSchemaMemberByName
(
raw
,
name
,
0
,
getMethods
());
}
InterfaceSchema
::
Method
InterfaceSchema
::
getMethodByName
(
Text
::
Reader
name
)
const
{
Maybe
<
InterfaceSchema
::
Method
>
method
=
findMethodByName
(
name
);
PRECOND
(
method
!=
nullptr
,
"interface has no such method"
,
name
);
return
*
method
;
}
// =======================================================================================
ListSchema
ListSchema
::
of
(
schema
::
Type
::
Body
::
Which
primitiveType
)
{
...
...
c++/src/capnproto/schema.h
View file @
07b979a3
...
...
@@ -100,8 +100,12 @@ public:
class
MemberList
;
MemberList
getMembers
()
const
;
Maybe
<
Member
>
findMemberByName
(
Text
::
Reader
name
)
const
;
Member
getMemberByName
(
Text
::
Reader
name
)
const
;
// Like findMemberByName() but throws an exception on failure.
private
:
StructSchema
(
const
internal
::
RawSchema
*
raw
)
:
Schema
(
raw
)
{}
template
<
typename
T
>
static
inline
StructSchema
fromImpl
()
{
...
...
@@ -148,8 +152,12 @@ public:
Union
()
=
default
;
MemberList
getMembers
()
const
;
Maybe
<
Member
>
findMemberByName
(
Text
::
Reader
name
)
const
;
Member
getMemberByName
(
Text
::
Reader
name
)
const
;
// Like findMemberByName() but throws an exception on failure.
private
:
inline
Union
(
const
Member
&
base
)
:
Member
(
base
)
{}
...
...
@@ -187,8 +195,12 @@ public:
class
EnumerantList
;
EnumerantList
getEnumerants
()
const
;
Maybe
<
Enumerant
>
findEnumerantByName
(
Text
::
Reader
name
)
const
;
Enumerant
getEnumerantByName
(
Text
::
Reader
name
)
const
;
// Like findEnumerantByName() but throws an exception on failure.
private
:
EnumSchema
(
const
internal
::
RawSchema
*
raw
)
:
Schema
(
raw
)
{}
template
<
typename
T
>
static
inline
EnumSchema
fromImpl
()
{
...
...
@@ -250,8 +262,12 @@ public:
class
MethodList
;
MethodList
getMethods
()
const
;
Maybe
<
Method
>
findMethodByName
(
Text
::
Reader
name
)
const
;
Method
getMethodByName
(
Text
::
Reader
name
)
const
;
// Like findMethodByName() but throws an exception on failure.
private
:
InterfaceSchema
(
const
internal
::
RawSchema
*
raw
)
:
Schema
(
raw
)
{}
template
<
typename
T
>
static
inline
InterfaceSchema
fromImpl
()
{
...
...
compiler/src/CxxGenerator.hs
View file @
07b979a3
...
...
@@ -498,7 +498,7 @@ outerFileContext schemaNodes = fileContext where
DescEnum
d
->
muJust
$
enumContext
context
d
_
->
muNull
context
"typeSchema"
=
case
desc
of
DescUnion
u
->
muNull
DescUnion
_
->
muNull
_
->
muJust
$
schemaContext
context
desc
context
s
=
parent
s
...
...
compiler/src/WireFormat.hs
View file @
07b979a3
...
...
@@ -523,7 +523,7 @@ encodeSchema requestedFiles allFiles = (encRoot, nodesForEmbedding) where
BuiltinType
BuiltinFloat64
->
11
BuiltinType
BuiltinText
->
12
BuiltinType
BuiltinData
->
13
BuiltinType
BuiltinObject
->
1
9
BuiltinType
BuiltinObject
->
1
8
ListType
_
->
14
EnumType
_
->
15
StructType
_
->
16
...
...
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