Dear all,

There are a couple of bugs in the current (1043485) thrift that cause
invalid OCaml to be generated.  One problem is that floats can be
written without a decimal point.  The other is that the copy type in
the mli file is wrong.

I've attached a small patch that fixes both of these issues.

Best wishes,

Richard.
--- thrift-trunk/compiler/cpp/src/generate/t_ocaml_generator.cc	2010-12-08 16:16:01.212340347 +0000
+++ thrift/compiler/cpp/src/generate/t_ocaml_generator.cc	2010-12-08 16:17:04.222336337 +0000
@@ -385,11 +385,11 @@
       break;
     case t_base_type::TYPE_DOUBLE:
       if (value->get_type() == t_const_value::CV_INTEGER) {
-        out << value->get_integer();
+        out << value->get_integer() << ".0";
       } else if(value->get_double() == 0.0) {
         out << "0.0";   // OCaml can't bear '0' in place of double.
       } else {
-        out << value->get_double();
+        out << value->get_double() << ".0";
       }
       break;
     default:
@@ -733,7 +733,7 @@
   vector<t_field*>::const_iterator m_iter;
   string tname = type_name(tstruct);
   indent(out) << "class " << tname << " :" << endl;
-  indent(out) << "object" << endl;
+  indent(out) << "object ('a)" << endl;
 
   indent_up();
 
@@ -750,7 +750,7 @@
       indent(out) << "method reset_" << mname << " : unit" << endl;
     }
   }
-  indent(out) << "method copy : " << tname << endl;
+  indent(out) << "method copy : 'a" << endl;
   indent(out) << "method write : Protocol.t -> unit" << endl;
   indent_down();
   indent(out) << "end" << endl;

Reply via email to