Getting rid of obsolete functions and making files parsing more flexible
This commit is contained in:
parent
80724b1cda
commit
ba8137da9d
|
@ -1,26 +1,5 @@
|
|||
<?php
|
||||
|
||||
function mtg_conf($key)
|
||||
{
|
||||
global $METAGEN_CONFIG;
|
||||
|
||||
if(!isset($METAGEN_CONFIG[$key]))
|
||||
{
|
||||
if(func_num_args() == 1)
|
||||
throw new Exception("Config option '$key' is not set");
|
||||
else //default value
|
||||
return func_get_arg(1);
|
||||
}
|
||||
|
||||
return $METAGEN_CONFIG[$key];
|
||||
}
|
||||
|
||||
function mtg_conf_set($key, $val)
|
||||
{
|
||||
global $METAGEN_CONFIG;
|
||||
$METAGEN_CONFIG[$key] = $val;
|
||||
}
|
||||
|
||||
interface mtgType
|
||||
{}
|
||||
|
||||
|
@ -90,7 +69,10 @@ class mtgMetaInfoUnit
|
|||
|
||||
class mtgMetaInfo
|
||||
{
|
||||
public static $BUILTIN_TYPES = array('int8', 'int16', 'int32', 'uint8', 'uint16', 'uint32', 'float', 'double', 'uint64', 'int64', 'bool', 'string', 'blob');
|
||||
public static $BUILTIN_TYPES = array(
|
||||
'int8', 'int16', 'int32', 'uint8', 'uint16', 'uint32',
|
||||
'float', 'double', 'uint64', 'int64', 'bool', 'string', 'blob'
|
||||
);
|
||||
|
||||
private $units = array();
|
||||
|
||||
|
@ -174,6 +156,7 @@ class mtgUserType extends mtgMetaUnit implements mtgType
|
|||
|
||||
function getClassId()
|
||||
{
|
||||
//TODO: use more flexible schema, maybe get rid of this method
|
||||
//NOTE: using crc28 actually, leaving some extra reserved space
|
||||
return crc32($this->name) & 0xFFFFFFF;
|
||||
}
|
||||
|
|
|
@ -800,20 +800,24 @@ class mtgMetaInfoParser
|
|||
}
|
||||
}
|
||||
|
||||
function mtg_parse_meta(array $meta_srcs, $valid_tokens = null)
|
||||
function mtg_parse_meta(array $meta_srcs, $valid_tokens = null, $inc_path = null)
|
||||
{
|
||||
$meta_dirs = array();
|
||||
foreach($meta_srcs as $src)
|
||||
if($inc_path === null)
|
||||
{
|
||||
if(is_dir($src))
|
||||
$meta_dirs[] = $src;
|
||||
else if(is_file($src))
|
||||
$meta_dirs[] = dirname($src);
|
||||
//let's autodetect include path
|
||||
$inc_path = array();
|
||||
foreach($meta_srcs as $src)
|
||||
{
|
||||
if(is_dir($src))
|
||||
$inc_path[] = $src;
|
||||
else if(is_file($src))
|
||||
$inc_path[] = dirname($src);
|
||||
}
|
||||
}
|
||||
|
||||
$meta_parser = new mtgMetaInfoParser(
|
||||
array(
|
||||
'include_path' => $meta_dirs,
|
||||
'include_path' => $inc_path,
|
||||
'valid_tokens' => $valid_tokens
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue