mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 02:45:22 +00:00
THRIFT-3417: "namespace xsd" is not really working
Client: XSD Patch: Benjamin Gould This closes #691
This commit is contained in:
parent
a6b120301a
commit
cc193c1bec
@ -260,6 +260,11 @@ void t_xsd_generator::generate_service(t_service* tservice) {
|
|||||||
f_xsd_.open(f_xsd_name.c_str());
|
f_xsd_.open(f_xsd_name.c_str());
|
||||||
|
|
||||||
string ns = program_->get_namespace("xsd");
|
string ns = program_->get_namespace("xsd");
|
||||||
|
const std::map<std::string, std::string> annot = program_->get_namespace_annotations("xsd");
|
||||||
|
const std::map<std::string, std::string>::const_iterator uri = annot.find("uri");
|
||||||
|
if (uri != annot.end()) {
|
||||||
|
ns = uri->second;
|
||||||
|
}
|
||||||
if (ns.size() > 0) {
|
if (ns.size() > 0) {
|
||||||
ns = " targetNamespace=\"" + ns + "\" xmlns=\"" + ns + "\" "
|
ns = " targetNamespace=\"" + ns + "\" xmlns=\"" + ns + "\" "
|
||||||
+ "elementFormDefault=\"qualified\"";
|
+ "elementFormDefault=\"qualified\"";
|
||||||
|
@ -324,6 +324,15 @@ public:
|
|||||||
const std::map<std::string, std::string>& get_all_namespaces(){
|
const std::map<std::string, std::string>& get_all_namespaces(){
|
||||||
return namespaces_;
|
return namespaces_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_namespace_annotations(std::string language, std::map<std::string, std::string> annotations) {
|
||||||
|
namespace_annotations_[language] = annotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::map<std::string, std::string>& get_namespace_annotations(std::string language) {
|
||||||
|
return namespace_annotations_[language];
|
||||||
|
}
|
||||||
|
|
||||||
// Language specific namespace / packaging
|
// Language specific namespace / packaging
|
||||||
|
|
||||||
void add_cpp_include(std::string path) { cpp_includes_.push_back(path); }
|
void add_cpp_include(std::string path) { cpp_includes_.push_back(path); }
|
||||||
@ -371,6 +380,9 @@ private:
|
|||||||
// Dynamic namespaces
|
// Dynamic namespaces
|
||||||
std::map<std::string, std::string> namespaces_;
|
std::map<std::string, std::string> namespaces_;
|
||||||
|
|
||||||
|
// Annotations for dynamic namespaces
|
||||||
|
std::map<std::string, std::map<std::string, std::string>> namespace_annotations_;
|
||||||
|
|
||||||
// C++ extra includes
|
// C++ extra includes
|
||||||
std::vector<std::string> cpp_includes_;
|
std::vector<std::string> cpp_includes_;
|
||||||
|
|
||||||
|
@ -297,13 +297,17 @@ Header:
|
|||||||
{
|
{
|
||||||
pdebug("Header -> Include");
|
pdebug("Header -> Include");
|
||||||
}
|
}
|
||||||
| tok_namespace tok_identifier tok_identifier
|
| tok_namespace tok_identifier tok_identifier TypeAnnotations
|
||||||
{
|
{
|
||||||
pdebug("Header -> tok_namespace tok_identifier tok_identifier");
|
pdebug("Header -> tok_namespace tok_identifier tok_identifier");
|
||||||
declare_valid_program_doctext();
|
declare_valid_program_doctext();
|
||||||
if (g_parse_mode == PROGRAM) {
|
if (g_parse_mode == PROGRAM) {
|
||||||
g_program->set_namespace($2, $3);
|
g_program->set_namespace($2, $3);
|
||||||
}
|
}
|
||||||
|
if ($4 != NULL) {
|
||||||
|
g_program->set_namespace_annotations($2, $4->annotations_);
|
||||||
|
delete $4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| tok_namespace '*' tok_identifier
|
| tok_namespace '*' tok_identifier
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,7 @@ namespace php ThriftTest
|
|||||||
namespace delphi Thrift.Test
|
namespace delphi Thrift.Test
|
||||||
namespace cocoa ThriftTest
|
namespace cocoa ThriftTest
|
||||||
namespace lua ThriftTest
|
namespace lua ThriftTest
|
||||||
|
namespace xsd test (uri = 'http://thrift.apache.org/ns/ThriftTest')
|
||||||
|
|
||||||
// Presence of namespaces and sub-namespaces for which there is
|
// Presence of namespaces and sub-namespaces for which there is
|
||||||
// no generator should compile with warnings only
|
// no generator should compile with warnings only
|
||||||
|
Loading…
Reference in New Issue
Block a user