[Laszlo-checkins] r9429 - openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler

hqm@openlaszlo.org hqm at openlaszlo.org
Mon Jun 2 05:41:19 PDT 2008


Author: hqm
Date: 2008-06-02 05:41:15 -0700 (Mon, 02 Jun 2008)
New Revision: 9429

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
Log:
Change 20080601-hqm-o by hqm at badtzmaru.home on 2008-06-01 21:48:11 EDT
    in /Users/hqm/openlaszlo/trunk4
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: add new 'node' type for attributes

New Features: 

Bugs Fixed: LPP-5799

Technical Reviewer: ptw
QA Reviewer: max
Doc Reviewer: dtemkin

Documentation:

You can declare an attribute with the new LZX type 'node', which means that it is acceptable
to have a named child with that attribute name. For example:

<class name="myclass">
   <attribute name="titleview" type="node"/>
</class>

<myclass>
  <view name="titleview"/> <!-- this is fine, will not give warning -->
  <view name="source"/>  <!-- this overrides a non-node-type attribute, and will give a warning -->
</myclass>


Release Notes:


Details:

Tests:

<canvas>
  <class name="myclass">
    <attribute name="titleview" type="node"/>
  </class>

  <myclass>
    <!-- should be no warning for this, it's a node-type attribute -->
    <view name="titleview"/> 

    <!-- should get warning for this, about ndoe name conflicting with 'source' attribute -->
    <view name="source"/>
  </myclass>
</canvas>




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-06-02 10:34:04 UTC (rev 9428)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java	2008-06-02 12:41:15 UTC (rev 9429)
@@ -1139,9 +1139,8 @@
         String allocation = child.getAttributeValue("allocation", ALLOCATION_INSTANCE);
 
         if (attrName != null) {
-          AttributeSpec attrSpec = schema.getClassAttribute ( parentName, attrName, allocation) ;
-            // Only warn if the attribute we are shadowing has a declared initial value.
-            if (attrSpec != null && attrSpec.defaultValue != null) {
+          AttributeSpec attrSpec = schema.getClassAttribute ( parentName, attrName, allocation );
+            if (attrSpec != null && attrSpec.type != ViewSchema.NODE_TYPE) {
                 // TODO [2007-09-26 hqm] i18n this
                 env.warn(
                     "Child tag '" + child.getName() +
@@ -1567,7 +1566,9 @@
                 if (when.equals(WHEN_IMMEDIATELY)) {
                     value = ScriptCompiler.quote(value);
                 }
-            } else if ((type == ViewSchema.EXPRESSION_TYPE) || (type == ViewSchema.BOOLEAN_TYPE)) {
+            } else if ((type == ViewSchema.EXPRESSION_TYPE) ||
+                       (type == ViewSchema.BOOLEAN_TYPE) ||
+                       (type == ViewSchema.NODE_TYPE)) {
                 // No change currently, possibly analyze expressions
                 // and default non-constant to when="once" in the
                 // future

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java	2008-06-02 10:34:04 UTC (rev 9428)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java	2008-06-02 12:41:15 UTC (rev 9429)
@@ -62,27 +62,28 @@
     public boolean enforceValidIdentifier = false;
 
     /** Type of script expressions. */
-    public static final Type EXPRESSION_TYPE = newType("expression");
+    public static final Type EXPRESSION_TYPE          = newType("expression");
 
     /** 'boolean' is compiled the same as an expression type */
-    public static final Type BOOLEAN_TYPE = newType("boolean");
+    public static final Type BOOLEAN_TYPE             = newType("boolean");
 
-    public static final Type REFERENCE_TYPE = newType("reference");
+    public static final Type REFERENCE_TYPE           = newType("reference");
     /** Type of event handler bodies. */
-    public static final Type EVENT_HANDLER_TYPE = newType("script");
+    public static final Type EVENT_HANDLER_TYPE       = newType("script");
 
     /** Type of attribute setter function */
-    public static final Type SETTER_TYPE = newType("setter");
+    public static final Type SETTER_TYPE              = newType("setter");
 
     /** Type of tokens. */
-    public static final Type TOKEN_TYPE = newType("token");
-    public static final Type COLOR_TYPE = newType("color");
-    public static final Type NUMBER_EXPRESSION_TYPE = newType("numberExpression");
-    public static final Type SIZE_EXPRESSION_TYPE = newType("size");
-    public static final Type CSS_TYPE = newType("css");
+    public static final Type TOKEN_TYPE               = newType("token");
+    public static final Type COLOR_TYPE               =  newType("color");
+    public static final Type NUMBER_EXPRESSION_TYPE   = newType("numberExpression");
+    public static final Type SIZE_EXPRESSION_TYPE     = newType("size");
+    public static final Type CSS_TYPE                 = newType("css");
     public static final Type INHERITABLE_BOOLEAN_TYPE = newType("inheritableBoolean");
-    public static final Type XML_LITERAL = newType("xmlLiteral");
-    public static final Type METHOD_TYPE = newType("method");
+    public static final Type XML_LITERAL              = newType("xmlLiteral");
+    public static final Type METHOD_TYPE              = newType("method");
+    public static final Type NODE_TYPE                = newType("node");
     
     static {
 



More information about the Laszlo-checkins mailing list