mirror of
https://github.com/google/flatbuffers.git
synced 2025-04-10 00:03:27 +08: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:
parent
b701c7d56e
commit
f9ebfcb9c4
@ -70,7 +70,7 @@ inline const BaseType (&EnumValuesBaseType())[17] {
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesBaseType() {
|
||||
static const char * const names[] = {
|
||||
static const char * const names[18] = {
|
||||
"None",
|
||||
"UType",
|
||||
"Bool",
|
||||
|
@ -48,7 +48,7 @@ inline const Color (&EnumValuesColor())[3] {
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesColor() {
|
||||
static const char * const names[] = {
|
||||
static const char * const names[4] = {
|
||||
"Red",
|
||||
"Green",
|
||||
"Blue",
|
||||
@ -79,7 +79,7 @@ inline const Equipment (&EnumValuesEquipment())[2] {
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesEquipment() {
|
||||
static const char * const names[] = {
|
||||
static const char * const names[3] = {
|
||||
"NONE",
|
||||
"Weapon",
|
||||
nullptr
|
||||
|
@ -1019,7 +1019,8 @@ class CppGenerator : public BaseGenerator {
|
||||
static const uint64_t kMaxSparseness = 5;
|
||||
if (range / static_cast<uint64_t>(enum_def.size()) < kMaxSparseness) {
|
||||
code_ += "inline const char * const *EnumNames{{ENUM_NAME}}() {";
|
||||
code_ += " static const char * const names[] = {";
|
||||
code_ += " static const char * const names[" +
|
||||
NumToString(range + 1 + 1) + "] = {";
|
||||
|
||||
auto val = enum_def.Vals().front();
|
||||
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
|
||||
|
@ -101,7 +101,8 @@ class JavaTest {
|
||||
TestEq(pos.y(), 2.0f);
|
||||
TestEq(pos.z(), 3.0f);
|
||||
TestEq(pos.test1(), 3.0);
|
||||
TestEq(pos.test2(), Color.Green);
|
||||
// issue: int != byte
|
||||
TestEq(pos.test2(), (int) Color.Green);
|
||||
Test t = pos.test3();
|
||||
TestEq(t.a(), (short)5);
|
||||
TestEq(t.b(), (byte)6);
|
||||
|
@ -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)
|
||||
|
@ -15,9 +15,9 @@
|
||||
set buildtype=Release
|
||||
if "%1"=="-b" set buildtype=%2
|
||||
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --go --binary --python --lobster --lua --js --rust --ts --php --grpc --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --cpp-ptr-type flatbuffers::unique_ptr --no-fb-import -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --go --binary --python --lobster --lua --js --rust --ts --php --gen-mutable --reflect-names --no-fb-import --cpp-ptr-type flatbuffers::unique_ptr -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --java --js --ts --php --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr -o union_vector ./union_vector/union_vector.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --dart --go --binary --lobster --lua --python --js --ts --php --rust --grpc --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --cpp-ptr-type flatbuffers::unique_ptr --no-fb-import -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --dart --go --binary --lobster --lua --python --js --ts --php --rust --gen-mutable --reflect-names --no-fb-import --cpp-ptr-type flatbuffers::unique_ptr -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --cpp --java --csharp --js --ts --php --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr -o union_vector ./union_vector/union_vector.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs || goto FAIL
|
||||
..\%buildtype%\flatc.exe --jsonschema --schema -I include_test monster_test.fbs || goto FAIL
|
||||
|
||||
|
@ -199,8 +199,8 @@ func CheckReadBuffer(buf []byte, offset flatbuffers.UOffsetT, fail func(string,
|
||||
fail(FailString("Pos.Test1", float64(3.0), got))
|
||||
}
|
||||
|
||||
if got := vec.Test2(); int8(2) != got {
|
||||
fail(FailString("Pos.Test2", int8(2), got))
|
||||
if got := vec.Test2(); uint8(2) != got {
|
||||
fail(FailString("Pos.Test2", uint8(2), got))
|
||||
}
|
||||
|
||||
// initialize a Test from Test3(...)
|
||||
@ -331,7 +331,7 @@ func CheckMutateBuffer(org []byte, offset flatbuffers.UOffsetT, fail func(string
|
||||
testcase{"Pos.Y'", func() bool { return monster.Pos(nil).Y() == float32(2.0) }},
|
||||
testcase{"Pos.Z'", func() bool { return monster.Pos(nil).Z() == float32(3.0) }},
|
||||
testcase{"Pos.Test1'", func() bool { return monster.Pos(nil).Test1() == float64(3.0) }},
|
||||
testcase{"Pos.Test2'", func() bool { return monster.Pos(nil).Test2() == int8(2) }},
|
||||
testcase{"Pos.Test2'", func() bool { return monster.Pos(nil).Test2() == uint8(2) }},
|
||||
testcase{"Pos.Test3.A", func() bool { return monster.Pos(nil).Test3(nil).A() == int16(5) }},
|
||||
testcase{"Pos.Test3.B", func() bool { return monster.Pos(nil).Test3(nil).B() == int8(6) }},
|
||||
testcase{"Inventory[2]", func() bool { return monster.Inventory(2) == byte(2) }},
|
||||
@ -359,7 +359,7 @@ func CheckMutateBuffer(org []byte, offset flatbuffers.UOffsetT, fail func(string
|
||||
testcase{"Pos.Y'", func() bool { return monster.Pos(nil).Y() == float32(20.0) }},
|
||||
testcase{"Pos.Z'", func() bool { return monster.Pos(nil).Z() == float32(30.0) }},
|
||||
testcase{"Pos.Test1'", func() bool { return monster.Pos(nil).Test1() == float64(30.0) }},
|
||||
testcase{"Pos.Test2'", func() bool { return monster.Pos(nil).Test2() == int8(20) }},
|
||||
testcase{"Pos.Test2'", func() bool { return monster.Pos(nil).Test2() == uint8(20) }},
|
||||
testcase{"Pos.Test3.A", func() bool { return monster.Pos(nil).Test3(nil).A() == int16(50) }},
|
||||
testcase{"Pos.Test3.B", func() bool { return monster.Pos(nil).Test3(nil).B() == int8(60) }},
|
||||
testcase{"Inventory[2]", func() bool { return monster.Inventory(2) == byte(200) }},
|
||||
|
Binary file not shown.
@ -14,7 +14,7 @@ namespace MyGame.Example;
|
||||
|
||||
attribute "priority";
|
||||
|
||||
enum Color:byte (bit_flags) { Red = 0, Green, Blue = 3, }
|
||||
enum Color:ubyte (bit_flags) { Red = 0, Green, Blue = 3, }
|
||||
|
||||
union Any { Monster, TestSimpleTableWithEnum, MyGame.Example2.Monster }
|
||||
|
||||
|
@ -117,7 +117,7 @@ inline const Color (&EnumValuesColor())[3] {
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesColor() {
|
||||
static const char * const names[] = {
|
||||
static const char * const names[9] = {
|
||||
"Red",
|
||||
"Green",
|
||||
"",
|
||||
@ -157,7 +157,7 @@ inline const Any (&EnumValuesAny())[4] {
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesAny() {
|
||||
static const char * const names[] = {
|
||||
static const char * const names[5] = {
|
||||
"NONE",
|
||||
"Monster",
|
||||
"TestSimpleTableWithEnum",
|
||||
@ -299,7 +299,7 @@ inline const AnyUniqueAliases (&EnumValuesAnyUniqueAliases())[4] {
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesAnyUniqueAliases() {
|
||||
static const char * const names[] = {
|
||||
static const char * const names[5] = {
|
||||
"NONE",
|
||||
"M",
|
||||
"T",
|
||||
@ -441,7 +441,7 @@ inline const AnyAmbiguousAliases (&EnumValuesAnyAmbiguousAliases())[4] {
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesAnyAmbiguousAliases() {
|
||||
static const char * const names[] = {
|
||||
static const char * const names[5] = {
|
||||
"NONE",
|
||||
"M1",
|
||||
"M2",
|
||||
@ -587,7 +587,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
float z_;
|
||||
int32_t padding0__;
|
||||
double test1_;
|
||||
int8_t test2_;
|
||||
uint8_t test2_;
|
||||
int8_t padding1__;
|
||||
Test test3_;
|
||||
int16_t padding2__;
|
||||
@ -605,7 +605,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
z_(flatbuffers::EndianScalar(_z)),
|
||||
padding0__(0),
|
||||
test1_(flatbuffers::EndianScalar(_test1)),
|
||||
test2_(flatbuffers::EndianScalar(static_cast<int8_t>(_test2))),
|
||||
test2_(flatbuffers::EndianScalar(static_cast<uint8_t>(_test2))),
|
||||
padding1__(0),
|
||||
test3_(_test3),
|
||||
padding2__(0) {
|
||||
@ -641,7 +641,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
return static_cast<Color>(flatbuffers::EndianScalar(test2_));
|
||||
}
|
||||
void mutate_test2(Color _test2) {
|
||||
flatbuffers::WriteScalar(&test2_, static_cast<int8_t>(_test2));
|
||||
flatbuffers::WriteScalar(&test2_, static_cast<uint8_t>(_test2));
|
||||
}
|
||||
const Test &test3() const {
|
||||
return test3_;
|
||||
@ -854,14 +854,14 @@ struct TestSimpleTableWithEnum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Ta
|
||||
VT_COLOR = 4
|
||||
};
|
||||
Color color() const {
|
||||
return static_cast<Color>(GetField<int8_t>(VT_COLOR, 2));
|
||||
return static_cast<Color>(GetField<uint8_t>(VT_COLOR, 2));
|
||||
}
|
||||
bool mutate_color(Color _color) {
|
||||
return SetField<int8_t>(VT_COLOR, static_cast<int8_t>(_color), 2);
|
||||
return SetField<uint8_t>(VT_COLOR, static_cast<uint8_t>(_color), 2);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int8_t>(verifier, VT_COLOR) &&
|
||||
VerifyField<uint8_t>(verifier, VT_COLOR) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
TestSimpleTableWithEnumT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||
@ -873,7 +873,7 @@ struct TestSimpleTableWithEnumBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_color(Color color) {
|
||||
fbb_.AddElement<int8_t>(TestSimpleTableWithEnum::VT_COLOR, static_cast<int8_t>(color), 2);
|
||||
fbb_.AddElement<uint8_t>(TestSimpleTableWithEnum::VT_COLOR, static_cast<uint8_t>(color), 2);
|
||||
}
|
||||
explicit TestSimpleTableWithEnumBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
@ -1301,10 +1301,10 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
|
||||
}
|
||||
Color color() const {
|
||||
return static_cast<Color>(GetField<int8_t>(VT_COLOR, 8));
|
||||
return static_cast<Color>(GetField<uint8_t>(VT_COLOR, 8));
|
||||
}
|
||||
bool mutate_color(Color _color) {
|
||||
return SetField<int8_t>(VT_COLOR, static_cast<int8_t>(_color), 8);
|
||||
return SetField<uint8_t>(VT_COLOR, static_cast<uint8_t>(_color), 8);
|
||||
}
|
||||
Any test_type() const {
|
||||
return static_cast<Any>(GetField<uint8_t>(VT_TEST_TYPE, 0));
|
||||
@ -1583,11 +1583,11 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
void *mutable_any_ambiguous() {
|
||||
return GetPointer<void *>(VT_ANY_AMBIGUOUS);
|
||||
}
|
||||
const flatbuffers::Vector<int8_t> *vector_of_enums() const {
|
||||
return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_VECTOR_OF_ENUMS);
|
||||
const flatbuffers::Vector<uint8_t> *vector_of_enums() const {
|
||||
return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
|
||||
}
|
||||
flatbuffers::Vector<int8_t> *mutable_vector_of_enums() {
|
||||
return GetPointer<flatbuffers::Vector<int8_t> *>(VT_VECTOR_OF_ENUMS);
|
||||
flatbuffers::Vector<uint8_t> *mutable_vector_of_enums() {
|
||||
return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_VECTOR_OF_ENUMS);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@ -1598,7 +1598,7 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
verifier.VerifyString(name()) &&
|
||||
VerifyOffset(verifier, VT_INVENTORY) &&
|
||||
verifier.VerifyVector(inventory()) &&
|
||||
VerifyField<int8_t>(verifier, VT_COLOR) &&
|
||||
VerifyField<uint8_t>(verifier, VT_COLOR) &&
|
||||
VerifyField<uint8_t>(verifier, VT_TEST_TYPE) &&
|
||||
VerifyOffset(verifier, VT_TEST) &&
|
||||
VerifyAny(verifier, test(), test_type()) &&
|
||||
@ -1718,7 +1718,7 @@ struct MonsterBuilder {
|
||||
fbb_.AddOffset(Monster::VT_INVENTORY, inventory);
|
||||
}
|
||||
void add_color(Color color) {
|
||||
fbb_.AddElement<int8_t>(Monster::VT_COLOR, static_cast<int8_t>(color), 8);
|
||||
fbb_.AddElement<uint8_t>(Monster::VT_COLOR, static_cast<uint8_t>(color), 8);
|
||||
}
|
||||
void add_test_type(Any test_type) {
|
||||
fbb_.AddElement<uint8_t>(Monster::VT_TEST_TYPE, static_cast<uint8_t>(test_type), 0);
|
||||
@ -1840,7 +1840,7 @@ struct MonsterBuilder {
|
||||
void add_any_ambiguous(flatbuffers::Offset<void> any_ambiguous) {
|
||||
fbb_.AddOffset(Monster::VT_ANY_AMBIGUOUS, any_ambiguous);
|
||||
}
|
||||
void add_vector_of_enums(flatbuffers::Offset<flatbuffers::Vector<int8_t>> vector_of_enums) {
|
||||
void add_vector_of_enums(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> vector_of_enums) {
|
||||
fbb_.AddOffset(Monster::VT_VECTOR_OF_ENUMS, vector_of_enums);
|
||||
}
|
||||
explicit MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
||||
@ -1904,7 +1904,7 @@ inline flatbuffers::Offset<Monster> CreateMonster(
|
||||
flatbuffers::Offset<void> any_unique = 0,
|
||||
AnyAmbiguousAliases any_ambiguous_type = AnyAmbiguousAliases_NONE,
|
||||
flatbuffers::Offset<void> any_ambiguous = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<int8_t>> vector_of_enums = 0) {
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> vector_of_enums = 0) {
|
||||
MonsterBuilder builder_(_fbb);
|
||||
builder_.add_non_owning_reference(non_owning_reference);
|
||||
builder_.add_co_owning_reference(co_owning_reference);
|
||||
@ -2004,7 +2004,7 @@ inline flatbuffers::Offset<Monster> CreateMonsterDirect(
|
||||
flatbuffers::Offset<void> any_unique = 0,
|
||||
AnyAmbiguousAliases any_ambiguous_type = AnyAmbiguousAliases_NONE,
|
||||
flatbuffers::Offset<void> any_ambiguous = 0,
|
||||
const std::vector<int8_t> *vector_of_enums = nullptr) {
|
||||
const std::vector<uint8_t> *vector_of_enums = nullptr) {
|
||||
auto name__ = name ? _fbb.CreateString(name) : 0;
|
||||
auto inventory__ = inventory ? _fbb.CreateVector<uint8_t>(*inventory) : 0;
|
||||
auto test4__ = test4 ? _fbb.CreateVectorOfStructs<Test>(*test4) : 0;
|
||||
@ -2023,7 +2023,7 @@ inline flatbuffers::Offset<Monster> CreateMonsterDirect(
|
||||
auto vector_of_strong_referrables__ = vector_of_strong_referrables ? _fbb.CreateVector<flatbuffers::Offset<Referrable>>(*vector_of_strong_referrables) : 0;
|
||||
auto vector_of_co_owning_references__ = vector_of_co_owning_references ? _fbb.CreateVector<uint64_t>(*vector_of_co_owning_references) : 0;
|
||||
auto vector_of_non_owning_references__ = vector_of_non_owning_references ? _fbb.CreateVector<uint64_t>(*vector_of_non_owning_references) : 0;
|
||||
auto vector_of_enums__ = vector_of_enums ? _fbb.CreateVector<int8_t>(*vector_of_enums) : 0;
|
||||
auto vector_of_enums__ = vector_of_enums ? _fbb.CreateVector<uint8_t>(*vector_of_enums) : 0;
|
||||
return MyGame::Example::CreateMonster(
|
||||
_fbb,
|
||||
pos,
|
||||
@ -2612,7 +2612,7 @@ inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder
|
||||
auto _any_unique = _o->any_unique.Pack(_fbb);
|
||||
auto _any_ambiguous_type = _o->any_ambiguous.type;
|
||||
auto _any_ambiguous = _o->any_ambiguous.Pack(_fbb);
|
||||
auto _vector_of_enums = _o->vector_of_enums.size() ? _fbb.CreateVectorScalarCast<int8_t>(flatbuffers::data(_o->vector_of_enums), _o->vector_of_enums.size()) : 0;
|
||||
auto _vector_of_enums = _o->vector_of_enums.size() ? _fbb.CreateVectorScalarCast<uint8_t>(flatbuffers::data(_o->vector_of_enums), _o->vector_of_enums.size()) : 0;
|
||||
return MyGame::Example::CreateMonster(
|
||||
_fbb,
|
||||
_pos,
|
||||
@ -3058,9 +3058,9 @@ inline void AnyAmbiguousAliasesUnion::Reset() {
|
||||
|
||||
inline const flatbuffers::TypeTable *ColorTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ flatbuffers::ET_CHAR, 0, 0 }
|
||||
{ flatbuffers::ET_UCHAR, 0, 0 },
|
||||
{ flatbuffers::ET_UCHAR, 0, 0 },
|
||||
{ flatbuffers::ET_UCHAR, 0, 0 }
|
||||
};
|
||||
static const flatbuffers::TypeFunction type_refs[] = {
|
||||
ColorTypeTable
|
||||
@ -3187,7 +3187,7 @@ inline const flatbuffers::TypeTable *TestTypeTable() {
|
||||
|
||||
inline const flatbuffers::TypeTable *TestSimpleTableWithEnumTypeTable() {
|
||||
static const flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_CHAR, 0, 0 }
|
||||
{ flatbuffers::ET_UCHAR, 0, 0 }
|
||||
};
|
||||
static const flatbuffers::TypeFunction type_refs[] = {
|
||||
ColorTypeTable
|
||||
@ -3207,7 +3207,7 @@ inline const flatbuffers::TypeTable *Vec3TypeTable() {
|
||||
{ flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ flatbuffers::ET_FLOAT, 0, -1 },
|
||||
{ flatbuffers::ET_DOUBLE, 0, -1 },
|
||||
{ flatbuffers::ET_CHAR, 0, 0 },
|
||||
{ flatbuffers::ET_UCHAR, 0, 0 },
|
||||
{ flatbuffers::ET_SEQUENCE, 0, 1 }
|
||||
};
|
||||
static const flatbuffers::TypeFunction type_refs[] = {
|
||||
@ -3283,7 +3283,7 @@ inline const flatbuffers::TypeTable *MonsterTypeTable() {
|
||||
{ flatbuffers::ET_STRING, 0, -1 },
|
||||
{ flatbuffers::ET_BOOL, 0, -1 },
|
||||
{ flatbuffers::ET_UCHAR, 1, -1 },
|
||||
{ flatbuffers::ET_CHAR, 0, 1 },
|
||||
{ flatbuffers::ET_UCHAR, 0, 1 },
|
||||
{ flatbuffers::ET_UTYPE, 0, 2 },
|
||||
{ flatbuffers::ET_SEQUENCE, 0, 2 },
|
||||
{ flatbuffers::ET_SEQUENCE, 1, 3 },
|
||||
@ -3324,7 +3324,7 @@ inline const flatbuffers::TypeTable *MonsterTypeTable() {
|
||||
{ flatbuffers::ET_SEQUENCE, 0, 9 },
|
||||
{ flatbuffers::ET_UTYPE, 0, 10 },
|
||||
{ flatbuffers::ET_SEQUENCE, 0, 10 },
|
||||
{ flatbuffers::ET_CHAR, 1, 1 }
|
||||
{ flatbuffers::ET_UCHAR, 1, 1 }
|
||||
};
|
||||
static const flatbuffers::TypeFunction type_refs[] = {
|
||||
Vec3TypeTable,
|
||||
|
@ -346,7 +346,7 @@ MyGame.Example.TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum = functi
|
||||
*/
|
||||
MyGame.Example.TestSimpleTableWithEnum.prototype.color = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Green;
|
||||
return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.Color.Green;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -360,7 +360,7 @@ MyGame.Example.TestSimpleTableWithEnum.prototype.mutate_color = function(value)
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt8(this.bb_pos + offset, value);
|
||||
this.bb.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -517,7 +517,7 @@ MyGame.Example.Vec3.prototype.mutate_test1 = function(value) {
|
||||
* @returns {MyGame.Example.Color}
|
||||
*/
|
||||
MyGame.Example.Vec3.prototype.test2 = function() {
|
||||
return /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + 24));
|
||||
return /** @type {MyGame.Example.Color} */ (this.bb.readUint8(this.bb_pos + 24));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -531,7 +531,7 @@ MyGame.Example.Vec3.prototype.mutate_test2 = function(value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt8(this.bb_pos + offset, value);
|
||||
this.bb.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -1031,7 +1031,7 @@ MyGame.Example.Monster.prototype.inventoryArray = function() {
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.color = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 16);
|
||||
return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Blue;
|
||||
return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.Color.Blue;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1045,7 +1045,7 @@ MyGame.Example.Monster.prototype.mutate_color = function(value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt8(this.bb_pos + offset, value);
|
||||
this.bb.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -1838,7 +1838,7 @@ MyGame.Example.Monster.prototype.anyAmbiguous = function(obj) {
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.vectorOfEnums = function(index) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 98);
|
||||
return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index)) : /** @type {MyGame.Example.Color} */ (0);
|
||||
return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index)) : /** @type {MyGame.Example.Color} */ (0);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1850,11 +1850,11 @@ MyGame.Example.Monster.prototype.vectorOfEnumsLength = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Int8Array}
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.vectorOfEnumsArray = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 98);
|
||||
return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -99,7 +99,7 @@ def GetRootAsTestSimpleTableWithEnum(buf:string): TestSimpleTableWithEnum { buf,
|
||||
def TestSimpleTableWithEnumStart(b_:flatbuffers_builder):
|
||||
b_.StartObject(1)
|
||||
def TestSimpleTableWithEnumAddColor(b_:flatbuffers_builder, color:int):
|
||||
b_.PrependInt8Slot(0, color, 2)
|
||||
b_.PrependUint8Slot(0, color, 2)
|
||||
def TestSimpleTableWithEnumEnd(b_:flatbuffers_builder):
|
||||
b_.EndObject()
|
||||
|
||||
@ -125,7 +125,7 @@ def CreateVec3(b_:flatbuffers_builder, x:float, y:float, z:float, test1:float, t
|
||||
b_.PrependInt8(test3_b)
|
||||
b_.PrependInt16(test3_a)
|
||||
b_.Pad(1)
|
||||
b_.PrependInt8(test2)
|
||||
b_.PrependUint8(test2)
|
||||
b_.PrependFloat64(test1)
|
||||
b_.Pad(4)
|
||||
b_.PrependFloat32(z)
|
||||
@ -351,7 +351,7 @@ def MonsterCreateInventoryVector(b_:flatbuffers_builder, v_:[int]):
|
||||
reverse(v_) e_: b_.PrependUint8(e_)
|
||||
b_.EndVector(v_.length)
|
||||
def MonsterAddColor(b_:flatbuffers_builder, color:int):
|
||||
b_.PrependInt8Slot(6, color, 8)
|
||||
b_.PrependUint8Slot(6, color, 8)
|
||||
def MonsterAddTestType(b_:flatbuffers_builder, test_type:int):
|
||||
b_.PrependUint8Slot(7, test_type, 0)
|
||||
def MonsterAddTest(b_:flatbuffers_builder, test:int):
|
||||
@ -522,7 +522,7 @@ def MonsterStartVectorOfEnumsVector(b_:flatbuffers_builder, n_:int):
|
||||
b_.StartVector(1, n_, 1)
|
||||
def MonsterCreateVectorOfEnumsVector(b_:flatbuffers_builder, v_:[int]):
|
||||
b_.StartVector(1, v_.length, 1)
|
||||
reverse(v_) e_: b_.PrependInt8(e_)
|
||||
reverse(v_) e_: b_.PrependUint8(e_)
|
||||
b_.EndVector(v_.length)
|
||||
def MonsterEnd(b_:flatbuffers_builder):
|
||||
b_.EndObject()
|
||||
|
@ -164,7 +164,7 @@ pub mod example {
|
||||
use self::flatbuffers::EndianScalar;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[repr(i8)]
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub enum Color {
|
||||
Red = 1,
|
||||
@ -173,8 +173,8 @@ pub enum Color {
|
||||
|
||||
}
|
||||
|
||||
const ENUM_MIN_COLOR: i8 = 1;
|
||||
const ENUM_MAX_COLOR: i8 = 8;
|
||||
const ENUM_MIN_COLOR: u8 = 1;
|
||||
const ENUM_MAX_COLOR: u8 = 8;
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Color {
|
||||
type Inner = Self;
|
||||
@ -187,14 +187,14 @@ impl<'a> flatbuffers::Follow<'a> for Color {
|
||||
impl flatbuffers::EndianScalar for Color {
|
||||
#[inline]
|
||||
fn to_little_endian(self) -> Self {
|
||||
let n = i8::to_le(self as i8);
|
||||
let p = &n as *const i8 as *const Color;
|
||||
let n = u8::to_le(self as u8);
|
||||
let p = &n as *const u8 as *const Color;
|
||||
unsafe { *p }
|
||||
}
|
||||
#[inline]
|
||||
fn from_little_endian(self) -> Self {
|
||||
let n = i8::from_le(self as i8);
|
||||
let p = &n as *const i8 as *const Color;
|
||||
let n = u8::from_le(self as u8);
|
||||
let p = &n as *const u8 as *const Color;
|
||||
unsafe { *p }
|
||||
}
|
||||
}
|
||||
@ -227,7 +227,7 @@ const ENUM_NAMES_COLOR:[&'static str; 8] = [
|
||||
];
|
||||
|
||||
pub fn enum_name_color(e: Color) -> &'static str {
|
||||
let index = e as i8 - Color::Red as i8;
|
||||
let index = e as u8 - Color::Red as u8;
|
||||
ENUM_NAMES_COLOR[index as usize]
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimp
|
||||
*/
|
||||
color():MyGame.Example.Color {
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? /** */ (this.bb!.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Green;
|
||||
return offset ? /** */ (this.bb!.readUint8(this.bb_pos + offset)) : MyGame.Example.Color.Green;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -269,7 +269,7 @@ mutate_color(value:MyGame.Example.Color):boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeInt8(this.bb_pos + offset, value);
|
||||
this.bb!.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -415,7 +415,7 @@ mutate_test1(value:number):boolean {
|
||||
* @returns MyGame.Example.Color
|
||||
*/
|
||||
test2():MyGame.Example.Color {
|
||||
return /** */ (this.bb!.readInt8(this.bb_pos + 24));
|
||||
return /** */ (this.bb!.readUint8(this.bb_pos + 24));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -429,7 +429,7 @@ mutate_test2(value:MyGame.Example.Color):boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeInt8(this.bb_pos + offset, value);
|
||||
this.bb!.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -899,7 +899,7 @@ inventoryArray():Uint8Array|null {
|
||||
*/
|
||||
color():MyGame.Example.Color {
|
||||
var offset = this.bb!.__offset(this.bb_pos, 16);
|
||||
return offset ? /** */ (this.bb!.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Blue;
|
||||
return offset ? /** */ (this.bb!.readUint8(this.bb_pos + offset)) : MyGame.Example.Color.Blue;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -913,7 +913,7 @@ mutate_color(value:MyGame.Example.Color):boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb!.writeInt8(this.bb_pos + offset, value);
|
||||
this.bb!.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -1710,7 +1710,7 @@ anyAmbiguous<T extends flatbuffers.Table>(obj:T):T|null {
|
||||
*/
|
||||
vectorOfEnums(index: number):MyGame.Example.Color|null {
|
||||
var offset = this.bb!.__offset(this.bb_pos, 98);
|
||||
return offset ? /** */ (this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index)) : /** */ (0);
|
||||
return offset ? /** */ (this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index)) : /** */ (0);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1722,11 +1722,11 @@ vectorOfEnumsLength():number {
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns Int8Array
|
||||
* @returns Uint8Array
|
||||
*/
|
||||
vectorOfEnumsArray():Int8Array|null {
|
||||
vectorOfEnumsArray():Uint8Array|null {
|
||||
var offset = this.bb!.__offset(this.bb_pos, 98);
|
||||
return offset ? new Int8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -44,7 +44,7 @@ class _ColorReader extends fb.Reader<Color> {
|
||||
|
||||
@override
|
||||
Color read(fb.BufferContext bc, int offset) =>
|
||||
new Color.fromValue(const fb.Int8Reader().read(bc, offset));
|
||||
new Color.fromValue(const fb.Uint8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class AnyTypeId {
|
||||
@ -257,7 +257,7 @@ class TestSimpleTableWithEnum {
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
Color get color => new Color.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 4, 2));
|
||||
Color get color => new Color.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 2));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -285,7 +285,7 @@ class TestSimpleTableWithEnumBuilder {
|
||||
}
|
||||
|
||||
int addColor(Color color) {
|
||||
fbBuilder.addInt8(0, color?.value);
|
||||
fbBuilder.addUint8(0, color?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ class TestSimpleTableWithEnumObjectBuilder extends fb.ObjectBuilder {
|
||||
assert(fbBuilder != null);
|
||||
|
||||
fbBuilder.startTable();
|
||||
fbBuilder.addInt8(0, _color?.value);
|
||||
fbBuilder.addUint8(0, _color?.value);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@ -333,7 +333,7 @@ class Vec3 {
|
||||
double get y => const fb.Float32Reader().read(_bc, _bcOffset + 4);
|
||||
double get z => const fb.Float32Reader().read(_bc, _bcOffset + 8);
|
||||
double get test1 => const fb.Float64Reader().read(_bc, _bcOffset + 16);
|
||||
Color get test2 => new Color.fromValue(const fb.Int8Reader().read(_bc, _bcOffset + 24));
|
||||
Color get test2 => new Color.fromValue(const fb.Uint8Reader().read(_bc, _bcOffset + 24));
|
||||
Test get test3 => Test.reader.read(_bc, _bcOffset + 26);
|
||||
|
||||
@override
|
||||
@ -364,7 +364,7 @@ class Vec3Builder {
|
||||
fbBuilder.pad(2);
|
||||
test3();
|
||||
fbBuilder.pad(1);
|
||||
fbBuilder.putInt8(test2?.value);
|
||||
fbBuilder.putUint8(test2?.value);
|
||||
fbBuilder.putFloat64(test1);
|
||||
fbBuilder.pad(4);
|
||||
fbBuilder.putFloat32(z);
|
||||
@ -407,7 +407,7 @@ class Vec3ObjectBuilder extends fb.ObjectBuilder {
|
||||
fbBuilder.pad(2);
|
||||
_test3.finish(fbBuilder);
|
||||
fbBuilder.pad(1);
|
||||
fbBuilder.putInt8(_test2?.value);
|
||||
fbBuilder.putUint8(_test2?.value);
|
||||
fbBuilder.putFloat64(_test1);
|
||||
fbBuilder.pad(4);
|
||||
fbBuilder.putFloat32(_z);
|
||||
@ -688,7 +688,7 @@ class Monster {
|
||||
int get hp => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 8, 100);
|
||||
String get name => const fb.StringReader().vTableGet(_bc, _bcOffset, 10, null);
|
||||
List<int> get inventory => const fb.ListReader<int>(const fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 14, null);
|
||||
Color get color => new Color.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 16, 8));
|
||||
Color get color => new Color.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 16, 8));
|
||||
AnyTypeId get testType => new AnyTypeId.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0));
|
||||
dynamic get test {
|
||||
switch (testType?.value) {
|
||||
@ -800,7 +800,7 @@ class MonsterBuilder {
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addColor(Color color) {
|
||||
fbBuilder.addInt8(6, color?.value);
|
||||
fbBuilder.addUint8(6, color?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addTestType(AnyTypeId testType) {
|
||||
@ -1183,7 +1183,7 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
final int anyUniqueOffset = _anyUnique?.getOrCreateOffset(fbBuilder);
|
||||
final int anyAmbiguousOffset = _anyAmbiguous?.getOrCreateOffset(fbBuilder);
|
||||
final int vectorOfEnumsOffset = _vectorOfEnums?.isNotEmpty == true
|
||||
? fbBuilder.writeListInt8(_vectorOfEnums.map((f) => f.value))
|
||||
? fbBuilder.writeListUint8(_vectorOfEnums.map((f) => f.value))
|
||||
: null;
|
||||
|
||||
fbBuilder.startTable();
|
||||
@ -1198,7 +1198,7 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
if (inventoryOffset != null) {
|
||||
fbBuilder.addOffset(5, inventoryOffset);
|
||||
}
|
||||
fbBuilder.addInt8(6, _color?.value);
|
||||
fbBuilder.addUint8(6, _color?.value);
|
||||
fbBuilder.addUint8(7, _testType?.value);
|
||||
if (testOffset != null) {
|
||||
fbBuilder.addOffset(8, testOffset);
|
||||
|
@ -35,7 +35,7 @@ inline const EnumInNestedNS (&EnumValuesEnumInNestedNS())[3] {
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesEnumInNestedNS() {
|
||||
static const char * const names[] = {
|
||||
static const char * const names[4] = {
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
|
@ -172,7 +172,7 @@ flatbuffers::DetachedBuffer CreateFlatBufferTest(std::string &buffer) {
|
||||
// We use this special creation function because we have an array of
|
||||
// pre-C++11 (enum class) enums whose size likely is int, yet its declared
|
||||
// type in the schema is byte.
|
||||
auto vecofcolors = builder.CreateVectorScalarCast<int8_t, Color>(colors, 2);
|
||||
auto vecofcolors = builder.CreateVectorScalarCast<uint8_t, Color>(colors, 2);
|
||||
|
||||
// shortcut for creating monster with all fields set:
|
||||
auto mloc = CreateMonster(builder, &vec, 150, 80, name, inventory, Color_Blue,
|
||||
|
@ -59,7 +59,7 @@ inline const Character (&EnumValuesCharacter())[7] {
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesCharacter() {
|
||||
static const char * const names[] = {
|
||||
static const char * const names[8] = {
|
||||
"NONE",
|
||||
"MuLan",
|
||||
"Rapunzel",
|
||||
|
Loading…
x
Reference in New Issue
Block a user