v.add("return (val*){res};")
v.add("\}")
return
- else if mtype.mclass.kind == extern_kind and mtype.mclass.name != "NativeString" then
+ else if mtype.mclass.kind == extern_kind and mtype.mclass.name != "CString" then
var pointer_type = mainmodule.pointer_type
self.provide_declaration("NEW_{c_name}", "{mtype.ctype} NEW_{c_name}();")
redef fun unbox_extern(value, mtype)
do
if mtype isa MClassType and mtype.mclass.kind == extern_kind and
- mtype.mclass.name != "NativeString" then
+ mtype.mclass.name != "CString" then
var pointer_type = compiler.mainmodule.pointer_type
var res = self.new_var_extern(mtype)
self.add "{res} = ((struct instance_{pointer_type.c_name}*){value})->value; /* unboxing {value.mtype} */"
redef fun box_extern(value, mtype)
do
if mtype isa MClassType and mtype.mclass.kind == extern_kind and
- mtype.mclass.name != "NativeString" then
+ mtype.mclass.name != "CString" then
var valtype = compiler.mainmodule.pointer_type
var res = self.new_var(mtype)
if compiler.runtime_type_analysis != null and not compiler.runtime_type_analysis.live_types.has(value.mtype.as(MClassType)) then
var res = self.new_var(mtype)
res.is_exact = true
self.require_declaration("NEW_{nclass.c_name}")
+ length = autobox(length, compiler.mainmodule.int_type)
self.add("{res} = NEW_{nclass.c_name}({length});")
return res
end
-
- redef fun calloc_array(ret_type, arguments)
- do
- var ret = ret_type.as(MClassType)
- self.require_declaration("NEW_{ret.mclass.c_name}")
- self.ret(self.new_expr("NEW_{ret.mclass.c_name}({arguments[1]})", ret_type))
- end
end