Example #1
0
def sizeof(ctype, count):
    ctype = to_type(ctype)
    if count:
        size = simple.sizeof_a(ctype, count.value)
    else:
        size = simple.sizeof(ctype)
    return Integer(size)
Example #2
0
def sizeof(ctype, count):
    ctype = to_type(ctype)
    if count:
        size = simple.sizeof_a(ctype, count.value)
    else:
        size = simple.sizeof(ctype)
    return Integer(size)
Example #3
0
def sizeof(argv):
    ctype = argument(argv, 0, Type)
    if len(argv) >= 2:
        n = argument(argv, 1, Integer)
        size = simple.sizeof_a(ctype, n.value)
    else:
        size = simple.sizeof(ctype)
    return Integer(size)
Example #4
0
def automem(argv):
    ctype = argument(argv, 0, Type)
    if len(argv) >= 2:
        n = argument(argv, 1, Integer).value
        size = simple.sizeof_a(ctype, n)
    else:
        n = 1
        size = simple.sizeof(ctype)
    pointer = lltype.malloc(rffi.VOIDP.TO, size, flavor='raw')
    return systemv.AutoMem(systemv.Pointer(ctype), pointer, n)
Example #5
0
def automem(ctype, count, clear):
    ctype = to_type(ctype)
    if count:
        n = count.value
        size = simple.sizeof_a(ctype, n)
    else:
        n = 1
        size = simple.sizeof(ctype)
    pointer = lltype.malloc(rffi.VOIDP.TO, size, flavor='raw')
    if is_true(clear):
        rffi.c_memset(pointer, 0, size)
    return systemv.AutoMem(systemv.Pointer(ctype), pointer, n)
Example #6
0
def automem(ctype, count, clear):
    ctype = to_type(ctype)
    if count:
        n = count.value
        size = simple.sizeof_a(ctype, n)
    else:
        n = 1
        size = simple.sizeof(ctype)
    pointer = lltype.malloc(rffi.VOIDP.TO, size, flavor='raw')
    if is_true(clear):
        rffi.c_memset(pointer, 0, size)
    return systemv.AutoMem(systemv.Pointer(ctype), pointer, n)
Example #7
0
def ref(mem):
    #mem = argument(argv, 0, Object)
    if isinstance(mem, Mem):
        size = simple.sizeof(mem.ctype)
        ctype = mem.ctype
    elif isinstance(mem, Uint8Data):
        size = rffi.sizeof(rffi.VOIDP)
        ctype = c_ubytep
    else:
        raise unwind(LTypeError(u"expected object that can be converted to c-object"))
    pointer = lltype.malloc(rffi.VOIDP.TO, size, flavor='raw')
    result = systemv.AutoMem(systemv.Pointer(ctype), pointer, 1)
    result.setattr(u"to", mem)
    return result
Example #8
0
def ref(mem):
    #mem = argument(argv, 0, Object)
    if isinstance(mem, Mem):
        size = simple.sizeof(mem.ctype)
        ctype = mem.ctype
    elif isinstance(mem, Uint8Array):
        size = rffi.sizeof(rffi.VOIDP)
        ctype = c_ubytep
    else:
        raise unwind(LTypeError(u"expected object that can be converted to c-object"))
    pointer = lltype.malloc(rffi.VOIDP.TO, size, flavor='raw')
    result = systemv.AutoMem(systemv.Pointer(ctype), pointer, 1)
    result.setattr(u"to", mem)
    return result