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
ee4f2492
Commit
ee4f2492
authored
Aug 16, 2019
by
Joshua Haberman
Committed by
Paul Yang
Aug 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some lint errors seen in google3. (#6520)
parent
c60aaf79
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
29 deletions
+27
-29
csharp_helpers.cc
src/google/protobuf/compiler/csharp/csharp_helpers.cc
+1
-1
csharp_reflection_class.cc
...oogle/protobuf/compiler/csharp/csharp_reflection_class.cc
+3
-0
php_generator.cc
src/google/protobuf/compiler/php/php_generator.cc
+23
-28
No files found.
src/google/protobuf/compiler/csharp/csharp_helpers.cc
View file @
ee4f2492
...
@@ -297,7 +297,7 @@ uint GetGroupEndTag(const Descriptor* descriptor) {
...
@@ -297,7 +297,7 @@ uint GetGroupEndTag(const Descriptor* descriptor) {
std
::
string
ToCSharpName
(
const
std
::
string
&
name
,
const
FileDescriptor
*
file
)
{
std
::
string
ToCSharpName
(
const
std
::
string
&
name
,
const
FileDescriptor
*
file
)
{
std
::
string
result
=
GetFileNamespace
(
file
);
std
::
string
result
=
GetFileNamespace
(
file
);
if
(
result
!=
""
)
{
if
(
!
result
.
empty
()
)
{
result
+=
'.'
;
result
+=
'.'
;
}
}
string
classname
;
string
classname
;
...
...
src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
View file @
ee4f2492
...
@@ -261,6 +261,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
...
@@ -261,6 +261,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
// Fields
// Fields
if
(
descriptor
->
field_count
()
>
0
)
{
if
(
descriptor
->
field_count
()
>
0
)
{
std
::
vector
<
std
::
string
>
fields
;
std
::
vector
<
std
::
string
>
fields
;
fields
.
reserve
(
descriptor
->
field_count
());
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
i
++
)
{
fields
.
push_back
(
GetPropertyName
(
descriptor
->
field
(
i
)));
fields
.
push_back
(
GetPropertyName
(
descriptor
->
field
(
i
)));
}
}
...
@@ -273,6 +274,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
...
@@ -273,6 +274,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
// Oneofs
// Oneofs
if
(
descriptor
->
oneof_decl_count
()
>
0
)
{
if
(
descriptor
->
oneof_decl_count
()
>
0
)
{
std
::
vector
<
std
::
string
>
oneofs
;
std
::
vector
<
std
::
string
>
oneofs
;
oneofs
.
reserve
(
descriptor
->
oneof_decl_count
());
for
(
int
i
=
0
;
i
<
descriptor
->
oneof_decl_count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
descriptor
->
oneof_decl_count
();
i
++
)
{
oneofs
.
push_back
(
UnderscoresToCamelCase
(
descriptor
->
oneof_decl
(
i
)
->
name
(),
true
));
oneofs
.
push_back
(
UnderscoresToCamelCase
(
descriptor
->
oneof_decl
(
i
)
->
name
(),
true
));
}
}
...
@@ -285,6 +287,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
...
@@ -285,6 +287,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript
// Nested enums
// Nested enums
if
(
descriptor
->
enum_type_count
()
>
0
)
{
if
(
descriptor
->
enum_type_count
()
>
0
)
{
std
::
vector
<
std
::
string
>
enums
;
std
::
vector
<
std
::
string
>
enums
;
enums
.
reserve
(
descriptor
->
enum_type_count
());
for
(
int
i
=
0
;
i
<
descriptor
->
enum_type_count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
descriptor
->
enum_type_count
();
i
++
)
{
enums
.
push_back
(
GetClassName
(
descriptor
->
enum_type
(
i
)));
enums
.
push_back
(
GetClassName
(
descriptor
->
enum_type
(
i
)));
}
}
...
...
src/google/protobuf/compiler/php/php_generator.cc
View file @
ee4f2492
...
@@ -88,7 +88,6 @@ std::string GeneratedMetadataFileName(const FileDescriptor* file,
...
@@ -88,7 +88,6 @@ std::string GeneratedMetadataFileName(const FileDescriptor* file,
std
::
string
LabelForField
(
FieldDescriptor
*
field
);
std
::
string
LabelForField
(
FieldDescriptor
*
field
);
std
::
string
TypeName
(
FieldDescriptor
*
field
);
std
::
string
TypeName
(
FieldDescriptor
*
field
);
std
::
string
UnderscoresToCamelCase
(
const
string
&
name
,
bool
cap_first_letter
);
std
::
string
UnderscoresToCamelCase
(
const
string
&
name
,
bool
cap_first_letter
);
std
::
string
EscapeDollor
(
const
string
&
to_escape
);
std
::
string
BinaryToHex
(
const
string
&
binary
);
std
::
string
BinaryToHex
(
const
string
&
binary
);
void
Indent
(
io
::
Printer
*
printer
);
void
Indent
(
io
::
Printer
*
printer
);
void
Outdent
(
io
::
Printer
*
printer
);
void
Outdent
(
io
::
Printer
*
printer
);
...
@@ -153,7 +152,7 @@ template <typename DescriptorType>
...
@@ -153,7 +152,7 @@ template <typename DescriptorType>
std
::
string
ClassNamePrefix
(
const
string
&
classname
,
std
::
string
ClassNamePrefix
(
const
string
&
classname
,
const
DescriptorType
*
desc
)
{
const
DescriptorType
*
desc
)
{
const
string
&
prefix
=
(
desc
->
file
()
->
options
()).
php_class_prefix
();
const
string
&
prefix
=
(
desc
->
file
()
->
options
()).
php_class_prefix
();
if
(
prefix
!=
""
)
{
if
(
!
prefix
.
empty
()
)
{
return
prefix
;
return
prefix
;
}
}
...
@@ -244,13 +243,13 @@ template <typename DescriptorType>
...
@@ -244,13 +243,13 @@ template <typename DescriptorType>
std
::
string
RootPhpNamespace
(
const
DescriptorType
*
desc
,
bool
is_descriptor
)
{
std
::
string
RootPhpNamespace
(
const
DescriptorType
*
desc
,
bool
is_descriptor
)
{
if
(
desc
->
file
()
->
options
().
has_php_namespace
())
{
if
(
desc
->
file
()
->
options
().
has_php_namespace
())
{
const
string
&
php_namespace
=
desc
->
file
()
->
options
().
php_namespace
();
const
string
&
php_namespace
=
desc
->
file
()
->
options
().
php_namespace
();
if
(
php_namespace
!=
""
)
{
if
(
!
php_namespace
.
empty
()
)
{
return
php_namespace
;
return
php_namespace
;
}
}
return
""
;
return
""
;
}
}
if
(
desc
->
file
()
->
package
()
!=
""
)
{
if
(
!
desc
->
file
()
->
package
().
empty
()
)
{
return
PhpName
(
desc
->
file
()
->
package
(),
is_descriptor
);
return
PhpName
(
desc
->
file
()
->
package
(),
is_descriptor
);
}
}
return
""
;
return
""
;
...
@@ -260,7 +259,7 @@ template <typename DescriptorType>
...
@@ -260,7 +259,7 @@ template <typename DescriptorType>
std
::
string
FullClassName
(
const
DescriptorType
*
desc
,
bool
is_descriptor
)
{
std
::
string
FullClassName
(
const
DescriptorType
*
desc
,
bool
is_descriptor
)
{
string
classname
=
GeneratedClassNameImpl
(
desc
);
string
classname
=
GeneratedClassNameImpl
(
desc
);
string
php_namespace
=
RootPhpNamespace
(
desc
,
is_descriptor
);
string
php_namespace
=
RootPhpNamespace
(
desc
,
is_descriptor
);
if
(
php_namespace
!=
""
)
{
if
(
!
php_namespace
.
empty
()
)
{
return
php_namespace
+
"
\\
"
+
classname
;
return
php_namespace
+
"
\\
"
+
classname
;
}
}
return
classname
;
return
classname
;
...
@@ -270,7 +269,7 @@ template <typename DescriptorType>
...
@@ -270,7 +269,7 @@ template <typename DescriptorType>
std
::
string
LegacyFullClassName
(
const
DescriptorType
*
desc
,
bool
is_descriptor
)
{
std
::
string
LegacyFullClassName
(
const
DescriptorType
*
desc
,
bool
is_descriptor
)
{
string
classname
=
LegacyGeneratedClassName
(
desc
);
string
classname
=
LegacyGeneratedClassName
(
desc
);
string
php_namespace
=
RootPhpNamespace
(
desc
,
is_descriptor
);
string
php_namespace
=
RootPhpNamespace
(
desc
,
is_descriptor
);
if
(
php_namespace
!=
""
)
{
if
(
!
php_namespace
.
empty
()
)
{
return
php_namespace
+
"
\\
"
+
classname
;
return
php_namespace
+
"
\\
"
+
classname
;
}
}
return
classname
;
return
classname
;
...
@@ -352,7 +351,7 @@ std::string GeneratedMetadataFileName(const FileDescriptor* file,
...
@@ -352,7 +351,7 @@ std::string GeneratedMetadataFileName(const FileDescriptor* file,
if
(
file
->
options
().
has_php_metadata_namespace
())
{
if
(
file
->
options
().
has_php_metadata_namespace
())
{
const
string
&
php_metadata_namespace
=
const
string
&
php_metadata_namespace
=
file
->
options
().
php_metadata_namespace
();
file
->
options
().
php_metadata_namespace
();
if
(
php_metadata_namespace
!=
""
&&
php_metadata_namespace
!=
"
\\
"
)
{
if
(
!
php_metadata_namespace
.
empty
()
&&
php_metadata_namespace
!=
"
\\
"
)
{
result
+=
php_metadata_namespace
;
result
+=
php_metadata_namespace
;
std
::
replace
(
result
.
begin
(),
result
.
end
(),
'\\'
,
'/'
);
std
::
replace
(
result
.
begin
(),
result
.
end
(),
'\\'
,
'/'
);
if
(
result
.
at
(
result
.
size
()
-
1
)
!=
'/'
)
{
if
(
result
.
at
(
result
.
size
()
-
1
)
!=
'/'
)
{
...
@@ -552,45 +551,41 @@ std::string EnumOrMessageSuffix(
...
@@ -552,45 +551,41 @@ std::string EnumOrMessageSuffix(
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// first letter.
// first letter.
std
::
string
UnderscoresToCamelCase
(
const
string
&
input
,
bool
cap_first_letter
)
{
std
::
string
UnderscoresToCamelCase
(
const
string
&
name
,
bool
cap_first_letter
)
{
std
::
string
result
;
std
::
string
result
;
for
(
int
i
=
0
;
i
<
input
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
name
.
size
();
i
++
)
{
if
(
'a'
<=
input
[
i
]
&&
input
[
i
]
<=
'z'
)
{
if
(
'a'
<=
name
[
i
]
&&
name
[
i
]
<=
'z'
)
{
if
(
cap_first_letter
)
{
if
(
cap_first_letter
)
{
result
+=
input
[
i
]
+
(
'A'
-
'a'
);
result
+=
name
[
i
]
+
(
'A'
-
'a'
);
}
else
{
}
else
{
result
+=
input
[
i
];
result
+=
name
[
i
];
}
}
cap_first_letter
=
false
;
cap_first_letter
=
false
;
}
else
if
(
'A'
<=
input
[
i
]
&&
input
[
i
]
<=
'Z'
)
{
}
else
if
(
'A'
<=
name
[
i
]
&&
name
[
i
]
<=
'Z'
)
{
if
(
i
==
0
&&
!
cap_first_letter
)
{
if
(
i
==
0
&&
!
cap_first_letter
)
{
// Force first letter to lower-case unless explicitly told to
// Force first letter to lower-case unless explicitly told to
// capitalize it.
// capitalize it.
result
+=
input
[
i
]
+
(
'a'
-
'A'
);
result
+=
name
[
i
]
+
(
'a'
-
'A'
);
}
else
{
}
else
{
// Capital letters after the first are left as-is.
// Capital letters after the first are left as-is.
result
+=
input
[
i
];
result
+=
name
[
i
];
}
}
cap_first_letter
=
false
;
cap_first_letter
=
false
;
}
else
if
(
'0'
<=
input
[
i
]
&&
input
[
i
]
<=
'9'
)
{
}
else
if
(
'0'
<=
name
[
i
]
&&
name
[
i
]
<=
'9'
)
{
result
+=
input
[
i
];
result
+=
name
[
i
];
cap_first_letter
=
true
;
cap_first_letter
=
true
;
}
else
{
}
else
{
cap_first_letter
=
true
;
cap_first_letter
=
true
;
}
}
}
}
// Add a trailing "_" if the name should be altered.
// Add a trailing "_" if the name should be altered.
if
(
input
[
input
.
size
()
-
1
]
==
'#'
)
{
if
(
name
[
name
.
size
()
-
1
]
==
'#'
)
{
result
+=
'_'
;
result
+=
'_'
;
}
}
return
result
;
return
result
;
}
}
std
::
string
EscapeDollor
(
const
string
&
to_escape
)
{
std
::
string
BinaryToHex
(
const
string
&
binary
)
{
return
StringReplace
(
to_escape
,
"$"
,
"
\\
$"
,
true
);
}
std
::
string
BinaryToHex
(
const
string
&
src
)
{
string
dest
;
string
dest
;
size_t
i
;
size_t
i
;
unsigned
char
symbol
[
16
]
=
{
unsigned
char
symbol
[
16
]
=
{
...
@@ -600,12 +595,12 @@ std::string BinaryToHex(const string& src) {
...
@@ -600,12 +595,12 @@ std::string BinaryToHex(const string& src) {
'c'
,
'd'
,
'e'
,
'f'
,
'c'
,
'd'
,
'e'
,
'f'
,
};
};
dest
.
resize
(
src
.
size
()
*
2
);
dest
.
resize
(
binary
.
size
()
*
2
);
char
*
append_ptr
=
&
dest
[
0
];
char
*
append_ptr
=
&
dest
[
0
];
for
(
i
=
0
;
i
<
src
.
size
();
i
++
)
{
for
(
i
=
0
;
i
<
binary
.
size
();
i
++
)
{
*
append_ptr
++
=
symbol
[(
src
[
i
]
&
0xf0
)
>>
4
];
*
append_ptr
++
=
symbol
[(
binary
[
i
]
&
0xf0
)
>>
4
];
*
append_ptr
++
=
symbol
[
src
[
i
]
&
0x0f
];
*
append_ptr
++
=
symbol
[
binary
[
i
]
&
0x0f
];
}
}
return
dest
;
return
dest
;
...
@@ -1103,7 +1098,7 @@ void LegacyGenerateClassFile(const FileDescriptor* file, const DescriptorType* d
...
@@ -1103,7 +1098,7 @@ void LegacyGenerateClassFile(const FileDescriptor* file, const DescriptorType* d
GenerateHead
(
file
,
&
printer
);
GenerateHead
(
file
,
&
printer
);
std
::
string
php_namespace
=
RootPhpNamespace
(
desc
,
is_descriptor
);
std
::
string
php_namespace
=
RootPhpNamespace
(
desc
,
is_descriptor
);
if
(
php_namespace
!=
""
)
{
if
(
!
php_namespace
.
empty
()
)
{
printer
.
Print
(
printer
.
Print
(
"namespace ^name^;
\n\n
"
,
"namespace ^name^;
\n\n
"
,
"name"
,
php_namespace
);
"name"
,
php_namespace
);
...
...
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