diff --git a/src/codegen.inc.php b/src/codegen.inc.php index 9d84729..368671d 100644 --- a/src/codegen.inc.php +++ b/src/codegen.inc.php @@ -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) {