def encode_structs(self, c): # XXX structs = [qpid.Struct(c.spec.domains.byname["delivery_properties"].type), qpid.Struct(c.spec.domains.byname["message_properties"].type)] # XXX props = self.properties.copy() for k in self.properties: for s in structs: if s.exists(k): s.set(k, props.pop(k)) if props: raise TypeError("no such property: %s" % (", ".join(props))) # message properties store the content-length now, and weight is # deprecated if self.size != None: structs[1].content_length = self.size for s in structs: c.encode_long_struct(s)
def decode_struct_body(self, type): reserved = 8 * type.pack - len(type.fields) assert reserved >= 0 s = qpid.Struct(type) for f in type.fields: if f.type == "bit": s.set(f.name, self.decode_bit()) elif self.decode_bit(): s.set(f.name, None) for i in range(reserved): if self.decode_bit(): raise ValueError("expecting reserved flag") for f in type.fields: if f.type != "bit" and s.has(f.name): s.set(f.name, self.decode(f.type)) self.clearbits() return s
def struct(self, name, *args, **kwargs): type = self.domains.byname[name].type return qpid.Struct(type, *args, **kwargs)