Пример #1
0
def field_spec_putter(chan, val, nnn):
    # fields are '_name', '_type', '_quantifier', '_fieldNbr', '_default'

    # write the field header
    write_raw_varint(chan, field_hdr(nnn, LEN_PLUS_TYPE))
#   print "FIELD SPEC: AFTER WRITING HEADER pos = %u" %  pos

    # write the byte count
    count = field_spec_len(val, nnn)
    write_raw_varint(chan, count)
#   print "FIELD SPEC: AFTER WRITING BYTE COUNT %u pos = %u" % (count, pos)

    # write the field's name
    L_STRING_PUT(chan, val.name, 0)             # field 0

    # write the type
    VENUM_PUT(chan, val.field_type_ndx, 1)

    # write the quantifier
    VENUM_PUT(chan, val.quantifier, 2)

    # write the field number
    VUINT32_PUT(chan, val.field_nbr, 3)

    # write the default, should there be one
    if val.default is not None:
        # XXX STUB XXX
        pass
Пример #2
0
def enum_pair_spec_putter(chan, val, nnn):
    # write the field header
    write_raw_varint(chan, field_hdr(nnn, LEN_PLUS_TYPE))

    # write the byte count
    count = enum_pair_spec_len(val, nnn)
    write_raw_varint(chan, count)
#   print "AFTER WRITING BYTE COUNT %u pos = %u" % (count, pos)

    # write field 0, the symbol
    L_STRING_PUT(chan, val.symbol, 0)
#   print "AFTER WRITING SYMBOL %s pos = %u" % ( val.symbol, pos)

    # write field 1, the value
    VUINT32_PUT(chan, val.value, 1)
Пример #3
0
def enum_spec_putter(chan, val, nnn):
    # write the field header
    write_raw_varint(chan, field_hdr(nnn, LEN_PLUS_TYPE))
#   print "AFTER WRITING HEADER pos = %u" %  pos

    # write the byte count
    count = enum_spec_len(val, nnn)
    write_raw_varint(chan, count)
#   print "AFTER WRITING BYTE COUNT %u pos = %u" % (count, pos)

    # write the enum's name
    L_STRING_PUT(chan, val.name, 0)             # field 0

    # write the pairs
    for pair in val:
        enum_pair_spec_putter(chan, pair, 1)   # field 1 instances
Пример #4
0
def msg_spec_putter(chan, val, nnn):
    # fields are  protocol, name, fields, enum=None

    # write the field header
    write_raw_varint(chan, field_hdr(nnn, LEN_PLUS_TYPE))
    print("MSG SPEC: AFTER WRITING HEADER pos = %u" % chan.position)

    # write the byte count
    count = msg_spec_len(val, nnn)
    write_raw_varint(chan, count)
    print("MSG SPEC: AFTER WRITING BYTE COUNT %u pos = %u" % (
        count, chan.position))

    # write the spec's name
    L_STRING_PUT(chan, val.name, 0)                 # field 0

    # write the fields
    for field in val:
        field_spec_putter(chan, field, 1)          # field 1 instances

    # write the enum, should there be one
    if val.enums is not None and val.enums != []:
        for enum in val.enums:
            enum_spec_putter(chan, enum, 2)         # yup, field 2