Make the Perl generator use non-hardcoded namespaces.
authorDavid Reiss <dreiss@apache.org>
Thu, 27 Mar 2008 21:42:39 +0000 (21:42 +0000)
committerDavid Reiss <dreiss@apache.org>
Thu, 27 Mar 2008 21:42:39 +0000 (21:42 +0000)
- 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

compiler/cpp/src/generate/t_perl_generator.cc
compiler/cpp/src/parse/t_program.h
compiler/cpp/src/thrifty.yy
test/ThriftTest.thrift
thrift.el
thrift.vim
tutorial/shared.thrift
tutorial/tutorial.thrift

index 3bdc5a0..1e7483e 100644 (file)
@@ -149,7 +149,7 @@ class t_perl_generator : public t_oop_generator {
   }
 
   void perl_namespace_dirs(t_program* p, std::list<std::string>& 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;
 
index b544c2f..4e99294 100644 (file)
@@ -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
index d555f53..654c85a 100644 (file)
@@ -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. */
index 29d4c2e..b11e1f2 100644 (file)
@@ -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
index 988aa19..736b720 100644 (file)
--- 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
index d95524e..e350a4e 100644 (file)
@@ -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
index e986537..28de241 100755 (executable)
@@ -7,7 +7,7 @@
 
 namespace cpp shared
 namespace java shared
-perl_package shared
+namespace perl shared
 
 struct SharedStruct {
   1: i32 key
index 8a72f60..bf0ffa0 100755 (executable)
@@ -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
 
 /**