lib: update the kernel module to the light FFI
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 16 Jun 2015 18:01:34 +0000 (14:01 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 16 Jun 2015 18:03:50 +0000 (14:03 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/standard/kernel.nit
lib/standard/kernel_nit.h [deleted file]

index c596bb3..e05d152 100644 (file)
@@ -17,6 +17,11 @@ module kernel
 
 import end # Mark this module is a top level one. (must be only one)
 
+in "C" `{
+       #include <stdlib.h>
+       #include <errno.h>
+`}
+
 ###############################################################################
 # System Classes                                                              #
 ###############################################################################
@@ -107,7 +112,7 @@ class Sys
        fun run do main
 
        # Number of the last error
-       fun errno: Int is extern "sys_errno"
+       fun errno: Int `{ return errno; `}
 end
 
 # Quit the program with a specific return code
@@ -851,8 +856,8 @@ end
 # Pointer classes are used to manipulate extern C structures.
 extern class Pointer
        # Is the address behind this Object at NULL?
-       fun address_is_null: Bool is extern "address_is_null"
+       fun address_is_null: Bool `{ return self == NULL; `}
 
        # Free the memory pointed by this pointer
-       fun free is extern "free"
+       fun free `{ free(self); `}
 end
diff --git a/lib/standard/kernel_nit.h b/lib/standard/kernel_nit.h
deleted file mode 100644 (file)
index ba97c06..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __KERNEL_NIT_H
-#define __KERNEL_NIT_H
-/* This file is part of NIT ( http://www.nitlanguage.org ).
- *
- * This file is free software, which comes along with NIT.  This software is
- * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A 
- * PARTICULAR PURPOSE.  You can modify it is you want,  provided this header
- * is kept unaltered, and a notification of the changes is added.
- * You  are  allowed  to  redistribute it and sell it, alone or is a part of
- * another product.
- */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#define address_is_null(x) ((x)==NULL)
-#define sys_errno(x) (errno)
-
-#endif