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
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc
index 1e09bff..cfb1ff1 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -103,7 +103,7 @@
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 @@
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 3afc226..bcb3967 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -176,14 +176,6 @@
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 @@
// 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 61febeb..81c7360 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -341,11 +341,13 @@
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 94a8548..ddb66e8 100644
--- a/test/ThriftTest.thrift
+++ b/test/ThriftTest.thrift
@@ -2,7 +2,7 @@
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 a16817d..e0cf6eb 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 e2cfa9b..3551dbc 100644
--- a/thrift.vim
+++ b/thrift.vim
@@ -31,7 +31,6 @@
" 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