THRIFT-2215 Generated HTML/Graphviz lists referenced enum identifiers as UNKNOWN.
Patch: Jens Geyer
diff --git a/compiler/cpp/src/generate/t_gv_generator.cc b/compiler/cpp/src/generate/t_gv_generator.cc
index ff6bca1..46c9d38 100644
--- a/compiler/cpp/src/generate/t_gv_generator.cc
+++ b/compiler/cpp/src/generate/t_gv_generator.cc
@@ -80,7 +80,7 @@
* Helpers
*/
void print_type(t_type* ttype, string struct_field_ref);
- void print_const_value(t_const_value* tvalue);
+ void print_const_value(t_type* type, t_const_value* tvalue);
private:
std::ofstream f_out_;
@@ -162,7 +162,7 @@
f_out_ << escape_string(name);
f_out_ << " = ";
- print_const_value(tconst->get_value());
+ print_const_value( tconst->get_type(), tconst->get_value());
f_out_ << " :: ";
print_type(tconst->get_type(), "const_" + name);
@@ -232,7 +232,7 @@
/**
* Prints out an string representation of the provided constant value
*/
-void t_gv_generator::print_const_value(t_const_value* tvalue) {
+void t_gv_generator::print_const_value(t_type* type, t_const_value* tvalue) {
bool first = true;
switch (tvalue->get_type()) {
case t_const_value::CV_INTEGER:
@@ -254,9 +254,9 @@
f_out_ << ", ";
}
first = false;
- print_const_value(map_iter->first);
+ print_const_value( ((t_map*)type)->get_key_type(), map_iter->first);
f_out_ << " = ";
- print_const_value(map_iter->second);
+ print_const_value( ((t_map*)type)->get_val_type(), map_iter->second);
}
f_out_ << " \\}";
}
@@ -271,11 +271,18 @@
f_out_ << ", ";
}
first = false;
- print_const_value(*list_iter);
+ if (type->is_list()) {
+ print_const_value( ((t_list*)type)->get_elem_type(), *list_iter);
+ } else {
+ print_const_value( ((t_set*)type)->get_elem_type(), *list_iter);
+ }
}
f_out_ << " \\}";
}
break;
+ case t_const_value::CV_IDENTIFIER:
+ f_out_ << escape_string(type->get_name()) << "." << escape_string(tvalue->get_identifier_name());
+ break;
default:
f_out_ << "UNKNOWN";
break;
@@ -308,7 +315,7 @@
f_out_ << (*arg_iter)->get_name();
if ((*arg_iter)->get_value() != NULL) {
f_out_ << " = ";
- print_const_value((*arg_iter)->get_value());
+ print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value());
}
f_out_ << " :: ";
print_type((*arg_iter)->get_type(),
diff --git a/compiler/cpp/src/generate/t_html_generator.cc b/compiler/cpp/src/generate/t_html_generator.cc
index 0d0115d..ef1f312 100644
--- a/compiler/cpp/src/generate/t_html_generator.cc
+++ b/compiler/cpp/src/generate/t_html_generator.cc
@@ -99,7 +99,7 @@
void print_doc (t_doc* tdoc);
int print_type (t_type* ttype);
- void print_const_value(t_const_value* tvalue);
+ void print_const_value(t_type* type, t_const_value* tvalue);
void print_fn_args_doc(t_function* tfunction);
private:
@@ -594,7 +594,7 @@
/**
* Prints out an HTML representation of the provided constant value
*/
-void t_html_generator::print_const_value(t_const_value* tvalue) {
+void t_html_generator::print_const_value(t_type* type, t_const_value* tvalue) {
bool first = true;
switch (tvalue->get_type()) {
case t_const_value::CV_INTEGER:
@@ -616,9 +616,9 @@
f_out_ << ", ";
}
first = false;
- print_const_value(map_iter->first);
+ print_const_value( ((t_map*)type)->get_key_type(), map_iter->first);
f_out_ << " = ";
- print_const_value(map_iter->second);
+ print_const_value( ((t_map*)type)->get_val_type(), map_iter->second);
}
f_out_ << " }";
}
@@ -633,11 +633,18 @@
f_out_ << ", ";
}
first = false;
- print_const_value(*list_iter);
+ if (type->is_list()) {
+ print_const_value( ((t_list*)type)->get_elem_type(), *list_iter);
+ } else {
+ print_const_value( ((t_set*)type)->get_elem_type(), *list_iter);
+ }
}
f_out_ << " }";
}
break;
+ case t_const_value::CV_IDENTIFIER:
+ f_out_ << escape_html(type->get_name()) << "." << escape_html(tvalue->get_identifier_name());
+ break;
default:
f_out_ << "UNKNOWN";
break;
@@ -749,7 +756,7 @@
<< "</code></td><td>";
print_type(tconst->get_type());
f_out_ << "</td><td><code>";
- print_const_value(tconst->get_value());
+ print_const_value(tconst->get_type(), tconst->get_value());
f_out_ << "</code></td></tr>";
if (tconst->has_doc()) {
f_out_ << "<tr><td colspan=\"3\"><blockquote>";
@@ -798,7 +805,7 @@
f_out_ << "</td><td>";
t_const_value* default_val = (*mem_iter)->get_value();
if (default_val != NULL) {
- print_const_value(default_val);
+ print_const_value((*mem_iter)->get_type(), default_val);
}
f_out_ << "</td></tr>" << endl;
}
@@ -858,7 +865,7 @@
f_out_ << " " << (*arg_iter)->get_name();
if ((*arg_iter)->get_value() != NULL) {
f_out_ << " = ";
- print_const_value((*arg_iter)->get_value());
+ print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value());
}
}
f_out_ << ")" << endl;