浏览代码

haxe 2 fixes

Nicolas Cannasse 17 年之前
父节点
当前提交
08979962cc
共有 7 个文件被更改,包括 50 次插入50 次删除
  1. 10 0
      std/all.hxml
  2. 7 10
      std/haxe/ImportAll.hx
  3. 15 16
      std/mtwin/net/Ftp.hx
  4. 2 2
      std/neko/net/ThreadRemotingServer.hx
  5. 12 12
      std/neko/net/ThreadServer.hx
  6. 1 1
      std/tools/haxelib/Main.hx
  7. 3 9
      std/tools/haxelib/Site.hx

+ 10 - 0
std/all.hxml

@@ -1,11 +1,13 @@
 
 -neko all.n
+--no-output
 -xml neko.xml
 haxe.ImportAll
 
 --next
 
 -swf all.swf
+--no-output
 -xml flash.xml
 -D flash_lite
 haxe.ImportAll
@@ -13,12 +15,14 @@ haxe.ImportAll
 --next
 
 -js all.js
+--no-output
 -xml js.xml
 haxe.ImportAll
 
 --next
 
 -swf all_strict.swf
+--no-output
 -D flash_strict
 -D flash_lite
 -xml flash_strict.xml
@@ -28,5 +32,11 @@ haxe.ImportAll
 --next
 
 -swf9 all9.swf
+--no-output
 -xml flash9.xml
 haxe.ImportAll
+
+--next
+
+-xml cross.xml
+haxe.ImportAll

+ 7 - 10
std/haxe/ImportAll.hx

@@ -84,17 +84,15 @@ import haxe.remoting.AsyncProxy;
 import haxe.remoting.LocalConnection;
 import haxe.remoting.DelayedConnection;
 import haxe.remoting.FlashJsConnection;
-
-/*
 #if neko
 import haxe.remoting.NekoSocketConnection;
-#end
+#else
 import haxe.remoting.SocketConnection;
+#end
 import haxe.remoting.SocketProtocol;
 #if flash
 import haxe.remoting.SocketWrapper;
 #end
-*/
 
 import haxe.rtti.Infos;
 import haxe.rtti.Type;
@@ -400,12 +398,11 @@ import neko.db.Transaction;
 import neko.net.Host;
 import neko.net.Poll;
 import neko.net.ProxyDetect;
-//import neko.net.RemotingServer;
 import neko.net.ServerLoop;
 import neko.net.Socket;
 import neko.net.SocketInput;
 import neko.net.SocketOutput;
-//import neko.net.ThreadRemotingServer;
+import neko.net.ThreadRemotingServer;
 import neko.net.ThreadServer;
 
 import neko.vm.Loader;
@@ -426,7 +423,7 @@ import js.Dom;
 import js.Selection;
 import js.SWFObject;
 import js.XMLHttpRequest;
-//import js.XMLSocket;
+import js.XMLSocket;
 
 #end
 
@@ -434,9 +431,9 @@ import js.XMLHttpRequest;
 
 #if neko
 
-//import tools.haxedoc.Main;
-//import tools.haxelib.Main;
-//import tools.haxelib.Site;
+import tools.haxedoc.Main;
+import tools.haxelib.Main;
+import tools.haxelib.Site;
 //import tools.hxinst.Main -> needs xCross
 
 #end

+ 15 - 16
std/mtwin/net/Ftp.hx

@@ -24,7 +24,6 @@
  */
 package mtwin.net;
 
-import neko.io.Eof;
 import neko.net.Socket;
 import neko.net.Host;
 
@@ -193,7 +192,7 @@ class Ftp {
 	/**
 		Reads input and upload its content to remoteName.
 	**/
-	public function put( input:neko.io.Input, remoteName:String, ?bufSize:Int ){
+	public function put( input:haxe.io.Input, remoteName:String, ?bufSize:Int ){
 		if (bufSize == null)
 			bufSize = 8192;
 		voidCommand("TYPE I");
@@ -206,10 +205,10 @@ class Ftp {
 	/**
 		Downloads remote file and write its content in output using neko.io.Output.writeBytes()
 	**/
-	public function get( output:neko.io.Output, remoteFileName:String, ?bufSize:Int ){
+	public function get( output:haxe.io.Output, remoteFileName:String, ?bufSize:Int ){
 		if (bufSize == null)
 			bufSize = 8192;
-		retrieveBytes("RETR "+remoteFileName, function(s:String, n:Int){ output.writeBytes(s,0,n); }, bufSize);
+		retrieveBytes("RETR "+remoteFileName, function(s:haxe.io.Bytes, n:Int){ output.writeBytes(s,0,n); }, bufSize);
 	}
 
 	/**
@@ -227,7 +226,7 @@ class Ftp {
 
 		Don't forget to close the neko.io.Output when done.
 	**/
-	public function write( remoteName:String ) : neko.io.Output {
+	public function write( remoteName:String ) : haxe.io.Output {
 		var pwd = pwd();
 		var ftp = new Ftp(host.toString(), port);
 		ftp.login(user, pass, acct);
@@ -235,9 +234,9 @@ class Ftp {
 		ftp.voidCommand("TYPE I");
 		var cnx = ftp.transferConnection("STOR "+remoteName);
 		var out = cnx.output;
-		untyped out.oldclose = out.close;
-		out.close = function(){
-			untyped out.oldclose();
+		var old = out.close;
+		(cast out).close = function(){
+			old();
 			ftp.voidResponse();
 			ftp.close();
 		}
@@ -249,7 +248,7 @@ class Ftp {
 
 		Don't forget to close the neko.io.Output when done.
 	**/
-	public function read( remoteFileName:String ) : neko.io.Input {
+	public function read( remoteFileName:String ) : haxe.io.Input {
 		var pwd = pwd();
 		var ftp = new Ftp(host.toString(), port);
 		ftp.login(user, pass, acct);
@@ -257,9 +256,9 @@ class Ftp {
 		ftp.voidCommand("TYPE I");
 		var cnx = ftp.transferConnection("RETR "+remoteFileName);
 		var inp = cnx.input;
-		untyped inp.oldclose = inp.close;
-		inp.close = function(){
-			untyped inp.oldclose();
+		var old = inp.close;
+		(cast inp).close = function(){
+			old();
 			ftp.voidResponse();
 			ftp.close();
 		}
@@ -367,7 +366,7 @@ class Ftp {
 				var line = cnx.input.readLine();
 				lines.push(line);
 			}
-			catch (eof:Eof){
+			catch (eof:haxe.io.Eof){
 				cnx.close();
 				voidResponse();
 				return lines;
@@ -378,14 +377,14 @@ class Ftp {
 		return null;
 	}
 
-	function retrieveBytes( cmd:String, cb:String->Int->Void, ?bufSize:Int, ?rest:String ) {
+	function retrieveBytes( cmd:String, cb:haxe.io.Bytes->Int->Void, ?bufSize:Int, ?rest:String ) {
 		if (bufSize == null)
 			bufSize = 8192;
 		var res = voidCommand("TYPE I");
 		var cnx = transferConnection(cmd, rest);
-		var buf = neko.Lib.makeString(bufSize);
+		var buf = haxe.io.Bytes.alloc(bufSize);
 		while (cnx != null){
-			var rdd = try cnx.input.readBytes(buf, 0, bufSize) catch(eof:Eof) break;
+			var rdd = try cnx.input.readBytes(buf, 0, bufSize) catch(eof:haxe.io.Eof) break;
 			cb(buf, rdd);
 			/*
 			var rdd = 0;

+ 2 - 2
std/neko/net/ThreadRemotingServer.hx

@@ -31,11 +31,11 @@ class ThreadRemotingServer extends ThreadServer<haxe.remoting.SocketConnection,S
 		messageHeaderSize = 2;
 	}
 
-	public function initClientApi( cnx : haxe.remoting.SocketConnection, ctx : haxe.remoting.Context ) {
+	public dynamic function initClientApi( cnx : haxe.remoting.SocketConnection, ctx : haxe.remoting.Context ) {
 		throw "Not implemented";
 	}
 
-	public function onXml( cnx : haxe.remoting.SocketConnection, data : String ) {
+	public dynamic function onXml( cnx : haxe.remoting.SocketConnection, data : String ) {
 		throw "Unhandled XML data '"+data+"'";
 	}
 

+ 12 - 12
std/neko/net/ThreadServer.hx

@@ -159,12 +159,6 @@ class ThreadServer<Client,Message> {
 		worker.sendMessage(f);
 	}
 
-	public function onError( e : Dynamic, stack ) {
-		var estr = try Std.string(e) catch( e2 : Dynamic ) "???" + try "["+Std.string(e2)+"]" catch( e : Dynamic ) "";
-		errorOutput.writeString( estr + "\n" + haxe.Stack.toString(stack) );
-		errorOutput.flush();
-	}
-
 	function logError( e : Dynamic ) {
 		var stack = haxe.Stack.exceptionStack();
 		if( neko.vm.Thread.current() == worker )
@@ -243,27 +237,33 @@ class ThreadServer<Client,Message> {
 
 	// --- CUSTOMIZABLE API ---
 
-	public function clientConnected( s : neko.net.Socket ) : Client {
+	public dynamic function onError( e : Dynamic, stack ) {
+		var estr = try Std.string(e) catch( e2 : Dynamic ) "???" + try "["+Std.string(e2)+"]" catch( e : Dynamic ) "";
+		errorOutput.writeString( estr + "\n" + haxe.Stack.toString(stack) );
+		errorOutput.flush();
+	}
+
+	public dynamic function clientConnected( s : neko.net.Socket ) : Client {
 		return null;
 	}
 
-	public function clientDisconnected( c : Client ) {
+	public dynamic function clientDisconnected( c : Client ) {
 	}
 
-	public function readClientMessage( c : Client, buf : haxe.io.Bytes, pos : Int, len : Int ) : { msg : Message, bytes : Int } {
+	public dynamic function readClientMessage( c : Client, buf : haxe.io.Bytes, pos : Int, len : Int ) : { msg : Message, bytes : Int } {
 		return {
 			msg : null,
 			bytes : len,
 		};
 	}
 
-	public function clientMessage( c : Client, msg : Message ) {
+	public dynamic function clientMessage( c : Client, msg : Message ) {
 	}
 
-	public function update() {
+	public dynamic function update() {
 	}
 
-	public function afterEvent() {
+	public dynamic function afterEvent() {
 	}
 
 }

+ 1 - 1
std/tools/haxelib/Main.hx

@@ -125,7 +125,7 @@ class Main {
 		addCommand("test",test,"install the specified package localy");
 		addCommand("dev",dev,"set the development directory for a given project");
 		siteUrl = "http://"+SERVER.host+":"+SERVER.port+"/"+SERVER.dir;
-		site = new SiteProxy(haxe.remoting.Connection.urlConnect(siteUrl+SERVER.url).api);
+		site = new SiteProxy(haxe.remoting.HttpConnection.urlConnect(siteUrl+SERVER.url).api);
 	}
 
 	function param( name, ?passwd ) {

+ 3 - 9
std/tools/haxelib/Site.hx

@@ -26,15 +26,9 @@ class Site {
 		if( !neko.FileSystem.exists(REP_DIR) )
 			neko.FileSystem.createDirectory(REP_DIR);
 
-		var server = new neko.net.RemotingServer();
-		var log = neko.io.File.append(TMP_DIR+"/log.txt",false);
-		var api = new SiteApi(db);
-		server.setPrivatePrefix("db");
-		server.setLogger(log.writeString);
-		server.addObject("api",api);
-		var flag = server.handleRequest();
-		log.close();
-		if( flag )
+		var ctx = new haxe.remoting.Context();
+		ctx.addObject("api",new SiteApi(db));
+		if( haxe.remoting.HttpConnection.handleRequest(ctx) )
 			return;
 		if( neko.Sys.args()[0] == "setup" ) {
 			setup();