class ImageText16(rq.Request): _request = rq.Struct( rq.Opcode(77), rq.LengthOf('string', 1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Int16('x'), rq.Int16('y'), rq.String16('string'), )
class QueryTextExtents(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(48), rq.OddLength('string'), rq.RequestLength(), rq.Fontable('font'), rq.String16('string'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('draw_direction'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Int16('font_ascent'), rq.Int16('font_descent'), rq.Int16('overall_ascent'), rq.Int16('overall_descent'), rq.Int32('overall_width'), rq.Int32('overall_left'), rq.Int32('overall_right'), rq.Pad(4), )
(None, lambda name: rq.LengthOf('s2', 2), None, pack('H', 13)), (None, lambda name: rq.LengthOf('s3', 4), None, pack('L', 34)), ('s1', lambda name: rq.String8(name, pad=1), "testing", partial(packstr, padding=1)), ('s2', lambda name: rq.String8(name, pad=1), "one two three", partial(packstr, padding=3)), ('s3', lambda name: rq.String8(name, pad=1), "supercalifragilisticexpialidocious", partial(packstr, padding=2)), )) _struct_test( 'simple string16', ( (None, lambda name: rq.LengthOf('s1', 1), None, pack('B', 3)), (None, lambda name: rq.LengthOf('s2', 2), None, pack('H', 3)), ('s1', lambda name: rq.String16(name, pad=0), (0, 1, 2), lambda s: struct.pack('>' + 'H' * len(s), *s)), # An 8-bits string is also allowed on input. ('s2', lambda name: rq.String16(name, pad=0), b'\x03\x04\x05', lambda s: struct.pack('>' + 'H' * len(s), *iterbytes(s)), (3, 4, 5)), )) _struct_test('binary', ( (None, lambda name: rq.LengthOf('s1', 1), None, pack('B', 7)), (None, lambda name: rq.LengthOf('s2', 2), None, pack('H', 13)), (None, lambda name: rq.LengthOf('s3', 4), None, pack('L', 34)), ('s1', lambda name: rq.Binary(name, pad=0), b"testing", lambda v: v), ('s2', lambda name: rq.Binary(name, pad=0), b"one two three", lambda v: v), ('s3', lambda name: rq.Binary(name, pad=0), b"supercalifragilisticexpialidocious", lambda v: v), ))