swigjava将函数作为回调传递

swigjava将函数作为回调传递,java,callback,handler,swig,Java,Callback,Handler,Swig,我有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); //!

我有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);
static void STDCALL NotifyVerifyAppliance(mdp_sdk_handle_t handle, const char* hostname, bool is_verified, const availableappliance_t* appliance, void* context)
{
...
}
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;
  }
}
NotifyVerifyAppliance在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);
static void STDCALL NotifyVerifyAppliance(mdp_sdk_handle_t handle, const char* hostname, bool is_verified, const availableappliance_t* appliance, void* context)
{
...
}
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;
  }
}
我已经为函数生成了Java包装器,生成的回调类如下所示:

//! 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);
static void STDCALL NotifyVerifyAppliance(mdp_sdk_handle_t handle, const char* hostname, bool is_verified, const availableappliance_t* appliance, void* context)
{
...
}
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方法不获取任何参数。我应该如何改进Sigg一代来获得这个?

看看这个:因为它与你的问题有关。是的,但是导演功能只适用于C++在Swig。我需要这是与C代码的工作。有什么想法吗?