rpc: RPCHelpMan: Always push_name when outer type is an object
This commit is contained in:
parent
fa652b229e
commit
fa26eb5e8f
1 changed files with 6 additions and 4 deletions
|
@ -208,6 +208,8 @@ struct Sections {
|
||||||
{
|
{
|
||||||
const auto indent = std::string(current_indent, ' ');
|
const auto indent = std::string(current_indent, ' ');
|
||||||
const auto indent_next = std::string(current_indent + 2, ' ');
|
const auto indent_next = std::string(current_indent + 2, ' ');
|
||||||
|
const bool push_name{outer_type == OuterType::OBJ}; // Dictionary keys must have a name
|
||||||
|
|
||||||
switch (arg.m_type) {
|
switch (arg.m_type) {
|
||||||
case RPCArg::Type::STR_HEX:
|
case RPCArg::Type::STR_HEX:
|
||||||
case RPCArg::Type::STR:
|
case RPCArg::Type::STR:
|
||||||
|
@ -217,10 +219,10 @@ struct Sections {
|
||||||
case RPCArg::Type::BOOL: {
|
case RPCArg::Type::BOOL: {
|
||||||
if (outer_type == OuterType::NAMED_ARG) return; // Nothing more to do for non-recursive types on first recursion
|
if (outer_type == OuterType::NAMED_ARG) return; // Nothing more to do for non-recursive types on first recursion
|
||||||
auto left = indent;
|
auto left = indent;
|
||||||
if (arg.m_type_str.size() != 0 && outer_type == OuterType::OBJ) {
|
if (arg.m_type_str.size() != 0 && push_name) {
|
||||||
left += "\"" + arg.m_name + "\": " + arg.m_type_str.at(0);
|
left += "\"" + arg.m_name + "\": " + arg.m_type_str.at(0);
|
||||||
} else {
|
} else {
|
||||||
left += outer_type == OuterType::OBJ ? arg.ToStringObj(/* oneline */ false) : arg.ToString(/* oneline */ false);
|
left += push_name ? arg.ToStringObj(/* oneline */ false) : arg.ToString(/* oneline */ false);
|
||||||
}
|
}
|
||||||
left += ",";
|
left += ",";
|
||||||
PushSection({left, arg.ToDescriptionString()});
|
PushSection({left, arg.ToDescriptionString()});
|
||||||
|
@ -229,7 +231,7 @@ struct Sections {
|
||||||
case RPCArg::Type::OBJ:
|
case RPCArg::Type::OBJ:
|
||||||
case RPCArg::Type::OBJ_USER_KEYS: {
|
case RPCArg::Type::OBJ_USER_KEYS: {
|
||||||
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString();
|
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString();
|
||||||
PushSection({indent + "{", right});
|
PushSection({indent + (push_name ? "\"" + arg.m_name + "\": " : "") + "{", right});
|
||||||
for (const auto& arg_inner : arg.m_inner) {
|
for (const auto& arg_inner : arg.m_inner) {
|
||||||
Push(arg_inner, current_indent + 2, OuterType::OBJ);
|
Push(arg_inner, current_indent + 2, OuterType::OBJ);
|
||||||
}
|
}
|
||||||
|
@ -241,7 +243,7 @@ struct Sections {
|
||||||
}
|
}
|
||||||
case RPCArg::Type::ARR: {
|
case RPCArg::Type::ARR: {
|
||||||
auto left = indent;
|
auto left = indent;
|
||||||
left += outer_type == OuterType::OBJ ? "\"" + arg.m_name + "\": " : "";
|
left += push_name ? "\"" + arg.m_name + "\": " : "";
|
||||||
left += "[";
|
left += "[";
|
||||||
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString();
|
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString();
|
||||||
PushSection({left, right});
|
PushSection({left, right});
|
||||||
|
|
Loading…
Reference in a new issue