You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2013/10/04 19:10:37 UTC
git commit: THRIFT-2215 Generated HTML/Graphviz lists referenced enum
identifiers as UNKNOWN.
Updated Branches:
refs/heads/master aea8bfe0f -> 27148dee9
THRIFT-2215 Generated HTML/Graphviz lists referenced enum identifiers as UNKNOWN.
Patch: Jens Geyer
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/27148dee
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/27148dee
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/27148dee
Branch: refs/heads/master
Commit: 27148dee980b396afee80bc7e5ce704443de4408
Parents: aea8bfe
Author: Jens Geyer <je...@apache.org>
Authored: Fri Oct 4 19:10:16 2013 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Fri Oct 4 19:10:16 2013 +0200
----------------------------------------------------------------------
compiler/cpp/src/generate/t_gv_generator.cc | 21 +++++++++++++-------
compiler/cpp/src/generate/t_html_generator.cc | 23 ++++++++++++++--------
2 files changed, 29 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/27148dee/compiler/cpp/src/generate/t_gv_generator.cc
----------------------------------------------------------------------
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 @@ class t_gv_generator : public t_generator {
* 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 @@ void t_gv_generator::generate_const (t_const* tconst) {
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 @@ void t_gv_generator::print_type(t_type* ttype, string struct_field_ref) {
/**
* 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 @@ void t_gv_generator::print_const_value(t_const_value* tvalue) {
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 @@ void t_gv_generator::print_const_value(t_const_value* tvalue) {
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 @@ void t_gv_generator::generate_service (t_service* tservice) {
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(),
http://git-wip-us.apache.org/repos/asf/thrift/blob/27148dee/compiler/cpp/src/generate/t_html_generator.cc
----------------------------------------------------------------------
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 @@ class t_html_generator : public t_generator {
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 @@ int t_html_generator::print_type(t_type* ttype) {
/**
* 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 @@ void t_html_generator::print_const_value(t_const_value* tvalue) {
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 @@ void t_html_generator::print_const_value(t_const_value* tvalue) {
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 @@ void t_html_generator::generate_const(t_const* tconst) {
<< "</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 @@ void t_html_generator::generate_struct(t_struct* tstruct) {
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 @@ void t_html_generator::generate_service(t_service* tservice) {
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;