# Will convert C arguments to C++ and call the C++ implementation function.
fc = new CFunction(indirection_sig)
if not mproperty.is_init then
# Will convert C arguments to C++ and call the C++ implementation function.
fc = new CFunction(indirection_sig)
if not mproperty.is_init then
var type_name = to_cpp_call_context.name_mtype(mclass_type)
if mclass_type.mclass.ftype isa ForeignCppType then
fc.exprs.add("{type_name} {param_name}_for_cpp = static_cast<{type_name}>({param_name});\n")
var type_name = to_cpp_call_context.name_mtype(mclass_type)
if mclass_type.mclass.ftype isa ForeignCppType then
fc.exprs.add("{type_name} {param_name}_for_cpp = static_cast<{type_name}>({param_name});\n")
end
fc.exprs.add(mproperty.build_ccall(mclass_type, mmodule, "___cpp_impl", long_signature, cpp_call_context, "_for_cpp"))
fc.exprs.add("\n")
end
fc.exprs.add(mproperty.build_ccall(mclass_type, mmodule, "___cpp_impl", long_signature, cpp_call_context, "_for_cpp"))
fc.exprs.add("\n")
# Custom C++, the body of the Nit C++ method is copied to its own C++ function
var cpp_signature = mproperty.build_csignature(mclass_type, mmodule, "___cpp_impl", long_signature, cpp_call_context)
# Custom C++, the body of the Nit C++ method is copied to its own C++ function
var cpp_signature = mproperty.build_csignature(mclass_type, mmodule, "___cpp_impl", long_signature, cpp_call_context)
cpp_file.header_custom.add("\}\n")
var file = cpp_file.write_to_files(mmodule, compdir)
cpp_file.header_custom.add("\}\n")
var file = cpp_file.write_to_files(mmodule, compdir)
end
redef fun compile_callback(callback, mmodule, mainmodule, ecc)
end
redef fun compile_callback(callback, mmodule, mainmodule, ecc)
write_header_to_file(mmodule, "{compdir}/{h_file}", new Array[String], guard)
write_header_to_file(mmodule, "{compdir}/{h_file}", new Array[String], guard)
- redef fun makefile_rule_name do return "{filename.basename("")}.o"
- redef fun makefile_rule_content do return "$(CXX) $(CFLAGS) {mmodule.cpp_compiler_options} -c {filename.basename("")} -o {filename.basename("")}.o"
+ redef fun makefile_rule_name do return "{filename}.o"
+ redef fun makefile_rule_content do return "$(CXX) $(CFLAGS) {mmodule.cppflags[""].join(" ")} -c {filename} -o {filename}.o"
end
redef class NitniCallback
fun compile_callback_to_cpp(mmodule: MModule, mainmodule: MModule) do end
end
end
redef class NitniCallback
fun compile_callback_to_cpp(mmodule: MModule, mainmodule: MModule) do end
end
-redef class Object
- private fun cpp_call_context: CppCallContext do return once new CppCallContext
- private fun to_cpp_call_context: ToCppCallContext do return once new ToCppCallContext
- private fun from_cpp_call_context: FromCppCallContext do return once new FromCppCallContext
-end
+private fun cpp_call_context: CppCallContext do return once new CppCallContext
+private fun to_cpp_call_context: ToCppCallContext do return once new ToCppCallContext
+private fun from_cpp_call_context: FromCppCallContext do return once new FromCppCallContext
redef class MExplicitCall
redef fun compile_callback_to_cpp(mmodule, mainmodule)
redef class MExplicitCall
redef fun compile_callback_to_cpp(mmodule, mainmodule)