فهرست منبع

added -exclude.

Nicolas Cannasse 19 سال پیش
والد
کامیت
65cb9d8750
2فایلهای تغییر یافته به همراه24 افزوده شده و 5 حذف شده
  1. 13 1
      main.ml
  2. 11 4
      typer.ml

+ 13 - 1
main.ml

@@ -121,6 +121,7 @@ try
 	let has_hxml = ref false in
 	let next = ref (fun() -> ()) in
 	let hres = Hashtbl.create 0 in
+	let excludes = ref [] in
 	Plugin.defines := base_defines;
 	Plugin.verbose := false;
 	Typer.forbidden_packages := ["js"; "neko"; "flash"];
@@ -202,6 +203,17 @@ try
 			| _ ->
 				raise (Arg.Bad "Invalid Resource format : should be file@name")
 		),"<file@name> : add a named resource file");
+		("-exclude",Arg.String (fun file ->
+			let file = (try Plugin.find_file file with Not_found -> file) in
+			let ch = open_in file in
+			let lines = Std.input_list ch in
+			close_in ch;
+			excludes := (List.map (fun l -> 
+				match List.rev (ExtString.String.nsplit l ".") with
+				| [] -> ([],"")
+				| x :: l -> (List.rev l,x)
+			) lines) @ !excludes;
+		),"<filename> : don't generate code for classes listed in this file");
 		("-v",Arg.Unit (fun () -> Plugin.verbose := true),": turn on verbose mode");
 		("-prompt", Arg.Unit (fun() -> prompt := true),": prompt on error");
 		("--flash-strict", define "flash_strict", ": more type strict flash API");
@@ -267,7 +279,7 @@ try
 		let ctx = Typer.context type_error warn in
 		List.iter (fun cpath -> ignore(Typer.load ctx cpath Ast.null_pos)) (List.rev !classes);
 		Typer.finalize ctx;
-		let types = Typer.types ctx (!main_class) in
+		let types = Typer.types ctx (!main_class) (!excludes) in
 		(match !target with
 		| No -> ()
 		| Swf file ->

+ 11 - 4
typer.ml

@@ -2081,7 +2081,7 @@ type state =
 	| Done
 	| NotYet
 
-let types ctx main =
+let types ctx main excludes =
 	let types = ref [] in
 	let states = Hashtbl.create 0 in
 	let state p = try Hashtbl.find states p with Not_found -> NotYet in
@@ -2095,9 +2095,16 @@ let types ctx main =
 			prerr_endline ("Warning : maybe loop in static generation of " ^ s_type_path p);
 		| NotYet ->
 			Hashtbl.add states p Generating;
-			(match t with
-			| TClassDecl c -> walk_class p c
-			| TEnumDecl _ | TSignatureDecl _ -> ());
+			let t = (match t with
+			| TClassDecl c ->				
+				walk_class p c;
+				if List.mem c.cl_path excludes then
+					TClassDecl { c with cl_extern = true; cl_init = None }
+				else
+					t
+			| TEnumDecl _ | TSignatureDecl _ ->
+				t
+			) in
 			Hashtbl.replace states p Done;
 			types := t :: !types