A kind of resolve was missing so the name of the generated C function was different between the call and its implementation.
Fix #1899.
Pull-Request: #1902
Reviewed-by: Jean Privat <jean@pryen.org>
for param in msignature.mparameters do params.add param.mtype.cname_blind
# Declare the implementation function as extern
- var impl_cname = mproperty.build_cname(mclassdef.mclass.mclass_type,
+ var impl_cname = mproperty.build_cname(mclassdef.bound_mtype,
mclassdef.mmodule, "___impl", long_signature)
ecc.body_decl.add "extern {c_return_type} {impl_cname}({params.join(", ")});\n"
# Representation of this type in pure C on the FFI extern side
# Object -> Object
# Pointer -> void*
- fun cname: String is abstract
+ fun cname: String do return cname_normal_class
# Representation of this type in C for the internal of the system
# Hides extern types.
# type Object is_primitive? false
# type Pointer is_primitive? true
fun is_cprimitive: Bool do return false
+
+ # Name of this type in C for normal classes (not extern and not primitive)
+ protected fun cname_normal_class: String do return mangled_cname
end
redef class MClassType
return super
end
- # Name of this type in C for normal classes (not extern and not primitive)
- protected fun cname_normal_class: String do return mangled_cname
-
redef fun mangled_cname do return mclass.name
redef fun is_cprimitive do return mclass.kind == extern_kind or
end
redef class MNullableType
- redef fun cname do return mangled_cname
redef fun mangled_cname do return "nullable_{mtype.mangled_cname}"
end
end
redef class MGenericType
- redef fun cname do return mangled_cname
redef fun mangled_cname
do
var base = super
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+redef class Array[E]
+ fun bar `{ puts("bar"); `}
+end
+
+redef class NativeArray[E]
+ fun foo `{ puts("foo"); `}
+end
+
+var a = new Array[String]
+a.bar
+
+var aa = new NativeArray[Int](1)
+aa.foo