Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------------------------------
- package haxe.ui.core;
- @:autoBuild(haxe.ui.macros.Macros.buildBindings())
- @:autoBuild(haxe.ui.macros.Macros.addClonable())
- class Component extends ComponentBase {
- }
- -------------------------------------------------------
- package haxe.ui.openfl;
- class ComponentBase extends Sprite {
- }
- -------------------------------------------------------
- 1) haxe.ui.core.ComponentBase is aliased to haxe.ui.openfl.ComponentBase at the very start using --macro
- 2) "modules" are needed to know what componed packages are available, these are then added to a "class register", like:
- haxe.ui.components.Button => button
- this happens also at compile time via a "processModules" macro that scans the classpath looking for "module.xml" and
- doing the required "stuff"
- 3) I now want to do something like the following:
- @:build(haxe.ui.macros.ComponentMacros.fromXML("somefile.xml"))
- class MyClass extends Component {
- }
- However, in order for that to work, modules must be loaded as if not the the components in the mark up, say, <button />
- wont exist in the component registry, so i wont know what class they are, etc.
- So the first problem is when i use "processModules" i got a "haxe.ui.core.ComponentBase isnt defined" type error, even
- though in the build macro it is there, its not in the processModules macro (checked both).
- So i manually aliased the types (to test) in the processModules macro, like:
- MacroHelpers.aliasType("haxe.ui.openfl.ComponentBase", "haxe.ui.core.ComponentBase");
- MacroHelpers.aliasType("haxe.ui.openfl.TextInputBase", "haxe.ui.core.TextInputBase");
- MacroHelpers.aliasType("haxe.ui.openfl.TextDisplayBase", "haxe.ui.core.TextDisplayBase");
- MacroHelpers.aliasType("openfl.display.BitmapData", "haxe.ui.ImageData");
- MacroHelpers.aliasType("haxe.ui.openfl.ImageDisplayBase", "haxe.ui.core.ImageDisplayBase");
- MacroHelpers.aliasType("haxe.ui.openfl.AssetsBase", "haxe.ui.AssetsBase");
- MacroHelpers.aliasType("haxe.ui.openfl.FontBase", "haxe.ui.FontBase");
- And then i got:
- You cannot use @:build inside a macro : make sure that your enum is not used in macro
- Which is because the Component has a build macro also, but the real question (to me) is the first problem, ie, why isnt
- "haxe.ui.core.ComponentBase" available to the processModules function when i call it from a build macro?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement