Skip to content

Commit

Permalink
Merge pull request #10 from upfluence/am/json-enum
Browse files Browse the repository at this point in the history
compiler/cpp/src/generate/t_json_generator: Handle enum with particular typeId
  • Loading branch information
AlexisMontagne authored May 3, 2024
2 parents 95ab4bf + 26323d6 commit 889a2b0
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit 889a2b0

Please sign in to comment.