On 2008-06-30, at 18:21 EDT, Donald Anderson wrote:
Here's the perl script (attached). I tried to upload it to the
Runtime_Differences page,
but it looks like I can only update .gif/.jpeg files. Any advice
about where to put it?
The other conversion script is in WEB-INF/lps/server/bin (not that
that is the right place, but it is where lzc and other scripts are, so
should already be in the search path of most developers who will need
this script).
I think I got all the cases:
- if the class name already has lz. , no change
Correct.
- 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`.
- if the class name is class for a LFC tagname, convert it to
tagname and add lz. (new LzView => lz.view)
I coded my list from WEB-INF/lps/server/src/org/openlaszlo/
compiler/ClassModel.java
Optional, but good practice.
- if the class name is a known laszlo class, then add lz.
I have a fixed list embedded in the script, generated via
find WEB-INF/lps | xargs grep class
No. Only LFC classes that implement LZX tags should be converted, and
that is covered by the previous step.
[Detail: Script class definitions _do_ create global definitions.
Eventually we will want these in a laszlo namespace, but that will be
by `use namespace` or something. Certain LFC script classes implement
tags and are entered into the `lz` namespace by hand in the LFC.
E.g., if you look at the bottom of the file defining LzView, you will
see:
lz[LzView.tagname] = LzView;
That little bit of glue attaches the LFC implementation to the LZX
interface.]
- new global[*] is converted to new lz[*]
Correct, unless the user code is doing something really tricky.
Perhaps the script should announce when it is making this transform,
as it should be manually verified.
- otherwise, no change (this includes Object, Array, ...).
Correct.
Let me know if there are any changes, should be easy to modify.
Script includes a testcase to try all these situations.
Once the above fixes are made, how about sending out a regular review
request. Perhaps Sebastian would like to be one of the reviewers.
- Don
<convert_instantiation.pl>
On Jun 30, 2008, at 3:01 PM, P T Withington wrote:
One flaw in thus idea: many times the argument to new will be a
parameter of the class, so you have to skip all the class
attributes too. That may make searching for only the defined class
names a better choice of algorithm.
On Jun 30, 2008, at 13:59, P T Withington <[EMAIL PROTECTED]> wrote:
The only 'native' classes that you might say `new *` or `x
instanceof *` about are:
Object, Array, String, Number, or Boolean.
So we should be able to add to the conversion script that if you
see `new *` or `x instanceof *` and * does not start with lz. and
is not one of the five native classes above, you should rewrite it
to lz.*.
We also need to cover the case `new global[*]` needs to become
`new lz[*]`.
Icing on the cake would be to replace instances of the LFC class
names with their tagname, e.g., (LzView becomes lz.view).
--
Don Anderson
Java/C/C++, Berkeley DB, systems consultant
voice: 617-547-7881
email: [EMAIL PROTECTED]
www: http://www.ddanderson.com