do
# Collect all bas box class
# FIXME: this is not completely fine with a separate compilation scheme
- for classname in ["Int", "Bool", "Byte", "Char", "Float", "NativeString",
+ for classname in ["Int", "Bool", "Byte", "Char", "Float", "CString",
"Pointer", "Int8", "Int16", "UInt16", "Int32", "UInt32"] do
var classes = self.mainmodule.model.get_mclasses_by_name(classname)
if classes == null then continue
#if mclass.mclass_type.ctype == "val*" or mclass.mclass_type.is_subtype(self.mainmodule, mclass.mclass_type pointer_type) then
if mclass.mclass_type.ctype_extern == "val*" then
return 0
- else if mclass.kind == extern_kind and mclass.name != "NativeString" then
+ else if mclass.kind == extern_kind and mclass.name != "CString" then
return self.box_kinds[self.mainmodule.pointer_type.mclass]
else
return self.box_kinds[mclass]
v.add("return (val*){res};")
v.add("\}")
return
- else if mtype.mclass.kind == extern_kind and mtype.mclass.name != "NativeString" then
- # Is an extern class (other than Pointer and NativeString)
- # Pointer is caught in a previous `if`, and NativeString is internal
+ else if mtype.mclass.kind == extern_kind and mtype.mclass.name != "CString" then
+ # Is an extern class (other than Pointer and CString)
+ # Pointer is caught in a previous `if`, and CString is internal
var pointer_type = mainmodule.pointer_type
return res
end
var valtype = value.mtype.as(MClassType)
- if mtype isa MClassType and mtype.mclass.kind == extern_kind and mtype.mclass.name != "NativeString" then
+ if mtype isa MClassType and mtype.mclass.kind == extern_kind and mtype.mclass.name != "CString" then
valtype = compiler.mainmodule.pointer_type
end
var res = self.new_var(mtype)
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)
compiler.undead_types.add(mtype)
if not value.mtype.is_c_primitive then
self.add "{res} = {value} == NULL ? \"null\" : {type_info(value)}->name;"
else if value.mtype isa MClassType and value.mtype.as(MClassType).mclass.kind == extern_kind and
- value.mtype.as(MClassType).name != "NativeString" then
+ value.mtype.as(MClassType).name != "CString" then
self.add "{res} = \"{value.mtype.as(MClassType).mclass}\";"
else
self.require_declaration("type_{value.mtype.c_name}")