THRIFT-1105. ocaml: OCaml generator does not prefix methods of included structs with...
authorBryan Duxbury <bryanduxbury@apache.org>
Wed, 23 Mar 2011 17:57:21 +0000 (17:57 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Wed, 23 Mar 2011 17:57:21 +0000 (17:57 +0000)
This patch fixes the ocaml generator to generate good code when the 'include' Thrift IDL directive is used.

Patch: Joel Raymont

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1084654 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/generate/t_ocaml_generator.cc

index 46cb9fb..0b9bfb7 100644 (file)
@@ -1470,8 +1470,13 @@ void t_ocaml_generator::generate_deserialize_type(ofstream &out,
  */
 void t_ocaml_generator::generate_deserialize_struct(ofstream &out,
                                                   t_struct* tstruct) {
+  string prefix = "";
+  t_program* program = tstruct->get_program();
+  if (program != NULL && program != program_) {
+     prefix = capitalize(program->get_name()) + "_types.";
+  }
   string name = decapitalize(tstruct->get_name());
-  out << "(read_" << name << " iprot)";
+  out << "(" << prefix << "read_" << name << " iprot)";
 
 }