mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 20:48:18 +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:
committed by
Wouter van Oortmerssen
parent
4d98faa515
commit
31e34faa15
@@ -828,7 +828,7 @@ class PhpGenerator : public BaseGenerator {
|
|||||||
for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
|
for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
|
||||||
++it) {
|
++it) {
|
||||||
auto &ev = **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";
|
code += Indent + ");\n\n";
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ class Any
|
|||||||
const MyGame_Example2_Monster = 3;
|
const MyGame_Example2_Monster = 3;
|
||||||
|
|
||||||
private static $names = array(
|
private static $names = array(
|
||||||
"NONE",
|
Any::NONE=>"NONE",
|
||||||
"Monster",
|
Any::Monster=>"Monster",
|
||||||
"TestSimpleTableWithEnum",
|
Any::TestSimpleTableWithEnum=>"TestSimpleTableWithEnum",
|
||||||
"MyGame_Example2_Monster",
|
Any::MyGame_Example2_Monster=>"MyGame_Example2_Monster",
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function Name($e)
|
public static function Name($e)
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ class AnyAmbiguousAliases
|
|||||||
const M3 = 3;
|
const M3 = 3;
|
||||||
|
|
||||||
private static $names = array(
|
private static $names = array(
|
||||||
"NONE",
|
AnyAmbiguousAliases::NONE=>"NONE",
|
||||||
"M1",
|
AnyAmbiguousAliases::M1=>"M1",
|
||||||
"M2",
|
AnyAmbiguousAliases::M2=>"M2",
|
||||||
"M3",
|
AnyAmbiguousAliases::M3=>"M3",
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function Name($e)
|
public static function Name($e)
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ class AnyUniqueAliases
|
|||||||
const M2 = 3;
|
const M2 = 3;
|
||||||
|
|
||||||
private static $names = array(
|
private static $names = array(
|
||||||
"NONE",
|
AnyUniqueAliases::NONE=>"NONE",
|
||||||
"M",
|
AnyUniqueAliases::M=>"M",
|
||||||
"T",
|
AnyUniqueAliases::T=>"T",
|
||||||
"M2",
|
AnyUniqueAliases::M2=>"M2",
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function Name($e)
|
public static function Name($e)
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ class Color
|
|||||||
const Blue = 8;
|
const Blue = 8;
|
||||||
|
|
||||||
private static $names = array(
|
private static $names = array(
|
||||||
"Red",
|
Color::Red=>"Red",
|
||||||
"Green",
|
Color::Green=>"Green",
|
||||||
"Blue",
|
Color::Blue=>"Blue",
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function Name($e)
|
public static function Name($e)
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ class EnumInNestedNS
|
|||||||
const C = 2;
|
const C = 2;
|
||||||
|
|
||||||
private static $names = array(
|
private static $names = array(
|
||||||
"A",
|
EnumInNestedNS::A=>"A",
|
||||||
"B",
|
EnumInNestedNS::B=>"B",
|
||||||
"C",
|
EnumInNestedNS::C=>"C",
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function Name($e)
|
public static function Name($e)
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ class Character
|
|||||||
const Unused = 6;
|
const Unused = 6;
|
||||||
|
|
||||||
private static $names = array(
|
private static $names = array(
|
||||||
"NONE",
|
Character::NONE=>"NONE",
|
||||||
"MuLan",
|
Character::MuLan=>"MuLan",
|
||||||
"Rapunzel",
|
Character::Rapunzel=>"Rapunzel",
|
||||||
"Belle",
|
Character::Belle=>"Belle",
|
||||||
"BookFan",
|
Character::BookFan=>"BookFan",
|
||||||
"Other",
|
Character::Other=>"Other",
|
||||||
"Unused",
|
Character::Unused=>"Unused",
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function Name($e)
|
public static function Name($e)
|
||||||
|
|||||||
Reference in New Issue
Block a user