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 3bdc5a0..1e7483e 100644
--- a/compiler/cpp/src/generate/t_perl_generator.cc
+++ b/compiler/cpp/src/generate/t_perl_generator.cc
@@ -149,7 +149,7 @@
   }
 
   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 @@
   }
 
   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 b544c2f..4e99294 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -184,14 +184,6 @@
     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 @@
   // 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 d555f53..654c85a 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -286,11 +286,13 @@
         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 29d4c2e..b11e1f2 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 988aa19..736b720 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 d95524e..e350a4e 100644
--- a/thrift.vim
+++ b/thrift.vim
@@ -31,7 +31,7 @@
 
 " 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 e986537..28de241 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 8a72f60..bf0ffa0 100755
--- a/tutorial/tutorial.thrift
+++ b/tutorial/tutorial.thrift
@@ -47,7 +47,7 @@
 namespace cpp tutorial
 namespace java tutorial
 php_namespace tutorial
-perl_package tutorial
+namespace perl tutorial
 namespace smalltalk.category Thrift.Tutorial
 
 /**