Thrift and Python: Made to be together
Summary: Python client code generation for Thrift... HOTNESS!
Notes: Servers and asynchronous clients are coming soon...
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664779 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
index 944cd66..f75bd53 100644
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -21,6 +21,7 @@
#include "generate/t_cpp_generator.h"
#include "generate/t_java_generator.h"
#include "generate/t_php_generator.h"
+#include "generate/t_py_generator.h"
using namespace std;
@@ -99,8 +100,8 @@
fprintf(stderr, " --java Generate Java output files\n");
fprintf(stderr, " --php Generate PHP output files\n");
fprintf(stderr, " --phpi Generate PHP inlined files\n");
- //fprintf(stderr, " -python Generate Python output files\n");
- fprintf(stderr, " --debug Print parse debugging to standard output\n");
+ fprintf(stderr, " --py Generate Python output files\n");
+ fprintf(stderr, " --debug Print parse debugging to standard output\n");
exit(1);
}
@@ -111,6 +112,7 @@
int i;
bool gen_cpp = false;
bool gen_java = false;
+ bool gen_py = false;
bool gen_php = false;
bool php_inline = false;
@@ -136,13 +138,15 @@
} else if (strcmp(argv[i], "--phpi") == 0) {
gen_php = true;
php_inline = true;
+ } else if (strcmp(argv[i], "--py") == 0) {
+ gen_py = true;
} else {
fprintf(stderr, "!!! Unrecognized option: %s\n", argv[i]);
usage();
}
}
- if (!gen_cpp && !gen_java && !gen_php) {
+ if (!gen_cpp && !gen_java && !gen_php && !gen_py) {
fprintf(stderr, "!!! No output language(s) specified\n\n");
usage();
}
@@ -191,6 +195,12 @@
php->generate_program(g_program);
delete php;
}
+
+ if (gen_py) {
+ t_py_generator* py = new t_py_generator();
+ py->generate_program(g_program);
+ delete py;
+ }
} catch (string s) {
printf("Error: %s\n", s.c_str());
} catch (const char* exc) {