summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Reiss <dreiss@apache.org>2009-02-17 20:28:37 +0000
committerDavid Reiss <dreiss@apache.org>2009-02-17 20:28:37 +0000
commit554ea6f936c3ad2c3317e6ba94356c65b088536f (patch)
tree35b0bd685146e7c8d35840ab2f2014fb144c0f4e
parent32272d9bd81f3d05b2dbfd3f504b29aeb9289964 (diff)
downloadthrift-554ea6f936c3ad2c3317e6ba94356c65b088536f.tar.gz
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
-rw-r--r--compiler/cpp/src/generate/t_php_generator.cc2
-rw-r--r--compiler/cpp/src/parse/t_program.h11
-rw-r--r--compiler/cpp/src/thrifty.yy3
-rw-r--r--contrib/thrift.el2
-rw-r--r--contrib/thrift.vim1
-rwxr-xr-xtutorial/tutorial.thrift2
6 files changed, 5 insertions, 16 deletions
diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc
index 53a680f92..08d09162c 100644
--- a/compiler/cpp/src/generate/t_php_generator.cc
+++ b/compiler/cpp/src/generate/t_php_generator.cc
@@ -166,7 +166,7 @@ class t_php_generator : public t_oop_generator {
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 83ffbeaa6..c71ebcce4 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -168,14 +168,6 @@ class t_program : public t_doc {
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 @@ class t_program : public t_doc {
// 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 24f4edac8..b71fd7ea2 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -282,9 +282,10 @@ Header:
}
| 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. */
diff --git a/contrib/thrift.el b/contrib/thrift.el
index 736b7209e..56d2b94a4 100644
--- a/contrib/thrift.el
+++ b/contrib/thrift.el
@@ -10,7 +10,7 @@
(defconst thrift-font-lock-keywords
(list
'("#.*$" . font-lock-comment-face) ;; perl style comments
- '("\\<\\(include\\|struct\\|exception\\|typedef\\|php_namespace\\|const\\|enum\\|service\\|extends\\|void\\|async\\|throws\\|optional\\|required\\)\\>" . font-lock-keyword-face) ;; keywords
+ '("\\<\\(include\\|struct\\|exception\\|typedef\\|const\\|enum\\|service\\|extends\\|void\\|async\\|throws\\|optional\\|required\\)\\>" . font-lock-keyword-face) ;; keywords
'("\\<\\(bool\\|byte\\|i16\\|i32\\|i64\\|double\\|string\\|binary\\|map\\|list\\|set\\)\\>" . font-lock-type-face) ;; built-in types
'("\\<\\([0-9]+\\)\\>" . font-lock-variable-name-face) ;; ordinals
'("\\<\\(\\w+\\)\\s-*(" (1 font-lock-function-name-face)) ;; functions
diff --git a/contrib/thrift.vim b/contrib/thrift.vim
index 04d6a10f6..e8580c71f 100644
--- a/contrib/thrift.vim
+++ b/contrib/thrift.vim
@@ -31,7 +31,6 @@ syn match thriftNumber "-\=\<\d\+\>" contained
" Keywords
syn keyword thriftKeyword namespace
-syn keyword thriftKeyword php_namespace
syn keyword thriftKeyword xsd_all xsd_optional xsd_nillable xsd_attrs
syn keyword thriftKeyword include cpp_include cpp_type const optional required
syn keyword thriftBasicTypes void bool byte i16 i32 i64 double string binary
diff --git a/tutorial/tutorial.thrift b/tutorial/tutorial.thrift
index 2655bcbca..1eb83b6a5 100755
--- a/tutorial/tutorial.thrift
+++ b/tutorial/tutorial.thrift
@@ -47,7 +47,7 @@ include "shared.thrift"
*/
namespace cpp tutorial
namespace java tutorial
-php_namespace tutorial
+namespace php tutorial
namespace perl tutorial
namespace smalltalk.category Thrift.Tutorial