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
e10b8d6f
Commit
e10b8d6f
authored
Nov 25, 2015
by
Wouter van Oortmerssen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #349 from belldon/enum-fix
Fixes issue #348: C# vector of enums doesn't compile
parents
6775a0a9
644bcbde
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
14 additions
and
14 deletions
+14
-14
idl_gen_general.cpp
src/idl_gen_general.cpp
+0
-0
Monster.cs
tests/MyGame/Example/Monster.cs
+4
-4
Monster.java
tests/MyGame/Example/Monster.java
+2
-2
Stat.cs
tests/MyGame/Example/Stat.cs
+2
-2
Stat.java
tests/MyGame/Example/Stat.java
+3
-3
TestSimpleTableWithEnum.cs
tests/MyGame/Example/TestSimpleTableWithEnum.cs
+2
-2
Vec3.cs
tests/MyGame/Example/Vec3.cs
+1
-1
No files found.
src/idl_gen_general.cpp
View file @
e10b8d6f
This diff is collapsed.
Click to expand it.
tests/MyGame/Example/Monster.cs
View file @
e10b8d6f
...
...
@@ -22,9 +22,9 @@ public sealed class Monster : Table {
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
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
.
Blue
;
}
}
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
.
NONE
;
}
}
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
Test
GetTest4
(
int
j
)
{
return
GetTest4
(
new
Test
(),
j
);
}
...
...
@@ -74,8 +74,8 @@ public sealed class Monster : Table {
public
static
void
AddInventory
(
FlatBufferBuilder
builder
,
VectorOffset
inventoryOffset
)
{
builder
.
AddOffset
(
5
,
inventoryOffset
.
Value
,
0
);
}
public
static
VectorOffset
CreateInventoryVector
(
FlatBufferBuilder
builder
,
byte
[]
data
)
{
builder
.
StartVector
(
1
,
data
.
Length
,
1
);
for
(
int
i
=
data
.
Length
-
1
;
i
>=
0
;
i
--)
builder
.
AddByte
(
data
[
i
]);
return
builder
.
EndVector
();
}
public
static
void
StartInventoryVector
(
FlatBufferBuilder
builder
,
int
numElems
)
{
builder
.
StartVector
(
1
,
numElems
,
1
);
}
public
static
void
AddColor
(
FlatBufferBuilder
builder
,
Color
color
)
{
builder
.
AddSbyte
(
6
,
(
sbyte
)
(
color
)
,
8
);
}
public
static
void
AddTestType
(
FlatBufferBuilder
builder
,
Any
testType
)
{
builder
.
AddByte
(
7
,
(
byte
)
(
testType
)
,
0
);
}
public
static
void
AddColor
(
FlatBufferBuilder
builder
,
Color
color
)
{
builder
.
AddSbyte
(
6
,
(
sbyte
)
color
,
8
);
}
public
static
void
AddTestType
(
FlatBufferBuilder
builder
,
Any
testType
)
{
builder
.
AddByte
(
7
,
(
byte
)
testType
,
0
);
}
public
static
void
AddTest
(
FlatBufferBuilder
builder
,
int
testOffset
)
{
builder
.
AddOffset
(
8
,
testOffset
,
0
);
}
public
static
void
AddTest4
(
FlatBufferBuilder
builder
,
VectorOffset
test4Offset
)
{
builder
.
AddOffset
(
9
,
test4Offset
.
Value
,
0
);
}
public
static
void
StartTest4Vector
(
FlatBufferBuilder
builder
,
int
numElems
)
{
builder
.
StartVector
(
4
,
numElems
,
2
);
}
...
...
tests/MyGame/Example/Monster.java
View file @
e10b8d6f
...
...
@@ -103,11 +103,11 @@ public final class Monster extends Table {
public
static
void
addTestempty
(
FlatBufferBuilder
builder
,
int
testemptyOffset
)
{
builder
.
addOffset
(
14
,
testemptyOffset
,
0
);
}
public
static
void
addTestbool
(
FlatBufferBuilder
builder
,
boolean
testbool
)
{
builder
.
addBoolean
(
15
,
testbool
,
false
);
}
public
static
void
addTesthashs32Fnv1
(
FlatBufferBuilder
builder
,
int
testhashs32Fnv1
)
{
builder
.
addInt
(
16
,
testhashs32Fnv1
,
0
);
}
public
static
void
addTesthashu32Fnv1
(
FlatBufferBuilder
builder
,
long
testhashu32Fnv1
)
{
builder
.
addInt
(
17
,
(
int
)
(
testhashu32Fnv1
&
0xFFFFFFFF
L
)
,
0
);
}
public
static
void
addTesthashu32Fnv1
(
FlatBufferBuilder
builder
,
long
testhashu32Fnv1
)
{
builder
.
addInt
(
17
,
(
int
)
testhashu32Fnv1
,
0
);
}
public
static
void
addTesthashs64Fnv1
(
FlatBufferBuilder
builder
,
long
testhashs64Fnv1
)
{
builder
.
addLong
(
18
,
testhashs64Fnv1
,
0
);
}
public
static
void
addTesthashu64Fnv1
(
FlatBufferBuilder
builder
,
long
testhashu64Fnv1
)
{
builder
.
addLong
(
19
,
testhashu64Fnv1
,
0
);
}
public
static
void
addTesthashs32Fnv1a
(
FlatBufferBuilder
builder
,
int
testhashs32Fnv1a
)
{
builder
.
addInt
(
20
,
testhashs32Fnv1a
,
0
);
}
public
static
void
addTesthashu32Fnv1a
(
FlatBufferBuilder
builder
,
long
testhashu32Fnv1a
)
{
builder
.
addInt
(
21
,
(
int
)
(
testhashu32Fnv1a
&
0xFFFFFFFF
L
)
,
0
);
}
public
static
void
addTesthashu32Fnv1a
(
FlatBufferBuilder
builder
,
long
testhashu32Fnv1a
)
{
builder
.
addInt
(
21
,
(
int
)
testhashu32Fnv1a
,
0
);
}
public
static
void
addTesthashs64Fnv1a
(
FlatBufferBuilder
builder
,
long
testhashs64Fnv1a
)
{
builder
.
addLong
(
22
,
testhashs64Fnv1a
,
0
);
}
public
static
void
addTesthashu64Fnv1a
(
FlatBufferBuilder
builder
,
long
testhashu64Fnv1a
)
{
builder
.
addLong
(
23
,
testhashu64Fnv1a
,
0
);
}
public
static
void
addTestarrayofbools
(
FlatBufferBuilder
builder
,
int
testarrayofboolsOffset
)
{
builder
.
addOffset
(
24
,
testarrayofboolsOffset
,
0
);
}
...
...
tests/MyGame/Example/Stat.cs
View file @
e10b8d6f
...
...
@@ -17,12 +17,12 @@ public sealed class Stat : Table {
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
,
StringOffset
id
=
default
(
StringOffset
),
StringOffset
id
Offset
=
default
(
StringOffset
),
long
val
=
0
,
ushort
count
=
0
)
{
builder
.
StartObject
(
3
);
Stat
.
AddVal
(
builder
,
val
);
Stat
.
AddId
(
builder
,
id
);
Stat
.
AddId
(
builder
,
id
Offset
);
Stat
.
AddCount
(
builder
,
count
);
return
Stat
.
EndStat
(
builder
);
}
...
...
tests/MyGame/Example/Stat.java
View file @
e10b8d6f
...
...
@@ -21,12 +21,12 @@ public final class Stat extends Table {
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
,
int
id
,
int
id
Offset
,
long
val
,
int
count
)
{
builder
.
startObject
(
3
);
Stat
.
addVal
(
builder
,
val
);
Stat
.
addId
(
builder
,
id
);
Stat
.
addId
(
builder
,
id
Offset
);
Stat
.
addCount
(
builder
,
count
);
return
Stat
.
endStat
(
builder
);
}
...
...
@@ -34,7 +34,7 @@ public final class Stat extends Table {
public
static
void
startStat
(
FlatBufferBuilder
builder
)
{
builder
.
startObject
(
3
);
}
public
static
void
addId
(
FlatBufferBuilder
builder
,
int
idOffset
)
{
builder
.
addOffset
(
0
,
idOffset
,
0
);
}
public
static
void
addVal
(
FlatBufferBuilder
builder
,
long
val
)
{
builder
.
addLong
(
1
,
val
,
0
);
}
public
static
void
addCount
(
FlatBufferBuilder
builder
,
int
count
)
{
builder
.
addShort
(
2
,
(
short
)
(
count
&
0xFFFF
)
,
0
);
}
public
static
void
addCount
(
FlatBufferBuilder
builder
,
int
count
)
{
builder
.
addShort
(
2
,
(
short
)
count
,
0
);
}
public
static
int
endStat
(
FlatBufferBuilder
builder
)
{
int
o
=
builder
.
endObject
();
return
o
;
...
...
tests/MyGame/Example/TestSimpleTableWithEnum.cs
View file @
e10b8d6f
...
...
@@ -10,7 +10,7 @@ public sealed class TestSimpleTableWithEnum : Table {
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
Color
Color
{
get
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
(
Color
)
bb
.
GetSbyte
(
o
+
bb_pos
)
:
(
Color
)
2
;
}
}
public
Color
Color
{
get
{
int
o
=
__offset
(
4
);
return
o
!=
0
?
(
Color
)
bb
.
GetSbyte
(
o
+
bb_pos
)
:
Color
.
Green
;
}
}
public
bool
MutateColor
(
Color
color
)
{
int
o
=
__offset
(
4
);
if
(
o
!=
0
)
{
bb
.
PutSbyte
(
o
+
bb_pos
,
(
sbyte
)
color
);
return
true
;
}
else
{
return
false
;
}
}
public
static
Offset
<
TestSimpleTableWithEnum
>
CreateTestSimpleTableWithEnum
(
FlatBufferBuilder
builder
,
...
...
@@ -21,7 +21,7 @@ public sealed class TestSimpleTableWithEnum : Table {
}
public
static
void
StartTestSimpleTableWithEnum
(
FlatBufferBuilder
builder
)
{
builder
.
StartObject
(
1
);
}
public
static
void
AddColor
(
FlatBufferBuilder
builder
,
Color
color
)
{
builder
.
AddSbyte
(
0
,
(
sbyte
)
(
color
)
,
2
);
}
public
static
void
AddColor
(
FlatBufferBuilder
builder
,
Color
color
)
{
builder
.
AddSbyte
(
0
,
(
sbyte
)
color
,
2
);
}
public
static
Offset
<
TestSimpleTableWithEnum
>
EndTestSimpleTableWithEnum
(
FlatBufferBuilder
builder
)
{
int
o
=
builder
.
EndObject
();
return
new
Offset
<
TestSimpleTableWithEnum
>(
o
);
...
...
tests/MyGame/Example/Vec3.cs
View file @
e10b8d6f
...
...
@@ -29,7 +29,7 @@ public sealed class Vec3 : Struct {
builder
.
PutSbyte
(
test3_B
);
builder
.
PutShort
(
test3_A
);
builder
.
Pad
(
1
);
builder
.
PutSbyte
((
sbyte
)
(
Test2
)
);
builder
.
PutSbyte
((
sbyte
)
Test2
);
builder
.
PutDouble
(
Test1
);
builder
.
Pad
(
4
);
builder
.
PutFloat
(
Z
);
...
...
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