Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
a6189acd
Commit
a6189acd
authored
Apr 26, 2017
by
Paul Yang
Committed by
GitHub
Apr 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add prefix to enum value with reserved name. (#3020)
parent
3c0855e9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
test.proto
php/tests/proto/test.proto
+1
-0
php_generator.cc
src/google/protobuf/compiler/php/php_generator.cc
+4
-4
No files found.
php/tests/proto/test.proto
View file @
a6189acd
...
...
@@ -119,6 +119,7 @@ enum TestEnum {
ZERO
=
0
;
ONE
=
1
;
TWO
=
2
;
ECHO
=
3
;
// Test reserved name.
}
// Test prefix for reserved words.
...
...
src/google/protobuf/compiler/php/php_generator.cc
View file @
a6189acd
...
...
@@ -49,8 +49,8 @@ const std::string kDescriptorMetadataFile =
"GPBMetadata/Google/Protobuf/Internal/Descriptor.php"
;
const
std
::
string
kDescriptorDirName
=
"Google/Protobuf/Internal"
;
const
std
::
string
kDescriptorPackageName
=
"Google
\\
Protobuf
\\
Internal"
;
const
char
*
const
kReservedNames
[]
=
{
"Empty"
};
const
int
kReservedNamesSize
=
1
;
const
char
*
const
kReservedNames
[]
=
{
"Empty"
,
"ECHO"
};
const
int
kReservedNamesSize
=
2
;
namespace
google
{
namespace
protobuf
{
...
...
@@ -559,7 +559,7 @@ void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) {
const
EnumValueDescriptor
*
value
=
en
->
value
(
i
);
printer
->
Print
(
"->value(
\"
^name^
\"
, ^number^)
\n
"
,
"name"
,
value
->
name
(),
"name"
,
ClassNamePrefix
(
value
->
name
(),
en
)
+
value
->
name
(),
"number"
,
IntToString
(
value
->
number
()));
}
printer
->
Print
(
"->finalizeToPool();
\n\n
"
);
...
...
@@ -845,7 +845,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
const
EnumValueDescriptor
*
value
=
en
->
value
(
i
);
GenerateEnumValueDocComment
(
&
printer
,
value
);
printer
.
Print
(
"const ^name^ = ^number^;
\n
"
,
"name"
,
value
->
name
(),
"name"
,
ClassNamePrefix
(
value
->
name
(),
en
)
+
value
->
name
(),
"number"
,
IntToString
(
value
->
number
()));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment