Browse Source

fixed Type.enumParameters() for PHP

Franco Ponticelli 17 years ago
parent
commit
a6eed43fd6
2 changed files with 16 additions and 10 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 15 10
      std/Type.hx

+ 1 - 0
doc/CHANGES.txt

@@ -7,6 +7,7 @@ TODO inlining : allow inlined getter/setter
 TODO inlining : substitute class+function type parameters in order to have fully typed expressions
 
 2008-??-??: 2.01
+	fixed Type.enumParameters() for PHP
 	fixed null references in class constructors for array arguments
 	fixed php.Boot.__string_rec() when invoked from toString
 	added neko.NativeString

+ 15 - 10
std/Type.hx

@@ -355,7 +355,7 @@ class Type {
 				if(nargs > 0) {
 					var args = __call__("array_fill", 0, m.getNumberOfRequiredParameters(), null);
 					i = __php__("$rfl->newInstanceArgs($args)");
-				} else {				
+				} else {
 					i = __php__("$rfl->newInstanceArgs(array())");
 				}
 				php.Boot.skip_constructor = false;
@@ -418,7 +418,7 @@ class Type {
 			$r = array();
 			$internals = array('__construct', '__call', '__get', '__set', '__isset', '__unset', '__toString');
 			foreach($ms as $m) {
-				$n = $m->getName();				
+				$n = $m->getName();
 				if(!$m->isStatic() && ! in_array($n, $internals)) $r[] = $n;
 			}
 			foreach($ps as $p)
@@ -485,7 +485,7 @@ class Type {
 	/**
 		Returns all the available constructor names for an enum.
 	**/
-	public static function getEnumConstructs( e : Enum ) : Array<String> untyped {		
+	public static function getEnumConstructs( e : Enum ) : Array<String> untyped {
 		#if php
 			if(__php__("$e->__tname__ == 'Bool'")) return ['true', 'false'];
 			if(__php__("$e->__tname__ == 'Void'")) return [];
@@ -586,7 +586,7 @@ class Type {
 			}
 		#elseif php
 			if(v == null) return TNull;
-			if(__call__("is_array", v)) { 
+			if(__call__("is_array", v)) {
 				if(__call__("is_callable", v)) return TFunction;
 				return TClass(Array);
 			}
@@ -598,12 +598,12 @@ class Type {
 			if(__call__("is_bool", v)) return TBool;
 			if(__call__("is_int", v)) return TInt;
 			if(__call__("is_float", v)) return TFloat;
-			if(__php__("$v instanceof Anonymous"))  return TObject;    
-			if(__php__("$v instanceof __enumtype__"))  return TObject;  
-			if(__php__("$v instanceof __classtype__"))  return TObject;  
-    
+			if(__php__("$v instanceof Anonymous"))  return TObject;
+			if(__php__("$v instanceof __enumtype__"))  return TObject;
+			if(__php__("$v instanceof __classtype__"))  return TObject;
+
 			var c = __php__("php_Boot::__ttype(get_class($v))");
-    
+
 			if(__php__("$c instanceof __enumtype__"))  return TEnum(cast c);
 			if(__php__("$c instanceof __classtype__")) return TClass(cast c);
 			return TUnknown;
@@ -685,8 +685,13 @@ class Type {
 	public static function enumParameters( e : Dynamic ) : Array<Dynamic> {
 		#if neko
 			return if( e.args == null ) [] else untyped Array.new1(e.args,__dollar__asize(e.args));
-		#elseif (flash9 || php)
+		#elseif flash9
 			return if( e.params == null ) [] else e.params;
+		#elseif php
+			if(e.params == null)
+				return [];
+			else
+				return e.params;
 		#else
 			return e.slice(2);
 		#end