Explorar el Código

Lua : update externs for ffi and jit

Justin Donaldson hace 9 años
padre
commit
3da9c66ae2
Se han modificado 2 ficheros con 35 adiciones y 5 borrados
  1. 34 4
      std/lua/Ffi.hx
  2. 1 1
      std/lua/Jit.hx

+ 34 - 4
std/lua/Ffi.hx

@@ -1,9 +1,39 @@
 package lua;
+
+#if lua_jit
 @:native("_G.ffi")
 extern class Ffi {
-	public static function cdef(arg:String) : Void;
-	public static function load(arg:String, global : Bool) : Dynamic;
-	@:native("new")
-	public static function _new(arg:String) : Dynamic;
 
+	// Declaring and accessing external symbols
+	public static var C : Dynamic;
+	public static function gc(cdata : Dynamic, finalizer : Function) : Void;
+	public static function load : (name : String, ?global : Bool) : Dynamic;
+	public static function metatype<T>(ct : Ctype<T>, metatable : Table<Dynamic>) : Ctype<T>;
+	public static function typeof(str:String) : Ctype<Dynamic>;
+
+	// C Type functionality 
+	public static function alignof(ct : Ctype<T>) : Int;
+	public static function istype(ct : Ctype<T>, obj:Dynamic) : Bool;
+	public static function offsetof(ct : Ctype<T>, field:String) : Int;
+	public static function sizeof(ct : Ctype<T>, ?nelem : Int) : Int;
+
+
+	// Utility functionality
+	public static function errno(?newerr : Int) : Int;
+	public static function fill(dst : Dynamic, len : Int, c:Int) : Void; 
+	public static function string(ptr : Dynamic, ?len : Int) : String;
+
+	@:overload(   function     (dst : Dynamic, str : String)             : Dynamic {})
+	public static function copy(dst : Dynamic, src : Dynamic, len : Int) : String;
+
+	// Target specific functionality
+	public static var os : String;
+	public static var arch : String;
+	public static function abi(param : String) : Bool; 
 }
+
+extern class Ctype<T> {}
+
+// TODO FFI callback type (gc methods)
+#end
+

+ 1 - 1
std/lua/jit/Jit.hx → std/lua/Jit.hx

@@ -1,4 +1,4 @@
-package lua.jit;
+package lua;
 
 import haxe.Constraints.Function;