Exemple #1
0
def unpack_fields(space, w_fields):
    fields_w = space.unpackiterable(w_fields)
    fields = []
    for w_tup in fields_w:
        l_w = space.unpackiterable(w_tup)
        len_l = len(l_w)

        if len_l < 2 or len_l > 3:
            raise OperationError(space.w_ValueError, space.wrap(
                "Expected list of 2- or 3-size tuples"))

        name = space.str_w(l_w[0])
        tp = unpack_shape_with_length(space, l_w[1])

        if len_l == 3:
            for c in unroll_letters_for_numbers:
                if c == tp.itemcode:
                    break
            else:
                raise OperationError(space.w_TypeError, space.wrap(
                    "bit fields not allowed for type"))
            bitsize = space.int_w(l_w[2])
            if bitsize <= 0 or bitsize > tp.size * 8:
                raise OperationError(space.w_ValueError, space.wrap(
                    "number of bits invalid for bit field"))
        else:
            bitsize = 0

        fields.append((name, tp, bitsize))
    return fields
Exemple #2
0
def unpack_fields(space, w_fields):
    fields_w = space.unpackiterable(w_fields)
    fields = []
    for w_tup in fields_w:
        l_w = space.unpackiterable(w_tup)
        len_l = len(l_w)

        if len_l < 2 or len_l > 3:
            raise OperationError(
                space.w_ValueError,
                space.wrap("Expected list of 2- or 3-size tuples"))

        name = space.str_w(l_w[0])
        tp = unpack_shape_with_length(space, l_w[1])

        if len_l == 3:
            for c in unroll_letters_for_numbers:
                if c == tp.itemcode:
                    break
            else:
                raise OperationError(
                    space.w_TypeError,
                    space.wrap("bit fields not allowed for type"))
            bitsize = space.int_w(l_w[2])
            if bitsize <= 0 or bitsize > tp.size * 8:
                raise OperationError(
                    space.w_ValueError,
                    space.wrap("number of bits invalid for bit field"))
        else:
            bitsize = 0

        fields.append((name, tp, bitsize))
    return fields
Exemple #3
0
def descr_new_array(space, w_type, w_shape):
    return unpack_shape_with_length(space, w_shape)
Exemple #4
0
def descr_new_array(space, w_type, w_shape):
    return unpack_shape_with_length(space, w_shape)