Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
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
brpc
Commits
2979f5c9
Commit
2979f5c9
authored
Oct 31, 2017
by
Zhangyi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
r53423: Fix the bug that empty required arrays in sub messages are not
serialized as empty
parent
c5710867
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
12 deletions
+47
-12
generator.cpp
src/mcpack2pb/generator.cpp
+47
-12
No files found.
src/mcpack2pb/generator.cpp
View file @
2979f5c9
...
@@ -765,12 +765,21 @@ static bool generate_parsing(const google::protobuf::Descriptor* d,
...
@@ -765,12 +765,21 @@ static bool generate_parsing(const google::protobuf::Descriptor* d,
(printer).Print( \
(printer).Print( \
" serializer.add_multiple_$type$($msg$.$lcfield$().data(), $msg$.$lcfield$_size());\n" \
" serializer.add_multiple_$type$($msg$.$lcfield$().data(), $msg$.$lcfield$_size());\n" \
" serializer.end_array();\n" \
" serializer.end_array();\n" \
"} else {\n" \
"}" \
" serializer.add_null();\n" \
"}\n" \
, "msg", msg \
, "msg", msg \
, "type", to_mcpack_typestr(cit, (field)) \
, "type", to_mcpack_typestr(cit, (field)) \
, "lcfield", (field)->lowercase_name()); \
, "lcfield", (field)->lowercase_name()); \
if ((field)->options().GetExtension(idl_on)) { \
(printer).Print( \
" else {\n" \
" serializer.add_empty_array();\n" \
"}\n"); \
} else { \
(printer).Print( \
" else {\n" \
" serializer.add_null();\n" \
"}\n"); \
} \
} else if (looser_cond) { \
} else if (looser_cond) { \
(printer).Print( \
(printer).Print( \
"if ($msg$.$lcfield$_size()) {\n" \
"if ($msg$.$lcfield$_size()) {\n" \
...
@@ -783,12 +792,21 @@ static bool generate_parsing(const google::protobuf::Descriptor* d,
...
@@ -783,12 +792,21 @@ static bool generate_parsing(const google::protobuf::Descriptor* d,
" serializer.add_$type$($msg$.$lcfield$(j));\n" \
" serializer.add_$type$($msg$.$lcfield$(j));\n" \
" }\n" \
" }\n" \
" serializer.end_array();\n" \
" serializer.end_array();\n" \
"} else {\n" \
"}" \
" serializer.add_null();\n" \
"}\n" \
, "msg", msg \
, "msg", msg \
, "type", to_mcpack_typestr(cit, (field)) \
, "type", to_mcpack_typestr(cit, (field)) \
, "lcfield", (field)->lowercase_name()); \
, "lcfield", (field)->lowercase_name()); \
if ((field)->options().GetExtension(idl_on)) { \
(printer).Print( \
" else {\n" \
" serializer.add_empty_array();\n" \
"}\n"); \
} else { \
(printer).Print( \
" else {\n" \
" serializer.add_null();\n" \
"}\n"); \
} \
} else { \
} else { \
if ((field)->type() == google::protobuf::FieldDescriptor::TYPE_ENUM) { \
if ((field)->type() == google::protobuf::FieldDescriptor::TYPE_ENUM) { \
LOG(ERROR) << "Disallow converting " << (field)->full_name() \
LOG(ERROR) << "Disallow converting " << (field)->full_name() \
...
@@ -993,12 +1011,20 @@ static bool generate_serializing(const google::protobuf::Descriptor* d,
...
@@ -993,12 +1011,20 @@ static bool generate_serializing(const google::protobuf::Descriptor* d,
" serializer.end_object();
\n
"
" serializer.end_object();
\n
"
" }
\n
"
" }
\n
"
" serializer.end_array();
\n
"
" serializer.end_array();
\n
"
" }
\n
"
" }"
"} else if (msg.$lcfield$_size()) {
\n
"
,
"field"
,
get_idl_name
(
f
)
,
"field"
,
get_idl_name
(
f
)
,
"lcfield"
,
f
->
lowercase_name
()
,
"lcfield"
,
f
->
lowercase_name
()
,
"vmsg2"
,
var_name2
);
,
"vmsg2"
,
var_name2
);
if
(
f
->
options
().
GetExtension
(
idl_on
))
{
impl
.
Print
(
" else {
\n
"
" serializer.add_empty_array(
\"
$field$
\"
);
\n
"
" }
\n
"
,
"field"
,
get_idl_name
(
f
));
}
else
{
impl
.
Print
(
"
\n
"
);
}
impl
.
Print
(
"} else if (msg.$lcfield$_size()) {
\n
"
,
"lcfield"
,
f
->
lowercase_name
());
impl
.
Indent
();
impl
.
Indent
();
impl
.
Print
(
"serializer.begin_object(
\"
$field$
\"
);
\n
"
impl
.
Print
(
"serializer.begin_object(
\"
$field$
\"
);
\n
"
,
"field"
,
get_idl_name
(
f
));
,
"field"
,
get_idl_name
(
f
));
...
@@ -1032,12 +1058,21 @@ static bool generate_serializing(const google::protobuf::Descriptor* d,
...
@@ -1032,12 +1058,21 @@ static bool generate_serializing(const google::protobuf::Descriptor* d,
" serializer.end_object();
\n
"
" serializer.end_object();
\n
"
" }
\n
"
" }
\n
"
" serializer.end_array();
\n
"
" serializer.end_array();
\n
"
"} else {
\n
"
"}"
" serializer.add_null();
\n
"
"}
\n
"
,
"vmsg3"
,
var_name3
,
"vmsg3"
,
var_name3
,
"lcfield"
,
f
->
lowercase_name
()
,
"lcfield"
,
f
->
lowercase_name
()
,
"lcfield2"
,
f2
->
lowercase_name
());
,
"lcfield2"
,
f2
->
lowercase_name
());
if
(
f2
->
options
().
GetExtension
(
idl_on
))
{
impl
.
Print
(
" else {
\n
"
" serializer.add_empty_array();
\n
"
"}
\n
"
);
}
else
{
impl
.
Print
(
" else {
\n
"
" serializer.add_null();
\n
"
"}
\n
"
);
}
}
else
{
}
else
{
impl
.
Print
(
impl
.
Print
(
"if (msg.$lcfield$(i).has_$lcfield2$()) {
\n
"
"if (msg.$lcfield$(i).has_$lcfield2$()) {
\n
"
...
...
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