Resolve attempt to JIT for PJSIP (PJSUA2) C# on Xamarin.iOS AOT only

CL
Casey Lowe
Thu, May 18, 2017 8:01 PM

Hi,

I am using PJSIP (PJSUA2) in Xamarin.Android and Xamarin.iOS projects using
C#.  PJSIP (PJSUA2) utilizes SWIG to generate the Java and C# bindings for
the C++ library.

I am new to SWIG and am having difficulties understanding how to best use
SWIG on C++ Callbacks to generate appropriate SWIG C# for iOS which is AOT
only. ( SWIG C# for java/Android works great since JIT is allowed )

I have resolved the pjsua2PINVOKE.SWIGExceptionHelper class:

  1. Added the [ObjCRuntime.MonoNativeFunctionWrapper] descriptor to the
    delegates
  2. Added the [ObjCRuntime.MonoPInvokeCallback(typeof(ExceptionDelegate))]
    descriptor to the static functions.

Now I have encountered issues with callbacks using directors, how do I
resolve?

Call.cs SWIG generated code:

[ObjCRuntime.MonoNativeFunctionWrapper]
public delegate void SwigDelegateCall_0(global::System.IntPtr prm);

[ObjCRuntime.MonoPInvokeCallback(typeof(SwigDelegateCall_0))]
private void SwigDirectoronCallState(global::System.IntPtr prm) {
onCallState(new OnCallStateParam(prm, false));
}

  1. Added [ObjCRuntime.MonoNativeFunctionWrapper] descriptor to the delgates
  2. Attempted to add
    [ObjCRuntime.MonoPInvokeCallback(typeof(SwigDelegateCall_0))] descriptor,
    but it won't work on non-static functions.

What is the best practice for having SWIG generate the appropriate
Callbacks?

Thank you for your time and assistance,
~Casey

Hi, I am using PJSIP (PJSUA2) in Xamarin.Android and Xamarin.iOS projects using C#. PJSIP (PJSUA2) utilizes SWIG to generate the Java and C# bindings for the C++ library. I am new to SWIG and am having difficulties understanding how to best use SWIG on C++ Callbacks to generate appropriate SWIG C# for iOS which is AOT only. ( SWIG C# for java/Android works great since JIT is allowed ) I have resolved the pjsua2PINVOKE.SWIGExceptionHelper class: 1. Added the [ObjCRuntime.MonoNativeFunctionWrapper] descriptor to the delegates 2. Added the [ObjCRuntime.MonoPInvokeCallback(typeof(ExceptionDelegate))] descriptor to the static functions. Now I have encountered issues with callbacks using directors, how do I resolve? Call.cs SWIG generated code: [ObjCRuntime.MonoNativeFunctionWrapper] public delegate void SwigDelegateCall_0(global::System.IntPtr prm); [ObjCRuntime.MonoPInvokeCallback(typeof(SwigDelegateCall_0))] private void SwigDirectoronCallState(global::System.IntPtr prm) { onCallState(new OnCallStateParam(prm, false)); } 1. Added [ObjCRuntime.MonoNativeFunctionWrapper] descriptor to the delgates 2. Attempted to add [ObjCRuntime.MonoPInvokeCallback(typeof(SwigDelegateCall_0))] descriptor, but it won't work on non-static functions. What is the best practice for having SWIG generate the appropriate Callbacks? Thank you for your time and assistance, ~Casey