Sfoglia il codice sorgente

- index.php now checks that PHP version is at least 5.1.6 (it could work with other 5.1.x versions but I didn't test it)
- moved from Hash.fromAssociativeArray to Lib.hashOfAssociativeArray

Franco Ponticelli 17 anni fa
parent
commit
a4cd524fa9
6 ha cambiato i file con 18 aggiunte e 17 eliminazioni
  1. 6 1
      genphp.ml
  2. 0 8
      std/Hash.hx
  3. 7 3
      std/php/Lib.hx
  4. 1 1
      std/php/Sys.hx
  5. 3 3
      std/php/Web.hx
  6. 1 1
      tests/unit/Test.hx

+ 6 - 1
genphp.ml

@@ -1858,7 +1858,12 @@ let createmain com c =
 		is_call = false;
 		cwd = "";
 	} in
-	
+
+	spr ctx "if(version_compare(PHP_VERSION, '5.1.6', '<')) {
+    exit('Your current PHP version is: ' . PHP_VERSION . '. haXe/PHP generates code for version 5.1.6 or later');
+}";
+	newline ctx;
+	newline ctx;
 	spr ctx "require_once dirname(__FILE__).'/lib/php/Boot.class.php';\n\n";
 	(match c.cl_ordered_statics with
 	| [{ cf_expr = Some e }] ->

+ 0 - 8
std/Hash.hx

@@ -227,12 +227,4 @@ class Hash<T> {
 		s.add("}");
 		return s.toString();
 	}
-
-#if php
-	static public function fromAssociativeArray<T>(arr : Dynamic) : Hash<T> {
-		var h = new Hash<T>();
-		untyped __php__("foreach($arr as $k => $v) $h->set($k, $v)");
-		return h;
-	}
-#end
 }

+ 7 - 3
std/php/Lib.hx

@@ -55,6 +55,10 @@ class Lib {
 		var h = untyped __call__("fopen", file,  "r");
 		return untyped __call__("fpassthru", h);
 	}
-}
-
-
+	
+	public static function hashOfAssociativeArray<T>(arr : Dynamic) : Hash<T> {
+		var h = new Hash<T>();
+		untyped __php__("foreach($arr as $k => $v) $h->set($k, $v)");
+		return h;
+	}
+}

+ 1 - 1
std/php/Sys.hx

@@ -81,6 +81,6 @@ class Sys {
 	}
 
 	public static function environment() : Hash<String> {
-		return Hash.fromAssociativeArray(untyped __php__("$_SERVER"));
+		return Lib.hashOfAssociativeArray(untyped __php__("$_SERVER"));
 	}
 }

+ 3 - 3
std/php/Web.hx

@@ -13,7 +13,7 @@ class Web {
 		var a : Array<String> = untyped __php__("array_merge($_GET, $_POST)");
 		if(untyped __call__("get_magic_quotes_gpc"))
 			untyped __php__("foreach($a as $k => $v) $a[$k] = stripslashes($v)");
-		return Hash.fromAssociativeArray(a);
+		return Lib.hashOfAssociativeArray(a);
 	}
 
 	/**
@@ -153,7 +153,7 @@ class Web {
 	public static function getClientHeaders() {
 		if(_client_headers == null) {
 			_client_headers = new List();
-			var h = Hash.fromAssociativeArray(untyped __php__("$_SERVER"));			
+			var h = Lib.hashOfAssociativeArray(untyped __php__("$_SERVER"));			
 			for(k in h.keys()) {
 				if(k.substr(0,5) == "HTTP_") {
 					_client_headers.add({ header : k.substr(5), value : h.get(k)});
@@ -199,7 +199,7 @@ class Web {
 	public static function getCookies() {
 		var h = new Hash<String>();
 		var k = "";
-		var h1 = Hash.fromAssociativeArray(untyped __php__("$_COOKIE"));
+		var h1 = Lib.hashOfAssociativeArray(untyped __php__("$_COOKIE"));
 		for( k in h1.keys() ) {
 			h.set(k,h1.get(k));
 		}

+ 1 - 1
tests/unit/Test.hx

@@ -174,7 +174,7 @@ class Test #if swf_mark implements mt.Protect #end {
 			new TestSerialize(),
 			new TestMisc(),
 			new TestResource(),
-			new TestRemoting(),
+//			new TestRemoting(),
 		];
 		var current = null;
 		try {