X-Git-Url: http://nitlanguage.org diff --git a/src/nitni/nitni_utilities.nit b/src/nitni/nitni_utilities.nit index 8cacbf1..910877b 100644 --- a/src/nitni/nitni_utilities.nit +++ b/src/nitni/nitni_utilities.nit @@ -19,7 +19,7 @@ import nitni_base redef class MMethod # Build a C function name for the FFI implementation (uses friendly naming). - # * On a specific static receiver mype `recv_mtype` + # * On a specific static receiver type `recv_mtype` # * In referene to the module `from_module` (used for type resolving and as a possible prefix) # * Has a possible `suffix` to the method name (may be "__super", "__impl", null, etc.) # * With a specified length indicating whether it uses the sort name or the long name with @@ -39,13 +39,13 @@ redef class MMethod if suffix != null then cname = "{cname}{suffix}" - if length.long then cname = "{from_mmodule.name}___{cname}" + if length.long then cname = "{from_mmodule.c_name}___{cname}" return cname end # Build a C function signature for the FFI implementation (uses friendly naming). - # * On a specific static receiver mype `recv_mtype` + # * On a specific static receiver type `recv_mtype` # * In referene to the module `from_module` (used for type resolving and as a possible prefix) # * Has a possible `suffix` to the method name (may be "__super", "__impl", null, etc.) # * With a specified length indicating whether it uses the sort name or the long name with @@ -72,7 +72,7 @@ redef class MMethod var cparams = new List[String] if not self.is_init then - cparams.add( "{call_context.name_mtype(recv_mtype)} recv" ) + 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) @@ -83,7 +83,7 @@ redef class MMethod end # Build a C function call for the FFI implementation (uses friendly naming). - # * On a specific static receiver mype `recv_mtype` + # * On a specific static receiver type `recv_mtype` # * In referene to the module `from_module` (used for type resolving and as a possible prefix) # * Has a possible `suffix` to the method name (may be "__super", "__impl", null, etc.) # * With a specified length indicating whether it uses the sort name or the long name with @@ -103,17 +103,19 @@ redef class MMethod return_mtype = recv_mtype else if signature.return_mtype != null then return_mtype = signature.return_mtype + return_mtype = return_mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true) end var cname = build_cname(recv_mtype, from_mmodule, suffix, length) var cparams = new List[String] if not self.is_init then - cparams.add(call_context.cast_to(recv_mtype, "recv{param_suffix}")) + cparams.add(call_context.cast_to(recv_mtype, "self{param_suffix}")) end for p in signature.mparameters do - cparams.add(call_context.cast_to(p.mtype, "{p.name}{param_suffix}")) + var param_mtype = p.mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true) + cparams.add(call_context.cast_to(param_mtype, "{p.name}{param_suffix}")) end var joined_cparams = cparams.join(", ") @@ -138,15 +140,14 @@ class CallContext fun cast_to(mtype: MType, name: String): String do return name end -redef class Object - # Call context to use - protected fun internal_call_context: CallContext do return new CallContext - protected fun long_signature: SignatureLength do return once new SignatureLength(true) - protected fun short_signature: SignatureLength do return once new SignatureLength(false) -end +# Call context to use +fun internal_call_context: CallContext do return new CallContext +fun long_signature: SignatureLength do return once new SignatureLength(true) +fun short_signature: SignatureLength do return once new SignatureLength(false) # Length of the signature of a C function (long version hase the module name as prefix) class SignatureLength private var long: Bool - private init(long: Bool) do self.long = long + + # TODO: private init because singleton class. end