in qpid/codec.py [0:0]
def __init__(self, stream, spec):
"""
initializing the stream/fields used
"""
self.stream = stream
self.spec = spec
self.nwrote = 0
self.nread = 0
self.incoming_bits = []
self.outgoing_bits = []
# Before 0-91, the AMQP's set of types did not include the boolean type. However,
# the 0-8 and 0-9 Java client uses this type so we encode/decode it too. However, this
# can be turned off by setting the followng environment value.
if "QPID_CODEC_DISABLE_0_91_BOOLEAN" in os.environ:
self.understand_boolean = False
else:
self.understand_boolean = True
log.debug("AMQP 0-91 boolean supported : %r", self.understand_boolean)
self.types = {}
self.codes = {}
self.integertypes = [int, long]
self.encodings = {
float: "double", # python uses 64bit floats, send them as doubles
basestring: "longstr",
None.__class__:"void",
list: "sequence",
tuple: "sequence",
dict: "table"
}
if self.understand_boolean:
self.encodings[bool] = "boolean"
for constant in self.spec.constants:
# This code appears to be dead
if constant.klass == "field-table-type":
type = constant.name.replace("field_table_", "")
self.typecode(constant.id, TYPE_ALIASES.get(type, type))
if not self.types:
# long-string 'S'
self.typecode(ord('S'), "longstr")
# void 'V'
self.typecode(ord('V'), "void")
# long-int 'I' (32bit signed)
self.typecode(ord('I'), "signed_int")
# long-long-int 'l' (64bit signed)
# This is a long standing pre-0-91-spec type used by the Java
# client, 0-9-1 says it should be unsigned or use 'L')
self.typecode(ord('l'), "signed_long")
# double 'd'
self.typecode(ord('d'), "double")
# float 'f'
self.typecode(ord('f'), "float")
if self.understand_boolean:
self.typecode(ord('t'), "boolean")
## The following are supported for decoding only ##
# short-short-uint 'b' (8bit signed)
self.types[ord('b')] = "signed_octet"
# short-int 's' (16bit signed)
# This is a long standing pre-0-91-spec type code used by the Java
# client to send shorts, it should really be a short-string, or for 0-9-1 use 'U'
self.types[ord('s')] = "signed_short"