From f160cb6566c17945f7ebc4f3a752b2cc6a051685 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Tue, 5 Jul 2016 21:55:35 +0000 Subject: QPID-7207: remove cpp and python subdirs from svn trunk, they have migrated to their own git repositories git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1751566 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb | 53 -- qpid/cpp/rubygen/README.txt | 17 - qpid/cpp/rubygen/amqpgen.rb | 557 ------------------ qpid/cpp/rubygen/cppgen.rb | 452 --------------- .../rubygen/framing.0-10/MethodBodyConstVisitor.rb | 45 -- .../framing.0-10/MethodBodyDefaultVisitor.rb | 54 -- qpid/cpp/rubygen/framing.0-10/MethodBodyFactory.rb | 59 -- qpid/cpp/rubygen/framing.0-10/Operations.rb | 121 ---- qpid/cpp/rubygen/framing.0-10/OperationsInvoker.rb | 117 ---- qpid/cpp/rubygen/framing.0-10/Proxy.rb | 109 ---- qpid/cpp/rubygen/framing.0-10/Session.rb | 419 -------------- qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb | 39 -- qpid/cpp/rubygen/framing.0-10/constants.rb | 208 ------- qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb | 49 -- qpid/cpp/rubygen/framing.0-10/structs.rb | 635 --------------------- qpid/cpp/rubygen/generate | 145 ----- 16 files changed, 3079 deletions(-) delete mode 100755 qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb delete mode 100644 qpid/cpp/rubygen/README.txt delete mode 100755 qpid/cpp/rubygen/amqpgen.rb delete mode 100755 qpid/cpp/rubygen/cppgen.rb delete mode 100755 qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb delete mode 100755 qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb delete mode 100644 qpid/cpp/rubygen/framing.0-10/MethodBodyFactory.rb delete mode 100755 qpid/cpp/rubygen/framing.0-10/Operations.rb delete mode 100755 qpid/cpp/rubygen/framing.0-10/OperationsInvoker.rb delete mode 100755 qpid/cpp/rubygen/framing.0-10/Proxy.rb delete mode 100755 qpid/cpp/rubygen/framing.0-10/Session.rb delete mode 100755 qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb delete mode 100755 qpid/cpp/rubygen/framing.0-10/constants.rb delete mode 100644 qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb delete mode 100755 qpid/cpp/rubygen/framing.0-10/structs.rb delete mode 100755 qpid/cpp/rubygen/generate (limited to 'qpid/cpp/rubygen') diff --git a/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb b/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb deleted file mode 100755 index 11dbcb8f83..0000000000 --- a/qpid/cpp/rubygen/MethodBodyDefaultVisitor.rb +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env ruby -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -$: << ".." # Include .. in load path -require 'cppgen' - -class MethodBodyDefaultVisitorGen < CppGen - - def initialize(outdir, amqp) - super(outdir, amqp) - set_classname("qpid::framing::MethodBodyDefaultVisitor") - end - - def generate() - h_file(@filename) { - include "qpid/framing/MethodBodyConstVisitor" - namespace(@namespace) { - genl - cpp_extern_class("QPID_COMMON_CLASS_EXTERN", @classname, "public MethodBodyConstVisitor") { - genl "public:" - genl "virtual void defaultVisit() = 0;" - @amqp.methods_.each { |m| - genl "virtual void visit(const #{m.body_name}&);" } - }}} - - cpp_file(@filename) { - include(@filename) - namespace(@namespace) { - @amqp.methods_.each { |m| - genl "void #{@classname}::visit(const #{m.body_name}&) { defaultVisit(); }" - }}} - end -end - -MethodBodyDefaultVisitorGen.new($outdir, $amqp).generate(); - diff --git a/qpid/cpp/rubygen/README.txt b/qpid/cpp/rubygen/README.txt deleted file mode 100644 index a1fd6cfec8..0000000000 --- a/qpid/cpp/rubygen/README.txt +++ /dev/null @@ -1,17 +0,0 @@ -RUBY CODE GENERATOR - -Run ./generate for usage. -Examples in samples/ - -For example: - ./generate . ../../specs/amqp.0-9.xml samples/Proxy.rb -will generate - - - - - - - - - diff --git a/qpid/cpp/rubygen/amqpgen.rb b/qpid/cpp/rubygen/amqpgen.rb deleted file mode 100755 index 7eee953c04..0000000000 --- a/qpid/cpp/rubygen/amqpgen.rb +++ /dev/null @@ -1,557 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Generic AMQP code generation library. -# -# TODO aconway 2008-02-21: -# -# The amqp_attr_reader and amqp_child_reader for each Amqp* class -# should correspond exactly to ampq.dtd. Currently they are more -# permissive so we can parse 0-10 preview and 0-10 final XML. -# -# Code marked with "# preview" should be removed/modified when final 0-10 -# is complete and we are ready to remove preview-related code. -# - -require 'delegate' -require 'rexml/document' -require 'pathname' -require 'set' -include REXML - -# Handy String functions for converting names. -class String - # Convert to CapitalizedForm. - def caps() gsub( /(^|\W)(\w)/ ) { |m| $2.upcase } end - - # Convert to underbar_separated_form. - def bars() tr('- .','_'); end - - # Convert to ALL_UPPERCASE_FORM - def shout() bars.upcase; end - - # Convert to lowerCaseCapitalizedForm - def lcaps() gsub( /\W(\w)/ ) { |m| $1.upcase } end - - def plural() self + (/[xs]$/ === self ? 'es' : 's'); end -end - -# Sort an array by name. -module Enumerable - def sort_by_name() sort { |a,b| a.name <=> b.name }; end -end - -# Add functions similar to attr_reader for AMQP attributes/children. -# Symbols that are ruby Object function names (e.g. class) get -# an "_" suffix. -class Module - # Add trailing _ to avoid conflict with Object methods. - def mangle(sym) - sym = (sym.to_s+"_").to_sym if (Object.method_defined?(sym) or sym == :type) - sym - end - - # Add attribute reader for XML attribute. - def amqp_attr_reader(*attrs) - attrs.each { |a| - 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 - - # Add 2 child readers: - # elname(name) == child('elname',name) - # elnames() == children('elname') - def amqp_child_reader(*element_names) - element_names.each { |e| - define_method(mangle(e)) { |name| child(e.to_s, name) } - define_method(mangle(e.to_s.plural)) { children(e.to_s) } } - end - - # When there can only be one child instance - def amqp_single_child_reader(*element_names) - element_names.each { |e| - define_method(mangle(e)) { children(e.to_s)[0] } } - end -end - -# An AmqpElement contains an XML element and provides a convenient -# API to access AMQP data. -# -# NB: AmqpElements cache values from XML, they assume that -# the XML model does not change after the AmqpElement has -# been created. -class AmqpElement - - def wrap(xml) - return nil if ["assert","rule"].include? xml.name - eval("Amqp"+xml.name.caps).new(xml, self) or raise "nil wrapper" - end - - public - - def initialize(xml, parent) - @xml, @parent=xml, parent - @children=xml.elements.map { |e| wrap e }.compact - @cache_child={} - @cache_child_named={} - @cache_children={} - @cache_children[nil]=@children - end - - attr_reader :parent, :xml, :children, :doc - amqp_attr_reader :name, :label - - # List of children of type elname, or all children if elname - # not specified. - def children(elname=nil) - if elname - @cache_children[elname] ||= @children.select { |c| elname==c.xml.name } - else - @children - end - end - - def each_descendant(&block) - yield self - @children.each { |c| c.each_descendant(&block) } - end - - def collect_all(amqp_type) - collect=[] - each_descendant { |d| collect << d if d.is_a? amqp_type } - collect - end - - # Look up child of type elname with attribute name. - def child(elname, name) - @cache_child[[elname,name]] ||= children(elname).find { |c| c.name==name } - end - - # Look up any child with name - def child_named(name) - @cache_child_named[name] ||= @children.find { |c| c.name==name } - end - - # The root element. - def root() @root ||=parent ? parent.root : self; end - - def to_s() "#<#{self.class}(#{fqname})>"; end - def inspect() to_s; end - - # Text of doc child if there is one. - def doc() d=xml.elements["doc"]; d and d.text; end - - def fqname() - throw "fqname: #{self} #{parent.fqname} has no name" unless name - p=parent && parent.fqname - p ? p+"."+name : name; - end - - def containing_class() - return self if is_a? AmqpClass - return parent && parent.containing_class - end - - # 0-10 array domains are missing element type information, add it here. - ArrayTypes={ - "str16-array" => "str-16", - "amqp-host-array" => "connection.amqp-host-url", - "command-fragments" => "session.command-fragment", - "in-doubt" => "dtx.xid", - "tx-publish" => "str-8", - "urls" => "str-16", - "queues" => "str-8", - "prepared" => "str-8" - } - - def array_type(name) - return ArrayTypes[name] if ArrayTypes[name] - raise "Missing ArrayType entry for " + name - end - -end - -class AmqpResponse < AmqpElement - def initialize(xml, parent) super; end - def fqname() (parent ? parent.dotted_name+"." : "") + "response"; end -end - -class AmqpDoc < AmqpElement - def initialize(xml,parent) super; end - def text() @xml.text end -end - -class AmqpChoice < AmqpElement - def initialize(xml,parent) super; end - amqp_attr_reader :name, :value -end - -class AmqpEnum < AmqpElement - def initialize(xml,parent) super; end - amqp_child_reader :choice -end - -class AmqpDomain < AmqpElement - def initialize(xml, parent) - super - root.used_by[uses].push(fqname) if uses and uses.index('.') - end - - amqp_attr_reader :type - amqp_single_child_reader :struct # preview - amqp_single_child_reader :enum - - def uses() type_=="array" ? ArrayTypes[name] : type_; end -end - -class AmqpException < AmqpElement - def initialize(xml, amqp) super; end; - amqp_attr_reader :error_code -end - -class AmqpField < AmqpElement - def initialize(xml, amqp) - super; - root.used_by[type_].push(parent.fqname) if type_ and type_.index('.') - end - amqp_single_child_reader :struct # preview - amqp_child_reader :exception - amqp_attr_reader :type, :default, :code, :required -end - -class AmqpChassis < AmqpElement # preview - def initialize(xml, parent) super; end - amqp_attr_reader :implement -end - -class AmqpConstant < AmqpElement - def initialize(xml, parent) super; end - amqp_attr_reader :value, :class -end - -class AmqpResult < AmqpElement - def initialize(xml, parent) super; end - amqp_single_child_reader :struct # preview - amqp_attr_reader :type - def name() "result"; end -end - -class AmqpEntry < AmqpElement - def initialize(xml,parent) super; end - amqp_attr_reader :type -end - -class AmqpHeader < AmqpElement - def initialize(xml,parent) super; end - amqp_child_reader :entry - amqp_attr_reader :required -end - -class AmqpBody < AmqpElement - def initialize(xml,parent) super; end - amqp_attr_reader :required -end - -class AmqpSegments < AmqpElement - def initialize(xml,parent) super; end - amqp_child_reader :header, :body -end - -class AmqpStruct < AmqpElement - def initialize(xml, parent) super; end - amqp_attr_reader :type # preview - amqp_attr_reader :size, :code, :pack - amqp_child_reader :field - - def result?() parent.xml.name == "result"; end - def domain?() parent.xml.name == "domain"; end -end - -class AmqpMethod < AmqpElement - def initialize(xml, parent) super; end - - amqp_attr_reader :content, :index, :synchronous - amqp_child_reader :field, :chassis,:response - amqp_single_child_reader :result - - def on_chassis?(chassis) child("chassis", chassis); end - def on_client?() on_chassis? "client"; end - def on_server?() on_chassis? "server"; end -end - -# preview: Map command/control to preview method. -class AmqpFakeMethod < AmqpMethod - def initialize(action) - super(action.xml, action.parent); - @action=action - end - - def content() return "1" if @action.is_a? AmqpCommand and @action.segments end - def index() @action.code end - def code() @action.code end - def synchronous() end - def on_chassis?(chassis) - @action.received_by?(chassis) - end - def pack() "2" end # Encode pack=2, size=4 struct - def size() "4" end -end - -class AmqpImplement < AmqpElement - def initialize(xml,amqp) super; end - amqp_attr_reader :handle, :send -end - -class AmqpRole < AmqpElement - def initialize(xml,amqp) super; end - amqp_attr_reader :implement -end - -# Base class for command and control. -class AmqpAction < AmqpElement - def initialize(xml,amqp) super; end - amqp_child_reader :implement, :field, :response - amqp_attr_reader :code - def implement?(role) - # we can't use xpath for this because it triggers a bug in some - # versions of ruby, including version 1.8.6.110 - xml.elements.each {|el| - return true if el.name == "implement" and el.attributes["role"] == role - } - return false - end - def received_by?(client_or_server) - return (implement?(client_or_server) or implement?("sender") or implement?("receiver")) - end - def pack() "2" end - def size() "4" end # Encoded as a size 4 Struct -end - -class AmqpControl < AmqpAction - def initialize(xml,amqp) super; end -end - -class AmqpCommand < AmqpAction - def initialize(xml,amqp) super; end - amqp_child_reader :exception - amqp_single_child_reader :result, :segments -end - -class AmqpClass < AmqpElement - def initialize(xml,amqp) super; end - - amqp_attr_reader :index # preview - - amqp_child_reader :struct, :domain, :control, :command, :role, :method - amqp_attr_reader :code - - def actions() controls+commands; end - - # preview - command/control as methods - def methods_() - return (controls + commands).map { |a| AmqpFakeMethod.new(a) } - end - - def method(name) - a = (command(name) or control(name)) - return AmqpFakeMethod.new(a) - end - - # chassis should be "client" or "server" - def methods_on(chassis) # preview - @methods_on ||= { } - @methods_on[chassis] ||= methods_.select { |m| m.on_chassis? chassis } - end - - # FIXME aconway 2008-04-11: - def l4?() # preview - !["connection", "session", "execution"].include?(name) && !control? - end - - # FIXME aconway 2008-04-11: - def control?() - ["connection", "session"].include?(name) - end -end - -class AmqpType < AmqpElement - def initialize(xml,amqp) super; end - amqp_attr_reader :code, :fixed_width, :variable_width -end - -class AmqpXref < AmqpElement - def initialize(xml,amqp) super; end -end - -# AMQP root element. -class AmqpRoot < AmqpElement - amqp_attr_reader :major, :minor, :port, :comment - amqp_child_reader :doc, :type, :struct, :domain, :constant, :class - - 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=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 - - attr_reader :used_by - - def merge(root) xml_merge(xml, root.xml); end - - def version() major + "-" + minor; end - - def methods_() classes.map { |c| c.methods_ }.flatten; end - - #preview - # Return all methods on chassis for all classes. - def methods_on(chassis) - @methods_on ||= { } - @methods_on[chassis] ||= classes.map { |c| c.methods_on(chassis) }.flatten - end - - def fqname() nil; end - - private - - # Merge contents of elements. - def xml_merge(to,from) - from.elements.each { |from_child| - tag,name = from_child.name, from_child.attributes["name"] - to_child=to.elements["./#{tag}[@name='#{name}']"] - to_child ? xml_merge(to_child, from_child) : to.add(from_child.deep_clone) } - end -end - -# Collect information about generated files. -class GenFiles - @@files = Set.new - @@public_api = [] - def GenFiles.add(f) @@files.add(f); end - def GenFiles.get() @@files; end - def GenFiles.public_api(file) @@public_api << file; end - def GenFiles.public_api?(file) @@public_api.find { |f| f == file }; end -end - -# Base class for code generators. -# Supports setting a per-line prefix, useful for e.g. indenting code. -# -class Generator - # Takes directory for output or "-", meaning print file names that - # would be generated. - def initialize (outdir, amqp) - @outdir=outdir[0] - @apidir=outdir[1] - @amqp=amqp - raise "outdir is not an array" unless outdir.class == Array - @prefix=[''] # For indentation or comments. - @indentstr=' ' # One indent level. - @outdent=2 - @verbose=false - end - - # Declare next file to be public API - def public_api(file) GenFiles.public_api(file); end - - # Create a new file, set @out. - def file(file, &block) - GenFiles.add(file) - dir = GenFiles.public_api?(file) ? @apidir : @outdir - if (dir != "-") - @path=Pathname.new "#{dir}/#{file}" - @path.parent.mkpath - @out=String.new # Generate in memory first - yield if block - if @path.exist? and @path.read == @out - if @verbose - puts "Skipped #{@path} - unchanged" # Dont generate if unchanged - end - else - @path.open('w') { |f| f << @out } - if @verbose - puts "Generated #{@path}" - end - end - end - end - - # Append multi-line string to generated code, prefixing each line. - def gen(str) - str.each_line { |line| - @out << @prefix.last unless @midline - @out << line - @midline = nil - } - # Note if we stopped mid-line - @midline = /[^\n]\z/ === str - end - - # Append str + '\n' to generated code. - def genl(str="") gen str+"\n"; end - - # Generate code with added prefix. - def prefix(add, &block) - @prefix.push @prefix.last+add - if block then yield; endprefix; end - end - - def endprefix() - @prefix.pop - end - - # Generate indented code - def indent(n=1,&block) prefix(@indentstr * n,&block); end - alias :endindent :endprefix - - # Generate outdented code - def outdent(&block) - @prefix.push @prefix.last[0...-2] - if block then yield; endprefix; end - end - alias :endoutdent :endprefix - - attr_accessor :out -end - diff --git a/qpid/cpp/rubygen/cppgen.rb b/qpid/cpp/rubygen/cppgen.rb deleted file mode 100755 index 3d21e7d4fa..0000000000 --- a/qpid/cpp/rubygen/cppgen.rb +++ /dev/null @@ -1,452 +0,0 @@ -#!/usr/bin/env ruby -# -# General purpose C++ code generation. -# -require 'amqpgen' -require 'set' - -Copyright=< CppType.new("bool").code("Octet").defval("false"), - "boolean"=> CppType.new("bool").code("Octet").defval("false"), - "uint8"=>CppType.new("uint8_t").code("Octet").defval("0"), - "uint16"=>CppType.new("uint16_t").code("Short").defval("0"), - "uint32"=>CppType.new("uint32_t").code("Long").defval("0"), - "uint64"=>CppType.new("uint64_t").code("LongLong").defval("0"), - "datetime"=>CppType.new("uint64_t").code("LongLong").defval("0"), - "str8"=>CppType.new("std::string").passcref.retcref.code("ShortString"), - "str16"=>CppType.new("std::string").passcref.retcref.code("MediumString"), - "str32"=>CppType.new("std::string").passcref.retcref.code("LongString"), - "vbin8"=>CppType.new("std::string").passcref.retcref.code("ShortString"), - "vbin16"=>CppType.new("std::string").passcref.retcref.code("MediumString"), - "vbin32"=>CppType.new("std::string").passcref.retcref.code("LongString"), - "map"=>CppType.new("FieldTable").passcref.retcref, - "array"=>CppType.new("Array").passcref.retcref, - "sequence-no"=>CppType.new("SequenceNumber").passcref, - "sequence-set"=>CppType.new("SequenceSet").passcref.retcref, - "struct32"=>CppType.new("std::string").passcref.retcref.code("LongString"), - "uuid"=>CppType.new("Uuid").passcref.retcref, - "byte-ranges"=>CppType.new("ByteRanges").passcref.retcref - } - - # preview: map amqp types to preview cpp types. - def lookup_cpptype(t) t = @@typemap[t] and return t end -end - - -class AmqpElement - # convert my amqp type_ attribute to a C++ type. - def amqp2cpp() - return "ArrayDomain<#{array_type(name).amqp2cpp}> " if type_=="array" - return type_.amqp2cpp - end - - # Does this object have a type-like child named name? - def typechild(name) - child = domain(name) if respond_to? :domain - child = struct(name) if not child and respond_to? :struct - child = type_(name) if not child and respond_to? :type_ - child - end - - # dotted name to a type object - def dotted_typechild(name) - names=name.split('.') - context = self - while context and names.size > 1 - context = context.child_named(names.shift) - end - return context.typechild(names[0]) if context - end - - # preview mapping - type_ attribute to C++ type - def lookup_cpptype(name) - if t = root.lookup_cpptype(name) then return t - elsif c = containing_class.typechild(name) then return c.cpptype - elsif c= root.dotted_typechild(name) then return c.cpptype - else raise "Cannot resolve type-name #{name} from #{self}" - end - end - - def containing_class() - return self if is_a? AmqpClass - return parent && parent.containing_class - end -end - - -class AmqpField - def struct?() - c=containing_class - c.struct(type_) - end - def cpptype() lookup_cpptype(type_) or raise "no cpptype #{type_} for field #{self}" end - def cppname() name.lcaps.cppsafe; end - def bit?() type_ == "bit"; end - def signature() cpptype.param+" "+cppname; end - - def fqtypename() - unless type_.index(".") - c=containing_class - return c.domain(type_).fqtypename if c.domain(type_) - return c.struct(type_).fqclassname if c.struct(type_) - end - return amqp2cpp - end - def paramtype() - /^(int|uint|char|boolean|bit)/ === type_ ? fqtypename : "const #{fqtypename}&" - end - def param_default() "=#{fqtypename}()" end - - # Default value is normally the C++ default but over-ridden in specific cases - def default_value() - defval = cpptype.default_value; - if name == "accept-mode" and parent.name == "transfer" then defval = "1"; end - return defval - end -end - -class AmqpMethod - def cppname() name.lcaps.cppsafe; end - def param_names() fields.map { |f| f.cppname }; end - def signature() fields.map { |f| f.signature }; end - def classname() parent.name; end - def body_name() - classname().caps+name.caps+"Body" - end - def cpp_pack_type() root.lookup_cpptype("uint16") end -end - -module AmqpHasFields - def parameters(with_default=nil) - fields.map { |f| - "#{f.paramtype} #{f.cppname}_#{f.param_default if with_default}" - } - end - def unused_parameters() fields.map { |f| "#{f.paramtype} /*#{f.cppname}_*/"} end - def arguments() fields.map { |f| "#{f.cppname}_"} end - def values() fields.map { |f| "#{f.cppname}"} end - def initializers() fields.map { |f| "#{f.cppname}(#{f.cppname}_)"} end -end - -class AmqpAction - def classname() name.typename; end - def funcname() parent.name.funcname + name.caps; end - def fqclassname() parent.name+"::"+classname; end - def full_code() (containing_class.code.hex << 8)+code.hex; end - include AmqpHasFields -end - -class AmqpType - def cpptype() root.lookup_cpptype(name) end # preview - def typename() name.typename; end # new mapping - def fixed?() fixed_width; end -end - -class AmqpCommand < AmqpAction - def base() "Command"; end -end - -class AmqpControl < AmqpAction - def base() "Control"; end -end - -class AmqpClass - def cppname() name.caps; end # preview - def nsname() name.nsname; end -end - -class AmqpDomain - # preview - def cpptype() lookup_cpptype(type_) end - def cppname() name.caps; end - - # new mapping - def fqtypename() - return containing_class.nsname+"::"+name.typename if containing_class - name.typename - end -end - -class AmqpResult - # preview - def cpptype() - if type_ then lookup_cpptype(type_) - else CppType.new(parent.parent.name.caps+parent.name.caps+"Result").passcref - end - end -end - -class AmqpStruct - include AmqpHasFields - - @@pack_types={ "1"=>"uint8", "2"=>"uint16", "4"=>"uint32"} - def cpp_pack_type() # preview - root.lookup_cpptype(@@pack_types[pack]) - end - def cpptype() CppType.new(cppname).passcref.retcref end - #def cppname() containing_class.cppname+name.caps; end - def cppname() - if parent.kind_of? AmqpResult - parent.parent.parent.name.caps+parent.parent.name.caps+"Result" - else - name.caps - end - end - def fqclassname() containing_class.nsname+"::"+name.typename; end - def classname() name.typename; end - def full_code() (containing_class.code.hex << 8)+code.hex; end -end - -class CppGen < Generator - def initialize(outdir, *specs) - super(outdir,*specs) - # need to sort classes for dependencies - @actions=[] # Stack of end-scope actions - end - - # Write a header file. - def h_file(path, &block) - path = (/\.h$/ === path ? path : path+".h") - guard=path.upcase.tr('./-','_') - file(path) { - gen "#ifndef #{guard}\n" - gen "#define #{guard}\n" - gen Copyright - yield - gen "#endif /*!#{guard}*/\n" - } - end - - # Write a .cpp file. - def cpp_file(path, &block) - path = (/\.cpp$/ === path ? path : path+".cpp") - file(path) do - gen Copyright - yield - end - end - - def include(header) - header+=".h" unless /(\.h|[">])$/===header - header="\"#{header}\"" unless /(^<.*>$)|(^".*"$)/===header - genl "#include #{header}" - end - - def scope(open="{",close="}", &block) - genl open - indent &block - genl close - end - - def namespace(name, &block) - genl - names = name.split("::") - names.each { |n| genl "namespace #{n} {" } - genl "namespace {" if (names.empty?) - genl - yield - genl - genl('}'*([names.size, 1].max)+" // namespace "+name) - genl - end - - def struct_class(type, name, bases, &block) - gen "#{type} #{name}" - if (!bases.empty?) - genl ":" - indent { gen "#{bases.join(",\n")}" } - end - genl - scope("{","};", &block) - end - - def struct(name, *bases, &block) - struct_class("struct", name, bases, &block); - end - def cpp_class(name, *bases, &block) - struct_class("class", name, bases, &block); - end - def cpp_extern_class(scope, name, *bases, &block) - struct_class("class "+scope, name, bases, &block); - end - - def typedef(type, name) genl "typedef #{type} #{name};\n"; end - - def variant(types) "boost::variant<#{types.join(", ")}>"; end - def variantl(types) "boost::variant<#{types.join(", \n")}>"; end - def blank_variant(types) variant(["boost::blank"]+types); end - def tuple(types) "boost::tuple<#{types.join(', ')}>"; end - - def public() outdent { genl "public:" } end - def private() outdent { genl "private:" } end - def protected() outdent { genl "protected:" } end - - # Returns [namespace, classname, filename] - def parse_classname(full_cname) - names=full_cname.split("::") - return names[0..-2].join('::'), names[-1], names.join("/") - end - - def doxygen_comment(&block) - genl "/**" - prefix(" * ",&block) - genl " */" - end - - # Generate code in namespace for each class - def each_class_ns() - @amqp.classes.each { |c| namespace(c.nsname) { yield c } } - end - - def signature(ret_name, params, trailer="") - if params.size <= 1 - genl ret_name+"(#{params})"+trailer - else - scope(ret_name+"(",")"+trailer) { genl params.join(",\n") } - end - end - - def function_decl(ret_name, params=[], trailer="") - signature(ret_name, params, trailer+";") - end - - def function_defn(ret_name, params=[], trailer="") - genl - signature(ret_name, params, trailer) - scope() { yield } - end - - def ctor_decl(name, params=[]) function_decl(name, params); end - - def ctor_defn(name, params=[], inits=[]) - signature(name, params, inits.empty? ? "" : " :") - indent { gen inits.join(",\n") } if not inits.empty? - scope() { yield } - end - - def function_call(name, params=[], trailer="") - gen name - list "(",params, ")" - gen trailer - end -end - -# Fully-qualified class name -class FqClass < Struct.new(:fqname,:namespace,:name,:file) - def initialize(fqclass) - names=fqclass.split "::" - super(fqclass, names[0..-2].join('::'), names[-1], names.join("/")) - end -end - diff --git a/qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb b/qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb deleted file mode 100755 index d784e589df..0000000000 --- a/qpid/cpp/rubygen/framing.0-10/MethodBodyConstVisitor.rb +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env ruby -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -$: << ".." # Include .. in load path -require 'cppgen' - -class MethodBodyConstVisitorGen < CppGen - - def initialize(outdir, amqp) - super(outdir, amqp) - @namespace="qpid::framing" - @classname="MethodBodyConstVisitor" - @filename="qpid/framing/MethodBodyConstVisitor" - end - - def generate() - h_file("#{@filename}") { - namespace(@namespace) { - @amqp.methods_.each { |m| genl "class #{m.body_name};" } - cpp_class("MethodBodyConstVisitor") { - genl "public:" - genl "virtual ~MethodBodyConstVisitor() {}" - @amqp.methods_.each { |m| genl "virtual void visit(const #{m.body_name}&) = 0;" } - }}} - end -end - -MethodBodyConstVisitorGen.new($outdir, $amqp).generate(); - diff --git a/qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb b/qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb deleted file mode 100755 index 4c58ff2bbb..0000000000 --- a/qpid/cpp/rubygen/framing.0-10/MethodBodyDefaultVisitor.rb +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env ruby -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -$: << ".." # Include .. in load path -require 'cppgen' - -class MethodBodyDefaultVisitorGen < CppGen - - def initialize(outdir, amqp) - super(outdir, amqp) - @namespace, @classname, @filename = parse_classname("qpid::framing::MethodBodyDefaultVisitor") - end - - def generate() - h_file(@filename) { - include "qpid/framing/MethodBodyConstVisitor" - include "qpid/CommonImportExport.h" - namespace(@namespace) { - genl "class AMQMethodBody;" - cpp_extern_class("QPID_COMMON_CLASS_EXTERN", @classname, "public MethodBodyConstVisitor") { - genl "public:" - genl "virtual void defaultVisit(const AMQMethodBody&) = 0;" - @amqp.methods_.each { |m| - genl "QPID_COMMON_EXTERN virtual void visit(const #{m.body_name}&);" } - }}} - - cpp_file(@filename) { - include(@filename) - include("qpid/framing/all_method_bodies.h") - namespace(@namespace) { - @amqp.methods_.each { |m| - genl "void #{@classname}::visit(const #{m.body_name}& b) { defaultVisit(b); }" - }}} - end -end - -MethodBodyDefaultVisitorGen.new($outdir, $amqp).generate(); - diff --git a/qpid/cpp/rubygen/framing.0-10/MethodBodyFactory.rb b/qpid/cpp/rubygen/framing.0-10/MethodBodyFactory.rb deleted file mode 100644 index 28a5d94e32..0000000000 --- a/qpid/cpp/rubygen/framing.0-10/MethodBodyFactory.rb +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env ruby -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -$: << ".." # Include .. in load path -require 'cppgen' - -class MethodBodyFactoryGen < CppGen - - def initialize(outdir, amqp) - super(outdir, amqp) - @namespace="qpid::framing" - @classname="MethodBodyFactory" - @filename="qpid/framing/MethodBodyFactory" - end - - def generate() - cpp_file(@filename) { - include @filename - include "qpid/framing/BodyFactory" - @amqp.methods_.each { |m| include "qpid/framing/#{m.body_name}" } - include "qpid/Exception.h" - include "qpid/Msg.h" - genl - namespace(@namespace) { - scope("boost::intrusive_ptr #{@classname}::create(ClassId c, MethodId m) {") { - scope("switch (c) {") { - @amqp.classes.each { |c| - scope("case #{c.code}: switch(m) {") { - c.methods_.each { |m| - genl "case #{m.code}: return BodyFactory::create<#{m.body_name}>();" - } - genl "default: throw Exception(QPID_MSG(\"Invalid method id \" << int(m) << \" for class #{c.name} \"));" - } - genl "break;" - } - genl "default: throw Exception(QPID_MSG(\"Invalid class id \" << int(c)));" - } - } - }} - end -end - -MethodBodyFactoryGen.new($outdir, $amqp).generate(); diff --git a/qpid/cpp/rubygen/framing.0-10/Operations.rb b/qpid/cpp/rubygen/framing.0-10/Operations.rb deleted file mode 100755 index cd6a363c56..0000000000 --- a/qpid/cpp/rubygen/framing.0-10/Operations.rb +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env ruby -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Usage: output_directory xml_spec_file [xml_spec_file...] -# -$: << '..' -require 'cppgen' -require 'fileutils' -require 'etc' -require 'pathname' - -class OperationsGen < CppGen - - def initialize(chassis, outdir, amqp) - super(outdir, amqp) - @chassis=chassis - @classname="AMQP_#{@chassis.caps}Operations" - end - - def handler_method (m) - return_type = m.result ? m.result.cpptype.ret_by_val : "void" - gen "\nvirtual #{return_type} #{m.cppname}(" - gen m.signature.join(",\n") - gen ") = 0;\n" - end - - def handler_classname(c) c.name.caps+"Handler"; end - - def methods_on(parent, chassis) - chassis == "all" ? parent.methods_ : parent.methods_on(chassis) - end - - def handler_class(c) - m = methods_on(c,@chassis) - if (not m.empty?) - handlerclass=handler_classname c - gen < -#include "qpid/framing/ProtocolVersion.h" -#include "qpid/framing/amqp_structs.h" - -namespace qpid { -namespace framing { - -class AMQMethodBody; - -class #{@classname} { - public: - class Invoker; // Declared in #{@chassis.caps}Invoker - - virtual ~#{@classname}() {} - - virtual ProtocolVersion getVersion() const = 0; - - // Inner classes -EOS - indent { @amqp.classes.each { |c| handler_class(c) } } - gen <encode(body.invoke(target), result.result);" - else - genl "body.invoke(target);" - end - genl "result.handled=true;" - } - } - end - - def ops_visits_cpp() - @amqp.classes.each { |c| - visit_methods(c).each { |m| - scope("void #{@classname}::visit(const #{m.body_name}& body) {") { - genl "#{handler(c)}::Invoker invoker(*target.#{getter(c)}());" - genl "body.accept(invoker);" - genl "result=invoker.getResult();" - } - } - } - end - - def invoker_h(invoker, target, methods) - return if methods.empty? - genl - cpp_extern_class("QPID_COMMON_CLASS_EXTERN", invoker, "public qpid::framing::Invoker") { - genl "#{target}& target;" - public - genl("Invoker(#{target}& target_) : target(target_) {}") - genl "using MethodBodyDefaultVisitor::visit;" - methods.each { |m| genl "QPID_COMMON_EXTERN void visit(const #{m.body_name}& body);" } - } - end - - def generate() - h_file(@filename) { - include "qpid/framing/#{@ops}" - include "qpid/framing/Invoker.h" - include "qpid/CommonImportExport.h" - namespace("qpid::framing") { - # AMQP_*Operations invoker. - methods=@amqp.classes.map { |c| visit_methods(c).to_a }.flatten - invoker_h(@classname, @ops, methods) - - # AMQP_*Operations::*Handler invokers. - @amqp.classes.each { |c| - invoker_h(invoker(c), handler(c), visit_methods(c)) - } - } - } - - cpp_file(@filename) { - include @filename - @amqp.classes.each { |c| - visit_methods(c).each { |m| - include "qpid/framing/#{m.body_name}" - }} - namespace("qpid::framing") { - ops_visits_cpp - @amqp.classes.each { |c| - next if visit_methods(c).empty? - handler_visits_cpp(c) - } - } - } - end -end - -OperationsInvokerGen.new("client",$outdir, $amqp).generate() -OperationsInvokerGen.new("server",$outdir, $amqp).generate() -OperationsInvokerGen.new("all",$outdir, $amqp).generate() diff --git a/qpid/cpp/rubygen/framing.0-10/Proxy.rb b/qpid/cpp/rubygen/framing.0-10/Proxy.rb deleted file mode 100755 index 3325616754..0000000000 --- a/qpid/cpp/rubygen/framing.0-10/Proxy.rb +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env ruby -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -$: << ".." # Include .. in load path -require 'cppgen' - -class ProxyGen < CppGen - - def initialize(chassis, outdir, amqp) - super(outdir, amqp) - @chassis=chassis - @classname="AMQP_#{@chassis.caps}Proxy" - @filename="qpid/framing/#{@classname}" - end - - def methods_on(parent, chassis) - chassis == "all" ? parent.methods_ : parent.methods_on(chassis) - end - - def proxy_member(c) c.name.lcaps+"Proxy"; end - - def inner_class_decl(c) - cname=c.name.caps - cpp_extern_class("QPID_COMMON_CLASS_EXTERN", cname, "public Proxy") { - gen <" - include "qpid/framing/#{@classname}.h" - include "qpid/framing/amqp_types_full.h" - methods_on(@amqp, @chassis).each { - |m| include "qpid/framing/"+m.body_name - } - genl - namespace("qpid::framing") { - genl "#{@classname}::#{@classname}(FrameHandler& f) :" - gen " Proxy(f)" - @amqp.classes.each { |c| gen ",\n "+proxy_member(c)+"(f)" } - genl "{}\n" - @amqp.classes.each { |c| inner_class_defn(c) } - }} - end -end - - -ProxyGen.new("client", $outdir, $amqp).generate; -ProxyGen.new("server", $outdir, $amqp).generate; -ProxyGen.new("all", $outdir, $amqp).generate; - diff --git a/qpid/cpp/rubygen/framing.0-10/Session.rb b/qpid/cpp/rubygen/framing.0-10/Session.rb deleted file mode 100755 index 28165448ed..0000000000 --- a/qpid/cpp/rubygen/framing.0-10/Session.rb +++ /dev/null @@ -1,419 +0,0 @@ -#!/usr/bin/env ruby -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Usage: output_directory xml_spec_file [xml_spec_file...] -# -$: << '..' -require 'cppgen' - -class CppGen - def session_methods(sync_default) - excludes = ["connection", "session", "file", "stream"] - gen_methods=@amqp.methods_on(@chassis).reject { |m| - excludes.include? m.parent.name or m.body_name.include?("010") - } - gen_methods.each { |m| m.set_sync_default(sync_default) } - end - - - # Generates a doxygen comment for AmqpMethod m. - def doxygen(m) - return unless m.doc - doxygen_comment { - genl m.doc - genl - m.fields_c.each { |f| - genl "@param #{f.cppname}" - genl f.doc if f.doc - genl - } - } - end -end - -# Sync vs. async APIs -module SyncAsync - def sync_prefix() @async ? "Async" : "" end - def sync_adjective() @async ? "asynchronous" : "synchronous" end - def sync_convert() @async ? "async" : "sync" end - - - def decl_ctor_opeq() - genl - genl "QPID_CLIENT_EXTERN #{@classname}();" - genl "QPID_CLIENT_INLINE_EXTERN #{@classname}(const #{@version_base}& other);" - genl "QPID_CLIENT_INLINE_EXTERN #{@classname}& operator=(const #{@version_base}& other);" - end - - def defn_ctor_opeq(inline="") - genl - genl "#{inline} #{@classname}::#{@classname}() {}" - scope("#{inline} #{@classname}::#{@classname}(const #{@version_base}& other) {") { - genl "*this = other;" - } - scope("#{inline} #{@classname}& #{@classname}::operator=(const #{@version_base}& other) {") { - genl "impl = static_cast(other).impl;" - genl "return *this;" - } - end - - def sync_default() !@async end -end - -class ContentField # For extra content parameters - def cppname() "content" end - def signature() "const Message& content" end - def sig_default() signature+"="+"Message(std::string())" end - def unpack() "p[arg::content|Message(std::string())]"; end - def doc() "Message content"; end -end - -class SyncField # For extra sync parameters - def initialize(default_value) @default_value=default_value ? "true" : "false" end - def cppname() "sync" end - def signature() "bool sync" end - def sig_default() signature+"="+@default_value end - def unpack() "p[arg::sync|#{@default_value}]"; end - def doc() "If true the broker will respond with completion status as soon as possible."; end -end - -class AmqpField - def unpack() "p[arg::#{cppname}|#{default_value}]"; end - def sig_default() signature+"="+default_value; end -end - -class AmqpMethod - def set_sync_default(sync_default) @sync_default=sync_default end - def fields_c() result = fields + (content ? [ContentField.new] : []) + [SyncField.new(@sync_default)] end - def param_names_c() fields_c.map { |f| f.cppname} end - def signature_c() fields_c.map { |f| f.signature }; end - def sig_c_default() fields_c.map { |f| f.sig_default }; end - def argpack_name() "#{parent.cppname}#{name.caps}Parameters"; end - def argpack_type() - "boost::parameter::parameters<" + - fields_c.map { |f| "arg::keyword_tags::"+f.cppname }.join(',') + - ">" - end - - def return_type(async) - if (async) - return "TypedResult" if (result) - return "Completion" - else - return "qpid::framing::#{result.cpptype.ret_by_val}" if (result) - return "void" - end - end - - def session_function() "#{parent.name.lcaps}#{name.caps}"; end -end - -class SessionNoKeywordGen < CppGen - include SyncAsync - - def initialize(outdir, amqp, async) - super(outdir, amqp) - @async=async - @chassis="server" - @namespace,@classname,@file= - parse_classname "qpid::client::no_keyword::#{sync_prefix}Session_#{@amqp.version.bars}" - @version_base="SessionBase_#{@amqp.major}_#{@amqp.minor}" - end - - def generate() - public_api("#{@file}.h") - h_file(@file) { - include "qpid/client/#{@version_base}.h" - include "qpid/client/ClientImportExport.h" - namespace(@namespace) { - doxygen_comment { - genl "AMQP #{@amqp.version} #{sync_adjective} session API." - d = @amqp.class_("session").doc - genl d if d - # FIXME aconway 2008-05-23: additional doc on sync/async use. - } - cpp_class(@classname, "public #{@version_base}") { - public - decl_ctor_opeq() - session_methods(sync_default).each { |m| - genl - doxygen(m) - args=m.sig_c_default.join(", ") - genl "QPID_CLIENT_EXTERN #{m.return_type(@async)} #{m.session_function}(#{args});" - } - } - }} - - cpp_file(@file) { - include "qpid/client/#{@classname}" - include "qpid/framing/all_method_bodies.h" - include "qpid/client/SessionImpl.h" - include "qpid/client/MessageImpl.h" - include "qpid/client/PrivateImplRef.h" - include "qpid/client/CompletionImpl.h" - include "" - namespace(@namespace) { - genl "using namespace framing;" - session_methods(sync_default).each { |m| - genl - sig=m.signature_c.join(", ") - func="#{@classname}::#{m.session_function}" - scope("#{m.return_type(@async)} #{func}(#{sig}) {") { - args=(["ProtocolVersion(#{@amqp.major},#{@amqp.minor})"]+m.param_names).join(", ") - genl "#{m.body_name} body(#{args});"; - genl "body.setSync(sync);" - sendargs="body" - sendargs << ", *MessageImpl::get(content)" if m.content - async_retval="#{m.return_type(true)}(new CompletionImpl(impl->send(#{sendargs}), impl))" - if @async then - genl "return #{async_retval};" - else - if m.result - genl "return #{async_retval}.get();" - else - genl "#{async_retval}.wait();" - end - end - }} - defn_ctor_opeq() - }} - end -end - -class SessionGen < CppGen - include SyncAsync - - def initialize(outdir, amqp, async) - super(outdir, amqp) - @async=async - @chassis="server" - session="#{sync_prefix}Session_#{@amqp.version.bars}" - @base="no_keyword::#{session}" - @fqclass=FqClass.new "qpid::client::#{session}" - @classname=@fqclass.name - @fqbase=FqClass.new("qpid::client::#{@base}") - @version_base="SessionBase_#{@amqp.major}_#{@amqp.minor}" - end - - def gen_keyword_decl(m) - return if m.fields_c.empty? # Inherited function will do. - scope("BOOST_PARAMETER_MEMFUN(#{m.return_type(@async)}, #{m.session_function}, 0, #{m.fields_c.size}, #{m.argpack_name}) {") { - scope("return #{@base}::#{m.session_function}(",");") { - gen m.fields_c.map { |f| f.unpack() }.join(",\n") - } - } - genl - end - - def generate() - keyword_methods=session_methods(sync_default).reject { |m| m.fields_c.empty? } - max_arity = keyword_methods.map{ |m| m.fields_c.size }.max - - public_api("qpid/client/arg.h") - h_file("qpid/client/arg.h") { - # Generate keyword tag declarations. - genl "#define BOOST_PARAMETER_MAX_ARITY #{max_arity}" - include "" - namespace("qpid::client::arg") { - keyword_methods.map{ |m| m.param_names_c }.flatten.uniq.each { |k| - genl "BOOST_PARAMETER_KEYWORD(keyword_tags, #{k})" - }} - } - public_api("#{@fqclass.file}.h") - h_file(@fqclass.file) { - include @fqbase.file - include "qpid/client/arg" - include "qpid/client/ClientImportExport" - namespace("qpid::client") { - # Doxygen comment. - doxygen_comment { - genl "AMQP #{@amqp.version} session API with keyword arguments." - genl <Publishing Messages -
    -
  • messageTransfer()

    -
    session.messageTransfer(arg::content=message, arg::destination="amq.topic");
  • -
  • messageTransfer() — asynchronous

    -
    #include <qpid/client/AsyncSession.h>
    -
    -for (int i=0; i<10; i++) {
    -    message.setData(message_data.str());
    -    async(session).messageTransfer(arg::content=message,  arg::destination="amq.direct");        
    -}
    -
    -session.sync();
    -
    -
  • -
- -

Exchanges

-
    -
  • exchangeBind()

    -
    session.exchangeBind(arg::exchange="amq.topic", arg::queue=queue, arg::bindingKey=routing_key);
    -
  • -
  • exchangeUnbind()

    -
    session.exchangeUnBind(arg::exchange="amq.topic", arg::queue=queue, arg::bindingKey=routing_key);
  • -
  • exchangeBound()

    -
    if (session.exchangeBound(arg::exchange="amq.topic", arg::queue=queue, arg::bindingKey=rk)){...}
    -
    if (session.exchangeBound(arg::exchange="amq.topic", arg::queue=queue)){...}
    -
  • -
  • exchangeDeclare()

    -
    session.exchangeDeclare(arg::exchange="my.topic", arg::type="topic");
    -
    session.exchangeDeclare(arg::exchange="xml", arg::type="xml");
    -
  • -
  • exchangeDelete()

    -
    session.exchangeDeclare(arg::exchange="my.topic");
    -
    session.exchangeDeclare(arg::exchange="xml", arg::ifUnused=true);
    -
  • -
  • exchangeQuery()

    -
    ExchangeQueryResult eqr = session.exchangeQuery(arg::exchange="my.topic");
  • -
- - -

Configuring exchanges in session.exchangeDeclare

- -
arg::durable=true
-

Default: false.

-

If durable=true, an exchange remains active even if the server is restarted. If durable=false, an exchange is purged when a server restarts.

- -
arg::autoDelete=true
-

Default: false.

-

If autoDelete=true, deleting the last binding for an exchange also deletes the exchange.

- -
arg::alternatExchange="my.exchange"
-

Default: none.

-

If an alternate exchange is specified, messages that can not be delivered to any queue are sent to the alternate exchange.

- -

Queues

-
    -
  • queueDeclare()

    -
    session.queueDeclare(arg::queue="message_queue");
    -
  • -
  • queueDelete()

    -
    session.queueDelete(arg::queue="message_queue");
  • -
  • queuePurge()

    -
    session.queuePurge(arg::queue="message_queue");
  • -
  • queueQuery()

    -
    QueueQueryResult qqr = session.queueQuery(arg::queue="message_queue");
  • -
- - -

Configuring queues with session.queueDeclare

-
arg::durable=true
-

Default: false.

-

If durable=true, a queue remains active if the server is restarted. If durable=false, a queue and its contents are lost when a server restarts.

-
- -
arg::autoDelete=true
-

Default: false.

-

If autoDelete=true, the queue is deleted when the last active Subscription to the Queue is canceled.

-
- -
arg::exclusive=true
-

Default: false.

-

If exclusive=true, only the Session that created a queue can access it.

-
- -
arg::alternateExchange="my.exchange"
-

Default: none.

-

If an alternate exchange is specified, messages are routed to it if (1) they are rejected by a client, or (2) they remain on the queue when it is deleted.

-
- - -

Accepting, Acquiring, Rejecting, or Releasing Messages

-
    -
  • messageAccept() — acknowledges messages

    -
    SequenceSet tobeAccepted; 
    -toAccepted.add(msg.getId()); 
    -session.messageAccept(toBeAccepted);
    -
  • -
  • messageAcquire()

    -
    SequenceSet tobeAcquired;
    -toBeAcquired.add(msg.getId()); 
    -session.messageAcquire(toBeAcquired);
    -
  • -
  • messageReject()

    -
    SequenceSet tobeRejected; 
    -toRejected.add(msg.getId()); 
    -session.messageReject(toBeRejected);
    -
  • -
  • messageRelease()

    -
    SequenceSet tobeReleased; 
    -toReleased.add(msg.getId()); 
    -session.messageRelease(toBeReleased);
  • -
- -

Transactions

-
    -
  • txSelect()

    -
    session.txSelect();
    -
  • -
  • txCommit()

    -
    session.txSelect();
  • -
  • txRollback()

    -
    session.txRollback();
  • -
- - -EOS - } - # Session class. - cpp_class(@classname,"public #{@base}") { - public - decl_ctor_opeq() - private - keyword_methods.each { |m| typedef m.argpack_type, m.argpack_name } - genl "friend class Connection;" - public - keyword_methods.each { |m| gen_keyword_decl(m) } - } - genl "/** Conversion to #{@classname} from another session type */" - genl "inline #{@classname} #{sync_convert}(const #{@version_base}& other) { return #{@clasname}(other); }" - defn_ctor_opeq("inline") - }} - end -end - -SessionNoKeywordGen.new($outdir, $amqp, true).generate() -SessionNoKeywordGen.new($outdir, $amqp, false).generate() -SessionGen.new($outdir, $amqp, true).generate() -SessionGen.new($outdir, $amqp, false).generate() - diff --git a/qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb b/qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb deleted file mode 100755 index 4c7fccfff5..0000000000 --- a/qpid/cpp/rubygen/framing.0-10/all_method_bodies.rb +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env ruby -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -$: << ".." # Include .. in load path -require 'cppgen' - -class AllMethodBodiesGen < CppGen - - def initialize(outdir, amqp) - super(outdir, amqp) - @namespace="qpid::framing" - @filename="qpid/framing/all_method_bodies" - end - - def generate() - h_file(@filename) { - @amqp.methods_.each { |m| include "qpid/framing/"+m.body_name } - } - end -end - -AllMethodBodiesGen.new($outdir, $amqp).generate(); - diff --git a/qpid/cpp/rubygen/framing.0-10/constants.rb b/qpid/cpp/rubygen/framing.0-10/constants.rb deleted file mode 100755 index 589d94e23d..0000000000 --- a/qpid/cpp/rubygen/framing.0-10/constants.rb +++ /dev/null @@ -1,208 +0,0 @@ -#!/usr/bin/env ruby -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -$: << ".." # Include .. in load path -require 'cppgen' - -class ConstantsGen < CppGen - - def initialize(outdir, amqp) - super(outdir, amqp) - @namespace="qpid::framing" - @dir="qpid/framing" - end - - def constants_h() - public_api("#{@dir}/constants.h") - h_file("#{@dir}/constants.h") { - namespace(@namespace) { - # Constants for class/method names. - scope("enum AmqpConstant {","};") { - l=[] - l.concat @amqp.constants.map { |c| "#{c.name.shout}=#{c.value}" } - @amqp.classes.each { |c| - l << "#{c.name.shout}_CLASS_ID=#{c.code}" - l.concat c.methods_.map { |m| - "#{c.name.shout}_#{m.name.shout}_METHOD_ID=#{m.code}" } - } - genl l.join(",\n") - } - } - } - end - - def typecode_enum(t) "TYPE_CODE_#{t.name.shout}" end - - def typecode_h_cpp - path="#{@dir}/TypeCode" - public_api(path+".h") - h_file(path) { - include("") - include("\"qpid/sys/IntegerTypes.h\"") - namespace(@namespace) { - scope("enum TypeCode {", "};") { - genl @amqp.types.map { |t| "#{typecode_enum t} = #{t.code}" if t.code }.compact.join(",\n") - } - genl <") - namespace(@namespace) { - scope("const char* typeName(TypeCode t) {") { - scope("switch (t) {") { - @amqp.types.each { |t| genl "case #{typecode_enum t}: return \"#{t.name}\";" if t.code } - genl "default: break;" - } - genl "return 0;"; - } - genl <" - include "" - namespace("qpid::framing") { - create_exception("execution", "error-code", "SessionException", "InvalidArgumentException") - # FIXME aconway 2008-10-07: there are no good exception codes in 0-10 for an invalid code. - # The following choices are arbitrary. - create_exception("connection", "close-code", "ConnectionException", "FramingErrorException") - create_exception("session", "detach-code", "ChannelException", "NotAttachedException") - } - } - end - - def generate() - constants_h - enum_h - reply_exceptions_h - reply_exceptions_cpp - typecode_h_cpp - end -end - -ConstantsGen.new($outdir, $amqp).generate(); - diff --git a/qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb b/qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb deleted file mode 100644 index 4f1b976032..0000000000 --- a/qpid/cpp/rubygen/framing.0-10/frame_body_lists.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -$: << ".." # Include .. in load path -require 'cppgen' - -class FrameBodyListsGen < CppGen - - def initialize(outdir, amqp) - super(outdir, amqp); - end - - def generate - h_file("qpid/framing/frame_body_lists.h") { - gen <1, - "Short"=>2, - "Long"=>4, - "LongLong"=>8, - "int8"=>1, - "int16"=>2, - "int32"=>4, - "int64"=>8, - "uint8"=>1, - "uint16"=>2, - "uint32"=>4, - "uint64"=>8, - "timestamp"=>8 - } - - StringSizeMap={ - "LongString"=>4, - "MediumString"=>2, - "ShortString"=>1 - } - - SizeType={ - 1=>"Octet", - 2=>"Short", - 4=>"Long", - 8=>"LongLong" - } - - ValueTypes=["uint8_t", "uint16_t", "uint32_t", "uint64_t"] - - def is_packed(s) s.pack and s.pack != "0" end - - def execution_header?(s) - s.is_a? AmqpMethod and not s.parent.control? - # s.kind_of? AmqpMethod and s.parent.name.include?("010") and not s.parent.control? - end - - def has_bitfields_only(s) - s.fields.select {|f| f.type_ != "bit"}.empty? - end - - def default_initialisation(s) - params = s.fields.select {|f| ValueTypes.include?(f.cpptype.name) || (!is_packed(s) && f.type_ == "bit")} - strings = params.collect {|f| "#{f.cppname}(#{f.default_value})"} - strings << "flags(0)" if (is_packed(s)) - if strings.empty? - return "" - else - return " : " + strings.join(", ") - end - end - - def printable_form(f) - if (f.cpptype.name == "uint8_t") - return "(int) " + f.cppname - elsif (f.type_ == "bit") - return "get#{f.name.caps}()" - else - return f.cppname - end - end - - def flag_mask(s, i) - pos = s.pack.to_i*8 - 8 - (i/8)*8 + (i % 8) - return "(1 << #{pos})" - end - - def encode_packed_struct(s) - genl s.cpp_pack_type.encode('flags', 'buffer') - process_packed_fields(s) { |f, i| encode_packed_field(s, f, i) unless f.type_ == "bit" } - end - - def decode_packed_struct(s) - genl "#{s.cpp_pack_type.decode('flags', 'buffer')}" - process_packed_fields(s) { |f, i| decode_packed_field(s, f, i) unless f.type_ == "bit" } - end - - def size_packed_struct(s) - genl "total += #{s.pack};" - process_packed_fields(s) { |f, i| size_packed_field(s, f, i) unless f.type_ == "bit" } - end - - def print_packed_struct(s) - process_packed_fields(s) { |f, i| print_packed_field(s, f, i) } - end - - def encode_packed_field(s, f, i) - genl "if (flags & #{flag_mask(s, i)})" - indent { genl f.cpptype.encode(f.cppname,"buffer") } - end - - def decode_packed_field(s, f, i) - genl "if (flags & #{flag_mask(s, i)})" - indent { genl f.cpptype.decode(f.cppname,"buffer") } - end - - def size_packed_field(s, f, i) - genl "if (flags & #{flag_mask(s, i)})" - indent { generate_size(f, []) } - end - - def print_packed_field(s, f, i) - classname = s.cppname - if (s.kind_of? AmqpMethod) - classname = s.body_name - end - genl "if (flags & #{flag_mask(s, i)})" - indent { - unless (classname == "ConnectionStartOkBody" && f.name == "response") - genl "out << \"#{f.name}=\" << #{printable_form(f)} << \"; \";" - else - genl "out << \"response=\" << \"xxxxxx\" << \"; \";" - end - } - end - - def generate_encode(f, combined) - if (f.type_ == "bit") - genl "uint8_t #{f.cppname}_bits = #{f.cppname};" - count = 0 - combined.each { |c| genl "#{f.cppname}_bits |= #{c.cppname} << #{count += 1};" } - genl "buffer.putOctet(#{f.cppname}_bits);" - else - genl f.cpptype.encode(f.cppname,"buffer") - end - end - - def generate_decode(f, combined) - if (f.type_ == "bit") - genl "uint8_t #{f.cppname}_bits = buffer.getOctet();" - genl "#{f.cppname} = 1 & #{f.cppname}_bits;" - count = 0 - combined.each { |c| genl "#{c.cppname} = (1 << #{count += 1}) & #{f.cppname}_bits;" } - else - genl f.cpptype.decode(f.cppname,"buffer") - end - end - - def generate_size(f, combined) - if (f.type_ == "bit") - names = ([f] + combined).collect {|g| g.cppname} - genl "total += 1;//#{names.join(", ")}" - else - size = SizeMap[f.cpptype.encoded] - if (size) - genl "total += #{size};//#{f.cppname}" - elsif (f.cpptype.name == "SequenceNumberSet") - genl "total += #{f.cppname}.encodedSize();" - elsif (size = StringSizeMap[f.cpptype.encoded]) - genl "total += #{size} + #{f.cppname}.size();" - else - genl "total += #{f.cppname}.encodedSize();" - end - end - end - - def check_field(f) - if (size = StringSizeMap[f.cpptype.encoded] and size < 4) - limit = 2 ** (size * 8) - genl "if (#{f.cppname}.size() >= #{limit}) throw IllegalArgumentException(\"Value for #{f.cppname} is too large\");" - end - end - - def process_packed_fields(s) - s.fields.each { |f| yield f, s.fields.index(f) } - end - - def process_fields(s) - last = nil - count = 0 - bits = [] - s.fields.each { - |f| if (last and last.bit? and f.bit? and count < 7) - count += 1 - bits << f - else - if (last and last.bit?) - yield last, bits - count = 0 - bits = [] - end - if (not f.bit?) - yield f - end - last = f - end - } - if (last and last.bit?) - yield last, bits - 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}(#{all_fields_via_accessors(s)}); - } - - using AMQMethodBody::accept; - void accept(MethodBodyConstVisitor& v) const { v.visit(*this); } - boost::intrusive_ptr clone() const { return BodyFactory::copy(*this); } - - ClassId amqpClassId() const { return CLASS_ID; } - MethodId amqpMethodId() const { return METHOD_ID; } - bool isContentBearing() const { return #{s.content ? "true" : "false" }; } - bool resultExpected() const { return #{s.result ? "true" : "false"}; } - bool responseExpected() const { return #{s.responses().empty? ? "false" : "true"}; } -EOS - end - - def define_constructor(name, s) - if (s.fields.size > 0) - genl "#{name}(" - if (s.kind_of? AmqpMethod) - indent {gen "ProtocolVersion, "} - end - indent { gen s.fields.collect { |f| "#{f.cpptype.param} _#{f.cppname}" }.join(",\n") } - genl ") : " - if (is_packed(s)) - initialisers = s.fields.select { |f| f.type_ != "bit"}.collect { |f| "#{f.cppname}(_#{f.cppname})"} - - initialisers << "flags(0)" - indent { gen initialisers.join(",\n") } - genl "{" - indent { - process_packed_fields(s) { |f, i| genl "set#{f.name.caps}(_#{f.cppname});" if f.type_ == "bit"} - process_packed_fields(s) { |f, i| genl "flags |= #{flag_mask(s, i)};" unless f.type_ == "bit"} - s.fields.each { |f| check_field(f) } - } - genl "}" - else - indent { gen s.fields.collect { |f| " #{f.cppname}(_#{f.cppname})" }.join(",\n") } - genl "{" - indent { - s.fields.each { |f| check_field(f) } - } - genl "}" - end - end - #default constructors: - if (s.kind_of? AmqpMethod) - genl "#{name}(ProtocolVersion=ProtocolVersion()) #{default_initialisation(s)} {}" - end - if (s.kind_of? AmqpStruct) - genl "#{name}() #{default_initialisation(s)} {}" - end - 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.type_ == "bit") - genl "void #{s.cppname}::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.cppname}::get#{f.name.caps}() const { return flags & #{flag_mask(s, i)}; }" - else - genl "void #{s.cppname}::set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {" - indent { - genl "#{f.cppname} = _#{f.cppname};" - genl "flags |= #{flag_mask(s, i)};" - check_field(f) - } - genl "}" - genl "#{f.cpptype.ret} #{s.cppname}::get#{f.name.caps}() const { return #{f.cppname}; }" - if (f.cpptype.name == "FieldTable") - genl "#{f.cpptype.name}& #{s.cppname}::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.cppname}::has#{f.name.caps}() const { return flags & #{flag_mask(s, i)}; }" - genl "void #{s.cppname}::clear#{f.name.caps}Flag() { flags &= ~#{flag_mask(s, i)}; }" - end - genl "" - end - - def define_packed_field_accessors_for_method(s, f, i) - if (f.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)};" - check_field(f) - } - 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 - - def declare_packed_accessors(f) - genl "QPID_COMMON_EXTERN void set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname});"; - genl "QPID_COMMON_EXTERN #{f.cpptype.ret} get#{f.name.caps}() const;" - if (f.cpptype.name == "FieldTable") - genl "QPID_COMMON_EXTERN #{f.cpptype.name}& get#{f.name.caps}();" - end - if (f.type_ != "bit") - #extra 'accessors' for packed fields: - genl "QPID_COMMON_EXTERN bool has#{f.name.caps}() const;" - genl "QPID_COMMON_EXTERN void clear#{f.name.caps}Flag();" - end - end - - def define_accessors(f) - genl "void set#{f.name.caps}(#{f.cpptype.param} _#{f.cppname}) {" - indent { - genl "#{f.cppname} = _#{f.cppname};" - check_field(f) - } - genl "}" - genl "#{f.cpptype.ret} get#{f.name.caps}() const { return #{f.cppname}; }" - if (f.cpptype.name == "FieldTable") - genl "#{f.cpptype.name}& get#{f.name.caps}() { return #{f.cppname}; }" - end - end - - def define_struct(s) - classname = s.cppname - inheritance = "" - if (s.kind_of? AmqpMethod) - classname = s.body_name - if (execution_header?(s)) - inheritance = ": public ModelMethod" - else - inheritance = ": public AMQMethodBody" - end - else - public_api("qpid/framing/#{classname}.h") # Non-method structs are public - end - - h_file("qpid/framing/#{classname}.h") { - if (s.kind_of? AmqpMethod) - gen < -#include "qpid/framing/amqp_types_full.h" -#include "qpid/framing/reply_exceptions.h" -#include "qpid/CommonImportExport.h" - -namespace qpid { -namespace framing { - -class QPID_COMMON_CLASS_EXTERN #{classname} #{inheritance} { -EOS - if (is_packed(s)) - indent { s.fields.each { |f| genl "#{f.cpptype.name} #{f.cppname};" unless f.type_ == "bit"} } - indent { - genl "#{s.cpp_pack_type.name} flags;" - } - else - indent { s.fields.each { |f| genl "#{f.cpptype.name} #{f.cppname};" } } - end - genl "public:" - if (s.kind_of? AmqpMethod) - indent { genl "static const ClassId CLASS_ID = #{s.parent.code};" } - indent { genl "static const MethodId METHOD_ID = #{s.code};" } - end - - if (s.kind_of? AmqpStruct) - if (s.code) - indent { genl "static const uint16_t TYPE = #{s.full_code};" } - end - end - - indent { - define_constructor(classname, s) - genl "" - if (is_packed(s)) - s.fields.each { |f| declare_packed_accessors(f) } - else - s.fields.each { |f| define_accessors(f) } - end - } - if (s.kind_of? AmqpMethod) - methodbody_extra_defs(s) - end - if (s.kind_of? AmqpStruct) - indent {genl "QPID_COMMON_EXTERN friend std::ostream& operator<<(std::ostream&, const #{classname}&);" } - end - - gen < 0 || execution_header?(s)) - buffer = "buffer" - else - buffer = "/*buffer*/" - end - gen <