java.interop icon indicating copy to clipboard operation
java.interop copied to clipboard

[jnimarshalmethod-gen] Finish support of delegates for methods with 15+ parameters

Open radekdoulik opened this issue 5 years ago • 0 comments

Commit 857b9a9405c6d69de9a95771044289e8f895427b introduced the support of 15+ parameters methods. The changes in jnimarshalmethod-gen are incomplete though and we end up with a generated code, which uses reflection to get a type, which doesn't exist.

Like the generated code here (from Mono.Android-JniMarshalMethods.dll):

    IL_0122:  ldstr      "Delegate18$1"
    IL_0127:  ldc.i4.1
    IL_0128:  call       [mscorlib]System.Type [mscorlib]System.Type::GetType(string, bool)

It happens, because the Delegate18$1 type is created by SLE on the fly and exists in memory only. jnimarshalmethod-gen doesn't know about that yet.

We need to save the in-memory-only type to our marshaling class and change the name to reflect the parameter types.

Currently the in-memory-only type is placed in Snippets assembly. An example:

assembly qualified name: Delegate18$1, Snippets, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
the delegate:            lambda (__jnienv, __class, srcName, srcTarget, srcLevel, srcX, srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight, srcDepth) => {var __envp;var __jvm; ... }

We should save the type from the example to the assembly containing the marshaling __<$>_jni_marshal_methods class and name it something like __<$>_JniMarshal_PPIIIIIIIIIIIIIII_V or maybe to be more consistent as __<$>_jni_marshal_PPIIIIIIIIIIIIIII_V. And also update the generated code to use it.

radekdoulik avatar Sep 07 '20 19:09 radekdoulik