Make the Smalltalk generator use non-hardcoded namespaces.

- Make the Smalltalk generator use program->get_namespace("smalltalk.*")
  instead of program->get_smalltalk_{category|prefix}()
- Eliminate the explicit "smalltalk_{category|prefix}" in t_program.
- Deprecate the smalltalk_{category|prefix} tokens.
- Update example .thrift files and syntax files.

This was a little more complex than the others.  We now convert "." to "-"
in Smalltalk categories, because we no longer lex them as tok_st_identifier.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665601 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_st_generator.cc b/compiler/cpp/src/generate/t_st_generator.cc
index 312e2ba..cf93bdc 100644
--- a/compiler/cpp/src/generate/t_st_generator.cc
+++ b/compiler/cpp/src/generate/t_st_generator.cc
@@ -169,7 +169,7 @@
 }
 
 string t_st_generator::prefix(string class_name) {
-  string prefix = program_->get_smalltalk_prefix();
+  string prefix = program_->get_namespace("smalltalk.prefix");
   string name = capitalize(class_name);
   name = prefix.empty() ? name : (prefix + name);
   return name;
@@ -206,7 +206,14 @@
 }
 
 string t_st_generator::generated_category() {
-  string cat = program_->get_smalltalk_category();
+  string cat = program_->get_namespace("smalltalk.category");
+  // For compatibility with the Thrift grammar, the category must
+  // be punctuated by dots.  Replaces them with dashes here.
+  for (string::iterator iter = cat.begin(); iter != cat.end(); ++iter) {
+    if (*iter == '.') {
+      *iter = '-';
+    }
+  }
   return cat.size() ? cat : "Generated-" + class_name();
 }
 
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 72c3cdd..5d331a5 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -224,22 +224,6 @@
     return cocoa_prefix_;
   }
 
-  void set_smalltalk_category(std::string smalltalk_category) {
-    smalltalk_category_ = smalltalk_category;
-  }
-
-  const std::string& get_smalltalk_category() const {
-    return smalltalk_category_;
-  }
-
-  void set_smalltalk_prefix(std::string smalltalk_prefix) {
-    smalltalk_prefix_ = smalltalk_prefix;
-  }
-
-  const std::string& get_smalltalk_prefix() const {
-    return smalltalk_prefix_;
-  }
-
  private:
 
   // File path
@@ -292,14 +276,9 @@
 
   // Perl namespace
   std::string perl_package_;
-
   // Cocoa/Objective-C naming prefix
   std::string cocoa_prefix_;
 
-  // Smalltalk category
-  std::string smalltalk_category_;
-  // Smalltalk prefix
-  std::string smalltalk_prefix_;
 
   // C# namespace
   std::string csharp_namespace_;
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index db4a4a8..36b9316 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -298,18 +298,22 @@
         g_program->set_ruby_namespace($2);
       }
     }
+/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */
 | tok_smalltalk_category tok_st_identifier
     {
+      pwarning(1, "'smalltalk_category' is deprecated. Use 'namespace smalltalk.category' instead");
       pdebug("Header -> tok_smalltalk_category tok_st_identifier");
       if (g_parse_mode == PROGRAM) {
-        g_program->set_smalltalk_category($2);
+        g_program->set_namespace("smalltalk.category", $2);
       }
     }
+/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */
 | tok_smalltalk_prefix tok_identifier
     {
+      pwarning(1, "'smalltalk_prefix' is deprecated. Use 'namespace smalltalk.prefix' instead");
       pdebug("Header -> tok_smalltalk_prefix tok_identifier");
       if (g_parse_mode == PROGRAM) {
-        g_program->set_smalltalk_prefix($2);
+        g_program->set_namespace("smalltalk.prefix", $2);
       }
     }
 /* TODO(dreiss): Get rid of this once everyone is using the new hotness. */