summaryrefslogtreecommitdiff
path: root/cpp/rubygen
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-11-07 20:55:35 +0000
committerGordon Sim <gsim@apache.org>2007-11-07 20:55:35 +0000
commit0a6761806f55ad18d65e2c22cd18a08e2ec5a149 (patch)
treee68f5ba20c7096cd1740131d4ab1a9326dfe0053 /cpp/rubygen
parentc9900041bf70ac76a4eb8753965fe24426ba8cd4 (diff)
downloadqpid-python-0a6761806f55ad18d65e2c22cd18a08e2ec5a149.tar.gz
Fix for QPID-639: c++ now includes sizes for all structs (enabled the same in python & java)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@592895 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/rubygen')
-rw-r--r--cpp/rubygen/templates/structs.rb61
1 files changed, 54 insertions, 7 deletions
diff --git a/cpp/rubygen/templates/structs.rb b/cpp/rubygen/templates/structs.rb
index d67a8925c4..edbadb01f6 100644
--- a/cpp/rubygen/templates/structs.rb
+++ b/cpp/rubygen/templates/structs.rb
@@ -260,7 +260,7 @@ EOS
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}() { flags &= ~#{flag_mask(s, i)}; }"
+ genl "void #{s.cppname}::clear#{f.name.caps}Flag() { flags &= ~#{flag_mask(s, i)}; }"
end
genl ""
end
@@ -275,9 +275,11 @@ EOS
if (f.cpptype.name == "FieldTable")
genl "#{f.cpptype.name}& get#{f.name.caps}();"
end
- #extra 'accessors' for packed fields:
- genl "bool has#{f.name.caps}() const;";
- genl "void clear#{f.name.caps}();";
+ if (f.domain.type_ != "bit")
+ #extra 'accessors' for packed fields:
+ genl "bool has#{f.name.caps}() const;"
+ genl "void clear#{f.name.caps}Flag();"
+ end
end
def define_accessors(f)
@@ -370,7 +372,10 @@ EOS
gen <<EOS
void encode(Buffer&) const;
void decode(Buffer&, uint32_t=0);
+ void encodeStructBody(Buffer&) const;
+ void decodeStructBody(Buffer&, uint32_t=0);
uint32_t size() const;
+ uint32_t bodySize() const;
void print(std::ostream& out) const;
}; /* class #{classname} */
@@ -394,7 +399,7 @@ EOS
define_packed_accessors(s)
end
gen <<EOS
-void #{classname}::encode(Buffer& #{buffer}) const
+void #{classname}::encodeStructBody(Buffer& #{buffer}) const
{
EOS
if (execution_header?(s))
@@ -409,7 +414,24 @@ EOS
gen <<EOS
}
-void #{classname}::decode(Buffer& #{buffer}, uint32_t /*size*/)
+void #{classname}::encode(Buffer& buffer) const
+{
+EOS
+ indent {
+ if (s.kind_of? AmqpStruct)
+ if (s.type_)
+ genl "buffer.put#{s.size.caps}(bodySize() + 2/*typecode*/);" if s.size
+ genl "buffer.putShort(TYPE);"
+ else
+ genl "buffer.put#{s.size.caps}(size());" if s.size
+ end
+ end
+ genl "encodeStructBody(buffer);"
+ }
+ gen <<EOS
+}
+
+void #{classname}::decodeStructBody(Buffer& #{buffer}, uint32_t /*size*/)
{
EOS
if (execution_header?(s))
@@ -424,7 +446,20 @@ EOS
gen <<EOS
}
-uint32_t #{classname}::size() const
+void #{classname}::decode(Buffer& buffer, uint32_t /*size*/)
+{
+EOS
+ indent {
+ if (s.kind_of? AmqpStruct)
+ genl "buffer.get#{s.size.caps}();" if s.size
+ genl "if (TYPE != buffer.getShort()) throw InternalErrorException(\"Bad type code for struct\");" if s.type_
+ end
+ genl "decodeStructBody(buffer);"
+ }
+ gen <<EOS
+}
+
+uint32_t #{classname}::bodySize() const
{
uint32_t total = 0;
EOS
@@ -441,6 +476,18 @@ EOS
return total;
}
+uint32_t #{classname}::size() const
+{
+ uint32_t total = bodySize();
+EOS
+ if (s.kind_of? AmqpStruct)
+ genl "total += #{SizeMap[s.size]}/*size field*/;" if s.size
+ genl "total += 2/*typecode*/;" if s.type_
+ end
+ gen <<EOS
+ return total;
+}
+
void #{classname}::print(std::ostream& out) const
{
out << "{#{classname}: ";