From 54b602b7468dd1260a3d65d389e449b572cdff0f Mon Sep 17 00:00:00 2001 From: David Reiss Date: Thu, 27 Mar 2008 21:41:06 +0000 Subject: [PATCH] Make the Cocoa generator use non-hardcoded namespaces. - Make the Cocoa generator use program->get_namespace("cocoa") instead of program->get_cocoa_prefix() - Eliminate the explicit "cocoa_prefix" in t_program. - Deprecate the cocoa_prefix token. - Update example .thrift files and syntax files. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665606 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/generate/t_cocoa_generator.cc | 4 ++-- compiler/cpp/src/parse/t_program.h | 10 ---------- compiler/cpp/src/thrifty.yy | 4 +++- thrift.el | 2 +- thrift.vim | 2 +- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/compiler/cpp/src/generate/t_cocoa_generator.cc b/compiler/cpp/src/generate/t_cocoa_generator.cc index cb56c794..759b25cb 100644 --- a/compiler/cpp/src/generate/t_cocoa_generator.cc +++ b/compiler/cpp/src/generate/t_cocoa_generator.cc @@ -192,7 +192,7 @@ class t_cocoa_generator : public t_oop_generator { void t_cocoa_generator::init_generator() { // Make output directory MKDIR(get_out_dir().c_str()); - cocoa_prefix_ = program_->get_cocoa_prefix(); + cocoa_prefix_ = program_->get_namespace("cocoa"); // we have a .h header file... string f_header_name = program_name_+".h"; @@ -1734,7 +1734,7 @@ string t_cocoa_generator::type_name(t_type* ttype, bool class_ref) { // Check for prefix t_program* program = ttype->get_program(); if (program != NULL) { - result = program->get_cocoa_prefix() + ttype->get_name(); + result = program->get_namespace("cocoa") + ttype->get_name(); } else { result = ttype->get_name(); } diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h index 5d331a53..3afc226c 100644 --- a/compiler/cpp/src/parse/t_program.h +++ b/compiler/cpp/src/parse/t_program.h @@ -216,14 +216,6 @@ class t_program : public t_doc { return perl_package_; } - void set_cocoa_prefix(std::string cocoa_prefix) { - cocoa_prefix_ = cocoa_prefix; - } - - const std::string& get_cocoa_prefix() const { - return cocoa_prefix_; - } - private: // File path @@ -276,8 +268,6 @@ class t_program : public t_doc { // Perl namespace std::string perl_package_; - // Cocoa/Objective-C naming prefix - std::string cocoa_prefix_; // C# namespace diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy index 36b93169..2040d5f3 100644 --- a/compiler/cpp/src/thrifty.yy +++ b/compiler/cpp/src/thrifty.yy @@ -325,11 +325,13 @@ Header: g_program->set_namespace("java", $2); } } +/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */ | tok_cocoa_prefix tok_identifier { + pwarning(1, "'cocoa_prefix' is deprecated. Use 'namespace cocoa' instead"); pdebug("Header -> tok_cocoa_prefix tok_identifier"); if (g_parse_mode == PROGRAM) { - g_program->set_cocoa_prefix($2); + g_program->set_namespace("cocoa", $2); } } | tok_xsd_namespace tok_literal diff --git a/thrift.el b/thrift.el index a8c6adb8..a16817dc 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\\|cocoa_prefix\\|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\\|csharp_namespace\\|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 115e9369..e2cfa9b8 100644 --- a/thrift.vim +++ b/thrift.vim @@ -30,7 +30,7 @@ syn region thriftStringDouble matchgroup=None start=+"+ end=+"+ syn match thriftNumber "-\=\<\d\+\>" contained " Keywords -syn keyword thriftKeyword namespace cocoa_prefix +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 -- 2.17.1