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
a239ed2b
Unverified
Commit
a239ed2b
authored
May 30, 2018
by
Paul Yang
Committed by
GitHub
May 30, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4702 from TeBoring/3.6.x
Cherry-pick changes into 3.6.x
parents
d31864a7
4f5eb100
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
5 deletions
+26
-5
php_generator.cc
src/google/protobuf/compiler/php/php_generator.cc
+16
-4
php_generator.h
src/google/protobuf/compiler/php/php_generator.h
+10
-1
No files found.
src/google/protobuf/compiler/php/php_generator.cc
View file @
a239ed2b
...
...
@@ -157,7 +157,7 @@ std::string ClassNamePrefix(const string& classname,
}
template
<
typename
DescriptorType
>
std
::
string
GeneratedClassName
(
const
DescriptorType
*
desc
)
{
std
::
string
GeneratedClassName
Impl
(
const
DescriptorType
*
desc
)
{
std
::
string
classname
=
ClassNamePrefix
(
desc
->
name
(),
desc
)
+
desc
->
name
();
const
Descriptor
*
containing
=
desc
->
containing_type
();
while
(
containing
!=
NULL
)
{
...
...
@@ -168,11 +168,23 @@ std::string GeneratedClassName(const DescriptorType* desc) {
return
classname
;
}
std
::
string
GeneratedClassName
(
const
ServiceDescriptor
*
desc
)
{
std
::
string
GeneratedClassName
Impl
(
const
ServiceDescriptor
*
desc
)
{
std
::
string
classname
=
desc
->
name
();
return
ClassNamePrefix
(
classname
,
desc
)
+
classname
;
}
std
::
string
GeneratedClassName
(
const
Descriptor
*
desc
)
{
return
GeneratedClassNameImpl
(
desc
);
}
std
::
string
GeneratedClassName
(
const
EnumDescriptor
*
desc
)
{
return
GeneratedClassNameImpl
(
desc
);
}
std
::
string
GeneratedClassName
(
const
ServiceDescriptor
*
desc
)
{
return
GeneratedClassNameImpl
(
desc
);
}
template
<
typename
DescriptorType
>
std
::
string
LegacyGeneratedClassName
(
const
DescriptorType
*
desc
)
{
std
::
string
classname
=
desc
->
name
();
...
...
@@ -242,7 +254,7 @@ std::string RootPhpNamespace(const DescriptorType* desc, bool is_descriptor) {
template
<
typename
DescriptorType
>
std
::
string
FullClassName
(
const
DescriptorType
*
desc
,
bool
is_descriptor
)
{
string
classname
=
GeneratedClassName
(
desc
);
string
classname
=
GeneratedClassName
Impl
(
desc
);
string
php_namespace
=
RootPhpNamespace
(
desc
,
is_descriptor
);
if
(
php_namespace
!=
""
)
{
return
php_namespace
+
"
\\
"
+
classname
;
...
...
@@ -1074,7 +1086,7 @@ void LegacyGenerateClassFile(const FileDescriptor* file, const DescriptorType* d
Outdent
(
&
printer
);
printer
.
Print
(
"}
\n
"
);
printer
.
Print
(
"class_exists(^new^::class);
\n
"
,
"new"
,
GeneratedClassName
(
desc
));
"new"
,
GeneratedClassName
Impl
(
desc
));
printer
.
Print
(
"@trigger_error('^old^ is deprecated and will be removed in "
"the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);
\n\n
"
,
"old"
,
LegacyFullClassName
(
desc
,
is_descriptor
),
...
...
src/google/protobuf/compiler/php/php_generator.h
View file @
a239ed2b
...
...
@@ -48,9 +48,18 @@ class LIBPROTOC_EXPORT Generator
const
string
&
parameter
,
GeneratorContext
*
generator_context
,
string
*
error
)
const
;
};
// To skip reserved keywords in php, some generated classname are prefixed.
// Other code generators may need following API to figure out the actual
// classname.
LIBPROTOC_EXPORT
std
::
string
GeneratedClassName
(
const
google
::
protobuf
::
Descriptor
*
desc
);
LIBPROTOC_EXPORT
std
::
string
GeneratedClassName
(
const
google
::
protobuf
::
EnumDescriptor
*
desc
);
LIBPROTOC_EXPORT
std
::
string
GeneratedClassName
(
const
google
::
protobuf
::
ServiceDescriptor
*
desc
);
}
// namespace php
}
// namespace compiler
}
// namespace protobuf
...
...
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