Make the Ruby generator use non-hardcoded namespaces.
- Make the Ruby generator use program->get_namespace("ruby")
instead of program->get_ruby_namespace()
- Eliminate the explicit "ruby_namespace" in t_program.
- Deprecate the ruby_namespace token.
- Update example .thrift files and syntax files.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665620 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index 833dfd3..395bb64 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -151,7 +151,7 @@
std::vector<std::string> ruby_modules(t_program* p) {
- std::string ns = p->get_ruby_namespace();
+ std::string ns = p->get_namespace("rb");
boost::tokenizer<> tok(ns);
std::vector<std::string> modules;
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 6dcba86..b544c2f 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -184,14 +184,6 @@
return xsd_namespace_;
}
- void set_ruby_namespace(std::string ruby_namespace) {
- ruby_namespace_ = ruby_namespace;
- }
-
- const std::string& get_ruby_namespace() const {
- return ruby_namespace_;
- }
-
void set_perl_package(std::string perl_package) {
perl_package_ = perl_package;
}
@@ -244,9 +236,6 @@
// XSD namespace
std::string xsd_namespace_;
- // Ruby namespace
- std::string ruby_namespace_;
-
// Perl namespace
std::string perl_package_;
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index 53c6d81..d555f53 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -293,11 +293,13 @@
g_program->set_perl_package($2);
}
}
+/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */
| tok_ruby_namespace tok_identifier
{
+ pwarning(1, "'ruby_namespace' is deprecated. Use 'namespace rb' instead");
pdebug("Header -> tok_ruby_namespace tok_identifier");
if (g_parse_mode == PROGRAM) {
- g_program->set_ruby_namespace($2);
+ g_program->set_namespace("rb", $2);
}
}
/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */
diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift
index ddb66e8..29d4c2e 100644
--- a/test/ThriftTest.thrift
+++ b/test/ThriftTest.thrift
@@ -1,6 +1,6 @@
namespace java thrift.test
namespace cpp thrift.test
-ruby_namespace Thrift.Test
+namespace rb Thrift.Test
perl_package ThriftTest
namespace csharp Thrift.Test
diff --git a/thrift.el b/thrift.el
index 0d0def8..988aa19 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\\|php_namespace\\|ruby_namespace\\|perl_package\\|const\\|enum\\|service\\|extends\\|void\\|async\\|throws\\|optional\\|required\\)\\>" . font-lock-keyword-face) ;; keywords
+ '("\\<\\(include\\|struct\\|exception\\|typedef\\|php_namespace\\|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 d4f509c..d95524e 100644
--- a/thrift.vim
+++ b/thrift.vim
@@ -31,7 +31,7 @@
" Keywords
syn keyword thriftKeyword namespace
-syn keyword thriftKeyword php_namespace ruby_namespace perl_package
+syn keyword thriftKeyword php_namespace 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
syn keyword thriftBasicTypes void bool byte i16 i32 i64 double string binary