From 0fb2f5356f1ea96ea0f3ccbc3de54cbd556fc57e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 3 Mar 2008 14:49:06 +0000 Subject: A further step to final 0-10 spec. The extra.xml fragment adds class defs for connection in session that are in line with latest spec but use old schema. The preview codepath (99-0) remains unaltered. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@633108 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/rubygen/99-0/structs.rb | 56 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/rubygen/99-0/structs.rb') diff --git a/qpid/cpp/rubygen/99-0/structs.rb b/qpid/cpp/rubygen/99-0/structs.rb index 336591be00..4052befa2b 100644 --- a/qpid/cpp/rubygen/99-0/structs.rb +++ b/qpid/cpp/rubygen/99-0/structs.rb @@ -17,6 +17,7 @@ class StructGen < CppGen "longlong"=>"LongLong", "longstr"=>"LongString", "shortstr"=>"ShortString", + "mediumstr"=>"MediumString", "timestamp"=>"LongLong", "table"=>"FieldTable", "content"=>"Content", @@ -33,7 +34,8 @@ class StructGen < CppGen ValueTypes=["octet", "short", "long", "longlong", "timestamp"] def is_packed(s) - s.kind_of? AmqpStruct + #return true + s.kind_of?(AmqpStruct) or s.body_name.include?("010") end def execution_header?(s) @@ -182,12 +184,21 @@ class StructGen < CppGen end end + def all_fields_via_accessors(s) + s.fields.collect { |f| "get#{f.name.caps}()" }.join(", ") + end + def methodbody_extra_defs(s) + if (s.parent.control?) + genl "virtual uint8_t type() const { return 0;/*control segment*/ }" + end + + gen < ResultType invoke(T& invocable) const { - return invocable.#{s.cppname}(#{s.param_names.join ", "}); + return invocable.#{s.cppname}(#{all_fields_via_accessors(s)}); } using AMQMethodBody::accept; @@ -235,6 +246,14 @@ EOS end def define_packed_field_accessors(s, f, i) + if (s.kind_of? AmqpMethod) + define_packed_field_accessors_for_method(s, f, i) + else + define_packed_field_accessors_for_struct(s, f, i) + end + end + + def define_packed_field_accessors_for_struct(s, f, i) if (f.domain.type_ == "bit") genl "void #{s.cppname}::set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {" indent { @@ -265,6 +284,37 @@ EOS genl "" end + def define_packed_field_accessors_for_method(s, f, i) + if (f.domain.type_ == "bit") + genl "void #{s.body_name}::set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {" + indent { + genl "if (_#{f.cppname}) flags |= #{flag_mask(s, i)};" + genl "else flags &= ~#{flag_mask(s, i)};" + } + genl "}" + genl "#{f.cpptype.ret} #{s.body_name}::get#{f.name.caps}() const { return flags & #{flag_mask(s, i)}; }" + else + genl "void #{s.body_name}::set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {" + indent { + genl "#{f.cppname} = _#{f.cppname};" + genl "flags |= #{flag_mask(s, i)};" + } + genl "}" + genl "#{f.cpptype.ret} #{s.body_name}::get#{f.name.caps}() const { return #{f.cppname}; }" + if (f.cpptype.name == "FieldTable") + genl "#{f.cpptype.name}& #{s.body_name}::get#{f.name.caps}() {" + indent { + genl "flags |= #{flag_mask(s, i)};"#treat the field table as having been 'set' + genl "return #{f.cppname};" + } + genl "}" + end + genl "bool #{s.body_name}::has#{f.name.caps}() const { return flags & #{flag_mask(s, i)}; }" + genl "void #{s.body_name}::clear#{f.name.caps}Flag() { flags &= ~#{flag_mask(s, i)}; }" + end + genl "" + end + def define_packed_accessors(s) process_packed_fields(s) { |f, i| define_packed_field_accessors(s, f, i) } end @@ -383,7 +433,7 @@ EOS EOS } cpp_file("qpid/framing/#{classname}.cpp") { - if (s.fields.size > 0 || execution_header?(s)) + if (is_packed(s) || s.fields.size > 0 || execution_header?(s)) buffer = "buffer" else buffer = "/*buffer*/" -- cgit v1.2.1