Fix 64-bit numeric enum values in typescript (#7135)

* Fix 64-bit default numeric enum values in typescript

If you had a default value that wasn't a valid enum value (e.g., a zero
if you used a bit_flag setting, like you get with AdvancedFeatures
in reflection.fbs), we weren't using BigInt.

* Run generate_code.py

* [DART] Handle deprecated fields & invalid enum defaults

* Update .NET test
This commit is contained in:
James Kuszmaul
2022-03-04 21:57:48 -08:00
committed by GitHub
parent 1a4c405662
commit 9ed1323044
39 changed files with 1342 additions and 275 deletions

View File

@@ -736,22 +736,40 @@ class Monster extends Table
return $o != 0 ? $obj->init($o + $this->bb_pos, $this->bb) : 0;
}
/**
* @return ulong
*/
public function getLongEnumNonEnumDefault()
{
$o = $this->__offset(108);
return $o != 0 ? $this->bb->getUlong($o + $this->bb_pos) : 0;
}
/**
* @return ulong
*/
public function getLongEnumNormalDefault()
{
$o = $this->__offset(110);
return $o != 0 ? $this->bb->getUlong($o + $this->bb_pos) : \MyGame\Example\LongEnum::LongOne;
}
/**
* @param FlatBufferBuilder $builder
* @return void
*/
public static function startMonster(FlatBufferBuilder $builder)
{
$builder->StartObject(52);
$builder->StartObject(54);
}
/**
* @param FlatBufferBuilder $builder
* @return Monster
*/
public static function createMonster(FlatBufferBuilder $builder, $pos, $mana, $hp, $name, $inventory, $color, $test_type, $test, $test4, $testarrayofstring, $testarrayoftables, $enemy, $testnestedflatbuffer, $testempty, $testbool, $testhashs32_fnv1, $testhashu32_fnv1, $testhashs64_fnv1, $testhashu64_fnv1, $testhashs32_fnv1a, $testhashu32_fnv1a, $testhashs64_fnv1a, $testhashu64_fnv1a, $testarrayofbools, $testf, $testf2, $testf3, $testarrayofstring2, $testarrayofsortedstruct, $flex, $test5, $vector_of_longs, $vector_of_doubles, $parent_namespace_test, $vector_of_referrables, $single_weak_reference, $vector_of_weak_references, $vector_of_strong_referrables, $co_owning_reference, $vector_of_co_owning_references, $non_owning_reference, $vector_of_non_owning_references, $any_unique_type, $any_unique, $any_ambiguous_type, $any_ambiguous, $vector_of_enums, $signed_enum, $testrequirednestedflatbuffer, $scalar_key_sorted_tables, $native_inline)
public static function createMonster(FlatBufferBuilder $builder, $pos, $mana, $hp, $name, $inventory, $color, $test_type, $test, $test4, $testarrayofstring, $testarrayoftables, $enemy, $testnestedflatbuffer, $testempty, $testbool, $testhashs32_fnv1, $testhashu32_fnv1, $testhashs64_fnv1, $testhashu64_fnv1, $testhashs32_fnv1a, $testhashu32_fnv1a, $testhashs64_fnv1a, $testhashu64_fnv1a, $testarrayofbools, $testf, $testf2, $testf3, $testarrayofstring2, $testarrayofsortedstruct, $flex, $test5, $vector_of_longs, $vector_of_doubles, $parent_namespace_test, $vector_of_referrables, $single_weak_reference, $vector_of_weak_references, $vector_of_strong_referrables, $co_owning_reference, $vector_of_co_owning_references, $non_owning_reference, $vector_of_non_owning_references, $any_unique_type, $any_unique, $any_ambiguous_type, $any_ambiguous, $vector_of_enums, $signed_enum, $testrequirednestedflatbuffer, $scalar_key_sorted_tables, $native_inline, $long_enum_non_enum_default, $long_enum_normal_default)
{
$builder->startObject(52);
$builder->startObject(54);
self::addPos($builder, $pos);
self::addMana($builder, $mana);
self::addHp($builder, $hp);
@@ -803,6 +821,8 @@ class Monster extends Table
self::addTestrequirednestedflatbuffer($builder, $testrequirednestedflatbuffer);
self::addScalarKeySortedTables($builder, $scalar_key_sorted_tables);
self::addNativeInline($builder, $native_inline);
self::addLongEnumNonEnumDefault($builder, $long_enum_non_enum_default);
self::addLongEnumNormalDefault($builder, $long_enum_normal_default);
$o = $builder->endObject();
$builder->required($o, 10); // name
return $o;
@@ -1783,6 +1803,26 @@ class Monster extends Table
$builder->addStructX(51, $nativeInline, 0);
}
/**
* @param FlatBufferBuilder $builder
* @param ulong
* @return void
*/
public static function addLongEnumNonEnumDefault(FlatBufferBuilder $builder, $longEnumNonEnumDefault)
{
$builder->addUlongX(52, $longEnumNonEnumDefault, 0);
}
/**
* @param FlatBufferBuilder $builder
* @param ulong
* @return void
*/
public static function addLongEnumNormalDefault(FlatBufferBuilder $builder, $longEnumNormalDefault)
{
$builder->addUlongX(53, $longEnumNormalDefault, 2);
}
/**
* @param FlatBufferBuilder $builder
* @return int table offset