Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
protobuf-c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
protobuf-c
Commits
75f1c32c
Commit
75f1c32c
authored
Feb 08, 2025
by
Robert Edmonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert string views to owned strings where necessary
parent
bc2cb66d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
8 deletions
+7
-8
protoc-gen-c/c_enum.cc
protoc-gen-c/c_enum.cc
+1
-1
protoc-gen-c/c_enum_field.cc
protoc-gen-c/c_enum_field.cc
+1
-1
protoc-gen-c/c_helpers.cc
protoc-gen-c/c_helpers.cc
+4
-4
protoc-gen-c/c_helpers.h
protoc-gen-c/c_helpers.h
+1
-2
No files found.
protoc-gen-c/c_enum.cc
View file @
75f1c32c
...
...
@@ -152,7 +152,7 @@ void EnumGenerator::GenerateValueInitializer(google::protobuf::io::Printer *prin
descriptor_
->
file
()
->
options
().
optimize_for
()
==
google
::
protobuf
::
FileOptions_OptimizeMode_CODE_SIZE
;
vars
[
"enum_value_name"
]
=
vd
->
name
();
vars
[
"c_enum_value_name"
]
=
FullNameToUpper
(
descriptor_
->
full_name
(),
descriptor_
->
file
())
+
"__"
+
vd
->
name
(
);
vars
[
"c_enum_value_name"
]
=
FullNameToUpper
(
descriptor_
->
full_name
(),
descriptor_
->
file
())
+
"__"
+
std
::
string
(
vd
->
name
()
);
vars
[
"value"
]
=
SimpleItoa
(
vd
->
number
());
if
(
optimize_code_size
)
printer
->
Print
(
vars
,
" { NULL, NULL, $value$ }, /* CODE_SIZE */
\n
"
);
...
...
protoc-gen-c/c_enum_field.cc
View file @
75f1c32c
...
...
@@ -78,7 +78,7 @@ void SetEnumVariables(const google::protobuf::FieldDescriptor* descriptor,
(
*
variables
)[
"type"
]
=
FullNameToC
(
descriptor
->
enum_type
()
->
full_name
(),
descriptor
->
enum_type
()
->
file
());
const
google
::
protobuf
::
EnumValueDescriptor
*
default_value
=
descriptor
->
default_value_enum
();
(
*
variables
)[
"default"
]
=
FullNameToUpper
(
default_value
->
type
()
->
full_name
(),
default_value
->
type
()
->
file
())
+
"__"
+
default_value
->
name
(
);
+
"__"
+
std
::
string
(
default_value
->
name
()
);
(
*
variables
)[
"deprecated"
]
=
FieldDeprecated
(
descriptor
);
}
...
...
protoc-gen-c/c_helpers.cc
View file @
75f1c32c
...
...
@@ -178,13 +178,13 @@ std::string ToCamel(compat::StringView name) {
std
::
string
OverrideFullName
(
compat
::
StringView
full_name
,
const
google
::
protobuf
::
FileDescriptor
*
file
)
{
const
ProtobufCFileOptions
opt
=
file
->
options
().
GetExtension
(
pb_c_file
);
if
(
!
opt
.
has_c_package
())
return
full_name
;
return
std
::
string
(
full_name
)
;
std
::
string
new_name
=
opt
.
c_package
();
if
(
file
->
package
().
empty
())
new_name
+=
"."
;
return
new_name
+
full_name
.
substr
(
file
->
package
().
length
(
));
return
new_name
+
std
::
string
(
full_name
.
substr
(
file
->
package
().
length
()
));
}
std
::
string
FullNameToLower
(
compat
::
StringView
full_name
,
const
google
::
protobuf
::
FileDescriptor
*
file
)
{
...
...
@@ -418,10 +418,10 @@ void SplitStringToIteratorUsing(compat::StringView full,
while
(
begin_index
!=
std
::
string
::
npos
)
{
end_index
=
full
.
find_first_of
(
delim
,
begin_index
);
if
(
end_index
==
std
::
string
::
npos
)
{
*
result
++
=
full
.
substr
(
begin_index
);
*
result
++
=
std
::
string
(
full
.
substr
(
begin_index
)
);
return
;
}
*
result
++
=
full
.
substr
(
begin_index
,
(
end_index
-
begin_index
));
*
result
++
=
std
::
string
(
full
.
substr
(
begin_index
,
(
end_index
-
begin_index
)
));
begin_index
=
full
.
find_first_not_of
(
delim
,
end_index
);
}
}
...
...
protoc-gen-c/c_helpers.h
View file @
75f1c32c
...
...
@@ -89,10 +89,9 @@ std::string SimpleDtoa(double f);
void
SplitStringUsing
(
compat
::
StringView
str
,
const
char
*
delim
,
std
::
vector
<
std
::
string
>
*
out
);
std
::
string
CEscape
(
compat
::
StringView
src
);
inline
bool
HasSuffixString
(
compat
::
StringView
str
,
compat
::
StringView
suffix
)
{
return
str
.
size
()
>=
suffix
.
size
()
&&
str
.
compare
(
str
.
size
()
-
suffix
.
size
(),
suffix
.
size
(),
suffix
)
==
0
;
}
inline
std
::
string
StripSuffixString
(
compat
::
StringView
str
,
compat
::
StringView
suffix
)
{
if
(
HasSuffixString
(
str
,
suffix
))
{
return
st
r
.
substr
(
0
,
str
.
size
()
-
suffix
.
size
());
}
else
{
return
str
;
}
}
inline
std
::
string
StripSuffixString
(
compat
::
StringView
str
,
compat
::
StringView
suffix
)
{
if
(
HasSuffixString
(
str
,
suffix
))
{
return
st
d
::
string
(
str
.
substr
(
0
,
str
.
size
()
-
suffix
.
size
()));
}
else
{
return
std
::
string
(
str
)
;
}
}
char
*
FastHexToBuffer
(
int
i
,
char
*
buffer
);
// Get the (unqualified) name that should be used for this field in C code.
// The name is coerced to lower-case to emulate proto1 behavior. People
// should be using lowercase-with-underscores style for proto field names
...
...
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