Explorar o código

added haxe.xml.Proxy

Nicolas Cannasse %!s(int64=18) %!d(string=hai) anos
pai
achega
7c56f0a81a
Modificáronse 10 ficheiros con 133 adicións e 10 borrados
  1. 6 4
      Makefile
  2. 1 1
      Makefile.win
  3. 2 0
      doc/CHANGES.txt
  4. 1 1
      genxml.ml
  5. 31 4
      std/flash9/Event.hx
  6. 5 0
      std/haxe/ImportAll.hx
  7. 24 0
      std/haxe/xml/Check.hx
  8. 24 0
      std/haxe/xml/Fast.hx
  9. 1 0
      type.ml
  10. 38 0
      typer.ml

+ 6 - 4
Makefile

@@ -2,13 +2,15 @@ EXTLIB=../../mtcvs/extlib-dev
 SWFLIB=../../mtcvs/swflib
 EXTC=../../mtcvs/extc
 NEKO=../neko
-FILES=$(EXTLIB)/*.ml* -n $(EXTLIB)/install.ml $(SWFLIB)/*.ml* $(EXTC)/extc.ml* $(NEKO)/libs/include/ocaml/*.ml* *.ml*
+XML=../../mtcvs/xml-light
+LIBS_SRC=$(EXTLIB)/*.ml* -n $(EXTLIB)/install.ml $(SWFLIB)/*.ml* $(EXTC)/extc.ml* $(XML)/*.ml* -n $(XML)/test.ml
+SRC=$(NEKO)/libs/include/ocaml/*.ml* *.ml*
 LIBS=unix.cmxa
 FLAGS=-o haxe -pp camlp4o -lp "-cclib extc_stubs.o -cclib -lz"
 
 all:
 	ocamlc -c $(EXTC)/extc_stubs.c
-	ocamake $(FLAGS) $(FILES) $(LIBS)
+	ocamake $(FLAGS) $(LIBS_SRC) $(SRC) $(LIBS)
 
 universal: clean_haxe all
 	mv haxe haxe.intel
@@ -20,8 +22,8 @@ clean_haxe:
 
 tools:
 	(cd std/tools/haxedoc && haxe haxedoc.hxml && cp haxedoc ../../..)
-	(cd std/tools/haxelib && haxe haxelib.hxml && cp haxelib ../../..) 
+	(cd std/tools/haxelib && haxe haxelib.hxml && cp haxelib ../../..)
 
 clean:
-	ocamake $(FLAGS) -clean $(FILES) $(LIBS)
+	ocamake $(FLAGS) -clean $(LIBS_SRC) $(SRC) $(LIBS)
 	rm -rf extc_stubs.o

+ 1 - 1
Makefile.win

@@ -3,7 +3,7 @@
 .SUFFIXES : .ml .mli .cmo .cmi .cmx .mll .mly
 
 CFLAGS= -I ../neko/libs/include/ocaml
-LIBS=extLib.cmxa extc.cmxa swfLib.cmxa unix.cmxa
+LIBS=extLib.cmxa extc.cmxa swfLib.cmxa unix.cmxa xml-light.cmxa
 LFLAGS= -o haxe.exe -I ../neko/libs/include/ocaml
 OUTPUT=sed 's/File "\([^"]\+\)", line \([0-9]\+\), \(.*\)/\1(\2): \3/' tmp.cmi
 

+ 2 - 0
doc/CHANGES.txt

@@ -9,6 +9,8 @@
 	added flash.Event for Flash9
 	added --no-output
 	fixed neko.net.Socket peer and host methods
+	added neko.io.Process and neko.vm.Ui
+	added haxe.xml.Proxy
 
 2007-05-18: 1.13
 	fixed bug with local variable masking package in catch type

+ 1 - 1
genxml.ml

@@ -73,7 +73,7 @@ let gen_constr e =
 let gen_field att f =
 	let add_get_set acc name att =
 		match acc with
-		| NormalAccess -> att
+		| NormalAccess | ResolveAccess -> att
 		| NoAccess -> (name, "null") :: att
 		| MethodAccess m -> (name, if m = name ^ "_" ^ f.cf_name then "dynamic" else m) :: att
 		| F9MethodAccess -> att

+ 31 - 4
std/flash9/Event.hx

@@ -1,10 +1,35 @@
+/*
+ * Copyright (c) 2005-2007, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
 package flash;
 
 import flash.events.MouseEvent;
+import flash.events.EventDispatcher;
 
 typedef MEvent = Event<MouseEvent,flash.display.InteractiveObject>;
 
-class Event<T,Target : flash.events.EventDispatcher> {
+class Event<T,Target : EventDispatcher> {
 
 	var name : String;
 	var onAdd : Target -> Void;
@@ -58,6 +83,7 @@ class Event<T,Target : flash.events.EventDispatcher> {
 	public static var move = new MEvent(MouseEvent.MOUSE_MOVE,mouseEnable);
 
 	public static function drag( t : flash.display.InteractiveObject, f : Void -> Void ) {
+		#if flash9
 		var stage = flash.Lib.current.stage;
 		var mouseX = stage.mouseX;
 		var mouseY = stage.mouseY;
@@ -71,10 +97,11 @@ class Event<T,Target : flash.events.EventDispatcher> {
 		var stop;
 		stop = function(e) {
 			t.removeEventListener(flash.events.Event.ENTER_FRAME,fevent);
-			stage.removeEventListener(flash.events.MouseEvent.MOUSE_UP,stop);
+			stage.removeEventListener(MouseEvent.MOUSE_UP,stop);
 		};
 		t.addEventListener(flash.events.Event.ENTER_FRAME,fevent);
-		stage.addEventListener(flash.events.MouseEvent.MOUSE_UP,stop);
+		stage.addEventListener(MouseEvent.MOUSE_UP,stop);
+		#end
 	}
 
-}
+}

+ 5 - 0
std/haxe/ImportAll.hx

@@ -80,6 +80,7 @@ import haxe.rtti.XmlParser;
 
 import haxe.xml.Check;
 import haxe.xml.Fast;
+import haxe.xml.Proxy;
 
 import haxe.unit.TestCase;
 import haxe.unit.TestResult;
@@ -90,6 +91,7 @@ import haxe.unit.TestStatus;
 
 // generated by haxe
 import flash.Boot;
+import flash.Event;
 import flash.Lib;
 import flash.FlashXml__;
 import flash.accessibility.Accessibility;
@@ -298,6 +300,7 @@ import flash.system.Security;
 
 // generated by haxe
 import flash9.Boot;
+import flash9.Event;
 import flash9.Lib;
 import flash9.FlashXml__;
 import flash9.accessibility.Accessibility;
@@ -518,6 +521,7 @@ import neko.io.Logger;
 import neko.io.Multiple;
 import neko.io.Output;
 import neko.io.Path;
+import neko.io.Process;
 import neko.io.StringInput;
 import neko.io.StringOutput;
 
@@ -548,6 +552,7 @@ import neko.vm.Loader;
 import neko.vm.Module;
 import neko.vm.Thread;
 import neko.vm.Lock;
+import neko.vm.Ui;
 
 #end
 

+ 24 - 0
std/haxe/xml/Check.hx

@@ -1,3 +1,27 @@
+/*
+ * Copyright (c) 2005-2007, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
 package haxe.xml;
 
 enum Filter {

+ 24 - 0
std/haxe/xml/Fast.hx

@@ -1,3 +1,27 @@
+/*
+ * Copyright (c) 2005-2007, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
 package haxe.xml;
 
 private class NodeAccess implements Dynamic<Fast> {

+ 1 - 0
type.ml

@@ -23,6 +23,7 @@ type module_path = string list * string
 type field_access =
 	| NormalAccess
 	| NoAccess
+	| ResolveAccess
 	| MethodAccess of string
 	| F9MethodAccess
 

+ 38 - 0
typer.ml

@@ -81,6 +81,7 @@ let access_str = function
 	| NoAccess -> "null"
 	| MethodAccess m -> m
 	| F9MethodAccess -> "f9dynamic"
+	| ResolveAccess -> "resolve"
 
 let unify_error_msg ctx = function
 	| Cannot_unify (t1,t2) ->
@@ -256,6 +257,9 @@ let field_access ctx get f t e p =
 			AccExpr (mk (TCall (mk (TField (e,m)) (mk_mono()) p,[])) t p)
 		else
 			AccSet (e,m,t,f.cf_name)
+	| ResolveAccess ->
+		let fstring = mk (TConst (TString f.cf_name)) (mk_mono()) p in
+		AccExpr (mk (TCall (mk (TField (e,"__resolve")) (mk_mono()) p,[fstring])) t p)
 
 let acc_get g p =
 	match g with
@@ -560,6 +564,36 @@ let extend_proxy ctx c t p =
 		| _ -> assert false
 	)
 
+let extend_xml_proxy ctx c t file p =
+	let t = load_type ctx p t in
+	let file = (try Plugin.find_file file with Not_found -> file) in
+	try
+		let rec loop = function
+			| Xml.Element (_,attrs,childs) ->
+				(try
+					let id = List.assoc "id" attrs in
+					if PMap.mem id c.cl_fields then error ("Duplicate id " ^ id) p;
+					let f = {
+						cf_name = id;
+						cf_type = t;
+						cf_public = true;
+						cf_doc = None;
+						cf_get = ResolveAccess;
+						cf_set = NoAccess;
+						cf_params = [];
+						cf_expr = None;
+					} in
+					c.cl_fields <- PMap.add id f c.cl_fields;
+				with
+					Not_found -> ());
+				List.iter loop childs;
+			| Xml.PCData _ -> ()
+		in
+		loop (Xml.parse_file file)
+	with
+		| Xml.Error e -> error ("XML error " ^ Xml.error e) p
+		| Xml.File_not_found f -> error ("XML File not found : " ^ f) p
+
 let set_heritance ctx c herits p =
 	let rec loop = function
 		| HPrivate | HExtern | HInterface ->
@@ -574,6 +608,10 @@ let set_heritance ctx c herits p =
 			extend_proxy ctx c t p
 		| HExtends t ->
 			if c.cl_super <> None then error "Cannot extend several classes" p;
+			(match t with
+			| { tpackage = ["haxe";"xml"]; tname = "Proxy"; tparams = [TPConst(String file);TPType t] } -> 
+				extend_xml_proxy ctx c t file p
+			| _ -> ());
 			let t = load_normal_type ctx t p false in
 			(match follow t with
 			| TInst (cl,params) ->