def test_functionptr_intptr_return(self):
ffi = FFI(backend=self.Backend())
def cb():
return ffi.NULL
p = ffi.callback("int*(*)()", cb)
res = p()
assert res == ffi.NULL
int_ptr = ffi.new('int*')
def cb():
return int_ptr
p = ffi.callback("int*(*)()", cb)
res = p()
assert repr(res).startswith("<cdata 'int *' 0x")
assert res == int_ptr
int_array_ptr = ffi.new('int[1]')
def cb():
return int_array_ptr
p = ffi.callback("int*(*)()", cb)
res = p()
assert repr(res).startswith("<cdata 'int *' 0x")
assert res == int_array_ptr
评论列表
文章目录