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
0e85eeef
Commit
0e85eeef
authored
Jun 26, 2017
by
Robbie McElrath
Committed by
Wouter van Oortmerssen
Jun 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make inter-file cycles compile (#4364)
parent
b0fa5e0f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
26 deletions
+46
-26
idl.h
include/flatbuffers/idl.h
+3
-0
idl_parser.cpp
src/idl_parser.cpp
+36
-24
include_test1.fbs
tests/include_test/include_test1.fbs
+3
-1
include_test2.fbs
tests/include_test/sub/include_test2.fbs
+4
-1
No files found.
include/flatbuffers/idl.h
View file @
0e85eeef
...
...
@@ -607,6 +607,9 @@ private:
FLATBUFFERS_CHECKED_ERROR
ParseFlexBufferValue
(
flexbuffers
::
Builder
*
builder
);
FLATBUFFERS_CHECKED_ERROR
StartParseFile
(
const
char
*
source
,
const
char
*
source_filename
);
FLATBUFFERS_CHECKED_ERROR
ParseRoot
(
const
char
*
_source
,
const
char
**
include_paths
,
const
char
*
source_filename
);
FLATBUFFERS_CHECKED_ERROR
DoParse
(
const
char
*
_source
,
const
char
**
include_paths
,
const
char
*
source_filename
,
...
...
src/idl_parser.cpp
View file @
0e85eeef
...
...
@@ -1632,8 +1632,10 @@ void Parser::MarkGenerated() {
}
for
(
auto
it
=
structs_
.
vec
.
begin
();
it
!=
structs_
.
vec
.
end
();
++
it
)
{
if
(
!
(
*
it
)
->
predecl
)
{
(
*
it
)
->
generated
=
true
;
}
}
for
(
auto
it
=
services_
.
vec
.
begin
();
it
!=
services_
.
vec
.
end
();
++
it
)
{
(
*
it
)
->
generated
=
true
;
...
...
@@ -2001,7 +2003,7 @@ bool Parser::ParseFlexBuffer(const char *source, const char *source_filename,
bool
Parser
::
Parse
(
const
char
*
source
,
const
char
**
include_paths
,
const
char
*
source_filename
)
{
return
!
DoParse
(
source
,
include_paths
,
source_filename
,
nullptr
).
Check
();
return
!
ParseRoot
(
source
,
include_paths
,
source_filename
).
Check
();
}
CheckedError
Parser
::
StartParseFile
(
const
char
*
source
,
const
char
*
source_filename
)
{
...
...
@@ -2016,7 +2018,39 @@ CheckedError Parser::StartParseFile(const char *source, const char *source_filen
return
NoError
();
}
CheckedError
Parser
::
DoParse
(
const
char
*
source
,
const
char
**
include_paths
,
CheckedError
Parser
::
ParseRoot
(
const
char
*
source
,
const
char
**
include_paths
,
const
char
*
source_filename
)
{
ECHECK
(
DoParse
(
source
,
include_paths
,
source_filename
,
nullptr
));
// Check that all types were defined.
for
(
auto
it
=
structs_
.
vec
.
begin
();
it
!=
structs_
.
vec
.
end
();
++
it
)
{
if
((
*
it
)
->
predecl
)
{
return
Error
(
"type referenced but not defined: "
+
(
*
it
)
->
name
);
}
}
// This check has to happen here and not earlier, because only now do we
// know for sure what the type of these are.
for
(
auto
it
=
enums_
.
vec
.
begin
();
it
!=
enums_
.
vec
.
end
();
++
it
)
{
auto
&
enum_def
=
**
it
;
if
(
enum_def
.
is_union
)
{
for
(
auto
val_it
=
enum_def
.
vals
.
vec
.
begin
();
val_it
!=
enum_def
.
vals
.
vec
.
end
();
++
val_it
)
{
auto
&
val
=
**
val_it
;
if
(
opts
.
lang_to_generate
!=
IDLOptions
::
kCpp
&&
val
.
union_type
.
struct_def
&&
val
.
union_type
.
struct_def
->
fixed
)
return
Error
(
"only tables can be union elements in the generated language: "
+
val
.
name
);
}
}
}
return
NoError
();
}
CheckedError
Parser
::
DoParse
(
const
char
*
source
,
const
char
**
include_paths
,
const
char
*
source_filename
,
const
char
*
include_filename
)
{
if
(
source_filename
&&
...
...
@@ -2147,28 +2181,6 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths,
ECHECK
(
ParseDecl
());
}
}
for
(
auto
it
=
structs_
.
vec
.
begin
();
it
!=
structs_
.
vec
.
end
();
++
it
)
{
if
((
*
it
)
->
predecl
)
{
return
Error
(
"type referenced but not defined: "
+
(
*
it
)
->
name
);
}
}
// This check has to happen here and not earlier, because only now do we
// know for sure what the type of these are.
for
(
auto
it
=
enums_
.
vec
.
begin
();
it
!=
enums_
.
vec
.
end
();
++
it
)
{
auto
&
enum_def
=
**
it
;
if
(
enum_def
.
is_union
)
{
for
(
auto
val_it
=
enum_def
.
vals
.
vec
.
begin
();
val_it
!=
enum_def
.
vals
.
vec
.
end
();
++
val_it
)
{
auto
&
val
=
**
val_it
;
if
(
opts
.
lang_to_generate
!=
IDLOptions
::
kCpp
&&
val
.
union_type
.
struct_def
&&
val
.
union_type
.
struct_def
->
fixed
)
return
Error
(
"only tables can be union elements in the generated language: "
+
val
.
name
);
}
}
}
return
NoError
();
}
...
...
tests/include_test/include_test1.fbs
View file @
0e85eeef
...
...
@@ -2,4 +2,6 @@ include "sub/include_test2.fbs";
include "sub/include_test2.fbs"; // should be skipped
include "include_test1.fbs"; // should be skipped
table TableA {
b:MyGame.OtherNameSpace.TableB;
}
tests/include_test/sub/include_test2.fbs
View file @
0e85eeef
include "include_test1.fbs";
include "sub/include_test2.fbs"; // should be skipped
namespace MyGame.OtherNameSpace;
...
...
@@ -6,4 +7,6 @@ enum FromInclude:long { IncludeVal }
struct Unused {}
table TableB {
a:TableA;
}
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