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
e733d95e
Commit
e733d95e
authored
Jul 11, 2016
by
Wouter van Oortmerssen
Committed by
GitHub
Jul 11, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3924 from TGIshib/master
Added --escape-proto-identifiers command-line option.
parents
14bdce41
df5575de
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
1 deletion
+8
-1
idl.h
include/flatbuffers/idl.h
+2
-0
flatc.cpp
src/flatc.cpp
+4
-1
idl_gen_fbs.cpp
src/idl_gen_fbs.cpp
+2
-0
No files found.
include/flatbuffers/idl.h
View file @
e733d95e
...
...
@@ -337,6 +337,7 @@ struct IDLOptions {
bool
generate_all
;
bool
skip_unexpected_fields_in_json
;
bool
generate_name_strings
;
bool
escape_proto_identifiers
;
// Possible options for the more general generator below.
enum
Language
{
kJava
,
kCSharp
,
kGo
,
kMAX
};
...
...
@@ -356,6 +357,7 @@ struct IDLOptions {
generate_all
(
false
),
skip_unexpected_fields_in_json
(
false
),
generate_name_strings
(
false
),
escape_proto_identifiers
(
false
),
lang
(
IDLOptions
::
kJava
)
{}
};
...
...
src/flatc.cpp
View file @
e733d95e
...
...
@@ -120,8 +120,9 @@ static void Error(const std::string &err, bool usage, bool show_exe_name) {
" --no-includes Don
\'
t generate include statements for included
\n
"
" schemas the generated file depends on (C++).
\n
"
" --gen-mutable Generate accessors that can mutate buffers in-place.
\n
"
" --gen-onefile Generate single output file for C#
\n
"
" --gen-onefile Generate single output file for C#
.
\n
"
" --gen-name-strings Generate type name functions for C++.
\n
"
" --escape-proto-ids Disable appending '_' in namespaces names.
\n
"
" --raw-binary Allow binaries without file_indentifier to be read.
\n
"
" This may crash flatc given a mismatched schema.
\n
"
" --proto Input is a .proto, translate to .fbs.
\n
"
...
...
@@ -194,6 +195,8 @@ int main(int argc, const char *argv[]) {
binary_files_from
=
filenames
.
size
();
}
else
if
(
arg
==
"--proto"
)
{
opts
.
proto_mode
=
true
;
}
else
if
(
arg
==
"--escape-proto-ids"
)
{
opts
.
escape_proto_identifiers
=
true
;
}
else
if
(
arg
==
"--schema"
)
{
schema_binary
=
true
;
}
else
if
(
arg
==
"-M"
)
{
...
...
src/idl_gen_fbs.cpp
View file @
e733d95e
...
...
@@ -54,6 +54,7 @@ static void GenNameSpace(const Namespace &name_space, std::string *_schema,
// Generate a flatbuffer schema from the Parser's internal representation.
std
::
string
GenerateFBS
(
const
Parser
&
parser
,
const
std
::
string
&
file_name
)
{
// Proto namespaces may clash with table names, so we have to prefix all:
if
(
!
parser
.
opts
.
escape_proto_identifiers
)
{
for
(
auto
it
=
parser
.
namespaces_
.
begin
();
it
!=
parser
.
namespaces_
.
end
();
++
it
)
{
for
(
auto
comp
=
(
*
it
)
->
components
.
begin
();
comp
!=
(
*
it
)
->
components
.
end
();
...
...
@@ -61,6 +62,7 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name) {
(
*
comp
)
=
"_"
+
(
*
comp
);
}
}
}
std
::
string
schema
;
schema
+=
"// Generated from "
+
file_name
+
".proto
\n\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