- name: test
working-directory: tests/FlatBuffers.Test.Swift
run: sh SwiftTest.sh
-
-
// automatically generated by the FlatBuffers compiler, do not modify
-// ignore_for_file: unused_import, non_constant_identifier_names
+// ignore_for_file: unused_import, unused_field, unused_local_variable
library my_game.sample;
const Color._(this.value);
factory Color.fromValue(int value) {
- if (value == null) return null;
+ if (value == null) value = 0;
if (!values.containsKey(value)) {
throw new StateError('Invalid value $value for bit flag enum Color');
}
static const Color Red = const Color._(0);
static const Color Green = const Color._(1);
static const Color Blue = const Color._(2);
- static get values => {0: Red,1: Green,2: Blue,};
+ static const Map<int,Color> values = {0: Red,1: Green,2: Blue,};
static const fb.Reader<Color> reader = const _ColorReader();
const EquipmentTypeId._(this.value);
factory EquipmentTypeId.fromValue(int value) {
- if (value == null) return null;
+ if (value == null) value = 0;
if (!values.containsKey(value)) {
throw new StateError('Invalid value $value for bit flag enum EquipmentTypeId');
}
static const EquipmentTypeId NONE = const EquipmentTypeId._(0);
static const EquipmentTypeId Weapon = const EquipmentTypeId._(1);
- static get values => {0: NONE,1: Weapon,};
+ static const Map<int,EquipmentTypeId> values = {0: NONE,1: Weapon,};
static const fb.Reader<EquipmentTypeId> reader = const _EquipmentTypeIdReader();
List<int> get inventory => const fb.ListReader<int>(const fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 14, null);
Color get color => new Color.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 16, 2));
List<Weapon> get weapons => const fb.ListReader<Weapon>(Weapon.reader).vTableGet(_bc, _bcOffset, 18, null);
- EquipmentTypeId get equippedType => new EquipmentTypeId.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, null));
+ EquipmentTypeId get equippedType => new EquipmentTypeId.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, 0));
dynamic get equipped {
switch (equippedType?.value) {
case 1: return Weapon.reader.vTableGet(_bc, _bcOffset, 22, null);
final int _bcOffset;
String get name => const fb.StringReader().vTableGet(_bc, _bcOffset, 4, null);
- int get damage => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 6, null);
+ int get damage => const fb.Int16Reader().vTableGet(_bc, _bcOffset, 6, 0);
@override
String toString() {
# Note to pub consumers: this file is used to assist with publishing the
# pub package from the flatbuffers repository and is not meant for general use.
# As pub does not currently provide a way to exclude files, it is included here.
+set -e
-command -v pub >/dev/null 2>&1 || { echo >&2 "Require `pub` but it's not installed. Aborting."; exit 1; }
+command -v dart >/dev/null 2>&1 || { echo >&2 "Require `dart` but it's not installed. Aborting."; exit 1; }
cp ../samples/monster.fbs example/
cp ../tests/monster_test.fbs test/
-pub publish
+cp -r ../tests/include_test/*.fbs test/
+cp -r ../tests/include_test/sub test/
+
+pushd example
+../../flatc --dart ./monster.fbs
+popd
+
+pushd test
+../../flatc --dart ./monster_test.fbs
+popd
+
+dart pub publish
rm example/monster.fbs
-rm test/monster_test.fbs
\ No newline at end of file
+rm test/*.fbs
+rm -rf test/sub
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
'anyUniqueType: AnyUniqueAliasesTypeId{value: 0}, anyUnique: null, '
'anyAmbiguousType: AnyAmbiguousAliasesTypeId{value: 0}, '
- 'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}}, '
+ 'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
+ 'testrequirednestedflatbuffer: null}, '
'test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
'testarrayofstring: [test1, test2], testarrayoftables: null, '
'enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
'anyUniqueType: AnyUniqueAliasesTypeId{value: 0}, anyUnique: null, '
'anyAmbiguousType: AnyAmbiguousAliasesTypeId{value: 0}, '
- 'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}}, '
+ 'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
+ 'testrequirednestedflatbuffer: null}, '
'testnestedflatbuffer: null, testempty: null, testbool: true, '
'testhashs32Fnv1: -579221183, testhashu32Fnv1: 3715746113, '
'testhashs64Fnv1: 7930699090847568257, '
'vectorOfNonOwningReferences: null, '
'anyUniqueType: AnyUniqueAliasesTypeId{value: 0}, anyUnique: null, '
'anyAmbiguousType: AnyAmbiguousAliasesTypeId{value: 0}, '
- 'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}}',
+ 'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
+ 'testrequirednestedflatbuffer: null}',
);
}
}
/// \brief color Blue (1u << 3)
static const Color Blue = const Color._(8);
- static const values = {1: Red,2: Green,8: Blue,};
+ static const Map<int,Color> values = {1: Red,2: Green,8: Blue,};
static const fb.Reader<Color> reader = const _ColorReader();
static const Race Human = const Race._(0);
static const Race Dwarf = const Race._(1);
static const Race Elf = const Race._(2);
- static const values = {-1: None,0: Human,1: Dwarf,2: Elf,};
+ static const Map<int,Race> values = {-1: None,0: Human,1: Dwarf,2: Elf,};
static const fb.Reader<Race> reader = const _RaceReader();
static const AnyTypeId Monster = const AnyTypeId._(1);
static const AnyTypeId TestSimpleTableWithEnum = const AnyTypeId._(2);
static const AnyTypeId MyGame_Example2_Monster = const AnyTypeId._(3);
- static const values = {0: NONE,1: Monster,2: TestSimpleTableWithEnum,3: MyGame_Example2_Monster,};
+ static const Map<int,AnyTypeId> values = {0: NONE,1: Monster,2: TestSimpleTableWithEnum,3: MyGame_Example2_Monster,};
static const fb.Reader<AnyTypeId> reader = const _AnyTypeIdReader();
static const AnyUniqueAliasesTypeId M = const AnyUniqueAliasesTypeId._(1);
static const AnyUniqueAliasesTypeId TS = const AnyUniqueAliasesTypeId._(2);
static const AnyUniqueAliasesTypeId M2 = const AnyUniqueAliasesTypeId._(3);
- static const values = {0: NONE,1: M,2: TS,3: M2,};
+ static const Map<int,AnyUniqueAliasesTypeId> values = {0: NONE,1: M,2: TS,3: M2,};
static const fb.Reader<AnyUniqueAliasesTypeId> reader = const _AnyUniqueAliasesTypeIdReader();
static const AnyAmbiguousAliasesTypeId M1 = const AnyAmbiguousAliasesTypeId._(1);
static const AnyAmbiguousAliasesTypeId M2 = const AnyAmbiguousAliasesTypeId._(2);
static const AnyAmbiguousAliasesTypeId M3 = const AnyAmbiguousAliasesTypeId._(3);
- static const values = {0: NONE,1: M1,2: M2,3: M3,};
+ static const Map<int,AnyAmbiguousAliasesTypeId> values = {0: NONE,1: M1,2: M2,3: M3,};
static const fb.Reader<AnyAmbiguousAliasesTypeId> reader = const _AnyAmbiguousAliasesTypeIdReader();
}
List<Color> get vectorOfEnums => const fb.ListReader<Color>(Color.reader).vTableGet(_bc, _bcOffset, 98, null);
Race get signedEnum => new Race.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 100, -1));
+ List<int> get testrequirednestedflatbuffer => const fb.ListReader<int>(const fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 102, null);
@override
String toString() {
- return 'Monster{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences, anyUniqueType: $anyUniqueType, anyUnique: $anyUnique, anyAmbiguousType: $anyAmbiguousType, anyAmbiguous: $anyAmbiguous, vectorOfEnums: $vectorOfEnums, signedEnum: $signedEnum}';
+ return 'Monster{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences, anyUniqueType: $anyUniqueType, anyUnique: $anyUnique, anyAmbiguousType: $anyAmbiguousType, anyAmbiguous: $anyAmbiguous, vectorOfEnums: $vectorOfEnums, signedEnum: $signedEnum, testrequirednestedflatbuffer: $testrequirednestedflatbuffer}';
}
}
fbBuilder.addInt8(48, signedEnum?.value);
return fbBuilder.offset;
}
+ int addTestrequirednestedflatbufferOffset(int offset) {
+ fbBuilder.addOffset(49, offset);
+ return fbBuilder.offset;
+ }
int finish() {
return fbBuilder.endTable();
final dynamic _anyAmbiguous;
final List<Color> _vectorOfEnums;
final Race _signedEnum;
+ final List<int> _testrequirednestedflatbuffer;
MonsterObjectBuilder({
Vec3ObjectBuilder pos,
dynamic anyAmbiguous,
List<Color> vectorOfEnums,
Race signedEnum,
+ List<int> testrequirednestedflatbuffer,
})
: _pos = pos,
_mana = mana,
_anyAmbiguousType = anyAmbiguousType,
_anyAmbiguous = anyAmbiguous,
_vectorOfEnums = vectorOfEnums,
- _signedEnum = signedEnum;
+ _signedEnum = signedEnum,
+ _testrequirednestedflatbuffer = testrequirednestedflatbuffer;
/// Finish building, and store into the [fbBuilder].
@override
final int vectorOfEnumsOffset = _vectorOfEnums?.isNotEmpty == true
? fbBuilder.writeListUint8(_vectorOfEnums.map((f) => f.value))
: null;
+ final int testrequirednestedflatbufferOffset = _testrequirednestedflatbuffer?.isNotEmpty == true
+ ? fbBuilder.writeListUint8(_testrequirednestedflatbuffer)
+ : null;
fbBuilder.startTable();
if (_pos != null) {
fbBuilder.addOffset(47, vectorOfEnumsOffset);
}
fbBuilder.addInt8(48, _signedEnum?.value);
+ if (testrequirednestedflatbufferOffset != null) {
+ fbBuilder.addOffset(49, testrequirednestedflatbufferOffset);
+ }
return fbBuilder.endTable();
}
code += "const " + name + "._(" + enum_def.ToString(ev) + ");\n";
}
- code += " static const values = {";
+ code += " static const Map<int," + name + "> values = {";
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end(); ++it) {
auto &ev = **it;
code += enum_def.ToString(ev) + ": " + ev.name + ",";
pushd "$(dirname $0)" >/dev/null
-command -v pub >/dev/null 2>&1 || { echo >&2 "Dart tests require `pub` but it's not installed. Aborting."; exit 1; }
command -v dart >/dev/null 2>&1 || { echo >&2 "Dart tests require dart to be in path but it's not installed. Aborting."; exit 1; }
# output required files to the dart folder so that pub will be able to
# distribute them and more people can more easily run the dart tests
cd ../dart
# update packages
-pub get
+dart pub get
# Execute the sample.
dart test/flat_buffers_test.dart
/// \brief color Blue (1u << 3)
static const Color Blue = const Color._(8);
- static const values = {1: Red,2: Green,8: Blue,};
+ static const Map<int,Color> values = {1: Red,2: Green,8: Blue,};
static const fb.Reader<Color> reader = const _ColorReader();
static const Race Human = const Race._(0);
static const Race Dwarf = const Race._(1);
static const Race Elf = const Race._(2);
- static const values = {-1: None,0: Human,1: Dwarf,2: Elf,};
+ static const Map<int,Race> values = {-1: None,0: Human,1: Dwarf,2: Elf,};
static const fb.Reader<Race> reader = const _RaceReader();
static const AnyTypeId Monster = const AnyTypeId._(1);
static const AnyTypeId TestSimpleTableWithEnum = const AnyTypeId._(2);
static const AnyTypeId MyGame_Example2_Monster = const AnyTypeId._(3);
- static const values = {0: NONE,1: Monster,2: TestSimpleTableWithEnum,3: MyGame_Example2_Monster,};
+ static const Map<int,AnyTypeId> values = {0: NONE,1: Monster,2: TestSimpleTableWithEnum,3: MyGame_Example2_Monster,};
static const fb.Reader<AnyTypeId> reader = const _AnyTypeIdReader();
static const AnyUniqueAliasesTypeId M = const AnyUniqueAliasesTypeId._(1);
static const AnyUniqueAliasesTypeId TS = const AnyUniqueAliasesTypeId._(2);
static const AnyUniqueAliasesTypeId M2 = const AnyUniqueAliasesTypeId._(3);
- static const values = {0: NONE,1: M,2: TS,3: M2,};
+ static const Map<int,AnyUniqueAliasesTypeId> values = {0: NONE,1: M,2: TS,3: M2,};
static const fb.Reader<AnyUniqueAliasesTypeId> reader = const _AnyUniqueAliasesTypeIdReader();
static const AnyAmbiguousAliasesTypeId M1 = const AnyAmbiguousAliasesTypeId._(1);
static const AnyAmbiguousAliasesTypeId M2 = const AnyAmbiguousAliasesTypeId._(2);
static const AnyAmbiguousAliasesTypeId M3 = const AnyAmbiguousAliasesTypeId._(3);
- static const values = {0: NONE,1: M1,2: M2,3: M3,};
+ static const Map<int,AnyAmbiguousAliasesTypeId> values = {0: NONE,1: M1,2: M2,3: M3,};
static const fb.Reader<AnyAmbiguousAliasesTypeId> reader = const _AnyAmbiguousAliasesTypeIdReader();
static const EnumInNestedNS A = const EnumInNestedNS._(0);
static const EnumInNestedNS B = const EnumInNestedNS._(1);
static const EnumInNestedNS C = const EnumInNestedNS._(2);
- static const values = {0: A,1: B,2: C,};
+ static const Map<int,EnumInNestedNS> values = {0: A,1: B,2: C,};
static const fb.Reader<EnumInNestedNS> reader = const _EnumInNestedNSReader();