Make the C# generator use non-hardcoded namespaces.
authorDavid Reiss <dreiss@apache.org>
Thu, 27 Mar 2008 21:41:37 +0000 (21:41 +0000)
committerDavid Reiss <dreiss@apache.org>
Thu, 27 Mar 2008 21:41:37 +0000 (21:41 +0000)
- Make the C# generator use program->get_namespace("csharp")
  instead of program->get_csharp_namespace()
- Eliminate the explicit "csharp_namespace" in t_program.
- Deprecate the csharp_namespace token.
- Update example .thrift files and syntax files.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665611 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/generate/t_csharp_generator.cc
compiler/cpp/src/parse/t_program.h
compiler/cpp/src/thrifty.yy
test/ThriftTest.thrift
thrift.el
thrift.vim

index 1e09bff..cfb1ff1 100644 (file)
@@ -103,7 +103,7 @@ class t_csharp_generator : public t_oop_generator
 
 void t_csharp_generator::init_generator() {
   MKDIR(get_out_dir().c_str());
-  namespace_name_ = program_->get_csharp_namespace();
+  namespace_name_ = program_->get_namespace("csharp");
 
   string dir = namespace_name_;
   string subdir = get_out_dir().c_str();
@@ -1501,7 +1501,7 @@ string t_csharp_generator::type_name(t_type* ttype, bool in_container, bool in_i
 
   t_program* program = ttype->get_program();
   if (program != NULL && program != program_) {
-    string ns = program->get_csharp_namespace();
+    string ns = program->get_namespace("csharp");
     if (!ns.empty()) {
       return ns + "." + ttype->get_name();
     }
index 3afc226..bcb3967 100644 (file)
@@ -176,14 +176,6 @@ class t_program : public t_doc {
     return php_namespace_;
   }
 
-  void set_csharp_namespace(std::string csharp_namespace) {
-    csharp_namespace_ = csharp_namespace;
-  }
-
-  const std::string& get_csharp_namespace() const {
-    return csharp_namespace_;
-  }
-
   void set_xsd_namespace(std::string xsd_namespace) {
     xsd_namespace_ = xsd_namespace;
   }
@@ -269,9 +261,6 @@ class t_program : public t_doc {
   // Perl namespace
   std::string perl_package_;
 
-
-  // C# namespace
-  std::string csharp_namespace_;
 };
 
 #endif
index 61febeb..81c7360 100644 (file)
@@ -341,11 +341,13 @@ Header:
         g_program->set_xsd_namespace($2);
       }
     }
+/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */
 | tok_csharp_namespace tok_identifier
    {
+     pwarning(1, "'csharp_namespace' is deprecated. Use 'namespace csharp' instead");
      pdebug("Header -> tok_csharp_namespace tok_identifier");
      if (g_parse_mode == PROGRAM) {
-       g_program->set_csharp_namespace($2);
+       g_program->set_namespace("csharp", $2);
      }
    }
 
index 94a8548..ddb66e8 100644 (file)
@@ -2,7 +2,7 @@ namespace java thrift.test
 namespace cpp thrift.test
 ruby_namespace Thrift.Test
 perl_package ThriftTest
-csharp_namespace Thrift.Test
+namespace csharp Thrift.Test
 
 enum Numberz
 {
index a16817d..e0cf6eb 100644 (file)
--- 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\\|csharp_namespace\\|php_namespace\\|ruby_namespace\\|py_module\\|perl_package\\|const\\|enum\\|service\\|extends\\|void\\|async\\|throws\\|optional\\|required\\)\\>" . font-lock-keyword-face)  ;; keywords
+   '("\\<\\(include\\|struct\\|exception\\|typedef\\|php_namespace\\|ruby_namespace\\|py_module\\|perl_package\\|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
index e2cfa9b..3551dbc 100644 (file)
@@ -31,7 +31,6 @@ syn match thriftNumber "-\=\<\d\+\>" contained
 
 " Keywords
 syn keyword thriftKeyword namespace
-syn keyword thriftKeyword csharp_namespace
 syn keyword thriftKeyword php_namespace ruby_namespace py_module perl_package
 syn keyword thriftKeyword xsd_all xsd_optional xsd_nillable xsd_namespace xsd_attrs
 syn keyword thriftKeyword include cpp_include cpp_type const optional required