X-Git-Url: http://nitlanguage.org diff --git a/src/nitni/nitni_base.nit b/src/nitni/nitni_base.nit index 4f31aaf..7cf6bbc 100644 --- a/src/nitni/nitni_base.nit +++ b/src/nitni/nitni_base.nit @@ -22,7 +22,6 @@ module nitni_base import parser import modelbuilder # builder only for externcalls -private import compiler::abstract_compiler redef class MMethod # Short name of this method in C (without the class name) @@ -32,6 +31,8 @@ redef class MMethod if nit_name == "+" then return "_plus" if nit_name == "-" then return "_minus" if nit_name == "unary -" then return "_unary_minus" + if nit_name == "unary +" then return "_unary_plus" + if nit_name == "unary ~" then return "_unary_tilde" if nit_name == "*" then return "_star" if nit_name == "/" then return "_slash" if nit_name == "%" then return "_percent" @@ -39,25 +40,23 @@ redef class MMethod if nit_name == "[]=" then return "_index_assign" if nit_name == "==" then return "_equal" if nit_name == "<" then return "_less" - if nit_name == ">" then return "_geater" + if nit_name == ">" then return "_greater" if nit_name == "<=" then return "_less_or_equal" if nit_name == ">=" then return "_greater_or_equal" if nit_name == "!=" then return "_not_equal" if nit_name == "<<" then return "_left" if nit_name == ">>" then return "_right" if nit_name == "<=>" then return "_starship" + if nit_name == "|" then return "_pipe" + if nit_name == "^" then return "_caret" + if nit_name == "&" then return "_amp" + if nit_name == "~" then return "_tilde" if nit_name.chars.last == '=' then return "{nit_name.substring(0, nit_name.length-1)}__assign" return nit_name end end -redef class MModule - # Mangled name of this module in C - fun cname: String do return c_name # FIXME this is a hack to keep the internal FFI - # API independent of the compilers while still using the `MModule::c_name` service. -end - redef class MMethodDef # Name of the function to callback this method from C, # also used in other functions names used for this method. @@ -93,13 +92,14 @@ redef class MClassType if name == "Char" then return "char" if name == "Float" then return "double" if name == "Int" then return "long" + if name == "Byte" then return "unsigned char" if name == "NativeString" then return "char*" if mclass.kind == extern_kind then var ctype = mclass.ctype assert ctype != null return ctype end - return mangled_cname + return cname_normal_class end redef fun cname_blind do @@ -108,11 +108,15 @@ redef class MClassType if name == "Char" then return "char" if name == "Float" then return "double" if name == "Int" then return "long" + if name == "Byte" then return "unsigned char" if name == "NativeString" then return "char*" if mclass.kind == extern_kind then return "void*" return "struct nitni_instance *" 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