build_c_signature
but adapted to create the signature expected by JNI for C functionsimplementing Java extern methods.
Is used to generate FFI callbacks to Nit at MExplicitCall::compile_callback_to_java
.
# Similar to `build_c_signature` but adapted to create the signature expected by JNI for C functions
# implementing Java extern methods.
#
# Is used to generate FFI callbacks to Nit at `MExplicitCall::compile_callback_to_java`.
private fun build_c_implementation_signature(recv_mtype: MClassType, from_mmodule: MModule,
suffix: nullable String, length: SignatureLength, call_context: CallContext): String
do
var mmethoddef = lookup_first_definition(from_mmodule, recv_mtype)
var signature = mmethoddef.msignature
assert signature != null
var creturn_type
if self.is_init then
creturn_type = call_context.name_mtype(recv_mtype)
else if signature.return_mtype != null then
var ret_mtype = signature.return_mtype
ret_mtype = ret_mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true)
creturn_type = call_context.name_mtype(ret_mtype)
else
creturn_type = "void"
end
var cname = build_cname(recv_mtype, from_mmodule, suffix, length)
var cparams = new List[String]
cparams.add "JNIEnv *nit_ffi_jni_env"
cparams.add "jclass clazz"
if not self.is_init then
cparams.add "{call_context.name_mtype(recv_mtype)} self"
end
for p in signature.mparameters do
var param_mtype = p.mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true)
cparams.add "{call_context.name_mtype(param_mtype)} {p.name}"
end
return "{creturn_type} {cname}( {cparams.join(", ")} )"
end
src/ffi/java.nit:793,2--831,4