From: Mark Slee Date: Fri, 19 Jan 2007 00:17:02 +0000 (+0000) Subject: Add xsd_all keyword to Thrift X-Git-Tag: 0.2.0~1543 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=782abbb75692d4cc582e60e88da5e58c049e4bfd;p=common%2Fthrift.git Add xsd_all keyword to Thrift Summary: Makes a struct an xsd_all instead of a sequence Reviewed By: dave git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664929 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_xsd_generator.cc b/compiler/cpp/src/generate/t_xsd_generator.cc index cb184a3d..57c9656a 100644 --- a/compiler/cpp/src/generate/t_xsd_generator.cc +++ b/compiler/cpp/src/generate/t_xsd_generator.cc @@ -26,10 +26,15 @@ void t_xsd_generator::generate_typedef(t_typedef* ttypedef) { void t_xsd_generator::generate_struct(t_struct* tstruct) { vector::const_iterator m_iter; const vector& members = tstruct->get_members(); + bool xsd_all = tstruct->get_xsd_all(); indent(s_xsd_types_) << "get_name() << "\">" << endl; indent_up(); - indent(s_xsd_types_) << "" << endl; + if (xsd_all) { + indent(s_xsd_types_) << "" << endl; + } else { + indent(s_xsd_types_) << "" << endl; + } indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -37,7 +42,11 @@ void t_xsd_generator::generate_struct(t_struct* tstruct) { } indent_down(); - indent(s_xsd_types_) << "" << endl; + if (xsd_all) { + indent(s_xsd_types_) << "" << endl; + } else { + indent(s_xsd_types_) << "" << endl; + } indent_down(); indent(s_xsd_types_) << "" << endl << diff --git a/compiler/cpp/src/parse/t_struct.h b/compiler/cpp/src/parse/t_struct.h index ce5f7524..bebea2a5 100644 --- a/compiler/cpp/src/parse/t_struct.h +++ b/compiler/cpp/src/parse/t_struct.h @@ -20,11 +20,13 @@ class t_struct : public t_type { public: t_struct(t_program* program) : t_type(program), - is_xception_(false) {} + is_xception_(false), + xsd_all_(false) {} t_struct(t_program* program, const std::string& name) : t_type(program, name), - is_xception_(false) {} + is_xception_(false), + xsd_all_(false) {} void set_name(const std::string& name) { name_ = name; @@ -34,6 +36,14 @@ class t_struct : public t_type { is_xception_ = is_xception; } + void set_xsd_all(bool xsd_all) { + xsd_all_ = xsd_all; + } + + bool get_xsd_all() const { + return xsd_all_; + } + void append(t_field* elem) { members_.push_back(elem); } @@ -53,6 +63,9 @@ class t_struct : public t_type { private: std::vector members_; bool is_xception_; + + bool xsd_all_; + }; #endif diff --git a/compiler/cpp/src/thrift.l b/compiler/cpp/src/thrift.l index 324c5ea1..4f2d542a 100644 --- a/compiler/cpp/src/thrift.l +++ b/compiler/cpp/src/thrift.l @@ -59,6 +59,7 @@ sliteral ("'"[^']*"'") "cpp_type" { return tok_cpp_type; } "java_package" { return tok_java_package; } "php_namespace" { return tok_php_namespace; } +"xsd_all" { return tok_xsd_all; } "include" { return tok_include; } "void" { return tok_void; } diff --git a/compiler/cpp/src/thrift.y b/compiler/cpp/src/thrift.y index 8dbe6214..cfb3e44f 100644 --- a/compiler/cpp/src/thrift.y +++ b/compiler/cpp/src/thrift.y @@ -66,6 +66,7 @@ int y_field_val = -1; %token tok_cpp_type %token tok_php_namespace %token tok_java_package +%token tok_xsd_all /** * Base datatype keywords @@ -144,6 +145,7 @@ int y_field_val = -1; %type ThrowsOptional %type ExtendsOptional %type AsyncOptional +%type XsdAllOptional %type CppTypeOptional %% @@ -440,14 +442,25 @@ ConstMapContents: } Struct: - tok_struct tok_identifier '{' FieldList '}' + tok_struct tok_identifier XsdAllOptional '{' FieldList '}' { pdebug("Struct -> tok_struct tok_identifier { FieldList }"); - $4->set_name($2); - $$ = $4; + $5->set_name($2); + $5->set_xsd_all($3); + $$ = $5; y_field_val = -1; } +XsdAllOptional: + tok_xsd_all + { + $$ = true; + } +| + { + $$ = false; + } + Xception: tok_xception tok_identifier '{' FieldList '}' {