summaryrefslogtreecommitdiff
path: root/cpp/rubygen/0-10/specification.rb
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-03-11 22:13:10 +0000
committerAlan Conway <aconway@apache.org>2008-03-11 22:13:10 +0000
commiteadb91781ab0d6e786500a3798f1bf2a83293a05 (patch)
treee582626920f3583e27deda835a2e2389c9c5e8c7 /cpp/rubygen/0-10/specification.rb
parent2250ec787ae5fb84fbebfee35bd9925ebd1dd679 (diff)
downloadqpid-python-eadb91781ab0d6e786500a3798f1bf2a83293a05.tar.gz
rubygen/0-10/specification.rb:
- Simplified enum mapping/encoding. - struct encoding - ostream << operators src/qpid/Serializer.h - free funciton serialization - separate Encoder/Decoder for const correctness - split() to allow separate encode/decode for complex cases. src/qpid/amqp_0_10/Assembly.cpp, Assembly.h: AMQP 0-10 final Assembly src/qpid/amqp_0_10/Codec.h - Replaced enable_if with overloads, simpler & more flexible. src/qpid/amqp_0_10/Frame.cpp, .h: AMQP 0-10 final frame. src/qpid/amqp_0_10/Holder.h: - provide const and non-const apply src/qpid/amqp_0_10/Segment.cpp, .h: AMQP 0-10 final Segment. src/qpid/amqp_0_10/apply.h - ConstApplyFunctor for const apply. src/qpid/amqp_0_10/built_in_types.h - SerializableString encoding src/qpid/amqp_0_10/complex_types.cpp, .h - const application - Action base class for command/control. src/qpid/framing/AMQBody.h - removed 0-10 final changes, moving integration point down the stack. src/qpid/sys/Shlib.h - removed unused and uncompilable (on some compilers) function. src/qpid/sys/Time.h, .cpp - ostream << for AbsTime and Duration. src/tests/Assembly.cpp, Segment.cpp, apply.cpp, serialize.cpp: testing new code. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@636126 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/rubygen/0-10/specification.rb')
-rwxr-xr-xcpp/rubygen/0-10/specification.rb30
1 files changed, 21 insertions, 9 deletions
diff --git a/cpp/rubygen/0-10/specification.rb b/cpp/rubygen/0-10/specification.rb
index c159d9f08b..a11abdb877 100755
--- a/cpp/rubygen/0-10/specification.rb
+++ b/cpp/rubygen/0-10/specification.rb
@@ -15,11 +15,13 @@ class Specification < CppGen
genl
typename=d.name.typename
if d.enum
- scope("enum #{typename}Enum {", "};") {
+ scope("enum #{typename} {", "};") {
genl d.enum.choices.map { |c|
"#{c.name.constname} = #{c.value}" }.join(",\n")
}
- genl "typedef Enum<#{typename}Enum, uint8_t> #{typename};"
+ scope("inline SerializableEnum<#{typename}, uint8_t> serializable(#{typename}& e) {") {
+ genl "return SerializableEnum<#{typename}>(e);"
+ }
else
genl "typedef #{d.amqp2cpp} #{typename};"
end
@@ -52,11 +54,20 @@ class Specification < CppGen
ctor_decl(x.classname, x.parameters) unless x.fields.empty?
genl "void accept(Visitor&);"
genl "void accept(ConstVisitor&) const;"
+ if (x.fields.empty?)
+ genl "template <class S> void serialize(S&) {}"
+ else
+ scope("template <class S> void serialize(S& s) {") {
+ gen "s"; x.fields.each { |f| gen "(#{f.cppname})"}; genl ";"
+ }
+ end
genl
yield if block
}
+ genl "std::ostream& operator << (std::ostream&, const #{x.classname}&);"
end
+ # FIXME aconway 2008-03-10: packing, coding
def action_struct_cpp(x)
genl
genl "const char* #{x.classname}::NAME=\"#{x.fqname}\";"
@@ -73,6 +84,12 @@ class Specification < CppGen
genl "void #{x.classname}::accept(Visitor& v) { v.visit(*this); }"
genl "void #{x.classname}::accept(ConstVisitor& v) const { v.visit(*this); }"
end
+ genl
+ scope("std::ostream& operator << (std::ostream& o, const #{x.classname}&#{"x" unless x.fields.empty?}) {") {
+ genl "return o << \"[#{x.fqname}\";";
+ x.fields.each{ |f| genl "o << \" #{f.name}=\" << x.#{f.cppname};" }
+ genl "o << \"];\";"
+ }
end
# structs
@@ -87,13 +104,6 @@ class Specification < CppGen
function_defn("template <class T> void invoke", ["T& target"]) {
genl "target.#{a.funcname}(#{a.values.join(', ')});"
}
- if (a.fields.empty?)
- genl "template <class S> void serialize(S&) {}"
- else
- scope("template <class S> void serialize(S& s) {") {
- gen "s"; a.fields.each { |f| gen "(#{f.cppname})"}; genl ";"
- }
- end
}
end
@@ -108,6 +118,7 @@ class Specification < CppGen
include "#{@dir}/built_in_types"
include "#{@dir}/complex_types"
include "<boost/call_traits.hpp>"
+ include "<iosfwd>"
genl "using boost::call_traits;"
namespace(@ns) {
# Top level
@@ -133,6 +144,7 @@ class Specification < CppGen
cpp_file("#{@dir}/specification") {
include "#{@dir}/specification"
+ include "<iostream>"
# FIXME aconway 2008-03-04: add Struct visitors.
["Command","Control"].each { |x| include "#{@dir}/Apply#{x}" }
namespace(@ns) {