Infrastructure for a language-neutral namespace declaration.

Altered the once-deprecated "namespace" directive in .thrift files
to take two identifiers: the language and the namespace.
They are stored in a map inside of the program object.
Future changes will convert specific generators to use this map
and deprecate the old language-specific tokens.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665512 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 7b369d6..d788e2b 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -145,6 +145,19 @@
     }
   }
 
+  // Language neutral namespace / packaging
+  void set_namespace(std::string language, std::string name_space) {
+    namespaces_[language] = name_space;
+  }
+
+  std::string get_namespace(std::string language) const {
+    std::map<std::string, std::string>::const_iterator iter = namespaces_.find(language);
+    if (iter == namespaces_.end()) {
+      return std::string();
+    }
+    return iter->second;
+  }
+
   // Language specific namespace / packaging
 
   void set_cpp_namespace(std::string cpp_namespace) {
@@ -275,6 +288,9 @@
   std::vector<t_struct*>  xceptions_;
   std::vector<t_service*> services_;
 
+  // Dynamic namespaces
+  std::map<std::string, std::string> namespaces_;
+
   // C++ namespace
   std::string cpp_namespace_;
 
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index c104a81..7bd189f 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -247,12 +247,11 @@
     {
       pdebug("Header -> Include");
     }
-| tok_namespace tok_identifier
+| tok_namespace tok_identifier tok_identifier
     {
-      pwarning(1, "'namespace' is deprecated. Use 'cpp_namespace' and/or 'java_package' instead");
+      pdebug("Header -> tok_namespace tok_identifier tok_identifier");
       if (g_parse_mode == PROGRAM) {
-        g_program->set_cpp_namespace($2);
-        g_program->set_java_package($2);
+        g_program->set_namespace($2, $3);
       }
     }
 | tok_cpp_namespace tok_identifier