https://linen.dev logo
Join Discord
Powered by
# haxe-ui
  • w

    witty-island-52596

    04/10/2019, 4:15 PM
    First
  • b

    bright-gpu-74537

    04/10/2019, 5:06 PM
    ... second! 😃
  • b

    bitter-family-72722

    04/10/2019, 5:10 PM
    third?
  • b

    bright-gpu-74537

    04/10/2019, 5:17 PM
    ... ... this could go on for a while... heh heh
  • a

    ambitious-knife-25690

    04/10/2019, 5:19 PM
    You're all banned.
  • b

    bright-gpu-74537

    04/10/2019, 5:19 PM
    😃
  • b

    bright-gpu-74537

    04/10/2019, 5:39 PM
    refactoring haxeui macro code... ... what a difference! old:
  • b

    bright-gpu-74537

    04/10/2019, 5:40 PM
    heh heh, wont let me paste the old code... ... too big! 😄
  • b

    bright-gpu-74537

    04/10/2019, 5:40 PM
    old: https://pastebin.com/bBRS8Xfs
  • b

    bright-gpu-74537

    04/10/2019, 5:40 PM
    new:
  • b

    bright-gpu-74537

    04/10/2019, 5:40 PM
    Copy code
    if (builder.hasSuperClass("haxe.ui.core.Component") == false) {
                return "Must have a superclass of haxe.ui.core.Component";
            }
            
            if (builder.constructor == null) {
                return "A class building component must have a constructor";
            }
    
            ModuleMacros.populateClassMap();
            
            var xml = builder.getClassMetaValue("xml");
            var namedComponents:Map<String, String> = new Map<String, String>();
            var expr = ComponentMacros.buildComponentFromString([], xml, namedComponents);
            var codeBuilder = new CodeBuilder(expr);
            codeBuilder.add(macro
                addComponent(c0)
            );
            
            var createChildrenFn = builder.findFunction("createChildren");
            if (createChildrenFn == null) {
                createChildrenFn = builder.addFunction("createChildren", macro {
                    super.createChildren();
                }, [APrivate, AOverride]);
            }
            createChildrenFn.add(codeBuilder);
            
            for (id in namedComponents.keys()) {
                var safeId:String = StringUtil.capitalizeHyphens(id);
                var cls:String = namedComponents.get(id);
                builder.addVar(safeId, TypeTools.toComplexType(Context.getType(cls)));
                builder.constructor.add(macro
                    $i{safeId} = findComponent($v{id}, $p{cls.split(".")}, true)
                , 1);
            }
            
            return null;
  • b

    bright-gpu-74537

    04/10/2019, 5:41 PM
    helluva diff...
  • b

    bitter-family-72722

    04/10/2019, 6:16 PM
    Copy code
    createChildrenFn = builder.addFunction("createChildren", macro {
        super.createChildren();
    }, [APrivate, AOverride]);
  • b

    bitter-family-72722

    04/10/2019, 6:16 PM
    ^looks like that might be nicer with a
    macro class
    ?
  • b

    bright-gpu-74537

    04/10/2019, 6:24 PM
    how so?
  • b

    bright-gpu-74537

    04/10/2019, 6:24 PM
    if the function doesnt exist, create it, then add to it, if it does exist then use that, and add to it
  • b

    bright-gpu-74537

    04/10/2019, 6:24 PM
    better way?
  • b

    bitter-family-72722

    04/10/2019, 6:28 PM
    hm.. maybe I misunderstand the code, but it just seems like an awkward way to create a function with macros
  • b

    bitter-family-72722

    04/10/2019, 6:29 PM
    with macro classes, you can use regular Haxe syntax to declare fields
  • b

    bitter-family-72722

    04/10/2019, 6:29 PM
    Copy code
    var createChildrenFn = (macro class {
        override private function createChildren() {
            super.createChildren();
        }
    }).fields[0];
  • b

    bright-gpu-74537

    04/10/2019, 6:29 PM
    rightyo... ill take a look
  • b

    bitter-family-72722

    04/10/2019, 6:33 PM
    I've talked a bit about that here https://stackoverflow.com/questions/48475603/using-haxe-macros-to-instantiate-a-class-with-parameters/48475928#48475928
  • b

    bright-gpu-74537

    04/10/2019, 6:54 PM
    👍
  • b

    brave-kangaroo-30399

    04/11/2019, 12:48 AM
    Oh boy
  • c

    cool-psychiatrist-49311

    04/11/2019, 2:47 AM
    @bright-gpu-74537 you probably want to use tink_macro's ClassBuilder https://github.com/haxetink/tink_macro#classbuilder
  • u

    user

    04/11/2019, 7:09 AM
    What is this
  • u

    user

    04/11/2019, 7:09 AM
  • u

    user

    04/11/2019, 7:09 AM
    UI library for Haxe?
  • m

    miniature-summer-93860

    04/11/2019, 7:13 AM
    @User maybe Haha
  • h

    handsome-television-62908

    04/11/2019, 7:55 AM
12345...1687Latest