return "nullable_{local_class.name.to_s}"
else if pi == null then
return local_class.name.to_s
- else if local_class.global.is_extern then
- return local_class.name.to_s
else
return pi.cname
end
end
+ fun mangled_name: String
+ do
+ var pi = local_class.primitive_info
+ if is_nullable then
+ return "nullable_{local_class.name.to_s}"
+ else
+ return local_class.name.to_s
+ end
+ end
+
# Return the expression to convert this type from its native version.
fun from_native( name : String ) : String
do
not is_nullable then
return boxtype( name )
else
- var getter = "{name}.v"
+ var getter = "{name}->ref.val"
return boxtype( getter )
end
not is_nullable then
return "{native_name} = {unboxtype( nit_name )}"
else
- return "{native_name}.v = {unboxtype( nit_name )}"
+ return "{native_name}->ref.val = {unboxtype( nit_name )}"
end
end
not is_nullable then # int, float, point/void* ...
return "{nit_name} = {boxtype(native_name)}"
else
- return "{nit_name} = {"{native_name}.v"}"
+ return "{nit_name} = {native_name}->ref.val"
end
end
+
+ fun uses_nitni_ref : Bool do return local_class.primitive_info == null or is_nullable
+
+ fun friendly_null_getter : String
+ do
+ return "null_{as_notnull.mangled_name}"
+ end
+
+ fun local_friendly_null_getter_from( m : MMModule ) : String
+ do
+ return "{m.to_s}_{friendly_null_getter}"
+ end
end
redef class MMMethod
do
var params = new List[String]
- if not is_init then
+ if not global.is_init then
params.add( "{local_class.get_type.friendly_extern_name} recv" )
end
# return type
if signature.return_type != null then
s.append( "{signature.return_type.friendly_extern_name} " )
- else if is_init then
+ else if global.is_init then
s.append( "{local_class.get_type.friendly_extern_name} " )
else
s.append( "void " )
private fun cparams : List[ String ]
do
var params = new List[String]
-
- if not is_init then
- params.add( "val_t recv" )
- end
-
- for p in signature.params do
- params.add( "val_t {p.name}" )
- end
-
+ if not global.is_init then params.add( "val_t recv" )
+ for p in signature.params do params.add( "val_t {p.name}" )
return params
end
var s = new Buffer
# return type
- if signature.return_type != null or is_init then
+ if signature.return_type != null or global.is_init then
s.append( "val_t " )
else
s.append( "void " )
end
# function name
- if is_init then
+ if global.is_init then
s.append( "NEW_{local_class}_{cname}" )
else
s.append( "{friendly_extern_name(local_class)}___out" )
if is_about_nullable_only then
if is_not_null_to_nullable then # to null
# nullable_Object Object_as_nullable( Object o )
- return "{from.friendly_extern_name}_as_nullable"
+ return "{from.mangled_name}_as_nullable"
else if is_nullable_to_not_null then # from null
# Object Object_as_not_null( nullable_Object o )
- return "{to.friendly_extern_name}_as_not_null"
+ return "{to.mangled_name}_as_not_null"
else
abort
end
else # inter types
# String Object_as_String( Object o )
- return "{from.friendly_extern_name}_as_{to.friendly_extern_name}"
+ return "{from.mangled_name}_as_{to.mangled_name}"
end
end
else if is_nullable_to_not_null then # from null
# Object_is_null( nullable_Object o )
# is opposite from others
- return "{to.local_class}_is_null"
+ return "{to.mangled_name}_is_null"
else
abort
end
else # inter types
# Object_is_a_String( Object o )
- return "{from.friendly_extern_name}_is_a_{to.friendly_extern_name}"
+ return "{from.mangled_name}_is_a_{to.mangled_name}"
end
end