<commit_before>package luxe.macros;

import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.ExprTools;

@:noCompletion class EntityRules {

#if macro

    static var init_field : Field;
    static var ondestroy_field : Field;

    macro public static function apply() : Array<Field> {

        init_field = null;
        ondestroy_field = null;

        var _fields = Context.getBuildFields();

            //do this first to ensure the values are set
        for(_field in _fields) {
            switch(_field.name) {
                case 'init': init_field = _field;
                case 'ondestroy': ondestroy_field = _field;
            }
        }

            //if no init field, insert one
        if(init_field == null) {
            init_field = {
                name: 'init',
                doc: null, meta: [],
                access: [AOverride],
                kind: FFun({ params:[], args:[], ret:null, expr:macro { } }),
                pos: Context.currentPos()
            };
            _fields.push(init_field);
        }

            //if no ondestroy field, insert one
        if(ondestroy_field == null) {
            ondestroy_field = {
                name: 'ondestroy',
                doc: null, meta: [],
                access: [AOverride],
                kind: FFun({ params:[], args:[], ret:null, expr:macro { super.ondestroy(); } }),
                pos: Context.currentPos()
            };
            _fields.push(ondestroy_field);
        }

        for(_field in _fields) {

            switch(_field.name) {

                case
                    'ontouchmove',<commit_msg>Entity; rules; call super when inserting an init function which should retain the existing behaviour<commit_after>package luxe.macros;

import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.ExprTools;

@:noCompletion class EntityRules {

#if macro

    static var init_field : Field;
    static var ondestroy_field : Field;

    macro public static function apply() : Array<Field> {

        init_field = null;
        ondestroy_field = null;

        var _fields = Context.getBuildFields();

            //do this first to ensure the values are set
        for(_field in _fields) {
            switch(_field.name) {
                case 'init': init_field = _field;
                case 'ondestroy': ondestroy_field = _field;
            }
        }

            //if no init field, insert one
        if(init_field == null) {
            init_field = {
                name: 'init',
                doc: null, meta: [],
                access: [AOverride],
                kind: FFun({ params:[], args:[], ret:null, expr:macro { super.init(); } }),
                pos: Context.currentPos()
            };
            _fields.push(init_field);
        }

            //if no ondestroy field, insert one
        if(ondestroy_field == null) {
            ondestroy_field = {
                name: 'ondestroy',
                doc: null, meta: [],
                access: [AOverride],
                kind: FFun({ params:[], args:[], ret:null, expr:macro { super.ondestroy(); } }),
                pos: Context.currentPos()
            };
            _fields.push(ondestroy_field);
        }

        for(_field in _fields) {

            switch(_field.name) {

                case
                    'ontouchmove',
{'fraction_non_alphanumeric': 0.1088961618565903, 'fraction_numerical': 0.0, 'mean_word_length': 1.5723029839326703, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5599491', 'n_tokens_mistral': 954, 'n_tokens_neox': 896, 'n_words': 238}