Fixing generic structs support

This commit is contained in:
Pavel Shevaev 2023-08-08 15:06:14 +03:00
parent 9180aa8b5d
commit 97db32ffc7
1 changed files with 7 additions and 9 deletions

View File

@ -187,23 +187,21 @@ function data2value($name, \mtgType $type, $buf, $prefix = '', $tokens = array()
}
else if($type instanceof \mtgMetaStruct)
{
$str .= $cond_indent."if({$tmp_val} === null) {\n";
$str .= $cond_indent." {$pname} = null; \n";
$str .= $cond_indent."} else {\n";
$str .= $cond_indent."{$tmp_val} = " . apply_value_filters($name, $tokens, "{$tmp_val}"). ";\n";
$str .= $cond_indent."\$tmp_sub_arr__ = \metagen_php\\val_arr({$tmp_val});\n";
if(array_key_exists('virtual', $tokens))
{
$str .= $cond_indent."{$tmp_val} = " . apply_value_filters($name, $tokens, "{$tmp_val}"). ";\n";
$str .= $cond_indent."\$tmp_sub_arr__ = \metagen_php\\val_arr({$tmp_val});\n";
$str .= $cond_indent."\$vclass__ = AutogenBundle::getClassName(\metagen_php\\val_uint32(\metagen_php\array_extract_val(\$tmp_sub_arr__, \$assoc, 'vclass__')));\n";
$str .= $cond_indent."\$vclass__ = AutogenBundle::getClassName(\metagen_php\\val_uint32(\metagen_php\array_extract_val(\$tmp_sub_arr__, \$assoc, '\$id', {$type->getClassId()})));\n";
$str .= $cond_indent."{$pname} = new \$vclass__(\$tmp_sub_arr__, \$assoc);\n";
}
else
{
$str .= $cond_indent."if({$tmp_val} === null) {\n";
$str .= $cond_indent." {$pname} = null; \n";
$str .= $cond_indent."} else {\n";
$str .= $cond_indent." {$tmp_val} = " . apply_value_filters($name, $tokens, "{$tmp_val}"). ";\n";
$str .= $cond_indent." \$tmp_sub_arr__ = \metagen_php\\val_arr({$tmp_val});\n";
$str .= $cond_indent." {$pname} = new {$type}(\$tmp_sub_arr__, \$assoc);\n";
$str .= "}";
}
$str .= "}";
}
else if($type instanceof \mtgArrType)
{