def fn(): buf = lltype.malloc(INTARRAY, 4, flavor='raw') buf[0] = 1 buf[1] = 2 buf[2] = 3 buf[3] = 4 lst = [] populate_list_from_raw_array(lst, buf, 4) assert lst == [1, 2, 3, 4] lltype.free(buf, flavor='raw')
def fn(): buf = lltype.malloc(INTARRAY, 4, flavor='raw') buf[0] = 1 buf[1] = 2 buf[2] = 3 buf[3] = 4 lst = [] populate_list_from_raw_array(lst, buf, 4) assert lst == [1, 2, 3, 4] lltype.free(buf, flavor='raw')
def test_new_list_from_raw_array(self): INTARRAY = rffi.CArray(lltype.Signed) buf = lltype.malloc(INTARRAY, 4, flavor='raw') buf[0] = 1 buf[1] = 2 buf[2] = 3 buf[3] = 4 lst = [] populate_list_from_raw_array(lst, buf, 4) assert lst == [1, 2, 3, 4] lltype.free(buf, flavor='raw')
def test_new_list_from_raw_array(self): INTARRAY = rffi.CArray(lltype.Signed) buf = lltype.malloc(INTARRAY, 4, flavor='raw') buf[0] = 1 buf[1] = 2 buf[2] = 3 buf[3] = 4 lst = [] populate_list_from_raw_array(lst, buf, 4) assert lst == [1, 2, 3, 4] lltype.free(buf, flavor='raw')
def unpack_list_of_float_items(self, ptr, length): if self.size == rffi.sizeof(rffi.DOUBLE): from rpython.rlib.rrawarray import populate_list_from_raw_array res = [] buf = rffi.cast(rffi.DOUBLEP, ptr) populate_list_from_raw_array(res, buf, length) return res elif self.size == rffi.sizeof(rffi.FLOAT): res = [0.0] * length misc.unpack_cfloat_list_from_raw_array(res, ptr) return res return None
def unpack_list_of_int_items(self, ptr, length): if self.size == rffi.sizeof(rffi.LONG): from rpython.rlib.rrawarray import populate_list_from_raw_array res = [] buf = rffi.cast(rffi.LONGP, ptr) populate_list_from_raw_array(res, buf, length) return res elif self.value_smaller_than_long: res = [0] * length misc.unpack_list_from_raw_array(res, ptr, self.size) return res return None
def unpack_list_of_float_items(self, ptr, length): if self.size == rffi.sizeof(rffi.DOUBLE): from rpython.rlib.rrawarray import populate_list_from_raw_array res = [] buf = rffi.cast(rffi.DOUBLEP, ptr) populate_list_from_raw_array(res, buf, length) return res elif self.size == rffi.sizeof(rffi.FLOAT): res = [0.0] * length misc.unpack_cfloat_list_from_raw_array(res, ptr) return res return None
def unpack_list_of_int_items(self, ptr, length): if self.size == rffi.sizeof(rffi.LONG): from rpython.rlib.rrawarray import populate_list_from_raw_array res = [] buf = rffi.cast(rffi.LONGP, ptr) populate_list_from_raw_array(res, buf, length) return res elif self.value_smaller_than_long: res = [0] * length misc.unpack_list_from_raw_array(res, ptr, self.size) return res return None
def unpack_list_of_float_items(self, w_cdata): if self.size == rffi.sizeof(rffi.DOUBLE): from rpython.rlib.rrawarray import populate_list_from_raw_array res = [] buf = rffi.cast(rffi.DOUBLEP, w_cdata._cdata) length = w_cdata.get_array_length() populate_list_from_raw_array(res, buf, length) return res elif self.size == rffi.sizeof(rffi.FLOAT): res = [0.0] * w_cdata.get_array_length() misc.unpack_cfloat_list_from_raw_array(res, w_cdata._cdata) return res return None
def unpack_list_of_int_items(self, w_cdata): if self.size == rffi.sizeof(rffi.LONG): from rpython.rlib.rrawarray import populate_list_from_raw_array res = [] buf = rffi.cast(rffi.LONGP, w_cdata._cdata) length = w_cdata.get_array_length() populate_list_from_raw_array(res, buf, length) return res elif self.value_smaller_than_long: res = [0] * w_cdata.get_array_length() misc.unpack_list_from_raw_array(res, w_cdata._cdata, self.size) return res return None
def unpack_list_of_float_items(self, w_cdata): if self.size == rffi.sizeof(rffi.DOUBLE): from rpython.rlib.rrawarray import populate_list_from_raw_array res = [] buf = rffi.cast(rffi.DOUBLEP, w_cdata._cdata) length = w_cdata.get_array_length() populate_list_from_raw_array(res, buf, length) return res elif self.size == rffi.sizeof(rffi.FLOAT): res = [0.0] * w_cdata.get_array_length() misc.unpack_cfloat_list_from_raw_array(res, w_cdata._cdata) return res return None
def unpack_list_of_int_items(self, w_cdata): if self.size == rffi.sizeof(rffi.LONG): from rpython.rlib.rrawarray import populate_list_from_raw_array res = [] buf = rffi.cast(rffi.LONGP, w_cdata._cdata) length = w_cdata.get_array_length() populate_list_from_raw_array(res, buf, length) return res elif self.value_fits_long: res = [0] * w_cdata.get_array_length() misc.unpack_list_from_raw_array(res, w_cdata._cdata, self.size) return res return None
def unpack_list_of_int_items(self, w_cdata): if self.size == rffi.sizeof(rffi.LONG): from rpython.rlib.rrawarray import populate_list_from_raw_array res = [] length = w_cdata.get_array_length() with w_cdata as ptr: buf = rffi.cast(rffi.LONGP, ptr) populate_list_from_raw_array(res, buf, length) return res elif self.value_smaller_than_long: res = [0] * w_cdata.get_array_length() with w_cdata as ptr: misc.unpack_list_from_raw_array(res, ptr, self.size) return res return None