diff options
| author | Alan Conway <aconway@apache.org> | 2008-02-28 14:47:59 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-02-28 14:47:59 +0000 |
| commit | 8bda6f7e14245e568d5bc99c4354c3551f522bff (patch) | |
| tree | 2f3da362ddf48b946d5ac0e21a8f174a23f2717e /cpp/rubygen | |
| parent | 564f7fec042784a3dc94d77aabbaeddeab845c7d (diff) | |
| download | qpid-python-8bda6f7e14245e568d5bc99c4354c3551f522bff.tar.gz | |
Fixed merging of multiple XML files for the same version.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@631987 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/rubygen')
| -rwxr-xr-x | cpp/rubygen/0-10/specification.rb | 2 | ||||
| -rwxr-xr-x | cpp/rubygen/amqpgen.rb | 12 | ||||
| -rwxr-xr-x | cpp/rubygen/generate | 19 |
3 files changed, 17 insertions, 16 deletions
diff --git a/cpp/rubygen/0-10/specification.rb b/cpp/rubygen/0-10/specification.rb index 026b49e1a9..d88b03c3c6 100755 --- a/cpp/rubygen/0-10/specification.rb +++ b/cpp/rubygen/0-10/specification.rb @@ -112,8 +112,6 @@ class Specification < CppGen # segment-type and track are are built in domain_h d unless ["track","segment-type"].include?(d.name) } - puts @amqp.used_by.inspect - # Domains and structs that must be generated early because # they are used by other definitions: each_class_ns { |c| diff --git a/cpp/rubygen/amqpgen.rb b/cpp/rubygen/amqpgen.rb index b1e635a27b..b95a507b5e 100755 --- a/cpp/rubygen/amqpgen.rb +++ b/cpp/rubygen/amqpgen.rb @@ -356,13 +356,19 @@ class AmqpRoot < AmqpElement amqp_attr_reader :major, :minor, :port, :comment amqp_child_reader :doc, :type, :struct, :domain, :constant, :class - def parse(filename) Document.new(File.new(filename)).root; end + def get_root(x) + case x + when Element then x + when Document then x.root + else Document.new(x).root + end + end # Initialize with output directory and spec files from ARGV. def initialize(*specs) raise "No XML spec files." if specs.empty? - xml=parse(specs.shift) - specs.each { |s| xml_merge(xml, parse(s)) } + xml=get_root(specs.shift) + specs.each { |s| xml_merge(xml, get_root(s)) } @used_by=Hash.new{ |h,k| h[k]=[] } super(xml, nil) end diff --git a/cpp/rubygen/generate b/cpp/rubygen/generate index d094be4f41..c370d92897 100755 --- a/cpp/rubygen/generate +++ b/cpp/rubygen/generate @@ -20,18 +20,15 @@ EOS end # Create array of specs by version -def parse_specs(specs) - roots={ } - specs.each { |spec| - root=AmqpRoot.new(spec) - ver=root.version - if (roots[ver]) - roots[ver].merge(root) - else - roots[ver]=root - end +def parse_specs(files) + specs=Hash.new { |h,k| h[k]=[] } + files.each { |f| + spec=AmqpRoot.new(File.new(f)) + specs[spec.version] << spec + } + specs.each_pair { |k,v| + specs[k] = v.size==1 ? v.first : AmqpRoot.new(*v.map { |s| s.xml}) } - roots end # Run selected templates |
