On 2008-07-01, at 08:32 EDT, Donald Anderson wrote:
- if the class name is a class defined in the input, then add
lz. (?) [requires two passes]
Correct. All LZX classes defined with <class name="foo"... must be
referenced as lz.foo in `new` and `instanceof`.
I'm a little confused. I thought this script only converted .lzs
files.
It sounds like the script operates on and converts both, but we
should only collect the class names
I see in LZX on the first pass. ??
Yes the script is for LZX files. Yes the script should accumulate
class names in first pass (by looking for <class name="...", probably
also <interface name="...", just in case). But you can't just replace
class names with lz.<name> everywhere. You should only replace it
when they are an operand of a `new` or `instanceof` operator.
Why? Because in the old days, <class name="foo" ... defined both a
tag 'foo' and a class 'foo'. Now, we separate those two concepts.
In LZX you can create an instance of an LZX class either by using the
tag in declarative code:
<foo />
_or_ by using `new` and the class in script:
<method ...>
new ¿foo? ;
</method>
You used to say `new foo`, but now the actual class is (effectively)
in a private namespace, so that it won't clutter up the global
namespace. Instead, we build a mapping from tag name to class, so
that you can get at the class that implements a tag by saying
`lz['foo']` (which for a constant tag can be abbreviated `lz.foo`).
But!
A common idiom in components was to say:
<class name="complex">
<attribute name="subviewClass" type="String" />
<method ...>
new global[subviewClass](...);
</method>
In this case, `subviewClass` _really_ meant subviewTag. The user
would pass the tag name (as a string) for the type of subview they
wanted. So you would invoke it:
<complex subviewClass="text" />
In the new world, all you want to do is change `global` to `lz`. You
don't want to change `text` to `lz.text`.