mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-06 18:35:19 +00:00
Allow "*" as a catch-all namespace.
In an IDL file, you can can now declare "namespace * foo", which will apply to any language not explicitly specified. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@992012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f723e8d5b5
commit
fb790d7262
@ -189,11 +189,12 @@ class t_program : public t_doc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string get_namespace(std::string language) const {
|
std::string get_namespace(std::string language) const {
|
||||||
std::map<std::string, std::string>::const_iterator iter = namespaces_.find(language);
|
std::map<std::string, std::string>::const_iterator iter;
|
||||||
if (iter == namespaces_.end()) {
|
if ((iter = namespaces_.find(language)) != namespaces_.end() ||
|
||||||
return std::string();
|
(iter = namespaces_.find("*" )) != namespaces_.end()) {
|
||||||
|
return iter->second;
|
||||||
}
|
}
|
||||||
return iter->second;
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Language specific namespace / packaging
|
// Language specific namespace / packaging
|
||||||
|
@ -342,6 +342,11 @@ literal_begin (['\"])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
. {
|
||||||
|
/* Catch-all to let us catch "*" in the parser. */
|
||||||
|
return (int) yytext[0];
|
||||||
|
}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
/* vim: filetype=lex
|
/* vim: filetype=lex
|
||||||
|
@ -280,6 +280,13 @@ Header:
|
|||||||
g_program->set_namespace($2, $3);
|
g_program->set_namespace($2, $3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
| tok_namespace '*' tok_identifier
|
||||||
|
{
|
||||||
|
pdebug("Header -> tok_namespace * tok_identifier");
|
||||||
|
if (g_parse_mode == PROGRAM) {
|
||||||
|
g_program->set_namespace("*", $3);
|
||||||
|
}
|
||||||
|
}
|
||||||
/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */
|
/* TODO(dreiss): Get rid of this once everyone is using the new hotness. */
|
||||||
| tok_cpp_namespace tok_identifier
|
| tok_cpp_namespace tok_identifier
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,7 @@ namespace perl ThriftTest
|
|||||||
namespace csharp Thrift.Test
|
namespace csharp Thrift.Test
|
||||||
namespace js ThriftTest
|
namespace js ThriftTest
|
||||||
namespace st ThriftTest
|
namespace st ThriftTest
|
||||||
|
namespace * thrift.test
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Docstring!
|
* Docstring!
|
||||||
|
Loading…
Reference in New Issue
Block a user