فهرست منبع

- php : added php.Lib.loadLib to load external libs generated with haxe

Franco Ponticelli 14 سال پیش
والد
کامیت
fdc96f18d3
1فایلهای تغییر یافته به همراه30 افزوده شده و 0 حذف شده
  1. 30 0
      std/php/Lib.hx

+ 30 - 0
std/php/Lib.hx

@@ -97,4 +97,34 @@ class Lib {
 		}
 		return o;
 	}
+	
+	/**
+	*  Loads types defined in the specified directory.
+ 	*/
+ 	public static function loadLib(pathToLib : String) : Void
+ 	{
+		untyped __php__("$_hx_types_array = array();
+ 		$_hx_cache_content = '';
+ 		//Calling this function will put all types present in the specified types in the $_hx_types_array
+ 		_hx_build_paths($pathToLib, $_hx_types_array, array());
+ 
+ 		for($i=0;$i<count($_hx_types_array);$i++) {
+ 			//For every type that has been found, create its description
+ 			$t = null;
+ 			if($_hx_types_array[$i]['type'] == 0) {
+ 				$t = new _hx_class($_hx_types_array[$i]['phpname'], $_hx_types_array[$i]['qname'], $_hx_types_array[$i]['path']);
+ 			} else if($_hx_types_array[$i]['type'] == 1) {
+ 				$t = new _hx_enum($_hx_types_array[$i]['phpname'], $_hx_types_array[$i]['qname'], $_hx_types_array[$i]['path']);
+ 			} else if($_hx_types_array[$i]['type'] == 2) {
+ 				$t = new _hx_interface($_hx_types_array[$i]['phpname'], $_hx_types_array[$i]['qname'], $_hx_types_array[$i]['path']);
+ 			} else if($_hx_types_array[$i]['type'] == 3) {
+ 				$t = new _hx_class($_hx_types_array[$i]['name'], $_hx_types_array[$i]['qname'], $_hx_types_array[$i]['path']);
+ 			}
+ 			//Register the type
+ 			if(!array_key_exists($t->__qname__, php_Boot::$qtypes)) {
+ 				_hx_register_type($t);
+ 			}
+ 		}
+ ");
+ 	}
 }