The magic of “[Binding]“
Having been on my Metadata train of though I finally found the time to hunt out in the compiler source where this all happens. Please bear in mind I am no Java buff, nor do I claim to be. In fact quite the opposite
Basically there are a list of Metadata tags in the Flex framework that when they appear in your AS3 or Mxml source, they get “preprocessed” by the compiler. Basically the compiler looks for these tags and modifies the code that appears below it according to a template. I was looking into how I could add my own “preprocessed” tags to the mix and unfortunately it seems that a custom build of the compiler would be the only solution
(please correct me if I am wrong)
If you would like to see what happens.. The compiler uses a .vm file (some strange Macro file) to add watchers and setup functions to your classes for [Bindable] etc. Check out the ClassDefLib.vm file and scroll to the bottom and you will see:
#** * * emitBindingsSetup * *#
Below the comments you might be able to figure out how it builds up the bindingsSetup function.
But I digress. The whole point of me tracking this down so I could… well for lack of a better work… Hack the compiler for my own selfish needs.
I find myself asking the question “are there more people out there that want to do the same“, have their own preprocessors for Metatags and build up their own libraries of time saving “preprocessors”. I imagine so. I guess it comes in under the feature request area.
I would love to see us as developers have some config file where we specify the tag and the appropriate template file and the compiler runs off and does some of the hard repetitive coding for me. We could specify a xslt file and knowing the variables that might be coming in would could build/add to code source.
[CampbellsSuperTag] :: someTeplateFilepath.xslt
Off to http://opensource.adobe.com I go….

You know what would be cool? A compiler argument. Off the top of my head
mxmlc –metadata-parser+=JoshsUltraTag “c:/dev/tagParserFile.ext”
I’m definitely with you on making custom metadata parsers easy to add without recompiling the compilers. I think it would encourage a nice little community that would provide simple parsers that anyone could drop in.
You could implement your own preprocessor with the Flex Compiler API. Just write a Java application that does the preprocessing you want and then send it all off to the actual compiler. This is sort of how the MXML is processed in mxmlc. Unfortunately you don’t get the benefit of having the compiler parsing the source for you.
http://blog.iconara.net/2008/03/18/creating-specialized-compilers-with-the-flex-compiler-api/