FromNativeContext resultContext = new MethodResultContext(runtime, closureMethod);
SignatureType signatureType = DefaultSignatureType.create(closureMethod.getReturnType(), resultContext);
jnr.ffi.mapper.FromNativeType fromNativeType = typeMapper.getFromNativeType(signatureType, resultContext);
FromNativeConverter fromNativeConverter = fromNativeType != null ? fromNativeType.getFromNativeConverter() : null;
ResultType resultType = getResultType(runtime, closureMethod.getReturnType(),
resultContext.getAnnotations(), fromNativeConverter, resultContext);
ParameterType[] parameterTypes = getParameterTypes(runtime, typeMapper, closureMethod);
// Allow individual methods to set the calling convention to stdcall
CallingConvention callingConvention = closureClass.isAnnotationPresent(StdCall.class)
? CallingConvention.STDCALL : CallingConvention.DEFAULT;
CallContext callContext = getCallContext(resultType, parameterTypes, callingConvention, true);
LocalVariableAllocator localVariableAllocator = new LocalVariableAllocator(parameterTypes);
Class[] javaParameterTypes = new Class[parameterTypes.length];
for (int i = 0; i < parameterTypes.length; i++) {
javaParameterTypes[i] = parameterTypes[i].getDeclaredType();
}
SkinnyMethodAdapter mv = new SkinnyMethodAdapter(builder.getClassVisitor(), ACC_PUBLIC | ACC_FINAL,
closureMethod.getName(),
sig(resultType.getDeclaredType(), javaParameterTypes), null, null);
mv.start();
// Retrieve the static 'ffi' Invoker instance
mv.getstatic(p(AbstractClosurePointer.class), "ffi", ci(com.kenai.jffi.Invoker.class));
// retrieve the call context and function address