From 9d65bf061f2c9876944e5eddea513a2f50d5e883 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Thu, 27 Mar 2008 21:41:37 +0000 Subject: [PATCH] Make the C# generator use non-hardcoded namespaces. - 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 | 4 ++-- compiler/cpp/src/parse/t_program.h | 11 ----------- compiler/cpp/src/thrifty.yy | 4 +++- test/ThriftTest.thrift | 2 +- thrift.el | 2 +- thrift.vim | 1 - 6 files changed, 7 insertions(+), 17 deletions(-) diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc index 1e09bff4..cfb1ff11 100644 --- a/compiler/cpp/src/generate/t_csharp_generator.cc +++ b/compiler/cpp/src/generate/t_csharp_generator.cc @@ -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(); } diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h index 3afc226c..bcb39672 100644 --- a/compiler/cpp/src/parse/t_program.h +++ b/compiler/cpp/src/parse/t_program.h @@ -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 diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy index 61febebc..81c73607 100644 --- a/compiler/cpp/src/thrifty.yy +++ b/compiler/cpp/src/thrifty.yy @@ -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); } } diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index 94a85489..ddb66e8f 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -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 { diff --git a/thrift.el b/thrift.el index a16817dc..e0cf6ebf 100644 --- 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 diff --git a/thrift.vim b/thrift.vim index e2cfa9b8..3551dbce 100644 --- a/thrift.vim +++ b/thrift.vim @@ -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 -- 2.17.1