Make the Cocoa generator dynamic.

- Modify the Cocoa generator constructor to fit the new generic interface.
- Register the Cocoa genrator with the central registry.
- Deprecate the old way of invoking the Cocoa generator.
- main.cc no longer includes t_cocoa_generator.h.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665603 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 2b325c4..4be14db 100644
--- a/compiler/cpp/src/generate/t_cocoa_generator.cc
+++ b/compiler/cpp/src/generate/t_cocoa_generator.cc
@@ -1867,3 +1867,6 @@
 string t_cocoa_generator::call_field_setter(t_field* tfield, string fieldName) {
   return "[self set" + capitalize(tfield->get_name()) + ": " + fieldName + "];";
 }
+
+
+THRIFT_REGISTER_GENERATOR(cocoa, "Cocoa", "");
diff --git a/compiler/cpp/src/generate/t_cocoa_generator.h b/compiler/cpp/src/generate/t_cocoa_generator.h
index 79f3007..1d68fa5 100644
--- a/compiler/cpp/src/generate/t_cocoa_generator.h
+++ b/compiler/cpp/src/generate/t_cocoa_generator.h
@@ -22,8 +22,12 @@
  */
 class t_cocoa_generator : public t_oop_generator {
  public:
-  t_cocoa_generator(t_program* program) :
-    t_oop_generator(program) {
+  t_cocoa_generator(
+      t_program* program,
+      const std::map<std::string, std::string>& parsed_options,
+      const std::string& option_string)
+    : t_oop_generator(program)
+  {
     out_dir_base_ = "gen-cocoa";
   }
 
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
index dfd5f9e..3499035 100644
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -41,7 +41,6 @@
 #include "generate/t_xsd_generator.h"
 #include "generate/t_perl_generator.h"
 #include "generate/t_erl_generator.h"
-#include "generate/t_cocoa_generator.h"
 #include "generate/t_csharp_generator.h"
 
 using namespace std;
@@ -610,7 +609,6 @@
   fprintf(stderr, "  -xsd        Generate XSD output files\n");
   fprintf(stderr, "  -perl       Generate Perl output files\n");
   fprintf(stderr, "  -erl        Generate Erlang output files\n");
-  fprintf(stderr, "  -cocoa      Generate Cocoa/Objective-C output files\n");
   fprintf(stderr, "  -csharp     Generate C# output files\n");
   fprintf(stderr, "  -o dir      Set the output directory for gen-* packages\n");
   fprintf(stderr, "               (default: current directory)\n");
@@ -909,13 +907,6 @@
       delete erl;
     }
 
-    if (gen_cocoa) {
-      pverbose("Generating Cocoa/Objective-C\n");
-      t_cocoa_generator* cocoa = new t_cocoa_generator(program);
-      cocoa->generate_program();
-      delete cocoa;
-    }
-
     if (gen_csharp) {
       pverbose("Generating C#\n");
       t_csharp_generator* csharp = new t_csharp_generator(program);
@@ -1116,6 +1107,10 @@
     pwarning(1, "-javabean is deprecated.  Use --gen java:beans");
     generator_strings.push_back("java:beans");
   }
+  if (gen_cocoa) {
+    pwarning(1, "-cocoa is deprecated.  Use --gen cocoa");
+    generator_strings.push_back("cocoa");
+  }
   if (gen_st) {
     pwarning(1, "-st is deprecated.  Use --gen st");
     generator_strings.push_back("st");
@@ -1130,7 +1125,7 @@
   }
 
   // You gotta generate something!
-  if (!gen_php && !gen_phpi && !gen_py && !gen_rb && !gen_xsd && !gen_perl && !gen_erl && !gen_cocoa && !gen_csharp && generator_strings.empty()) {
+  if (!gen_php && !gen_phpi && !gen_py && !gen_rb && !gen_xsd && !gen_perl && !gen_erl && !gen_csharp && generator_strings.empty()) {
     fprintf(stderr, "!!! No output language(s) specified\n\n");
     usage();
   }