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
42bfe240
Commit
42bfe240
authored
Feb 09, 2015
by
Wouter van Oortmerssen
Committed by
Android (Google) Code Review
Feb 09, 2015
Browse files
Options
Browse Files
Download
Plain Diff
Merge "added reuse option for root objects" into ub-games-master
parents
1c8c9438
b0910e75
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
10 deletions
+19
-10
idl_gen_general.cpp
src/idl_gen_general.cpp
+11
-6
Monster.cs
tests/MyGame/Example/Monster.cs
+2
-1
Monster.java
tests/MyGame/Example/Monster.java
+2
-1
Stat.cs
tests/MyGame/Example/Stat.cs
+2
-1
Stat.java
tests/MyGame/Example/Stat.java
+2
-1
No files found.
src/idl_gen_general.cpp
View file @
42bfe240
...
@@ -322,13 +322,18 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
...
@@ -322,13 +322,18 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
if
(
!
struct_def
.
fixed
)
{
if
(
!
struct_def
.
fixed
)
{
// Generate a special accessor for the table that when used as the root
// Generate a special accessor for the table that when used as the root
// of a FlatBuffer
// of a FlatBuffer
code
+=
" public static "
+
struct_def
.
name
+
" "
;
std
::
string
method_name
=
FunctionStart
(
lang
,
'G'
)
+
"etRootAs"
+
struct_def
.
name
;
code
+=
FunctionStart
(
lang
,
'G'
)
+
"etRootAs"
+
struct_def
.
name
;
std
::
string
method_signature
=
" public static "
+
struct_def
.
name
+
" "
+
method_name
;
code
+=
"(ByteBuffer _bb) { "
;
// create convenience method that doesn't require an existing object
code
+=
method_signature
+
"(ByteBuffer _bb) "
;
code
+=
"{ return "
+
method_name
+
"(_bb, new "
+
struct_def
.
name
+
"()); }
\n
"
;
// create method that allows object reuse
code
+=
method_signature
+
"(ByteBuffer _bb, "
+
struct_def
.
name
+
" obj) { "
;
code
+=
lang
.
set_bb_byteorder
;
code
+=
lang
.
set_bb_byteorder
;
code
+=
"return (new "
+
struct_def
.
name
;
code
+=
"return (obj.__init(_bb."
+
FunctionStart
(
lang
,
'G'
);
code
+=
"()).__init(_bb."
+
FunctionStart
(
lang
,
'G'
);
code
+=
"etInt(_bb.position()) + _bb.position(), _bb)); }
\n
"
;
code
+=
"etInt(_bb.position()) + _bb.position(), _bb); }
\n
"
;
if
(
parser
.
root_struct_def
==
&
struct_def
)
{
if
(
parser
.
root_struct_def
==
&
struct_def
)
{
if
(
parser
.
file_identifier_
.
length
())
{
if
(
parser
.
file_identifier_
.
length
())
{
// Check if a buffer has the identifier.
// Check if a buffer has the identifier.
...
...
tests/MyGame/Example/Monster.cs
View file @
42bfe240
...
@@ -6,7 +6,8 @@ namespace MyGame.Example
...
@@ -6,7 +6,8 @@ namespace MyGame.Example
using
FlatBuffers
;
using
FlatBuffers
;
public
class
Monster
:
Table
{
public
class
Monster
:
Table
{
public
static
Monster
GetRootAsMonster
(
ByteBuffer
_bb
)
{
return
(
new
Monster
()).
__init
(
_bb
.
GetInt
(
_bb
.
position
())
+
_bb
.
position
(),
_bb
);
}
public
static
Monster
GetRootAsMonster
(
ByteBuffer
_bb
)
{
return
GetRootAsMonster
(
_bb
,
new
Monster
());
}
public
static
Monster
GetRootAsMonster
(
ByteBuffer
_bb
,
Monster
obj
)
{
return
(
obj
.
__init
(
_bb
.
GetInt
(
_bb
.
position
())
+
_bb
.
position
(),
_bb
));
}
public
static
bool
MonsterBufferHasIdentifier
(
ByteBuffer
_bb
)
{
return
__has_identifier
(
_bb
,
"MONS"
);
}
public
static
bool
MonsterBufferHasIdentifier
(
ByteBuffer
_bb
)
{
return
__has_identifier
(
_bb
,
"MONS"
);
}
public
Monster
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
Monster
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
...
...
tests/MyGame/Example/Monster.java
View file @
42bfe240
...
@@ -8,7 +8,8 @@ import java.util.*;
...
@@ -8,7 +8,8 @@ import java.util.*;
import
com.google.flatbuffers.*
;
import
com.google.flatbuffers.*
;
public
class
Monster
extends
Table
{
public
class
Monster
extends
Table
{
public
static
Monster
getRootAsMonster
(
ByteBuffer
_bb
)
{
_bb
.
order
(
ByteOrder
.
LITTLE_ENDIAN
);
return
(
new
Monster
()).
__init
(
_bb
.
getInt
(
_bb
.
position
())
+
_bb
.
position
(),
_bb
);
}
public
static
Monster
getRootAsMonster
(
ByteBuffer
_bb
)
{
return
getRootAsMonster
(
_bb
,
new
Monster
());
}
public
static
Monster
getRootAsMonster
(
ByteBuffer
_bb
,
Monster
obj
)
{
_bb
.
order
(
ByteOrder
.
LITTLE_ENDIAN
);
return
(
obj
.
__init
(
_bb
.
getInt
(
_bb
.
position
())
+
_bb
.
position
(),
_bb
));
}
public
static
boolean
MonsterBufferHasIdentifier
(
ByteBuffer
_bb
)
{
return
__has_identifier
(
_bb
,
"MONS"
);
}
public
static
boolean
MonsterBufferHasIdentifier
(
ByteBuffer
_bb
)
{
return
__has_identifier
(
_bb
,
"MONS"
);
}
public
Monster
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
Monster
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
...
...
tests/MyGame/Example/Stat.cs
View file @
42bfe240
...
@@ -6,7 +6,8 @@ namespace MyGame.Example
...
@@ -6,7 +6,8 @@ namespace MyGame.Example
using
FlatBuffers
;
using
FlatBuffers
;
public
class
Stat
:
Table
{
public
class
Stat
:
Table
{
public
static
Stat
GetRootAsStat
(
ByteBuffer
_bb
)
{
return
(
new
Stat
()).
__init
(
_bb
.
GetInt
(
_bb
.
position
())
+
_bb
.
position
(),
_bb
);
}
public
static
Stat
GetRootAsStat
(
ByteBuffer
_bb
)
{
return
GetRootAsStat
(
_bb
,
new
Stat
());
}
public
static
Stat
GetRootAsStat
(
ByteBuffer
_bb
,
Stat
obj
)
{
return
(
obj
.
__init
(
_bb
.
GetInt
(
_bb
.
position
())
+
_bb
.
position
(),
_bb
));
}
public
Stat
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
Stat
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
string
Id
()
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
public
string
Id
()
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
...
...
tests/MyGame/Example/Stat.java
View file @
42bfe240
...
@@ -8,7 +8,8 @@ import java.util.*;
...
@@ -8,7 +8,8 @@ import java.util.*;
import
com.google.flatbuffers.*
;
import
com.google.flatbuffers.*
;
public
class
Stat
extends
Table
{
public
class
Stat
extends
Table
{
public
static
Stat
getRootAsStat
(
ByteBuffer
_bb
)
{
_bb
.
order
(
ByteOrder
.
LITTLE_ENDIAN
);
return
(
new
Stat
()).
__init
(
_bb
.
getInt
(
_bb
.
position
())
+
_bb
.
position
(),
_bb
);
}
public
static
Stat
getRootAsStat
(
ByteBuffer
_bb
)
{
return
getRootAsStat
(
_bb
,
new
Stat
());
}
public
static
Stat
getRootAsStat
(
ByteBuffer
_bb
,
Stat
obj
)
{
_bb
.
order
(
ByteOrder
.
LITTLE_ENDIAN
);
return
(
obj
.
__init
(
_bb
.
getInt
(
_bb
.
position
())
+
_bb
.
position
(),
_bb
));
}
public
Stat
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
Stat
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
String
id
()
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
public
String
id
()
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
...
...
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