summaryrefslogtreecommitdiff
path: root/python/qpid/spec.py
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2007-10-14 02:21:59 +0000
committerRafael H. Schloming <rhs@apache.org>2007-10-14 02:21:59 +0000
commit9637c6b5095e9fadc895288508888c4c54c8de91 (patch)
tree6fade7cb8a21adb3d55c8d4f467941d0927d635d /python/qpid/spec.py
parent92e0c21cfbe396079abac9ae7e884d86371170bb (diff)
downloadqpid-python-9637c6b5095e9fadc895288508888c4c54c8de91.tar.gz
Enabled packed struct encoding in python, cpp, and java. Also fixed computation of required byte credit in Message.cpp.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@584474 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/spec.py')
-rw-r--r--python/qpid/spec.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/python/qpid/spec.py b/python/qpid/spec.py
index 2542ccc3e1..31c79276aa 100644
--- a/python/qpid/spec.py
+++ b/python/qpid/spec.py
@@ -29,7 +29,7 @@ class so that the generated code can be reused in a variety of
situations.
"""
-import re, textwrap, new, mllib
+import re, textwrap, new, mllib, qpid
class SpecContainer:
@@ -115,6 +115,10 @@ class Spec(Metadata):
klass, meth = parts
return self.classes.byname[klass].methods.byname[meth]
+ def struct(self, name):
+ type = self.domains.byname[name].type
+ return qpid.Struct(type)
+
def define_module(self, name, doc = None):
module = new.module(name, doc)
module.__file__ = self.file
@@ -303,14 +307,26 @@ class Field(Metadata):
else:
return Method.DEFAULTS[self.type]
+WIDTHS = {
+ "octet": 1,
+ "short": 2,
+ "long": 4
+ }
+
+def width(st, default=None):
+ if st in (None, "none", ""):
+ return default
+ else:
+ return WIDTHS[st]
+
def get_result(nd, spec):
result = nd["result"]
if not result: return None
name = result["@domain"]
if name != None: return spec.domains.byname[name]
st_nd = result["struct"]
- st = Struct(st_nd["@size"], int(result.parent.parent["@index"])*256 +
- int(st_nd["@type"]), st_nd["@pack"])
+ st = Struct(width(st_nd["@size"]), int(result.parent.parent["@index"])*256 +
+ int(st_nd["@type"]), width(st_nd["@pack"], 2))
spec.structs[st.type] = st
load_fields(st_nd, st.fields, spec.domains.byname)
return st
@@ -366,7 +382,7 @@ def load(specfile, *errata):
code = st_nd["@type"]
if code not in (None, "", "none"):
code = int(code)
- type = Struct(st_nd["@size"], code, st_nd["@pack"])
+ type = Struct(width(st_nd["@size"]), code, width(st_nd["@pack"], 2))
if type.type != None:
spec.structs[type.type] = type
structs.append((type, st_nd))