[Laszlo-checkins] r11056 - openlaszlo/trunk/WEB-INF/lps/server/bin
dda@openlaszlo.org
dda at openlaszlo.org
Wed Sep 17 19:38:14 PDT 2008
Author: dda
Date: 2008-09-17 19:38:06 -0700 (Wed, 17 Sep 2008)
New Revision: 11056
Modified:
openlaszlo/trunk/WEB-INF/lps/server/bin/convert_laszlo.pl
Log:
Change 20080908-dda-I by dda at lester.local on 2008-09-08 14:58:01 EDT
in /Users/dda/laszlo/src/svn/openlaszlo/trunk-c
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Fix conversion script for apply
New Features:
Bugs Fixed: LPP-6947 (Conversion script mishandling "onapply")
Technical Reviewer: ptw (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
x.onapply="..." is no longer converted to x.onapplied="...."
Also, by default, x.apply()/x.remove() is not converted to x.setAttribute("applied", true/false);
per Tucker's review comment. But kept this transform available as an option.
Added a -a option to allow (nondefault) transforms to be added, and named the one for
apply/remove calls to be 'applycall'. So -a applycall turns on the transform to give
the old behavior. See hte Tests below.
Tests:
# Note that xxx.apply() is NOT changed in this first test.
$ cat /tmp/foo.lzx
xxx.apply="goahead"
xxx.onapply="donotchange"
xxx.apply() // maybe
xxx.onapply() // no
$ perl $LPS_HOME/WEB-INF/lps/server/bin/convert_laszlo.pl foo.lzx
$ cat /tmp/foo.lzx
xxx.applied="goahead"
xxx.onapply="donotchange"
xxx.apply() // maybe
xxx.onapply() // no
# Note that xxx.apply() IS changed in this first test.
$ cp /tmp/foo.lzx{.bak,} # restore original test case above
$ perl $LPS_HOME/WEB-INF/lps/server/bin/convert_laszlo.pl -a applycall foo.lzx
$ cat /tmp/foo.lzx
xxx.applied="goahead"
xxx.onapply="donotchange"
xxx.setAttribute('applied', true) // maybe
xxx.onapply() // no
Modified: openlaszlo/trunk/WEB-INF/lps/server/bin/convert_laszlo.pl
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/bin/convert_laszlo.pl 2008-09-17 22:44:15 UTC (rev 11055)
+++ openlaszlo/trunk/WEB-INF/lps/server/bin/convert_laszlo.pl 2008-09-18 02:38:06 UTC (rev 11056)
@@ -56,9 +56,14 @@
setattribute - setVisible -> setAttribute('visible', ...) etc.
widthheight - getWidth(),getHeight() to width,height
tagname - constructor.classname to constructor.tagname
- states - apply=" -> applied=", state.apply()/remove() -> setAttribute('applied', true|false)
+ states - apply=" -> applied="
+ applycall - state.apply()/remove() -> setAttribute('applied', true|false)
proxymethods - Lz.setCanvasAttribute()/callMethod() -> lz.embed.*
+ -a applylist
+ applylist is a comma separated list of transforms to apply,
+ chosen from the same list above
+
-v
show version number and exit
@@ -79,14 +84,16 @@
################
##
-# These are the transforms we'll do, these are turned off by the -x option.
+# These are the transforms in their default state,
+# these are turned off/on by the -x/-a options.
##
%xform = {};
$xform{method}=1; # transform <method event=
$xform{setattribute}=1; # transform calls like setVisible into setAttribute(...
$xform{widthheight}=1; # transform getWidth(),getHeight() to width,height
$xform{tagname}=1; # transform constructor.classname to constructor.tagname
-$xform{states}=1; # transform apply=" -> applied=", state.apply()/remove() -> setAttribute('applied', true|false)
+$xform{states}=1; # transform apply=" -> applied="
+$xform{applycall}=0; # transform state.apply()/remove() -> setAttribute('applied', true|false)
$xform{proxymethods}=1; # transform Lz.setCanvasAttribute()/callMethod() -> lz.embed.*
##
@@ -323,11 +330,18 @@
#### transform states
#
- # apply=" -> applied=", state.apply()/remove() -> setAttribute('applied', true|false)
+ # apply=" -> applied="
if ($xform{states}) {
- s/apply="/applied="/g;
- # May cause problems with function.apply() but what can you do?
+ s/\bapply="/applied="/g;
+ }
+
+ #### transform apply calls
+ # This is not done by default
+ # May cause problems with function.apply()
+ #
+ # state.apply()/remove() -> setAttribute('applied', true|false)
+ if ($xform{applycall}) {
s/\.apply\(\w*?\)/.setAttribute('applied', true)/g;
s/\.remove\(\w*?\)/.setAttribute('applied', false)/g;
}
@@ -426,7 +440,7 @@
##
my $file;
my %options;
-$ok = getopts("d:tx:vg:", \%options);
+$ok = getopts("d:tx:a:vg:", \%options);
if (!$ok) {
print STDERR "$USAGE";
exit(1);
@@ -445,6 +459,18 @@
$xform{$xval} = 0;
}
+my $aopt = $options{a} || '';
+my @avalues = split(',', $aopt);
+foreach my $aval (@avalues) {
+ if (!exists $xform{$aval}) {
+ print STDERR "$aval: unknown transform\n";
+ print STDERR "$USAGE";
+ exit(1);
+ }
+ print STDOUT "Turning on $aval\n";
+ $xform{$aval} = 1;
+}
+
if ($options{v}) {
print STDOUT "$PROG: version $VERSION\n";
exit(0);
More information about the Laszlo-checkins
mailing list