diff --git a/src/codegen.inc.php b/src/codegen.inc.php index 03416b3..17f0ac1 100644 --- a/src/codegen.inc.php +++ b/src/codegen.inc.php @@ -82,7 +82,7 @@ function _add_twig_support(\Twig\Environment $twig) } )); $twig->addFunction(new \Twig\TwigFunction('get_all_fields', - function($meta, $o) + function($o) { return \mtg_get_all_fields($o); } @@ -253,13 +253,13 @@ function field_reset($name, \mtgType $type, array $tokens) } else if($type instanceof \mtgArrType) { - $str = "if self.$name == nil { \nself.$name = make(".go_type($field->getType(), $field->getTokens()).",0) \n}\n "; + $str = "if self.$name == nil { \nself.$name = make(".go_type($type, $tokens).",0) \n}\n "; $str .= "self.$name = self.{$name}[0:0]"; } else if($type instanceof \mtgMetaEnum) { if(array_key_exists('default', $tokens)) - $str = "self.$name = ".go_type($field->getType(), $field->getTokens())."_".trim($tokens['default'], '"'); + $str = "self.$name = ".go_type($type, $tokens)."_".trim($tokens['default'], '"'); else $str = "self.$name = 0"; } @@ -267,7 +267,7 @@ function field_reset($name, \mtgType $type, array $tokens) { $is_virtual = array_key_exists("virtual", $tokens); if($is_virtual) - $str .= "self.$name = New".ltrim(go_type($field->getType(), $field->getTokens()),'I')."() "; + $str .= "self.$name = New".ltrim(go_type($type, $tokens),'I')."() "; else $str .= "self.$name.Reset()"; }