diff options
-rw-r--r-- | docs/source/Tutorial.md | 36 | ||||
-rw-r--r-- | lobster/flatbuffers.lobster | 1 | ||||
-rw-r--r-- | samples/monster_generated.lobster | 85 | ||||
-rw-r--r-- | samples/sample_binary.lobster | 30 | ||||
-rw-r--r-- | src/idl_gen_lobster.cpp | 25 | ||||
-rw-r--r-- | tests/lobstertest.lobster | 34 | ||||
-rw-r--r-- | tests/monster_test_generated.lobster | 417 | ||||
-rw-r--r-- | tests/namespace_test/namespace_test1_generated.lobster | 16 | ||||
-rw-r--r-- | tests/namespace_test/namespace_test2_generated.lobster | 63 |
9 files changed, 431 insertions, 276 deletions
diff --git a/docs/source/Tutorial.md b/docs/source/Tutorial.md index 14961b77..dc09c181 100644 --- a/docs/source/Tutorial.md +++ b/docs/source/Tutorial.md @@ -815,10 +815,11 @@ our `orc` Monster, lets create some `Weapon`s: a `Sword` and an `Axe`. let weapon_offsets = map(weapon_names) name, i: let ns = builder.CreateString(name) - builder.MyGame_Sample_WeaponStart() - builder.MyGame_Sample_WeaponAddName(ns) - builder.MyGame_Sample_WeaponAddDamage(weapon_damages[i]) - builder.MyGame_Sample_WeaponEnd() + MyGame_Sample_WeaponBuilder { b } + .start() + .add_name(ns) + .add_damage(weapon_damages[i]) + .end() ~~~ </div> <div class="language-rust"> @@ -1503,17 +1504,18 @@ can serialize the monster itself: </div> <div class="language-lobster"> ~~~{.lobster} - builder.MyGame_Sample_MonsterStart() - builder.MyGame_Sample_MonsterAddPos(builder.MyGame_Sample_CreateVec3(1.0, 2.0, 3.0)) - builder.MyGame_Sample_MonsterAddHp(300) - builder.MyGame_Sample_MonsterAddName(name) - builder.MyGame_Sample_MonsterAddInventory(inv) - builder.MyGame_Sample_MonsterAddColor(MyGame_Sample_Color_Red) - builder.MyGame_Sample_MonsterAddWeapons(weapons) - builder.MyGame_Sample_MonsterAddEquippedType(MyGame_Sample_Equipment_Weapon) - builder.MyGame_Sample_MonsterAddEquipped(weapon_offsets[1]) - builder.MyGame_Sample_MonsterAddPath(path) - let orc = builder.MyGame_Sample_MonsterEnd() + let orc = MyGame_Sample_MonsterBuilder { b } + .start() + .add_pos(b.MyGame_Sample_CreateVec3(1.0, 2.0, 3.0)) + .add_hp(300) + .add_name(name) + .add_inventory(inv) + .add_color(MyGame_Sample_Color_Red) + .add_weapons(weapons) + .add_equipped_type(MyGame_Sample_Equipment_Weapon) + .add_equipped(weapon_offsets[1]) + .add_path(path) + .end() ~~~ </div> <div class="language-rust"> @@ -1687,8 +1689,8 @@ Here is a repetition these lines, to help highlight them more clearly: </div> <div class="language-lobster"> ~~~{.lobster} - builder.MyGame_Sample_MonsterAddEquippedType(MyGame_Sample_Equipment_Weapon) - builder.MyGame_Sample_MonsterAddEquipped(axe) + .add_equipped_type(MyGame_Sample_Equipment_Weapon) + .add_equipped(axe) ~~~ </div> <div class="language-rust"> diff --git a/lobster/flatbuffers.lobster b/lobster/flatbuffers.lobster index 40f57832..0f1c15dd 100644 --- a/lobster/flatbuffers.lobster +++ b/lobster/flatbuffers.lobster @@ -282,4 +282,3 @@ class builder: // elsewhere. assert x.o == head Slot(v) - diff --git a/samples/monster_generated.lobster b/samples/monster_generated.lobster index a012d6a9..702cdd42 100644 --- a/samples/monster_generated.lobster +++ b/samples/monster_generated.lobster @@ -64,44 +64,60 @@ class Monster : flatbuffers_handle def GetRootAsMonster(buf:string): return Monster { buf, buf.flatbuffers_indirect(0) } -def MonsterStart(b_:flatbuffers_builder): - b_.StartObject(11) -def MonsterAddPos(b_:flatbuffers_builder, pos:flatbuffers_offset): - b_.PrependStructSlot(0, pos) -def MonsterAddMana(b_:flatbuffers_builder, mana:int): - b_.PrependInt16Slot(1, mana, 150) -def MonsterAddHp(b_:flatbuffers_builder, hp:int): - b_.PrependInt16Slot(2, hp, 100) -def MonsterAddName(b_:flatbuffers_builder, name:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(3, name) -def MonsterAddInventory(b_:flatbuffers_builder, inventory:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(5, inventory) +struct MonsterBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(11) + return this + def add_pos(pos:flatbuffers_offset): + b_.PrependStructSlot(0, pos) + return this + def add_mana(mana:int): + b_.PrependInt16Slot(1, mana, 150) + return this + def add_hp(hp:int): + b_.PrependInt16Slot(2, hp, 100) + return this + def add_name(name:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(3, name) + return this + def add_inventory(inventory:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(5, inventory) + return this + def add_color(color:Color): + b_.PrependInt8Slot(6, color, 2) + return this + def add_weapons(weapons:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(7, weapons) + return this + def add_equipped_type(equipped_type:Equipment): + b_.PrependUint8Slot(8, equipped_type, 0) + return this + def add_equipped(equipped:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(9, equipped) + return this + def add_path(path:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(10, path) + return this + def end(): + return b_.EndObject() + def MonsterStartInventoryVector(b_:flatbuffers_builder, n_:int): b_.StartVector(1, n_, 1) def MonsterCreateInventoryVector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(1, v_.length, 1) reverse(v_) e_: b_.PrependUint8(e_) return b_.EndVector(v_.length) -def MonsterAddColor(b_:flatbuffers_builder, color:Color): - b_.PrependInt8Slot(6, color, 2) -def MonsterAddWeapons(b_:flatbuffers_builder, weapons:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(7, weapons) + def MonsterStartWeaponsVector(b_:flatbuffers_builder, n_:int): b_.StartVector(4, n_, 4) def MonsterCreateWeaponsVector(b_:flatbuffers_builder, v_:[flatbuffers_offset]): b_.StartVector(4, v_.length, 4) reverse(v_) e_: b_.PrependUOffsetTRelative(e_) return b_.EndVector(v_.length) -def MonsterAddEquippedType(b_:flatbuffers_builder, equipped_type:Equipment): - b_.PrependUint8Slot(8, equipped_type, 0) -def MonsterAddEquipped(b_:flatbuffers_builder, equipped:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(9, equipped) -def MonsterAddPath(b_:flatbuffers_builder, path:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(10, path) + def MonsterStartPathVector(b_:flatbuffers_builder, n_:int): b_.StartVector(12, n_, 4) -def MonsterEnd(b_:flatbuffers_builder): - return b_.EndObject() class Weapon : flatbuffers_handle def name(): @@ -111,12 +127,17 @@ class Weapon : flatbuffers_handle def GetRootAsWeapon(buf:string): return Weapon { buf, buf.flatbuffers_indirect(0) } -def WeaponStart(b_:flatbuffers_builder): - b_.StartObject(2) -def WeaponAddName(b_:flatbuffers_builder, name:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(0, name) -def WeaponAddDamage(b_:flatbuffers_builder, damage:int): - b_.PrependInt16Slot(1, damage, 0) -def WeaponEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct WeaponBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(2) + return this + def add_name(name:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(0, name) + return this + def add_damage(damage:int): + b_.PrependInt16Slot(1, damage, 0) + return this + def end(): + return b_.EndObject() diff --git a/samples/sample_binary.lobster b/samples/sample_binary.lobster index ae3dbe1d..cd7adab2 100644 --- a/samples/sample_binary.lobster +++ b/samples/sample_binary.lobster @@ -26,10 +26,11 @@ let weapon_damages = [ 3, 5 ] let weapon_offsets = map(weapon_names) name, i: let ns = b.CreateString(name) - b.MyGame_Sample_WeaponStart() - b.MyGame_Sample_WeaponAddName(ns) - b.MyGame_Sample_WeaponAddDamage(weapon_damages[i]) - b.MyGame_Sample_WeaponEnd() + MyGame_Sample_WeaponBuilder { b } + .start() + .add_name(ns) + .add_damage(weapon_damages[i]) + .end() let weapons = b.MyGame_Sample_MonsterCreateWeaponsVector(weapon_offsets) @@ -40,16 +41,17 @@ let name = b.CreateString("Orc") let inv = b.MyGame_Sample_MonsterCreateInventoryVector(map(10): _) // Now pack it all together in our root monster object. -b.MyGame_Sample_MonsterStart() -b.MyGame_Sample_MonsterAddPos(b.MyGame_Sample_CreateVec3(1.0, 2.0, 3.0)) -b.MyGame_Sample_MonsterAddHp(300) -b.MyGame_Sample_MonsterAddName(name) -b.MyGame_Sample_MonsterAddInventory(inv) -b.MyGame_Sample_MonsterAddColor(MyGame_Sample_Color_Red) -b.MyGame_Sample_MonsterAddWeapons(weapons) -b.MyGame_Sample_MonsterAddEquippedType(MyGame_Sample_Equipment_Weapon) -b.MyGame_Sample_MonsterAddEquipped(weapon_offsets[1]) -let orc = b.MyGame_Sample_MonsterEnd() +let orc = MyGame_Sample_MonsterBuilder { b } + .start() + .add_pos(b.MyGame_Sample_CreateVec3(1.0, 2.0, 3.0)) + .add_hp(300) + .add_name(name) + .add_inventory(inv) + .add_color(MyGame_Sample_Color_Red) + .add_weapons(weapons) + .add_equipped_type(MyGame_Sample_Equipment_Weapon) + .add_equipped(weapon_offsets[1]) + .end() // Finish the buffer! b.Finish(orc) diff --git a/src/idl_gen_lobster.cpp b/src/idl_gen_lobster.cpp index 71a35af7..9a8214c6 100644 --- a/src/idl_gen_lobster.cpp +++ b/src/idl_gen_lobster.cpp @@ -180,22 +180,28 @@ class LobsterGenerator : public BaseGenerator { void GenTableBuilders(const StructDef &struct_def, std::string *code_ptr) { std::string &code = *code_ptr; - code += "def " + NormalizedName(struct_def) + - "Start(b_:flatbuffers_builder):\n b_.StartObject(" + - NumToString(struct_def.fields.vec.size()) + ")\n"; + code += "struct " + NormalizedName(struct_def) + + "Builder:\n b_:flatbuffers_builder\n"; + code += " def start():\n b_.StartObject(" + + NumToString(struct_def.fields.vec.size()) + ")\n return this\n"; for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { + it != struct_def.fields.vec.end(); ++it) { auto &field = **it; if (field.deprecated) continue; auto offset = it - struct_def.fields.vec.begin(); - code += "def " + NormalizedName(struct_def) + "Add" + - MakeCamel(NormalizedName(field)) + "(b_:flatbuffers_builder, " + + code += " def add_" + NormalizedName(field) + "(" + NormalizedName(field) + ":" + LobsterType(field.value.type) + - "):\n b_.Prepend" + GenMethod(field.value.type) + "Slot(" + + "):\n b_.Prepend" + GenMethod(field.value.type) + "Slot(" + NumToString(offset) + ", " + NormalizedName(field); if (IsScalar(field.value.type.base_type)) code += ", " + field.value.constant; - code += ")\n"; + code += ")\n return this\n"; + } + code += " def end():\n return b_.EndObject()\n\n"; + for (auto it = struct_def.fields.vec.begin(); + it != struct_def.fields.vec.end(); ++it) { + auto &field = **it; + if (field.deprecated) continue; if (field.value.type.base_type == BASE_TYPE_VECTOR) { code += "def " + NormalizedName(struct_def) + "Start" + MakeCamel(NormalizedName(field)) + @@ -217,10 +223,9 @@ class LobsterGenerator : public BaseGenerator { GenMethod(vector_type) + "(e_)\n return b_.EndVector(v_.length)\n"; } + code += "\n"; } } - code += "def " + NormalizedName(struct_def) + - "End(b_:flatbuffers_builder):\n return b_.EndObject()\n\n"; } void GenStructPreDecl(const StructDef &struct_def, std::string *code_ptr) { diff --git a/tests/lobstertest.lobster b/tests/lobstertest.lobster index bfd8347b..7ea9b388 100644 --- a/tests/lobstertest.lobster +++ b/tests/lobstertest.lobster @@ -70,9 +70,10 @@ def make_monster_from_generated_code(): let inv = b.MyGame_Example_MonsterCreateInventoryVector([ 0, 1, 2, 3, 4 ]) - b.MyGame_Example_MonsterStart() - b.MyGame_Example_MonsterAddName(fred) - let mon2 = b.MyGame_Example_MonsterEnd() + let mon2 = MyGame_Example_MonsterBuilder { b } + .start() + .add_name(fred) + .end() b.MyGame_Example_MonsterStartTest4Vector(2) b.MyGame_Example_CreateTest(10, 20) @@ -88,19 +89,20 @@ def make_monster_from_generated_code(): let vector_of_doubles = b.MyGame_Example_MonsterCreateVectorOfDoublesVector( [ -1.7976931348623157e+308, 0, 1.7976931348623157e+308 ]) - b.MyGame_Example_MonsterStart() - b.MyGame_Example_MonsterAddPos(b.MyGame_Example_CreateVec3(1.0, 2.0, 3.0, 3.0, - MyGame_Example_Color_Green, 5, 6)) - b.MyGame_Example_MonsterAddHp(80) - b.MyGame_Example_MonsterAddName(name) - b.MyGame_Example_MonsterAddInventory(inv) - b.MyGame_Example_MonsterAddTestType(MyGame_Example_Any_Monster) - b.MyGame_Example_MonsterAddTest(mon2) - b.MyGame_Example_MonsterAddTest4(test4) - b.MyGame_Example_MonsterAddTestarrayofstring(test_array_of_string) - b.MyGame_Example_MonsterAddVectorOfLongs(vector_of_longs) - b.MyGame_Example_MonsterAddVectorOfDoubles(vector_of_doubles) - let mon = b.MyGame_Example_MonsterEnd() + let mon = MyGame_Example_MonsterBuilder { b } + .start() + .add_pos(b.MyGame_Example_CreateVec3(1.0, 2.0, 3.0, 3.0, + MyGame_Example_Color_Green, 5, 6)) + .add_hp(80) + .add_name(name) + .add_inventory(inv) + .add_test_type(MyGame_Example_Any_Monster) + .add_test(mon2) + .add_test4(test4) + .add_testarrayofstring(test_array_of_string) + .add_vector_of_longs(vector_of_longs) + .add_vector_of_doubles(vector_of_doubles) + .end() b.Finish(mon) diff --git a/tests/monster_test_generated.lobster b/tests/monster_test_generated.lobster index fb5b0901..4b92a895 100644 --- a/tests/monster_test_generated.lobster +++ b/tests/monster_test_generated.lobster @@ -58,10 +58,13 @@ class InParentNamespace : flatbuffers_handle def GetRootAsInParentNamespace(buf:string): return InParentNamespace { buf, buf.flatbuffers_indirect(0) } -def InParentNamespaceStart(b_:flatbuffers_builder): - b_.StartObject(0) -def InParentNamespaceEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct InParentNamespaceBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(0) + return this + def end(): + return b_.EndObject() namespace MyGame_Example2 @@ -69,10 +72,13 @@ class Monster : flatbuffers_handle def GetRootAsMonster(buf:string): return Monster { buf, buf.flatbuffers_indirect(0) } -def MonsterStart(b_:flatbuffers_builder): - b_.StartObject(0) -def MonsterEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct MonsterBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(0) + return this + def end(): + return b_.EndObject() namespace MyGame_Example @@ -95,12 +101,16 @@ class TestSimpleTableWithEnum : flatbuffers_handle def GetRootAsTestSimpleTableWithEnum(buf:string): return TestSimpleTableWithEnum { buf, buf.flatbuffers_indirect(0) } -def TestSimpleTableWithEnumStart(b_:flatbuffers_builder): - b_.StartObject(1) -def TestSimpleTableWithEnumAddColor(b_:flatbuffers_builder, color:Color): - b_.PrependUint8Slot(0, color, 2) -def TestSimpleTableWithEnumEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct TestSimpleTableWithEnumBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(1) + return this + def add_color(color:Color): + b_.PrependUint8Slot(0, color, 2) + return this + def end(): + return b_.EndObject() class Vec3 : flatbuffers_handle def x(): @@ -154,16 +164,22 @@ class Stat : flatbuffers_handle def GetRootAsStat(buf:string): return Stat { buf, buf.flatbuffers_indirect(0) } -def StatStart(b_:flatbuffers_builder): - b_.StartObject(3) -def StatAddId(b_:flatbuffers_builder, id:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(0, id) -def StatAddVal(b_:flatbuffers_builder, val:int): - b_.PrependInt64Slot(1, val, 0) -def StatAddCount(b_:flatbuffers_builder, count:int): - b_.PrependUint16Slot(2, count, 0) -def StatEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct StatBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(3) + return this + def add_id(id:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(0, id) + return this + def add_val(val:int): + b_.PrependInt64Slot(1, val, 0) + return this + def add_count(count:int): + b_.PrependUint16Slot(2, count, 0) + return this + def end(): + return b_.EndObject() class Referrable : flatbuffers_handle def id(): @@ -171,12 +187,16 @@ class Referrable : flatbuffers_handle def GetRootAsReferrable(buf:string): return Referrable { buf, buf.flatbuffers_indirect(0) } -def ReferrableStart(b_:flatbuffers_builder): - b_.StartObject(1) -def ReferrableAddId(b_:flatbuffers_builder, id:int): - b_.PrependUint64Slot(0, id, 0) -def ReferrableEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct ReferrableBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(1) + return this + def add_id(id:int): + b_.PrependUint64Slot(0, id, 0) + return this + def end(): + return b_.EndObject() /// an example documentation comment: monster object class Monster : flatbuffers_handle @@ -331,200 +351,268 @@ class Monster : flatbuffers_handle def GetRootAsMonster(buf:string): return Monster { buf, buf.flatbuffers_indirect(0) } -def MonsterStart(b_:flatbuffers_builder): - b_.StartObject(48) -def MonsterAddPos(b_:flatbuffers_builder, pos:flatbuffers_offset): - b_.PrependStructSlot(0, pos) -def MonsterAddMana(b_:flatbuffers_builder, mana:int): - b_.PrependInt16Slot(1, mana, 150) -def MonsterAddHp(b_:flatbuffers_builder, hp:int): - b_.PrependInt16Slot(2, hp, 100) -def MonsterAddName(b_:flatbuffers_builder, name:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(3, name) -def MonsterAddInventory(b_:flatbuffers_builder, inventory:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(5, inventory) +struct MonsterBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(48) + return this + def add_pos(pos:flatbuffers_offset): + b_.PrependStructSlot(0, pos) + return this + def add_mana(mana:int): + b_.PrependInt16Slot(1, mana, 150) + return this + def add_hp(hp:int): + b_.PrependInt16Slot(2, hp, 100) + return this + def add_name(name:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(3, name) + return this + def add_inventory(inventory:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(5, inventory) + return this + def add_color(color:Color): + b_.PrependUint8Slot(6, color, 8) + return this + def add_test_type(test_type:Any): + b_.PrependUint8Slot(7, test_type, 0) + return this + def add_test(test:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(8, test) + return this + def add_test4(test4:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(9, test4) + return this + def add_testarrayofstring(testarrayofstring:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(10, testarrayofstring) + return this + def add_testarrayoftables(testarrayoftables:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(11, testarrayoftables) + return this + def add_enemy(enemy:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(12, enemy) + return this + def add_testnestedflatbuffer(testnestedflatbuffer:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(13, testnestedflatbuffer) + return this + def add_testempty(testempty:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(14, testempty) + return this + def add_testbool(testbool:int): + b_.PrependBoolSlot(15, testbool, 0) + return this + def add_testhashs32_fnv1(testhashs32_fnv1:int): + b_.PrependInt32Slot(16, testhashs32_fnv1, 0) + return this + def add_testhashu32_fnv1(testhashu32_fnv1:int): + b_.PrependUint32Slot(17, testhashu32_fnv1, 0) + return this + def add_testhashs64_fnv1(testhashs64_fnv1:int): + b_.PrependInt64Slot(18, testhashs64_fnv1, 0) + return this + def add_testhashu64_fnv1(testhashu64_fnv1:int): + b_.PrependUint64Slot(19, testhashu64_fnv1, 0) + return this + def add_testhashs32_fnv1a(testhashs32_fnv1a:int): + b_.PrependInt32Slot(20, testhashs32_fnv1a, 0) + return this + def add_testhashu32_fnv1a(testhashu32_fnv1a:int): + b_.PrependUint32Slot(21, testhashu32_fnv1a, 0) + return this + def add_testhashs64_fnv1a(testhashs64_fnv1a:int): + b_.PrependInt64Slot(22, testhashs64_fnv1a, 0) + return this + def add_testhashu64_fnv1a(testhashu64_fnv1a:int): + b_.PrependUint64Slot(23, testhashu64_fnv1a, 0) + return this + def add_testarrayofbools(testarrayofbools:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(24, testarrayofbools) + return this + def add_testf(testf:float): + b_.PrependFloat32Slot(25, testf, 3.14159) + return this + def add_testf2(testf2:float): + b_.PrependFloat32Slot(26, testf2, 3.0) + return this + def add_testf3(testf3:float): + b_.PrependFloat32Slot(27, testf3, 0.0) + return this + def add_testarrayofstring2(testarrayofstring2:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(28, testarrayofstring2) + return this + def add_testarrayofsortedstruct(testarrayofsortedstruct:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(29, testarrayofsortedstruct) + return this + def add_flex(flex:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(30, flex) + return this + def add_test5(test5:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(31, test5) + return this + def add_vector_of_longs(vector_of_longs:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(32, vector_of_longs) + return this + def add_vector_of_doubles(vector_of_doubles:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(33, vector_of_doubles) + return this + def add_parent_namespace_test(parent_namespace_test:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(34, parent_namespace_test) + return this + def add_vector_of_referrables(vector_of_referrables:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(35, vector_of_referrables) + return this + def add_single_weak_reference(single_weak_reference:int): + b_.PrependUint64Slot(36, single_weak_reference, 0) + return this + def add_vector_of_weak_references(vector_of_weak_references:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(37, vector_of_weak_references) + return this + def add_vector_of_strong_referrables(vector_of_strong_referrables:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(38, vector_of_strong_referrables) + return this + def add_co_owning_reference(co_owning_reference:int): + b_.PrependUint64Slot(39, co_owning_reference, 0) + return this + def add_vector_of_co_owning_references(vector_of_co_owning_references:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(40, vector_of_co_owning_references) + return this + def add_non_owning_reference(non_owning_reference:int): + b_.PrependUint64Slot(41, non_owning_reference, 0) + return this + def add_vector_of_non_owning_references(vector_of_non_owning_references:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(42, vector_of_non_owning_references) + return this + def add_any_unique_type(any_unique_type:AnyUniqueAliases): + b_.PrependUint8Slot(43, any_unique_type, 0) + return this + def add_any_unique(any_unique:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(44, any_unique) + return this + def add_any_ambiguous_type(any_ambiguous_type:AnyAmbiguousAliases): + b_.PrependUint8Slot(45, any_ambiguous_type, 0) + return this + def add_any_ambiguous(any_ambiguous:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(46, any_ambiguous) + return this + def add_vector_of_enums(vector_of_enums:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(47, vector_of_enums) + return this + def end(): + return b_.EndObject() + def MonsterStartInventoryVector(b_:flatbuffers_builder, n_:int): b_.StartVector(1, n_, 1) def MonsterCreateInventoryVector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(1, v_.length, 1) reverse(v_) e_: b_.PrependUint8(e_) return b_.EndVector(v_.length) -def MonsterAddColor(b_:flatbuffers_builder, color:Color): - b_.PrependUint8Slot(6, color, 8) -def MonsterAddTestType(b_:flatbuffers_builder, test_type:Any): - b_.PrependUint8Slot(7, test_type, 0) -def MonsterAddTest(b_:flatbuffers_builder, test:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(8, test) -def MonsterAddTest4(b_:flatbuffers_builder, test4:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(9, test4) + def MonsterStartTest4Vector(b_:flatbuffers_builder, n_:int): b_.StartVector(4, n_, 2) -def MonsterAddTestarrayofstring(b_:flatbuffers_builder, testarrayofstring:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(10, testarrayofstring) + def MonsterStartTestarrayofstringVector(b_:flatbuffers_builder, n_:int): b_.StartVector(4, n_, 4) def MonsterCreateTestarrayofstringVector(b_:flatbuffers_builder, v_:[flatbuffers_offset]): b_.StartVector(4, v_.length, 4) reverse(v_) e_: b_.PrependUOffsetTRelative(e_) return b_.EndVector(v_.length) -def MonsterAddTestarrayoftables(b_:flatbuffers_builder, testarrayoftables:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(11, testarrayoftables) + def MonsterStartTestarrayoftablesVector(b_:flatbuffers_builder, n_:int): b_.StartVector(4, n_, 4) def MonsterCreateTestarrayoftablesVector(b_:flatbuffers_builder, v_:[flatbuffers_offset]): b_.StartVector(4, v_.length, 4) reverse(v_) e_: b_.PrependUOffsetTRelative(e_) return b_.EndVector(v_.length) -def MonsterAddEnemy(b_:flatbuffers_builder, enemy:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(12, enemy) -def MonsterAddTestnestedflatbuffer(b_:flatbuffers_builder, testnestedflatbuffer:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(13, testnestedflatbuffer) + def MonsterStartTestnestedflatbufferVector(b_:flatbuffers_builder, n_:int): b_.StartVector(1, n_, 1) def MonsterCreateTestnestedflatbufferVector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(1, v_.length, 1) reverse(v_) e_: b_.PrependUint8(e_) return b_.EndVector(v_.length) -def MonsterAddTestempty(b_:flatbuffers_builder, testempty:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(14, testempty) -def MonsterAddTestbool(b_:flatbuffers_builder, testbool:int): - b_.PrependBoolSlot(15, testbool, 0) -def MonsterAddTesthashs32Fnv1(b_:flatbuffers_builder, testhashs32_fnv1:int): - b_.PrependInt32Slot(16, testhashs32_fnv1, 0) -def MonsterAddTesthashu32Fnv1(b_:flatbuffers_builder, testhashu32_fnv1:int): - b_.PrependUint32Slot(17, testhashu32_fnv1, 0) -def MonsterAddTesthashs64Fnv1(b_:flatbuffers_builder, testhashs64_fnv1:int): - b_.PrependInt64Slot(18, testhashs64_fnv1, 0) -def MonsterAddTesthashu64Fnv1(b_:flatbuffers_builder, testhashu64_fnv1:int): - b_.PrependUint64Slot(19, testhashu64_fnv1, 0) -def MonsterAddTesthashs32Fnv1a(b_:flatbuffers_builder, testhashs32_fnv1a:int): - b_.PrependInt32Slot(20, testhashs32_fnv1a, 0) -def MonsterAddTesthashu32Fnv1a(b_:flatbuffers_builder, testhashu32_fnv1a:int): - b_.PrependUint32Slot(21, testhashu32_fnv1a, 0) -def MonsterAddTesthashs64Fnv1a(b_:flatbuffers_builder, testhashs64_fnv1a:int): - b_.PrependInt64Slot(22, testhashs64_fnv1a, 0) -def MonsterAddTesthashu64Fnv1a(b_:flatbuffers_builder, testhashu64_fnv1a:int): - b_.PrependUint64Slot(23, testhashu64_fnv1a, 0) -def MonsterAddTestarrayofbools(b_:flatbuffers_builder, testarrayofbools:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(24, testarrayofbools) + def MonsterStartTestarrayofboolsVector(b_:flatbuffers_builder, n_:int): b_.StartVector(1, n_, 1) def MonsterCreateTestarrayofboolsVector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(1, v_.length, 1) reverse(v_) e_: b_.PrependBool(e_) return b_.EndVector(v_.length) -def MonsterAddTestf(b_:flatbuffers_builder, testf:float): - b_.PrependFloat32Slot(25, testf, 3.14159) -def MonsterAddTestf2(b_:flatbuffers_builder, testf2:float): - b_.PrependFloat32Slot(26, testf2, 3.0) -def MonsterAddTestf3(b_:flatbuffers_builder, testf3:float): - b_.PrependFloat32Slot(27, testf3, 0.0) -def MonsterAddTestarrayofstring2(b_:flatbuffers_builder, testarrayofstring2:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(28, testarrayofstring2) + def MonsterStartTestarrayofstring2Vector(b_:flatbuffers_builder, n_:int): b_.StartVector(4, n_, 4) def MonsterCreateTestarrayofstring2Vector(b_:flatbuffers_builder, v_:[flatbuffers_offset]): b_.StartVector(4, v_.length, 4) reverse(v_) e_: b_.PrependUOffsetTRelative(e_) return b_.EndVector(v_.length) -def MonsterAddTestarrayofsortedstruct(b_:flatbuffers_builder, testarrayofsortedstruct:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(29, testarrayofsortedstruct) + def MonsterStartTestarrayofsortedstructVector(b_:flatbuffers_builder, n_:int): b_.StartVector(8, n_, 4) -def MonsterAddFlex(b_:flatbuffers_builder, flex:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(30, flex) + def MonsterStartFlexVector(b_:flatbuffers_builder, n_:int): b_.StartVector(1, n_, 1) def MonsterCreateFlexVector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(1, v_.length, 1) reverse(v_) e_: b_.PrependUint8(e_) return b_.EndVector(v_.length) -def MonsterAddTest5(b_:flatbuffers_builder, test5:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(31, test5) + def MonsterStartTest5Vector(b_:flatbuffers_builder, n_:int): b_.StartVector(4, n_, 2) -def MonsterAddVectorOfLongs(b_:flatbuffers_builder, vector_of_longs:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(32, vector_of_longs) + def MonsterStartVectorOfLongsVector(b_:flatbuffers_builder, n_:int): b_.StartVector(8, n_, 8) def MonsterCreateVectorOfLongsVector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(8, v_.length, 8) reverse(v_) e_: b_.PrependInt64(e_) return b_.EndVector(v_.length) -def MonsterAddVectorOfDoubles(b_:flatbuffers_builder, vector_of_doubles:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(33, vector_of_doubles) + def MonsterStartVectorOfDoublesVector(b_:flatbuffers_builder, n_:int): b_.StartVector(8, n_, 8) def MonsterCreateVectorOfDoublesVector(b_:flatbuffers_builder, v_:[float]): b_.StartVector(8, v_.length, 8) reverse(v_) e_: b_.PrependFloat64(e_) return b_.EndVector(v_.length) -def MonsterAddParentNamespaceTest(b_:flatbuffers_builder, parent_namespace_test:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(34, parent_namespace_test) -def MonsterAddVectorOfReferrables(b_:flatbuffers_builder, vector_of_referrables:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(35, vector_of_referrables) + def MonsterStartVectorOfReferrablesVector(b_:flatbuffers_builder, n_:int): b_.StartVector(4, n_, 4) def MonsterCreateVectorOfReferrablesVector(b_:flatbuffers_builder, v_:[flatbuffers_offset]): b_.StartVector(4, v_.length, 4) reverse(v_) e_: b_.PrependUOffsetTRelative(e_) return b_.EndVector(v_.length) -def MonsterAddSingleWeakReference(b_:flatbuffers_builder, single_weak_reference:int): - b_.PrependUint64Slot(36, single_weak_reference, 0) -def MonsterAddVectorOfWeakReferences(b_:flatbuffers_builder, vector_of_weak_references:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(37, vector_of_weak_references) + def MonsterStartVectorOfWeakReferencesVector(b_:flatbuffers_builder, n_:int): b_.StartVector(8, n_, 8) def MonsterCreateVectorOfWeakReferencesVector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(8, v_.length, 8) reverse(v_) e_: b_.PrependUint64(e_) return b_.EndVector(v_.length) -def MonsterAddVectorOfStrongReferrables(b_:flatbuffers_builder, vector_of_strong_referrables:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(38, vector_of_strong_referrables) + def MonsterStartVectorOfStrongReferrablesVector(b_:flatbuffers_builder, n_:int): b_.StartVector(4, n_, 4) def MonsterCreateVectorOfStrongReferrablesVector(b_:flatbuffers_builder, v_:[flatbuffers_offset]): b_.StartVector(4, v_.length, 4) reverse(v_) e_: b_.PrependUOffsetTRelative(e_) return b_.EndVector(v_.length) -def MonsterAddCoOwningReference(b_:flatbuffers_builder, co_owning_reference:int): - b_.PrependUint64Slot(39, co_owning_reference, 0) -def MonsterAddVectorOfCoOwningReferences(b_:flatbuffers_builder, vector_of_co_owning_references:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(40, vector_of_co_owning_references) + def MonsterStartVectorOfCoOwningReferencesVector(b_:flatbuffers_builder, n_:int): b_.StartVector(8, n_, 8) def MonsterCreateVectorOfCoOwningReferencesVector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(8, v_.length, 8) reverse(v_) e_: b_.PrependUint64(e_) return b_.EndVector(v_.length) -def MonsterAddNonOwningReference(b_:flatbuffers_builder, non_owning_reference:int): - b_.PrependUint64Slot(41, non_owning_reference, 0) -def MonsterAddVectorOfNonOwningReferences(b_:flatbuffers_builder, vector_of_non_owning_references:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(42, vector_of_non_owning_references) + def MonsterStartVectorOfNonOwningReferencesVector(b_:flatbuffers_builder, n_:int): b_.StartVector(8, n_, 8) def MonsterCreateVectorOfNonOwningReferencesVector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(8, v_.length, 8) reverse(v_) e_: b_.PrependUint64(e_) return b_.EndVector(v_.length) -def MonsterAddAnyUniqueType(b_:flatbuffers_builder, any_unique_type:AnyUniqueAliases): - b_.PrependUint8Slot(43, any_unique_type, 0) -def MonsterAddAnyUnique(b_:flatbuffers_builder, any_unique:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(44, any_unique) -def MonsterAddAnyAmbiguousType(b_:flatbuffers_builder, any_ambiguous_type:AnyAmbiguousAliases): - b_.PrependUint8Slot(45, any_ambiguous_type, 0) -def MonsterAddAnyAmbiguous(b_:flatbuffers_builder, any_ambiguous:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(46, any_ambiguous) -def MonsterAddVectorOfEnums(b_:flatbuffers_builder, vector_of_enums:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(47, vector_of_enums) + def MonsterStartVectorOfEnumsVector(b_:flatbuffers_builder, n_:int): b_.StartVector(1, n_, 1) def MonsterCreateVectorOfEnumsVector(b_:flatbuffers_builder, v_:[Color]): b_.StartVector(1, v_.length, 1) reverse(v_) e_: b_.PrependUint8(e_) return b_.EndVector(v_.length) -def MonsterEnd(b_:flatbuffers_builder): - return b_.EndObject() class TypeAliases : flatbuffers_handle def i8(): @@ -558,44 +646,61 @@ class TypeAliases : flatbuffers_handle def GetRootAsTypeAliases(buf:string): return TypeAliases { buf, buf.flatbuffers_indirect(0) } -def TypeAliasesStart(b_:flatbuffers_builder): - b_.StartObject(12) -def TypeAliasesAddI8(b_:flatbuffers_builder, i8:int): - b_.PrependInt8Slot(0, i8, 0) -def TypeAliasesAddU8(b_:flatbuffers_builder, u8:int): - b_.PrependUint8Slot(1, u8, 0) -def TypeAliasesAddI16(b_:flatbuffers_builder, i16:int): - b_.PrependInt16Slot(2, i16, 0) -def TypeAliasesAddU16(b_:flatbuffers_builder, u16:int): - b_.PrependUint16Slot(3, u16, 0) -def TypeAliasesAddI32(b_:flatbuffers_builder, i32:int): - b_.PrependInt32Slot(4, i32, 0) -def TypeAliasesAddU32(b_:flatbuffers_builder, u32:int): - b_.PrependUint32Slot(5, u32, 0) -def TypeAliasesAddI64(b_:flatbuffers_builder, i64:int): - b_.PrependInt64Slot(6, i64, 0) -def TypeAliasesAddU64(b_:flatbuffers_builder, u64:int): - b_.PrependUint64Slot(7, u64, 0) -def TypeAliasesAddF32(b_:flatbuffers_builder, f32:float): - b_.PrependFloat32Slot(8, f32, 0.0) -def TypeAliasesAddF64(b_:flatbuffers_builder, f64:float): - b_.PrependFloat64Slot(9, f64, 0.0) -def TypeAliasesAddV8(b_:flatbuffers_builder, v8:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(10, v8) +struct TypeAliasesBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(12) + return this + def add_i8(i8:int): + b_.PrependInt8Slot(0, i8, 0) + return this + def add_u8(u8:int): + b_.PrependUint8Slot(1, u8, 0) + return this + def add_i16(i16:int): + b_.PrependInt16Slot(2, i16, 0) + return this + def add_u16(u16:int): + b_.PrependUint16Slot(3, u16, 0) + return this + def add_i32(i32:int): + b_.PrependInt32Slot(4, i32, 0) + return this + def add_u32(u32:int): + b_.PrependUint32Slot(5, u32, 0) + return this + def add_i64(i64:int): + b_.PrependInt64Slot(6, i64, 0) + return this + def add_u64(u64:int): + b_.PrependUint64Slot(7, u64, 0) + return this + def add_f32(f32:float): + b_.PrependFloat32Slot(8, f32, 0.0) + return this + def add_f64(f64:float): + b_.PrependFloat64Slot(9, f64, 0.0) + return this + def add_v8(v8:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(10, v8) + return this + def add_vf64(vf64:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(11, vf64) + return this + def end(): + return b_.EndObject() + def TypeAliasesStartV8Vector(b_:flatbuffers_builder, n_:int): b_.StartVector(1, n_, 1) def TypeAliasesCreateV8Vector(b_:flatbuffers_builder, v_:[int]): b_.StartVector(1, v_.length, 1) reverse(v_) e_: b_.PrependInt8(e_) return b_.EndVector(v_.length) -def TypeAliasesAddVf64(b_:flatbuffers_builder, vf64:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(11, vf64) + def TypeAliasesStartVf64Vector(b_:flatbuffers_builder, n_:int): b_.StartVector(8, n_, 8) def TypeAliasesCreateVf64Vector(b_:flatbuffers_builder, v_:[float]): b_.StartVector(8, v_.length, 8) reverse(v_) e_: b_.PrependFloat64(e_) return b_.EndVector(v_.length) -def TypeAliasesEnd(b_:flatbuffers_builder): - return b_.EndObject() diff --git a/tests/namespace_test/namespace_test1_generated.lobster b/tests/namespace_test/namespace_test1_generated.lobster index 42b0859e..65030059 100644 --- a/tests/namespace_test/namespace_test1_generated.lobster +++ b/tests/namespace_test/namespace_test1_generated.lobster @@ -18,12 +18,16 @@ class TableInNestedNS : flatbuffers_handle def GetRootAsTableInNestedNS(buf:string): return TableInNestedNS { buf, buf.flatbuffers_indirect(0) } -def TableInNestedNSStart(b_:flatbuffers_builder): - b_.StartObject(1) -def TableInNestedNSAddFoo(b_:flatbuffers_builder, foo:int): - b_.PrependInt32Slot(0, foo, 0) -def TableInNestedNSEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct TableInNestedNSBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(1) + return this + def add_foo(foo:int): + b_.PrependInt32Slot(0, foo, 0) + return this + def end(): + return b_.EndObject() class StructInNestedNS : flatbuffers_handle def a(): diff --git a/tests/namespace_test/namespace_test2_generated.lobster b/tests/namespace_test/namespace_test2_generated.lobster index 68fde1fc..4383e685 100644 --- a/tests/namespace_test/namespace_test2_generated.lobster +++ b/tests/namespace_test/namespace_test2_generated.lobster @@ -25,16 +25,22 @@ class TableInFirstNS : flatbuffers_handle def GetRootAsTableInFirstNS(buf:string): return TableInFirstNS { buf, buf.flatbuffers_indirect(0) } -def TableInFirstNSStart(b_:flatbuffers_builder): - b_.StartObject(3) -def TableInFirstNSAddFooTable(b_:flatbuffers_builder, foo_table:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(0, foo_table) -def TableInFirstNSAddFooEnum(b_:flatbuffers_builder, foo_enum:EnumInNestedNS): - b_.PrependInt8Slot(1, foo_enum, 0) -def TableInFirstNSAddFooStruct(b_:flatbuffers_builder, foo_struct:flatbuffers_offset): - b_.PrependStructSlot(2, foo_struct) -def TableInFirstNSEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct TableInFirstNSBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(3) + return this + def add_foo_table(foo_table:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(0, foo_table) + return this + def add_foo_enum(foo_enum:EnumInNestedNS): + b_.PrependInt8Slot(1, foo_enum, 0) + return this + def add_foo_struct(foo_struct:flatbuffers_offset): + b_.PrependStructSlot(2, foo_struct) + return this + def end(): + return b_.EndObject() namespace NamespaceC @@ -48,14 +54,19 @@ class TableInC : flatbuffers_handle def GetRootAsTableInC(buf:string): return TableInC { buf, buf.flatbuffers_indirect(0) } -def TableInCStart(b_:flatbuffers_builder): - b_.StartObject(2) -def TableInCAddReferToA1(b_:flatbuffers_builder, refer_to_a1:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(0, refer_to_a1) -def TableInCAddReferToA2(b_:flatbuffers_builder, refer_to_a2:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(1, refer_to_a2) -def TableInCEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct TableInCBuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(2) + return this + def add_refer_to_a1(refer_to_a1:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(0, refer_to_a1) + return this + def add_refer_to_a2(refer_to_a2:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(1, refer_to_a2) + return this + def end(): + return b_.EndObject() namespace NamespaceA @@ -66,10 +77,14 @@ class SecondTableInA : flatbuffers_handle def GetRootAsSecondTableInA(buf:string): return SecondTableInA { buf, buf.flatbuffers_indirect(0) } -def SecondTableInAStart(b_:flatbuffers_builder): - b_.StartObject(1) -def SecondTableInAAddReferToC(b_:flatbuffers_builder, refer_to_c:flatbuffers_offset): - b_.PrependUOffsetTRelativeSlot(0, refer_to_c) -def SecondTableInAEnd(b_:flatbuffers_builder): - return b_.EndObject() +struct SecondTableInABuilder: + b_:flatbuffers_builder + def start(): + b_.StartObject(1) + return this + def add_refer_to_c(refer_to_c:flatbuffers_offset): + b_.PrependUOffsetTRelativeSlot(0, refer_to_c) + return this + def end(): + return b_.EndObject() |