}
}
impl EquipmentT {
- fn equipment_type(&self) -> Equipment {
+ pub fn equipment_type(&self) -> Equipment {
match self {
Self::NONE => Equipment::NONE,
Self::Weapon(_) => Equipment::Weapon,
ds.field("equipped", &"InvalidFlatbuffer: Union discriminant does not match value.")
}
},
- _ => {
+ _ => {
let x: Option<()> = None;
ds.field("equipped", &x)
},
code_ += "impl flatbuffers::SimpleToVerifyInSlice for {{ENUM_NAME}} {}";
if (enum_def.is_union) {
- // Generate tyoesafe offset(s) for unions
+ // Generate typesafe offset(s) for unions
code_.SetValue("NAME", Name(enum_def));
code_.SetValue("UNION_OFFSET_NAME", Name(enum_def) + "UnionTableOffset");
code_ += "pub struct {{UNION_OFFSET_NAME}} {}";
// Get flatbuffers union key.
// CASPER: add docstrings?
- code_ += " fn {{ENUM_NAME_SNAKE}}_type(&self) -> {{ENUM_NAME}} {";
+ code_ += " pub fn {{ENUM_NAME_SNAKE}}_type(&self) -> {{ENUM_NAME}} {";
code_ += " match self {";
code_ += " Self::NONE => {{ENUM_NAME}}::NONE,";
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
case ftUnionKey: return;
case ftUnionValue: {
const auto &enum_def = *type.enum_def;
- code_.SetValue("ENUM_NAME", Name(enum_def));
- code_.SetValue("NATIVE_ENUM_NAME", NativeName(enum_def));
+ code_.SetValue("ENUM_NAME", WrapInNameSpace(enum_def));
+ code_.SetValue("NATIVE_ENUM_NAME", NamespacedNativeName(enum_def));
code_ +=
" let {{FIELD_NAME}} = match "
"self.{{FIELD_NAME}}_type() {";
}
// Unions.
EnumDef &union_def = *field.value.type.enum_def;
- code_.SetValue("UNION_TYPE", Name(union_def));
+ code_.SetValue("UNION_TYPE", WrapInNameSpace(union_def));
code_ +=
"\n .visit_union::<{{UNION_TYPE}}, _>("
"&\"{{FIELD_NAME}}_type\", Self::{{OFFSET_NAME}}_TYPE, "
code_ += " }";
code_ += " },";
});
- code_ += " _ => { ";
+ code_ += " _ => {";
code_ += " let x: Option<()> = None;";
code_ += " ds.field(\"{{FIELD_NAME}}\", &x)";
code_ += " },";
<Compile Include="..\namespace_test\NamespaceA\NamespaceB\TableInNestedNS.cs">
<Link>NamespaceA\NamespaceB\TableInNestedNS.cs</Link>
</Compile>
+ <Compile Include="..\namespace_test\NamespaceA\NamespaceB\UnionInNestedNS.cs">
+ <Link>NamespaceA\NamespaceB\UnionInNestedNS.cs</Link>
+ </Compile>
<Compile Include="..\namespace_test\NamespaceA\TableInFirstNS.cs">
<Link>NamespaceA\TableInFirstNS.cs</Link>
</Compile>
<Compile Include="..\namespace_test\NamespaceA\NamespaceB\TableInNestedNS.cs">
<Link>NamespaceA\NamespaceB\TableInNestedNS.cs</Link>
</Compile>
+ <Compile Include="..\namespace_test\NamespaceA\NamespaceB\UnionInNestedNS.cs">
+ <Link>NamespaceA\NamespaceB\UnionInNestedNS.cs</Link>
+ </Compile>
<Compile Include="..\namespace_test\NamespaceA\TableInFirstNS.cs">
<Link>NamespaceA\TableInFirstNS.cs</Link>
</Compile>
set TEST_CPP_FLAGS=--gen-compare --cpp-ptr-type flatbuffers::unique_ptr %TEST_CPP_FLAGS%
set TEST_CS_FLAGS=--cs-gen-json-serializer
set TEST_JS_TS_FLAGS=--gen-name-strings
-set TEST_RUST_FLAGS=--gen-name-strings
set TEST_BASE_FLAGS=--reflect-names --gen-mutable --gen-object-api
+set TEST_RUST_FLAGS=%TEST_BASE_FLAGS% --gen-name-strings
set TEST_NOINCL_FLAGS=%TEST_BASE_FLAGS% --no-includes
..\%buildtype%\flatc.exe --binary --cpp --java --kotlin --csharp --dart --go --lobster --lua --ts --php --grpc ^
%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
-..\%buildtype%\flatc.exe --rust %TEST_NOINCL_FLAGS% %TEST_RUST_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
+..\%buildtype%\flatc.exe --rust %TEST_RUST_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
-..\%buildtype%\flatc.exe --binary --cpp --java --csharp --dart --go --lobster --lua --ts --php --python --rust ^
+..\%buildtype%\flatc.exe --binary --cpp --java --csharp --dart --go --lobster --lua --ts --php --python ^
%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_JS_TS_FLAGS% -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
+@rem For Rust we currently generate two independent schemas, with namespace_test2
+@rem duplicating the types in namespace_test1
+..\%buildtype%\flatc.exe --rust --gen-all %TEST_RUST_FLAGS% -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
+
..\%buildtype%\flatc.exe --cpp --java --csharp --ts --php %TEST_BASE_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_JS_TS_FLAGS% -o union_vector ./union_vector/union_vector.fbs || goto FAIL
..\%buildtype%\flatc.exe --rust -I include_test -o include_test include_test/include_test1.fbs || goto FAIL
..\%buildtype%\flatc.exe --rust -I include_test -o include_test/sub include_test/sub/include_test2.fbs || goto FAIL
../flatc --python $TEST_BASE_FLAGS -I include_test monster_test.fbs monsterdata_test.json
-../flatc --cpp --java --kotlin --csharp --dart --go --binary --lobster --lua --ts --php --python --rust \
+../flatc --cpp --java --kotlin --csharp --dart --go --binary --lobster --lua --ts --php --python \
$TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
+# For Rust we currently generate two independent schemas, with namespace_test2
+# duplicating the types in namespace_test1
+../flatc --rust --gen-all $TEST_RUST_FLAGS -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
+
../flatc --cpp --java --kotlin --csharp --ts --php $TEST_BASE_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o union_vector ./union_vector/union_vector.fbs
../flatc --rust -I include_test -o include_test include_test/include_test1.fbs
../flatc --rust -I include_test -o include_test/sub include_test/sub/include_test2.fbs
}
}
impl AnyT {
- fn any_type(&self) -> Any {
+ pub fn any_type(&self) -> Any {
match self {
Self::NONE => Any::NONE,
Self::Monster(_) => Any::Monster,
}
}
impl AnyUniqueAliasesT {
- fn any_unique_aliases_type(&self) -> AnyUniqueAliases {
+ pub fn any_unique_aliases_type(&self) -> AnyUniqueAliases {
match self {
Self::NONE => AnyUniqueAliases::NONE,
Self::M(_) => AnyUniqueAliases::M,
}
}
impl AnyAmbiguousAliasesT {
- fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
+ pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
match self {
Self::NONE => AnyAmbiguousAliases::NONE,
Self::M1(_) => AnyAmbiguousAliases::M1,
ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
}
},
- _ => {
+ _ => {
let x: Option<()> = None;
ds.field("test", &x)
},
ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
}
},
- _ => {
+ _ => {
let x: Option<()> = None;
ds.field("any_unique", &x)
},
ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
}
},
- _ => {
+ _ => {
let x: Option<()> = None;
ds.field("any_ambiguous", &x)
},
--- /dev/null
+// <auto-generated>
+// automatically generated by the FlatBuffers compiler, do not modify
+// </auto-generated>
+
+namespace NamespaceA.NamespaceB
+{
+
+[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
+public enum UnionInNestedNS : byte
+{
+ NONE = 0,
+ TableInNestedNS = 1,
+};
+
+public class UnionInNestedNSUnion {
+ public UnionInNestedNS Type { get; set; }
+ public object Value { get; set; }
+
+ public UnionInNestedNSUnion() {
+ this.Type = UnionInNestedNS.NONE;
+ this.Value = null;
+ }
+
+ public T As<T>() where T : class { return this.Value as T; }
+ public NamespaceA.NamespaceB.TableInNestedNST AsTableInNestedNS() { return this.As<NamespaceA.NamespaceB.TableInNestedNST>(); }
+
+ public static int Pack(FlatBuffers.FlatBufferBuilder builder, UnionInNestedNSUnion _o) {
+ switch (_o.Type) {
+ default: return 0;
+ case UnionInNestedNS.TableInNestedNS: return NamespaceA.NamespaceB.TableInNestedNS.Pack(builder, _o.AsTableInNestedNS()).Value;
+ }
+ }
+}
+
+public class UnionInNestedNSUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
+ public override bool CanConvert(System.Type objectType) {
+ return objectType == typeof(UnionInNestedNSUnion) || objectType == typeof(System.Collections.Generic.List<UnionInNestedNSUnion>);
+ }
+ public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer) {
+ var _olist = value as System.Collections.Generic.List<UnionInNestedNSUnion>;
+ if (_olist != null) {
+ writer.WriteStartArray();
+ foreach (var _o in _olist) { this.WriteJson(writer, _o, serializer); }
+ writer.WriteEndArray();
+ } else {
+ this.WriteJson(writer, value as UnionInNestedNSUnion, serializer);
+ }
+ }
+ public void WriteJson(Newtonsoft.Json.JsonWriter writer, UnionInNestedNSUnion _o, Newtonsoft.Json.JsonSerializer serializer) {
+ if (_o == null) return;
+ serializer.Serialize(writer, _o.Value);
+ }
+ public override object ReadJson(Newtonsoft.Json.JsonReader reader, System.Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) {
+ var _olist = existingValue as System.Collections.Generic.List<UnionInNestedNSUnion>;
+ if (_olist != null) {
+ for (var _j = 0; _j < _olist.Count; ++_j) {
+ reader.Read();
+ _olist[_j] = this.ReadJson(reader, _olist[_j], serializer);
+ }
+ reader.Read();
+ return _olist;
+ } else {
+ return this.ReadJson(reader, existingValue as UnionInNestedNSUnion, serializer);
+ }
+ }
+ public UnionInNestedNSUnion ReadJson(Newtonsoft.Json.JsonReader reader, UnionInNestedNSUnion _o, Newtonsoft.Json.JsonSerializer serializer) {
+ if (_o == null) return null;
+ switch (_o.Type) {
+ default: break;
+ case UnionInNestedNS.TableInNestedNS: _o.Value = serializer.Deserialize<NamespaceA.NamespaceB.TableInNestedNST>(reader); break;
+ }
+ return _o;
+ }
+}
+
+
+}
--- /dev/null
+// Code generated by the FlatBuffers compiler. DO NOT EDIT.
+
+package NamespaceB
+
+import (
+ "strconv"
+
+ flatbuffers "github.com/google/flatbuffers/go"
+
+ NamespaceA__NamespaceB "NamespaceA/NamespaceB"
+)
+
+type UnionInNestedNST struct {
+ Type UnionInNestedNS
+ Value interface{}
+}
+
+func (t *UnionInNestedNST) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
+ if t == nil {
+ return 0
+ }
+ switch t.Type {
+ case UnionInNestedNSTableInNestedNS:
+ return t.Value.(*NamespaceA__NamespaceB.TableInNestedNST).Pack(builder)
+ }
+ return 0
+}
+
+func (rcv UnionInNestedNS) UnPack(table flatbuffers.Table) *UnionInNestedNST {
+ switch rcv {
+ case UnionInNestedNSTableInNestedNS:
+ x := TableInNestedNS{_tab: table}
+ return &NamespaceA__NamespaceB.UnionInNestedNST{ Type: UnionInNestedNSTableInNestedNS, Value: x.UnPack() }
+ }
+ return nil
+}
--- /dev/null
+// automatically generated by the FlatBuffers compiler, do not modify
+
+package NamespaceA.NamespaceB;
+
+public final class UnionInNestedNS {
+ private UnionInNestedNS() { }
+ public static final byte NONE = 0;
+ public static final byte TableInNestedNS = 1;
+
+ public static final String[] names = { "NONE", "TableInNestedNS", };
+
+ public static String name(int e) { return names[e]; }
+}
+
--- /dev/null
+// automatically generated by the FlatBuffers compiler, do not modify
+
+package NamespaceA.NamespaceB
+
+@Suppress("unused")
+@ExperimentalUnsignedTypes
+class UnionInNestedNS private constructor() {
+ companion object {
+ const val NONE: UByte = 0u
+ const val TableInNestedNS: UByte = 1u
+ val names : Array<String> = arrayOf("NONE", "TableInNestedNS")
+ fun name(e: Int) : String = names[e]
+ }
+}
--- /dev/null
+-- automatically generated by the FlatBuffers compiler, do not modify
+
+-- namespace: NamespaceB
+
+local UnionInNestedNS = {
+ NONE = 0,
+ TableInNestedNS = 1,
+}
+
+return UnionInNestedNS -- return the module
\ No newline at end of file
--- /dev/null
+<?php
+// automatically generated by the FlatBuffers compiler, do not modify
+
+namespace NamespaceA\NamespaceB;
+
+class UnionInNestedNS
+{
+ const NONE = 0;
+ const TableInNestedNS = 1;
+
+ private static $names = array(
+ UnionInNestedNS::NONE=>"NONE",
+ UnionInNestedNS::TableInNestedNS=>"TableInNestedNS",
+ );
+
+ public static function Name($e)
+ {
+ if (!isset(self::$names[$e])) {
+ throw new \Exception();
+ }
+ return self::$names[$e];
+ }
+}
--- /dev/null
+# automatically generated by the FlatBuffers compiler, do not modify
+
+# namespace: NamespaceB
+
+
+def UnionInNestedNSCreator(unionType, table):
+ from flatbuffers.table import Table
+ if not isinstance(table, Table):
+ return None
+ if unionType == UnionInNestedNS().TableInNestedNS:
+ return TableInNestedNST.InitFromBuf(table.Bytes, table.Pos)
+ return None
public NamespaceA.NamespaceB.TableInNestedNS? FooTable { get { int o = __p.__offset(4); return o != 0 ? (NamespaceA.NamespaceB.TableInNestedNS?)(new NamespaceA.NamespaceB.TableInNestedNS()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }
public NamespaceA.NamespaceB.EnumInNestedNS FooEnum { get { int o = __p.__offset(6); return o != 0 ? (NamespaceA.NamespaceB.EnumInNestedNS)__p.bb.GetSbyte(o + __p.bb_pos) : NamespaceA.NamespaceB.EnumInNestedNS.A; } }
public bool MutateFooEnum(NamespaceA.NamespaceB.EnumInNestedNS foo_enum) { int o = __p.__offset(6); if (o != 0) { __p.bb.PutSbyte(o + __p.bb_pos, (sbyte)foo_enum); return true; } else { return false; } }
- public NamespaceA.NamespaceB.StructInNestedNS? FooStruct { get { int o = __p.__offset(8); return o != 0 ? (NamespaceA.NamespaceB.StructInNestedNS?)(new NamespaceA.NamespaceB.StructInNestedNS()).__assign(o + __p.bb_pos, __p.bb) : null; } }
+ public NamespaceA.NamespaceB.UnionInNestedNS FooUnionType { get { int o = __p.__offset(8); return o != 0 ? (NamespaceA.NamespaceB.UnionInNestedNS)__p.bb.Get(o + __p.bb_pos) : NamespaceA.NamespaceB.UnionInNestedNS.NONE; } }
+ public TTable? FooUnion<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(10); return o != 0 ? (TTable?)__p.__union<TTable>(o + __p.bb_pos) : null; }
+ public NamespaceA.NamespaceB.TableInNestedNS FooUnionAsTableInNestedNS() { return FooUnion<NamespaceA.NamespaceB.TableInNestedNS>().Value; }
+ public NamespaceA.NamespaceB.StructInNestedNS? FooStruct { get { int o = __p.__offset(12); return o != 0 ? (NamespaceA.NamespaceB.StructInNestedNS?)(new NamespaceA.NamespaceB.StructInNestedNS()).__assign(o + __p.bb_pos, __p.bb) : null; } }
public static Offset<NamespaceA.TableInFirstNS> CreateTableInFirstNS(FlatBufferBuilder builder,
Offset<NamespaceA.NamespaceB.TableInNestedNS> foo_tableOffset = default(Offset<NamespaceA.NamespaceB.TableInNestedNS>),
NamespaceA.NamespaceB.EnumInNestedNS foo_enum = NamespaceA.NamespaceB.EnumInNestedNS.A,
+ NamespaceA.NamespaceB.UnionInNestedNS foo_union_type = NamespaceA.NamespaceB.UnionInNestedNS.NONE,
+ int foo_unionOffset = 0,
NamespaceA.NamespaceB.StructInNestedNST foo_struct = null) {
- builder.StartTable(3);
+ builder.StartTable(5);
TableInFirstNS.AddFooStruct(builder, NamespaceA.NamespaceB.StructInNestedNS.Pack(builder, foo_struct));
+ TableInFirstNS.AddFooUnion(builder, foo_unionOffset);
TableInFirstNS.AddFooTable(builder, foo_tableOffset);
+ TableInFirstNS.AddFooUnionType(builder, foo_union_type);
TableInFirstNS.AddFooEnum(builder, foo_enum);
return TableInFirstNS.EndTableInFirstNS(builder);
}
- public static void StartTableInFirstNS(FlatBufferBuilder builder) { builder.StartTable(3); }
+ public static void StartTableInFirstNS(FlatBufferBuilder builder) { builder.StartTable(5); }
public static void AddFooTable(FlatBufferBuilder builder, Offset<NamespaceA.NamespaceB.TableInNestedNS> fooTableOffset) { builder.AddOffset(0, fooTableOffset.Value, 0); }
public static void AddFooEnum(FlatBufferBuilder builder, NamespaceA.NamespaceB.EnumInNestedNS fooEnum) { builder.AddSbyte(1, (sbyte)fooEnum, 0); }
- public static void AddFooStruct(FlatBufferBuilder builder, Offset<NamespaceA.NamespaceB.StructInNestedNS> fooStructOffset) { builder.AddStruct(2, fooStructOffset.Value, 0); }
+ public static void AddFooUnionType(FlatBufferBuilder builder, NamespaceA.NamespaceB.UnionInNestedNS fooUnionType) { builder.AddByte(2, (byte)fooUnionType, 0); }
+ public static void AddFooUnion(FlatBufferBuilder builder, int fooUnionOffset) { builder.AddOffset(3, fooUnionOffset, 0); }
+ public static void AddFooStruct(FlatBufferBuilder builder, Offset<NamespaceA.NamespaceB.StructInNestedNS> fooStructOffset) { builder.AddStruct(4, fooStructOffset.Value, 0); }
public static Offset<NamespaceA.TableInFirstNS> EndTableInFirstNS(FlatBufferBuilder builder) {
int o = builder.EndTable();
return new Offset<NamespaceA.TableInFirstNS>(o);
public void UnPackTo(TableInFirstNST _o) {
_o.FooTable = this.FooTable.HasValue ? this.FooTable.Value.UnPack() : null;
_o.FooEnum = this.FooEnum;
+ _o.FooUnion = new NamespaceA.NamespaceB.UnionInNestedNSUnion();
+ _o.FooUnion.Type = this.FooUnionType;
+ switch (this.FooUnionType) {
+ default: break;
+ case NamespaceA.NamespaceB.UnionInNestedNS.TableInNestedNS:
+ _o.FooUnion.Value = this.FooUnion<NamespaceA.NamespaceB.TableInNestedNS>().HasValue ? this.FooUnion<NamespaceA.NamespaceB.TableInNestedNS>().Value.UnPack() : null;
+ break;
+ }
_o.FooStruct = this.FooStruct.HasValue ? this.FooStruct.Value.UnPack() : null;
}
public static Offset<NamespaceA.TableInFirstNS> Pack(FlatBufferBuilder builder, TableInFirstNST _o) {
if (_o == null) return default(Offset<NamespaceA.TableInFirstNS>);
var _foo_table = _o.FooTable == null ? default(Offset<NamespaceA.NamespaceB.TableInNestedNS>) : NamespaceA.NamespaceB.TableInNestedNS.Pack(builder, _o.FooTable);
+ var _foo_union_type = _o.FooUnion == null ? NamespaceA.NamespaceB.UnionInNestedNS.NONE : _o.FooUnion.Type;
+ var _foo_union = _o.FooUnion == null ? 0 : NamespaceA.NamespaceB.UnionInNestedNSUnion.Pack(builder, _o.FooUnion);
return CreateTableInFirstNS(
builder,
_foo_table,
_o.FooEnum,
+ _foo_union_type,
+ _foo_union,
_o.FooStruct);
}
};
public NamespaceA.NamespaceB.TableInNestedNST FooTable { get; set; }
[Newtonsoft.Json.JsonProperty("foo_enum")]
public NamespaceA.NamespaceB.EnumInNestedNS FooEnum { get; set; }
+ [Newtonsoft.Json.JsonProperty("foo_union_type")]
+ private NamespaceA.NamespaceB.UnionInNestedNS FooUnionType {
+ get {
+ return this.FooUnion != null ? this.FooUnion.Type : NamespaceA.NamespaceB.UnionInNestedNS.NONE;
+ }
+ set {
+ this.FooUnion = new NamespaceA.NamespaceB.UnionInNestedNSUnion();
+ this.FooUnion.Type = value;
+ }
+ }
+ [Newtonsoft.Json.JsonProperty("foo_union")]
+ [Newtonsoft.Json.JsonConverter(typeof(NamespaceA.NamespaceB.UnionInNestedNSUnion_JsonConverter))]
+ public NamespaceA.NamespaceB.UnionInNestedNSUnion FooUnion { get; set; }
[Newtonsoft.Json.JsonProperty("foo_struct")]
public NamespaceA.NamespaceB.StructInNestedNST FooStruct { get; set; }
public TableInFirstNST() {
this.FooTable = null;
this.FooEnum = NamespaceA.NamespaceB.EnumInNestedNS.A;
+ this.FooUnion = null;
this.FooStruct = new NamespaceA.NamespaceB.StructInNestedNST();
}
}
type TableInFirstNST struct {
FooTable *NamespaceA__NamespaceB.TableInNestedNST
FooEnum NamespaceA__NamespaceB.EnumInNestedNS
+ FooUnion *NamespaceA__NamespaceB.UnionInNestedNST
FooStruct *NamespaceA__NamespaceB.StructInNestedNST
}
func (t *TableInFirstNST) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
fooTableOffset := t.FooTable.Pack(builder)
+ fooUnionOffset := t.FooUnion.Pack(builder)
+
TableInFirstNSStart(builder)
TableInFirstNSAddFooTable(builder, fooTableOffset)
TableInFirstNSAddFooEnum(builder, t.FooEnum)
+ if t.FooUnion != nil {
+ TableInFirstNSAddFooUnionType(builder, t.FooUnion.Type)
+ }
+ TableInFirstNSAddFooUnion(builder, fooUnionOffset)
fooStructOffset := t.FooStruct.Pack(builder)
TableInFirstNSAddFooStruct(builder, fooStructOffset)
return TableInFirstNSEnd(builder)
func (rcv *TableInFirstNS) UnPackTo(t *TableInFirstNST) {
t.FooTable = rcv.FooTable(nil).UnPack()
t.FooEnum = rcv.FooEnum()
+ fooUnionTable := flatbuffers.Table{}
+ if rcv.FooUnion(&fooUnionTable) {
+ t.FooUnion = rcv.FooUnionType().UnPack(fooUnionTable)
+ }
t.FooStruct = rcv.FooStruct(nil).UnPack()
}
return rcv._tab.MutateInt8Slot(6, int8(n))
}
-func (rcv *TableInFirstNS) FooStruct(obj *NamespaceA__NamespaceB.StructInNestedNS) *NamespaceA__NamespaceB.StructInNestedNS {
+func (rcv *TableInFirstNS) FooUnionType() NamespaceA__NamespaceB.UnionInNestedNS {
o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
if o != 0 {
+ return NamespaceA__NamespaceB.UnionInNestedNS(rcv._tab.GetByte(o + rcv._tab.Pos))
+ }
+ return 0
+}
+
+func (rcv *TableInFirstNS) MutateFooUnionType(n NamespaceA__NamespaceB.UnionInNestedNS) bool {
+ return rcv._tab.MutateByteSlot(8, byte(n))
+}
+
+func (rcv *TableInFirstNS) FooUnion(obj *flatbuffers.Table) bool {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
+ if o != 0 {
+ rcv._tab.Union(obj, o)
+ return true
+ }
+ return false
+}
+
+func (rcv *TableInFirstNS) FooStruct(obj *NamespaceA__NamespaceB.StructInNestedNS) *NamespaceA__NamespaceB.StructInNestedNS {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(12))
+ if o != 0 {
x := o + rcv._tab.Pos
if obj == nil {
obj = new(NamespaceA__NamespaceB.StructInNestedNS)
}
func TableInFirstNSStart(builder *flatbuffers.Builder) {
- builder.StartObject(3)
+ builder.StartObject(5)
}
func TableInFirstNSAddFooTable(builder *flatbuffers.Builder, fooTable flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(fooTable), 0)
func TableInFirstNSAddFooEnum(builder *flatbuffers.Builder, fooEnum NamespaceA__NamespaceB.EnumInNestedNS) {
builder.PrependInt8Slot(1, int8(fooEnum), 0)
}
+func TableInFirstNSAddFooUnionType(builder *flatbuffers.Builder, fooUnionType NamespaceA__NamespaceB.UnionInNestedNS) {
+ builder.PrependByteSlot(2, byte(fooUnionType), 0)
+}
+func TableInFirstNSAddFooUnion(builder *flatbuffers.Builder, fooUnion flatbuffers.UOffsetT) {
+ builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(fooUnion), 0)
+}
func TableInFirstNSAddFooStruct(builder *flatbuffers.Builder, fooStruct flatbuffers.UOffsetT) {
- builder.PrependStructSlot(2, flatbuffers.UOffsetT(fooStruct), 0)
+ builder.PrependStructSlot(4, flatbuffers.UOffsetT(fooStruct), 0)
}
func TableInFirstNSEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
public NamespaceA.NamespaceB.TableInNestedNS fooTable(NamespaceA.NamespaceB.TableInNestedNS obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public byte fooEnum() { int o = __offset(6); return o != 0 ? bb.get(o + bb_pos) : 0; }
public boolean mutateFooEnum(byte foo_enum) { int o = __offset(6); if (o != 0) { bb.put(o + bb_pos, foo_enum); return true; } else { return false; } }
+ public byte fooUnionType() { int o = __offset(8); return o != 0 ? bb.get(o + bb_pos) : 0; }
+ public Table fooUnion(Table obj) { int o = __offset(10); return o != 0 ? __union(obj, o + bb_pos) : null; }
public NamespaceA.NamespaceB.StructInNestedNS fooStruct() { return fooStruct(new NamespaceA.NamespaceB.StructInNestedNS()); }
- public NamespaceA.NamespaceB.StructInNestedNS fooStruct(NamespaceA.NamespaceB.StructInNestedNS obj) { int o = __offset(8); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; }
+ public NamespaceA.NamespaceB.StructInNestedNS fooStruct(NamespaceA.NamespaceB.StructInNestedNS obj) { int o = __offset(12); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; }
- public static void startTableInFirstNS(FlatBufferBuilder builder) { builder.startTable(3); }
+ public static void startTableInFirstNS(FlatBufferBuilder builder) { builder.startTable(5); }
public static void addFooTable(FlatBufferBuilder builder, int fooTableOffset) { builder.addOffset(0, fooTableOffset, 0); }
public static void addFooEnum(FlatBufferBuilder builder, byte fooEnum) { builder.addByte(1, fooEnum, 0); }
- public static void addFooStruct(FlatBufferBuilder builder, int fooStructOffset) { builder.addStruct(2, fooStructOffset, 0); }
+ public static void addFooUnionType(FlatBufferBuilder builder, byte fooUnionType) { builder.addByte(2, fooUnionType, 0); }
+ public static void addFooUnion(FlatBufferBuilder builder, int fooUnionOffset) { builder.addOffset(3, fooUnionOffset, 0); }
+ public static void addFooStruct(FlatBufferBuilder builder, int fooStructOffset) { builder.addStruct(4, fooStructOffset, 0); }
public static int endTableInFirstNS(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
false
}
}
+ val fooUnionType : UByte
+ get() {
+ val o = __offset(8)
+ return if(o != 0) bb.get(o + bb_pos).toUByte() else 0u
+ }
+ fun mutateFooUnionType(fooUnionType: UByte) : Boolean {
+ val o = __offset(8)
+ return if (o != 0) {
+ bb.put(o + bb_pos, fooUnionType.toByte())
+ true
+ } else {
+ false
+ }
+ }
+ fun fooUnion(obj: Table) : Table? {
+ val o = __offset(10); return if (o != 0) __union(obj, o + bb_pos) else null
+ }
val fooStruct : NamespaceA.NamespaceB.StructInNestedNS? get() = fooStruct(NamespaceA.NamespaceB.StructInNestedNS())
fun fooStruct(obj: NamespaceA.NamespaceB.StructInNestedNS) : NamespaceA.NamespaceB.StructInNestedNS? {
- val o = __offset(8)
+ val o = __offset(12)
return if (o != 0) {
obj.__assign(o + bb_pos, bb)
} else {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
- fun startTableInFirstNS(builder: FlatBufferBuilder) = builder.startTable(3)
+ fun startTableInFirstNS(builder: FlatBufferBuilder) = builder.startTable(5)
fun addFooTable(builder: FlatBufferBuilder, fooTable: Int) = builder.addOffset(0, fooTable, 0)
fun addFooEnum(builder: FlatBufferBuilder, fooEnum: Byte) = builder.addByte(1, fooEnum, 0)
- fun addFooStruct(builder: FlatBufferBuilder, fooStruct: Int) = builder.addStruct(2, fooStruct, 0)
+ fun addFooUnionType(builder: FlatBufferBuilder, fooUnionType: UByte) = builder.addByte(2, fooUnionType.toByte(), 0)
+ fun addFooUnion(builder: FlatBufferBuilder, fooUnion: Int) = builder.addOffset(3, fooUnion, 0)
+ fun addFooStruct(builder: FlatBufferBuilder, fooStruct: Int) = builder.addStruct(4, fooStruct, 0)
fun endTableInFirstNS(builder: FlatBufferBuilder) : Int {
val o = builder.endTable()
return o
end
return 0
end
-function TableInFirstNS_mt:FooStruct()
+function TableInFirstNS_mt:FooUnionType()
local o = self.view:Offset(8)
if o ~= 0 then
+ return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
+ end
+ return 0
+end
+function TableInFirstNS_mt:FooUnion()
+ local o = self.view:Offset(10)
+ if o ~= 0 then
+ local obj = flatbuffers.view.New(require('flatbuffers.binaryarray').New(0), 0)
+ self.view:Union(obj, o)
+ return obj
+ end
+end
+function TableInFirstNS_mt:FooStruct()
+ local o = self.view:Offset(12)
+ if o ~= 0 then
local x = o + self.view.pos
local obj = require('NamespaceA.NamespaceB.StructInNestedNS').New()
obj:Init(self.view.bytes, x)
return obj
end
end
-function TableInFirstNS.Start(builder) builder:StartObject(3) end
+function TableInFirstNS.Start(builder) builder:StartObject(5) end
function TableInFirstNS.AddFooTable(builder, fooTable) builder:PrependUOffsetTRelativeSlot(0, fooTable, 0) end
function TableInFirstNS.AddFooEnum(builder, fooEnum) builder:PrependInt8Slot(1, fooEnum, 0) end
-function TableInFirstNS.AddFooStruct(builder, fooStruct) builder:PrependStructSlot(2, fooStruct, 0) end
+function TableInFirstNS.AddFooUnionType(builder, fooUnionType) builder:PrependUint8Slot(2, fooUnionType, 0) end
+function TableInFirstNS.AddFooUnion(builder, fooUnion) builder:PrependUOffsetTRelativeSlot(3, fooUnion, 0) end
+function TableInFirstNS.AddFooStruct(builder, fooStruct) builder:PrependStructSlot(4, fooStruct, 0) end
function TableInFirstNS.End(builder) return builder:EndObject() end
return TableInFirstNS -- return the module
\ No newline at end of file
return $o != 0 ? $this->bb->getSbyte($o + $this->bb_pos) : \NamespaceA\NamespaceB\EnumInNestedNS::A;
}
+ /**
+ * @return byte
+ */
+ public function getFooUnionType()
+ {
+ $o = $this->__offset(8);
+ return $o != 0 ? $this->bb->getByte($o + $this->bb_pos) : \NamespaceA\NamespaceB\UnionInNestedNS::NONE;
+ }
+
+ /**
+ * @returnint
+ */
+ public function getFooUnion($obj)
+ {
+ $o = $this->__offset(10);
+ return $o != 0 ? $this->__union($obj, $o) : null;
+ }
+
public function getFooStruct()
{
$obj = new StructInNestedNS();
- $o = $this->__offset(8);
+ $o = $this->__offset(12);
return $o != 0 ? $obj->init($o + $this->bb_pos, $this->bb) : 0;
}
*/
public static function startTableInFirstNS(FlatBufferBuilder $builder)
{
- $builder->StartObject(3);
+ $builder->StartObject(5);
}
/**
* @param FlatBufferBuilder $builder
* @return TableInFirstNS
*/
- public static function createTableInFirstNS(FlatBufferBuilder $builder, $foo_table, $foo_enum, $foo_struct)
+ public static function createTableInFirstNS(FlatBufferBuilder $builder, $foo_table, $foo_enum, $foo_union_type, $foo_union, $foo_struct)
{
- $builder->startObject(3);
+ $builder->startObject(5);
self::addFooTable($builder, $foo_table);
self::addFooEnum($builder, $foo_enum);
+ self::addFooUnionType($builder, $foo_union_type);
+ self::addFooUnion($builder, $foo_union);
self::addFooStruct($builder, $foo_struct);
$o = $builder->endObject();
return $o;
/**
* @param FlatBufferBuilder $builder
+ * @param byte
+ * @return void
+ */
+ public static function addFooUnionType(FlatBufferBuilder $builder, $fooUnionType)
+ {
+ $builder->addByteX(2, $fooUnionType, 0);
+ }
+
+ public static function addFooUnion(FlatBufferBuilder $builder, $offset)
+ {
+ $builder->addOffsetX(3, $offset, 0);
+ }
+
+ /**
+ * @param FlatBufferBuilder $builder
* @param int
* @return void
*/
public static function addFooStruct(FlatBufferBuilder $builder, $fooStruct)
{
- $builder->addStructX(2, $fooStruct, 0);
+ $builder->addStructX(4, $fooStruct, 0);
}
/**
return 0
# TableInFirstNS
- def FooStruct(self):
+ def FooUnionType(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
+ return 0
+
+ # TableInFirstNS
+ def FooUnion(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
+ if o != 0:
+ from flatbuffers.table import Table
+ obj = Table(bytearray(), 0)
+ self._tab.Union(obj, o)
+ return obj
+ return None
+
+ # TableInFirstNS
+ def FooStruct(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
+ if o != 0:
x = o + self._tab.Pos
obj = StructInNestedNS()
obj.Init(self._tab.Bytes, x)
return obj
return None
-def TableInFirstNSStart(builder): builder.StartObject(3)
+def TableInFirstNSStart(builder): builder.StartObject(5)
def TableInFirstNSAddFooTable(builder, fooTable): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(fooTable), 0)
def TableInFirstNSAddFooEnum(builder, fooEnum): builder.PrependInt8Slot(1, fooEnum, 0)
-def TableInFirstNSAddFooStruct(builder, fooStruct): builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(fooStruct), 0)
+def TableInFirstNSAddFooUnionType(builder, fooUnionType): builder.PrependUint8Slot(2, fooUnionType, 0)
+def TableInFirstNSAddFooUnion(builder, fooUnion): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(fooUnion), 0)
+def TableInFirstNSAddFooStruct(builder, fooStruct): builder.PrependStructSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(fooStruct), 0)
def TableInFirstNSEnd(builder): return builder.EndObject()
try:
- from typing import Optional
+ from typing import Optional, Union
except:
pass
def __init__(self):
self.fooTable = None # type: Optional[TableInNestedNST]
self.fooEnum = 0 # type: int
+ self.fooUnionType = 0 # type: int
+ self.fooUnion = None # type: Union[None, TableInNestedNST]
self.fooStruct = None # type: Optional[StructInNestedNST]
@classmethod
if tableInFirstNS.FooTable() is not None:
self.fooTable = TableInNestedNST.InitFromObj(tableInFirstNS.FooTable())
self.fooEnum = tableInFirstNS.FooEnum()
+ self.fooUnionType = tableInFirstNS.FooUnionType()
+ self.fooUnion = UnionInNestedNSCreator(self.fooUnionType, tableInFirstNS.FooUnion())
if tableInFirstNS.FooStruct() is not None:
self.fooStruct = StructInNestedNST.InitFromObj(tableInFirstNS.FooStruct())
def Pack(self, builder):
if self.fooTable is not None:
fooTable = self.fooTable.Pack(builder)
+ if self.fooUnion is not None:
+ fooUnion = self.fooUnion.Pack(builder)
TableInFirstNSStart(builder)
if self.fooTable is not None:
TableInFirstNSAddFooTable(builder, fooTable)
TableInFirstNSAddFooEnum(builder, self.fooEnum)
+ TableInFirstNSAddFooUnionType(builder, self.fooUnionType)
+ if self.fooUnion is not None:
+ TableInFirstNSAddFooUnion(builder, fooUnion)
if self.fooStruct is not None:
fooStruct = self.fooStruct.Pack(builder)
TableInFirstNSAddFooStruct(builder, fooStruct)
foo:int;
}
+union UnionInNestedNS {
+ TableInNestedNS,
+}
+
enum EnumInNestedNS:byte
{
A, B, C
inline const flatbuffers::TypeTable *StructInNestedNSTypeTable();
+enum UnionInNestedNS : uint8_t {
+ UnionInNestedNS_NONE = 0,
+ UnionInNestedNS_TableInNestedNS = 1,
+ UnionInNestedNS_MIN = UnionInNestedNS_NONE,
+ UnionInNestedNS_MAX = UnionInNestedNS_TableInNestedNS
+};
+
+inline const UnionInNestedNS (&EnumValuesUnionInNestedNS())[2] {
+ static const UnionInNestedNS values[] = {
+ UnionInNestedNS_NONE,
+ UnionInNestedNS_TableInNestedNS
+ };
+ return values;
+}
+
+inline const char * const *EnumNamesUnionInNestedNS() {
+ static const char * const names[3] = {
+ "NONE",
+ "TableInNestedNS",
+ nullptr
+ };
+ return names;
+}
+
+inline const char *EnumNameUnionInNestedNS(UnionInNestedNS e) {
+ if (flatbuffers::IsOutRange(e, UnionInNestedNS_NONE, UnionInNestedNS_TableInNestedNS)) return "";
+ const size_t index = static_cast<size_t>(e);
+ return EnumNamesUnionInNestedNS()[index];
+}
+
+template<typename T> struct UnionInNestedNSTraits {
+ static const UnionInNestedNS enum_value = UnionInNestedNS_NONE;
+};
+
+template<> struct UnionInNestedNSTraits<NamespaceA::NamespaceB::TableInNestedNS> {
+ static const UnionInNestedNS enum_value = UnionInNestedNS_TableInNestedNS;
+};
+
+struct UnionInNestedNSUnion {
+ UnionInNestedNS type;
+ void *value;
+
+ UnionInNestedNSUnion() : type(UnionInNestedNS_NONE), value(nullptr) {}
+ UnionInNestedNSUnion(UnionInNestedNSUnion&& u) FLATBUFFERS_NOEXCEPT :
+ type(UnionInNestedNS_NONE), value(nullptr)
+ { std::swap(type, u.type); std::swap(value, u.value); }
+ UnionInNestedNSUnion(const UnionInNestedNSUnion &);
+ UnionInNestedNSUnion &operator=(const UnionInNestedNSUnion &u)
+ { UnionInNestedNSUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }
+ UnionInNestedNSUnion &operator=(UnionInNestedNSUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(value, u.value); return *this; }
+ ~UnionInNestedNSUnion() { Reset(); }
+
+ void Reset();
+
+#ifndef FLATBUFFERS_CPP98_STL
+ template <typename T>
+ void Set(T&& val) {
+ using RT = typename std::remove_reference<T>::type;
+ Reset();
+ type = UnionInNestedNSTraits<typename RT::TableType>::enum_value;
+ if (type != UnionInNestedNS_NONE) {
+ value = new RT(std::forward<T>(val));
+ }
+ }
+#endif // FLATBUFFERS_CPP98_STL
+
+ static void *UnPack(const void *obj, UnionInNestedNS type, const flatbuffers::resolver_function_t *resolver);
+ flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const;
+
+ NamespaceA::NamespaceB::TableInNestedNST *AsTableInNestedNS() {
+ return type == UnionInNestedNS_TableInNestedNS ?
+ reinterpret_cast<NamespaceA::NamespaceB::TableInNestedNST *>(value) : nullptr;
+ }
+ const NamespaceA::NamespaceB::TableInNestedNST *AsTableInNestedNS() const {
+ return type == UnionInNestedNS_TableInNestedNS ?
+ reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNST *>(value) : nullptr;
+ }
+};
+
+
+inline bool operator==(const UnionInNestedNSUnion &lhs, const UnionInNestedNSUnion &rhs) {
+ if (lhs.type != rhs.type) return false;
+ switch (lhs.type) {
+ case UnionInNestedNS_NONE: {
+ return true;
+ }
+ case UnionInNestedNS_TableInNestedNS: {
+ return *(reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNST *>(lhs.value)) ==
+ *(reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNST *>(rhs.value));
+ }
+ default: {
+ return false;
+ }
+ }
+}
+
+inline bool operator!=(const UnionInNestedNSUnion &lhs, const UnionInNestedNSUnion &rhs) {
+ return !(lhs == rhs);
+}
+
+bool VerifyUnionInNestedNS(flatbuffers::Verifier &verifier, const void *obj, UnionInNestedNS type);
+bool VerifyUnionInNestedNSVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
+
enum EnumInNestedNS : int8_t {
EnumInNestedNS_A = 0,
EnumInNestedNS_B = 1,
_foo);
}
+inline bool VerifyUnionInNestedNS(flatbuffers::Verifier &verifier, const void *obj, UnionInNestedNS type) {
+ switch (type) {
+ case UnionInNestedNS_NONE: {
+ return true;
+ }
+ case UnionInNestedNS_TableInNestedNS: {
+ auto ptr = reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNS *>(obj);
+ return verifier.VerifyTable(ptr);
+ }
+ default: return true;
+ }
+}
+
+inline bool VerifyUnionInNestedNSVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
+ if (!values || !types) return !values && !types;
+ if (values->size() != types->size()) return false;
+ for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
+ if (!VerifyUnionInNestedNS(
+ verifier, values->Get(i), types->GetEnum<UnionInNestedNS>(i))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline void *UnionInNestedNSUnion::UnPack(const void *obj, UnionInNestedNS type, const flatbuffers::resolver_function_t *resolver) {
+ switch (type) {
+ case UnionInNestedNS_TableInNestedNS: {
+ auto ptr = reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNS *>(obj);
+ return ptr->UnPack(resolver);
+ }
+ default: return nullptr;
+ }
+}
+
+inline flatbuffers::Offset<void> UnionInNestedNSUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const {
+ switch (type) {
+ case UnionInNestedNS_TableInNestedNS: {
+ auto ptr = reinterpret_cast<const NamespaceA::NamespaceB::TableInNestedNST *>(value);
+ return CreateTableInNestedNS(_fbb, ptr, _rehasher).Union();
+ }
+ default: return 0;
+ }
+}
+
+inline UnionInNestedNSUnion::UnionInNestedNSUnion(const UnionInNestedNSUnion &u) : type(u.type), value(nullptr) {
+ switch (type) {
+ case UnionInNestedNS_TableInNestedNS: {
+ value = new NamespaceA::NamespaceB::TableInNestedNST(*reinterpret_cast<NamespaceA::NamespaceB::TableInNestedNST *>(u.value));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+inline void UnionInNestedNSUnion::Reset() {
+ switch (type) {
+ case UnionInNestedNS_TableInNestedNS: {
+ auto ptr = reinterpret_cast<NamespaceA::NamespaceB::TableInNestedNST *>(value);
+ delete ptr;
+ break;
+ }
+ default: break;
+ }
+ value = nullptr;
+ type = UnionInNestedNS_NONE;
+}
+
+inline const flatbuffers::TypeTable *UnionInNestedNSTypeTable() {
+ static const flatbuffers::TypeCode type_codes[] = {
+ { flatbuffers::ET_SEQUENCE, 0, -1 },
+ { flatbuffers::ET_SEQUENCE, 0, 0 }
+ };
+ static const flatbuffers::TypeFunction type_refs[] = {
+ NamespaceA::NamespaceB::TableInNestedNSTypeTable
+ };
+ static const char * const names[] = {
+ "NONE",
+ "TableInNestedNS"
+ };
+ static const flatbuffers::TypeTable tt = {
+ flatbuffers::ST_UNION, 2, type_codes, type_refs, nullptr, nullptr, names
+ };
+ return &tt;
+}
+
inline const flatbuffers::TypeTable *EnumInNestedNSTypeTable() {
static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_CHAR, 0, 0 },
namespace NamespaceA_NamespaceB
+enum UnionInNestedNS:
+ UnionInNestedNS_NONE = 0
+ UnionInNestedNS_TableInNestedNS = 1
+
enum EnumInNestedNS:
EnumInNestedNS_A = 0
EnumInNestedNS_B = 1
use self::flatbuffers::EndianScalar;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_UNION_IN_NESTED_NS: u8 = 0;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MAX_UNION_IN_NESTED_NS: u8 = 1;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+#[allow(non_camel_case_types)]
+pub const ENUM_VALUES_UNION_IN_NESTED_NS: [UnionInNestedNS; 2] = [
+ UnionInNestedNS::NONE,
+ UnionInNestedNS::TableInNestedNS,
+];
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
+#[repr(transparent)]
+pub struct UnionInNestedNS(pub u8);
+#[allow(non_upper_case_globals)]
+impl UnionInNestedNS {
+ pub const NONE: Self = Self(0);
+ pub const TableInNestedNS: Self = Self(1);
+
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 1;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::TableInNestedNS,
+ ];
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::TableInNestedNS => Some("TableInNestedNS"),
+ _ => None,
+ }
+ }
+}
+impl std::fmt::Debug for UnionInNestedNS {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for UnionInNestedNS {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
+ Self(b)
+ }
+}
+
+impl flatbuffers::Push for UnionInNestedNS {
+ type Output = UnionInNestedNS;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ flatbuffers::emplace_scalar::<u8>(dst, self.0);
+ }
+}
+
+impl flatbuffers::EndianScalar for UnionInNestedNS {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = u8::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ fn from_little_endian(self) -> Self {
+ let b = u8::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for UnionInNestedNS {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for UnionInNestedNS {}
+pub struct UnionInNestedNSUnionTableOffset {}
+
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub enum UnionInNestedNST {
+ NONE,
+ TableInNestedNS(Box<TableInNestedNST>),
+}
+impl Default for UnionInNestedNST {
+ fn default() -> Self {
+ Self::NONE
+ }
+}
+impl UnionInNestedNST {
+ pub fn union_in_nested_ns_type(&self) -> UnionInNestedNS {
+ match self {
+ Self::NONE => UnionInNestedNS::NONE,
+ Self::TableInNestedNS(_) => UnionInNestedNS::TableInNestedNS,
+ }
+ }
+ pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
+ match self {
+ Self::NONE => None,
+ Self::TableInNestedNS(v) => Some(v.pack(fbb).as_union_value()),
+ }
+ }
+ /// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE.
+ pub fn take_table_in_nested_ns(&mut self) -> Option<Box<TableInNestedNST>> {
+ if let Self::TableInNestedNS(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::TableInNestedNS(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the TableInNestedNST.
+ pub fn as_table_in_nested_ns(&self) -> Option<&TableInNestedNST> {
+ if let Self::TableInNestedNS(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the TableInNestedNST.
+ pub fn as_table_in_nested_ns_mut(&mut self) -> Option<&mut TableInNestedNST> {
+ if let Self::TableInNestedNS(v) = self { Some(v.as_mut()) } else { None }
+ }
+}
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ENUM_IN_NESTED_NS: i8 = 0;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ENUM_IN_NESTED_NS: i8 = 2;
import 'package:flat_buffers/flat_buffers.dart' as fb;
+class UnionInNestedNSTypeId {
+ final int value;
+ const UnionInNestedNSTypeId._(this.value);
+
+ factory UnionInNestedNSTypeId.fromValue(int value) {
+ if (value == null) value = 0;
+ if (!values.containsKey(value)) {
+ throw new StateError('Invalid value $value for bit flag enum UnionInNestedNSTypeId');
+ }
+ return values[value];
+ }
+
+ static const int minValue = 0;
+ static const int maxValue = 1;
+ static bool containsValue(int value) => values.containsKey(value);
+
+ static const UnionInNestedNSTypeId NONE = const UnionInNestedNSTypeId._(0);
+ static const UnionInNestedNSTypeId TableInNestedNS = const UnionInNestedNSTypeId._(1);
+ static const Map<int,UnionInNestedNSTypeId> values = {0: NONE,1: TableInNestedNS,};
+
+ static const fb.Reader<UnionInNestedNSTypeId> reader = const _UnionInNestedNSTypeIdReader();
+
+ @override
+ String toString() {
+ return 'UnionInNestedNSTypeId{value: $value}';
+ }
+}
+
+class _UnionInNestedNSTypeIdReader extends fb.Reader<UnionInNestedNSTypeId> {
+ const _UnionInNestedNSTypeIdReader();
+
+ @override
+ int get size => 1;
+
+ @override
+ UnionInNestedNSTypeId read(fb.BufferContext bc, int offset) =>
+ new UnionInNestedNSTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
+}
+
class EnumInNestedNS {
final int value;
const EnumInNestedNS._(this.value);
{
foo_table:NamespaceB.TableInNestedNS;
foo_enum:NamespaceB.EnumInNestedNS;
+ foo_union:NamespaceB.UnionInNestedNS;
foo_struct:NamespaceB.StructInNestedNS;
}
}
flatbuffers::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST> foo_table{};
NamespaceA::NamespaceB::EnumInNestedNS foo_enum = NamespaceA::NamespaceB::EnumInNestedNS_A;
+ NamespaceA::NamespaceB::UnionInNestedNSUnion foo_union{};
flatbuffers::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS> foo_struct{};
};
return
(lhs.foo_table == rhs.foo_table) &&
(lhs.foo_enum == rhs.foo_enum) &&
+ (lhs.foo_union == rhs.foo_union) &&
(lhs.foo_struct == rhs.foo_struct);
}
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_FOO_TABLE = 4,
VT_FOO_ENUM = 6,
- VT_FOO_STRUCT = 8
+ VT_FOO_UNION_TYPE = 8,
+ VT_FOO_UNION = 10,
+ VT_FOO_STRUCT = 12
};
const NamespaceA::NamespaceB::TableInNestedNS *foo_table() const {
return GetPointer<const NamespaceA::NamespaceB::TableInNestedNS *>(VT_FOO_TABLE);
bool mutate_foo_enum(NamespaceA::NamespaceB::EnumInNestedNS _foo_enum) {
return SetField<int8_t>(VT_FOO_ENUM, static_cast<int8_t>(_foo_enum), 0);
}
+ NamespaceA::NamespaceB::UnionInNestedNS foo_union_type() const {
+ return static_cast<NamespaceA::NamespaceB::UnionInNestedNS>(GetField<uint8_t>(VT_FOO_UNION_TYPE, 0));
+ }
+ const void *foo_union() const {
+ return GetPointer<const void *>(VT_FOO_UNION);
+ }
+ template<typename T> const T *foo_union_as() const;
+ const NamespaceA::NamespaceB::TableInNestedNS *foo_union_as_TableInNestedNS() const {
+ return foo_union_type() == NamespaceA::NamespaceB::UnionInNestedNS_TableInNestedNS ? static_cast<const NamespaceA::NamespaceB::TableInNestedNS *>(foo_union()) : nullptr;
+ }
+ void *mutable_foo_union() {
+ return GetPointer<void *>(VT_FOO_UNION);
+ }
const NamespaceA::NamespaceB::StructInNestedNS *foo_struct() const {
return GetStruct<const NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT);
}
VerifyOffset(verifier, VT_FOO_TABLE) &&
verifier.VerifyTable(foo_table()) &&
VerifyField<int8_t>(verifier, VT_FOO_ENUM) &&
+ VerifyField<uint8_t>(verifier, VT_FOO_UNION_TYPE) &&
+ VerifyOffset(verifier, VT_FOO_UNION) &&
+ VerifyUnionInNestedNS(verifier, foo_union(), foo_union_type()) &&
VerifyField<NamespaceA::NamespaceB::StructInNestedNS>(verifier, VT_FOO_STRUCT) &&
verifier.EndTable();
}
static flatbuffers::Offset<TableInFirstNS> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableInFirstNST* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
};
+template<> inline const NamespaceA::NamespaceB::TableInNestedNS *TableInFirstNS::foo_union_as<NamespaceA::NamespaceB::TableInNestedNS>() const {
+ return foo_union_as_TableInNestedNS();
+}
+
struct TableInFirstNSBuilder {
typedef TableInFirstNS Table;
flatbuffers::FlatBufferBuilder &fbb_;
void add_foo_enum(NamespaceA::NamespaceB::EnumInNestedNS foo_enum) {
fbb_.AddElement<int8_t>(TableInFirstNS::VT_FOO_ENUM, static_cast<int8_t>(foo_enum), 0);
}
+ void add_foo_union_type(NamespaceA::NamespaceB::UnionInNestedNS foo_union_type) {
+ fbb_.AddElement<uint8_t>(TableInFirstNS::VT_FOO_UNION_TYPE, static_cast<uint8_t>(foo_union_type), 0);
+ }
+ void add_foo_union(flatbuffers::Offset<void> foo_union) {
+ fbb_.AddOffset(TableInFirstNS::VT_FOO_UNION, foo_union);
+ }
void add_foo_struct(const NamespaceA::NamespaceB::StructInNestedNS *foo_struct) {
fbb_.AddStruct(TableInFirstNS::VT_FOO_STRUCT, foo_struct);
}
flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<NamespaceA::NamespaceB::TableInNestedNS> foo_table = 0,
NamespaceA::NamespaceB::EnumInNestedNS foo_enum = NamespaceA::NamespaceB::EnumInNestedNS_A,
+ NamespaceA::NamespaceB::UnionInNestedNS foo_union_type = NamespaceA::NamespaceB::UnionInNestedNS_NONE,
+ flatbuffers::Offset<void> foo_union = 0,
const NamespaceA::NamespaceB::StructInNestedNS *foo_struct = 0) {
TableInFirstNSBuilder builder_(_fbb);
builder_.add_foo_struct(foo_struct);
+ builder_.add_foo_union(foo_union);
builder_.add_foo_table(foo_table);
+ builder_.add_foo_union_type(foo_union_type);
builder_.add_foo_enum(foo_enum);
return builder_.Finish();
}
(void)_resolver;
{ auto _e = foo_table(); if (_e) _o->foo_table = flatbuffers::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST>(_e->UnPack(_resolver)); }
{ auto _e = foo_enum(); _o->foo_enum = _e; }
+ { auto _e = foo_union_type(); _o->foo_union.type = _e; }
+ { auto _e = foo_union(); if (_e) _o->foo_union.value = NamespaceA::NamespaceB::UnionInNestedNSUnion::UnPack(_e, foo_union_type(), _resolver); }
{ auto _e = foo_struct(); if (_e) _o->foo_struct = flatbuffers::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS>(new NamespaceA::NamespaceB::StructInNestedNS(*_e)); }
}
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TableInFirstNST* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
auto _foo_table = _o->foo_table ? CreateTableInNestedNS(_fbb, _o->foo_table.get(), _rehasher) : 0;
auto _foo_enum = _o->foo_enum;
+ auto _foo_union_type = _o->foo_union.type;
+ auto _foo_union = _o->foo_union.Pack(_fbb);
auto _foo_struct = _o->foo_struct ? _o->foo_struct.get() : 0;
return NamespaceA::CreateTableInFirstNS(
_fbb,
_foo_table,
_foo_enum,
+ _foo_union_type,
+ _foo_union,
_foo_struct);
}
static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_SEQUENCE, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 1 },
- { flatbuffers::ET_SEQUENCE, 0, 2 }
+ { flatbuffers::ET_UTYPE, 0, 2 },
+ { flatbuffers::ET_SEQUENCE, 0, 2 },
+ { flatbuffers::ET_SEQUENCE, 0, 3 }
};
static const flatbuffers::TypeFunction type_refs[] = {
NamespaceA::NamespaceB::TableInNestedNSTypeTable,
NamespaceA::NamespaceB::EnumInNestedNSTypeTable,
+ NamespaceA::NamespaceB::UnionInNestedNSTypeTable,
NamespaceA::NamespaceB::StructInNestedNSTypeTable
};
static const char * const names[] = {
"foo_table",
"foo_enum",
+ "foo_union_type",
+ "foo_union",
"foo_struct"
};
static const flatbuffers::TypeTable tt = {
- flatbuffers::ST_TABLE, 3, type_codes, type_refs, nullptr, nullptr, names
+ flatbuffers::ST_TABLE, 5, type_codes, type_refs, nullptr, nullptr, names
};
return &tt;
}
return if o: NamespaceA_NamespaceB_TableInNestedNS { buf_, o } else: nil
def foo_enum():
return EnumInNestedNS(buf_.flatbuffers_field_int8(pos_, 6, 0))
+ def foo_union_type():
+ return UnionInNestedNS(buf_.flatbuffers_field_int8(pos_, 8, 0))
+ def foo_union_as_TableInNestedNS():
+ return NamespaceA_NamespaceB_TableInNestedNS { buf_, buf_.flatbuffers_field_table(pos_, 10) }
def foo_struct():
- let o = buf_.flatbuffers_field_struct(pos_, 8)
+ let o = buf_.flatbuffers_field_struct(pos_, 12)
return if o: NamespaceA_NamespaceB_StructInNestedNS { buf_, o } else: nil
def GetRootAsTableInFirstNS(buf:string): return TableInFirstNS { buf, buf.flatbuffers_indirect(0) }
struct TableInFirstNSBuilder:
b_:flatbuffers_builder
def start():
- b_.StartObject(3)
+ b_.StartObject(5)
return this
def add_foo_table(foo_table:flatbuffers_offset):
b_.PrependUOffsetTRelativeSlot(0, foo_table)
def add_foo_enum(foo_enum:EnumInNestedNS):
b_.PrependInt8Slot(1, foo_enum, 0)
return this
+ def add_foo_union_type(foo_union_type:UnionInNestedNS):
+ b_.PrependUint8Slot(2, foo_union_type, 0)
+ return this
+ def add_foo_union(foo_union:flatbuffers_offset):
+ b_.PrependUOffsetTRelativeSlot(3, foo_union)
+ return this
def add_foo_struct(foo_struct:flatbuffers_offset):
- b_.PrependStructSlot(2, foo_struct)
+ b_.PrependStructSlot(4, foo_struct)
return this
def end():
return b_.EndObject()
#![allow(unused_imports, dead_code)]
-use crate::namespace_test1_generated::*;
use std::mem;
use std::cmp::Ordering;
#[allow(unused_imports, dead_code)]
pub mod namespace_a {
- use crate::namespace_test1_generated::*;
use std::mem;
use std::cmp::Ordering;
extern crate flatbuffers;
use self::flatbuffers::EndianScalar;
+#[allow(unused_imports, dead_code)]
+pub mod namespace_b {
+
+ use std::mem;
+ use std::cmp::Ordering;
+
+ extern crate flatbuffers;
+ use self::flatbuffers::EndianScalar;
+
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_UNION_IN_NESTED_NS: u8 = 0;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MAX_UNION_IN_NESTED_NS: u8 = 1;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+#[allow(non_camel_case_types)]
+pub const ENUM_VALUES_UNION_IN_NESTED_NS: [UnionInNestedNS; 2] = [
+ UnionInNestedNS::NONE,
+ UnionInNestedNS::TableInNestedNS,
+];
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
+#[repr(transparent)]
+pub struct UnionInNestedNS(pub u8);
+#[allow(non_upper_case_globals)]
+impl UnionInNestedNS {
+ pub const NONE: Self = Self(0);
+ pub const TableInNestedNS: Self = Self(1);
+
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 1;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::TableInNestedNS,
+ ];
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::TableInNestedNS => Some("TableInNestedNS"),
+ _ => None,
+ }
+ }
+}
+impl std::fmt::Debug for UnionInNestedNS {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for UnionInNestedNS {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
+ Self(b)
+ }
+}
+
+impl flatbuffers::Push for UnionInNestedNS {
+ type Output = UnionInNestedNS;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ flatbuffers::emplace_scalar::<u8>(dst, self.0);
+ }
+}
+
+impl flatbuffers::EndianScalar for UnionInNestedNS {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = u8::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ fn from_little_endian(self) -> Self {
+ let b = u8::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for UnionInNestedNS {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for UnionInNestedNS {}
+pub struct UnionInNestedNSUnionTableOffset {}
+
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub enum UnionInNestedNST {
+ NONE,
+ TableInNestedNS(Box<TableInNestedNST>),
+}
+impl Default for UnionInNestedNST {
+ fn default() -> Self {
+ Self::NONE
+ }
+}
+impl UnionInNestedNST {
+ pub fn union_in_nested_ns_type(&self) -> UnionInNestedNS {
+ match self {
+ Self::NONE => UnionInNestedNS::NONE,
+ Self::TableInNestedNS(_) => UnionInNestedNS::TableInNestedNS,
+ }
+ }
+ pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
+ match self {
+ Self::NONE => None,
+ Self::TableInNestedNS(v) => Some(v.pack(fbb).as_union_value()),
+ }
+ }
+ /// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE.
+ pub fn take_table_in_nested_ns(&mut self) -> Option<Box<TableInNestedNST>> {
+ if let Self::TableInNestedNS(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::TableInNestedNS(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the TableInNestedNST.
+ pub fn as_table_in_nested_ns(&self) -> Option<&TableInNestedNST> {
+ if let Self::TableInNestedNS(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the TableInNestedNST.
+ pub fn as_table_in_nested_ns_mut(&mut self) -> Option<&mut TableInNestedNST> {
+ if let Self::TableInNestedNS(v) = self { Some(v.as_mut()) } else { None }
+ }
+}
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_ENUM_IN_NESTED_NS: i8 = 0;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MAX_ENUM_IN_NESTED_NS: i8 = 2;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+#[allow(non_camel_case_types)]
+pub const ENUM_VALUES_ENUM_IN_NESTED_NS: [EnumInNestedNS; 3] = [
+ EnumInNestedNS::A,
+ EnumInNestedNS::B,
+ EnumInNestedNS::C,
+];
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
+#[repr(transparent)]
+pub struct EnumInNestedNS(pub i8);
+#[allow(non_upper_case_globals)]
+impl EnumInNestedNS {
+ pub const A: Self = Self(0);
+ pub const B: Self = Self(1);
+ pub const C: Self = Self(2);
+
+ pub const ENUM_MIN: i8 = 0;
+ pub const ENUM_MAX: i8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::A,
+ Self::B,
+ Self::C,
+ ];
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::A => Some("A"),
+ Self::B => Some("B"),
+ Self::C => Some("C"),
+ _ => None,
+ }
+ }
+}
+impl std::fmt::Debug for EnumInNestedNS {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for EnumInNestedNS {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = flatbuffers::read_scalar_at::<i8>(buf, loc);
+ Self(b)
+ }
+}
+
+impl flatbuffers::Push for EnumInNestedNS {
+ type Output = EnumInNestedNS;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ flatbuffers::emplace_scalar::<i8>(dst, self.0);
+ }
+}
+
+impl flatbuffers::EndianScalar for EnumInNestedNS {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = i8::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ fn from_little_endian(self) -> Self {
+ let b = i8::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for EnumInNestedNS {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ i8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for EnumInNestedNS {}
+// struct StructInNestedNS, aligned to 4
+#[repr(transparent)]
+#[derive(Clone, Copy, PartialEq, Default)]
+pub struct StructInNestedNS(pub [u8; 8]);
+impl std::fmt::Debug for StructInNestedNS {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ f.debug_struct("StructInNestedNS")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .finish()
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for StructInNestedNS {}
+impl flatbuffers::SafeSliceAccess for StructInNestedNS {}
+impl<'a> flatbuffers::Follow<'a> for StructInNestedNS {
+ type Inner = &'a StructInNestedNS;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ <&'a StructInNestedNS>::follow(buf, loc)
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for &'a StructInNestedNS {
+ type Inner = &'a StructInNestedNS;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ flatbuffers::follow_cast_ref::<StructInNestedNS>(buf, loc)
+ }
+}
+impl<'b> flatbuffers::Push for StructInNestedNS {
+ type Output = StructInNestedNS;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+impl<'b> flatbuffers::Push for &'b StructInNestedNS {
+ type Output = StructInNestedNS;
+
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(*self as *const StructInNestedNS as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for StructInNestedNS {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
+impl StructInNestedNS {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i32,
+ b: i32,
+ ) -> Self {
+ let mut s = Self([0; 8]);
+ s.set_a(a);
+ s.set_b(b);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "NamespaceA.NamespaceB.StructInNestedNS"
+ }
+
+ pub fn a(&self) -> i32 {
+ let mut mem = core::mem::MaybeUninit::<i32>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<i32>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_a(&mut self, x: i32) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const i32 as *const u8,
+ self.0[0..].as_mut_ptr(),
+ core::mem::size_of::<i32>(),
+ );
+ }
+ }
+
+ pub fn b(&self) -> i32 {
+ let mut mem = core::mem::MaybeUninit::<i32>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[4..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<i32>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_b(&mut self, x: i32) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const i32 as *const u8,
+ self.0[4..].as_mut_ptr(),
+ core::mem::size_of::<i32>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> StructInNestedNST {
+ StructInNestedNST {
+ a: self.a(),
+ b: self.b(),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct StructInNestedNST {
+ pub a: i32,
+ pub b: i32,
+}
+impl StructInNestedNST {
+ pub fn pack(&self) -> StructInNestedNS {
+ StructInNestedNS::new(
+ self.a,
+ self.b,
+ )
+ }
+}
+
+pub enum TableInNestedNSOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub struct TableInNestedNS<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for TableInNestedNS<'a> {
+ type Inner = TableInNestedNS<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> TableInNestedNS<'a> {
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "NamespaceA.NamespaceB.TableInNestedNS"
+ }
+
+ #[inline]
+ pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
+ TableInNestedNS { _tab: table }
+ }
+ #[allow(unused_mut)]
+ pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ args: &'args TableInNestedNSArgs) -> flatbuffers::WIPOffset<TableInNestedNS<'bldr>> {
+ let mut builder = TableInNestedNSBuilder::new(_fbb);
+ builder.add_foo(args.foo);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableInNestedNST {
+ let foo = self.foo();
+ TableInNestedNST {
+ foo,
+ }
+ }
+ pub const VT_FOO: flatbuffers::VOffsetT = 4;
+
+ #[inline]
+ pub fn foo(&self) -> i32 {
+ self._tab.get::<i32>(TableInNestedNS::VT_FOO, Some(0)).unwrap()
+ }
+}
+
+impl flatbuffers::Verifiable for TableInNestedNS<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i32>(&"foo", Self::VT_FOO, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct TableInNestedNSArgs {
+ pub foo: i32,
+}
+impl<'a> Default for TableInNestedNSArgs {
+ #[inline]
+ fn default() -> Self {
+ TableInNestedNSArgs {
+ foo: 0,
+ }
+ }
+}
+pub struct TableInNestedNSBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> TableInNestedNSBuilder<'a, 'b> {
+ #[inline]
+ pub fn add_foo(&mut self, foo: i32) {
+ self.fbb_.push_slot::<i32>(TableInNestedNS::VT_FOO, foo, 0);
+ }
+ #[inline]
+ pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TableInNestedNSBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ TableInNestedNSBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<TableInNestedNS<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl std::fmt::Debug for TableInNestedNS<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut ds = f.debug_struct("TableInNestedNS");
+ ds.field("foo", &self.foo());
+ ds.finish()
+ }
+}
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct TableInNestedNST {
+ pub foo: i32,
+}
+impl TableInNestedNST {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<TableInNestedNS<'b>> {
+ let foo = self.foo;
+ TableInNestedNS::create(_fbb, &TableInNestedNSArgs{
+ foo,
+ })
+ }
+}
+} // pub mod NamespaceB
pub enum TableInFirstNSOffset {}
#[derive(Copy, Clone, PartialEq)]
args: &'args TableInFirstNSArgs<'args>) -> flatbuffers::WIPOffset<TableInFirstNS<'bldr>> {
let mut builder = TableInFirstNSBuilder::new(_fbb);
if let Some(x) = args.foo_struct { builder.add_foo_struct(x); }
+ if let Some(x) = args.foo_union { builder.add_foo_union(x); }
if let Some(x) = args.foo_table { builder.add_foo_table(x); }
+ builder.add_foo_union_type(args.foo_union_type);
builder.add_foo_enum(args.foo_enum);
builder.finish()
}
Box::new(x.unpack())
});
let foo_enum = self.foo_enum();
+ let foo_union = match self.foo_union_type() {
+ namespace_b::UnionInNestedNS::NONE => namespace_b::UnionInNestedNST::NONE,
+ namespace_b::UnionInNestedNS::TableInNestedNS => namespace_b::UnionInNestedNST::TableInNestedNS(Box::new(
+ self.foo_union_as_table_in_nested_ns()
+ .expect("Invalid union table, expected `namespace_b::UnionInNestedNS::TableInNestedNS`.")
+ .unpack()
+ )),
+ _ => namespace_b::UnionInNestedNST::NONE,
+ };
let foo_struct = self.foo_struct().map(|x| {
x.unpack()
});
TableInFirstNST {
foo_table,
foo_enum,
+ foo_union,
foo_struct,
}
}
pub const VT_FOO_TABLE: flatbuffers::VOffsetT = 4;
pub const VT_FOO_ENUM: flatbuffers::VOffsetT = 6;
- pub const VT_FOO_STRUCT: flatbuffers::VOffsetT = 8;
+ pub const VT_FOO_UNION_TYPE: flatbuffers::VOffsetT = 8;
+ pub const VT_FOO_UNION: flatbuffers::VOffsetT = 10;
+ pub const VT_FOO_STRUCT: flatbuffers::VOffsetT = 12;
#[inline]
pub fn foo_table(&self) -> Option<namespace_b::TableInNestedNS<'a>> {
self._tab.get::<namespace_b::EnumInNestedNS>(TableInFirstNS::VT_FOO_ENUM, Some(namespace_b::EnumInNestedNS::A)).unwrap()
}
#[inline]
+ pub fn foo_union_type(&self) -> namespace_b::UnionInNestedNS {
+ self._tab.get::<namespace_b::UnionInNestedNS>(TableInFirstNS::VT_FOO_UNION_TYPE, Some(namespace_b::UnionInNestedNS::NONE)).unwrap()
+ }
+ #[inline]
+ pub fn foo_union(&self) -> Option<flatbuffers::Table<'a>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(TableInFirstNS::VT_FOO_UNION, None)
+ }
+ #[inline]
pub fn foo_struct(&self) -> Option<&'a namespace_b::StructInNestedNS> {
self._tab.get::<namespace_b::StructInNestedNS>(TableInFirstNS::VT_FOO_STRUCT, None)
}
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn foo_union_as_table_in_nested_ns(&self) -> Option<namespace_b::TableInNestedNS<'a>> {
+ if self.foo_union_type() == namespace_b::UnionInNestedNS::TableInNestedNS {
+ self.foo_union().map(namespace_b::TableInNestedNS::init_from_table)
+ } else {
+ None
+ }
+ }
+
}
impl flatbuffers::Verifiable for TableInFirstNS<'_> {
v.visit_table(pos)?
.visit_field::<flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>(&"foo_table", Self::VT_FOO_TABLE, false)?
.visit_field::<namespace_b::EnumInNestedNS>(&"foo_enum", Self::VT_FOO_ENUM, false)?
+ .visit_union::<namespace_b::UnionInNestedNS, _>(&"foo_union_type", Self::VT_FOO_UNION_TYPE, &"foo_union", Self::VT_FOO_UNION, false, |key, v, pos| {
+ match key {
+ namespace_b::UnionInNestedNS::TableInNestedNS => v.verify_union_variant::<flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>("namespace_b::UnionInNestedNS::TableInNestedNS", pos),
+ _ => Ok(()),
+ }
+ })?
.visit_field::<namespace_b::StructInNestedNS>(&"foo_struct", Self::VT_FOO_STRUCT, false)?
.finish();
Ok(())
pub struct TableInFirstNSArgs<'a> {
pub foo_table: Option<flatbuffers::WIPOffset<namespace_b::TableInNestedNS<'a>>>,
pub foo_enum: namespace_b::EnumInNestedNS,
+ pub foo_union_type: namespace_b::UnionInNestedNS,
+ pub foo_union: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
pub foo_struct: Option<&'a namespace_b::StructInNestedNS>,
}
impl<'a> Default for TableInFirstNSArgs<'a> {
TableInFirstNSArgs {
foo_table: None,
foo_enum: namespace_b::EnumInNestedNS::A,
+ foo_union_type: namespace_b::UnionInNestedNS::NONE,
+ foo_union: None,
foo_struct: None,
}
}
self.fbb_.push_slot::<namespace_b::EnumInNestedNS>(TableInFirstNS::VT_FOO_ENUM, foo_enum, namespace_b::EnumInNestedNS::A);
}
#[inline]
+ pub fn add_foo_union_type(&mut self, foo_union_type: namespace_b::UnionInNestedNS) {
+ self.fbb_.push_slot::<namespace_b::UnionInNestedNS>(TableInFirstNS::VT_FOO_UNION_TYPE, foo_union_type, namespace_b::UnionInNestedNS::NONE);
+ }
+ #[inline]
+ pub fn add_foo_union(&mut self, foo_union: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
+ self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(TableInFirstNS::VT_FOO_UNION, foo_union);
+ }
+ #[inline]
pub fn add_foo_struct(&mut self, foo_struct: &namespace_b::StructInNestedNS) {
self.fbb_.push_slot_always::<&namespace_b::StructInNestedNS>(TableInFirstNS::VT_FOO_STRUCT, foo_struct);
}
let mut ds = f.debug_struct("TableInFirstNS");
ds.field("foo_table", &self.foo_table());
ds.field("foo_enum", &self.foo_enum());
+ ds.field("foo_union_type", &self.foo_union_type());
+ match self.foo_union_type() {
+ namespace_b::UnionInNestedNS::TableInNestedNS => {
+ if let Some(x) = self.foo_union_as_table_in_nested_ns() {
+ ds.field("foo_union", &x)
+ } else {
+ ds.field("foo_union", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("foo_union", &x)
+ },
+ };
ds.field("foo_struct", &self.foo_struct());
ds.finish()
}
pub struct TableInFirstNST {
pub foo_table: Option<Box<namespace_b::TableInNestedNST>>,
pub foo_enum: namespace_b::EnumInNestedNS,
+ pub foo_union: namespace_b::UnionInNestedNST,
pub foo_struct: Option<namespace_b::StructInNestedNST>,
}
impl TableInFirstNST {
x.pack(_fbb)
});
let foo_enum = self.foo_enum;
+ let foo_union_type = self.foo_union.union_in_nested_ns_type();
+ let foo_union = self.foo_union.pack(_fbb);
let foo_struct_tmp = self.foo_struct.as_ref().map(|x| x.pack());
let foo_struct = foo_struct_tmp.as_ref();
TableInFirstNS::create(_fbb, &TableInFirstNSArgs{
foo_table,
foo_enum,
+ foo_union_type,
+ foo_union,
foo_struct,
})
}
#[allow(unused_imports, dead_code)]
pub mod namespace_c {
- use crate::namespace_test1_generated::*;
use std::mem;
use std::cmp::Ordering;
namespace_a_namespace_b.TableInNestedNS get fooTable => namespace_a_namespace_b.TableInNestedNS.reader.vTableGet(_bc, _bcOffset, 4, null);
EnumInNestedNS get fooEnum => new EnumInNestedNS.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 6, 0));
- namespace_a_namespace_b.StructInNestedNS get fooStruct => namespace_a_namespace_b.StructInNestedNS.reader.vTableGet(_bc, _bcOffset, 8, null);
+ UnionInNestedNSTypeId get fooUnionType => new UnionInNestedNSTypeId.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 8, 0));
+ dynamic get fooUnion {
+ switch (fooUnionType?.value) {
+ case 1: return TableInNestedNS.reader.vTableGet(_bc, _bcOffset, 10, null);
+ default: return null;
+ }
+ }
+ namespace_a_namespace_b.StructInNestedNS get fooStruct => namespace_a_namespace_b.StructInNestedNS.reader.vTableGet(_bc, _bcOffset, 12, null);
@override
String toString() {
- return 'TableInFirstNS{fooTable: $fooTable, fooEnum: $fooEnum, fooStruct: $fooStruct}';
+ return 'TableInFirstNS{fooTable: $fooTable, fooEnum: $fooEnum, fooUnionType: $fooUnionType, fooUnion: $fooUnion, fooStruct: $fooStruct}';
}
}
fbBuilder.addInt8(1, fooEnum?.value);
return fbBuilder.offset;
}
+ int addFooUnionType(UnionInNestedNSTypeId fooUnionType) {
+ fbBuilder.addUint8(2, fooUnionType?.value);
+ return fbBuilder.offset;
+ }
+ int addFooUnionOffset(int offset) {
+ fbBuilder.addOffset(3, offset);
+ return fbBuilder.offset;
+ }
int addFooStruct(int offset) {
- fbBuilder.addStruct(2, offset);
+ fbBuilder.addStruct(4, offset);
return fbBuilder.offset;
}
class TableInFirstNSObjectBuilder extends fb.ObjectBuilder {
final namespace_a_namespace_b.TableInNestedNSObjectBuilder _fooTable;
final EnumInNestedNS _fooEnum;
+ final UnionInNestedNSTypeId _fooUnionType;
+ final dynamic _fooUnion;
final namespace_a_namespace_b.StructInNestedNSObjectBuilder _fooStruct;
TableInFirstNSObjectBuilder({
namespace_a_namespace_b.TableInNestedNSObjectBuilder fooTable,
EnumInNestedNS fooEnum,
+ UnionInNestedNSTypeId fooUnionType,
+ dynamic fooUnion,
namespace_a_namespace_b.StructInNestedNSObjectBuilder fooStruct,
})
: _fooTable = fooTable,
_fooEnum = fooEnum,
+ _fooUnionType = fooUnionType,
+ _fooUnion = fooUnion,
_fooStruct = fooStruct;
/// Finish building, and store into the [fbBuilder].
fb.Builder fbBuilder) {
assert(fbBuilder != null);
final int fooTableOffset = _fooTable?.getOrCreateOffset(fbBuilder);
+ final int fooUnionOffset = _fooUnion?.getOrCreateOffset(fbBuilder);
fbBuilder.startTable();
if (fooTableOffset != null) {
fbBuilder.addOffset(0, fooTableOffset);
}
fbBuilder.addInt8(1, _fooEnum?.value);
+ fbBuilder.addUint8(2, _fooUnionType?.value);
+ if (fooUnionOffset != null) {
+ fbBuilder.addOffset(3, fooUnionOffset);
+ }
if (_fooStruct != null) {
- fbBuilder.addStruct(2, _fooStruct.finish(fbBuilder));
+ fbBuilder.addStruct(4, _fooStruct.finish(fbBuilder));
}
return fbBuilder.endTable();
}
#[path = "../../include_test/sub/include_test2_generated.rs"]
pub mod include_test2_generated;
+#[path = "../../namespace_test/namespace_test1_generated.rs"]
+pub mod namespace_test1_generated;
+
+#[path = "../../namespace_test/namespace_test2_generated.rs"]
+pub mod namespace_test2_generated;
+
#[path = "../../monster_test_generated.rs"]
mod monster_test_generated;
pub use monster_test_generated::my_game;