From: David Reiss Date: Thu, 27 Mar 2008 21:42:39 +0000 (+0000) Subject: Make the Perl generator use non-hardcoded namespaces. X-Git-Tag: 0.2.0~848 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=07ef3a930a8f99b41ce381f9fda3aa6785bd3956;p=common%2Fthrift.git Make the Perl generator use non-hardcoded namespaces. - Make the Perl generator use program->get_namespace("perl") instead of program->get_perl_package() - Eliminate the explicit "perl_package" in t_program. - Deprecate the perl_package token. - Update example .thrift files and syntax files. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665624 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_perl_generator.cc b/compiler/cpp/src/generate/t_perl_generator.cc index 3bdc5a05..1e7483e7 100644 --- a/compiler/cpp/src/generate/t_perl_generator.cc +++ b/compiler/cpp/src/generate/t_perl_generator.cc @@ -149,7 +149,7 @@ class t_perl_generator : public t_oop_generator { } void perl_namespace_dirs(t_program* p, std::list& dirs) { - std::string ns = p->get_perl_package(); + std::string ns = p->get_namespace("perl"); std::string::size_type loc; if (ns.size() > 0) { @@ -165,7 +165,7 @@ class t_perl_generator : public t_oop_generator { } std::string perl_namespace(t_program* p) { - std::string ns = p->get_perl_package(); + std::string ns = p->get_namespace("perl"); std::string result = ""; std::string::size_type loc; diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h index b544c2fa..4e99294d 100644 --- a/compiler/cpp/src/parse/t_program.h +++ b/compiler/cpp/src/parse/t_program.h @@ -184,14 +184,6 @@ class t_program : public t_doc { return xsd_namespace_; } - void set_perl_package(std::string perl_package) { - perl_package_ = perl_package; - } - - const std::string& get_perl_package() const { - return perl_package_; - } - private: // File path @@ -236,9 +228,6 @@ class t_program : public t_doc { // XSD namespace std::string xsd_namespace_; - // Perl namespace - std::string perl_package_; - }; #endif diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy index d555f53e..654c85af 100644 --- a/compiler/cpp/src/thrifty.yy +++ b/compiler/cpp/src/thrifty.yy @@ -286,11 +286,13 @@ Header: g_program->set_namespace("py", $2); } } +/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */ | tok_perl_package tok_identifier { + pwarning(1, "'perl_package' is deprecated. Use 'namespace perl' instead"); pdebug("Header -> tok_perl_namespace tok_identifier"); if (g_parse_mode == PROGRAM) { - g_program->set_perl_package($2); + g_program->set_namespace("perl", $2); } } /* TODO(dreiss): Get rid of this once everyone is using the new hotness. */ diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index 29d4c2e3..b11e1f28 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -1,7 +1,7 @@ namespace java thrift.test namespace cpp thrift.test namespace rb Thrift.Test -perl_package ThriftTest +namespace perl ThriftTest namespace csharp Thrift.Test enum Numberz diff --git a/thrift.el b/thrift.el index 988aa196..736b7209 100644 --- a/thrift.el +++ b/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\\|perl_package\\|const\\|enum\\|service\\|extends\\|void\\|async\\|throws\\|optional\\|required\\)\\>" . font-lock-keyword-face) ;; keywords + '("\\<\\(include\\|struct\\|exception\\|typedef\\|php_namespace\\|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/thrift.vim b/thrift.vim index d95524eb..e350a4ee 100644 --- a/thrift.vim +++ b/thrift.vim @@ -31,7 +31,7 @@ syn match thriftNumber "-\=\<\d\+\>" contained " Keywords syn keyword thriftKeyword namespace -syn keyword thriftKeyword php_namespace perl_package +syn keyword thriftKeyword php_namespace syn keyword thriftKeyword xsd_all xsd_optional xsd_nillable xsd_namespace 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/shared.thrift b/tutorial/shared.thrift index e986537e..28de2412 100755 --- a/tutorial/shared.thrift +++ b/tutorial/shared.thrift @@ -7,7 +7,7 @@ namespace cpp shared namespace java shared -perl_package shared +namespace perl shared struct SharedStruct { 1: i32 key diff --git a/tutorial/tutorial.thrift b/tutorial/tutorial.thrift index 8a72f60b..bf0ffa0a 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 -perl_package tutorial +namespace perl tutorial namespace smalltalk.category Thrift.Tutorial /**