Thrift: Support for explicit Python module declaration.
Summary:
Previously, Thrift used the name of the .thrift file as the python module name.
This wasn't very flexible. Now the python module can be explicitly declared.
Also, there was no need for t_py_generator to inherit from t_oop_generator.
Reviewed By: mcslee
Test Plan:
cd test/py/explicit_module
./runtest.sh
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665234 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index 38ca516..8533805 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -75,6 +75,7 @@
%token tok_cpp_include
%token tok_cpp_type
%token tok_php_namespace
+%token tok_py_module
%token tok_perl_package
%token tok_java_package
%token tok_xsd_all
@@ -269,6 +270,13 @@
g_program->set_php_namespace($2);
}
}
+| tok_py_module tok_identifier
+ {
+ pdebug("Header -> tok_py_module tok_identifier");
+ if (g_parse_mode == PROGRAM) {
+ g_program->set_py_module($2);
+ }
+ }
| tok_perl_package tok_identifier
{
pdebug("Header -> tok_perl_namespace tok_identifier");