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
9b8a814c
Commit
9b8a814c
authored
Jan 28, 2016
by
Wouter van Oortmerssen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3742 from evolutional/cs-partial
Added support for C# partial class generation using attribute
parents
491e9709
dbf67023
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
3 deletions
+12
-3
idl.h
include/flatbuffers/idl.h
+1
-0
idl_gen_general.cpp
src/idl_gen_general.cpp
+9
-1
TestSimpleTableWithEnum.cs
tests/MyGame/Example/TestSimpleTableWithEnum.cs
+1
-1
monster_test.fbs
tests/monster_test.fbs
+1
-1
No files found.
include/flatbuffers/idl.h
View file @
9b8a814c
...
@@ -403,6 +403,7 @@ class Parser {
...
@@ -403,6 +403,7 @@ class Parser {
known_attributes_
.
insert
(
"bit_flags"
);
known_attributes_
.
insert
(
"bit_flags"
);
known_attributes_
.
insert
(
"original_order"
);
known_attributes_
.
insert
(
"original_order"
);
known_attributes_
.
insert
(
"nested_flatbuffer"
);
known_attributes_
.
insert
(
"nested_flatbuffer"
);
known_attributes_
.
insert
(
"csharp_partial"
);
}
}
~
Parser
()
{
~
Parser
()
{
...
...
src/idl_gen_general.cpp
View file @
9b8a814c
...
@@ -659,7 +659,15 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
...
@@ -659,7 +659,15 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
// int o = __offset(offset); return o != 0 ? bb.getType(o + i) : default;
// int o = __offset(offset); return o != 0 ? bb.getType(o + i) : default;
// }
// }
GenComment
(
struct_def
.
doc_comment
,
code_ptr
,
&
lang
.
comment_config
);
GenComment
(
struct_def
.
doc_comment
,
code_ptr
,
&
lang
.
comment_config
);
code
+=
std
::
string
(
"public "
)
+
lang
.
unsubclassable_decl
;
code
+=
"public "
;
if
(
lang
.
language
==
IDLOptions
::
kCSharp
&&
struct_def
.
attributes
.
Lookup
(
"csharp_partial"
))
{
// generate a partial class for this C# struct/table
code
+=
"partial "
;
}
else
{
code
+=
lang
.
unsubclassable_decl
;
}
code
+=
"class "
+
struct_def
.
name
+
lang
.
inheritance_marker
;
code
+=
"class "
+
struct_def
.
name
+
lang
.
inheritance_marker
;
code
+=
struct_def
.
fixed
?
"Struct"
:
"Table"
;
code
+=
struct_def
.
fixed
?
"Struct"
:
"Table"
;
code
+=
" {
\n
"
;
code
+=
" {
\n
"
;
...
...
tests/MyGame/Example/TestSimpleTableWithEnum.cs
View file @
9b8a814c
...
@@ -6,7 +6,7 @@ namespace MyGame.Example
...
@@ -6,7 +6,7 @@ namespace MyGame.Example
using
System
;
using
System
;
using
FlatBuffers
;
using
FlatBuffers
;
public
sealed
class
TestSimpleTableWithEnum
:
Table
{
public
partial
class
TestSimpleTableWithEnum
:
Table
{
public
static
TestSimpleTableWithEnum
GetRootAsTestSimpleTableWithEnum
(
ByteBuffer
_bb
)
{
return
GetRootAsTestSimpleTableWithEnum
(
_bb
,
new
TestSimpleTableWithEnum
());
}
public
static
TestSimpleTableWithEnum
GetRootAsTestSimpleTableWithEnum
(
ByteBuffer
_bb
)
{
return
GetRootAsTestSimpleTableWithEnum
(
_bb
,
new
TestSimpleTableWithEnum
());
}
public
static
TestSimpleTableWithEnum
GetRootAsTestSimpleTableWithEnum
(
ByteBuffer
_bb
,
TestSimpleTableWithEnum
obj
)
{
return
(
obj
.
__init
(
_bb
.
GetInt
(
_bb
.
Position
)
+
_bb
.
Position
,
_bb
));
}
public
static
TestSimpleTableWithEnum
GetRootAsTestSimpleTableWithEnum
(
ByteBuffer
_bb
,
TestSimpleTableWithEnum
obj
)
{
return
(
obj
.
__init
(
_bb
.
GetInt
(
_bb
.
Position
)
+
_bb
.
Position
,
_bb
));
}
public
TestSimpleTableWithEnum
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
TestSimpleTableWithEnum
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
...
...
tests/monster_test.fbs
View file @
9b8a814c
...
@@ -12,7 +12,7 @@ union Any { Monster, TestSimpleTableWithEnum } // TODO: add more elements
...
@@ -12,7 +12,7 @@ union Any { Monster, TestSimpleTableWithEnum } // TODO: add more elements
struct Test { a:short; b:byte; }
struct Test { a:short; b:byte; }
table TestSimpleTableWithEnum {
table TestSimpleTableWithEnum
(csharp_partial)
{
color: Color = Green;
color: Color = Green;
}
}
...
...
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