mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-01 17:57:25 +00:00
Changing array to be an associative array so that the Name function can work with non-sequential enums as well as those beginning at something other than zero. (#5151)
Also including the resulting changes in php files.
This commit is contained in:
parent
4d98faa515
commit
31e34faa15
7 changed files with 26 additions and 26 deletions
|
|
@ -828,7 +828,7 @@ class PhpGenerator : public BaseGenerator {
|
|||
for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
|
||||
++it) {
|
||||
auto &ev = **it;
|
||||
code += Indent + Indent + "\"" + ev.name + "\",\n";
|
||||
code += Indent + Indent + enum_def.name + "::" + ev.name + "=>" + "\"" + ev.name + "\",\n";
|
||||
}
|
||||
|
||||
code += Indent + ");\n\n";
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ class Any
|
|||
const MyGame_Example2_Monster = 3;
|
||||
|
||||
private static $names = array(
|
||||
"NONE",
|
||||
"Monster",
|
||||
"TestSimpleTableWithEnum",
|
||||
"MyGame_Example2_Monster",
|
||||
Any::NONE=>"NONE",
|
||||
Any::Monster=>"Monster",
|
||||
Any::TestSimpleTableWithEnum=>"TestSimpleTableWithEnum",
|
||||
Any::MyGame_Example2_Monster=>"MyGame_Example2_Monster",
|
||||
);
|
||||
|
||||
public static function Name($e)
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ class AnyAmbiguousAliases
|
|||
const M3 = 3;
|
||||
|
||||
private static $names = array(
|
||||
"NONE",
|
||||
"M1",
|
||||
"M2",
|
||||
"M3",
|
||||
AnyAmbiguousAliases::NONE=>"NONE",
|
||||
AnyAmbiguousAliases::M1=>"M1",
|
||||
AnyAmbiguousAliases::M2=>"M2",
|
||||
AnyAmbiguousAliases::M3=>"M3",
|
||||
);
|
||||
|
||||
public static function Name($e)
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ class AnyUniqueAliases
|
|||
const M2 = 3;
|
||||
|
||||
private static $names = array(
|
||||
"NONE",
|
||||
"M",
|
||||
"T",
|
||||
"M2",
|
||||
AnyUniqueAliases::NONE=>"NONE",
|
||||
AnyUniqueAliases::M=>"M",
|
||||
AnyUniqueAliases::T=>"T",
|
||||
AnyUniqueAliases::M2=>"M2",
|
||||
);
|
||||
|
||||
public static function Name($e)
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ class Color
|
|||
const Blue = 8;
|
||||
|
||||
private static $names = array(
|
||||
"Red",
|
||||
"Green",
|
||||
"Blue",
|
||||
Color::Red=>"Red",
|
||||
Color::Green=>"Green",
|
||||
Color::Blue=>"Blue",
|
||||
);
|
||||
|
||||
public static function Name($e)
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ class EnumInNestedNS
|
|||
const C = 2;
|
||||
|
||||
private static $names = array(
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
EnumInNestedNS::A=>"A",
|
||||
EnumInNestedNS::B=>"B",
|
||||
EnumInNestedNS::C=>"C",
|
||||
);
|
||||
|
||||
public static function Name($e)
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ class Character
|
|||
const Unused = 6;
|
||||
|
||||
private static $names = array(
|
||||
"NONE",
|
||||
"MuLan",
|
||||
"Rapunzel",
|
||||
"Belle",
|
||||
"BookFan",
|
||||
"Other",
|
||||
"Unused",
|
||||
Character::NONE=>"NONE",
|
||||
Character::MuLan=>"MuLan",
|
||||
Character::Rapunzel=>"Rapunzel",
|
||||
Character::Belle=>"Belle",
|
||||
Character::BookFan=>"BookFan",
|
||||
Character::Other=>"Other",
|
||||
Character::Unused=>"Unused",
|
||||
);
|
||||
|
||||
public static function Name($e)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue