Nicolas Cannasse 17 gadi atpakaļ
vecāks
revīzija
5736d92308
3 mainītis faili ar 43 papildinājumiem un 0 dzēšanām
  1. 1 0
      doc/CHANGES.txt
  2. 11 0
      std/neko/Lib.hx
  3. 31 0
      std/neko/net/Poll.hx

+ 1 - 0
doc/CHANGES.txt

@@ -12,6 +12,7 @@
 	fixed "".split() in Neko (now returns [""] instead of [])
 	bugfix for swf-lib f9 classes ordering
 	added EReg.customReplace
+	added neko.Lib.lazyLoad and improved neko.net.Poll for Neko 1.6.1
 
 2008-01-13: 1.17
 	fixed Int32.compare, added Int32.read and Int32.write

+ 11 - 0
std/neko/Lib.hx

@@ -33,6 +33,14 @@ class Lib {
 		return untyped __dollar__loader.loadprim((lib+"@"+prim).__s,nargs);
 	}
 
+	public static function loadLazy(lib,prim,nargs) : Dynamic {
+		try {
+			return load(lib,prim,nargs);
+		} catch( e : Dynamic ) {
+			return untyped __dollar__varargs(function(_) { throw e; });
+		}
+	}
+
 	/**
 		Print the specified value on the default output.
 	**/
@@ -165,6 +173,9 @@ class Lib {
 		}
 	}
 
+	/**
+		Returns an object containing all compiled packages and classes.
+	**/
 	public static function getClasses() : Dynamic {
 		return untyped neko.Boot.__classes;
 	}

+ 31 - 0
std/neko/net/Poll.hx

@@ -27,9 +27,38 @@ package neko.net;
 class Poll {
 
 	var d : Void;
+	public var readIndexes : ArrayAccess<Int>;
+	public var writeIndexes : ArrayAccess<Int>;
 
 	public function new( n : Int ) {
 		d = socket_poll_alloc(n);
+		readIndexes = writeIndexes = untyped __dollar__array(-1);
+	}
+
+	public function prepare( read : Array<Socket>, write : Array<Socket> ) {
+		untyped {
+			var r = __dollar__amake(read.length);
+			var w = __dollar__amake(write.length);
+			var i = 0;
+			var len = read.length;
+			while( i < len ) {
+				r[i] = read[i].__s;
+				i += 1;
+			}
+			i = 0;
+			len = write.length;
+			while( i < len ) {
+				w[i] = write[i].__s;
+				i += 1;
+			}
+			var k = socket_poll_prepare(d,r,w);
+			readIndexes = k[0];
+			writeIndexes = k[1];
+		}
+	}
+
+	public function events( ?t : Float ) {
+		socket_poll_events(d,t);
 	}
 
 	public function poll( a : Array<Socket>, ?t : Float ) : Array<Socket> {
@@ -56,5 +85,7 @@ class Poll {
 
 	static var socket_poll_alloc = neko.Lib.load("std","socket_poll_alloc",1);
 	static var socket_poll = neko.Lib.load("std","socket_poll",3);
+	static var socket_poll_prepare = neko.Lib.loadLazy("std","socket_poll_prepare",3);
+	static var socket_poll_events = neko.Lib.loadLazy("std","socket_poll_events",2);
 
 }