Browse Source

haXe/PHP integration

Nicolas Cannasse 17 năm trước cách đây
mục cha
commit
7cd3f8763d
10 tập tin đã thay đổi với 297 bổ sung236 xóa
  1. 4 2
      Makefile.win
  2. 7 3
      doc/CHANGES.txt
  3. 28 21
      haxe.vcproj
  4. 8 14
      std/DateTools.hx
  5. 7 0
      std/all.hxml
  6. 34 6
      std/haxe/ImportAll.hx
  7. 5 4
      std/haxe/remoting/SyncSocketConnection.hx
  8. 184 184
      std/php/Curl.hx
  9. 17 2
      tests/unit/unit.hxml
  10. 3 0
      tests/unit/unit.hxp

+ 4 - 2
Makefile.win

@@ -10,7 +10,7 @@ OUTPUT=sed 's/File "\([^"]\+\)", line \([0-9]\+\), \(.*\)/\1(\2): \3/' tmp.cmi
 FILES = ast.cmx lexer.cmx type.cmx common.cmx parser.cmx typecore.cmx \
 	genxml.cmx typeload.cmx codegen.cmx typer.cmx \
 	../neko/libs/include/ocaml/nast.cmx ../neko/libs/include/ocaml/binast.cmx ../neko/libs/include/ocaml/nxml.cmx \
-	genneko.cmx genas3.cmx genjs.cmx genswf8.cmx genswf9.cmx genswf.cmx \
+	genneko.cmx genas3.cmx genjs.cmx genswf8.cmx genswf9.cmx genswf.cmx genphp.cmx \
 	main.cmx
 	
 all: haxe.exe
@@ -34,6 +34,8 @@ genas3.cmx: type.cmx codegen.cmx ../../mtcvs/swflib/swfParser.cmx ../../mtcvs/sw
 
 genjs.cmx: type.cmx codegen.cmx lexer.cmx common.cmx ast.cmx
 
+genphp.cmx: type.cmx codegen.cmx lexer.cmx common.cmx ast.cmx
+
 genswf.cmx: type.cmx codegen.cmx ../../mtcvs/swflib/swfZip.cmx ../../mtcvs/swflib/swfParser.cmx ../../mtcvs/swflib/swf.cmx genswf9.cmx genswf8.cmx common.cmx ast.cmx ../../mtcvs/swflib/as3hlparse.cmx ../../mtcvs/swflib/as3hl.cmi ../../mtcvs/swflib/as3.cmi
 
 genswf8.cmx: type.cmx codegen.cmx ../../mtcvs/swflib/swf.cmx lexer.cmx common.cmx ast.cmx ../../mtcvs/swflib/actionScript.cmx
@@ -48,7 +50,7 @@ lexer.cmx: ast.cmx
 
 main.cmx: typer.cmx typeload.cmx typecore.cmx type.cmx parser.cmx lexer.cmx genxml.cmx genswf.cmx genneko.cmx genjs.cmx genas3.cmx common.cmx ast.cmx
 
-parser.cmx: lexer.cmx common.cmx ast.cmx
+parser.cmx: parser.ml lexer.cmx common.cmx ast.cmx
 	(ocamlopt -pp camlp4o $(CFLAGS) -c parser.ml 2>tmp.cmi && $(OUTPUT)) || ($(OUTPUT) && exit 1)
 
 type.cmx: ast.cmx

+ 7 - 3
doc/CHANGES.txt

@@ -6,6 +6,13 @@ TODO optimizer : move multiple statics access into local variables
 TODO inlining : allow inlined getter/setter
 TODO inlining : substitute class+function type parameters in order to have fully typed expressions
 
+2008-??-??: 2.0
+	fixed current package bug in inherited constructor type
+	delayed type-parameter constraints check (allow mutual rec extends for SPOD)
+	improved unclosed macro error reporting
+	haxe/PHP integeration
+	renamed NekoSocketConnection to SyncSocketConnection (php support)
+
 2008-07-17: 2.0-RC1
 	genneko : remove big array error (fixed in neko 1.7.1)
 	fixed neko.net.ThreadRemotingServer.onXML
@@ -52,9 +59,6 @@ TODO inlining : substitute class+function type parameters in order to have fully
 	added Type.createEnum
 	check that local variables get correctly initialized before usage
 	haxe.Stack support for flash9
-	fixed current package bug in inherited constructor type
-	delayed type-parameter constraints check (allow mutual rec extends for SPOD)
-	improved unclosed macro error reporting
 
 2008-04-05: 1.19
 	fixed flash9 Array.toString

+ 28 - 21
haxe.vcproj

@@ -44,9 +44,6 @@
 			<File
 				RelativePath="..\neko\libs\include\ocaml\binast.ml">
 			</File>
-			<File
-				RelativePath=".\genneko.ml">
-			</File>
 			<File
 				RelativePath="..\neko\libs\include\ocaml\nast.ml">
 			</File>
@@ -64,6 +61,34 @@
 				RelativePath="..\..\mtcvs\swflib\as3hl.mli">
 			</File>
 		</Filter>
+		<Filter
+			Name="gen"
+			Filter="">
+			<File
+				RelativePath=".\genas3.ml">
+			</File>
+			<File
+				RelativePath=".\genjs.ml">
+			</File>
+			<File
+				RelativePath=".\genneko.ml">
+			</File>
+			<File
+				RelativePath=".\genphp.ml">
+			</File>
+			<File
+				RelativePath=".\genswf.ml">
+			</File>
+			<File
+				RelativePath=".\genswf8.ml">
+			</File>
+			<File
+				RelativePath=".\genswf9.ml">
+			</File>
+			<File
+				RelativePath=".\genxml.ml">
+			</File>
+		</Filter>
 		<File
 			RelativePath=".\ast.ml">
 		</File>
@@ -73,24 +98,6 @@
 		<File
 			RelativePath=".\common.ml">
 		</File>
-		<File
-			RelativePath=".\genas3.ml">
-		</File>
-		<File
-			RelativePath=".\genjs.ml">
-		</File>
-		<File
-			RelativePath=".\genswf.ml">
-		</File>
-		<File
-			RelativePath=".\genswf8.ml">
-		</File>
-		<File
-			RelativePath=".\genswf9.ml">
-		</File>
-		<File
-			RelativePath=".\genxml.ml">
-		</File>
 		<File
 			RelativePath=".\lexer.mll">
 		</File>

+ 8 - 14
std/DateTools.hx

@@ -34,7 +34,7 @@ class DateTools {
 	#if neko
 	static var date_format = neko.Lib.load("std","date_format",2);
 	#else
-	private static function __jsflash_format_get( d : Date, e : String ) : String {
+	private static function __format_get( d : Date, e : String ) : String {
 		return switch( e ){
 			case "%":
 				"%";
@@ -43,7 +43,7 @@ class DateTools {
 			case "d":
 				untyped StringTools.lpad(Std.string(d.getDate()),"0",2);
 			case "D":
-				__jsflash_format(d,"%m/%d/%y");
+				__format(d,"%m/%d/%y");
 			case "e":
 				untyped Std.string(d.getDate());
 			case "H","k":
@@ -60,9 +60,9 @@ class DateTools {
 			case "p":
 				untyped if( d.getHours() > 11 ) "PM"; else "AM";
 			case "r":
-				__jsflash_format(d,"%I:%M:%S %p");
+				__format(d,"%I:%M:%S %p");
 			case "R":
-				__jsflash_format(d,"%H:%M");
+				__format(d,"%H:%M");
 			case "s":
 				Std.string(Std.int(d.getTime()/1000));
 			case "S":
@@ -70,7 +70,7 @@ class DateTools {
 			case "t":
 				"\t";
 			case "T":
-				__jsflash_format(d,"%H:%M:%S");
+				__format(d,"%H:%M:%S");
 			case "u":
 				untyped{
 					var t = d.getDay();
@@ -87,7 +87,7 @@ class DateTools {
 		}
 	}
 
-	private static function __jsflash_format( d : Date, f : String ) : String {
+	private static function __format( d : Date, f : String ) : String {
 		var r = new StringBuf();
 		var p = 0;
 		while( true ){
@@ -96,7 +96,7 @@ class DateTools {
 				break;
 
 			r.addSub(f,p,np-p);
-			r.add( __jsflash_format_get(d, f.substr(np+1,1) ) );
+			r.add( __format_get(d, f.substr(np+1,1) ) );
 
 			p = np+2;
 		}
@@ -115,14 +115,8 @@ class DateTools {
 	public static function format( d : Date, f : String ) : String {
 		#if neko
 			untyped return new String(date_format(d.__t, f.__s));
-		#elseif js
-			return __jsflash_format(d, f );
-		#elseif flash
-			return __jsflash_format(d, f );
-		#elseif php
-			return __jsflash_format(d, f );
 		#else
-			return null;
+			return __format(d,f);
 		#end
 	}
 

+ 7 - 0
std/all.hxml

@@ -39,5 +39,12 @@ haxe.ImportAll
 
 --next
 
+-php all_php
+--no-output
+-xml php.xml
+haxe.ImportAll
+
+--next
+
 -xml cross.xml
 haxe.ImportAll

+ 34 - 6
std/haxe/ImportAll.hx

@@ -46,9 +46,7 @@ import Type;
 import Xml;
 
 import haxe.FastList;
-#if !neko
 import haxe.Firebug;
-#end
 import haxe.Http;
 import haxe.ImportAll;
 import haxe.Log;
@@ -87,8 +85,8 @@ import haxe.remoting.AsyncProxy;
 import haxe.remoting.LocalConnection;
 import haxe.remoting.DelayedConnection;
 import haxe.remoting.FlashJsConnection;
-#if neko
-import haxe.remoting.NekoSocketConnection;
+#if (neko || php)
+import haxe.remoting.SyncSocketConnection;
 #else
 import haxe.remoting.SocketConnection;
 #end
@@ -444,7 +442,7 @@ import js.XMLSocket;
 import tools.haxedoc.Main;
 import tools.haxelib.Main;
 import tools.haxelib.Site;
-//import tools.hxinst.Main -> needs xCross
+import tools.hxinst.Main;
 
 #end
 
@@ -530,4 +528,34 @@ import flash.ui.ContextMenuClipboardItems;
 import flash.ui.MouseCursor;
 
 import flash.system.JPEGLoaderContext;
-#end
+#end
+
+#if php
+
+import php.Curl;
+import php.Exception;
+import php.FileSystem;
+import php.HException;
+import php.IniHash;
+import php.Lib;
+import php.Session;
+import php.Sys;
+import php.Utf8;
+import php.Web;
+
+import php.db.Connection;
+import php.db.DBase;
+import php.db.Manager;
+import php.db.Mysql;
+import php.db.Object;
+import php.db.ResultSet;
+import php.db.Sqlite;
+
+import php.io.File;
+import php.io.FileInput;
+import php.io.FileOutput;
+import php.io.Path;
+import php.io.Process;
+
+#end
+

+ 5 - 4
std/haxe/remoting/NekoSocketConnection.hx → std/haxe/remoting/SyncSocketConnection.hx

@@ -23,8 +23,9 @@
  * DAMAGE.
  */
 package haxe.remoting;
+import haxe.remoting.SocketProtocol.Socket;
 
-class NekoSocketConnection implements Connection, implements Dynamic<Connection> {
+class SyncSocketConnection implements Connection, implements Dynamic<Connection> {
 
 	var __path : Array<String>;
 	var __proto : SocketProtocol;
@@ -35,7 +36,7 @@ class NekoSocketConnection implements Connection, implements Dynamic<Connection>
 	}
 
 	public function resolve( name ) : Connection {
-		var s = new NekoSocketConnection(__proto,__path.copy());
+		var s = new SyncSocketConnection(__proto,__path.copy());
 		s.__path.push(name);
 		return s;
 	}
@@ -78,8 +79,8 @@ class NekoSocketConnection implements Connection, implements Dynamic<Connection>
 		try __proto.socket.close() catch( e : Dynamic ) { };
 	}
 
-	public static function create( s : neko.net.Socket, ?ctx : Context ) {
-		return new NekoSocketConnection(new SocketProtocol(s,ctx),[]);
+	public static function create( s : Socket, ?ctx : Context ) {
+		return new SyncSocketConnection(new SocketProtocol(s,ctx),[]);
 	}
 
 }

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 184 - 184
std/php/Curl.hx


+ 17 - 2
tests/unit/unit.hxml

@@ -8,8 +8,7 @@
 
 --next
 # Flash9
--swf unit9.swf
--swf-version 9
+-swf9 unit9.swf
 -main unit.Test
 -debug
 -cp ..
@@ -24,6 +23,14 @@ unit.Test
 -resource res1.txt
 -resource res2.bin
 
+--next
+# Php
+-php out
+-main unit.Test
+-cp ..
+-resource res1.txt
+-resource res2.bin
+
 --next
 # Neko
 -neko unit.n
@@ -38,3 +45,11 @@ unit.Test
 -neko remoting.n
 -main unit.RemotingServer
 -cp ..
+
+--next
+# PHP
+-php php
+-main unit.Test
+-cp ..
+-resource res1.txt
+-resource res2.bin

+ 3 - 0
tests/unit/unit.hxp

@@ -21,6 +21,9 @@
 -resource res2.bin
 </output>
   <output name="RemotingServer" mode="neko" out="remoting.n" class="unit.RemotingServer" lib="" cmd="" main="True" debug="False">-cp ..</output>
+  <output name="PHP" mode="php" out="php" class="unit.Test" lib="" cmd="" main="True" debug="False">-cp ..
+-resource res1.txt
+-resource res2.bin</output>
   <files path="/">
     <file path="MyClass.hx" />
     <file path="MyEnum.hx" />

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác