Przeglądaj źródła

add asys and target.asys defines

Simon Krajewski 6 lat temu
rodzic
commit
d031d63133
3 zmienionych plików z 19 dodań i 0 usunięć
  1. 6 0
      extra/ImportAll.hx
  2. 5 0
      src-json/define.json
  3. 8 0
      src/context/common.ml

+ 6 - 0
extra/ImportAll.hx

@@ -29,6 +29,10 @@ class ImportAll {
 		       Context.defined("lua") || Context.defined("hl") || Context.defined("eval"); // TODO: have to add cs here, SPOD gets in the way at the moment
 	}
 
+	static function isAsysTarget() {
+		return Context.defined("target.asys");
+	}
+
 	public static function run( ?pack ) {
 		if( pack == null ) {
 			pack = "";
@@ -52,6 +56,8 @@ class ImportAll {
 			return;
 		case "sys":
 			if(!isSysTarget()) return;
+		case "asys":
+			if(!isAsysTarget()) return;
 		case "sys.thread":
 			if ( !Context.defined("target.threaded") ) return;
 		case "java":

+ 5 - 0
src-json/define.json

@@ -21,6 +21,11 @@
 		"define": "as3",
 		"doc": "Defined when outputting flash9 as3 source code."
 	},
+	{
+		"name": "Asys",
+		"define": "asys",
+		"doc": "Defined for all platforms that support the libuv-based asys package."
+	},
 	{
 		"name": "CheckXmlProxy",
 		"define": "check_xml_proxy",

+ 8 - 0
src/context/common.ml

@@ -84,6 +84,8 @@ type platform_config = {
 	pf_static : bool;
 	(** has access to the "sys" package *)
 	pf_sys : bool;
+	(** has access to the "asys" package *)
+	pf_asys : bool;
 	(** captured variables handling (see before) *)
 	pf_capture_policy : capture_policy;
 	(** when calling a method with optional args, do we replace the missing args with "null" constants *)
@@ -312,6 +314,7 @@ let default_config =
 	{
 		pf_static = true;
 		pf_sys = true;
+		pf_asys = false;
 		pf_capture_policy = CPNone;
 		pf_pad_nulls = false;
 		pf_add_final_return = false;
@@ -588,6 +591,11 @@ let init_platform com pf =
 		define com Define.Sys
 	end else
 		com.package_rules <- PMap.add "sys" Forbidden com.package_rules;
+	if com.config.pf_asys then begin
+		raw_define_value com.defines "target.asys" "true";
+		define com Define.Asys
+	end else
+		com.package_rules <- PMap.add "asys" Forbidden com.package_rules;
 	if com.config.pf_uses_utf16 then begin
 		raw_define_value com.defines "target.utf16" "true";
 		define com Define.Utf16;