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
7f083a62
Commit
7f083a62
authored
Aug 28, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve readability of schema clasess a bit by making some union members into singleton groups.
parent
2bea8005
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
140 additions
and
107 deletions
+140
-107
capnp.c++
c++/src/capnp/compiler/capnp.c++
+1
-1
capnpc-c++.c++
c++/src/capnp/compiler/capnpc-c++.c++
+17
-16
capnpc-capnp.c++
c++/src/capnp/compiler/capnpc-capnp.c++
+9
-8
compiler.c++
c++/src/capnp/compiler/compiler.c++
+4
-4
evolution-test.c++
c++/src/capnp/compiler/evolution-test.c++
+8
-7
node-translator.c++
c++/src/capnp/compiler/node-translator.c++
+24
-21
dynamic.c++
c++/src/capnp/dynamic.c++
+27
-18
schema-loader-test.c++
c++/src/capnp/schema-loader-test.c++
+6
-4
schema-loader.c++
c++/src/capnp/schema-loader.c++
+19
-15
schema-parser-test.c++
c++/src/capnp/schema-parser-test.c++
+1
-1
schema-test.c++
c++/src/capnp/schema-test.c++
+2
-2
schema.c++
c++/src/capnp/schema.c++
+4
-4
schema.capnp
c++/src/capnp/schema.capnp
+18
-6
schema.capnp.c++
c++/src/capnp/schema.capnp.c++
+0
-0
schema.capnp.h
c++/src/capnp/schema.capnp.h
+0
-0
No files found.
c++/src/capnp/compiler/capnp.c++
View file @
7f083a62
...
@@ -995,7 +995,7 @@ public:
...
@@ -995,7 +995,7 @@ public:
// Set up stuff for the ValueTranslator.
// Set up stuff for the ValueTranslator.
ValueResolverGlue
resolver
(
compiler
->
getLoader
(),
errorReporter
);
ValueResolverGlue
resolver
(
compiler
->
getLoader
(),
errorReporter
);
auto
type
=
arena
.
getOrphanage
().
newOrphan
<
schema
::
Type
>
();
auto
type
=
arena
.
getOrphanage
().
newOrphan
<
schema
::
Type
>
();
type
.
get
().
setStruct
(
rootType
.
getProto
().
getId
());
type
.
get
().
initStruct
().
setTypeId
(
rootType
.
getProto
().
getId
());
// Set up output stream.
// Set up output stream.
kj
::
FdOutputStream
rawOutput
(
STDOUT_FILENO
);
kj
::
FdOutputStream
rawOutput
(
STDOUT_FILENO
);
...
...
c++/src/capnp/compiler/capnpc-c++.c++
View file @
7f083a62
...
@@ -62,16 +62,16 @@ static constexpr const char* FIELD_SIZE_NAMES[] = {
...
@@ -62,16 +62,16 @@ static constexpr const char* FIELD_SIZE_NAMES[] = {
void
enumerateDeps
(
schema
::
Type
::
Reader
type
,
std
::
set
<
uint64_t
>&
deps
)
{
void
enumerateDeps
(
schema
::
Type
::
Reader
type
,
std
::
set
<
uint64_t
>&
deps
)
{
switch
(
type
.
which
())
{
switch
(
type
.
which
())
{
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
deps
.
insert
(
type
.
getStruct
());
deps
.
insert
(
type
.
getStruct
()
.
getTypeId
()
);
break
;
break
;
case
schema
:
:
Type
::
ENUM
:
case
schema
:
:
Type
::
ENUM
:
deps
.
insert
(
type
.
getEnum
());
deps
.
insert
(
type
.
getEnum
()
.
getTypeId
()
);
break
;
break
;
case
schema
:
:
Type
::
INTERFACE
:
case
schema
:
:
Type
::
INTERFACE
:
deps
.
insert
(
type
.
getInterface
());
deps
.
insert
(
type
.
getInterface
()
.
getTypeId
()
);
break
;
break
;
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
enumerateDeps
(
type
.
getList
(),
deps
);
enumerateDeps
(
type
.
getList
()
.
getElementType
()
,
deps
);
break
;
break
;
default:
default:
break
;
break
;
...
@@ -88,7 +88,7 @@ void enumerateDeps(schema::Node::Reader node, std::set<uint64_t>& deps) {
...
@@ -88,7 +88,7 @@ void enumerateDeps(schema::Node::Reader node, std::set<uint64_t>& deps) {
enumerateDeps
(
field
.
getNonGroup
().
getType
(),
deps
);
enumerateDeps
(
field
.
getNonGroup
().
getType
(),
deps
);
break
;
break
;
case
schema
:
:
Field
::
GROUP
:
case
schema
:
:
Field
::
GROUP
:
deps
.
insert
(
field
.
getGroup
());
deps
.
insert
(
field
.
getGroup
()
.
getTypeId
()
);
break
;
break
;
}
}
}
}
...
@@ -221,14 +221,14 @@ private:
...
@@ -221,14 +221,14 @@ private:
case
schema
:
:
Type
::
DATA
:
return
kj
::
strTree
(
" ::capnp::Data"
);
case
schema
:
:
Type
::
DATA
:
return
kj
::
strTree
(
" ::capnp::Data"
);
case
schema
:
:
Type
::
ENUM
:
case
schema
:
:
Type
::
ENUM
:
return
cppFullName
(
schemaLoader
.
get
(
type
.
getEnum
()));
return
cppFullName
(
schemaLoader
.
get
(
type
.
getEnum
()
.
getTypeId
()
));
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
return
cppFullName
(
schemaLoader
.
get
(
type
.
getStruct
()));
return
cppFullName
(
schemaLoader
.
get
(
type
.
getStruct
()
.
getTypeId
()
));
case
schema
:
:
Type
::
INTERFACE
:
case
schema
:
:
Type
::
INTERFACE
:
return
cppFullName
(
schemaLoader
.
get
(
type
.
getInterface
()));
return
cppFullName
(
schemaLoader
.
get
(
type
.
getInterface
()
.
getTypeId
()
));
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
return
kj
::
strTree
(
" ::capnp::List<"
,
typeName
(
type
.
getList
()),
">"
);
return
kj
::
strTree
(
" ::capnp::List<"
,
typeName
(
type
.
getList
()
.
getElementType
()
),
">"
);
case
schema
:
:
Type
::
OBJECT
:
case
schema
:
:
Type
::
OBJECT
:
// Not used.
// Not used.
...
@@ -252,7 +252,7 @@ private:
...
@@ -252,7 +252,7 @@ private:
case
schema
:
:
Value
::
FLOAT32
:
return
kj
::
strTree
(
value
.
getFloat32
(),
"f"
);
case
schema
:
:
Value
::
FLOAT32
:
return
kj
::
strTree
(
value
.
getFloat32
(),
"f"
);
case
schema
:
:
Value
::
FLOAT64
:
return
kj
::
strTree
(
value
.
getFloat64
());
case
schema
:
:
Value
::
FLOAT64
:
return
kj
::
strTree
(
value
.
getFloat64
());
case
schema
:
:
Value
::
ENUM
:
{
case
schema
:
:
Value
::
ENUM
:
{
EnumSchema
schema
=
schemaLoader
.
get
(
type
.
getEnum
()).
asEnum
();
EnumSchema
schema
=
schemaLoader
.
get
(
type
.
getEnum
()
.
getTypeId
()
).
asEnum
();
if
(
value
.
getEnum
()
<
schema
.
getEnumerants
().
size
())
{
if
(
value
.
getEnum
()
<
schema
.
getEnumerants
().
size
())
{
return
kj
::
strTree
(
return
kj
::
strTree
(
cppFullName
(
schema
),
"::"
,
cppFullName
(
schema
),
"::"
,
...
@@ -437,7 +437,7 @@ private:
...
@@ -437,7 +437,7 @@ private:
break
;
break
;
}
}
case
schema
:
:
Field
::
GROUP
:
case
schema
:
:
Field
::
GROUP
:
getSlots
(
schema
.
getDependency
(
proto
.
getGroup
()).
asStruct
(),
slots
);
getSlots
(
schema
.
getDependency
(
proto
.
getGroup
()
.
getTypeId
()
).
asStruct
(),
slots
);
break
;
break
;
}
}
}
}
...
@@ -550,7 +550,8 @@ private:
...
@@ -550,7 +550,8 @@ private:
break
;
break
;
case
schema
:
:
Field
::
GROUP
:
{
case
schema
:
:
Field
::
GROUP
:
{
auto
slots
=
getSortedSlots
(
schemaLoader
.
get
(
field
.
getProto
().
getGroup
()).
asStruct
());
auto
slots
=
getSortedSlots
(
schemaLoader
.
get
(
field
.
getProto
().
getGroup
().
getTypeId
()).
asStruct
());
return
FieldText
{
return
FieldText
{
kj
::
strTree
(
kj
::
strTree
(
kj
::
mv
(
unionDiscrim
.
readerIsDecl
),
kj
::
mv
(
unionDiscrim
.
readerIsDecl
),
...
@@ -902,7 +903,7 @@ private:
...
@@ -902,7 +903,7 @@ private:
bool
isStructList
=
false
;
bool
isStructList
=
false
;
if
(
kind
==
FieldKind
::
LIST
)
{
if
(
kind
==
FieldKind
::
LIST
)
{
bool
primitiveElement
=
false
;
bool
primitiveElement
=
false
;
switch
(
typeBody
.
getList
().
which
())
{
switch
(
typeBody
.
getList
().
getElementType
().
which
())
{
case
schema
:
:
Type
::
VOID
:
case
schema
:
:
Type
::
VOID
:
case
schema
:
:
Type
::
BOOL
:
case
schema
:
:
Type
::
BOOL
:
case
schema
:
:
Type
::
INT8
:
case
schema
:
:
Type
::
INT8
:
...
@@ -933,7 +934,7 @@ private:
...
@@ -933,7 +934,7 @@ private:
break
;
break
;
}
}
elementReaderType
=
kj
::
str
(
elementReaderType
=
kj
::
str
(
typeName
(
typeBody
.
getList
()),
typeName
(
typeBody
.
getList
()
.
getElementType
()
),
primitiveElement
?
""
:
"::Reader"
);
primitiveElement
?
""
:
"::Reader"
);
}
}
...
@@ -1166,7 +1167,7 @@ private:
...
@@ -1166,7 +1167,7 @@ private:
case
schema
:
:
Value
::
LIST
:
{
case
schema
:
:
Value
::
LIST
:
{
kj
::
String
constType
=
kj
::
strTree
(
kj
::
String
constType
=
kj
::
strTree
(
"::capnp::_::ConstList<"
,
typeName
(
type
.
getList
()),
">"
).
flatten
();
"::capnp::_::ConstList<"
,
typeName
(
type
.
getList
()
.
getElementType
()
),
">"
).
flatten
();
return
ConstText
{
return
ConstText
{
true
,
true
,
kj
::
strTree
(
linkage
,
"const "
,
constType
,
' '
,
upperCase
,
";
\n
"
),
kj
::
strTree
(
linkage
,
"const "
,
constType
,
' '
,
upperCase
,
";
\n
"
),
...
@@ -1216,7 +1217,7 @@ private:
...
@@ -1216,7 +1217,7 @@ private:
if
(
field
.
isGroup
())
{
if
(
field
.
isGroup
())
{
nestedTexts
.
add
(
makeNodeText
(
nestedTexts
.
add
(
makeNodeText
(
namespace_
,
subScope
,
toTitleCase
(
field
.
getName
()),
namespace_
,
subScope
,
toTitleCase
(
field
.
getName
()),
schemaLoader
.
get
(
field
.
getGroup
())));
schemaLoader
.
get
(
field
.
getGroup
()
.
getTypeId
()
)));
}
}
}
}
}
}
...
...
c++/src/capnp/compiler/capnpc-capnp.c++
View file @
7f083a62
...
@@ -173,13 +173,13 @@ private:
...
@@ -173,13 +173,13 @@ private:
case
schema
:
:
Type
::
TEXT
:
return
kj
::
strTree
(
"Text"
);
case
schema
:
:
Type
::
TEXT
:
return
kj
::
strTree
(
"Text"
);
case
schema
:
:
Type
::
DATA
:
return
kj
::
strTree
(
"Data"
);
case
schema
:
:
Type
::
DATA
:
return
kj
::
strTree
(
"Data"
);
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
return
kj
::
strTree
(
"List("
,
genType
(
type
.
getList
(),
scope
),
")"
);
return
kj
::
strTree
(
"List("
,
genType
(
type
.
getList
()
.
getElementType
()
,
scope
),
")"
);
case
schema
:
:
Type
::
ENUM
:
case
schema
:
:
Type
::
ENUM
:
return
nodeName
(
scope
.
getDependency
(
type
.
getEnum
()),
scope
);
return
nodeName
(
scope
.
getDependency
(
type
.
getEnum
()
.
getTypeId
()
),
scope
);
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
return
nodeName
(
scope
.
getDependency
(
type
.
getStruct
()),
scope
);
return
nodeName
(
scope
.
getDependency
(
type
.
getStruct
()
.
getTypeId
()
),
scope
);
case
schema
:
:
Type
::
INTERFACE
:
case
schema
:
:
Type
::
INTERFACE
:
return
nodeName
(
scope
.
getDependency
(
type
.
getInterface
()),
scope
);
return
nodeName
(
scope
.
getDependency
(
type
.
getInterface
()
.
getTypeId
()
),
scope
);
case
schema
:
:
Type
::
OBJECT
:
return
kj
::
strTree
(
"Object"
);
case
schema
:
:
Type
::
OBJECT
:
return
kj
::
strTree
(
"Object"
);
}
}
return
kj
::
strTree
();
return
kj
::
strTree
();
...
@@ -256,12 +256,13 @@ private:
...
@@ -256,12 +256,13 @@ private:
return
kj
::
strTree
(
DynamicValue
::
Reader
(
value
.
getData
()));
return
kj
::
strTree
(
DynamicValue
::
Reader
(
value
.
getData
()));
case
schema
:
:
Value
::
LIST
:
{
case
schema
:
:
Value
::
LIST
:
{
KJ_REQUIRE
(
type
.
isList
(),
"type/value mismatch"
);
KJ_REQUIRE
(
type
.
isList
(),
"type/value mismatch"
);
auto
listValue
=
value
.
getList
<
DynamicList
>
(
ListSchema
::
of
(
type
.
getList
(),
scope
));
auto
listValue
=
value
.
getList
<
DynamicList
>
(
ListSchema
::
of
(
type
.
getList
().
getElementType
(),
scope
));
return
kj
::
strTree
(
listValue
);
return
kj
::
strTree
(
listValue
);
}
}
case
schema
:
:
Value
::
ENUM
:
{
case
schema
:
:
Value
::
ENUM
:
{
KJ_REQUIRE
(
type
.
isEnum
(),
"type/value mismatch"
);
KJ_REQUIRE
(
type
.
isEnum
(),
"type/value mismatch"
);
auto
enumNode
=
scope
.
getDependency
(
type
.
getEnum
()).
asEnum
().
getProto
();
auto
enumNode
=
scope
.
getDependency
(
type
.
getEnum
()
.
getTypeId
()
).
asEnum
().
getProto
();
auto
enumerants
=
enumNode
.
getEnum
().
getEnumerants
();
auto
enumerants
=
enumNode
.
getEnum
().
getEnumerants
();
KJ_REQUIRE
(
value
.
getEnum
()
<
enumerants
.
size
(),
KJ_REQUIRE
(
value
.
getEnum
()
<
enumerants
.
size
(),
"Enum value out-of-range."
,
value
.
getEnum
(),
enumNode
.
getDisplayName
());
"Enum value out-of-range."
,
value
.
getEnum
(),
enumNode
.
getDisplayName
());
...
@@ -270,7 +271,7 @@ private:
...
@@ -270,7 +271,7 @@ private:
case
schema
:
:
Value
::
STRUCT
:
{
case
schema
:
:
Value
::
STRUCT
:
{
KJ_REQUIRE
(
type
.
isStruct
(),
"type/value mismatch"
);
KJ_REQUIRE
(
type
.
isStruct
(),
"type/value mismatch"
);
auto
structValue
=
value
.
getStruct
<
DynamicStruct
>
(
auto
structValue
=
value
.
getStruct
<
DynamicStruct
>
(
scope
.
getDependency
(
type
.
getStruct
()).
asStruct
());
scope
.
getDependency
(
type
.
getStruct
()
.
getTypeId
()
).
asStruct
());
return
kj
::
strTree
(
structValue
);
return
kj
::
strTree
(
structValue
);
}
}
case
schema
:
:
Value
::
INTERFACE
:
{
case
schema
:
:
Value
::
INTERFACE
:
{
...
@@ -385,7 +386,7 @@ private:
...
@@ -385,7 +386,7 @@ private:
"
\n
"
);
"
\n
"
);
}
}
case
schema
:
:
Field
::
GROUP
:
{
case
schema
:
:
Field
::
GROUP
:
{
auto
group
=
scope
.
getDependency
(
field
.
getGroup
()).
asStruct
();
auto
group
=
scope
.
getDependency
(
field
.
getGroup
()
.
getTypeId
()
).
asStruct
();
return
kj
::
strTree
(
return
kj
::
strTree
(
indent
,
field
.
getName
(),
indent
,
field
.
getName
(),
" :group"
,
genAnnotations
(
field
.
getAnnotations
(),
scope
),
" {"
,
" :group"
,
genAnnotations
(
field
.
getAnnotations
(),
scope
),
" {"
,
...
...
c++/src/capnp/compiler/compiler.c++
View file @
7f083a62
...
@@ -743,16 +743,16 @@ void Compiler::Node::traverseType(const schema::Type::Reader& type, uint eagerne
...
@@ -743,16 +743,16 @@ void Compiler::Node::traverseType(const schema::Type::Reader& type, uint eagerne
uint64_t
id
=
0
;
uint64_t
id
=
0
;
switch
(
type
.
which
())
{
switch
(
type
.
which
())
{
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
id
=
type
.
getStruct
();
id
=
type
.
getStruct
()
.
getTypeId
()
;
break
;
break
;
case
schema
:
:
Type
::
ENUM
:
case
schema
:
:
Type
::
ENUM
:
id
=
type
.
getEnum
();
id
=
type
.
getEnum
()
.
getTypeId
()
;
break
;
break
;
case
schema
:
:
Type
::
INTERFACE
:
case
schema
:
:
Type
::
INTERFACE
:
id
=
type
.
getInterface
();
id
=
type
.
getInterface
()
.
getTypeId
()
;
break
;
break
;
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
traverseType
(
type
.
getList
(),
eagerness
,
seen
);
traverseType
(
type
.
getList
()
.
getElementType
()
,
eagerness
,
seen
);
return
;
return
;
default
:
default
:
return
;
return
;
...
...
c++/src/capnp/compiler/evolution-test.c++
View file @
7f083a62
...
@@ -447,7 +447,7 @@ uint getOrdinal(StructSchema::Field field) {
...
@@ -447,7 +447,7 @@ uint getOrdinal(StructSchema::Field field) {
KJ_ASSERT
(
proto
.
isGroup
());
KJ_ASSERT
(
proto
.
isGroup
());
auto
group
=
field
.
getContainingStruct
().
getDependency
(
proto
.
getGroup
()).
asStruct
();
auto
group
=
field
.
getContainingStruct
().
getDependency
(
proto
.
getGroup
()
.
getTypeId
()
).
asStruct
();
return
getOrdinal
(
group
.
getFields
()[
0
]);
return
getOrdinal
(
group
.
getFields
()[
0
]);
}
}
...
@@ -466,7 +466,7 @@ Orphan<DynamicValue> makeExampleValue(
...
@@ -466,7 +466,7 @@ Orphan<DynamicValue> makeExampleValue(
case
schema
:
:
Type
::
BOOL
:
return
ordinal
%
2
==
0
;
case
schema
:
:
Type
::
BOOL
:
return
ordinal
%
2
==
0
;
case
schema
:
:
Type
::
TEXT
:
return
orphanage
.
newOrphanCopy
(
Text
::
Reader
(
kj
::
str
(
ordinal
)));
case
schema
:
:
Type
::
TEXT
:
return
orphanage
.
newOrphanCopy
(
Text
::
Reader
(
kj
::
str
(
ordinal
)));
case
schema
:
:
Type
::
STRUCT
:
{
case
schema
:
:
Type
::
STRUCT
:
{
auto
structType
=
scope
.
getDependency
(
type
.
getStruct
()).
asStruct
();
auto
structType
=
scope
.
getDependency
(
type
.
getStruct
()
.
getTypeId
()
).
asStruct
();
auto
result
=
orphanage
.
newOrphan
(
structType
);
auto
result
=
orphanage
.
newOrphan
(
structType
);
auto
builder
=
result
.
get
();
auto
builder
=
result
.
get
();
...
@@ -484,11 +484,11 @@ Orphan<DynamicValue> makeExampleValue(
...
@@ -484,11 +484,11 @@ Orphan<DynamicValue> makeExampleValue(
return
kj
::
mv
(
result
);
return
kj
::
mv
(
result
);
}
}
case
schema
:
:
Type
::
ENUM
:
{
case
schema
:
:
Type
::
ENUM
:
{
auto
enumerants
=
scope
.
getDependency
(
type
.
getEnum
()).
asEnum
().
getEnumerants
();
auto
enumerants
=
scope
.
getDependency
(
type
.
getEnum
()
.
getTypeId
()
).
asEnum
().
getEnumerants
();
return
DynamicEnum
(
enumerants
[
ordinal
%
enumerants
.
size
()]);
return
DynamicEnum
(
enumerants
[
ordinal
%
enumerants
.
size
()]);
}
}
case
schema
:
:
Type
::
LIST
:
{
case
schema
:
:
Type
::
LIST
:
{
auto
elementType
=
type
.
getList
();
auto
elementType
=
type
.
getList
()
.
getElementType
()
;
auto
listType
=
ListSchema
::
of
(
elementType
,
scope
);
auto
listType
=
ListSchema
::
of
(
elementType
,
scope
);
auto
result
=
orphanage
.
newOrphan
(
listType
,
1
);
auto
result
=
orphanage
.
newOrphan
(
listType
,
1
);
result
.
get
().
adopt
(
0
,
makeExampleValue
(
result
.
get
().
adopt
(
0
,
makeExampleValue
(
...
@@ -531,7 +531,8 @@ void checkExampleValue(DynamicValue::Reader value, uint ordinal, schema::Type::R
...
@@ -531,7 +531,8 @@ void checkExampleValue(DynamicValue::Reader value, uint ordinal, schema::Type::R
break
;
break
;
}
}
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
checkExampleValue
(
value
.
as
<
DynamicList
>
()[
0
],
ordinal
,
type
.
getList
(),
sharedOrdinalCount
);
checkExampleValue
(
value
.
as
<
DynamicList
>
()[
0
],
ordinal
,
type
.
getList
().
getElementType
(),
sharedOrdinalCount
);
break
;
break
;
default
:
default
:
KJ_FAIL_ASSERT
(
"You added a new possible field type!"
);
KJ_FAIL_ASSERT
(
"You added a new possible field type!"
);
...
@@ -550,7 +551,7 @@ void setExampleField(DynamicStruct::Builder builder, StructSchema::Field field,
...
@@ -550,7 +551,7 @@ void setExampleField(DynamicStruct::Builder builder, StructSchema::Field field,
case
schema
:
:
Field
::
GROUP
:
case
schema
:
:
Field
::
GROUP
:
builder
.
adopt
(
field
,
makeExampleStruct
(
builder
.
adopt
(
field
,
makeExampleStruct
(
Orphanage
::
getForMessageContaining
(
builder
),
Orphanage
::
getForMessageContaining
(
builder
),
field
.
getContainingStruct
().
getDependency
(
fieldProto
.
getGroup
()).
asStruct
(),
field
.
getContainingStruct
().
getDependency
(
fieldProto
.
getGroup
()
.
getTypeId
()
).
asStruct
(),
sharedOrdinalCount
));
sharedOrdinalCount
));
break
;
break
;
}
}
...
@@ -656,7 +657,7 @@ static void loadStructAndGroups(const SchemaLoader& src, SchemaLoader& dst, uint
...
@@ -656,7 +657,7 @@ static void loadStructAndGroups(const SchemaLoader& src, SchemaLoader& dst, uint
for
(
auto
field
:
proto
.
getStruct
().
getFields
())
{
for
(
auto
field
:
proto
.
getStruct
().
getFields
())
{
if
(
field
.
isGroup
())
{
if
(
field
.
isGroup
())
{
loadStructAndGroups
(
src
,
dst
,
field
.
getGroup
());
loadStructAndGroups
(
src
,
dst
,
field
.
getGroup
()
.
getTypeId
()
);
}
}
}
}
}
}
...
...
c++/src/capnp/compiler/node-translator.c++
View file @
7f083a62
...
@@ -1090,7 +1090,7 @@ private:
...
@@ -1090,7 +1090,7 @@ private:
uint64_t
groupId
=
generateGroupId
(
parent
->
node
.
getId
(),
index
);
uint64_t
groupId
=
generateGroupId
(
parent
->
node
.
getId
(),
index
);
node
.
setId
(
groupId
);
node
.
setId
(
groupId
);
node
.
setScopeId
(
parent
->
node
.
getId
());
node
.
setScopeId
(
parent
->
node
.
getId
());
getSchema
().
setGroup
(
groupId
);
getSchema
().
initGroup
().
setTypeId
(
groupId
);
}
}
}
}
};
};
...
@@ -1313,9 +1313,9 @@ bool NodeTranslator::compileType(TypeExpression::Reader source, schema::Type::Bu
...
@@ -1313,9 +1313,9 @@ bool NodeTranslator::compileType(TypeExpression::Reader source, schema::Type::Bu
bool
handledParams
=
false
;
bool
handledParams
=
false
;
switch
(
base
->
kind
)
{
switch
(
base
->
kind
)
{
case
Declaration
:
:
ENUM
:
target
.
setEnum
(
base
->
id
);
break
;
case
Declaration
:
:
ENUM
:
target
.
initEnum
().
setTypeId
(
base
->
id
);
break
;
case
Declaration
:
:
STRUCT
:
target
.
setStruct
(
base
->
id
);
break
;
case
Declaration
:
:
STRUCT
:
target
.
initStruct
().
setTypeId
(
base
->
id
);
break
;
case
Declaration
:
:
INTERFACE
:
target
.
setInterface
(
base
->
id
);
break
;
case
Declaration
:
:
INTERFACE
:
target
.
initInterface
().
setTypeId
(
base
->
id
);
break
;
case
Declaration
:
:
BUILTIN_LIST
:
{
case
Declaration
:
:
BUILTIN_LIST
:
{
auto
params
=
source
.
getParams
();
auto
params
=
source
.
getParams
();
...
@@ -1324,7 +1324,7 @@ bool NodeTranslator::compileType(TypeExpression::Reader source, schema::Type::Bu
...
@@ -1324,7 +1324,7 @@ bool NodeTranslator::compileType(TypeExpression::Reader source, schema::Type::Bu
return
false
;
return
false
;
}
}
auto
elementType
=
target
.
initList
();
auto
elementType
=
target
.
initList
()
.
initElementType
()
;
if
(
!
compileType
(
params
[
0
],
elementType
))
{
if
(
!
compileType
(
params
[
0
],
elementType
))
{
return
false
;
return
false
;
}
}
...
@@ -1568,7 +1568,7 @@ kj::Maybe<Orphan<DynamicValue>> ValueTranslator::compileValue(
...
@@ -1568,7 +1568,7 @@ kj::Maybe<Orphan<DynamicValue>> ValueTranslator::compileValue(
case
DynamicValue
:
:
LIST
:
case
DynamicValue
:
:
LIST
:
if
(
type
.
isList
())
{
if
(
type
.
isList
())
{
KJ_IF_MAYBE
(
schema
,
makeListSchemaOf
(
type
.
getList
()))
{
KJ_IF_MAYBE
(
schema
,
makeListSchemaOf
(
type
.
getList
()
.
getElementType
()
))
{
if
(
result
.
getReader
().
as
<
DynamicList
>
().
getSchema
()
==
*
schema
)
{
if
(
result
.
getReader
().
as
<
DynamicList
>
().
getSchema
()
==
*
schema
)
{
return
kj
::
mv
(
result
);
return
kj
::
mv
(
result
);
}
}
...
@@ -1580,7 +1580,7 @@ kj::Maybe<Orphan<DynamicValue>> ValueTranslator::compileValue(
...
@@ -1580,7 +1580,7 @@ kj::Maybe<Orphan<DynamicValue>> ValueTranslator::compileValue(
case
DynamicValue
:
:
ENUM
:
case
DynamicValue
:
:
ENUM
:
if
(
type
.
isEnum
())
{
if
(
type
.
isEnum
())
{
KJ_IF_MAYBE
(
schema
,
resolver
.
resolveType
(
type
.
getEnum
()))
{
KJ_IF_MAYBE
(
schema
,
resolver
.
resolveType
(
type
.
getEnum
()
.
getTypeId
()
))
{
if
(
result
.
getReader
().
as
<
DynamicEnum
>
().
getSchema
()
==
*
schema
)
{
if
(
result
.
getReader
().
as
<
DynamicEnum
>
().
getSchema
()
==
*
schema
)
{
return
kj
::
mv
(
result
);
return
kj
::
mv
(
result
);
}
}
...
@@ -1592,7 +1592,7 @@ kj::Maybe<Orphan<DynamicValue>> ValueTranslator::compileValue(
...
@@ -1592,7 +1592,7 @@ kj::Maybe<Orphan<DynamicValue>> ValueTranslator::compileValue(
case
DynamicValue
:
:
STRUCT
:
case
DynamicValue
:
:
STRUCT
:
if
(
type
.
isStruct
())
{
if
(
type
.
isStruct
())
{
KJ_IF_MAYBE
(
schema
,
resolver
.
resolveType
(
type
.
getStruct
()))
{
KJ_IF_MAYBE
(
schema
,
resolver
.
resolveType
(
type
.
getStruct
()
.
getTypeId
()
))
{
if
(
result
.
getReader
().
as
<
DynamicStruct
>
().
getSchema
()
==
*
schema
)
{
if
(
result
.
getReader
().
as
<
DynamicStruct
>
().
getSchema
()
==
*
schema
)
{
return
kj
::
mv
(
result
);
return
kj
::
mv
(
result
);
}
}
...
@@ -1625,7 +1625,7 @@ Orphan<DynamicValue> ValueTranslator::compileValueInner(
...
@@ -1625,7 +1625,7 @@ Orphan<DynamicValue> ValueTranslator::compileValueInner(
kj
::
StringPtr
id
=
name
.
getBase
().
getRelativeName
().
getValue
();
kj
::
StringPtr
id
=
name
.
getBase
().
getRelativeName
().
getValue
();
if
(
type
.
isEnum
())
{
if
(
type
.
isEnum
())
{
KJ_IF_MAYBE
(
enumSchema
,
resolver
.
resolveType
(
type
.
getEnum
()))
{
KJ_IF_MAYBE
(
enumSchema
,
resolver
.
resolveType
(
type
.
getEnum
()
.
getTypeId
()
))
{
KJ_IF_MAYBE
(
enumerant
,
enumSchema
->
asEnum
().
findEnumerantByName
(
id
))
{
KJ_IF_MAYBE
(
enumerant
,
enumSchema
->
asEnum
().
findEnumerantByName
(
id
))
{
return
DynamicEnum
(
*
enumerant
);
return
DynamicEnum
(
*
enumerant
);
}
}
...
@@ -1689,7 +1689,7 @@ Orphan<DynamicValue> ValueTranslator::compileValueInner(
...
@@ -1689,7 +1689,7 @@ Orphan<DynamicValue> ValueTranslator::compileValueInner(
errorReporter
.
addErrorOn
(
src
,
"Type mismatch."
);
errorReporter
.
addErrorOn
(
src
,
"Type mismatch."
);
return
nullptr
;
return
nullptr
;
}
}
auto
elementType
=
type
.
getList
();
auto
elementType
=
type
.
getList
()
.
getElementType
()
;
KJ_IF_MAYBE
(
listSchema
,
makeListSchemaOf
(
elementType
))
{
KJ_IF_MAYBE
(
listSchema
,
makeListSchemaOf
(
elementType
))
{
auto
srcList
=
src
.
getList
();
auto
srcList
=
src
.
getList
();
Orphan
<
DynamicList
>
result
=
orphanage
.
newOrphan
(
*
listSchema
,
srcList
.
size
());
Orphan
<
DynamicList
>
result
=
orphanage
.
newOrphan
(
*
listSchema
,
srcList
.
size
());
...
@@ -1710,7 +1710,7 @@ Orphan<DynamicValue> ValueTranslator::compileValueInner(
...
@@ -1710,7 +1710,7 @@ Orphan<DynamicValue> ValueTranslator::compileValueInner(
errorReporter
.
addErrorOn
(
src
,
"Type mismatch."
);
errorReporter
.
addErrorOn
(
src
,
"Type mismatch."
);
return
nullptr
;
return
nullptr
;
}
}
KJ_IF_MAYBE
(
schema
,
resolver
.
resolveType
(
type
.
getStruct
()))
{
KJ_IF_MAYBE
(
schema
,
resolver
.
resolveType
(
type
.
getStruct
()
.
getTypeId
()
))
{
auto
structSchema
=
schema
->
asStruct
();
auto
structSchema
=
schema
->
asStruct
();
Orphan
<
DynamicStruct
>
result
=
orphanage
.
newOrphan
(
structSchema
);
Orphan
<
DynamicStruct
>
result
=
orphanage
.
newOrphan
(
structSchema
);
fillStructValue
(
result
.
get
(),
src
.
getStruct
());
fillStructValue
(
result
.
get
(),
src
.
getStruct
());
...
@@ -1783,10 +1783,11 @@ kj::String ValueTranslator::makeTypeName(schema::Type::Reader type) {
...
@@ -1783,10 +1783,11 @@ kj::String ValueTranslator::makeTypeName(schema::Type::Reader type) {
case
schema
:
:
Type
::
FLOAT64
:
return
kj
::
str
(
"Float64"
);
case
schema
:
:
Type
::
FLOAT64
:
return
kj
::
str
(
"Float64"
);
case
schema
:
:
Type
::
TEXT
:
return
kj
::
str
(
"Text"
);
case
schema
:
:
Type
::
TEXT
:
return
kj
::
str
(
"Text"
);
case
schema
:
:
Type
::
DATA
:
return
kj
::
str
(
"Data"
);
case
schema
:
:
Type
::
DATA
:
return
kj
::
str
(
"Data"
);
case
schema
:
:
Type
::
LIST
:
return
kj
::
str
(
"List("
,
makeTypeName
(
type
.
getList
()),
")"
);
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
ENUM
:
return
makeNodeName
(
type
.
getEnum
());
return
kj
::
str
(
"List("
,
makeTypeName
(
type
.
getList
().
getElementType
()),
")"
);
case
schema
:
:
Type
::
STRUCT
:
return
makeNodeName
(
type
.
getStruct
());
case
schema
:
:
Type
::
ENUM
:
return
makeNodeName
(
type
.
getEnum
().
getTypeId
());
case
schema
:
:
Type
::
INTERFACE
:
return
makeNodeName
(
type
.
getInterface
());
case
schema
:
:
Type
::
STRUCT
:
return
makeNodeName
(
type
.
getStruct
().
getTypeId
());
case
schema
:
:
Type
::
INTERFACE
:
return
makeNodeName
(
type
.
getInterface
().
getTypeId
());
case
schema
:
:
Type
::
OBJECT
:
return
kj
::
str
(
"Object"
);
case
schema
:
:
Type
::
OBJECT
:
return
kj
::
str
(
"Object"
);
}
}
KJ_UNREACHABLE
;
KJ_UNREACHABLE
;
...
@@ -1819,7 +1820,8 @@ kj::Maybe<DynamicValue::Reader> NodeTranslator::readConstant(
...
@@ -1819,7 +1820,8 @@ kj::Maybe<DynamicValue::Reader> NodeTranslator::readConstant(
auto
constType
=
constReader
.
getType
();
auto
constType
=
constReader
.
getType
();
switch
(
constType
.
which
())
{
switch
(
constType
.
which
())
{
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
KJ_IF_MAYBE
(
structSchema
,
resolver
.
resolveBootstrapSchema
(
constType
.
getStruct
()))
{
KJ_IF_MAYBE
(
structSchema
,
resolver
.
resolveBootstrapSchema
(
constType
.
getStruct
().
getTypeId
()))
{
constValue
=
objValue
.
as
(
structSchema
->
asStruct
());
constValue
=
objValue
.
as
(
structSchema
->
asStruct
());
}
else
{
}
else
{
// The struct's schema is broken for reasons already reported.
// The struct's schema is broken for reasons already reported.
...
@@ -1827,7 +1829,7 @@ kj::Maybe<DynamicValue::Reader> NodeTranslator::readConstant(
...
@@ -1827,7 +1829,7 @@ kj::Maybe<DynamicValue::Reader> NodeTranslator::readConstant(
}
}
break
;
break
;
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
KJ_IF_MAYBE
(
listSchema
,
makeListSchemaOf
(
constType
.
getList
()))
{
KJ_IF_MAYBE
(
listSchema
,
makeListSchemaOf
(
constType
.
getList
()
.
getElementType
()
))
{
constValue
=
objValue
.
as
(
*
listSchema
);
constValue
=
objValue
.
as
(
*
listSchema
);
}
else
{
}
else
{
// The list's schema is broken for reasons already reported.
// The list's schema is broken for reasons already reported.
...
@@ -1881,25 +1883,26 @@ static kj::Maybe<ListSchema> makeListSchemaImpl(schema::Type::Reader elementType
...
@@ -1881,25 +1883,26 @@ static kj::Maybe<ListSchema> makeListSchemaImpl(schema::Type::Reader elementType
const
ResolveTypeFunc
&
resolveType
)
{
const
ResolveTypeFunc
&
resolveType
)
{
switch
(
elementType
.
which
())
{
switch
(
elementType
.
which
())
{
case
schema
:
:
Type
::
ENUM
:
case
schema
:
:
Type
::
ENUM
:
KJ_IF_MAYBE
(
enumSchema
,
resolveType
(
elementType
.
getEnum
()))
{
KJ_IF_MAYBE
(
enumSchema
,
resolveType
(
elementType
.
getEnum
()
.
getTypeId
()
))
{
return
ListSchema
::
of
(
enumSchema
->
asEnum
());
return
ListSchema
::
of
(
enumSchema
->
asEnum
());
}
else
{
}
else
{
return
nullptr
;
return
nullptr
;
}
}
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
KJ_IF_MAYBE
(
structSchema
,
resolveType
(
elementType
.
getStruct
()))
{
KJ_IF_MAYBE
(
structSchema
,
resolveType
(
elementType
.
getStruct
()
.
getTypeId
()
))
{
return
ListSchema
::
of
(
structSchema
->
asStruct
());
return
ListSchema
::
of
(
structSchema
->
asStruct
());
}
else
{
}
else
{
return
nullptr
;
return
nullptr
;
}
}
case
schema
:
:
Type
::
INTERFACE
:
case
schema
:
:
Type
::
INTERFACE
:
KJ_IF_MAYBE
(
interfaceSchema
,
resolveType
(
elementType
.
getInterface
()))
{
KJ_IF_MAYBE
(
interfaceSchema
,
resolveType
(
elementType
.
getInterface
()
.
getTypeId
()
))
{
return
ListSchema
::
of
(
interfaceSchema
->
asInterface
());
return
ListSchema
::
of
(
interfaceSchema
->
asInterface
());
}
else
{
}
else
{
return
nullptr
;
return
nullptr
;
}
}
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
KJ_IF_MAYBE
(
listSchema
,
makeListSchemaImpl
(
elementType
.
getList
(),
resolveType
))
{
KJ_IF_MAYBE
(
listSchema
,
makeListSchemaImpl
(
elementType
.
getList
().
getElementType
(),
resolveType
))
{
return
ListSchema
::
of
(
*
listSchema
);
return
ListSchema
::
of
(
*
listSchema
);
}
else
{
}
else
{
return
nullptr
;
return
nullptr
;
...
...
c++/src/capnp/dynamic.c++
View file @
7f083a62
...
@@ -232,7 +232,7 @@ DynamicValue::Reader DynamicStruct::Reader::get(StructSchema::Field field) const
...
@@ -232,7 +232,7 @@ DynamicValue::Reader DynamicStruct::Reader::get(StructSchema::Field field) const
uint16_t
typedDval
;
uint16_t
typedDval
;
typedDval
=
dval
.
getEnum
();
typedDval
=
dval
.
getEnum
();
return
DynamicEnum
(
return
DynamicEnum
(
field
.
getContainingStruct
().
getDependency
(
type
.
getEnum
()).
asEnum
(),
field
.
getContainingStruct
().
getDependency
(
type
.
getEnum
()
.
getTypeId
()
).
asEnum
(),
reader
.
getDataField
<
uint16_t
>
(
nonGroup
.
getOffset
()
*
ELEMENTS
,
typedDval
));
reader
.
getDataField
<
uint16_t
>
(
nonGroup
.
getOffset
()
*
ELEMENTS
,
typedDval
));
}
}
...
@@ -249,7 +249,7 @@ DynamicValue::Reader DynamicStruct::Reader::get(StructSchema::Field field) const
...
@@ -249,7 +249,7 @@ DynamicValue::Reader DynamicStruct::Reader::get(StructSchema::Field field) const
}
}
case
schema
:
:
Type
::
LIST
:
{
case
schema
:
:
Type
::
LIST
:
{
auto
elementType
=
type
.
getList
();
auto
elementType
=
type
.
getList
()
.
getElementType
()
;
return
DynamicList
::
Reader
(
return
DynamicList
::
Reader
(
ListSchema
::
of
(
elementType
,
field
.
getContainingStruct
()),
ListSchema
::
of
(
elementType
,
field
.
getContainingStruct
()),
reader
.
getListField
(
nonGroup
.
getOffset
()
*
POINTERS
,
reader
.
getListField
(
nonGroup
.
getOffset
()
*
POINTERS
,
...
@@ -259,7 +259,7 @@ DynamicValue::Reader DynamicStruct::Reader::get(StructSchema::Field field) const
...
@@ -259,7 +259,7 @@ DynamicValue::Reader DynamicStruct::Reader::get(StructSchema::Field field) const
case
schema
:
:
Type
::
STRUCT
:
{
case
schema
:
:
Type
::
STRUCT
:
{
return
DynamicStruct
::
Reader
(
return
DynamicStruct
::
Reader
(
field
.
getContainingStruct
().
getDependency
(
type
.
getStruct
()).
asStruct
(),
field
.
getContainingStruct
().
getDependency
(
type
.
getStruct
()
.
getTypeId
()
).
asStruct
(),
reader
.
getStructField
(
nonGroup
.
getOffset
()
*
POINTERS
,
reader
.
getStructField
(
nonGroup
.
getOffset
()
*
POINTERS
,
dval
.
getStruct
<
_
::
UncheckedMessage
>
()));
dval
.
getStruct
<
_
::
UncheckedMessage
>
()));
}
}
...
@@ -279,7 +279,8 @@ DynamicValue::Reader DynamicStruct::Reader::get(StructSchema::Field field) const
...
@@ -279,7 +279,8 @@ DynamicValue::Reader DynamicStruct::Reader::get(StructSchema::Field field) const
}
}
case
schema
:
:
Field
::
GROUP
:
case
schema
:
:
Field
::
GROUP
:
return
DynamicStruct
::
Reader
(
schema
.
getDependency
(
proto
.
getGroup
()).
asStruct
(),
reader
);
return
DynamicStruct
::
Reader
(
schema
.
getDependency
(
proto
.
getGroup
().
getTypeId
()).
asStruct
(),
reader
);
}
}
KJ_UNREACHABLE
;
KJ_UNREACHABLE
;
...
@@ -324,7 +325,7 @@ DynamicValue::Builder DynamicStruct::Builder::get(StructSchema::Field field) {
...
@@ -324,7 +325,7 @@ DynamicValue::Builder DynamicStruct::Builder::get(StructSchema::Field field) {
uint16_t
typedDval
;
uint16_t
typedDval
;
typedDval
=
dval
.
getEnum
();
typedDval
=
dval
.
getEnum
();
return
DynamicEnum
(
return
DynamicEnum
(
field
.
getContainingStruct
().
getDependency
(
type
.
getEnum
()).
asEnum
(),
field
.
getContainingStruct
().
getDependency
(
type
.
getEnum
()
.
getTypeId
()
).
asEnum
(),
builder
.
getDataField
<
uint16_t
>
(
nonGroup
.
getOffset
()
*
ELEMENTS
,
typedDval
));
builder
.
getDataField
<
uint16_t
>
(
nonGroup
.
getOffset
()
*
ELEMENTS
,
typedDval
));
}
}
...
@@ -341,7 +342,8 @@ DynamicValue::Builder DynamicStruct::Builder::get(StructSchema::Field field) {
...
@@ -341,7 +342,8 @@ DynamicValue::Builder DynamicStruct::Builder::get(StructSchema::Field field) {
}
}
case
schema
:
:
Type
::
LIST
:
{
case
schema
:
:
Type
::
LIST
:
{
ListSchema
listType
=
ListSchema
::
of
(
type
.
getList
(),
field
.
getContainingStruct
());
ListSchema
listType
=
ListSchema
::
of
(
type
.
getList
().
getElementType
(),
field
.
getContainingStruct
());
if
(
listType
.
whichElementType
()
==
schema
::
Type
::
STRUCT
)
{
if
(
listType
.
whichElementType
()
==
schema
::
Type
::
STRUCT
)
{
return
DynamicList
::
Builder
(
listType
,
return
DynamicList
::
Builder
(
listType
,
builder
.
getStructListField
(
nonGroup
.
getOffset
()
*
POINTERS
,
builder
.
getStructListField
(
nonGroup
.
getOffset
()
*
POINTERS
,
...
@@ -357,7 +359,7 @@ DynamicValue::Builder DynamicStruct::Builder::get(StructSchema::Field field) {
...
@@ -357,7 +359,7 @@ DynamicValue::Builder DynamicStruct::Builder::get(StructSchema::Field field) {
case
schema
:
:
Type
::
STRUCT
:
{
case
schema
:
:
Type
::
STRUCT
:
{
auto
structSchema
=
auto
structSchema
=
field
.
getContainingStruct
().
getDependency
(
type
.
getStruct
()).
asStruct
();
field
.
getContainingStruct
().
getDependency
(
type
.
getStruct
()
.
getTypeId
()
).
asStruct
();
return
DynamicStruct
::
Builder
(
structSchema
,
return
DynamicStruct
::
Builder
(
structSchema
,
builder
.
getStructField
(
builder
.
getStructField
(
nonGroup
.
getOffset
()
*
POINTERS
,
nonGroup
.
getOffset
()
*
POINTERS
,
...
@@ -381,7 +383,8 @@ DynamicValue::Builder DynamicStruct::Builder::get(StructSchema::Field field) {
...
@@ -381,7 +383,8 @@ DynamicValue::Builder DynamicStruct::Builder::get(StructSchema::Field field) {
}
}
case
schema
:
:
Field
::
GROUP
:
case
schema
:
:
Field
::
GROUP
:
return
DynamicStruct
::
Builder
(
schema
.
getDependency
(
proto
.
getGroup
()).
asStruct
(),
builder
);
return
DynamicStruct
::
Builder
(
schema
.
getDependency
(
proto
.
getGroup
().
getTypeId
()).
asStruct
(),
builder
);
}
}
KJ_UNREACHABLE
;
KJ_UNREACHABLE
;
...
@@ -532,7 +535,8 @@ void DynamicStruct::Builder::set(StructSchema::Field field, const DynamicValue::
...
@@ -532,7 +535,8 @@ void DynamicStruct::Builder::set(StructSchema::Field field, const DynamicValue::
case
schema
:
:
Type
::
ENUM
:
{
case
schema
:
:
Type
::
ENUM
:
{
uint16_t
rawValue
;
uint16_t
rawValue
;
auto
enumSchema
=
field
.
getContainingStruct
().
getDependency
(
type
.
getEnum
()).
asEnum
();
auto
enumSchema
=
field
.
getContainingStruct
()
.
getDependency
(
type
.
getEnum
().
getTypeId
()).
asEnum
();
if
(
value
.
getType
()
==
DynamicValue
::
TEXT
)
{
if
(
value
.
getType
()
==
DynamicValue
::
TEXT
)
{
// Convert from text.
// Convert from text.
rawValue
=
enumSchema
.
getEnumerantByName
(
value
.
as
<
Text
>
()).
getOrdinal
();
rawValue
=
enumSchema
.
getEnumerantByName
(
value
.
as
<
Text
>
()).
getOrdinal
();
...
@@ -611,7 +615,7 @@ DynamicValue::Builder DynamicStruct::Builder::init(StructSchema::Field field) {
...
@@ -611,7 +615,7 @@ DynamicValue::Builder DynamicStruct::Builder::init(StructSchema::Field field) {
auto
nonGroup
=
proto
.
getNonGroup
();
auto
nonGroup
=
proto
.
getNonGroup
();
auto
type
=
nonGroup
.
getType
();
auto
type
=
nonGroup
.
getType
();
KJ_REQUIRE
(
type
.
isStruct
(),
"init() without a size is only valid for struct fields."
);
KJ_REQUIRE
(
type
.
isStruct
(),
"init() without a size is only valid for struct fields."
);
auto
subSchema
=
schema
.
getDependency
(
type
.
getStruct
()).
asStruct
();
auto
subSchema
=
schema
.
getDependency
(
type
.
getStruct
()
.
getTypeId
()
).
asStruct
();
return
DynamicStruct
::
Builder
(
subSchema
,
return
DynamicStruct
::
Builder
(
subSchema
,
builder
.
initStructField
(
nonGroup
.
getOffset
()
*
POINTERS
,
builder
.
initStructField
(
nonGroup
.
getOffset
()
*
POINTERS
,
structSizeFromSchema
(
subSchema
)));
structSizeFromSchema
(
subSchema
)));
...
@@ -619,7 +623,8 @@ DynamicValue::Builder DynamicStruct::Builder::init(StructSchema::Field field) {
...
@@ -619,7 +623,8 @@ DynamicValue::Builder DynamicStruct::Builder::init(StructSchema::Field field) {
case
schema
:
:
Field
::
GROUP
:
{
case
schema
:
:
Field
::
GROUP
:
{
clear
(
field
);
clear
(
field
);
return
DynamicStruct
::
Builder
(
schema
.
getDependency
(
proto
.
getGroup
()).
asStruct
(),
builder
);
return
DynamicStruct
::
Builder
(
schema
.
getDependency
(
proto
.
getGroup
().
getTypeId
()).
asStruct
(),
builder
);
}
}
}
}
...
@@ -638,7 +643,7 @@ DynamicValue::Builder DynamicStruct::Builder::init(StructSchema::Field field, ui
...
@@ -638,7 +643,7 @@ DynamicValue::Builder DynamicStruct::Builder::init(StructSchema::Field field, ui
auto
type
=
nonGroup
.
getType
();
auto
type
=
nonGroup
.
getType
();
switch
(
type
.
which
())
{
switch
(
type
.
which
())
{
case
schema
:
:
Type
::
LIST
:
{
case
schema
:
:
Type
::
LIST
:
{
auto
listType
=
ListSchema
::
of
(
type
.
getList
(),
schema
);
auto
listType
=
ListSchema
::
of
(
type
.
getList
()
.
getElementType
()
,
schema
);
if
(
listType
.
whichElementType
()
==
schema
::
Type
::
STRUCT
)
{
if
(
listType
.
whichElementType
()
==
schema
::
Type
::
STRUCT
)
{
return
DynamicList
::
Builder
(
listType
,
return
DynamicList
::
Builder
(
listType
,
builder
.
initStructListField
(
builder
.
initStructListField
(
...
@@ -707,7 +712,8 @@ void DynamicStruct::Builder::adopt(StructSchema::Field field, Orphan<DynamicValu
...
@@ -707,7 +712,8 @@ void DynamicStruct::Builder::adopt(StructSchema::Field field, Orphan<DynamicValu
break
;
break
;
case
schema
:
:
Type
::
LIST
:
{
case
schema
:
:
Type
::
LIST
:
{
ListSchema
listType
=
ListSchema
::
of
(
type
.
getList
(),
field
.
getContainingStruct
());
ListSchema
listType
=
ListSchema
::
of
(
type
.
getList
().
getElementType
(),
field
.
getContainingStruct
());
KJ_REQUIRE
(
orphan
.
getType
()
==
DynamicValue
::
LIST
&&
orphan
.
listSchema
==
listType
,
KJ_REQUIRE
(
orphan
.
getType
()
==
DynamicValue
::
LIST
&&
orphan
.
listSchema
==
listType
,
"Value type mismatch."
);
"Value type mismatch."
);
break
;
break
;
...
@@ -715,7 +721,7 @@ void DynamicStruct::Builder::adopt(StructSchema::Field field, Orphan<DynamicValu
...
@@ -715,7 +721,7 @@ void DynamicStruct::Builder::adopt(StructSchema::Field field, Orphan<DynamicValu
case
schema
:
:
Type
::
STRUCT
:
{
case
schema
:
:
Type
::
STRUCT
:
{
auto
structType
=
auto
structType
=
field
.
getContainingStruct
().
getDependency
(
type
.
getStruct
()).
asStruct
();
field
.
getContainingStruct
().
getDependency
(
type
.
getStruct
()
.
getTypeId
()
).
asStruct
();
KJ_REQUIRE
(
orphan
.
getType
()
==
DynamicValue
::
STRUCT
&&
orphan
.
structSchema
==
structType
,
KJ_REQUIRE
(
orphan
.
getType
()
==
DynamicValue
::
STRUCT
&&
orphan
.
structSchema
==
structType
,
"Value type mismatch."
);
"Value type mismatch."
);
break
;
break
;
...
@@ -883,7 +889,8 @@ void DynamicStruct::Builder::clear(StructSchema::Field field) {
...
@@ -883,7 +889,8 @@ void DynamicStruct::Builder::clear(StructSchema::Field field) {
}
}
case
schema
:
:
Field
::
GROUP
:
{
case
schema
:
:
Field
::
GROUP
:
{
DynamicStruct
::
Builder
group
(
schema
.
getDependency
(
proto
.
getGroup
()).
asStruct
(),
builder
);
DynamicStruct
::
Builder
group
(
schema
.
getDependency
(
proto
.
getGroup
().
getTypeId
()).
asStruct
(),
builder
);
// We clear the union field with discriminant 0 rather than the one that is set because
// We clear the union field with discriminant 0 rather than the one that is set because
// we want the union to end up with its default field active.
// we want the union to end up with its default field active.
...
@@ -1440,16 +1447,18 @@ DynamicValue::Reader::Reader(ConstSchema constant) {
...
@@ -1440,16 +1447,18 @@ DynamicValue::Reader::Reader(ConstSchema constant) {
case
schema
:
:
Type
::
DATA
:
*
this
=
value
.
getData
();
break
;
case
schema
:
:
Type
::
DATA
:
*
this
=
value
.
getData
();
break
;
case
schema
:
:
Type
::
ENUM
:
case
schema
:
:
Type
::
ENUM
:
*
this
=
DynamicEnum
(
constant
.
getDependency
(
typeSchema
.
getEnum
()).
asEnum
(),
value
.
getEnum
());
*
this
=
DynamicEnum
(
constant
.
getDependency
(
typeSchema
.
getEnum
().
getTypeId
()).
asEnum
(),
value
.
getEnum
());
break
;
break
;
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
*
this
=
value
.
getStruct
<
DynamicStruct
>
(
*
this
=
value
.
getStruct
<
DynamicStruct
>
(
constant
.
getDependency
(
typeSchema
.
getStruct
()).
asStruct
());
constant
.
getDependency
(
typeSchema
.
getStruct
()
.
getTypeId
()
).
asStruct
());
break
;
break
;
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
*
this
=
value
.
getList
<
DynamicList
>
(
ListSchema
::
of
(
typeSchema
.
getList
(),
constant
));
*
this
=
value
.
getList
<
DynamicList
>
(
ListSchema
::
of
(
typeSchema
.
getList
().
getElementType
(),
constant
));
break
;
break
;
case
schema
:
:
Type
::
OBJECT
:
case
schema
:
:
Type
::
OBJECT
:
...
...
c++/src/capnp/schema-loader-test.c++
View file @
7f083a62
...
@@ -64,9 +64,11 @@ TEST(SchemaLoader, LoadLateUnion) {
...
@@ -64,9 +64,11 @@ TEST(SchemaLoader, LoadLateUnion) {
loader
.
load
(
Schema
::
from
<
test
::
TestLateUnion
::
TheUnion
>
().
getProto
()).
asStruct
();
loader
.
load
(
Schema
::
from
<
test
::
TestLateUnion
::
TheUnion
>
().
getProto
()).
asStruct
();
loader
.
load
(
Schema
::
from
<
test
::
TestLateUnion
::
AnotherUnion
>
().
getProto
()).
asStruct
();
loader
.
load
(
Schema
::
from
<
test
::
TestLateUnion
::
AnotherUnion
>
().
getProto
()).
asStruct
();
EXPECT_EQ
(
6
,
schema
.
getDependency
(
schema
.
getFieldByName
(
"theUnion"
).
getProto
().
getGroup
())
EXPECT_EQ
(
6
,
schema
.
getDependency
(
schema
.
getFieldByName
(
"theUnion"
).
getProto
().
getGroup
().
getTypeId
())
.
asStruct
().
getFieldByName
(
"grault"
).
getProto
().
getOrdinal
().
getExplicit
());
.
asStruct
().
getFieldByName
(
"grault"
).
getProto
().
getOrdinal
().
getExplicit
());
EXPECT_EQ
(
9
,
schema
.
getDependency
(
schema
.
getFieldByName
(
"anotherUnion"
).
getProto
().
getGroup
())
EXPECT_EQ
(
9
,
schema
.
getDependency
(
schema
.
getFieldByName
(
"anotherUnion"
).
getProto
().
getGroup
().
getTypeId
())
.
asStruct
().
getFieldByName
(
"corge"
).
getProto
().
getOrdinal
().
getExplicit
());
.
asStruct
().
getFieldByName
(
"corge"
).
getProto
().
getOrdinal
().
getExplicit
());
EXPECT_TRUE
(
schema
.
findFieldByName
(
"corge"
)
==
nullptr
);
EXPECT_TRUE
(
schema
.
findFieldByName
(
"corge"
)
==
nullptr
);
EXPECT_TRUE
(
schema
.
findFieldByName
(
"grault"
)
==
nullptr
);
EXPECT_TRUE
(
schema
.
findFieldByName
(
"grault"
)
==
nullptr
);
...
@@ -185,8 +187,8 @@ Schema loadUnderAlternateTypeId(SchemaLoader& loader, uint64_t id) {
...
@@ -185,8 +187,8 @@ Schema loadUnderAlternateTypeId(SchemaLoader& loader, uint64_t id) {
for
(
auto
field
:
fields
)
{
for
(
auto
field
:
fields
)
{
if
(
field
.
isNonGroup
())
{
if
(
field
.
isNonGroup
())
{
auto
type
=
field
.
getNonGroup
().
getType
();
auto
type
=
field
.
getNonGroup
().
getType
();
if
(
type
.
isStruct
()
&&
type
.
getStruct
()
==
typeId
<
T
>
())
{
if
(
type
.
isStruct
()
&&
type
.
getStruct
()
.
getTypeId
()
==
typeId
<
T
>
())
{
type
.
setStruct
(
id
);
type
.
getStruct
().
setTypeId
(
id
);
}
}
}
}
}
}
...
...
c++/src/capnp/schema-loader.c++
View file @
7f083a62
...
@@ -326,7 +326,7 @@ private:
...
@@ -326,7 +326,7 @@ private:
case
schema
:
:
Field
::
GROUP
:
case
schema
:
:
Field
::
GROUP
:
// Require that the group is a struct node.
// Require that the group is a struct node.
validateTypeId
(
field
.
getGroup
(),
schema
::
Node
::
STRUCT
);
validateTypeId
(
field
.
getGroup
()
.
getTypeId
()
,
schema
::
Node
::
STRUCT
);
break
;
break
;
}
}
...
@@ -467,17 +467,17 @@ private:
...
@@ -467,17 +467,17 @@ private:
break
;
break
;
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
validateTypeId
(
type
.
getStruct
(),
schema
::
Node
::
STRUCT
);
validateTypeId
(
type
.
getStruct
()
.
getTypeId
()
,
schema
::
Node
::
STRUCT
);
break
;
break
;
case
schema
:
:
Type
::
ENUM
:
case
schema
:
:
Type
::
ENUM
:
validateTypeId
(
type
.
getEnum
(),
schema
::
Node
::
ENUM
);
validateTypeId
(
type
.
getEnum
()
.
getTypeId
()
,
schema
::
Node
::
ENUM
);
break
;
break
;
case
schema
:
:
Type
::
INTERFACE
:
case
schema
:
:
Type
::
INTERFACE
:
validateTypeId
(
type
.
getInterface
(),
schema
::
Node
::
INTERFACE
);
validateTypeId
(
type
.
getInterface
()
.
getTypeId
()
,
schema
::
Node
::
INTERFACE
);
break
;
break
;
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
validate
(
type
.
getList
());
validate
(
type
.
getList
()
.
getElementType
()
);
break
;
break
;
}
}
...
@@ -714,7 +714,8 @@ private:
...
@@ -714,7 +714,8 @@ private:
break
;
break
;
}
}
case
schema
:
:
Field
::
GROUP
:
case
schema
:
:
Field
::
GROUP
:
checkUpgradeToStruct
(
nonGroup
.
getType
(),
replacement
.
getGroup
(),
existingNode
,
field
);
checkUpgradeToStruct
(
nonGroup
.
getType
(),
replacement
.
getGroup
().
getTypeId
(),
existingNode
,
field
);
break
;
break
;
}
}
...
@@ -724,11 +725,12 @@ private:
...
@@ -724,11 +725,12 @@ private:
case
schema
:
:
Field
::
GROUP
:
case
schema
:
:
Field
::
GROUP
:
switch
(
replacement
.
which
())
{
switch
(
replacement
.
which
())
{
case
schema
:
:
Field
::
NON_GROUP
:
case
schema
:
:
Field
::
NON_GROUP
:
checkUpgradeToStruct
(
replacement
.
getNonGroup
().
getType
(),
field
.
getGroup
(),
checkUpgradeToStruct
(
replacement
.
getNonGroup
().
getType
(),
field
.
getGroup
()
.
getTypeId
()
,
replacementNode
,
replacement
);
replacementNode
,
replacement
);
break
;
break
;
case
schema
:
:
Field
::
GROUP
:
case
schema
:
:
Field
::
GROUP
:
VALIDATE_SCHEMA
(
field
.
getGroup
()
==
replacement
.
getGroup
(),
"group id changed"
);
VALIDATE_SCHEMA
(
field
.
getGroup
().
getTypeId
()
==
replacement
.
getGroup
().
getTypeId
(),
"group id changed"
);
break
;
break
;
}
}
break
;
break
;
...
@@ -840,10 +842,10 @@ private:
...
@@ -840,10 +842,10 @@ private:
if
(
upgradeToStructMode
==
ALLOW_UPGRADE_TO_STRUCT
)
{
if
(
upgradeToStructMode
==
ALLOW_UPGRADE_TO_STRUCT
)
{
if
(
type
.
isStruct
())
{
if
(
type
.
isStruct
())
{
checkUpgradeToStruct
(
replacement
,
type
.
getStruct
());
checkUpgradeToStruct
(
replacement
,
type
.
getStruct
()
.
getTypeId
()
);
return
;
return
;
}
else
if
(
replacement
.
isStruct
())
{
}
else
if
(
replacement
.
isStruct
())
{
checkUpgradeToStruct
(
type
,
replacement
.
getStruct
());
checkUpgradeToStruct
(
type
,
replacement
.
getStruct
()
.
getTypeId
()
);
return
;
return
;
}
}
}
}
...
@@ -870,11 +872,13 @@ private:
...
@@ -870,11 +872,13 @@ private:
return
;
return
;
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
checkCompatibility
(
type
.
getList
(),
replacement
.
getList
(),
ALLOW_UPGRADE_TO_STRUCT
);
checkCompatibility
(
type
.
getList
().
getElementType
(),
replacement
.
getList
().
getElementType
(),
ALLOW_UPGRADE_TO_STRUCT
);
return
;
return
;
case
schema
:
:
Type
::
ENUM
:
case
schema
:
:
Type
::
ENUM
:
VALIDATE_SCHEMA
(
replacement
.
getEnum
()
==
type
.
getEnum
(),
"type changed enum type"
);
VALIDATE_SCHEMA
(
replacement
.
getEnum
().
getTypeId
()
==
type
.
getEnum
().
getTypeId
(),
"type changed enum type"
);
return
;
return
;
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
...
@@ -885,12 +889,12 @@ private:
...
@@ -885,12 +889,12 @@ private:
// be compatible. However, that has another problem, which is that it could be that the
// be compatible. However, that has another problem, which is that it could be that the
// whole reason the type was replaced was to fork that type, and so an incompatibility
// whole reason the type was replaced was to fork that type, and so an incompatibility
// could be very much expected. This could be a rat hole...
// could be very much expected. This could be a rat hole...
VALIDATE_SCHEMA
(
replacement
.
getStruct
()
==
type
.
getStruct
(),
VALIDATE_SCHEMA
(
replacement
.
getStruct
()
.
getTypeId
()
==
type
.
getStruct
().
getTypeId
(),
"type changed to incompatible struct type"
);
"type changed to incompatible struct type"
);
return
;
return
;
case
schema
:
:
Type
::
INTERFACE
:
case
schema
:
:
Type
::
INTERFACE
:
VALIDATE_SCHEMA
(
replacement
.
getInterface
()
==
type
.
getInterface
(),
VALIDATE_SCHEMA
(
replacement
.
getInterface
()
.
getTypeId
()
==
type
.
getInterface
().
getTypeId
(),
"type changed to incompatible interface type"
);
"type changed to incompatible interface type"
);
return
;
return
;
}
}
...
@@ -1027,7 +1031,7 @@ private:
...
@@ -1027,7 +1031,7 @@ private:
if
(
type
.
isText
())
{
if
(
type
.
isText
())
{
return
true
;
return
true
;
}
else
if
(
type
.
isList
())
{
}
else
if
(
type
.
isList
())
{
switch
(
type
.
getList
().
which
())
{
switch
(
type
.
getList
().
getElementType
().
which
())
{
case
schema
:
:
Type
::
INT8
:
case
schema
:
:
Type
::
INT8
:
case
schema
:
:
Type
::
UINT8
:
case
schema
:
:
Type
::
UINT8
:
return
true
;
return
true
;
...
...
c++/src/capnp/schema-parser-test.c++
View file @
7f083a62
...
@@ -54,7 +54,7 @@ private:
...
@@ -54,7 +54,7 @@ private:
static
uint64_t
getFieldTypeFileId
(
StructSchema
::
Field
field
)
{
static
uint64_t
getFieldTypeFileId
(
StructSchema
::
Field
field
)
{
return
field
.
getContainingStruct
()
return
field
.
getContainingStruct
()
.
getDependency
(
field
.
getProto
().
getNonGroup
().
getType
().
getStruct
())
.
getDependency
(
field
.
getProto
().
getNonGroup
().
getType
().
getStruct
()
.
getTypeId
()
)
.
getProto
().
getScopeId
();
.
getProto
().
getScopeId
();
}
}
...
...
c++/src/capnp/schema-test.c++
View file @
7f083a62
...
@@ -100,7 +100,7 @@ TEST(Schema, Unions) {
...
@@ -100,7 +100,7 @@ TEST(Schema, Unions) {
EXPECT_TRUE
(
schema
.
findFieldByName
(
"u1f0s8"
)
==
nullptr
);
EXPECT_TRUE
(
schema
.
findFieldByName
(
"u1f0s8"
)
==
nullptr
);
auto
union1
=
schema
.
getFieldByName
(
"union1"
);
auto
union1
=
schema
.
getFieldByName
(
"union1"
);
auto
union1g
=
schema
.
getDependency
(
union1
.
getProto
().
getGroup
()).
asStruct
();
auto
union1g
=
schema
.
getDependency
(
union1
.
getProto
().
getGroup
()
.
getTypeId
()
).
asStruct
();
EXPECT_EQ
(
schema
,
union1g
.
getDependency
(
union1g
.
getProto
().
getScopeId
()));
EXPECT_EQ
(
schema
,
union1g
.
getDependency
(
union1g
.
getProto
().
getScopeId
()));
EXPECT_TRUE
(
union1g
.
findFieldByName
(
"bin0"
)
==
nullptr
);
EXPECT_TRUE
(
union1g
.
findFieldByName
(
"bin0"
)
==
nullptr
);
...
@@ -230,7 +230,7 @@ TEST(Schema, Lists) {
...
@@ -230,7 +230,7 @@ TEST(Schema, Lists) {
auto
context
=
Schema
::
from
<
TestAllTypes
>
();
auto
context
=
Schema
::
from
<
TestAllTypes
>
();
auto
type
=
context
.
getFieldByName
(
"enumList"
).
getProto
().
getNonGroup
().
getType
();
auto
type
=
context
.
getFieldByName
(
"enumList"
).
getProto
().
getNonGroup
().
getType
();
ListSchema
schema
=
ListSchema
::
of
(
type
.
getList
(),
context
);
ListSchema
schema
=
ListSchema
::
of
(
type
.
getList
()
.
getElementType
()
,
context
);
EXPECT_EQ
(
schema
::
Type
::
ENUM
,
schema
.
whichElementType
());
EXPECT_EQ
(
schema
::
Type
::
ENUM
,
schema
.
whichElementType
());
EXPECT_TRUE
(
schema
.
getEnumElementType
()
==
Schema
::
from
<
TestEnum
>
());
EXPECT_TRUE
(
schema
.
getEnumElementType
()
==
Schema
::
from
<
TestEnum
>
());
EXPECT_ANY_THROW
(
schema
.
getStructElementType
());
EXPECT_ANY_THROW
(
schema
.
getStructElementType
());
...
...
c++/src/capnp/schema.c++
View file @
7f083a62
...
@@ -293,16 +293,16 @@ ListSchema ListSchema::of(schema::Type::Reader elementType, Schema context) {
...
@@ -293,16 +293,16 @@ ListSchema ListSchema::of(schema::Type::Reader elementType, Schema context) {
return
of
(
elementType
.
which
());
return
of
(
elementType
.
which
());
case
schema
:
:
Type
::
STRUCT
:
case
schema
:
:
Type
::
STRUCT
:
return
of
(
context
.
getDependency
(
elementType
.
getStruct
()).
asStruct
());
return
of
(
context
.
getDependency
(
elementType
.
getStruct
()
.
getTypeId
()
).
asStruct
());
case
schema
:
:
Type
::
ENUM
:
case
schema
:
:
Type
::
ENUM
:
return
of
(
context
.
getDependency
(
elementType
.
getEnum
()).
asEnum
());
return
of
(
context
.
getDependency
(
elementType
.
getEnum
()
.
getTypeId
()
).
asEnum
());
case
schema
:
:
Type
::
INTERFACE
:
case
schema
:
:
Type
::
INTERFACE
:
return
of
(
context
.
getDependency
(
elementType
.
getInterface
()).
asInterface
());
return
of
(
context
.
getDependency
(
elementType
.
getInterface
()
.
getTypeId
()
).
asInterface
());
case
schema
:
:
Type
::
LIST
:
case
schema
:
:
Type
::
LIST
:
return
of
(
of
(
elementType
.
getList
(),
context
));
return
of
(
of
(
elementType
.
getList
()
.
getElementType
()
,
context
));
case
schema
:
:
Type
::
OBJECT
:
case
schema
:
:
Type
::
OBJECT
:
KJ_FAIL_REQUIRE
(
"List(Object) not supported."
);
KJ_FAIL_REQUIRE
(
"List(Object) not supported."
);
...
...
c++/src/capnp/schema.capnp
View file @
7f083a62
...
@@ -190,8 +190,12 @@ struct Field {
...
@@ -190,8 +190,12 @@ struct Field {
defaultValue @6 :Value;
defaultValue @6 :Value;
}
}
group @7 :Id;
group :group {
# A group. This is the ID of the group's node.
# A group.
typeId @7 :Id;
# The ID of the group's node.
}
}
}
ordinal :union {
ordinal :union {
...
@@ -264,11 +268,19 @@ struct Type {
...
@@ -264,11 +268,19 @@ struct Type {
text @12 :Void;
text @12 :Void;
data @13 :Void;
data @13 :Void;
list @14 :Type; # Value = the element type.
list :group {
elementType @14 :Type;
}
enum @15 :Id;
enum :group {
struct @16 :Id;
typeId @15 :Id;
interface @17 :Id;
}
struct :group {
typeId @16 :Id;
}
interface :group {
typeId @17 :Id;
}
object @18 :Void;
object @18 :Void;
}
}
...
...
c++/src/capnp/schema.capnp.c++
View file @
7f083a62
This diff is collapsed.
Click to expand it.
c++/src/capnp/schema.capnp.h
View file @
7f083a62
This diff is collapsed.
Click to expand it.
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