Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
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
flatbuffers
Commits
4a8801da
Commit
4a8801da
authored
May 25, 2016
by
Lakedaemon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shared method that exits early if everything is generated
parent
6765c19d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
31 deletions
+27
-31
code_generators.h
include/flatbuffers/code_generators.h
+12
-0
idl_gen_cpp.cpp
src/idl_gen_cpp.cpp
+1
-15
idl_gen_js.cpp
src/idl_gen_js.cpp
+14
-16
No files found.
include/flatbuffers/code_generators.h
View file @
4a8801da
...
...
@@ -29,6 +29,18 @@ class BaseGenerator {
protected
:
virtual
~
BaseGenerator
(){};
bool
IsEverythingGenerated
()
{
for
(
auto
it
=
parser_
.
enums_
.
vec
.
begin
();
it
!=
parser_
.
enums_
.
vec
.
end
();
++
it
)
{
if
(
!
(
*
it
)
->
generated
)
return
false
;
}
for
(
auto
it
=
parser_
.
structs_
.
vec
.
begin
();
it
!=
parser_
.
structs_
.
vec
.
end
();
++
it
)
{
if
(
!
(
*
it
)
->
generated
)
return
false
;
}
return
true
;
}
const
Parser
&
parser_
;
const
std
::
string
&
path_
;
const
std
::
string
&
file_name_
;
...
...
src/idl_gen_cpp.cpp
View file @
4a8801da
...
...
@@ -724,21 +724,7 @@ class CppGenerator : public BaseGenerator {
// structs,
// and tables) and output them to a single file.
bool
generate
()
{
// Check if we have any code to generate at all, to avoid an empty header.
for
(
auto
it
=
parser_
.
enums_
.
vec
.
begin
();
it
!=
parser_
.
enums_
.
vec
.
end
();
++
it
)
{
if
(
!
(
*
it
)
->
generated
)
goto
generate_code
;
}
for
(
auto
it
=
parser_
.
structs_
.
vec
.
begin
();
it
!=
parser_
.
structs_
.
vec
.
end
();
++
it
)
{
if
(
!
(
*
it
)
->
generated
)
goto
generate_code
;
}
// No code to generate, exit:
return
true
;
generate_code:
using
namespace
cpp
;
if
(
IsEverythingGenerated
())
return
true
;
std
::
string
code
;
code
=
...
...
src/idl_gen_js.cpp
View file @
4a8801da
...
...
@@ -678,31 +678,29 @@ class JsGenerator : public BaseGenerator {
// Iterate through all definitions we haven't generate code for (enums,
// structs, and tables) and output them to a single file.
bool
generate
()
{
if
(
IsEverythingGenerated
())
return
true
;
std
::
string
enum_code
,
struct_code
,
exports_code
,
code
;
generateEnums
(
&
enum_code
,
&
exports_code
);
generateStructs
(
&
struct_code
,
&
exports_code
);
// Only output file-level code if there were any declarations.
if
(
enum_code
.
length
()
||
struct_code
.
length
())
{
code
+=
"// automatically generated by the FlatBuffers compiler, do not "
"modify
\n\n
"
;
code
+=
"// automatically generated by the FlatBuffers compiler, do not "
"modify
\n\n
"
;
// Generate code for all the namespace declarations.
GenNamespaces
(
parser_
,
&
code
,
&
exports_code
);
// Generate code for all the namespace declarations.
GenNamespaces
(
parser_
,
&
code
,
&
exports_code
);
// Output the main declaration code from above.
code
+=
enum_code
;
code
+=
struct_code
;
// Output the main declaration code from above.
code
+=
enum_code
;
code
+=
struct_code
;
if
(
!
exports_code
.
empty
()
&&
!
parser_
.
opts
.
skip_js_exports
)
{
code
+=
"// Exports for Node.js and RequireJS
\n
"
;
code
+=
exports_code
;
}
if
(
!
exports_code
.
empty
()
&&
!
parser_
.
opts
.
skip_js_exports
)
{
code
+=
"// Exports for Node.js and RequireJS
\n
"
;
code
+=
exports_code
;
}
return
!
code
.
length
()
||
SaveFile
(
GeneratedFileName
(
path_
,
file_name_
).
c_str
(),
code
,
false
);
return
SaveFile
(
GeneratedFileName
(
path_
,
file_name_
).
c_str
(),
code
,
false
);
}
private
:
...
...
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