https://linen.dev logo
Join Discord
Powered by
# macros
  • w

    witty-island-52596

    05/18/2023, 6:06 PM
    i think before i had them as Expr and checked for strings or ERegs
  • w

    witty-island-52596

    05/18/2023, 6:06 PM
    not sure why i changed that
  • w

    witty-island-52596

    05/18/2023, 6:06 PM
    invalid how?
  • g

    gray-state-67732

    05/18/2023, 6:21 PM
    you can't pass functions as build macro argument iirc
  • w

    witty-island-52596

    05/18/2023, 6:26 PM
    also I just realized im calling
    flixel.system.FlxAssets
    which is a helper that calls
    flixel.system.FlxAssetPaths
    , which is where I added the arg
  • w

    witty-island-52596

    05/18/2023, 6:27 PM
    in FlxAssets include/exclude are Expr which are converted to ERegs for FlxAssetPaths
  • w

    witty-island-52596

    05/18/2023, 6:28 PM
    Now i know what to do, thanks Rudy
  • e

    elegant-intern-95950

    05/20/2023, 2:58 PM
    Hej, I come back with an old question I've asked some years ago on the forum about static extension and macro function, is there any evolution about being able to use static extension macro function and get the untyped expression on which the macro function apply instead of getting
    @:storedTypedExpr XX
    ? Because I'm still using a custom StaticExtension build macro that transforms all
    expr!.myMacroFunc()
    into
    myMacroFunc( expr )
    but maybe things have changed since this time ?
  • w

    witty-island-52596

    05/21/2023, 8:55 PM
    do i need to worry about memory leaks of a macro?
  • w

    witty-island-52596

    05/21/2023, 8:55 PM
    or once the macro is done all memory used by it is freed
  • w

    witty-island-52596

    05/21/2023, 8:56 PM
    i have circular references on my macro objects
  • c

    cool-musician-79004

    05/22/2023, 6:56 AM
    macros only happen at compile time, so once they are done, they are done. Once they completed withuout crashing they can not influence your runtime. However, that is different from you introducing code that has memory leaks with your macros
  • g

    gray-state-67732

    05/22/2023, 7:07 AM
    If you have memory leaks on persistent macro data it might very well be an issue. Just not a runtime issue ofc, but still. I haven't checked, but I would not expect non persistent data to be an issue (eval should take care of this)
  • g

    gray-state-67732

    05/22/2023, 7:08 AM
    > so once they are done, they are done Not necessarily true with compilation server (which the majority of us use, at least through Haxe LSP)
  • c

    cool-musician-79004

    05/22/2023, 7:09 AM
    Oh, never thought about a ever running compilation server, but that makes sense
  • w

    witty-island-52596

    05/23/2023, 6:47 PM
    I had no persistent macro data, but i also just rewrote it to not need refs
  • b

    brainy-machine-50829

    05/24/2023, 12:30 PM
    What would be a good way to pass some actions/code from normal context to be executed at macro context?
  • b

    brainy-machine-50829

    05/24/2023, 12:30 PM
    E.g. if I have an expression macro and I would want to give it some class/function that it would then execute as part of the macro?
  • b

    brainy-machine-50829

    05/24/2023, 12:38 PM
    Not sure how to make sure the class I want to use gets included in the macro context... without first referencing it in a macro. 😅
  • e

    elegant-intern-95950

    05/24/2023, 1:12 PM
    Do you mean you want to kind of resolve "macro" class in macro context ?
  • b

    brainy-machine-50829

    05/24/2023, 4:28 PM
    Yep.
  • b

    brainy-machine-50829

    05/24/2023, 4:29 PM
    I sorta-kinda found a workaround that I used once in some older project, just took me a while to figure which project it was. 😅
  • b

    brainy-machine-50829

    05/24/2023, 4:30 PM
    I let the class register itself in macro context to some persistent map, during init macro. Then I refer to that via key, some string or something, from normal context as constant given to macro context.
  • b

    brainy-machine-50829

    05/24/2023, 4:30 PM
    Awkward, but w/e.
  • e

    elegant-intern-95950

    05/24/2023, 5:18 PM
    I raised an "issue" some weeks ago about that without success : https://github.com/HaxeFoundation/haxe/issues/11147 Can you give me an example of your workaround please ? I don't really understand how do you do... My workaround is to do something like that (also in an init macro ) :
    Copy code
    haxe
    function myInitFunction(){
      ftk.tools.Rtmi.build;
      ftk.macro.Compiler.autoBuild2Build( "ftk.tools.Rtmi.IRtmi", [ "ftk.db.Session", "ftk.db.DBState" ], "ftk.tools.Rtmi.build" );
    }
  • b

    brainy-machine-50829

    05/24/2023, 5:50 PM
    It just comes down to what Simon said there, you need the macro context to see the class somewhere first.
  • b

    brainy-machine-50829

    05/24/2023, 5:50 PM
    Not sure what ways there are to do that. You simply need to mention it explicitly at some point somewhere. Not sure if there's more than one macro contexts, I didn't try.
  • b

    brainy-machine-50829

    05/24/2023, 5:50 PM
    Might just need some empty macro function that does nothing but mention the class.
  • b

    brainy-machine-50829

    05/24/2023, 5:51 PM
    Maybe that issue should have turned into a feature request for loading a class into macro context from a string. 😄
  • e

    elegant-intern-95950

    05/24/2023, 6:07 PM
    That is exactly what I'm doing, just mentionning the class in the init macro function. Yes my issue was a question/request ... but I also don't really know how this could be done... get the class from a string of reverse like get the name from a function 😄