mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
Fix up scripts, fix generated enum value for strong mode, regenerate files (#6389)
* Fix up scripts, fix generated enum value for strong mode, regenerate files * missing files * GH action * remove action
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -192,5 +192,3 @@ jobs:
|
||||
- name: test
|
||||
working-directory: tests/FlatBuffers.Test.Swift
|
||||
run: sh SwiftTest.sh
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// 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;
|
||||
|
||||
@@ -12,7 +12,7 @@ class Color {
|
||||
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');
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class 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();
|
||||
|
||||
@@ -52,7 +52,7 @@ class EquipmentTypeId {
|
||||
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');
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class 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();
|
||||
|
||||
@@ -184,7 +184,7 @@ class Monster {
|
||||
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);
|
||||
@@ -363,7 +363,7 @@ class Weapon {
|
||||
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() {
|
||||
|
||||
@@ -17,12 +17,25 @@
|
||||
# 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
|
||||
rm test/*.fbs
|
||||
rm -rf test/sub
|
||||
|
||||
@@ -81,7 +81,8 @@ class CheckOtherLangaugesData {
|
||||
'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, '
|
||||
@@ -101,7 +102,8 @@ class CheckOtherLangaugesData {
|
||||
'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, '
|
||||
@@ -121,7 +123,8 @@ class CheckOtherLangaugesData {
|
||||
'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}',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class Color {
|
||||
|
||||
/// \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();
|
||||
|
||||
@@ -73,7 +73,7 @@ class Race {
|
||||
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();
|
||||
|
||||
@@ -114,7 +114,7 @@ class AnyTypeId {
|
||||
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();
|
||||
|
||||
@@ -155,7 +155,7 @@ class AnyUniqueAliasesTypeId {
|
||||
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();
|
||||
|
||||
@@ -196,7 +196,7 @@ class AnyAmbiguousAliasesTypeId {
|
||||
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();
|
||||
|
||||
@@ -801,10 +801,11 @@ class Monster {
|
||||
}
|
||||
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}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1019,6 +1020,10 @@ class MonsterBuilder {
|
||||
fbBuilder.addInt8(48, signedEnum?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addTestrequirednestedflatbufferOffset(int offset) {
|
||||
fbBuilder.addOffset(49, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
@@ -1074,6 +1079,7 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
final dynamic _anyAmbiguous;
|
||||
final List<Color> _vectorOfEnums;
|
||||
final Race _signedEnum;
|
||||
final List<int> _testrequirednestedflatbuffer;
|
||||
|
||||
MonsterObjectBuilder({
|
||||
Vec3ObjectBuilder pos,
|
||||
@@ -1124,6 +1130,7 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
dynamic anyAmbiguous,
|
||||
List<Color> vectorOfEnums,
|
||||
Race signedEnum,
|
||||
List<int> testrequirednestedflatbuffer,
|
||||
})
|
||||
: _pos = pos,
|
||||
_mana = mana,
|
||||
@@ -1172,7 +1179,8 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
_anyAmbiguousType = anyAmbiguousType,
|
||||
_anyAmbiguous = anyAmbiguous,
|
||||
_vectorOfEnums = vectorOfEnums,
|
||||
_signedEnum = signedEnum;
|
||||
_signedEnum = signedEnum,
|
||||
_testrequirednestedflatbuffer = testrequirednestedflatbuffer;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
@@ -1240,6 +1248,9 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
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) {
|
||||
@@ -1342,6 +1353,9 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
fbBuilder.addOffset(47, vectorOfEnumsOffset);
|
||||
}
|
||||
fbBuilder.addInt8(48, _signedEnum?.value);
|
||||
if (testrequirednestedflatbufferOffset != null) {
|
||||
fbBuilder.addOffset(49, testrequirednestedflatbufferOffset);
|
||||
}
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ class DartGenerator : public BaseGenerator {
|
||||
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 + ",";
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
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
|
||||
@@ -26,7 +25,7 @@ cp monsterdata_test.mon ../dart/test
|
||||
cd ../dart
|
||||
|
||||
# update packages
|
||||
pub get
|
||||
dart pub get
|
||||
# Execute the sample.
|
||||
dart test/flat_buffers_test.dart
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class Color {
|
||||
|
||||
/// \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();
|
||||
|
||||
@@ -73,7 +73,7 @@ class Race {
|
||||
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();
|
||||
|
||||
@@ -114,7 +114,7 @@ class AnyTypeId {
|
||||
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();
|
||||
|
||||
@@ -155,7 +155,7 @@ class AnyUniqueAliasesTypeId {
|
||||
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();
|
||||
|
||||
@@ -196,7 +196,7 @@ class AnyAmbiguousAliasesTypeId {
|
||||
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();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class EnumInNestedNS {
|
||||
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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user