mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-08 06:05:17 +00:00
Make Monster's Color unsigned (#5318)
- update C++ monster_test::Color to unsigned type - update Go Color:ubyte in the go_test.go - add workaround for unsigned enum in java test - sync generate.bat and generate.sh
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
b701c7d56e
commit
f9ebfcb9c4
@@ -5,7 +5,7 @@
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
public enum Color : sbyte
|
||||
public enum Color : byte
|
||||
{
|
||||
Red = 1,
|
||||
Green = 2,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package Example
|
||||
|
||||
type Color = int8
|
||||
type Color = byte
|
||||
const (
|
||||
ColorRed Color = 1
|
||||
ColorGreen Color = 2
|
||||
|
||||
@@ -40,8 +40,8 @@ public struct Monster : IFlatbufferObject
|
||||
#endif
|
||||
public byte[] GetInventoryArray() { return __p.__vector_as_array<byte>(14); }
|
||||
public bool MutateInventory(int j, byte inventory) { int o = __p.__offset(14); if (o != 0) { __p.bb.Put(__p.__vector(o) + j * 1, inventory); return true; } else { return false; } }
|
||||
public Color Color { get { int o = __p.__offset(16); return o != 0 ? (Color)__p.bb.GetSbyte(o + __p.bb_pos) : Color.Blue; } }
|
||||
public bool MutateColor(Color color) { int o = __p.__offset(16); if (o != 0) { __p.bb.PutSbyte(o + __p.bb_pos, (sbyte)color); return true; } else { return false; } }
|
||||
public Color Color { get { int o = __p.__offset(16); return o != 0 ? (Color)__p.bb.Get(o + __p.bb_pos) : Color.Blue; } }
|
||||
public bool MutateColor(Color color) { int o = __p.__offset(16); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)color); return true; } else { return false; } }
|
||||
public Any TestType { get { int o = __p.__offset(18); return o != 0 ? (Any)__p.bb.Get(o + __p.bb_pos) : Any.NONE; } }
|
||||
public bool MutateTestType(Any test_type) { int o = __p.__offset(18); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)test_type); return true; } else { return false; } }
|
||||
public TTable? Test<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(20); return o != 0 ? (TTable?)__p.__union<TTable>(o) : null; }
|
||||
@@ -178,7 +178,7 @@ public struct Monster : IFlatbufferObject
|
||||
public AnyAmbiguousAliases AnyAmbiguousType { get { int o = __p.__offset(94); return o != 0 ? (AnyAmbiguousAliases)__p.bb.Get(o + __p.bb_pos) : AnyAmbiguousAliases.NONE; } }
|
||||
public bool MutateAnyAmbiguousType(AnyAmbiguousAliases any_ambiguous_type) { int o = __p.__offset(94); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)any_ambiguous_type); return true; } else { return false; } }
|
||||
public TTable? AnyAmbiguous<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(96); return o != 0 ? (TTable?)__p.__union<TTable>(o) : null; }
|
||||
public Color VectorOfEnums(int j) { int o = __p.__offset(98); return o != 0 ? (Color)__p.bb.GetSbyte(__p.__vector(o) + j * 1) : (Color)0; }
|
||||
public Color VectorOfEnums(int j) { int o = __p.__offset(98); return o != 0 ? (Color)__p.bb.Get(__p.__vector(o) + j * 1) : (Color)0; }
|
||||
public int VectorOfEnumsLength { get { int o = __p.__offset(98); return o != 0 ? __p.__vector_len(o) : 0; } }
|
||||
#if ENABLE_SPAN_T
|
||||
public Span<byte> GetVectorOfEnumsBytes() { return __p.__vector_as_span(98); }
|
||||
@@ -186,7 +186,7 @@ public struct Monster : IFlatbufferObject
|
||||
public ArraySegment<byte>? GetVectorOfEnumsBytes() { return __p.__vector_as_arraysegment(98); }
|
||||
#endif
|
||||
public Color[] GetVectorOfEnumsArray() { return __p.__vector_as_array<Color>(98); }
|
||||
public bool MutateVectorOfEnums(int j, Color vector_of_enums) { int o = __p.__offset(98); if (o != 0) { __p.bb.PutSbyte(__p.__vector(o) + j * 1, (sbyte)vector_of_enums); return true; } else { return false; } }
|
||||
public bool MutateVectorOfEnums(int j, Color vector_of_enums) { int o = __p.__offset(98); if (o != 0) { __p.bb.Put(__p.__vector(o) + j * 1, (byte)vector_of_enums); return true; } else { return false; } }
|
||||
|
||||
public static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(48); }
|
||||
public static void AddPos(FlatBufferBuilder builder, Offset<Vec3> posOffset) { builder.AddStruct(0, posOffset.Value, 0); }
|
||||
@@ -197,7 +197,7 @@ public struct Monster : IFlatbufferObject
|
||||
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 VectorOffset CreateInventoryVectorBlock(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); 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 AddColor(FlatBufferBuilder builder, Color color) { builder.AddByte(6, (byte)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); }
|
||||
@@ -281,7 +281,7 @@ public struct Monster : IFlatbufferObject
|
||||
public static void AddAnyAmbiguousType(FlatBufferBuilder builder, AnyAmbiguousAliases anyAmbiguousType) { builder.AddByte(45, (byte)anyAmbiguousType, 0); }
|
||||
public static void AddAnyAmbiguous(FlatBufferBuilder builder, int anyAmbiguousOffset) { builder.AddOffset(46, anyAmbiguousOffset, 0); }
|
||||
public static void AddVectorOfEnums(FlatBufferBuilder builder, VectorOffset vectorOfEnumsOffset) { builder.AddOffset(47, vectorOfEnumsOffset.Value, 0); }
|
||||
public static VectorOffset CreateVectorOfEnumsVector(FlatBufferBuilder builder, Color[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddSbyte((sbyte)data[i]); return builder.EndVector(); }
|
||||
public static VectorOffset CreateVectorOfEnumsVector(FlatBufferBuilder builder, Color[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte((byte)data[i]); return builder.EndVector(); }
|
||||
public static VectorOffset CreateVectorOfEnumsVectorBlock(FlatBufferBuilder builder, Color[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
|
||||
public static void StartVectorOfEnumsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
|
||||
public static Offset<Monster> EndMonster(FlatBufferBuilder builder) {
|
||||
|
||||
@@ -111,13 +111,13 @@ func (rcv *Monster) MutateInventory(j int, n byte) bool {
|
||||
func (rcv *Monster) Color() Color {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(16))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt8(o + rcv._tab.Pos)
|
||||
return rcv._tab.GetByte(o + rcv._tab.Pos)
|
||||
}
|
||||
return 8
|
||||
}
|
||||
|
||||
func (rcv *Monster) MutateColor(n Color) bool {
|
||||
return rcv._tab.MutateInt8Slot(16, n)
|
||||
return rcv._tab.MutateByteSlot(16, n)
|
||||
}
|
||||
|
||||
func (rcv *Monster) TestType() byte {
|
||||
@@ -785,7 +785,7 @@ func (rcv *Monster) VectorOfEnums(j int) Color {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(98))
|
||||
if o != 0 {
|
||||
a := rcv._tab.Vector(o)
|
||||
return rcv._tab.GetInt8(a + flatbuffers.UOffsetT(j*1))
|
||||
return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -798,11 +798,19 @@ func (rcv *Monster) VectorOfEnumsLength() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (rcv *Monster) VectorOfEnumsBytes() []byte {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(98))
|
||||
if o != 0 {
|
||||
return rcv._tab.ByteVector(o + rcv._tab.Pos)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *Monster) MutateVectorOfEnums(j int, n Color) bool {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(98))
|
||||
if o != 0 {
|
||||
a := rcv._tab.Vector(o)
|
||||
return rcv._tab.MutateInt8(a+flatbuffers.UOffsetT(j*1), n)
|
||||
return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n)
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -828,8 +836,8 @@ func MonsterAddInventory(builder *flatbuffers.Builder, inventory flatbuffers.UOf
|
||||
func MonsterStartInventoryVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
|
||||
return builder.StartVector(1, numElems, 1)
|
||||
}
|
||||
func MonsterAddColor(builder *flatbuffers.Builder, color int8) {
|
||||
builder.PrependInt8Slot(6, color, 8)
|
||||
func MonsterAddColor(builder *flatbuffers.Builder, color byte) {
|
||||
builder.PrependByteSlot(6, color, 8)
|
||||
}
|
||||
func MonsterAddTestType(builder *flatbuffers.Builder, testType byte) {
|
||||
builder.PrependByteSlot(7, testType, 0)
|
||||
|
||||
@@ -32,8 +32,8 @@ public final class Monster extends Table {
|
||||
public ByteBuffer inventoryAsByteBuffer() { return __vector_as_bytebuffer(14, 1); }
|
||||
public ByteBuffer inventoryInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 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 boolean mutateColor(byte color) { int o = __offset(16); if (o != 0) { bb.put(o + bb_pos, color); return true; } else { return false; } }
|
||||
public int color() { int o = __offset(16); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 8; }
|
||||
public boolean mutateColor(int color) { int o = __offset(16); if (o != 0) { bb.put(o + bb_pos, (byte)color); return true; } else { return false; } }
|
||||
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; }
|
||||
@@ -153,11 +153,11 @@ public final class Monster extends Table {
|
||||
public byte anyAmbiguousType() { int o = __offset(94); return o != 0 ? bb.get(o + bb_pos) : 0; }
|
||||
public boolean mutateAnyAmbiguousType(byte any_ambiguous_type) { int o = __offset(94); if (o != 0) { bb.put(o + bb_pos, any_ambiguous_type); return true; } else { return false; } }
|
||||
public Table anyAmbiguous(Table obj) { int o = __offset(96); return o != 0 ? __union(obj, o) : null; }
|
||||
public byte vectorOfEnums(int j) { int o = __offset(98); return o != 0 ? bb.get(__vector(o) + j * 1) : 0; }
|
||||
public int vectorOfEnums(int j) { int o = __offset(98); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
|
||||
public int vectorOfEnumsLength() { int o = __offset(98); return o != 0 ? __vector_len(o) : 0; }
|
||||
public ByteBuffer vectorOfEnumsAsByteBuffer() { return __vector_as_bytebuffer(98, 1); }
|
||||
public ByteBuffer vectorOfEnumsInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 98, 1); }
|
||||
public boolean mutateVectorOfEnums(int j, byte vector_of_enums) { int o = __offset(98); if (o != 0) { bb.put(__vector(o) + j * 1, vector_of_enums); return true; } else { return false; } }
|
||||
public boolean mutateVectorOfEnums(int j, int vector_of_enums) { int o = __offset(98); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)vector_of_enums); return true; } else { return false; } }
|
||||
|
||||
public static void startMonster(FlatBufferBuilder builder) { builder.startObject(48); }
|
||||
public static void addPos(FlatBufferBuilder builder, int posOffset) { builder.addStruct(0, posOffset, 0); }
|
||||
@@ -167,7 +167,7 @@ public final class Monster extends Table {
|
||||
public static void addInventory(FlatBufferBuilder builder, int inventoryOffset) { builder.addOffset(5, inventoryOffset, 0); }
|
||||
public static int 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, byte color) { builder.addByte(6, color, 8); }
|
||||
public static void addColor(FlatBufferBuilder builder, int color) { builder.addByte(6, (byte)color, (byte)8); }
|
||||
public static void addTestType(FlatBufferBuilder builder, byte testType) { builder.addByte(7, testType, 0); }
|
||||
public static void addTest(FlatBufferBuilder builder, int testOffset) { builder.addOffset(8, testOffset, 0); }
|
||||
public static void addTest4(FlatBufferBuilder builder, int test4Offset) { builder.addOffset(9, test4Offset, 0); }
|
||||
|
||||
@@ -69,7 +69,7 @@ end
|
||||
function Monster_mt:Color()
|
||||
local o = self.view:Offset(16)
|
||||
if o ~= 0 then
|
||||
return self.view:Get(flatbuffers.N.Int8, o + self.view.pos)
|
||||
return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
|
||||
end
|
||||
return 8
|
||||
end
|
||||
@@ -511,7 +511,7 @@ function Monster_mt:VectorOfEnums(j)
|
||||
local o = self.view:Offset(98)
|
||||
if o ~= 0 then
|
||||
local a = self.view:Vector(o)
|
||||
return self.view:Get(flatbuffers.N.Int8, a + ((j-1) * 1))
|
||||
return self.view:Get(flatbuffers.N.Uint8, a + ((j-1) * 1))
|
||||
end
|
||||
return 0
|
||||
end
|
||||
@@ -529,7 +529,7 @@ function Monster.AddHp(builder, hp) builder:PrependInt16Slot(2, hp, 100) end
|
||||
function Monster.AddName(builder, name) builder:PrependUOffsetTRelativeSlot(3, name, 0) end
|
||||
function Monster.AddInventory(builder, inventory) builder:PrependUOffsetTRelativeSlot(5, inventory, 0) end
|
||||
function Monster.StartInventoryVector(builder, numElems) return builder:StartVector(1, numElems, 1) end
|
||||
function Monster.AddColor(builder, color) builder:PrependInt8Slot(6, color, 8) end
|
||||
function Monster.AddColor(builder, color) builder:PrependUint8Slot(6, color, 8) end
|
||||
function Monster.AddTestType(builder, testType) builder:PrependUint8Slot(7, testType, 0) end
|
||||
function Monster.AddTest(builder, test) builder:PrependUOffsetTRelativeSlot(8, test, 0) end
|
||||
function Monster.AddTest4(builder, test4) builder:PrependUOffsetTRelativeSlot(9, test4, 0) end
|
||||
|
||||
@@ -107,12 +107,12 @@ class Monster extends Table
|
||||
}
|
||||
|
||||
/**
|
||||
* @return sbyte
|
||||
* @return byte
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
$o = $this->__offset(16);
|
||||
return $o != 0 ? $this->bb->getSbyte($o + $this->bb_pos) : \MyGame\Example\Color::Blue;
|
||||
return $o != 0 ? $this->bb->getByte($o + $this->bb_pos) : \MyGame\Example\Color::Blue;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -649,12 +649,12 @@ class Monster extends Table
|
||||
|
||||
/**
|
||||
* @param int offset
|
||||
* @return sbyte
|
||||
* @return byte
|
||||
*/
|
||||
public function getVectorOfEnums($j)
|
||||
{
|
||||
$o = $this->__offset(98);
|
||||
return $o != 0 ? $this->bb->getSbyte($this->__vector($o) + $j * 1) : 0;
|
||||
return $o != 0 ? $this->bb->getByte($this->__vector($o) + $j * 1) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -666,6 +666,14 @@ class Monster extends Table
|
||||
return $o != 0 ? $this->__vector_len($o) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVectorOfEnumsBytes()
|
||||
{
|
||||
return $this->__vector_as_bytes(98);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return void
|
||||
@@ -810,12 +818,12 @@ class Monster extends Table
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param sbyte
|
||||
* @param byte
|
||||
* @return void
|
||||
*/
|
||||
public static function addColor(FlatBufferBuilder $builder, $color)
|
||||
{
|
||||
$builder->addSbyteX(6, $color, 8);
|
||||
$builder->addByteX(6, $color, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1606,7 +1614,7 @@ class Monster extends Table
|
||||
{
|
||||
$builder->startVector(1, count($data), 1);
|
||||
for ($i = count($data) - 1; $i >= 0; $i--) {
|
||||
$builder->putSbyte($data[$i]);
|
||||
$builder->putByte($data[$i]);
|
||||
}
|
||||
return $builder->endVector();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class Monster(object):
|
||||
def Color(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 8
|
||||
|
||||
# Monster
|
||||
@@ -599,14 +599,14 @@ class Monster(object):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(98))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Int8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Monster
|
||||
def VectorOfEnumsAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(98))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int8Flags, o)
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Monster
|
||||
@@ -623,7 +623,7 @@ def MonsterAddHp(builder, hp): builder.PrependInt16Slot(2, hp, 100)
|
||||
def MonsterAddName(builder, name): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
|
||||
def MonsterAddInventory(builder, inventory): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(inventory), 0)
|
||||
def MonsterStartInventoryVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def MonsterAddColor(builder, color): builder.PrependInt8Slot(6, color, 8)
|
||||
def MonsterAddColor(builder, color): builder.PrependUint8Slot(6, color, 8)
|
||||
def MonsterAddTestType(builder, testType): builder.PrependUint8Slot(7, testType, 0)
|
||||
def MonsterAddTest(builder, test): builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(test), 0)
|
||||
def MonsterAddTest4(builder, test4): builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(test4), 0)
|
||||
|
||||
@@ -17,8 +17,8 @@ internal partial struct TestSimpleTableWithEnum : IFlatbufferObject
|
||||
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
|
||||
public TestSimpleTableWithEnum __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public Color Color { get { int o = __p.__offset(4); return o != 0 ? (Color)__p.bb.GetSbyte(o + __p.bb_pos) : Color.Green; } }
|
||||
public bool MutateColor(Color color) { int o = __p.__offset(4); if (o != 0) { __p.bb.PutSbyte(o + __p.bb_pos, (sbyte)color); return true; } else { return false; } }
|
||||
public Color Color { get { int o = __p.__offset(4); return o != 0 ? (Color)__p.bb.Get(o + __p.bb_pos) : Color.Green; } }
|
||||
public bool MutateColor(Color color) { int o = __p.__offset(4); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)color); return true; } else { return false; } }
|
||||
|
||||
public static Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(FlatBufferBuilder builder,
|
||||
Color color = Color.Green) {
|
||||
@@ -28,7 +28,7 @@ internal partial struct TestSimpleTableWithEnum : IFlatbufferObject
|
||||
}
|
||||
|
||||
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.AddByte(0, (byte)color, 2); }
|
||||
public static Offset<TestSimpleTableWithEnum> EndTestSimpleTableWithEnum(FlatBufferBuilder builder) {
|
||||
int o = builder.EndObject();
|
||||
return new Offset<TestSimpleTableWithEnum>(o);
|
||||
|
||||
@@ -29,20 +29,20 @@ func (rcv *TestSimpleTableWithEnum) Table() flatbuffers.Table {
|
||||
func (rcv *TestSimpleTableWithEnum) Color() Color {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt8(o + rcv._tab.Pos)
|
||||
return rcv._tab.GetByte(o + rcv._tab.Pos)
|
||||
}
|
||||
return 2
|
||||
}
|
||||
|
||||
func (rcv *TestSimpleTableWithEnum) MutateColor(n Color) bool {
|
||||
return rcv._tab.MutateInt8Slot(4, n)
|
||||
return rcv._tab.MutateByteSlot(4, n)
|
||||
}
|
||||
|
||||
func TestSimpleTableWithEnumStart(builder *flatbuffers.Builder) {
|
||||
builder.StartObject(1)
|
||||
}
|
||||
func TestSimpleTableWithEnumAddColor(builder *flatbuffers.Builder, color int8) {
|
||||
builder.PrependInt8Slot(0, color, 2)
|
||||
func TestSimpleTableWithEnumAddColor(builder *flatbuffers.Builder, color byte) {
|
||||
builder.PrependByteSlot(0, color, 2)
|
||||
}
|
||||
func TestSimpleTableWithEnumEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
return builder.EndObject()
|
||||
|
||||
@@ -14,18 +14,18 @@ final class TestSimpleTableWithEnum extends Table {
|
||||
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
|
||||
public TestSimpleTableWithEnum __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public byte color() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 2; }
|
||||
public boolean mutateColor(byte color) { int o = __offset(4); if (o != 0) { bb.put(o + bb_pos, color); return true; } else { return false; } }
|
||||
public int color() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 2; }
|
||||
public boolean mutateColor(int color) { int o = __offset(4); if (o != 0) { bb.put(o + bb_pos, (byte)color); return true; } else { return false; } }
|
||||
|
||||
public static int createTestSimpleTableWithEnum(FlatBufferBuilder builder,
|
||||
byte color) {
|
||||
int color) {
|
||||
builder.startObject(1);
|
||||
TestSimpleTableWithEnum.addColor(builder, color);
|
||||
return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
|
||||
}
|
||||
|
||||
public static void startTestSimpleTableWithEnum(FlatBufferBuilder builder) { builder.startObject(1); }
|
||||
public static void addColor(FlatBufferBuilder builder, byte color) { builder.addByte(0, color, 2); }
|
||||
public static void addColor(FlatBufferBuilder builder, int color) { builder.addByte(0, (byte)color, (byte)2); }
|
||||
public static int endTestSimpleTableWithEnum(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
return o;
|
||||
|
||||
@@ -24,12 +24,12 @@ end
|
||||
function TestSimpleTableWithEnum_mt:Color()
|
||||
local o = self.view:Offset(4)
|
||||
if o ~= 0 then
|
||||
return self.view:Get(flatbuffers.N.Int8, o + self.view.pos)
|
||||
return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
|
||||
end
|
||||
return 2
|
||||
end
|
||||
function TestSimpleTableWithEnum.Start(builder) builder:StartObject(1) end
|
||||
function TestSimpleTableWithEnum.AddColor(builder, color) builder:PrependInt8Slot(0, color, 2) end
|
||||
function TestSimpleTableWithEnum.AddColor(builder, color) builder:PrependUint8Slot(0, color, 2) end
|
||||
function TestSimpleTableWithEnum.End(builder) return builder:EndObject() end
|
||||
|
||||
return TestSimpleTableWithEnum -- return the module
|
||||
@@ -48,12 +48,12 @@ class TestSimpleTableWithEnum extends Table
|
||||
}
|
||||
|
||||
/**
|
||||
* @return sbyte
|
||||
* @return byte
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
$o = $this->__offset(4);
|
||||
return $o != 0 ? $this->bb->getSbyte($o + $this->bb_pos) : \MyGame\Example\Color::Green;
|
||||
return $o != 0 ? $this->bb->getByte($o + $this->bb_pos) : \MyGame\Example\Color::Green;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,12 +79,12 @@ class TestSimpleTableWithEnum extends Table
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param sbyte
|
||||
* @param byte
|
||||
* @return void
|
||||
*/
|
||||
public static function addColor(FlatBufferBuilder $builder, $color)
|
||||
{
|
||||
$builder->addSbyteX(0, $color, 2);
|
||||
$builder->addByteX(0, $color, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,9 +22,9 @@ class TestSimpleTableWithEnum(object):
|
||||
def Color(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 2
|
||||
|
||||
def TestSimpleTableWithEnumStart(builder): builder.StartObject(1)
|
||||
def TestSimpleTableWithEnumAddColor(builder, color): builder.PrependInt8Slot(0, color, 2)
|
||||
def TestSimpleTableWithEnumAddColor(builder, color): builder.PrependUint8Slot(0, color, 2)
|
||||
def TestSimpleTableWithEnumEnd(builder): return builder.EndObject()
|
||||
|
||||
@@ -23,8 +23,8 @@ public struct Vec3 : IFlatbufferObject
|
||||
public void MutateZ(float z) { __p.bb.PutFloat(__p.bb_pos + 8, z); }
|
||||
public double Test1 { get { return __p.bb.GetDouble(__p.bb_pos + 16); } }
|
||||
public void MutateTest1(double test1) { __p.bb.PutDouble(__p.bb_pos + 16, test1); }
|
||||
public Color Test2 { get { return (Color)__p.bb.GetSbyte(__p.bb_pos + 24); } }
|
||||
public void MutateTest2(Color test2) { __p.bb.PutSbyte(__p.bb_pos + 24, (sbyte)test2); }
|
||||
public Color Test2 { get { return (Color)__p.bb.Get(__p.bb_pos + 24); } }
|
||||
public void MutateTest2(Color test2) { __p.bb.Put(__p.bb_pos + 24, (byte)test2); }
|
||||
public Test Test3 { get { return (new Test()).__assign(__p.bb_pos + 26, __p.bb); } }
|
||||
|
||||
public static Offset<Vec3> CreateVec3(FlatBufferBuilder builder, float X, float Y, float Z, double Test1, Color Test2, short test3_A, sbyte test3_B) {
|
||||
@@ -35,7 +35,7 @@ public struct Vec3 : IFlatbufferObject
|
||||
builder.PutSbyte(test3_B);
|
||||
builder.PutShort(test3_A);
|
||||
builder.Pad(1);
|
||||
builder.PutSbyte((sbyte)Test2);
|
||||
builder.PutByte((byte)Test2);
|
||||
builder.PutDouble(Test1);
|
||||
builder.Pad(4);
|
||||
builder.PutFloat(Z);
|
||||
|
||||
@@ -48,10 +48,10 @@ func (rcv *Vec3) MutateTest1(n float64) bool {
|
||||
}
|
||||
|
||||
func (rcv *Vec3) Test2() Color {
|
||||
return rcv._tab.GetInt8(rcv._tab.Pos + flatbuffers.UOffsetT(24))
|
||||
return rcv._tab.GetByte(rcv._tab.Pos + flatbuffers.UOffsetT(24))
|
||||
}
|
||||
func (rcv *Vec3) MutateTest2(n Color) bool {
|
||||
return rcv._tab.MutateInt8(rcv._tab.Pos+flatbuffers.UOffsetT(24), n)
|
||||
return rcv._tab.MutateByte(rcv._tab.Pos+flatbuffers.UOffsetT(24), n)
|
||||
}
|
||||
|
||||
func (rcv *Vec3) Test3(obj *Test) *Test {
|
||||
@@ -62,7 +62,7 @@ func (rcv *Vec3) Test3(obj *Test) *Test {
|
||||
return obj
|
||||
}
|
||||
|
||||
func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, test1 float64, test2 int8, test3_a int16, test3_b int8) flatbuffers.UOffsetT {
|
||||
func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, test1 float64, test2 byte, test3_a int16, test3_b int8) flatbuffers.UOffsetT {
|
||||
builder.Prep(8, 32)
|
||||
builder.Pad(2)
|
||||
builder.Prep(2, 4)
|
||||
@@ -70,7 +70,7 @@ func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, t
|
||||
builder.PrependInt8(test3_b)
|
||||
builder.PrependInt16(test3_a)
|
||||
builder.Pad(1)
|
||||
builder.PrependInt8(test2)
|
||||
builder.PrependByte(test2)
|
||||
builder.PrependFloat64(test1)
|
||||
builder.Pad(4)
|
||||
builder.PrependFloat32(z)
|
||||
|
||||
@@ -20,12 +20,12 @@ public final class Vec3 extends Struct {
|
||||
public void mutateZ(float z) { bb.putFloat(bb_pos + 8, z); }
|
||||
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 void mutateTest2(byte test2) { bb.put(bb_pos + 24, test2); }
|
||||
public int test2() { return bb.get(bb_pos + 24) & 0xFF; }
|
||||
public void mutateTest2(int test2) { bb.put(bb_pos + 24, (byte)test2); }
|
||||
public Test test3() { return test3(new Test()); }
|
||||
public Test test3(Test obj) { return obj.__assign(bb_pos + 26, bb); }
|
||||
|
||||
public static int createVec3(FlatBufferBuilder builder, float x, float y, float z, double test1, byte test2, short test3_a, byte test3_b) {
|
||||
public static int createVec3(FlatBufferBuilder builder, float x, float y, float z, double test1, int test2, short test3_a, byte test3_b) {
|
||||
builder.prep(8, 32);
|
||||
builder.pad(2);
|
||||
builder.prep(2, 4);
|
||||
@@ -33,7 +33,7 @@ public final class Vec3 extends Struct {
|
||||
builder.putByte(test3_b);
|
||||
builder.putShort(test3_a);
|
||||
builder.pad(1);
|
||||
builder.putByte(test2);
|
||||
builder.putByte((byte)test2);
|
||||
builder.putDouble(test1);
|
||||
builder.pad(4);
|
||||
builder.putFloat(z);
|
||||
|
||||
@@ -28,7 +28,7 @@ function Vec3_mt:Test1()
|
||||
return self.view:Get(flatbuffers.N.Float64, self.view.pos + 16)
|
||||
end
|
||||
function Vec3_mt:Test2()
|
||||
return self.view:Get(flatbuffers.N.Int8, self.view.pos + 24)
|
||||
return self.view:Get(flatbuffers.N.Uint8, self.view.pos + 24)
|
||||
end
|
||||
function Vec3_mt:Test3(obj)
|
||||
obj:Init(self.view.bytes, self.view.pos + 26)
|
||||
@@ -42,7 +42,7 @@ function Vec3.CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b)
|
||||
builder:PrependInt8(test3_b)
|
||||
builder:PrependInt16(test3_a)
|
||||
builder:Pad(1)
|
||||
builder:PrependInt8(test2)
|
||||
builder:PrependUint8(test2)
|
||||
builder:PrependFloat64(test1)
|
||||
builder:Pad(4)
|
||||
builder:PrependFloat32(z)
|
||||
|
||||
@@ -55,11 +55,11 @@ class Vec3 extends Struct
|
||||
}
|
||||
|
||||
/**
|
||||
* @return sbyte
|
||||
* @return byte
|
||||
*/
|
||||
public function GetTest2()
|
||||
{
|
||||
return $this->bb->getSbyte($this->bb_pos + 24);
|
||||
return $this->bb->getByte($this->bb_pos + 24);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ class Vec3 extends Struct
|
||||
$builder->putSbyte($test3_b);
|
||||
$builder->putShort($test3_a);
|
||||
$builder->pad(1);
|
||||
$builder->putSbyte($test2);
|
||||
$builder->putByte($test2);
|
||||
$builder->putDouble($test1);
|
||||
$builder->pad(4);
|
||||
$builder->putFloat($z);
|
||||
|
||||
@@ -20,7 +20,7 @@ class Vec3(object):
|
||||
# Vec3
|
||||
def Test1(self): return self._tab.Get(flatbuffers.number_types.Float64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(16))
|
||||
# Vec3
|
||||
def Test2(self): return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(24))
|
||||
def Test2(self): return self._tab.Get(flatbuffers.number_types.Uint8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(24))
|
||||
# Vec3
|
||||
def Test3(self, obj):
|
||||
obj.Init(self._tab.Bytes, self._tab.Pos + 26)
|
||||
@@ -35,7 +35,7 @@ def CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b):
|
||||
builder.PrependInt8(test3_b)
|
||||
builder.PrependInt16(test3_a)
|
||||
builder.Pad(1)
|
||||
builder.PrependInt8(test2)
|
||||
builder.PrependUint8(test2)
|
||||
builder.PrependFloat64(test1)
|
||||
builder.Pad(4)
|
||||
builder.PrependFloat32(z)
|
||||
|
||||
Reference in New Issue
Block a user