Exemple #1
0
 function _hx_build_paths($d, &$_hx_types_array, $pack, $prefix)
 {
     $h = opendir($d);
     while (false !== ($f = readdir($h))) {
         $p = $d . '/' . $f;
         if ($f == '.' || $f == '..') {
             continue;
         }
         if (is_file($p) && substr($f, -4) == '.php') {
             $bn = basename($f, '.php');
             if ($prefix) {
                 if ($prefix != substr($bn, 0, $lenprefix = strlen($prefix))) {
                     continue;
                 }
                 $bn = substr($bn, $lenprefix);
             }
             if (substr($bn, -6) == '.class') {
                 $bn = substr($bn, 0, -6);
                 $t = 0;
             } else {
                 if (substr($bn, -5) == '.enum') {
                     $bn = substr($bn, 0, -5);
                     $t = 1;
                 } else {
                     if (substr($bn, -10) == '.interface') {
                         $bn = substr($bn, 0, -10);
                         $t = 2;
                     } else {
                         if (substr($bn, -7) == '.extern') {
                             $bn = substr($bn, 0, -7);
                             $t = 3;
                         } else {
                             continue;
                         }
                     }
                 }
             }
             $qname = $bn == 'HList' && empty($pack) ? 'List' : join(array_merge($pack, array($bn)), '.');
             $_hx_types_array[] = array('path' => $p, 'name' => $prefix . $bn, 'type' => $t, 'qname' => $qname, 'phpname' => join(array_merge($pack, array($prefix . $bn)), '_'));
         } else {
             if (is_dir($p)) {
                 _hx_build_paths($p, $_hx_types_array, array_merge($pack, array($f)), $prefix);
             }
         }
     }
     closedir($h);
 }
 static function loadLib($pathToLib)
 {
     $prefix = null;
     $_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(), $prefix);
     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);
         }
     }
 }