Ver código fonte

reset defines for core_api context (fixed issue #1017)

Nicolas Cannasse 13 anos atrás
pai
commit
369306d7c2
2 arquivos alterados com 9 adições e 5 exclusões
  1. 5 4
      std/cs/_std/Sys.hx
  2. 4 1
      typeload.ml

+ 5 - 4
std/cs/_std/Sys.hx

@@ -29,10 +29,11 @@ import system.threading.Thread;
 /**
 /**
 	This class gives you access to many base functionalities of system platforms. Looks in [sys] sub packages for more system APIs.
 	This class gives you access to many base functionalities of system platforms. Looks in [sys] sub packages for more system APIs.
 **/
 **/
+@:core_api
 class Sys {
 class Sys {
 	private static var _env:Hash<String>;
 	private static var _env:Hash<String>;
 	private static var _args:Array<String>;
 	private static var _args:Array<String>;
-	
+
 	/**
 	/**
 		Print any value on the standard output.
 		Print any value on the standard output.
 	**/
 	**/
@@ -95,7 +96,7 @@ class Sys {
 				e.set(nenv.Key, nenv.Value);
 				e.set(nenv.Key, nenv.Value);
 			}
 			}
 		}
 		}
-		
+
 		return _env;
 		return _env;
 	}
 	}
 
 
@@ -140,7 +141,7 @@ class Sys {
 	public static function systemName() : String
 	public static function systemName() : String
 	{
 	{
 		//doing a switch with strings since MacOS might not be available
 		//doing a switch with strings since MacOS might not be available
-		switch(Environment.OSVersion.Platform + "") 
+		switch(Environment.OSVersion.Platform + "")
 		{
 		{
 			case "Unix": return "Linux";
 			case "Unix": return "Linux";
 			case "Xbox": return "Xbox";
 			case "Xbox": return "Xbox";
@@ -163,7 +164,7 @@ class Sys {
 		var proc:Process = new Process(cmd, args == null ? [] : args);
 		var proc:Process = new Process(cmd, args == null ? [] : args);
 		var ret = proc.exitCode();
 		var ret = proc.exitCode();
 		proc.close();
 		proc.close();
-		
+
 		return ret;
 		return ret;
 	}
 	}
 
 

+ 4 - 1
typeload.ml

@@ -715,7 +715,10 @@ let init_core_api ctx c =
 	let ctx2 = (match ctx.g.core_api with
 	let ctx2 = (match ctx.g.core_api with
 		| None ->
 		| None ->
 			let com2 = Common.clone ctx.com in
 			let com2 = Common.clone ctx.com in
+			com2.defines <- PMap.empty;
 			Common.define com2 "core_api";
 			Common.define com2 "core_api";
+			Common.define com2 "sys";
+			if ctx.in_macro then Common.define com2 "macro";
 			com2.class_path <- ctx.com.std_path;
 			com2.class_path <- ctx.com.std_path;
 			let ctx2 = ctx.g.do_create com2 in
 			let ctx2 = ctx.g.do_create com2 in
 			ctx.g.core_api <- Some ctx2;
 			ctx.g.core_api <- Some ctx2;
@@ -744,7 +747,7 @@ let init_core_api ctx c =
 				match f2.cf_kind, f.cf_kind with
 				match f2.cf_kind, f.cf_kind with
 				| Method MethInline, Method MethNormal -> () (* allow to add 'inline' *)
 				| Method MethInline, Method MethNormal -> () (* allow to add 'inline' *)
 				| Method MethNormal, Method MethInline -> () (* allow to disable 'inline' *)
 				| Method MethNormal, Method MethInline -> () (* allow to disable 'inline' *)
-				| _ ->
+				| _ ->					
 					error ("Field " ^ f.cf_name ^ " has different property access than core type") p;
 					error ("Field " ^ f.cf_name ^ " has different property access than core type") p;
 			end;
 			end;
 			(match follow f.cf_type, follow f2.cf_type with
 			(match follow f.cf_type, follow f2.cf_type with