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
2f761418
Commit
2f761418
authored
Jun 07, 2015
by
Amol Deshpande
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
option to generate one file for C#
parent
932b22f0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
7 deletions
+29
-7
idl.h
include/flatbuffers/idl.h
+2
-0
flatc.cpp
src/flatc.cpp
+4
-1
idl_gen_general.cpp
src/idl_gen_general.cpp
+23
-6
No files found.
include/flatbuffers/idl.h
View file @
2f761418
...
...
@@ -406,6 +406,7 @@ struct GeneratorOptions {
bool
prefixed_enums
;
bool
include_dependence_headers
;
bool
mutable_buffer
;
bool
one_file
;
// Possible options for the more general generator below.
enum
Language
{
kJava
,
kCSharp
,
kGo
,
kMAX
};
...
...
@@ -418,6 +419,7 @@ struct GeneratorOptions {
output_enum_identifiers
(
true
),
prefixed_enums
(
true
),
include_dependence_headers
(
false
),
mutable_buffer
(
false
),
one_file
(
false
),
lang
(
GeneratorOptions
::
kJava
)
{}
};
...
...
src/flatc.cpp
View file @
2f761418
...
...
@@ -93,6 +93,7 @@ static void Error(const std::string &err, bool usage, bool show_exe_name) {
" --gen-includes Generate include statements for included schemas the
\n
"
" 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
"
" --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
"
...
...
@@ -140,7 +141,9 @@ int main(int argc, const char *argv[]) {
opts
.
mutable_buffer
=
true
;
}
else
if
(
arg
==
"--gen-includes"
)
{
opts
.
include_dependence_headers
=
true
;
}
else
if
(
arg
==
"--raw-binary"
)
{
}
else
if
(
arg
==
"--gen-onefile"
)
{
opts
.
one_file
=
true
;
}
else
if
(
arg
==
"--raw-binary"
)
{
raw_binary
=
true
;
}
else
if
(
arg
==
"--"
)
{
// Separator between text and binary inputs.
binary_files_from
=
filenames
.
size
();
...
...
src/idl_gen_general.cpp
View file @
2f761418
...
...
@@ -858,8 +858,8 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
// Save out the generated code for a single class while adding
// declaration boilerplate.
static
bool
SaveClass
(
const
LanguageParameters
&
lang
,
const
Parser
&
parser
,
const
Definition
&
def
,
const
std
::
string
&
classcode
,
const
std
::
string
&
path
,
bool
needs_includes
)
{
const
std
::
string
&
defname
,
const
std
::
string
&
classcode
,
const
std
::
string
&
path
,
bool
needs_includes
,
bool
onefile
)
{
if
(
!
classcode
.
length
())
return
true
;
std
::
string
namespace_general
;
...
...
@@ -870,8 +870,11 @@ static bool SaveClass(const LanguageParameters &lang, const Parser &parser,
namespace_general
+=
"."
;
}
namespace_general
+=
*
it
;
if
(
!
onefile
)
{
namespace_dir
+=
*
it
+
kPathSeparator
;
}
}
EnsureDirExists
(
namespace_dir
);
std
::
string
code
=
"// automatically generated, do not modify
\n\n
"
;
...
...
@@ -880,34 +883,48 @@ static bool SaveClass(const LanguageParameters &lang, const Parser &parser,
if
(
needs_includes
)
code
+=
lang
.
includes
;
code
+=
classcode
;
code
+=
lang
.
namespace_end
;
auto
filename
=
namespace_dir
+
def
.
name
+
lang
.
file_extension
;
auto
filename
=
namespace_dir
+
defname
+
lang
.
file_extension
;
return
SaveFile
(
filename
.
c_str
(),
code
,
false
);
}
bool
GenerateGeneral
(
const
Parser
&
parser
,
const
std
::
string
&
path
,
const
std
::
string
&
/*file_name*/
,
const
std
::
string
&
file_name
,
const
GeneratorOptions
&
opts
)
{
assert
(
opts
.
lang
<=
GeneratorOptions
::
kMAX
);
auto
lang
=
language_parameters
[
opts
.
lang
];
std
::
string
one_file_code
;
for
(
auto
it
=
parser
.
enums_
.
vec
.
begin
();
it
!=
parser
.
enums_
.
vec
.
end
();
++
it
)
{
std
::
string
enumcode
;
GenEnum
(
lang
,
**
it
,
&
enumcode
);
if
(
!
SaveClass
(
lang
,
parser
,
**
it
,
enumcode
,
path
,
false
))
if
(
opts
.
one_file
)
{
one_file_code
=
enumcode
;
}
else
{
if
(
!
SaveClass
(
lang
,
parser
,
(
**
it
).
name
,
enumcode
,
path
,
false
,
false
))
return
false
;
}
}
for
(
auto
it
=
parser
.
structs_
.
vec
.
begin
();
it
!=
parser
.
structs_
.
vec
.
end
();
++
it
)
{
std
::
string
declcode
;
GenStruct
(
lang
,
parser
,
**
it
,
&
declcode
);
if
(
!
SaveClass
(
lang
,
parser
,
**
it
,
declcode
,
path
,
true
))
if
(
opts
.
one_file
)
{
one_file_code
+=
declcode
;
}
else
{
if
(
!
SaveClass
(
lang
,
parser
,
(
**
it
).
name
,
declcode
,
path
,
true
,
false
))
return
false
;
}
}
if
(
opts
.
one_file
)
{
return
SaveClass
(
lang
,
parser
,
file_name
,
one_file_code
,
path
,
true
,
true
);
}
return
true
;
}
...
...
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