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 2015/07/11 11:48:48 UTC

thrift git commit: THRIFT-3230: transform typedef when getting type name Client: Python Patch: 软件工程师李飛

Repository: thrift
Updated Branches:
  refs/heads/master 90c60e340 -> 01a77ab01


THRIFT-3230: transform typedef when getting type name
Client: Python
Patch: 软件工程师李飛 <li...@7v1.net>

This closes #545

Python compiler generates wrong code if there is function throwing a typedef of exception with another namespace. We should use the real type name instead of  the name of typedef.


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/01a77ab0
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/01a77ab0
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/01a77ab0

Branch: refs/heads/master
Commit: 01a77ab01e7459d96059a2b49d9885d14a360ef1
Parents: 90c60e3
Author: Jens Geyer <je...@apache.org>
Authored: Sat Jul 11 11:41:32 2015 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Sat Jul 11 11:46:38 2015 +0200

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_py_generator.cc | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/01a77ab0/compiler/cpp/src/generate/t_py_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index 08a3536..2002c1e 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -2339,6 +2339,10 @@ string t_py_generator::argument_list(t_struct* tstruct, vector<string>* pre, vec
 }
 
 string t_py_generator::type_name(t_type* ttype) {
+  while (ttype->is_typedef()) {
+    ttype = ((t_typedef*)ttype)->get_type();
+  }
+
   t_program* program = ttype->get_program();
   if (ttype->is_service()) {
     return get_real_py_module(program, gen_twisted_) + "." + ttype->get_name();