Make the OCaml generator dynamic.
- Modify the OCaml generator constructor to fit the new generic interface.
- Register the OCaml genrator with the central registry.
- Deprecate the old way of invoking the OCaml generator.
- main.cc no longer includes t_ocaml_generator.h.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665591 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_ocaml_generator.cc b/compiler/cpp/src/generate/t_ocaml_generator.cc
index eafda46..88757bc 100644
--- a/compiler/cpp/src/generate/t_ocaml_generator.cc
+++ b/compiler/cpp/src/generate/t_ocaml_generator.cc
@@ -1510,3 +1510,6 @@
throw "INVALID TYPE IN type_to_enum: " + type->get_name();
}
+
+
+THRIFT_REGISTER_GENERATOR(ocaml, "OCaml", "");
diff --git a/compiler/cpp/src/generate/t_ocaml_generator.h b/compiler/cpp/src/generate/t_ocaml_generator.h
index 56f2a89..25bffdc 100644
--- a/compiler/cpp/src/generate/t_ocaml_generator.h
+++ b/compiler/cpp/src/generate/t_ocaml_generator.h
@@ -21,8 +21,12 @@
*/
class t_ocaml_generator : public t_oop_generator {
public:
- t_ocaml_generator(t_program* program) :
- t_oop_generator(program) {
+ t_ocaml_generator(
+ t_program* program,
+ const std::map<std::string, std::string>& parsed_options,
+ const std::string& option_string)
+ : t_oop_generator(program)
+ {
out_dir_base_ = "gen-ocaml";
}
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
index 6b80ff5..664db13 100644
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -41,7 +41,6 @@
#include "generate/t_xsd_generator.h"
#include "generate/t_perl_generator.h"
#include "generate/t_erl_generator.h"
-#include "generate/t_ocaml_generator.h"
#include "generate/t_hs_generator.h"
#include "generate/t_cocoa_generator.h"
#include "generate/t_st_generator.h"
@@ -613,7 +612,6 @@
fprintf(stderr, " -xsd Generate XSD output files\n");
fprintf(stderr, " -perl Generate Perl output files\n");
fprintf(stderr, " -erl Generate Erlang output files\n");
- fprintf(stderr, " -ocaml Generate OCaml output files\n");
fprintf(stderr, " -hs Generate Haskell output files\n");
fprintf(stderr, " -cocoa Generate Cocoa/Objective-C output files\n");
fprintf(stderr, " -csharp Generate C# output files\n");
@@ -915,13 +913,6 @@
delete erl;
}
- if (gen_ocaml) {
- pverbose("Generating OCaml\n");
- t_ocaml_generator* ocaml = new t_ocaml_generator(program);
- ocaml->generate_program();
- delete ocaml;
- }
-
if (gen_hs) {
pverbose("Generating Haskell\n");
t_hs_generator* hs = new t_hs_generator(program);
@@ -1143,9 +1134,13 @@
pwarning(1, "-javabean is deprecated. Use --gen java:beans");
generator_strings.push_back("java:beans");
}
+ if (gen_ocaml) {
+ pwarning(1, "-ocaml is deprecated. Use --gen ocaml");
+ generator_strings.push_back("ocaml");
+ }
// You gotta generate something!
- if (!gen_php && !gen_phpi && !gen_py && !gen_rb && !gen_xsd && !gen_perl && !gen_erl && !gen_ocaml && !gen_hs && !gen_cocoa && !gen_st && !gen_csharp && generator_strings.empty()) {
+ if (!gen_php && !gen_phpi && !gen_py && !gen_rb && !gen_xsd && !gen_perl && !gen_erl && !gen_hs && !gen_cocoa && !gen_st && !gen_csharp && generator_strings.empty()) {
fprintf(stderr, "!!! No output language(s) specified\n\n");
usage();
}