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
d06b2736
Commit
d06b2736
authored
Aug 19, 2015
by
Wouter van Oortmerssen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #248 from aeneid/master
Added Java and C# mutators
parents
d97f6287
a0f3fb44
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
307 additions
and
17 deletions
+307
-17
.gitignore
.gitignore
+7
-0
JavaUsage.md
docs/source/JavaUsage.md
+45
-0
ByteBuffer.cs
net/FlatBuffers/ByteBuffer.cs
+15
-7
FlatBufferBuilder.cs
net/FlatBuffers/FlatBufferBuilder.cs
+3
-3
idl_gen_general.cpp
src/idl_gen_general.cpp
+83
-2
FlatBuffersExampleTests.cs
tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
+47
-2
Program.cs
tests/FlatBuffers.Test/Program.cs
+1
-0
JavaTest.java
tests/JavaTest.java
+58
-3
Monster.cs
tests/MyGame/Example/Monster.cs
+15
-0
Monster.java
tests/MyGame/Example/Monster.java
+15
-0
Stat.cs
tests/MyGame/Example/Stat.cs
+2
-0
Stat.java
tests/MyGame/Example/Stat.java
+2
-0
Test.cs
tests/MyGame/Example/Test.cs
+2
-0
Test.java
tests/MyGame/Example/Test.java
+2
-0
Vec3.cs
tests/MyGame/Example/Vec3.cs
+5
-0
Vec3.java
tests/MyGame/Example/Vec3.java
+5
-0
No files found.
.gitignore
View file @
d06b2736
...
@@ -31,10 +31,15 @@ proguard-project.txt
...
@@ -31,10 +31,15 @@ proguard-project.txt
linklint_results
linklint_results
Makefile
Makefile
flatc
flatc
flatc.exe
flathash
flathash
flathash.exe
flattests
flattests
flattests.exe
flatsamplebinary
flatsamplebinary
flatsamplebinary.exe
flatsampletext
flatsampletext
flatsampletext.exe
snapshot.sh
snapshot.sh
tests/go_gen
tests/go_gen
tests/monsterdata_java_wire.mon
tests/monsterdata_java_wire.mon
...
@@ -50,3 +55,4 @@ java/.idea
...
@@ -50,3 +55,4 @@ java/.idea
java/*.iml
java/*.iml
java/target
java/target
**/*.pyc
**/*.pyc
.idea
\ No newline at end of file
docs/source/JavaUsage.md
View file @
d06b2736
...
@@ -177,3 +177,48 @@ There currently is no support for parsing text (Schema's and JSON) directly
...
@@ -177,3 +177,48 @@ There currently is no support for parsing text (Schema's and JSON) directly
from Java or C#, though you could use the C++ parser through native call
from Java or C#, though you could use the C++ parser through native call
interfaces available to each language. Please see the
interfaces available to each language. Please see the
C++ documentation for more on text parsing.
C++ documentation for more on text parsing.
### Mutating FlatBuffers
As you saw above, typically once you have created a FlatBuffer, it is
read-only from that moment on. There are however cases where you have just
received a FlatBuffer, and you'd like to modify something about it before
sending it on to another recipient. With the above functionality, you'd have
to generate an entirely new FlatBuffer, while tracking what you modify in your
own data structures. This is inconvenient.
For this reason FlatBuffers can also be mutated in-place. While this is great
for making small fixes to an existing buffer, you generally want to create
buffers from scratch whenever possible, since it is much more efficient and
the API is much more general purpose.
To get non-const accessors, invoke
`flatc`
with
`--gen-mutable`
.
You now can:
~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.java}
Monster monster = Monster.getRootAsMonster(bb);
monster.mutateHp(10); // Set table field.
monster.pos().mutateZ(4); // Set struct field.
monster.mutateInventory(0, 1); // Set vector element.
~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We use the somewhat verbose term
`mutate`
instead of
`set`
to indicate that
this is a special use case, not to be confused with the default way of
constructing FlatBuffer data.
After the above mutations, you can send on the FlatBuffer to a new recipient
without any further work!
Note that any
`mutate`
functions on tables return a boolean, which is false
if the field we're trying to set isn't present in the buffer. Fields are not
present if they weren't set, or even if they happen to be equal to the
default value. For example, in the creation code above we set the
`mana`
field
to
`150`
, which is the default value, so it was never stored in the buffer.
Trying to call mutateMana() on such data will return false, and the value won't
actually be modified!
One way to solve this is to call
`forceDefaults()`
on a
`FlatBufferBuilder`
to force all fields you set to actually be written. This
of course increases the size of the buffer somewhat, but this may be
acceptable for a mutable buffer.
net/FlatBuffers/ByteBuffer.cs
View file @
d06b2736
...
@@ -35,10 +35,17 @@ namespace FlatBuffers
...
@@ -35,10 +35,17 @@ namespace FlatBuffers
public
byte
[]
Data
{
get
{
return
_buffer
;
}
}
public
byte
[]
Data
{
get
{
return
_buffer
;
}
}
public
ByteBuffer
(
byte
[]
buffer
)
public
ByteBuffer
(
byte
[]
buffer
)
:
this
(
buffer
,
0
)
{
}
public
ByteBuffer
(
byte
[]
buffer
,
int
pos
)
{
{
_buffer
=
buffer
;
_buffer
=
buffer
;
_pos
=
0
;
_pos
=
pos
;
}
public
int
Position
{
get
{
return
_pos
;
}
set
{
_pos
=
value
;
}
}
}
public
void
Reset
()
public
void
Reset
()
...
@@ -46,8 +53,6 @@ namespace FlatBuffers
...
@@ -46,8 +53,6 @@ namespace FlatBuffers
_pos
=
0
;
_pos
=
0
;
}
}
public
int
Position
{
get
{
return
_pos
;
}
}
// Pre-allocated helper arrays for convertion.
// Pre-allocated helper arrays for convertion.
private
float
[]
floathelper
=
new
[]
{
0.0f
};
private
float
[]
floathelper
=
new
[]
{
0.0f
};
private
int
[]
inthelper
=
new
[]
{
0
};
private
int
[]
inthelper
=
new
[]
{
0
};
...
@@ -97,7 +102,6 @@ namespace FlatBuffers
...
@@ -97,7 +102,6 @@ namespace FlatBuffers
_buffer
[
offset
+
count
-
1
-
i
]
=
(
byte
)(
data
>>
i
*
8
);
_buffer
[
offset
+
count
-
1
-
i
]
=
(
byte
)(
data
>>
i
*
8
);
}
}
}
}
_pos
=
offset
;
}
}
protected
ulong
ReadLittleEndian
(
int
offset
,
int
count
)
protected
ulong
ReadLittleEndian
(
int
offset
,
int
count
)
...
@@ -134,14 +138,18 @@ namespace FlatBuffers
...
@@ -134,14 +138,18 @@ namespace FlatBuffers
{
{
AssertOffsetAndLength
(
offset
,
sizeof
(
sbyte
));
AssertOffsetAndLength
(
offset
,
sizeof
(
sbyte
));
_buffer
[
offset
]
=
(
byte
)
value
;
_buffer
[
offset
]
=
(
byte
)
value
;
_pos
=
offset
;
}
}
public
void
PutByte
(
int
offset
,
byte
value
)
public
void
PutByte
(
int
offset
,
byte
value
)
{
{
AssertOffsetAndLength
(
offset
,
sizeof
(
byte
));
AssertOffsetAndLength
(
offset
,
sizeof
(
byte
));
_buffer
[
offset
]
=
value
;
_buffer
[
offset
]
=
value
;
_pos
=
offset
;
}
// this method exists in order to conform with Java ByteBuffer standards
public
void
Put
(
int
offset
,
byte
value
)
{
PutByte
(
offset
,
value
);
}
}
#if UNSAFE_BYTEBUFFER
#if UNSAFE_BYTEBUFFER
...
...
net/FlatBuffers/FlatBufferBuilder.cs
View file @
d06b2736
...
@@ -86,8 +86,7 @@ namespace FlatBuffers
...
@@ -86,8 +86,7 @@ namespace FlatBuffers
Buffer
.
BlockCopy
(
oldBuf
,
0
,
newBuf
,
newBufSize
-
oldBufSize
,
Buffer
.
BlockCopy
(
oldBuf
,
0
,
newBuf
,
newBufSize
-
oldBufSize
,
oldBufSize
);
oldBufSize
);
_bb
=
new
ByteBuffer
(
newBuf
,
newBufSize
);
_bb
=
new
ByteBuffer
(
newBuf
);
}
}
// Prepare to write an element of `size` after `additional_bytes`
// Prepare to write an element of `size` after `additional_bytes`
...
@@ -370,6 +369,7 @@ namespace FlatBuffers
...
@@ -370,6 +369,7 @@ namespace FlatBuffers
{
{
Prep
(
_minAlign
,
sizeof
(
int
));
Prep
(
_minAlign
,
sizeof
(
int
));
AddOffset
(
rootTable
);
AddOffset
(
rootTable
);
_bb
.
Position
=
_space
;
}
}
public
ByteBuffer
DataBuffer
{
get
{
return
_bb
;
}
}
public
ByteBuffer
DataBuffer
{
get
{
return
_bb
;
}
}
...
@@ -398,7 +398,7 @@ namespace FlatBuffers
...
@@ -398,7 +398,7 @@ namespace FlatBuffers
{
{
AddByte
((
byte
)
fileIdentifier
[
i
]);
AddByte
((
byte
)
fileIdentifier
[
i
]);
}
}
AddOffset
(
rootTable
);
Finish
(
rootTable
);
}
}
...
...
src/idl_gen_general.cpp
View file @
d06b2736
...
@@ -363,6 +363,33 @@ static std::string DestinationValue(const LanguageParameters &lang,
...
@@ -363,6 +363,33 @@ static std::string DestinationValue(const LanguageParameters &lang,
}
}
}
}
// Cast statements for mutator method parameters.
// In Java, parameters representing unsigned numbers need to be cast down to their respective type.
// For example, a long holding an unsigned int value would be cast down to int before being put onto the buffer.
// In C#, one cast directly cast an Enum to its underlying type, which is essential before putting it onto the buffer.
static
std
::
string
SourceCast
(
const
LanguageParameters
&
lang
,
const
Type
&
type
)
{
if
(
type
.
base_type
==
BASE_TYPE_VECTOR
)
{
return
SourceCast
(
lang
,
type
.
VectorType
());
}
else
{
switch
(
lang
.
language
)
{
case
GeneratorOptions
:
:
kJava
:
if
(
type
.
base_type
==
BASE_TYPE_UINT
)
return
"(int)"
;
else
if
(
type
.
base_type
==
BASE_TYPE_USHORT
)
return
"(short)"
;
else
if
(
type
.
base_type
==
BASE_TYPE_UCHAR
)
return
"(byte)"
;
break
;
case
GeneratorOptions
:
:
kCSharp
:
if
(
type
.
enum_def
!=
nullptr
&&
type
.
base_type
!=
BASE_TYPE_UNION
)
return
"("
+
GenTypeGet
(
lang
,
type
)
+
")"
;
break
;
default
:
break
;
}
return
""
;
}
}
static
std
::
string
GenDefaultValue
(
const
LanguageParameters
&
lang
,
const
Value
&
value
,
bool
for_buffer
)
{
static
std
::
string
GenDefaultValue
(
const
LanguageParameters
&
lang
,
const
Value
&
value
,
bool
for_buffer
)
{
if
(
lang
.
language
==
GeneratorOptions
::
kCSharp
&&
!
for_buffer
)
{
if
(
lang
.
language
==
GeneratorOptions
::
kCSharp
&&
!
for_buffer
)
{
switch
(
value
.
type
.
base_type
)
{
switch
(
value
.
type
.
base_type
)
{
...
@@ -474,6 +501,22 @@ static std::string GenGetter(const LanguageParameters &lang,
...
@@ -474,6 +501,22 @@ static std::string GenGetter(const LanguageParameters &lang,
}
}
}
}
// Direct mutation is only allowed for scalar fields.
// Hence a setter method will only be generated for such fields.
static
std
::
string
GenSetter
(
const
LanguageParameters
&
lang
,
const
Type
&
type
)
{
if
(
IsScalar
(
type
.
base_type
))
{
std
::
string
setter
=
"bb."
+
FunctionStart
(
lang
,
'P'
)
+
"ut"
;
if
(
GenTypeBasic
(
lang
,
type
)
!=
"byte"
&&
type
.
base_type
!=
BASE_TYPE_BOOL
)
{
setter
+=
MakeCamel
(
GenTypeGet
(
lang
,
type
));
}
return
setter
;
}
else
{
return
""
;
}
}
// Returns the method name for use with add/put calls.
// Returns the method name for use with add/put calls.
static
std
::
string
GenMethod
(
const
LanguageParameters
&
lang
,
const
Type
&
type
)
{
static
std
::
string
GenMethod
(
const
LanguageParameters
&
lang
,
const
Type
&
type
)
{
return
IsScalar
(
type
.
base_type
)
return
IsScalar
(
type
.
base_type
)
...
@@ -539,7 +582,8 @@ static void GenStructBody(const LanguageParameters &lang,
...
@@ -539,7 +582,8 @@ static void GenStructBody(const LanguageParameters &lang,
}
}
static
void
GenStruct
(
const
LanguageParameters
&
lang
,
const
Parser
&
parser
,
static
void
GenStruct
(
const
LanguageParameters
&
lang
,
const
Parser
&
parser
,
StructDef
&
struct_def
,
std
::
string
*
code_ptr
)
{
StructDef
&
struct_def
,
const
GeneratorOptions
&
opts
,
std
::
string
*
code_ptr
)
{
if
(
struct_def
.
generated
)
return
;
if
(
struct_def
.
generated
)
return
;
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
...
@@ -599,8 +643,10 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
...
@@ -599,8 +643,10 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
std
::
string
type_name_dest
=
GenTypeNameDest
(
lang
,
field
.
value
.
type
);
std
::
string
type_name_dest
=
GenTypeNameDest
(
lang
,
field
.
value
.
type
);
std
::
string
dest_mask
=
DestinationMask
(
lang
,
field
.
value
.
type
,
true
);
std
::
string
dest_mask
=
DestinationMask
(
lang
,
field
.
value
.
type
,
true
);
std
::
string
dest_cast
=
DestinationCast
(
lang
,
field
.
value
.
type
);
std
::
string
dest_cast
=
DestinationCast
(
lang
,
field
.
value
.
type
);
std
::
string
src_cast
=
SourceCast
(
lang
,
field
.
value
.
type
);
std
::
string
method_start
=
" public "
+
type_name_dest
+
" "
+
std
::
string
method_start
=
" public "
+
type_name_dest
+
" "
+
MakeCamel
(
field
.
name
,
lang
.
first_camel_upper
);
MakeCamel
(
field
.
name
,
lang
.
first_camel_upper
);
// Most field accessors need to retrieve and test the field offset first,
// Most field accessors need to retrieve and test the field offset first,
// this is the prefix code for that:
// this is the prefix code for that:
auto
offset_prefix
=
" { int o = __offset("
+
auto
offset_prefix
=
" { int o = __offset("
+
...
@@ -744,6 +790,41 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
...
@@ -744,6 +790,41 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
InlineSize
(
field
.
value
.
type
.
VectorType
()));
InlineSize
(
field
.
value
.
type
.
VectorType
()));
code
+=
"); }
\n
"
;
code
+=
"); }
\n
"
;
}
}
// generate mutators for scalar fields or vectors of scalars
if
(
opts
.
mutable_buffer
)
{
auto
underlying_type
=
field
.
value
.
type
.
base_type
==
BASE_TYPE_VECTOR
?
field
.
value
.
type
.
VectorType
()
:
field
.
value
.
type
;
// boolean parameters have to be explicitly converted to byte representation
auto
setter_parameter
=
underlying_type
.
base_type
==
BASE_TYPE_BOOL
?
"(byte)("
+
field
.
name
+
" ? 1 : 0)"
:
field
.
name
;
auto
mutator_prefix
=
MakeCamel
(
"mutate"
,
lang
.
first_camel_upper
);
//a vector mutator also needs the index of the vector element it should mutate
auto
mutator_params
=
(
field
.
value
.
type
.
base_type
==
BASE_TYPE_VECTOR
?
"(int j, "
:
"("
)
+
GenTypeNameDest
(
lang
,
underlying_type
)
+
" "
+
field
.
name
+
") { "
;
auto
setter_index
=
field
.
value
.
type
.
base_type
==
BASE_TYPE_VECTOR
?
"__vector(o) + j * "
+
NumToString
(
InlineSize
(
underlying_type
))
:
(
struct_def
.
fixed
?
"bb_pos + "
+
NumToString
(
field
.
value
.
offset
)
:
"o + bb_pos"
);
if
(
IsScalar
(
field
.
value
.
type
.
base_type
)
||
(
field
.
value
.
type
.
base_type
==
BASE_TYPE_VECTOR
&&
IsScalar
(
field
.
value
.
type
.
VectorType
().
base_type
)))
{
code
+=
" public "
;
code
+=
struct_def
.
fixed
?
"void "
:
lang
.
bool_type
;
code
+=
mutator_prefix
+
MakeCamel
(
field
.
name
,
true
);
code
+=
mutator_params
;
if
(
struct_def
.
fixed
)
{
code
+=
GenSetter
(
lang
,
underlying_type
)
+
"("
+
setter_index
+
", "
;
code
+=
src_cast
+
setter_parameter
+
"); }
\n
"
;
}
else
{
code
+=
"int o = __offset("
+
NumToString
(
field
.
value
.
offset
)
+
");"
;
code
+=
" if (o != 0) { "
+
GenSetter
(
lang
,
underlying_type
);
code
+=
"("
+
setter_index
+
", "
+
src_cast
+
setter_parameter
+
"); return true; } else { return false; } }
\n
"
;
}
}
}
}
}
code
+=
"
\n
"
;
code
+=
"
\n
"
;
if
(
struct_def
.
fixed
)
{
if
(
struct_def
.
fixed
)
{
...
@@ -980,7 +1061,7 @@ bool GenerateGeneral(const Parser &parser,
...
@@ -980,7 +1061,7 @@ bool GenerateGeneral(const Parser &parser,
for
(
auto
it
=
parser
.
structs_
.
vec
.
begin
();
for
(
auto
it
=
parser
.
structs_
.
vec
.
begin
();
it
!=
parser
.
structs_
.
vec
.
end
();
++
it
)
{
it
!=
parser
.
structs_
.
vec
.
end
();
++
it
)
{
std
::
string
declcode
;
std
::
string
declcode
;
GenStruct
(
lang
,
parser
,
**
it
,
&
declcode
);
GenStruct
(
lang
,
parser
,
**
it
,
opts
,
&
declcode
);
if
(
opts
.
one_file
)
{
if
(
opts
.
one_file
)
{
one_file_code
+=
declcode
;
one_file_code
+=
declcode
;
}
}
...
...
tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
View file @
d06b2736
...
@@ -65,7 +65,6 @@ namespace FlatBuffers.Test
...
@@ -65,7 +65,6 @@ namespace FlatBuffers.Test
fbb
.
AddOffset
(
test1
.
Value
);
fbb
.
AddOffset
(
test1
.
Value
);
var
testArrayOfString
=
fbb
.
EndVector
();
var
testArrayOfString
=
fbb
.
EndVector
();
Monster
.
StartMonster
(
fbb
);
Monster
.
StartMonster
(
fbb
);
Monster
.
AddPos
(
fbb
,
Vec3
.
CreateVec3
(
fbb
,
1.0f
,
2.0f
,
3.0f
,
3.0
,
Monster
.
AddPos
(
fbb
,
Vec3
.
CreateVec3
(
fbb
,
1.0f
,
2.0f
,
3.0f
,
3.0
,
Color
.
Green
,
(
short
)
5
,
(
sbyte
)
6
));
Color
.
Green
,
(
short
)
5
,
(
sbyte
)
6
));
...
@@ -79,7 +78,8 @@ namespace FlatBuffers.Test
...
@@ -79,7 +78,8 @@ namespace FlatBuffers.Test
Monster
.
AddTestbool
(
fbb
,
false
);
Monster
.
AddTestbool
(
fbb
,
false
);
var
mon
=
Monster
.
EndMonster
(
fbb
);
var
mon
=
Monster
.
EndMonster
(
fbb
);
fbb
.
Finish
(
mon
.
Value
);
Monster
.
FinishMonsterBuffer
(
fbb
,
mon
);
// Dump to output directory so we can inspect later, if needed
// Dump to output directory so we can inspect later, if needed
using
(
var
ms
=
new
MemoryStream
(
fbb
.
DataBuffer
.
Data
,
fbb
.
DataBuffer
.
Position
,
fbb
.
Offset
))
using
(
var
ms
=
new
MemoryStream
(
fbb
.
DataBuffer
.
Data
,
fbb
.
DataBuffer
.
Position
,
fbb
.
Offset
))
...
@@ -90,6 +90,51 @@ namespace FlatBuffers.Test
...
@@ -90,6 +90,51 @@ namespace FlatBuffers.Test
// Now assert the buffer
// Now assert the buffer
TestBuffer
(
fbb
.
DataBuffer
);
TestBuffer
(
fbb
.
DataBuffer
);
//Attempt to mutate Monster fields and check whether the buffer has been mutated properly
// revert to original values after testing
Monster
monster
=
Monster
.
GetRootAsMonster
(
fbb
.
DataBuffer
);
// mana is optional and does not exist in the buffer so the mutation should fail
// the mana field should retain its default value
Assert
.
AreEqual
(
monster
.
MutateMana
((
short
)
10
),
false
);
Assert
.
AreEqual
(
monster
.
Mana
,
(
short
)
150
);
// testType is an existing field and mutating it should succeed
Assert
.
AreEqual
(
monster
.
TestType
,
Any
.
Monster
);
Assert
.
AreEqual
(
monster
.
MutateTestType
(
Any
.
NONE
),
true
);
Assert
.
AreEqual
(
monster
.
TestType
,
Any
.
NONE
);
Assert
.
AreEqual
(
monster
.
MutateTestType
(
Any
.
Monster
),
true
);
Assert
.
AreEqual
(
monster
.
TestType
,
Any
.
Monster
);
//mutate the inventory vector
Assert
.
AreEqual
(
monster
.
MutateInventory
(
0
,
1
),
true
);
Assert
.
AreEqual
(
monster
.
MutateInventory
(
1
,
2
),
true
);
Assert
.
AreEqual
(
monster
.
MutateInventory
(
2
,
3
),
true
);
Assert
.
AreEqual
(
monster
.
MutateInventory
(
3
,
4
),
true
);
Assert
.
AreEqual
(
monster
.
MutateInventory
(
4
,
5
),
true
);
for
(
int
i
=
0
;
i
<
monster
.
InventoryLength
;
i
++)
{
Assert
.
AreEqual
(
monster
.
GetInventory
(
i
),
i
+
1
);
}
//reverse mutation
Assert
.
AreEqual
(
monster
.
MutateInventory
(
0
,
0
),
true
);
Assert
.
AreEqual
(
monster
.
MutateInventory
(
1
,
1
),
true
);
Assert
.
AreEqual
(
monster
.
MutateInventory
(
2
,
2
),
true
);
Assert
.
AreEqual
(
monster
.
MutateInventory
(
3
,
3
),
true
);
Assert
.
AreEqual
(
monster
.
MutateInventory
(
4
,
4
),
true
);
// get a struct field and edit one of its fields
Vec3
pos
=
monster
.
Pos
;
Assert
.
AreEqual
(
pos
.
X
,
1.0f
);
pos
.
MutateX
(
55.0f
);
Assert
.
AreEqual
(
pos
.
X
,
55.0f
);
pos
.
MutateX
(
1.0f
);
Assert
.
AreEqual
(
pos
.
X
,
1.0f
);
TestBuffer
(
fbb
.
DataBuffer
);
}
}
private
void
TestBuffer
(
ByteBuffer
bb
)
private
void
TestBuffer
(
ByteBuffer
bb
)
...
...
tests/FlatBuffers.Test/Program.cs
View file @
d06b2736
...
@@ -56,6 +56,7 @@ namespace FlatBuffers.Test
...
@@ -56,6 +56,7 @@ namespace FlatBuffers.Test
}
}
Console
.
WriteLine
(
"FlatBuffers test: completed successfully"
);
return
0
;
return
0
;
}
}
}
}
...
...
tests/JavaTest.java
View file @
d06b2736
...
@@ -81,6 +81,7 @@ class JavaTest {
...
@@ -81,6 +81,7 @@ class JavaTest {
Monster
.
addTest4
(
fbb
,
test4
);
Monster
.
addTest4
(
fbb
,
test4
);
Monster
.
addTestarrayofstring
(
fbb
,
testArrayOfString
);
Monster
.
addTestarrayofstring
(
fbb
,
testArrayOfString
);
Monster
.
addTestbool
(
fbb
,
false
);
Monster
.
addTestbool
(
fbb
,
false
);
Monster
.
addTesthashu32Fnv1
(
fbb
,
Integer
.
MAX_VALUE
+
1L
);
int
mon
=
Monster
.
endMonster
(
fbb
);
int
mon
=
Monster
.
endMonster
(
fbb
);
Monster
.
finishMonsterBuffer
(
fbb
,
mon
);
Monster
.
finishMonsterBuffer
(
fbb
,
mon
);
...
@@ -101,15 +102,59 @@ class JavaTest {
...
@@ -101,15 +102,59 @@ class JavaTest {
}
}
// Test it:
// Test it:
TestBuffer
(
fbb
.
dataBuffer
());
Test
Extended
Buffer
(
fbb
.
dataBuffer
());
// Make sure it also works with read only ByteBuffers. This is slower,
// Make sure it also works with read only ByteBuffers. This is slower,
// since creating strings incurs an additional copy
// since creating strings incurs an additional copy
// (see Table.__string).
// (see Table.__string).
TestBuffer
(
fbb
.
dataBuffer
().
asReadOnlyBuffer
());
Test
Extended
Buffer
(
fbb
.
dataBuffer
().
asReadOnlyBuffer
());
TestEnums
();
TestEnums
();
//Attempt to mutate Monster fields and check whether the buffer has been mutated properly
// revert to original values after testing
Monster
monster
=
Monster
.
getRootAsMonster
(
fbb
.
dataBuffer
());
// mana is optional and does not exist in the buffer so the mutation should fail
// the mana field should retain its default value
TestEq
(
monster
.
mutateMana
((
short
)
10
),
false
);
TestEq
(
monster
.
mana
(),
(
short
)
150
);
// testType is an existing field and mutating it should succeed
TestEq
(
monster
.
testType
(),
(
byte
)
Any
.
Monster
);
TestEq
(
monster
.
mutateTestType
(
Any
.
NONE
),
true
);
TestEq
(
monster
.
testType
(),
(
byte
)
Any
.
NONE
);
TestEq
(
monster
.
mutateTestType
(
Any
.
Monster
),
true
);
TestEq
(
monster
.
testType
(),
(
byte
)
Any
.
Monster
);
//mutate the inventory vector
TestEq
(
monster
.
mutateInventory
(
0
,
1
),
true
);
TestEq
(
monster
.
mutateInventory
(
1
,
2
),
true
);
TestEq
(
monster
.
mutateInventory
(
2
,
3
),
true
);
TestEq
(
monster
.
mutateInventory
(
3
,
4
),
true
);
TestEq
(
monster
.
mutateInventory
(
4
,
5
),
true
);
for
(
int
i
=
0
;
i
<
monster
.
inventoryLength
();
i
++)
{
TestEq
(
monster
.
inventory
(
i
),
i
+
1
);
}
//reverse mutation
TestEq
(
monster
.
mutateInventory
(
0
,
0
),
true
);
TestEq
(
monster
.
mutateInventory
(
1
,
1
),
true
);
TestEq
(
monster
.
mutateInventory
(
2
,
2
),
true
);
TestEq
(
monster
.
mutateInventory
(
3
,
3
),
true
);
TestEq
(
monster
.
mutateInventory
(
4
,
4
),
true
);
// get a struct field and edit one of its fields
Vec3
pos
=
monster
.
pos
();
TestEq
(
pos
.
x
(),
1.0f
);
pos
.
mutateX
(
55.0f
);
TestEq
(
pos
.
x
(),
55.0f
);
pos
.
mutateX
(
1.0f
);
TestEq
(
pos
.
x
(),
1.0f
);
TestExtendedBuffer
(
fbb
.
dataBuffer
().
asReadOnlyBuffer
());
System
.
out
.
println
(
"FlatBuffers test: completed successfully"
);
System
.
out
.
println
(
"FlatBuffers test: completed successfully"
);
}
}
...
@@ -122,7 +167,7 @@ class JavaTest {
...
@@ -122,7 +167,7 @@ class JavaTest {
static
void
TestBuffer
(
ByteBuffer
bb
)
{
static
void
TestBuffer
(
ByteBuffer
bb
)
{
TestEq
(
Monster
.
MonsterBufferHasIdentifier
(
bb
),
true
);
TestEq
(
Monster
.
MonsterBufferHasIdentifier
(
bb
),
true
);
Monster
monster
=
Monster
.
getRootAsMonster
(
bb
);
Monster
monster
=
Monster
.
getRootAsMonster
(
bb
);
TestEq
(
monster
.
hp
(),
(
short
)
80
);
TestEq
(
monster
.
hp
(),
(
short
)
80
);
...
@@ -171,6 +216,16 @@ class JavaTest {
...
@@ -171,6 +216,16 @@ class JavaTest {
TestEq
(
monster
.
testbool
(),
false
);
TestEq
(
monster
.
testbool
(),
false
);
}
}
// this method checks additional fields not present in the binary buffer read from file
// these new tests are performed on top of the regular tests
static
void
TestExtendedBuffer
(
ByteBuffer
bb
)
{
TestBuffer
(
bb
);
Monster
monster
=
Monster
.
getRootAsMonster
(
bb
);
TestEq
(
monster
.
testhashu32Fnv1
(),
Integer
.
MAX_VALUE
+
1L
);
}
static
<
T
>
void
TestEq
(
T
a
,
T
b
)
{
static
<
T
>
void
TestEq
(
T
a
,
T
b
)
{
if
(!
a
.
equals
(
b
))
{
if
(!
a
.
equals
(
b
))
{
System
.
out
.
println
(
""
+
a
.
getClass
().
getName
()
+
" "
+
b
.
getClass
().
getName
());
System
.
out
.
println
(
""
+
a
.
getClass
().
getName
()
+
" "
+
b
.
getClass
().
getName
());
...
...
tests/MyGame/Example/Monster.cs
View file @
d06b2736
...
@@ -14,12 +14,17 @@ public sealed class Monster : Table {
...
@@ -14,12 +14,17 @@ public sealed class Monster : Table {
public
Vec3
Pos
{
get
{
return
GetPos
(
new
Vec3
());
}
}
public
Vec3
Pos
{
get
{
return
GetPos
(
new
Vec3
());
}
}
public
Vec3
GetPos
(
Vec3
obj
)
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
obj
.
__init
(
o
+
bb_pos
,
bb
)
:
null
;
}
public
Vec3
GetPos
(
Vec3
obj
)
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
obj
.
__init
(
o
+
bb_pos
,
bb
)
:
null
;
}
public
short
Mana
{
get
{
int
o
=
__offset
(
6
);
return
o
!=
0
?
bb
.
GetShort
(
o
+
bb_pos
)
:
(
short
)
150
;
}
}
public
short
Mana
{
get
{
int
o
=
__offset
(
6
);
return
o
!=
0
?
bb
.
GetShort
(
o
+
bb_pos
)
:
(
short
)
150
;
}
}
public
bool
MutateMana
(
short
mana
)
{
int
o
=
__offset
(
6
);
if
(
o
!=
0
)
{
bb
.
PutShort
(
o
+
bb_pos
,
mana
);
return
true
;
}
else
{
return
false
;
}
}
public
short
Hp
{
get
{
int
o
=
__offset
(
8
);
return
o
!=
0
?
bb
.
GetShort
(
o
+
bb_pos
)
:
(
short
)
100
;
}
}
public
short
Hp
{
get
{
int
o
=
__offset
(
8
);
return
o
!=
0
?
bb
.
GetShort
(
o
+
bb_pos
)
:
(
short
)
100
;
}
}
public
bool
MutateHp
(
short
hp
)
{
int
o
=
__offset
(
8
);
if
(
o
!=
0
)
{
bb
.
PutShort
(
o
+
bb_pos
,
hp
);
return
true
;
}
else
{
return
false
;
}
}
public
string
Name
{
get
{
int
o
=
__offset
(
10
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
}
public
string
Name
{
get
{
int
o
=
__offset
(
10
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
}
public
byte
GetInventory
(
int
j
)
{
int
o
=
__offset
(
14
);
return
o
!=
0
?
bb
.
Get
(
__vector
(
o
)
+
j
*
1
)
:
(
byte
)
0
;
}
public
byte
GetInventory
(
int
j
)
{
int
o
=
__offset
(
14
);
return
o
!=
0
?
bb
.
Get
(
__vector
(
o
)
+
j
*
1
)
:
(
byte
)
0
;
}
public
int
InventoryLength
{
get
{
int
o
=
__offset
(
14
);
return
o
!=
0
?
__vector_len
(
o
)
:
0
;
}
}
public
int
InventoryLength
{
get
{
int
o
=
__offset
(
14
);
return
o
!=
0
?
__vector_len
(
o
)
:
0
;
}
}
public
bool
MutateInventory
(
int
j
,
byte
inventory
)
{
int
o
=
__offset
(
14
);
if
(
o
!=
0
)
{
bb
.
Put
(
__vector
(
o
)
+
j
*
1
,
inventory
);
return
true
;
}
else
{
return
false
;
}
}
public
Color
Color
{
get
{
int
o
=
__offset
(
16
);
return
o
!=
0
?
(
Color
)
bb
.
GetSbyte
(
o
+
bb_pos
)
:
(
Color
)
8
;
}
}
public
Color
Color
{
get
{
int
o
=
__offset
(
16
);
return
o
!=
0
?
(
Color
)
bb
.
GetSbyte
(
o
+
bb_pos
)
:
(
Color
)
8
;
}
}
public
bool
MutateColor
(
Color
color
)
{
int
o
=
__offset
(
16
);
if
(
o
!=
0
)
{
bb
.
PutSbyte
(
o
+
bb_pos
,
(
sbyte
)
color
);
return
true
;
}
else
{
return
false
;
}
}
public
Any
TestType
{
get
{
int
o
=
__offset
(
18
);
return
o
!=
0
?
(
Any
)
bb
.
Get
(
o
+
bb_pos
)
:
(
Any
)
0
;
}
}
public
Any
TestType
{
get
{
int
o
=
__offset
(
18
);
return
o
!=
0
?
(
Any
)
bb
.
Get
(
o
+
bb_pos
)
:
(
Any
)
0
;
}
}
public
bool
MutateTestType
(
Any
test_type
)
{
int
o
=
__offset
(
18
);
if
(
o
!=
0
)
{
bb
.
Put
(
o
+
bb_pos
,
(
byte
)
test_type
);
return
true
;
}
else
{
return
false
;
}
}
public
TTable
GetTest
<
TTable
>(
TTable
obj
)
where
TTable
:
Table
{
int
o
=
__offset
(
20
);
return
o
!=
0
?
__union
(
obj
,
o
)
:
null
;
}
public
TTable
GetTest
<
TTable
>(
TTable
obj
)
where
TTable
:
Table
{
int
o
=
__offset
(
20
);
return
o
!=
0
?
__union
(
obj
,
o
)
:
null
;
}
public
Test
GetTest4
(
int
j
)
{
return
GetTest4
(
new
Test
(),
j
);
}
public
Test
GetTest4
(
int
j
)
{
return
GetTest4
(
new
Test
(),
j
);
}
public
Test
GetTest4
(
Test
obj
,
int
j
)
{
int
o
=
__offset
(
22
);
return
o
!=
0
?
obj
.
__init
(
__vector
(
o
)
+
j
*
4
,
bb
)
:
null
;
}
public
Test
GetTest4
(
Test
obj
,
int
j
)
{
int
o
=
__offset
(
22
);
return
o
!=
0
?
obj
.
__init
(
__vector
(
o
)
+
j
*
4
,
bb
)
:
null
;
}
...
@@ -35,17 +40,27 @@ public sealed class Monster : Table {
...
@@ -35,17 +40,27 @@ public sealed class Monster : Table {
public
Monster
GetEnemy
(
Monster
obj
)
{
int
o
=
__offset
(
28
);
return
o
!=
0
?
obj
.
__init
(
__indirect
(
o
+
bb_pos
),
bb
)
:
null
;
}
public
Monster
GetEnemy
(
Monster
obj
)
{
int
o
=
__offset
(
28
);
return
o
!=
0
?
obj
.
__init
(
__indirect
(
o
+
bb_pos
),
bb
)
:
null
;
}
public
byte
GetTestnestedflatbuffer
(
int
j
)
{
int
o
=
__offset
(
30
);
return
o
!=
0
?
bb
.
Get
(
__vector
(
o
)
+
j
*
1
)
:
(
byte
)
0
;
}
public
byte
GetTestnestedflatbuffer
(
int
j
)
{
int
o
=
__offset
(
30
);
return
o
!=
0
?
bb
.
Get
(
__vector
(
o
)
+
j
*
1
)
:
(
byte
)
0
;
}
public
int
TestnestedflatbufferLength
{
get
{
int
o
=
__offset
(
30
);
return
o
!=
0
?
__vector_len
(
o
)
:
0
;
}
}
public
int
TestnestedflatbufferLength
{
get
{
int
o
=
__offset
(
30
);
return
o
!=
0
?
__vector_len
(
o
)
:
0
;
}
}
public
bool
MutateTestnestedflatbuffer
(
int
j
,
byte
testnestedflatbuffer
)
{
int
o
=
__offset
(
30
);
if
(
o
!=
0
)
{
bb
.
Put
(
__vector
(
o
)
+
j
*
1
,
testnestedflatbuffer
);
return
true
;
}
else
{
return
false
;
}
}
public
Stat
Testempty
{
get
{
return
GetTestempty
(
new
Stat
());
}
}
public
Stat
Testempty
{
get
{
return
GetTestempty
(
new
Stat
());
}
}
public
Stat
GetTestempty
(
Stat
obj
)
{
int
o
=
__offset
(
32
);
return
o
!=
0
?
obj
.
__init
(
__indirect
(
o
+
bb_pos
),
bb
)
:
null
;
}
public
Stat
GetTestempty
(
Stat
obj
)
{
int
o
=
__offset
(
32
);
return
o
!=
0
?
obj
.
__init
(
__indirect
(
o
+
bb_pos
),
bb
)
:
null
;
}
public
bool
Testbool
{
get
{
int
o
=
__offset
(
34
);
return
o
!=
0
?
0
!=
bb
.
Get
(
o
+
bb_pos
)
:
(
bool
)
false
;
}
}
public
bool
Testbool
{
get
{
int
o
=
__offset
(
34
);
return
o
!=
0
?
0
!=
bb
.
Get
(
o
+
bb_pos
)
:
(
bool
)
false
;
}
}
public
bool
MutateTestbool
(
bool
testbool
)
{
int
o
=
__offset
(
34
);
if
(
o
!=
0
)
{
bb
.
Put
(
o
+
bb_pos
,
(
byte
)(
testbool
?
1
:
0
));
return
true
;
}
else
{
return
false
;
}
}
public
int
Testhashs32Fnv1
{
get
{
int
o
=
__offset
(
36
);
return
o
!=
0
?
bb
.
GetInt
(
o
+
bb_pos
)
:
(
int
)
0
;
}
}
public
int
Testhashs32Fnv1
{
get
{
int
o
=
__offset
(
36
);
return
o
!=
0
?
bb
.
GetInt
(
o
+
bb_pos
)
:
(
int
)
0
;
}
}
public
bool
MutateTesthashs32Fnv1
(
int
testhashs32_fnv1
)
{
int
o
=
__offset
(
36
);
if
(
o
!=
0
)
{
bb
.
PutInt
(
o
+
bb_pos
,
testhashs32_fnv1
);
return
true
;
}
else
{
return
false
;
}
}
public
uint
Testhashu32Fnv1
{
get
{
int
o
=
__offset
(
38
);
return
o
!=
0
?
bb
.
GetUint
(
o
+
bb_pos
)
:
(
uint
)
0
;
}
}
public
uint
Testhashu32Fnv1
{
get
{
int
o
=
__offset
(
38
);
return
o
!=
0
?
bb
.
GetUint
(
o
+
bb_pos
)
:
(
uint
)
0
;
}
}
public
bool
MutateTesthashu32Fnv1
(
uint
testhashu32_fnv1
)
{
int
o
=
__offset
(
38
);
if
(
o
!=
0
)
{
bb
.
PutUint
(
o
+
bb_pos
,
testhashu32_fnv1
);
return
true
;
}
else
{
return
false
;
}
}
public
long
Testhashs64Fnv1
{
get
{
int
o
=
__offset
(
40
);
return
o
!=
0
?
bb
.
GetLong
(
o
+
bb_pos
)
:
(
long
)
0
;
}
}
public
long
Testhashs64Fnv1
{
get
{
int
o
=
__offset
(
40
);
return
o
!=
0
?
bb
.
GetLong
(
o
+
bb_pos
)
:
(
long
)
0
;
}
}
public
bool
MutateTesthashs64Fnv1
(
long
testhashs64_fnv1
)
{
int
o
=
__offset
(
40
);
if
(
o
!=
0
)
{
bb
.
PutLong
(
o
+
bb_pos
,
testhashs64_fnv1
);
return
true
;
}
else
{
return
false
;
}
}
public
ulong
Testhashu64Fnv1
{
get
{
int
o
=
__offset
(
42
);
return
o
!=
0
?
bb
.
GetUlong
(
o
+
bb_pos
)
:
(
ulong
)
0
;
}
}
public
ulong
Testhashu64Fnv1
{
get
{
int
o
=
__offset
(
42
);
return
o
!=
0
?
bb
.
GetUlong
(
o
+
bb_pos
)
:
(
ulong
)
0
;
}
}
public
bool
MutateTesthashu64Fnv1
(
ulong
testhashu64_fnv1
)
{
int
o
=
__offset
(
42
);
if
(
o
!=
0
)
{
bb
.
PutUlong
(
o
+
bb_pos
,
testhashu64_fnv1
);
return
true
;
}
else
{
return
false
;
}
}
public
int
Testhashs32Fnv1a
{
get
{
int
o
=
__offset
(
44
);
return
o
!=
0
?
bb
.
GetInt
(
o
+
bb_pos
)
:
(
int
)
0
;
}
}
public
int
Testhashs32Fnv1a
{
get
{
int
o
=
__offset
(
44
);
return
o
!=
0
?
bb
.
GetInt
(
o
+
bb_pos
)
:
(
int
)
0
;
}
}
public
bool
MutateTesthashs32Fnv1a
(
int
testhashs32_fnv1a
)
{
int
o
=
__offset
(
44
);
if
(
o
!=
0
)
{
bb
.
PutInt
(
o
+
bb_pos
,
testhashs32_fnv1a
);
return
true
;
}
else
{
return
false
;
}
}
public
uint
Testhashu32Fnv1a
{
get
{
int
o
=
__offset
(
46
);
return
o
!=
0
?
bb
.
GetUint
(
o
+
bb_pos
)
:
(
uint
)
0
;
}
}
public
uint
Testhashu32Fnv1a
{
get
{
int
o
=
__offset
(
46
);
return
o
!=
0
?
bb
.
GetUint
(
o
+
bb_pos
)
:
(
uint
)
0
;
}
}
public
bool
MutateTesthashu32Fnv1a
(
uint
testhashu32_fnv1a
)
{
int
o
=
__offset
(
46
);
if
(
o
!=
0
)
{
bb
.
PutUint
(
o
+
bb_pos
,
testhashu32_fnv1a
);
return
true
;
}
else
{
return
false
;
}
}
public
long
Testhashs64Fnv1a
{
get
{
int
o
=
__offset
(
48
);
return
o
!=
0
?
bb
.
GetLong
(
o
+
bb_pos
)
:
(
long
)
0
;
}
}
public
long
Testhashs64Fnv1a
{
get
{
int
o
=
__offset
(
48
);
return
o
!=
0
?
bb
.
GetLong
(
o
+
bb_pos
)
:
(
long
)
0
;
}
}
public
bool
MutateTesthashs64Fnv1a
(
long
testhashs64_fnv1a
)
{
int
o
=
__offset
(
48
);
if
(
o
!=
0
)
{
bb
.
PutLong
(
o
+
bb_pos
,
testhashs64_fnv1a
);
return
true
;
}
else
{
return
false
;
}
}
public
ulong
Testhashu64Fnv1a
{
get
{
int
o
=
__offset
(
50
);
return
o
!=
0
?
bb
.
GetUlong
(
o
+
bb_pos
)
:
(
ulong
)
0
;
}
}
public
ulong
Testhashu64Fnv1a
{
get
{
int
o
=
__offset
(
50
);
return
o
!=
0
?
bb
.
GetUlong
(
o
+
bb_pos
)
:
(
ulong
)
0
;
}
}
public
bool
MutateTesthashu64Fnv1a
(
ulong
testhashu64_fnv1a
)
{
int
o
=
__offset
(
50
);
if
(
o
!=
0
)
{
bb
.
PutUlong
(
o
+
bb_pos
,
testhashu64_fnv1a
);
return
true
;
}
else
{
return
false
;
}
}
public
static
void
StartMonster
(
FlatBufferBuilder
builder
)
{
builder
.
StartObject
(
24
);
}
public
static
void
StartMonster
(
FlatBufferBuilder
builder
)
{
builder
.
StartObject
(
24
);
}
public
static
void
AddPos
(
FlatBufferBuilder
builder
,
Offset
<
Vec3
>
posOffset
)
{
builder
.
AddStruct
(
0
,
posOffset
.
Value
,
0
);
}
public
static
void
AddPos
(
FlatBufferBuilder
builder
,
Offset
<
Vec3
>
posOffset
)
{
builder
.
AddStruct
(
0
,
posOffset
.
Value
,
0
);
}
...
...
tests/MyGame/Example/Monster.java
View file @
d06b2736
...
@@ -16,14 +16,19 @@ public final class Monster extends Table {
...
@@ -16,14 +16,19 @@ public final class Monster extends Table {
public
Vec3
pos
()
{
return
pos
(
new
Vec3
());
}
public
Vec3
pos
()
{
return
pos
(
new
Vec3
());
}
public
Vec3
pos
(
Vec3
obj
)
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
obj
.
__init
(
o
+
bb_pos
,
bb
)
:
null
;
}
public
Vec3
pos
(
Vec3
obj
)
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
obj
.
__init
(
o
+
bb_pos
,
bb
)
:
null
;
}
public
short
mana
()
{
int
o
=
__offset
(
6
);
return
o
!=
0
?
bb
.
getShort
(
o
+
bb_pos
)
:
150
;
}
public
short
mana
()
{
int
o
=
__offset
(
6
);
return
o
!=
0
?
bb
.
getShort
(
o
+
bb_pos
)
:
150
;
}
public
boolean
mutateMana
(
short
mana
)
{
int
o
=
__offset
(
6
);
if
(
o
!=
0
)
{
bb
.
putShort
(
o
+
bb_pos
,
mana
);
return
true
;
}
else
{
return
false
;
}
}
public
short
hp
()
{
int
o
=
__offset
(
8
);
return
o
!=
0
?
bb
.
getShort
(
o
+
bb_pos
)
:
100
;
}
public
short
hp
()
{
int
o
=
__offset
(
8
);
return
o
!=
0
?
bb
.
getShort
(
o
+
bb_pos
)
:
100
;
}
public
boolean
mutateHp
(
short
hp
)
{
int
o
=
__offset
(
8
);
if
(
o
!=
0
)
{
bb
.
putShort
(
o
+
bb_pos
,
hp
);
return
true
;
}
else
{
return
false
;
}
}
public
String
name
()
{
int
o
=
__offset
(
10
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
public
String
name
()
{
int
o
=
__offset
(
10
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
public
ByteBuffer
nameAsByteBuffer
()
{
return
__vector_as_bytebuffer
(
10
,
1
);
}
public
ByteBuffer
nameAsByteBuffer
()
{
return
__vector_as_bytebuffer
(
10
,
1
);
}
public
int
inventory
(
int
j
)
{
int
o
=
__offset
(
14
);
return
o
!=
0
?
bb
.
get
(
__vector
(
o
)
+
j
*
1
)
&
0xFF
:
0
;
}
public
int
inventory
(
int
j
)
{
int
o
=
__offset
(
14
);
return
o
!=
0
?
bb
.
get
(
__vector
(
o
)
+
j
*
1
)
&
0xFF
:
0
;
}
public
int
inventoryLength
()
{
int
o
=
__offset
(
14
);
return
o
!=
0
?
__vector_len
(
o
)
:
0
;
}
public
int
inventoryLength
()
{
int
o
=
__offset
(
14
);
return
o
!=
0
?
__vector_len
(
o
)
:
0
;
}
public
ByteBuffer
inventoryAsByteBuffer
()
{
return
__vector_as_bytebuffer
(
14
,
1
);
}
public
ByteBuffer
inventoryAsByteBuffer
()
{
return
__vector_as_bytebuffer
(
14
,
1
);
}
public
boolean
mutateInventory
(
int
j
,
int
inventory
)
{
int
o
=
__offset
(
14
);
if
(
o
!=
0
)
{
bb
.
put
(
__vector
(
o
)
+
j
*
1
,
(
byte
)
inventory
);
return
true
;
}
else
{
return
false
;
}
}
public
byte
color
()
{
int
o
=
__offset
(
16
);
return
o
!=
0
?
bb
.
get
(
o
+
bb_pos
)
:
8
;
}
public
byte
color
()
{
int
o
=
__offset
(
16
);
return
o
!=
0
?
bb
.
get
(
o
+
bb_pos
)
:
8
;
}
public
boolean
mutateColor
(
byte
color
)
{
int
o
=
__offset
(
16
);
if
(
o
!=
0
)
{
bb
.
put
(
o
+
bb_pos
,
color
);
return
true
;
}
else
{
return
false
;
}
}
public
byte
testType
()
{
int
o
=
__offset
(
18
);
return
o
!=
0
?
bb
.
get
(
o
+
bb_pos
)
:
0
;
}
public
byte
testType
()
{
int
o
=
__offset
(
18
);
return
o
!=
0
?
bb
.
get
(
o
+
bb_pos
)
:
0
;
}
public
boolean
mutateTestType
(
byte
test_type
)
{
int
o
=
__offset
(
18
);
if
(
o
!=
0
)
{
bb
.
put
(
o
+
bb_pos
,
test_type
);
return
true
;
}
else
{
return
false
;
}
}
public
Table
test
(
Table
obj
)
{
int
o
=
__offset
(
20
);
return
o
!=
0
?
__union
(
obj
,
o
)
:
null
;
}
public
Table
test
(
Table
obj
)
{
int
o
=
__offset
(
20
);
return
o
!=
0
?
__union
(
obj
,
o
)
:
null
;
}
public
Test
test4
(
int
j
)
{
return
test4
(
new
Test
(),
j
);
}
public
Test
test4
(
int
j
)
{
return
test4
(
new
Test
(),
j
);
}
public
Test
test4
(
Test
obj
,
int
j
)
{
int
o
=
__offset
(
22
);
return
o
!=
0
?
obj
.
__init
(
__vector
(
o
)
+
j
*
4
,
bb
)
:
null
;
}
public
Test
test4
(
Test
obj
,
int
j
)
{
int
o
=
__offset
(
22
);
return
o
!=
0
?
obj
.
__init
(
__vector
(
o
)
+
j
*
4
,
bb
)
:
null
;
}
...
@@ -42,17 +47,27 @@ public final class Monster extends Table {
...
@@ -42,17 +47,27 @@ public final class Monster extends Table {
public
int
testnestedflatbuffer
(
int
j
)
{
int
o
=
__offset
(
30
);
return
o
!=
0
?
bb
.
get
(
__vector
(
o
)
+
j
*
1
)
&
0xFF
:
0
;
}
public
int
testnestedflatbuffer
(
int
j
)
{
int
o
=
__offset
(
30
);
return
o
!=
0
?
bb
.
get
(
__vector
(
o
)
+
j
*
1
)
&
0xFF
:
0
;
}
public
int
testnestedflatbufferLength
()
{
int
o
=
__offset
(
30
);
return
o
!=
0
?
__vector_len
(
o
)
:
0
;
}
public
int
testnestedflatbufferLength
()
{
int
o
=
__offset
(
30
);
return
o
!=
0
?
__vector_len
(
o
)
:
0
;
}
public
ByteBuffer
testnestedflatbufferAsByteBuffer
()
{
return
__vector_as_bytebuffer
(
30
,
1
);
}
public
ByteBuffer
testnestedflatbufferAsByteBuffer
()
{
return
__vector_as_bytebuffer
(
30
,
1
);
}
public
boolean
mutateTestnestedflatbuffer
(
int
j
,
int
testnestedflatbuffer
)
{
int
o
=
__offset
(
30
);
if
(
o
!=
0
)
{
bb
.
put
(
__vector
(
o
)
+
j
*
1
,
(
byte
)
testnestedflatbuffer
);
return
true
;
}
else
{
return
false
;
}
}
public
Stat
testempty
()
{
return
testempty
(
new
Stat
());
}
public
Stat
testempty
()
{
return
testempty
(
new
Stat
());
}
public
Stat
testempty
(
Stat
obj
)
{
int
o
=
__offset
(
32
);
return
o
!=
0
?
obj
.
__init
(
__indirect
(
o
+
bb_pos
),
bb
)
:
null
;
}
public
Stat
testempty
(
Stat
obj
)
{
int
o
=
__offset
(
32
);
return
o
!=
0
?
obj
.
__init
(
__indirect
(
o
+
bb_pos
),
bb
)
:
null
;
}
public
boolean
testbool
()
{
int
o
=
__offset
(
34
);
return
o
!=
0
?
0
!=
bb
.
get
(
o
+
bb_pos
)
:
false
;
}
public
boolean
testbool
()
{
int
o
=
__offset
(
34
);
return
o
!=
0
?
0
!=
bb
.
get
(
o
+
bb_pos
)
:
false
;
}
public
boolean
mutateTestbool
(
boolean
testbool
)
{
int
o
=
__offset
(
34
);
if
(
o
!=
0
)
{
bb
.
put
(
o
+
bb_pos
,
(
byte
)(
testbool
?
1
:
0
));
return
true
;
}
else
{
return
false
;
}
}
public
int
testhashs32Fnv1
()
{
int
o
=
__offset
(
36
);
return
o
!=
0
?
bb
.
getInt
(
o
+
bb_pos
)
:
0
;
}
public
int
testhashs32Fnv1
()
{
int
o
=
__offset
(
36
);
return
o
!=
0
?
bb
.
getInt
(
o
+
bb_pos
)
:
0
;
}
public
boolean
mutateTesthashs32Fnv1
(
int
testhashs32_fnv1
)
{
int
o
=
__offset
(
36
);
if
(
o
!=
0
)
{
bb
.
putInt
(
o
+
bb_pos
,
testhashs32_fnv1
);
return
true
;
}
else
{
return
false
;
}
}
public
long
testhashu32Fnv1
()
{
int
o
=
__offset
(
38
);
return
o
!=
0
?
(
long
)
bb
.
getInt
(
o
+
bb_pos
)
&
0xFFFFFFFF
L
:
0
;
}
public
long
testhashu32Fnv1
()
{
int
o
=
__offset
(
38
);
return
o
!=
0
?
(
long
)
bb
.
getInt
(
o
+
bb_pos
)
&
0xFFFFFFFF
L
:
0
;
}
public
boolean
mutateTesthashu32Fnv1
(
long
testhashu32_fnv1
)
{
int
o
=
__offset
(
38
);
if
(
o
!=
0
)
{
bb
.
putInt
(
o
+
bb_pos
,
(
int
)
testhashu32_fnv1
);
return
true
;
}
else
{
return
false
;
}
}
public
long
testhashs64Fnv1
()
{
int
o
=
__offset
(
40
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
long
testhashs64Fnv1
()
{
int
o
=
__offset
(
40
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
boolean
mutateTesthashs64Fnv1
(
long
testhashs64_fnv1
)
{
int
o
=
__offset
(
40
);
if
(
o
!=
0
)
{
bb
.
putLong
(
o
+
bb_pos
,
testhashs64_fnv1
);
return
true
;
}
else
{
return
false
;
}
}
public
long
testhashu64Fnv1
()
{
int
o
=
__offset
(
42
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
long
testhashu64Fnv1
()
{
int
o
=
__offset
(
42
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
boolean
mutateTesthashu64Fnv1
(
long
testhashu64_fnv1
)
{
int
o
=
__offset
(
42
);
if
(
o
!=
0
)
{
bb
.
putLong
(
o
+
bb_pos
,
testhashu64_fnv1
);
return
true
;
}
else
{
return
false
;
}
}
public
int
testhashs32Fnv1a
()
{
int
o
=
__offset
(
44
);
return
o
!=
0
?
bb
.
getInt
(
o
+
bb_pos
)
:
0
;
}
public
int
testhashs32Fnv1a
()
{
int
o
=
__offset
(
44
);
return
o
!=
0
?
bb
.
getInt
(
o
+
bb_pos
)
:
0
;
}
public
boolean
mutateTesthashs32Fnv1a
(
int
testhashs32_fnv1a
)
{
int
o
=
__offset
(
44
);
if
(
o
!=
0
)
{
bb
.
putInt
(
o
+
bb_pos
,
testhashs32_fnv1a
);
return
true
;
}
else
{
return
false
;
}
}
public
long
testhashu32Fnv1a
()
{
int
o
=
__offset
(
46
);
return
o
!=
0
?
(
long
)
bb
.
getInt
(
o
+
bb_pos
)
&
0xFFFFFFFF
L
:
0
;
}
public
long
testhashu32Fnv1a
()
{
int
o
=
__offset
(
46
);
return
o
!=
0
?
(
long
)
bb
.
getInt
(
o
+
bb_pos
)
&
0xFFFFFFFF
L
:
0
;
}
public
boolean
mutateTesthashu32Fnv1a
(
long
testhashu32_fnv1a
)
{
int
o
=
__offset
(
46
);
if
(
o
!=
0
)
{
bb
.
putInt
(
o
+
bb_pos
,
(
int
)
testhashu32_fnv1a
);
return
true
;
}
else
{
return
false
;
}
}
public
long
testhashs64Fnv1a
()
{
int
o
=
__offset
(
48
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
long
testhashs64Fnv1a
()
{
int
o
=
__offset
(
48
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
boolean
mutateTesthashs64Fnv1a
(
long
testhashs64_fnv1a
)
{
int
o
=
__offset
(
48
);
if
(
o
!=
0
)
{
bb
.
putLong
(
o
+
bb_pos
,
testhashs64_fnv1a
);
return
true
;
}
else
{
return
false
;
}
}
public
long
testhashu64Fnv1a
()
{
int
o
=
__offset
(
50
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
long
testhashu64Fnv1a
()
{
int
o
=
__offset
(
50
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
boolean
mutateTesthashu64Fnv1a
(
long
testhashu64_fnv1a
)
{
int
o
=
__offset
(
50
);
if
(
o
!=
0
)
{
bb
.
putLong
(
o
+
bb_pos
,
testhashu64_fnv1a
);
return
true
;
}
else
{
return
false
;
}
}
public
static
void
startMonster
(
FlatBufferBuilder
builder
)
{
builder
.
startObject
(
24
);
}
public
static
void
startMonster
(
FlatBufferBuilder
builder
)
{
builder
.
startObject
(
24
);
}
public
static
void
addPos
(
FlatBufferBuilder
builder
,
int
posOffset
)
{
builder
.
addStruct
(
0
,
posOffset
,
0
);
}
public
static
void
addPos
(
FlatBufferBuilder
builder
,
int
posOffset
)
{
builder
.
addStruct
(
0
,
posOffset
,
0
);
}
...
...
tests/MyGame/Example/Stat.cs
View file @
d06b2736
...
@@ -12,7 +12,9 @@ public sealed class Stat : Table {
...
@@ -12,7 +12,9 @@ public sealed class Stat : Table {
public
string
Id
{
get
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
}
public
string
Id
{
get
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
__string
(
o
+
bb_pos
)
:
null
;
}
}
public
long
Val
{
get
{
int
o
=
__offset
(
6
);
return
o
!=
0
?
bb
.
GetLong
(
o
+
bb_pos
)
:
(
long
)
0
;
}
}
public
long
Val
{
get
{
int
o
=
__offset
(
6
);
return
o
!=
0
?
bb
.
GetLong
(
o
+
bb_pos
)
:
(
long
)
0
;
}
}
public
bool
MutateVal
(
long
val
)
{
int
o
=
__offset
(
6
);
if
(
o
!=
0
)
{
bb
.
PutLong
(
o
+
bb_pos
,
val
);
return
true
;
}
else
{
return
false
;
}
}
public
ushort
Count
{
get
{
int
o
=
__offset
(
8
);
return
o
!=
0
?
bb
.
GetUshort
(
o
+
bb_pos
)
:
(
ushort
)
0
;
}
}
public
ushort
Count
{
get
{
int
o
=
__offset
(
8
);
return
o
!=
0
?
bb
.
GetUshort
(
o
+
bb_pos
)
:
(
ushort
)
0
;
}
}
public
bool
MutateCount
(
ushort
count
)
{
int
o
=
__offset
(
8
);
if
(
o
!=
0
)
{
bb
.
PutUshort
(
o
+
bb_pos
,
count
);
return
true
;
}
else
{
return
false
;
}
}
public
static
Offset
<
Stat
>
CreateStat
(
FlatBufferBuilder
builder
,
public
static
Offset
<
Stat
>
CreateStat
(
FlatBufferBuilder
builder
,
StringOffset
id
=
default
(
StringOffset
),
StringOffset
id
=
default
(
StringOffset
),
...
...
tests/MyGame/Example/Stat.java
View file @
d06b2736
...
@@ -15,7 +15,9 @@ public final class Stat extends Table {
...
@@ -15,7 +15,9 @@ public final class Stat extends Table {
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
;
}
public
ByteBuffer
idAsByteBuffer
()
{
return
__vector_as_bytebuffer
(
4
,
1
);
}
public
ByteBuffer
idAsByteBuffer
()
{
return
__vector_as_bytebuffer
(
4
,
1
);
}
public
long
val
()
{
int
o
=
__offset
(
6
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
long
val
()
{
int
o
=
__offset
(
6
);
return
o
!=
0
?
bb
.
getLong
(
o
+
bb_pos
)
:
0
;
}
public
boolean
mutateVal
(
long
val
)
{
int
o
=
__offset
(
6
);
if
(
o
!=
0
)
{
bb
.
putLong
(
o
+
bb_pos
,
val
);
return
true
;
}
else
{
return
false
;
}
}
public
int
count
()
{
int
o
=
__offset
(
8
);
return
o
!=
0
?
bb
.
getShort
(
o
+
bb_pos
)
&
0xFFFF
:
0
;
}
public
int
count
()
{
int
o
=
__offset
(
8
);
return
o
!=
0
?
bb
.
getShort
(
o
+
bb_pos
)
&
0xFFFF
:
0
;
}
public
boolean
mutateCount
(
int
count
)
{
int
o
=
__offset
(
8
);
if
(
o
!=
0
)
{
bb
.
putShort
(
o
+
bb_pos
,
(
short
)
count
);
return
true
;
}
else
{
return
false
;
}
}
public
static
int
createStat
(
FlatBufferBuilder
builder
,
public
static
int
createStat
(
FlatBufferBuilder
builder
,
int
id
,
int
id
,
...
...
tests/MyGame/Example/Test.cs
View file @
d06b2736
...
@@ -9,7 +9,9 @@ public sealed class Test : Struct {
...
@@ -9,7 +9,9 @@ public sealed class Test : Struct {
public
Test
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
Test
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
short
A
{
get
{
return
bb
.
GetShort
(
bb_pos
+
0
);
}
}
public
short
A
{
get
{
return
bb
.
GetShort
(
bb_pos
+
0
);
}
}
public
void
MutateA
(
short
a
)
{
bb
.
PutShort
(
bb_pos
+
0
,
a
);
}
public
sbyte
B
{
get
{
return
bb
.
GetSbyte
(
bb_pos
+
2
);
}
}
public
sbyte
B
{
get
{
return
bb
.
GetSbyte
(
bb_pos
+
2
);
}
}
public
void
MutateB
(
sbyte
b
)
{
bb
.
PutSbyte
(
bb_pos
+
2
,
b
);
}
public
static
Offset
<
Test
>
CreateTest
(
FlatBufferBuilder
builder
,
short
A
,
sbyte
B
)
{
public
static
Offset
<
Test
>
CreateTest
(
FlatBufferBuilder
builder
,
short
A
,
sbyte
B
)
{
builder
.
Prep
(
2
,
4
);
builder
.
Prep
(
2
,
4
);
...
...
tests/MyGame/Example/Test.java
View file @
d06b2736
...
@@ -11,7 +11,9 @@ public final class Test extends Struct {
...
@@ -11,7 +11,9 @@ public final class Test extends Struct {
public
Test
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
Test
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
short
a
()
{
return
bb
.
getShort
(
bb_pos
+
0
);
}
public
short
a
()
{
return
bb
.
getShort
(
bb_pos
+
0
);
}
public
void
mutateA
(
short
a
)
{
bb
.
putShort
(
bb_pos
+
0
,
a
);
}
public
byte
b
()
{
return
bb
.
get
(
bb_pos
+
2
);
}
public
byte
b
()
{
return
bb
.
get
(
bb_pos
+
2
);
}
public
void
mutateB
(
byte
b
)
{
bb
.
put
(
bb_pos
+
2
,
b
);
}
public
static
int
createTest
(
FlatBufferBuilder
builder
,
short
a
,
byte
b
)
{
public
static
int
createTest
(
FlatBufferBuilder
builder
,
short
a
,
byte
b
)
{
builder
.
prep
(
2
,
4
);
builder
.
prep
(
2
,
4
);
...
...
tests/MyGame/Example/Vec3.cs
View file @
d06b2736
...
@@ -9,10 +9,15 @@ public sealed class Vec3 : Struct {
...
@@ -9,10 +9,15 @@ public sealed class Vec3 : Struct {
public
Vec3
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
Vec3
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
float
X
{
get
{
return
bb
.
GetFloat
(
bb_pos
+
0
);
}
}
public
float
X
{
get
{
return
bb
.
GetFloat
(
bb_pos
+
0
);
}
}
public
void
MutateX
(
float
x
)
{
bb
.
PutFloat
(
bb_pos
+
0
,
x
);
}
public
float
Y
{
get
{
return
bb
.
GetFloat
(
bb_pos
+
4
);
}
}
public
float
Y
{
get
{
return
bb
.
GetFloat
(
bb_pos
+
4
);
}
}
public
void
MutateY
(
float
y
)
{
bb
.
PutFloat
(
bb_pos
+
4
,
y
);
}
public
float
Z
{
get
{
return
bb
.
GetFloat
(
bb_pos
+
8
);
}
}
public
float
Z
{
get
{
return
bb
.
GetFloat
(
bb_pos
+
8
);
}
}
public
void
MutateZ
(
float
z
)
{
bb
.
PutFloat
(
bb_pos
+
8
,
z
);
}
public
double
Test1
{
get
{
return
bb
.
GetDouble
(
bb_pos
+
16
);
}
}
public
double
Test1
{
get
{
return
bb
.
GetDouble
(
bb_pos
+
16
);
}
}
public
void
MutateTest1
(
double
test1
)
{
bb
.
PutDouble
(
bb_pos
+
16
,
test1
);
}
public
Color
Test2
{
get
{
return
(
Color
)
bb
.
GetSbyte
(
bb_pos
+
24
);
}
}
public
Color
Test2
{
get
{
return
(
Color
)
bb
.
GetSbyte
(
bb_pos
+
24
);
}
}
public
void
MutateTest2
(
Color
test2
)
{
bb
.
PutSbyte
(
bb_pos
+
24
,
(
sbyte
)
test2
);
}
public
Test
Test3
{
get
{
return
GetTest3
(
new
Test
());
}
}
public
Test
Test3
{
get
{
return
GetTest3
(
new
Test
());
}
}
public
Test
GetTest3
(
Test
obj
)
{
return
obj
.
__init
(
bb_pos
+
26
,
bb
);
}
public
Test
GetTest3
(
Test
obj
)
{
return
obj
.
__init
(
bb_pos
+
26
,
bb
);
}
...
...
tests/MyGame/Example/Vec3.java
View file @
d06b2736
...
@@ -11,10 +11,15 @@ public final class Vec3 extends Struct {
...
@@ -11,10 +11,15 @@ public final class Vec3 extends Struct {
public
Vec3
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
Vec3
__init
(
int
_i
,
ByteBuffer
_bb
)
{
bb_pos
=
_i
;
bb
=
_bb
;
return
this
;
}
public
float
x
()
{
return
bb
.
getFloat
(
bb_pos
+
0
);
}
public
float
x
()
{
return
bb
.
getFloat
(
bb_pos
+
0
);
}
public
void
mutateX
(
float
x
)
{
bb
.
putFloat
(
bb_pos
+
0
,
x
);
}
public
float
y
()
{
return
bb
.
getFloat
(
bb_pos
+
4
);
}
public
float
y
()
{
return
bb
.
getFloat
(
bb_pos
+
4
);
}
public
void
mutateY
(
float
y
)
{
bb
.
putFloat
(
bb_pos
+
4
,
y
);
}
public
float
z
()
{
return
bb
.
getFloat
(
bb_pos
+
8
);
}
public
float
z
()
{
return
bb
.
getFloat
(
bb_pos
+
8
);
}
public
void
mutateZ
(
float
z
)
{
bb
.
putFloat
(
bb_pos
+
8
,
z
);
}
public
double
test1
()
{
return
bb
.
getDouble
(
bb_pos
+
16
);
}
public
double
test1
()
{
return
bb
.
getDouble
(
bb_pos
+
16
);
}
public
void
mutateTest1
(
double
test1
)
{
bb
.
putDouble
(
bb_pos
+
16
,
test1
);
}
public
byte
test2
()
{
return
bb
.
get
(
bb_pos
+
24
);
}
public
byte
test2
()
{
return
bb
.
get
(
bb_pos
+
24
);
}
public
void
mutateTest2
(
byte
test2
)
{
bb
.
put
(
bb_pos
+
24
,
test2
);
}
public
Test
test3
()
{
return
test3
(
new
Test
());
}
public
Test
test3
()
{
return
test3
(
new
Test
());
}
public
Test
test3
(
Test
obj
)
{
return
obj
.
__init
(
bb_pos
+
26
,
bb
);
}
public
Test
test3
(
Test
obj
)
{
return
obj
.
__init
(
bb_pos
+
26
,
bb
);
}
...
...
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