nitc :: MMethod :: build_jni_format
Example: a Nity signature (Bool, Int, Float, JavaString)
is represented by
the JNI format `(ZIDLjava/lang/string;)V"
# Returns the JNI signature format of this Nit method
#
# Example: a Nity signature `(Bool, Int, Float, JavaString)` is represented by
# the JNI format `(ZIDLjava/lang/string;)V"
private fun build_jni_format(recv_mtype: MClassType, from_mmodule: MModule): String
do
var mmethoddef = lookup_first_definition(from_mmodule, recv_mtype)
var msignature = mmethoddef.msignature
var format = new Array[String]
format.add "("
# receiver
if not self.is_init then format.add recv_mtype.jni_format
# parameters
for p in msignature.mparameters do
var param_mtype = p.mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true)
format.add param_mtype.jni_format
end
format.add ")"
# return
if self.is_init then
format.add recv_mtype.jni_format
else
var return_mtype = msignature.return_mtype
if return_mtype != null then
return_mtype = return_mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true)
format.add return_mtype.jni_format
else format.add "V"
end
return format.join
end
src/ffi/java.nit:757,2--791,4