From 6a4b82c4b7cc4d77daa6e11f8eb69f1a8f5e3218 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Thu, 27 Mar 2008 21:42:16 +0000 Subject: [PATCH] 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 --- compiler/cpp/src/generate/t_rb_generator.cc | 2 +- compiler/cpp/src/parse/t_program.h | 11 ----------- compiler/cpp/src/thrifty.yy | 4 +++- test/ThriftTest.thrift | 2 +- thrift.el | 2 +- thrift.vim | 2 +- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc index 833dfd3b..395bb642 100644 --- a/compiler/cpp/src/generate/t_rb_generator.cc +++ b/compiler/cpp/src/generate/t_rb_generator.cc @@ -151,7 +151,7 @@ class t_rb_generator : public t_oop_generator { std::vector 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 modules; diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h index 6dcba86d..b544c2fa 100644 --- a/compiler/cpp/src/parse/t_program.h +++ b/compiler/cpp/src/parse/t_program.h @@ -184,14 +184,6 @@ class t_program : public t_doc { 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 @@ class t_program : public t_doc { // 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 53c6d819..d555f53e 100644 --- a/compiler/cpp/src/thrifty.yy +++ b/compiler/cpp/src/thrifty.yy @@ -293,11 +293,13 @@ Header: 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 ddb66e8f..29d4c2e3 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 0d0def8b..988aa196 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 d4f509c8..d95524eb 100644 --- a/thrift.vim +++ b/thrift.vim @@ -31,7 +31,7 @@ syn match thriftNumber "-\=\<\d\+\>" contained " 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 -- 2.17.1