diff --git a/src/codegen.inc.php b/src/codegen.inc.php index 9453924..77a5cd2 100644 --- a/src/codegen.inc.php +++ b/src/codegen.inc.php @@ -19,6 +19,24 @@ function get_twig(array $inc_path = []) return $twig; } +function supported_tokens() +{ + return [ + 'POD', + 'default', + 'optional', + 'cloneable', + 'virtual', + 'id', + 'owner', + 'pkey', + //TODO: + //'obscured', + //'bitfields', + //'diffable', + ]; +} + function _add_twig_support(\Twig\Environment $twig) { $twig->addTest(new \Twig\TwigTest('instanceof', diff --git a/tpl/codegen_bundle.twig b/tpl/codegen_bundle.twig index 55ef4b2..9f842d8 100644 --- a/tpl/codegen_bundle.twig +++ b/tpl/codegen_bundle.twig @@ -16,7 +16,11 @@ static public class AutogenBundle { switch(code) { - %create_rpc_by_id% +{%- for u in meta.getunits ~%} +{%- if u.object is instanceof('\\mtgMetaRPC') ~%} + case {{u.object.code}}: { return new {{u.object.name}}(); } +{%- endif ~%} +{%- endfor ~%} default: { return null; @@ -28,7 +32,11 @@ static public class AutogenBundle { switch(class_id) { - %create_struct_by_crc28% +{%- for u in meta.getunits ~%} +{%- if u.object is instanceof('\\mtgMetaEnum') or u.object is instanceof('\\mtgMetaStruct')~%} + case {{u.object.classid}}: { return new {{u.object.name}}(); } +{%- endif ~%} +{%- endfor ~%} default: { return null; @@ -40,7 +48,11 @@ static public class AutogenBundle { switch(class_id) { - %id2type% +{%- for u in meta.getunits ~%} +{%- if u.object is instanceof('\\mtgMetaEnum') or u.object is instanceof('\\mtgMetaStruct')~%} + case {{u.object.classid}}: { return typeof({{u.object.name}}); } +{%- endif ~%} +{%- endfor ~%} default: { return null;