diff options
author | Ivan Dlugos <6349682+vaind@users.noreply.github.com> | 2021-09-28 22:23:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-28 13:23:30 -0700 |
commit | b9d43a557c11e6c75812a2a098ffe9cdcfa02c86 (patch) | |
tree | 54855d725da8f6c1d78ea40d5287e6279b940e40 /tests | |
parent | 2ece9e25b469a2b42012738ead29a918c890aa40 (diff) | |
download | flatbuffers-b9d43a557c11e6c75812a2a098ffe9cdcfa02c86.tar.gz flatbuffers-b9d43a557c11e6c75812a2a098ffe9cdcfa02c86.tar.bz2 flatbuffers-b9d43a557c11e6c75812a2a098ffe9cdcfa02c86.zip |
dart - add Packable interface (#6846)
Diffstat (limited to 'tests')
7 files changed, 34 insertions, 17 deletions
diff --git a/tests/monster_extra_my_game_generated.dart b/tests/monster_extra_my_game_generated.dart index 3642525e..ed06ebba 100644 --- a/tests/monster_extra_my_game_generated.dart +++ b/tests/monster_extra_my_game_generated.dart @@ -53,7 +53,7 @@ class MonsterExtra { } } -class MonsterExtraT { +class MonsterExtraT implements fb.Packable { double d0; double d1; double d2; @@ -77,6 +77,7 @@ class MonsterExtraT { this.dvec, this.fvec}); + @override int pack(fb.Builder fbBuilder) { final int? dvecOffset = dvec == null ? null : fbBuilder.writeListFloat64(dvec!); diff --git a/tests/monster_test_my_game.example2_generated.dart b/tests/monster_test_my_game.example2_generated.dart index b1288874..24ccf721 100644 --- a/tests/monster_test_my_game.example2_generated.dart +++ b/tests/monster_test_my_game.example2_generated.dart @@ -35,7 +35,8 @@ class Monster { } } -class MonsterT { +class MonsterT implements fb.Packable { + @override int pack(fb.Builder fbBuilder) { fbBuilder.startTable(0); return fbBuilder.endTable(); diff --git a/tests/monster_test_my_game.example_generated.dart b/tests/monster_test_my_game.example_generated.dart index 869f1e6d..8db82e31 100644 --- a/tests/monster_test_my_game.example_generated.dart +++ b/tests/monster_test_my_game.example_generated.dart @@ -277,7 +277,7 @@ class Test { } } -class TestT { +class TestT implements fb.Packable { int a; int b; @@ -285,6 +285,7 @@ class TestT { required this.a, required this.b}); + @override int pack(fb.Builder fbBuilder) { fbBuilder.pad(1); fbBuilder.putInt8(b); @@ -379,12 +380,13 @@ class TestSimpleTableWithEnum { } } -class TestSimpleTableWithEnumT { +class TestSimpleTableWithEnumT implements fb.Packable { Color color; TestSimpleTableWithEnumT({ this.color = Color.Green}); + @override int pack(fb.Builder fbBuilder) { fbBuilder.startTable(1); fbBuilder.addUint8(0, color.value); @@ -482,7 +484,7 @@ class Vec3 { } } -class Vec3T { +class Vec3T implements fb.Packable { double x; double y; double z; @@ -498,6 +500,7 @@ class Vec3T { required this.test2, required this.test3}); + @override int pack(fb.Builder fbBuilder) { fbBuilder.pad(2); test3.pack(fbBuilder); @@ -620,7 +623,7 @@ class Ability { } } -class AbilityT { +class AbilityT implements fb.Packable { int id; int distance; @@ -628,6 +631,7 @@ class AbilityT { required this.id, required this.distance}); + @override int pack(fb.Builder fbBuilder) { fbBuilder.putUint32(distance); fbBuilder.putUint32(id); @@ -719,7 +723,7 @@ class StructOfStructs { } } -class StructOfStructsT { +class StructOfStructsT implements fb.Packable { AbilityT a; TestT b; AbilityT c; @@ -729,6 +733,7 @@ class StructOfStructsT { required this.b, required this.c}); + @override int pack(fb.Builder fbBuilder) { c.pack(fbBuilder); b.pack(fbBuilder); @@ -830,7 +835,7 @@ class Stat { } } -class StatT { +class StatT implements fb.Packable { String? id; int val; int count; @@ -840,6 +845,7 @@ class StatT { this.val = 0, this.count = 0}); + @override int pack(fb.Builder fbBuilder) { final int? idOffset = id == null ? null : fbBuilder.writeString(id!); @@ -953,12 +959,13 @@ class Referrable { } } -class ReferrableT { +class ReferrableT implements fb.Packable { int id; ReferrableT({ this.id = 0}); + @override int pack(fb.Builder fbBuilder) { fbBuilder.startTable(1); fbBuilder.addUint64(0, id); @@ -1173,7 +1180,7 @@ class Monster { } /// an example documentation comment: "monster object" -class MonsterT { +class MonsterT implements fb.Packable { Vec3T? pos; int mana; int hp; @@ -1279,6 +1286,7 @@ class MonsterT { this.testrequirednestedflatbuffer, this.scalarKeySortedTables}); + @override int pack(fb.Builder fbBuilder) { final int? nameOffset = name == null ? null : fbBuilder.writeString(name!); @@ -1942,7 +1950,7 @@ class TypeAliases { } } -class TypeAliasesT { +class TypeAliasesT implements fb.Packable { int i8; int u8; int i16; @@ -1970,6 +1978,7 @@ class TypeAliasesT { this.v8, this.vf64}); + @override int pack(fb.Builder fbBuilder) { final int? v8Offset = v8 == null ? null : fbBuilder.writeListInt8(v8!); diff --git a/tests/monster_test_my_game_generated.dart b/tests/monster_test_my_game_generated.dart index b76ae3d7..70e256ca 100644 --- a/tests/monster_test_my_game_generated.dart +++ b/tests/monster_test_my_game_generated.dart @@ -35,7 +35,8 @@ class InParentNamespace { } } -class InParentNamespaceT { +class InParentNamespaceT implements fb.Packable { + @override int pack(fb.Builder fbBuilder) { fbBuilder.startTable(0); return fbBuilder.endTable(); diff --git a/tests/namespace_test/namespace_test1_namespace_a.namespace_b_generated.dart b/tests/namespace_test/namespace_test1_namespace_a.namespace_b_generated.dart index b0ddad4f..5e0fb1dc 100644 --- a/tests/namespace_test/namespace_test1_namespace_a.namespace_b_generated.dart +++ b/tests/namespace_test/namespace_test1_namespace_a.namespace_b_generated.dart @@ -125,12 +125,13 @@ class TableInNestedNS { } } -class TableInNestedNST { +class TableInNestedNST implements fb.Packable { int foo; TableInNestedNST({ this.foo = 0}); + @override int pack(fb.Builder fbBuilder) { fbBuilder.startTable(1); fbBuilder.addInt32(0, foo); @@ -220,7 +221,7 @@ class StructInNestedNS { } } -class StructInNestedNST { +class StructInNestedNST implements fb.Packable { int a; int b; @@ -228,6 +229,7 @@ class StructInNestedNST { required this.a, required this.b}); + @override int pack(fb.Builder fbBuilder) { fbBuilder.putInt32(b); fbBuilder.putInt32(a); diff --git a/tests/namespace_test/namespace_test2_namespace_a_generated.dart b/tests/namespace_test/namespace_test2_namespace_a_generated.dart index 679b81c5..070cb5f9 100644 --- a/tests/namespace_test/namespace_test2_namespace_a_generated.dart +++ b/tests/namespace_test/namespace_test2_namespace_a_generated.dart @@ -49,7 +49,7 @@ class TableInFirstNS { } } -class TableInFirstNST { +class TableInFirstNST implements fb.Packable { namespace_a_namespace_b.TableInNestedNST? fooTable; EnumInNestedNS fooEnum; UnionInNestedNSTypeId? fooUnionType; @@ -63,6 +63,7 @@ class TableInFirstNST { this.fooUnion, this.fooStruct}); + @override int pack(fb.Builder fbBuilder) { final int? fooTableOffset = fooTable?.pack(fbBuilder); final int? fooUnionOffset = fooUnion?.pack(fbBuilder); @@ -198,12 +199,13 @@ class SecondTableInA { } } -class SecondTableInAT { +class SecondTableInAT implements fb.Packable { namespace_c.TableInCT? referToC; SecondTableInAT({ this.referToC}); + @override int pack(fb.Builder fbBuilder) { final int? referToCOffset = referToC?.pack(fbBuilder); fbBuilder.startTable(1); diff --git a/tests/namespace_test/namespace_test2_namespace_c_generated.dart b/tests/namespace_test/namespace_test2_namespace_c_generated.dart index 883a2ce5..1c30bb4a 100644 --- a/tests/namespace_test/namespace_test2_namespace_c_generated.dart +++ b/tests/namespace_test/namespace_test2_namespace_c_generated.dart @@ -38,7 +38,7 @@ class TableInC { } } -class TableInCT { +class TableInCT implements fb.Packable { namespace_a.TableInFirstNST? referToA1; namespace_a.SecondTableInAT? referToA2; @@ -46,6 +46,7 @@ class TableInCT { this.referToA1, this.referToA2}); + @override int pack(fb.Builder fbBuilder) { final int? referToA1Offset = referToA1?.pack(fbBuilder); final int? referToA2Offset = referToA2?.pack(fbBuilder); |