ฉันมีรหัส C โดยที่วิธีการกำหนดดังนี้:
//! Definition of the verify appliance notification function.
typedef void (STDCALL *pfNotifyVerifyAppliance)(mdp_sdk_handle_t handle, const char* hostname, bool is_verified, const availableappliance_t* appliance, void* context);
//! Function to specify a function that should be called when an available appliance is verified. Appliance is only valid when is_verified is true.
EXTERN void STDCALL mdp_sdk_notify_verify_appliance(mdp_sdk_handle_t handle, pfNotifyVerifyAppliance NotifyVerifyAppliance);
NotifyVerifyAppliance
อยู่ในตัวอย่างโค้ด C ซึ่งมีฟังก์ชันเรียกกลับดังนี้:
static void STDCALL NotifyVerifyAppliance(mdp_sdk_handle_t handle, const char* hostname, bool is_verified, const availableappliance_t* appliance, void* context)
{
...
}
ฉันได้สร้าง Java wrapper สำหรับฟังก์ชันแล้วและคลาสการโทรกลับที่สร้างขึ้นมีลักษณะดังนี้:
public class SWIGTYPE_p_f_p_struct_mdp_sdk_handle_dummystruct_p_q_const__char_bool_p_q_const__availableappliance_t_p_void__void {
private transient long swigCPtr;
protected SWIGTYPE_p_f_p_struct_mdp_sdk_handle_dummystruct_p_q_const__char_bool_p_q_const__availableappliance_t_p_void__void(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
swigCPtr = cPtr;
}
protected SWIGTYPE_p_f_p_struct_mdp_sdk_handle_dummystruct_p_q_const__char_bool_p_q_const__availableappliance_t_p_void__void() {
swigCPtr = 0;
}
protected static long getCPtr(SWIGTYPE_p_f_p_struct_mdp_sdk_handle_dummystruct_p_q_const__char_bool_p_q_const__availableappliance_t_p_void__void obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}
คลาสการโทรกลับของฉันถูกสร้างอินสแตนซ์ แต่ฉันไม่รู้ที่จะเข้าถึงข้อมูล ไม่มีข้อโต้แย้งที่วิธีการโทรกลับ C ดั้งเดิมได้รับ ฉันควรปรับปรุงการสร้าง Swig เพื่อให้ได้สิ่งนี้อย่างไร