[Laszlo-checkins] r10683 - in openlaszlo/trunk: WEB-INF/lps/server/src/org/openlaszlo/compiler lps/components/lz
hqm@openlaszlo.org
hqm at openlaszlo.org
Wed Aug 13 14:07:25 PDT 2008
Author: hqm
Date: 2008-08-13 14:07:22 -0700 (Wed, 13 Aug 2008)
New Revision: 10683
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
openlaszlo/trunk/lps/components/lz/gridcolumn.lzx
Log:
Change 20080813-hqm-V by hqm at badtzmaru-4.local on 2008-08-13 13:36:46 EDT
in /Users/hqm/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: make tag compiler hoist named children from states to parent as swf9 declarations
New Features:
Bugs Fixed: LPP-6741
Technical Reviewer: ptw
QA Reviewer: pbr
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
When building the NodeModel, if any children of a node are <state> or subclass of <state>,
recursively find any named nodes in them, and declare those as attributes of the NodeModel,
so that they get declared as instance vars in swf9. Note that this applies to nested
states, e.g. 'foobar' below will be declared as an attribute in the parent view,
<view name="parent">
<state>
<state>
<state>
<view name="foobar"/>
.
This allows them to be referenced without prefixing them with "this.xxx", which is what
code in grid component expects, an probably in other people's code as well.
Tests:
examples/components/grid_example swf9
examples/components/components_example swf9
smokecheck swf8,dhtml
Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java 2008-08-13 20:45:44 UTC (rev 10682)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java 2008-08-13 21:07:22 UTC (rev 10683)
@@ -511,6 +511,13 @@
if (includeChildren) {
model.addChildren(env);
+
+ // If any children are subclasses of <state>, recursively
+ // hoist named children up in order to declare them so
+ // they can be referenced as vars without a 'this.---" prefix.
+ if (!isState(model, schema)) {
+ model.addStateChildren(env);
+ }
model.addText();
if (!attrs.containsKey("clickable")
&& computeDefaultClickable(schema, attrs, delegates)) {
@@ -1192,6 +1199,72 @@
}
}
+ void addStateChildren(CompilationEnvironment env ) {
+ // Check for each child, if it is a subclass of <state>.
+ // If so, we need to declare any named children as attributes,
+ // so the swf9 compiler won't complain about references to them.
+ for (Iterator iter = children.iterator(); iter.hasNext(); ) {
+ NodeModel childModel = (NodeModel)iter.next();
+ if (isState(childModel, schema)) {
+ declareNamedChildren(childModel);
+ }
+ }
+ }
+
+ /** Is this NodeModel a <state> or subclass of <state> ? */
+ static boolean isState(NodeModel model, ViewSchema schema) {
+ ClassModel classModel = model.getClassModel();
+ boolean isstate = classModel.isSubclassOf(schema.getClassModel("state"));
+ return isstate;
+ }
+
+ /** Hoist named children declarations from a state into the parent.
+
+ Take all named children of this NodeModel (including named children
+ in the classmodel) and declare them as attributes, so the swf9
+ compiler will permit references to them at compile time.
+ */
+ void declareNamedChildren(NodeModel model) {
+ List childnames = collectNamedChildren(model);
+ for (Iterator i = childnames.iterator(); i.hasNext(); ) {
+ String childname = (String)i.next();
+ if (!attrs.containsKey(childname)) {
+ addProperty(childname, null, ALLOCATION_INSTANCE);
+ }
+ }
+ }
+
+ // Returns a list of names of all named children of this instance and
+ // those of its superclasses
+ List collectNamedChildren(NodeModel model) {
+ List names = new ArrayList();
+ // iterate over children, getting named ones. If a child is a <state>, recurse into it to
+ // hoist any named children up.
+ for (Iterator iter = model.children.iterator(); iter.hasNext(); ) {
+ NodeModel child = (NodeModel) iter.next();
+ if (isState(child,schema)) {
+ List childnames = collectNamedChildren(child);
+ // merge in returned list with names
+ names.addAll(childnames);
+ } else {
+ String childNameAttr = child.element.getAttributeValue("name");
+ if (childNameAttr != null) {
+ names.add(childNameAttr);
+ }
+ }
+ }
+ // Then recurse over superclasses, up to <state>
+ ClassModel classModel = model.getClassModel();
+ if (classModel.hasNodeModel()) {
+ List supernames = collectNamedChildren(classModel.nodeModel);
+ // merge in returned list with names
+ names.addAll(supernames);
+ }
+ return names;
+ }
+
+
+
void warnIfHasChildren(Element element) {
if (element.getChildren().size() > 0) {
CompilationError cerr = new CompilationError(
Modified: openlaszlo/trunk/lps/components/lz/gridcolumn.lzx
===================================================================
--- openlaszlo/trunk/lps/components/lz/gridcolumn.lzx 2008-08-13 20:45:44 UTC (rev 10682)
+++ openlaszlo/trunk/lps/components/lz/gridcolumn.lzx 2008-08-13 21:07:22 UTC (rev 10683)
@@ -12,9 +12,6 @@
<!--- If set to false, the column cannot be resized. -->
<attribute name="resizable" value="true" type="boolean"/>
- <attribute name="mybutton" value="null"/>
- <attribute name="resizer" value="null"/>
-
<!--- If true, the column header is clickable and will initiate a
sort -->
<attribute name="sortable" type="boolean" value="true"/>
More information about the Laszlo-checkins
mailing list