Example #1
0
 class S(prophy.struct_packed):
     __metaclass__ = prophy.struct_generator
     _descriptor = [("a", prophy.u8), ("c_len", prophy.u8),
                    ("e_len", prophy.u8), ("b", prophy.bytes(size=3)),
                    ("c", prophy.bytes(bound="c_len", size=3)),
                    ("d", prophy.array(prophy.u8, size=3)),
                    ("e", prophy.array(prophy.u8, bound="e_len", size=3))]
Example #2
0
 class Y(prophy.struct):
     __metaclass__ = prophy.struct_generator
     _descriptor = [
         ("x_len", prophy.u8), ("x", prophy.bytes(bound="x_len")),
         ("y_len", prophy.u32), ("y", prophy.bytes(bound="y_len")),
         ("z", prophy.u64)
     ]
Example #3
0
 class S(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("a_len", prophy.u8),
                    ("a", prophy.bytes(bound="a_len")),
                    ("b_len", prophy.u8),
                    ("b", prophy.array(prophy.u8, bound="b_len"))]
Example #4
0
class Object(prophy.struct):
    __metaclass__ = prophy.struct_generator
    _descriptor = [('token', Token), ('num_of_values', prophy.u32),
                   ('values', prophy.array(prophy.i64, bound='num_of_values')),
                   ('num_of_updated_values', prophy.u32),
                   ('updated_values',
                    prophy.bytes(bound='num_of_updated_values'))]
Example #5
0
 class Bytes(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("value_len", prophy.u32),
                    ("value",
                     prophy.array(prophy.bytes(size=5),
                                  bound="value_len"))]
Example #6
0
def test_bytes_bound_attributes():
    B = prophy.bytes(bound = "a_len")

    assert 0 == B._SIZE
    assert True == B._DYNAMIC
    assert False == B._UNLIMITED
    assert '' == B._DEFAULT
    assert False == B._OPTIONAL
    assert 1 == B._ALIGNMENT
    assert "a_len" == B._BOUND
    assert B._PARTIAL_ALIGNMENT is None
Example #7
0
def test_bytes_static_attributes():
    B = prophy.bytes(size = 3)

    assert 3 == B._SIZE
    assert False == B._DYNAMIC
    assert False == B._UNLIMITED
    assert '\x00\x00\x00' == B._DEFAULT
    assert False == B._OPTIONAL
    assert 1 == B._ALIGNMENT
    assert B._BOUND is None
    assert B._PARTIAL_ALIGNMENT is None
Example #8
0
def test_bytes_limited_attributes():
    B = prophy.bytes(bound="a_len", size=3)

    assert B._SIZE == 3
    assert B._DYNAMIC is False
    assert B._UNLIMITED is False
    assert B._DEFAULT == ''
    assert B._OPTIONAL is False
    assert B._ALIGNMENT == 1
    assert B._BOUND == "a_len"
    assert B._PARTIAL_ALIGNMENT is None
Example #9
0
def test_bytes_bound_attributes():
    B = prophy.bytes(bound="a_len")

    assert 0 == B._SIZE
    assert True == B._DYNAMIC
    assert False == B._UNLIMITED
    assert '' == B._DEFAULT
    assert False == B._OPTIONAL
    assert 1 == B._ALIGNMENT
    assert "a_len" == B._BOUND
    assert B._PARTIAL_ALIGNMENT is None
Example #10
0
def test_bytes_greedy_attributes():
    B = prophy.bytes()

    assert B._SIZE == 0
    assert B._DYNAMIC is True
    assert B._UNLIMITED is True
    assert B._DEFAULT == ''
    assert B._OPTIONAL is False
    assert B._ALIGNMENT == 1
    assert B._BOUND is None
    assert B._PARTIAL_ALIGNMENT is None
Example #11
0
def test_bytes_static_attributes():
    B = prophy.bytes(size=3)

    assert 3 == B._SIZE
    assert False == B._DYNAMIC
    assert False == B._UNLIMITED
    assert '\x00\x00\x00' == B._DEFAULT
    assert False == B._OPTIONAL
    assert 1 == B._ALIGNMENT
    assert B._BOUND is None
    assert B._PARTIAL_ALIGNMENT is None
Example #12
0
def test_bytes_static_attributes():
    B = prophy.bytes(size=3)

    assert B._SIZE == 3
    assert B._DYNAMIC is False
    assert B._UNLIMITED is False
    assert B._DEFAULT == b'\x00\x00\x00'
    assert B._OPTIONAL is False
    assert B._ALIGNMENT == 1
    assert B._BOUND is None
    assert B._PARTIAL_ALIGNMENT is None
Example #13
0
 class X(prophy.struct_packed):
     __metaclass__ = prophy.struct_generator
     _descriptor = [("x", prophy.bytes(size = 5)),
                    ("y", prophy.bytes(size = 5))]
Example #14
0
 class FixedBytes(prophy.struct_packed):
     __metaclass__ = prophy.struct_generator
     _descriptor = [("value", prophy.bytes(size = 5))]
Example #15
0
 class LastGreedyBytes(prophy.struct_packed):
     __metaclass__ = prophy.struct_generator
     _descriptor = [("x", prophy.bytes()),
                    ("y", prophy.u32)]
Example #16
0
 class GreedyBytes(prophy.struct_packed):
     __metaclass__ = prophy.struct_generator
     _descriptor = [("value", prophy.bytes())]
Example #17
0
 class LimitedBytes(prophy.struct_packed):
     __metaclass__ = prophy.struct_generator
     _descriptor = [("value_len", prophy.u32),
                    ("value", prophy.bytes(size = 5, bound = "value_len"))]
Example #18
0
 class Bytes(prophy.struct_packed):
     __metaclass__ = prophy.struct_generator
     _descriptor = [("value_len", prophy.u8),
                    ("value", prophy.bytes(bound = "value_len", size = 1, shift = 2))]
Example #19
0
 class S1(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("a", prophy.bytes())]
Example #20
0
def test_optional_bytes():
    with pytest.raises(Exception) as e:
        prophy.optional(prophy.bytes(size=3))
    assert "optional bytes not implemented" == str(e.value)
Example #21
0
 class GreedyBytes(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("value", prophy.bytes())]
Example #22
0
def test_optional_bytes():
    with pytest.raises(Exception) as e:
        prophy.optional(prophy.bytes(size=3))
    assert "optional bytes not implemented" == str(e.value)
Example #23
0
 class X(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("x_len", prophy.u32), ("y_len", prophy.u32),
                    ("x", prophy.bytes(size=5, bound="x_len")),
                    ("y", prophy.bytes(size=5, bound="y_len"))]
Example #24
0
 class Bytes(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("value_len", prophy.u8),
                    ("value", prophy.bytes(size=1, shift=2))]
Example #25
0
 class X(prophy.struct_packed):
     __metaclass__ = prophy.struct_generator
     _descriptor = [("x_len", prophy.u32),
                    ("y_len", prophy.u32),
                    ("x", prophy.bytes(bound = "x_len")),
                    ("y", prophy.bytes(bound = "y_len"))]
Example #26
0
 class ShiftBoundBytes(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("value_len", prophy.u8),
                    ("value", prophy.bytes(bound="value_len", shift=2))]
Example #27
0
 class S1(prophy.struct_packed):
     __metaclass__ = prophy.struct_generator
     _descriptor = [("a", prophy.bytes())]
Example #28
0
 class X(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("x", prophy.u32), ("y", prophy.bytes())]
Example #29
0
 class SBytesSized(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("a", prophy.bytes(size=3))]
Example #30
0
 class Bytes(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("z", prophy.u32), ("y", prophy.u32),
                    ("x",
                     prophy.array(prophy.bytes(bound="y"), bound="z"))]
Example #31
0
 class U1(prophy.with_metaclass(prophy.union_generator, prophy.union)):
     _descriptor = [("a_len", prophy.u8, 0),
                    ("a", prophy.bytes(bound="a_len", size=3), 1)]
Example #32
0
 class FixedBytes(
         prophy.with_metaclass(prophy.struct_generator,
                               prophy.struct_packed)):
     _descriptor = [("value", prophy.bytes(size=5))]
Example #33
0
 class U(prophy.with_metaclass(prophy.union_generator, prophy.union)):
     _descriptor = [("a", prophy.bytes(size=3), 0)]