summaryrefslogtreecommitdiff
path: root/cpp/rubygen
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/rubygen')
-rwxr-xr-xcpp/rubygen/99-0/Proxy.rb1
-rw-r--r--cpp/rubygen/99-0/Session.rb2
-rw-r--r--cpp/rubygen/99-0/structs.rb56
-rwxr-xr-xcpp/rubygen/amqpgen.rb4
-rwxr-xr-xcpp/rubygen/cppgen.rb9
5 files changed, 68 insertions, 4 deletions
diff --git a/cpp/rubygen/99-0/Proxy.rb b/cpp/rubygen/99-0/Proxy.rb
index 2829884673..85db52da5b 100755
--- a/cpp/rubygen/99-0/Proxy.rb
+++ b/cpp/rubygen/99-0/Proxy.rb
@@ -41,6 +41,7 @@ EOS
# .h file
h_file(@filename) {
include "qpid/framing/Proxy.h"
+ include "qpid/framing/Array.h"
include "qpid/framing/amqp_types.h"
namespace("qpid::framing") {
cpp_class(@classname, "public Proxy") {
diff --git a/cpp/rubygen/99-0/Session.rb b/cpp/rubygen/99-0/Session.rb
index e01a28a62d..5a6f061937 100644
--- a/cpp/rubygen/99-0/Session.rb
+++ b/cpp/rubygen/99-0/Session.rb
@@ -6,7 +6,7 @@ require 'cppgen'
class CppGen
def session_methods
- excludes = ["channel", "connection", "session", "execution"]
+ excludes = ["channel", "connection", "session", "execution", "connection010", "session010"]
gen_methods=@amqp.methods_on(@chassis).reject { |m|
excludes.include? m.parent.name
}
diff --git a/cpp/rubygen/99-0/structs.rb b/cpp/rubygen/99-0/structs.rb
index 336591be00..4052befa2b 100644
--- a/cpp/rubygen/99-0/structs.rb
+++ b/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 <<EOS
typedef #{s.result ? s.result.struct.cpptype.name : 'void'} ResultType;
template <class T> 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*/"
diff --git a/cpp/rubygen/amqpgen.rb b/cpp/rubygen/amqpgen.rb
index 67b4b1c73c..9e4bb7c22c 100755
--- a/cpp/rubygen/amqpgen.rb
+++ b/cpp/rubygen/amqpgen.rb
@@ -343,6 +343,10 @@ class AmqpClass < AmqpElement
!["connection", "session", "execution"].include?(name)
end
+ def control?()
+ ["connection010", "session010"].include?(name)
+ end
+
def actions() controls+commands; end
end
diff --git a/cpp/rubygen/cppgen.rb b/cpp/rubygen/cppgen.rb
index df4ba49ca8..8e64b06208 100755
--- a/cpp/rubygen/cppgen.rb
+++ b/cpp/rubygen/cppgen.rb
@@ -142,6 +142,13 @@ class AmqpMethod
def param_names() fields.map { |f| f.cppname }; end
def signature() fields.map { |f| f.signature }; end
def body_name() parent.name.caps+name.caps+"Body"; end
+
+ def cpp_pack_type() # preview
+ CppType.new("uint16_t").code("Short").defval("0");
+ end
+ def pack() # preview
+ "short"
+ end
end
module AmqpHasFields
@@ -182,10 +189,12 @@ class AmqpDomain
"timestamp"=>CppType.new("uint64_t").code("LongLong").defval("0"),
"longstr"=>CppType.new("string").passcref.retcref.code("LongString"),
"shortstr"=>CppType.new("string").passcref.retcref.code("ShortString"),
+ "mediumstr"=>CppType.new("string").passcref.retcref.code("MediumString"),
"table"=>CppType.new("FieldTable").passcref.retcref,
"array"=>CppType.new("Array").passcref.retcref,
"content"=>CppType.new("Content").passcref.retcref,
"rfc1982-long-set"=>CppType.new("SequenceNumberSet").passcref.retcref,
+ "sequence-set"=>CppType.new("SequenceSet").passcref.retcref,
"long-struct"=>CppType.new("string").passcref.retcref.code("LongString"),
"uuid"=>CppType.new("Uuid").passcref.retcref
}