我有C的密码:
typedef result function_callback(struct mes_t* message, void* data)
struct mes_t
{
uint32_t field1
uint32_t field2
void* data
};
function_one(&function_callback, data)
The application calls the user-defined (in the function_one) callback function function_callback. In the callback function passed field1, field2 and data parameters (data is usually equal to 0)
此示例中 python 的代码是否正确?
class mes_t(ctypes.Structure):
pass
mes_t._fields_ = [
( field1 , ctypes.c_uint32),
( dfield2 , ctypes.c_uint32),
( data , ctypes.POINTER(ctypes.c_void_p))]
data_t=ctypes.c_void_p
data=data_t()
CALLBACK=CFUNCTYPE(ccg_msg, data_t)
cb_func=CALLBACK()
result = function_one(ctypes.byref(cb_func), ctypes.byref(data))