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
04a9c84d
Commit
04a9c84d
authored
Oct 30, 2014
by
Philip Quinn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove zero-length array of brand dependencies from generated headers when there are none.
Zero-length arrays are a GNU extension.
parent
a6d898a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
capnpc-c++.c++
c++/src/capnp/compiler/capnpc-c++.c++
+17
-6
No files found.
c++/src/capnp/compiler/capnpc-c++.c++
View file @
04a9c84d
...
...
@@ -667,16 +667,19 @@ private:
}
}
auto
brandDeps
=
makeBrandDepInitializers
(
templateContext
,
schema
);
return
kj
::
strTree
(
"{
\n
"
,
macroParam
(
kj
::
StringTree
(
scopes
.
finish
(),
""
).
flatten
()),
"}, {
\n
"
,
macroParam
(
kj
::
StringTree
(
bindings
.
releaseAsArray
(),
""
).
flatten
()),
"}, "
,
macroParam
(
makeBrandDepInitializers
(
templateContext
,
schema
).
flatten
()));
"}, "
,
brandDeps
.
size
()
==
0
?
kj
::
strTree
(
"{}"
)
:
macroParam
(
brandDeps
.
flatten
()));
}
kj
::
StringTree
makeBrandDepInitializers
(
const
TemplateContext
&
templateContext
,
Schema
schema
)
{
// Build deps.
// Build deps.
Returns a braced initialiser list, or an empty string if there are no dependencies.
std
::
map
<
uint
,
kj
::
StringTree
>
depMap
;
#define ADD_DEP(kind, index, ...) \
...
...
@@ -719,6 +722,10 @@ private:
}
#undef ADD_DEP
if
(
!
depMap
.
size
())
{
return
kj
::
strTree
();
}
auto
deps
=
kj
::
heapArrayBuilder
<
kj
::
StringTree
>
(
depMap
.
size
());
for
(
auto
&
entry
:
depMap
)
{
deps
.
add
(
kj
::
strTree
(
" { "
,
entry
.
first
,
", "
,
kj
::
mv
(
entry
.
second
),
" },
\n
"
));
...
...
@@ -2335,6 +2342,8 @@ private:
break
;
}
auto
brandDeps
=
makeBrandDepInitializers
(
templateContext
,
schema
.
getGeneric
());
auto
schemaDef
=
kj
::
strTree
(
"static const ::capnp::_::AlignedData<"
,
rawSchema
.
size
(),
"> b_"
,
hexId
,
" = {
\n
"
" {"
,
kj
::
mv
(
schemaLiteral
),
" }
\n
"
...
...
@@ -2355,16 +2364,18 @@ private:
"static const uint16_t i_"
,
hexId
,
"[] = {"
,
kj
::
StringTree
(
KJ_MAP
(
index
,
membersByDiscrim
)
{
return
kj
::
strTree
(
index
);
},
", "
),
"};
\n
"
),
"const ::capnp::_::RawBrandedSchema::Dependency bd_"
,
hexId
,
"[] = "
,
makeBrandDepInitializers
(
templateContext
,
schema
.
getGeneric
()),
";
\n
"
brandDeps
.
size
()
==
0
?
kj
::
strTree
()
:
kj
::
strTree
(
"const ::capnp::_::RawBrandedSchema::Dependency bd_"
,
hexId
,
"[] = "
,
kj
::
mv
(
brandDeps
),
";
\n
"
),
"const ::capnp::_::RawSchema s_"
,
hexId
,
" = {
\n
"
" 0x"
,
hexId
,
", b_"
,
hexId
,
".words, "
,
rawSchema
.
size
(),
", "
,
deps
.
size
()
==
0
?
kj
::
strTree
(
"nullptr"
)
:
kj
::
strTree
(
"d_"
,
hexId
),
", "
,
membersByName
.
size
()
==
0
?
kj
::
strTree
(
"nullptr"
)
:
kj
::
strTree
(
"m_"
,
hexId
),
",
\n
"
,
" "
,
deps
.
size
(),
", "
,
membersByName
.
size
(),
", "
,
membersByDiscrim
.
size
()
==
0
?
kj
::
strTree
(
"nullptr"
)
:
kj
::
strTree
(
"i_"
,
hexId
),
", nullptr, nullptr, { &s_"
,
hexId
,
", nullptr, bd_"
,
hexId
,
", 0, "
"sizeof(bd_"
,
hexId
,
") / sizeof(bd_"
,
hexId
,
"[0]), nullptr }
\n
"
", nullptr, nullptr, { &s_"
,
hexId
,
", nullptr, "
,
brandDeps
.
size
()
==
0
?
kj
::
strTree
(
"nullptr, 0, 0"
)
:
kj
::
strTree
(
"bd_"
,
hexId
,
", 0, "
"sizeof(bd_"
,
hexId
,
") / sizeof(bd_"
,
hexId
,
"[0])"
),
", nullptr }
\n
"
"};
\n
"
"#endif // !CAPNP_LITE
\n
"
);
...
...
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