Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. -------------------------------------------------------
  2. package haxe.ui.core;
  3.  
  4. @:autoBuild(haxe.ui.macros.Macros.buildBindings())
  5. @:autoBuild(haxe.ui.macros.Macros.addClonable())
  6. class Component extends ComponentBase {
  7. }
  8.  
  9. -------------------------------------------------------
  10. package haxe.ui.openfl;
  11.  
  12. class ComponentBase extends Sprite {
  13. }
  14.  
  15. -------------------------------------------------------
  16.  
  17. 1) haxe.ui.core.ComponentBase is aliased to haxe.ui.openfl.ComponentBase at the very start using --macro
  18. 2) "modules" are needed to know what componed packages are available, these are then added to a "class register", like:
  19. haxe.ui.components.Button => button
  20. this happens also at compile time via a "processModules" macro that scans the classpath looking for "module.xml" and
  21. doing the required "stuff"
  22. 3) I now want to do something like the following:
  23.  
  24. @:build(haxe.ui.macros.ComponentMacros.fromXML("somefile.xml"))
  25. class MyClass extends Component {
  26. }
  27.  
  28. However, in order for that to work, modules must be loaded as if not the the components in the mark up, say, <button />
  29. wont exist in the component registry, so i wont know what class they are, etc.
  30.  
  31. So the first problem is when i use "processModules" i got a "haxe.ui.core.ComponentBase isnt defined" type error, even
  32. though in the build macro it is there, its not in the processModules macro (checked both).
  33.  
  34. So i manually aliased the types (to test) in the processModules macro, like:
  35. MacroHelpers.aliasType("haxe.ui.openfl.ComponentBase", "haxe.ui.core.ComponentBase");
  36. MacroHelpers.aliasType("haxe.ui.openfl.TextInputBase", "haxe.ui.core.TextInputBase");
  37. MacroHelpers.aliasType("haxe.ui.openfl.TextDisplayBase", "haxe.ui.core.TextDisplayBase");
  38. MacroHelpers.aliasType("openfl.display.BitmapData", "haxe.ui.ImageData");
  39. MacroHelpers.aliasType("haxe.ui.openfl.ImageDisplayBase", "haxe.ui.core.ImageDisplayBase");
  40. MacroHelpers.aliasType("haxe.ui.openfl.AssetsBase", "haxe.ui.AssetsBase");
  41. MacroHelpers.aliasType("haxe.ui.openfl.FontBase", "haxe.ui.FontBase");
  42.  
  43. And then i got:
  44.  
  45. You cannot use @:build inside a macro : make sure that your enum is not used in macro
  46.  
  47. Which is because the Component has a build macro also, but the real question (to me) is the first problem, ie, why isnt
  48. "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