Make the Cocoa generator use non-hardcoded namespaces.

- Make the Cocoa generator use program->get_namespace("cocoa")
  instead of program->get_cocoa_prefix()
- Eliminate the explicit "cocoa_prefix" in t_program.
- Deprecate the cocoa_prefix token.
- Update example .thrift files and syntax files.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665606 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_cocoa_generator.cc b/compiler/cpp/src/generate/t_cocoa_generator.cc
index cb56c79..759b25c 100644
--- a/compiler/cpp/src/generate/t_cocoa_generator.cc
+++ b/compiler/cpp/src/generate/t_cocoa_generator.cc
@@ -192,7 +192,7 @@
 void t_cocoa_generator::init_generator() {
   // Make output directory
   MKDIR(get_out_dir().c_str());
-  cocoa_prefix_ = program_->get_cocoa_prefix();
+  cocoa_prefix_ = program_->get_namespace("cocoa");
 
   // we have a .h header file...
   string f_header_name = program_name_+".h";
@@ -1734,7 +1734,7 @@
     // Check for prefix
     t_program* program = ttype->get_program();
     if (program != NULL) {
-      result = program->get_cocoa_prefix() + ttype->get_name();
+      result = program->get_namespace("cocoa") + ttype->get_name();
     } else {
       result = ttype->get_name();
     }
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 5d331a5..3afc226 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -216,14 +216,6 @@
     return perl_package_;
   }
 
-  void set_cocoa_prefix(std::string cocoa_prefix) {
-    cocoa_prefix_ = cocoa_prefix;
-  }
-
-  const std::string& get_cocoa_prefix() const {
-    return cocoa_prefix_;
-  }
-
  private:
 
   // File path
@@ -276,8 +268,6 @@
 
   // Perl namespace
   std::string perl_package_;
-  // Cocoa/Objective-C naming prefix
-  std::string cocoa_prefix_;
 
 
   // C# namespace
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index 36b9316..2040d5f 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -325,11 +325,13 @@
         g_program->set_namespace("java", $2);
       }
     }
+/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */
 | tok_cocoa_prefix tok_identifier
     {
+      pwarning(1, "'cocoa_prefix' is deprecated. Use 'namespace cocoa' instead");
       pdebug("Header -> tok_cocoa_prefix tok_identifier");
       if (g_parse_mode == PROGRAM) {
-        g_program->set_cocoa_prefix($2);
+        g_program->set_namespace("cocoa", $2);
       }
     }
 | tok_xsd_namespace tok_literal