Make the PHP generator use non-hardcoded namespaces.
- Make the PHP generator use program->get_namespace("php")
instead of program->get_php_namespace()
- Eliminate the explicit "php_namespace" in t_program.
- Deprecate the php_namespace token.
- Update example .thrift files and syntax files.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@745241 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc
index 53a680f..08d0916 100644
--- a/compiler/cpp/src/generate/t_php_generator.cc
+++ b/compiler/cpp/src/generate/t_php_generator.cc
@@ -166,7 +166,7 @@
std::string type_to_enum(t_type* ttype);
std::string php_namespace(t_program* p) {
- std::string ns = p->get_php_namespace();
+ std::string ns = p->get_namespace("php");
return ns.size() ? (ns + "_") : "";
}
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 83ffbea..c71ebcc 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -168,14 +168,6 @@
return cpp_includes_;
}
- void set_php_namespace(std::string php_namespace) {
- php_namespace_ = php_namespace;
- }
-
- const std::string& get_php_namespace() const {
- return php_namespace_;
- }
-
private:
// File path
@@ -214,9 +206,6 @@
// C++ extra includes
std::vector<std::string> cpp_includes_;
- // PHP namespace
- std::string php_namespace_;
-
};
#endif
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index 24f4eda..b71fd7e 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -282,9 +282,10 @@
}
| tok_php_namespace tok_identifier
{
+ pwarning(1, "'php_namespace' is deprecated. Use 'namespace php' instead");
pdebug("Header -> tok_php_namespace tok_identifier");
if (g_parse_mode == PROGRAM) {
- g_program->set_php_namespace($2);
+ g_program->set_namespace("php", $2);
}
}
/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */