-
-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add additional Compiler
/Context
functions for getting compiler configuration and main func/output types
#10871
Add additional Compiler
/Context
functions for getting compiler configuration and main func/output types
#10871
Conversation
…on, and other context info
Maybe we should have something like Also, I don't see why |
I'd absolutely love And yeahhh, originally just had |
Added `Compiler.getConfiguration` and its required typedefs/enums: * `haxe.macro.Compiler.CompilerConfiguration` * `haxe.macro.Compiler.PackageRule` * `haxe.macro.PlatformConfig` * `haxe.macro.PlatformConfig.CapturePolicy` * `haxe.macro.PlatformConfig.VarScopingConfig` * `haxe.macro.PlatformConfig.VarScope` * `haxe.macro.PlatformConfig.VarScopingFlags` * `haxe.macro.PlatformConfig.ExceptionsConfig`
Oh wow, you went all-in on that configuration part! My only concern in that regard is that we now can't easily change these internal structures without also changing the public interface. I suppose we could add a documentation comment about that somewhere so that people know something might change between compiler versions. It's a rare occurrence anyway, but I want to keep the option open at least. |
Haha, just wanted to see what it would look like if everything was typed, then get some feedback and trim down from there. (;^_^) Alternatively, since most of the |
Mostly copied the warning comment from haxe.macro.Type, seemed very applicable. Let me know if there's anything else, and I'll work on adding tests in meantime! 👍 |
Compiler
/Context
functions for getting input arguments and output typesCompiler
/Context
functions for getting compiler configuration and main func/output types
Nice! There might be some minor inaccuracies in the documentation, but we can address that later. Thank you for the contribution! |
Ha, had a minor report in the documentation indeed but was about to say lgtm but you just merged it :D |
Oh wow, that was fast! Thank you all so much, you have no idea how much these features will help! 😁❤️ (Sorry about the docs, ooof.) |
At the moment, it's impossible to get the compiler arguments and learn what the main function is with Haxe macros. This pull seeks to resolve this by exposing additional information from the context object in OCaml.
Input
There's a collection of static info regarding compiler input that could be helpful in Haxe macros, such as compiler arguments, main class path, platform, version, etc. The
Compiler.getConfiguration
function helps provide this info by exposing the "config" fields of the OCaml context object.Output
Similarly, there is some output information within this context object that would also be nice to access from
Context
. At the current moment, only the JavaScript target can access the generated "main" typed expression and a list ofhaxe.macro.Type
s outputs usingsetCustomJSGenerator
andJSGenApi
.The
Context.getMainExpr()
allows access to the main expression from any target at compile-time.Context.getAllModuleTypes()
on the other hand provides a list of thehaxe.macro.ModuleType
s that are readily available after a certain point in the compilation process. In order to keep consistent with the capabilities of the JS target, the two OCaml functions used to converting betweenModuleType
s andType
s have also been exposed inhaxe.macro.TypeTools
.Functions added
haxe.macro.Compiler.getConfiguration
haxe.macro.Context.getMainExpr
haxe.macro.Context.getAllModuleTypes
haxe.macro.TypeTools.toModuleType
haxe.macro.TypeTools.fromModuleType
Any thoughts are appreciated!