From e0ba5becd0052cabe0cfa997dd35d7362bf2c472 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Sun, 14 Oct 2007 02:21:59 +0000 Subject: Enabled packed struct encoding in python, cpp, and java. Also fixed computation of required byte credit in Message.cpp. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@584474 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/rubygen/amqpgen.rb | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'qpid/cpp/rubygen/amqpgen.rb') diff --git a/qpid/cpp/rubygen/amqpgen.rb b/qpid/cpp/rubygen/amqpgen.rb index 21bc05c651..5952b494df 100755 --- a/qpid/cpp/rubygen/amqpgen.rb +++ b/qpid/cpp/rubygen/amqpgen.rb @@ -41,10 +41,25 @@ class Module # Add attribute reader for XML attribute. def amqp_attr_reader(*attrs) attrs.each { |a| - define_method(mangle(a)) { - @amqp_attr_reader||={ } - @amqp_attr_reader[a] ||= xml.attributes[a.to_s] - } + case a + when Symbol + define_method(mangle(a)) { + @amqp_attr_reader||={ } + @amqp_attr_reader[a] ||= xml.attributes[a.to_s] + } + when Hash + a.each { |attr, default| + define_method(mangle(attr)) { + @amqp_attr_reader||={ } + value = xml.attributes[attr.to_s] + if value + @amqp_attr_reader[attr] ||= value + else + @amqp_attr_reader[attr] ||= default + end + } + } + end } end @@ -151,7 +166,7 @@ end class AmqpStruct < AmqpElement def initialize(xml, parent) super; end - amqp_attr_reader :size, :type, :pack + amqp_attr_reader :size, :type, :pack => "short" amqp_child_reader :field def result?() parent.xml.name == "result"; end -- cgit v1.2.1