예제 #1
0
def write_number(d, output, context):
    if isinstance(d, Decimal): d = float(d)
    if isinstance(d, (int, long)) and d >= -268435456 and d <= 268435455: # check valid range for 29bits
        amf0.write_byte(INTEGER, output) # Type Code
        _write_integer(d, output, context)
    else:
        amf0.write_byte(NUMBER, output) # Type Code
        amf0.write_double(d, output)
예제 #2
0
def write_date(d, output, context):
    amf.utils.logger().debug("amf3.write_date(%s)", repr(d))
    amf0.write_byte(DATE, output) # Type Code
    key = context.get_object_reference_index(d)
    if key == -1:
        ms = amf.utils.get_timestamp_from_date(d)
        _write_integer(0x01, output, context) # inline ref
        amf0.write_double(ms, output)
        context.add_object_reference(d)
    else:
        key <<= 1
        _write_integer(key, output, context)