Merge: names and concerns in model
[nit.git] / src / compiler_ffi.nit
index 2b162b5..2ebf76d 100644 (file)
@@ -53,7 +53,7 @@ redef class MModule
                end
        end
 
-       fun ensure_compile_nitni_base(v: AbstractCompilerVisitor)
+       private fun ensure_compile_nitni_base(v: AbstractCompilerVisitor)
        do
                if nitni_ccu != null then return
 
@@ -69,10 +69,10 @@ redef class MModule
                return res
        end
 
-       var compiled_callbacks: Array[NitniCallback] = new Array[NitniCallback]
+       private var compiled_callbacks: Array[NitniCallback] = new Array[NitniCallback]
 
        # Returns true if callbacks has yet to be generated and register it as being generated
-       fun check_callback_compilation(cb: NitniCallback): Bool
+       private fun check_callback_compilation(cb: NitniCallback): Bool
        do
                var compiled = compiled_callbacks.has(cb)
                if not compiled then compiled_callbacks.add(cb)
@@ -80,8 +80,8 @@ redef class MModule
        end
 end
 
-redef class AExternPropdef
-       fun compile_ffi_support_to_c(v: AbstractCompilerVisitor)
+redef class AMethPropdef
+       private fun compile_ffi_support_to_c(v: AbstractCompilerVisitor)
        do
                var mmodule = mpropdef.mclassdef.mmodule
                var mainmodule = v.compiler.mainmodule
@@ -97,6 +97,8 @@ redef class AExternPropdef
                amodule.ensure_compile_ffi_wrapper
                compile_ffi_method(mmodule)
 
+               assert self isa AExternPropdef
+
                # nitni - Compile missing callbacks
                mmodule.ensure_compile_nitni_base(v)
                var ccu = mmodule.nitni_ccu.as(not null)
@@ -126,10 +128,8 @@ redef class AExternPropdef
                # manage nitni callback set
                mmodule.foreign_callbacks.join(foreign_callbacks)
        end
-end
 
-redef class AExternMethPropdef
-       redef fun compile_to_c(v, mpropdef, arguments)
+       redef fun compile_externmeth_to_c(v, mpropdef, arguments)
        do
                var mmodule = mpropdef.mclassdef.mmodule
 
@@ -191,10 +191,8 @@ redef class AExternMethPropdef
 
                compile_ffi_support_to_c(v)
        end
-end
 
-redef class AExternInitPropdef
-       redef fun compile_to_c(v, mpropdef, arguments)
+       redef fun compile_externinit_to_c(v, mpropdef, arguments)
        do
                var mmodule = mpropdef.mclassdef.mmodule
 
@@ -289,7 +287,7 @@ redef class AbstractCompilerVisitor
 end
 
 redef class MType
-       fun compile_extern_type(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
+       private fun compile_extern_type(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
        do
                assert not is_cprimitive
 
@@ -300,7 +298,7 @@ redef class MType
                ccu.header_c_types.add("#endif\n")
        end
 
-       fun compile_extern_helper_functions(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
+       private fun compile_extern_helper_functions(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
        do
                # actually, we do not need to do anything when using the bohem garbage collector
 
@@ -351,7 +349,7 @@ redef class MNullableType
 end
 
 redef class MExplicitCall
-       fun compile_extern_callback(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
+       private fun compile_extern_callback(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
        do
                var mproperty = mproperty
                assert mproperty isa MMethod
@@ -412,7 +410,7 @@ redef class MExplicitCall
 end
 
 redef class MExplicitSuper
-       fun compile_extern_callback(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
+       private fun compile_extern_callback(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
        do
                var mproperty = from.mproperty
                assert mproperty isa MMethod
@@ -462,7 +460,7 @@ redef class MExplicitSuper
 end
 
 redef class MExplicitCast
-       fun compile_extern_callbacks(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
+       private fun compile_extern_callbacks(v: AbstractCompilerVisitor, ccu: CCompilationUnit)
        do
                var from = from
                var to = to