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
diff --git a/compiler/cpp/src/generate/t_cocoa_generator.cc b/compiler/cpp/src/generate/t_cocoa_generator.cc
index cb56c79..759b25c 100644
--- a/compiler/cpp/src/generate/t_cocoa_generator.cc
+++ b/compiler/cpp/src/generate/t_cocoa_generator.cc
@@ -192,7 +192,7 @@
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 @@
// 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 5d331a5..3afc226 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -216,14 +216,6 @@
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 @@
// 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 36b9316..2040d5f 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -325,11 +325,13 @@
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 a8c6adb..a16817d 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 115e936..e2cfa9b 100644
--- a/thrift.vim
+++ b/thrift.vim
@@ -30,7 +30,7 @@
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