[Laszlo-checkins] r8558 - openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler
ptw@openlaszlo.org
ptw at openlaszlo.org
Sat Apr 5 04:11:21 PDT 2008
Author: ptw
Date: 2008-04-05 04:11:14 -0700 (Sat, 05 Apr 2008)
New Revision: 8558
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
Log:
Change 20080404-ptw-8 by ptw at dueling-banjos.local on 2008-04-04 18:39:11 EDT
in /Users/ptw/OpenLaszlo/ringding-clean
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Finish instance classes
Bugs Fixed:
LPP-5625 'Implement instances with methods as singleton classes'
Technical Reviewer: hminsky (Message-ID: <8c61fad60804041906n66d150d5hf14d8e14c69be9be at mail.gmail.com>)
QA Reviewer: danderson (pending)
Details:
Just compile the instance as a class without any arguments. You
didn't really need to preserve _instanceAttrs after all.
Tests:
smokecheck, amazon
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-04-04 22:44:12 UTC (rev 8557)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java 2008-04-05 11:11:14 UTC (rev 8558)
@@ -1838,40 +1838,8 @@
assert classAttrs.isEmpty();
Map map = new LinkedHashMap();
String tagName = className;
- // Emit a class declaration to hold the methods, but for
- // compatibility with many construct methods, leave all
- // the non-methods in the attrs list...
- // TODO: [2008-04-02 ptw] Someday clean this up so that we
- // don't have to send so damn many Object's just to cons
- // up a view.
- boolean hasMethods = false;
- Map inits = new LinkedHashMap();
- // Node as map just wants to see all the attrs, so clean out
- // the binding markers
- for (Iterator i = attrs.entrySet().iterator(); i.hasNext(); ) {
- Map.Entry entry = (Map.Entry) i.next();
- String key = (String) entry.getKey();
- Object value = entry.getValue();
- if (value instanceof NodeModel.BindingExpr) {
- inits.put(key, ((NodeModel.BindingExpr)value).getExpr());
- } else if (! (value instanceof Function)) {
- inits.put(key, value);
- } else {
- hasMethods = true;
- }
- }
- if (hasMethods) {
- // We have to remove the attributes that have been
- // converted to inits so things like constraints don't get
- // installed twice.
- // TODO: [2008-04-03 ptw] This is a descructive operation
- // on the model, so the model is invalid after this. This
- // should be ok, since it should not be consulted once the
- // code is generated; but it would be safer to make this
- // non-destructive.
- for (Iterator i = inits.keySet().iterator(); i.hasNext(); ) {
- attrs.remove(i.next());
- }
+ if (hasMethods()) {
+ // If there are methods, make a class
String name = id;
if (name == null) {
name = CompilerUtils.attributeUniqueName(element, "class");
@@ -1882,15 +1850,27 @@
classModel.setNodeModel(this);
classModel.emitClassDeclaration(env);
} else {
+ // Node as map just wants to see all the attrs, so clean out
+ // the binding markers
+ Map inits = new LinkedHashMap();
+ for (Iterator i = attrs.entrySet().iterator(); i.hasNext(); ) {
+ Map.Entry entry = (Map.Entry) i.next();
+ String key = (String) entry.getKey();
+ Object value = entry.getValue();
+ if (! (value instanceof NodeModel.BindingExpr)) {
+ inits.put(key, value);
+ } else {
+ inits.put(key, ((NodeModel.BindingExpr)value).getExpr());
+ }
+ }
+ if (!inits.isEmpty()) {
+ map.put("attrs", inits);
+ }
if (!children.isEmpty()) {
map.put("children", childrenMaps());
}
}
- if (!attrs.isEmpty()) {
- map.put("attrs", inits);
- }
-
// The tag to instantiate
// TODO: [2008-04-01 ptw] we could have a flag day and put the
// class here, eliminating having to go through the
More information about the Laszlo-checkins
mailing list