Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler/cpp/src/generate/t_json_generator: Handle enum with particular typeId #10

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/cpp/src/generate/t_json_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void t_json_generator::end_array() {

void t_json_generator::write_type_spec_object(const char* name, t_type* ttype) {
ttype = ttype->get_true_type();
if (ttype->is_struct() || ttype->is_xception() || ttype->is_container()) {
if (ttype->is_struct() || ttype->is_xception() || ttype->is_container() || ttype->is_enum()) {
write_key_and(name);
start_object(NO_INDENT);
write_key_and("typeId");
Expand Down Expand Up @@ -271,6 +271,8 @@ void t_json_generator::write_type_spec(t_type* ttype) {
t_type* etype = ((t_list*)ttype)->get_elem_type();
write_key_and_string("elemTypeId", get_type_name(etype));
write_type_spec_object("elemType", etype);
} else if (ttype->is_enum()) {
write_key_and_string("class", get_qualified_name(ttype));
}
}

Expand Down Expand Up @@ -707,7 +709,7 @@ string t_json_generator::get_type_name(t_type* ttype) {
return "map";
}
if (ttype->is_enum()) {
return "i32";
return "enum";
}
if (ttype->is_struct()) {
return ((t_struct*)ttype)->is_union() ? "union" : "struct";
Expand Down
Loading