1 Aug 2003 03:47
reflection extensions
I've checked a new set of extensions into CVS. It's reflection, and here's
a quick run-down for the brave who want to try it out (it's very alpha)
and the curious who want to know what's coming.
there's a single function defined, called program(), that returns an XML
tree representing all types and functions in the program. The reflection
types all inherit from Element, which makes it easy to query them using
XPath. Here's an example how:
<o:set match="ref:program()/type[ <at> name = 'String']/function[ <at> name ='match']"/>
ref:program() gets the whole tree
/type[ <at> name = 'String'] gets the String type
/function[ <at> name ='match']"/> gets the match() function
(but remember that there are _two_ String.match() functions!)
the reflection tree looks roughly this:
<type name="TypeName">
<parent name="TypeName"/> *
<function name="FunctionName"> *
<param type="TypeName"/> *
</function>
</type>
so types can be selected based on parent types, functions based on
parameters and parameter types.
(Continue reading)
RSS Feed