diff options
author | Gordon Sim <gsim@apache.org> | 2007-08-21 15:51:41 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2007-08-21 15:51:41 +0000 |
commit | bb2883b9f5cfad0e028a9849ed91e36418a2d0ff (patch) | |
tree | 555686e2e819a875048610d88c2cee8e336b3687 /cpp/rubygen/amqpgen.rb | |
parent | 955d5ccb544ff4f56d35c40aa8934cbf4dfff14e (diff) | |
download | qpid-python-bb2883b9f5cfad0e028a9849ed91e36418a2d0ff.tar.gz |
Refresh of transitional xml to more closely reflect latest specification
Initial execution-result support (not yet handled on c++ client)
Generation is now all done through the ruby code (it is a little slower at present I'm afraid, will try to speed it up over the next weeks)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@568174 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/rubygen/amqpgen.rb')
-rwxr-xr-x | cpp/rubygen/amqpgen.rb | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/cpp/rubygen/amqpgen.rb b/cpp/rubygen/amqpgen.rb index 7d635c99c2..044a2497e0 100755 --- a/cpp/rubygen/amqpgen.rb +++ b/cpp/rubygen/amqpgen.rb @@ -60,8 +60,7 @@ class AmqpField < AmqpElement # Get AMQP type for a domain name. def domain_type(name) - domain=elements["/amqp/domain[@name='#{name}']"] - (domain and domain.attributes["type"] or name) + @cache_domain_type ||= domain_type_impl(name) end # Get the AMQP type of this field. @@ -70,6 +69,22 @@ class AmqpField < AmqpElement dt=domain_type d if d (dt or attributes["type"]) end + + # determine whether this type is defined as a struct in the spec + def defined_as_struct() + @cache_defined_as_struct ||= defined_as_struct_impl() + end + +private + def domain_type_impl(name) + domain=elements["/amqp/domain[@name='#{name}']"] + (domain and domain.attributes["type"] or name) + end + + def defined_as_struct_impl() + domain_name = attributes["domain"] + elements["/amqp/domain[@name='#{domain_name}']/struct"] + end end # AMQP method element @@ -98,6 +113,18 @@ class AmqpMethod < AmqpElement } end + def has_result?() + @cache_has_result ||= elements["result/struct"] + end + + def result_struct() + @cache_result_struct ||= has_result? ? AmqpStruct.new(elements["result/struct"], self) : nil + end + + def is_server_method?() + @cache_is_server_method ||= elements["chassis[@name='server']"] + end + def request?() responds_to().empty?; end def response?() not request?; end end @@ -116,7 +143,25 @@ class AmqpClass < AmqpElement def amqp_methods_on(chassis) @cache_amqp_methods_on ||= { } @cache_amqp_methods_on[chassis] ||= elements.collect("method/chassis[@name='#{chassis}']/..") { |m| AmqpMethod.new(m,self) }.sort_by_name + end end + + +# AMQP struct element. +class AmqpStruct < AmqpElement + def initialize(xml,amqp) super; end + + def type() attributes["type"]; end + + def size() attributes["size"]; end + + def result?() parent.name == "result"; end + + def domain?() parent.name == "domain"; end + + def fields() + @cache_fields ||= elements.collect("field") { |f| AmqpField.new(f,self); } + end end # AMQP root element. @@ -152,9 +197,23 @@ class AmqpRoot < AmqpElement @cache_amqp_classes ||= elements.collect("class") { |c| AmqpClass.new(c,self) }.sort_by_name end + + def amqp_structs() + @cache_amqp_structs ||= amqp_result_structs + amqp_domain_structs + end + + def amqp_domain_structs() + @cache_amqp_domain_structs ||= elements.collect("domain/struct") { |s| AmqpStruct.new(s, self) } + end + + def amqp_result_structs() + @cache_amqp_result_structs ||= amqp_methods.collect { |m| m.result_struct }.compact + end # Return all methods on all classes. - def amqp_methods() amqp_classes.collect { |c| c.amqp_methods }.flatten; end + def amqp_methods() + @cache_amqp_methods ||= amqp_classes.collect { |c| c.amqp_methods }.flatten; + end # Return all methods on chassis for all classes. def amqp_methods_on(chassis) |