[Laszlo-checkins] r9030 - in openlaszlo/trunk: WEB-INF/lps/schema WEB-INF/lps/server/src/org/openlaszlo/compiler WEB-INF/lps/server/src/org/openlaszlo/xml/internal test/lztest

hqm@openlaszlo.org hqm at openlaszlo.org
Wed May 7 09:21:23 PDT 2008


Author: hqm
Date: 2008-05-07 09:21:16 -0700 (Wed, 07 May 2008)
New Revision: 9030

Added:
   openlaszlo/trunk/test/lztest/lztest-static-attrs.lzx
Removed:
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/xml/internal/XMLCompiler.java
Modified:
   openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/AttributeSpec.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassCompiler.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema_Test.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/xml/internal/Schema.java
   openlaszlo/trunk/test/lztest/rhino.txt
   openlaszlo/trunk/test/lztest/smoketest.txt
Log:
Change 20080506-hqm-O by hqm at badtzmaru.home on 2008-05-06 18:48:10 EDT
    in /Users/hqm/openlaszlo/trunk5
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: allocation of static properties for lzx classes

New Features:

Bugs Fixed: LPP-5933

Technical Reviewer: ptw
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
    

Tests:

lztest, amazon

added new test, lztest-static-attrs.lzx




Modified: openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx	2008-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx	2008-05-07 16:21:16 UTC (rev 9030)
@@ -17,16 +17,16 @@
 <interface name="Instance" extends="Object">
   <method name="validateClassStructure" final="true"/>
   <method name="initialize" />
+  <method name="addProperty" final="true" />
   <method name="nextMethod" final="true"/>
-  <method name="addProperty" final="true"/>
-  <method name="constructor" final="true"/>
-  <method name="hasOwnProperty" final="true"/>
+  <method name="constructor" final="true" />
+  <method name="hasOwnProperty" final="true" />
   <method name="isPropertyEnumerable" final="true"/>
   <method name="isPrototypeOf" final="true"/>
-  <method name="toLocaleString" final="true"/>
-  <method name="prototype" final="true"/>
-  <method name="apply" final="true"/> 
-  <method name="call" final="true"/>
+  <method name="toLocaleString" final="true" />
+  <method name="prototype" final="true" allocation="class"/>
+  <method name="apply" final="true" allocation="class"/> 
+  <method name="call" final="true" allocation="class"/>
 </interface>
 
 <interface name="canvas" extends="Instance">

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/AttributeSpec.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/AttributeSpec.java	2008-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/AttributeSpec.java	2008-05-07 16:21:16 UTC (rev 9030)
@@ -28,6 +28,12 @@
     /** When does the initial value for this attribute get evaluated? */
     String when = NodeModel.WHEN_IMMEDIATELY;
 
+    /**
+     * Is this property allocated on the instance or the class.
+     * Legal values are NodeModel.ALLOCATION_INSTANCE, and NodeModel.ALLOCATION_CLASS
+     */
+    String allocation = NodeModel.ALLOCATION_INSTANCE;
+
     /** If this is a method, the arglist */
     String arglist = null;
 
@@ -54,7 +60,7 @@
   }
 
   public String toLZX(String indent, ClassModel superclass) {
-    AttributeSpec superSpec = superclass.getAttribute(name);
+    AttributeSpec superSpec = superclass.getAttribute(name, allocation);
     if (ViewSchema.METHOD_TYPE.equals(type)) {
       return indent + "  <method name='" + name + "'" + (("".equals(arglist))?"":(" args='" + arglist +"'")) + " />";
     }
@@ -76,7 +82,7 @@
         attrs += " value='" + defaultValue + "'";
       }
       if (type != null &&
-          (! type.equals(superclass.getAttributeType(name)))) {
+          (! type.equals(superclass.getAttributeType(name, allocation)))) {
         attrs += " type='" + typeToLZX() + "'";
       }
       if (when != null &&
@@ -95,7 +101,7 @@
 
   public String toString() {
     if (ViewSchema.METHOD_TYPE.equals(type)) {
-      return "[AttributeSpec: method name='" + name + "'" + (("".equals(arglist))?"":(" args='" + arglist +"'")) + " isfinal="+(isfinal  == null ?  "null" : ("'"+isfinal+"'"))+"]";
+      return "[AttributeSpec: method name='" + name + "'" + (("".equals(arglist))?"":(" args='" + arglist +"'")) + " isfinal="+(isfinal  == null ?  "null" : ("'"+isfinal+"'"))+ " allocation="+allocation+"]";
     } 
     if (ViewSchema.EVENT_HANDLER_TYPE.equals(type)) {
       return "[AttributeSpec: event name='" + name + "' ]";
@@ -105,6 +111,7 @@
         ((type != null)?(" type='" + typeToLZX() + "'"):"") +
         ((when != NodeModel.WHEN_IMMEDIATELY)?(" when='" + when + "'"):"") + 
         (required?(" required='true'"):"") +
+      " allocation="+allocation+
         " ";
   }
     

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassCompiler.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassCompiler.java	2008-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassCompiler.java	2008-05-07 16:21:16 UTC (rev 9030)
@@ -60,6 +60,26 @@
         return element.getName().equals("class");
     }
 
+    /**
+     * Check that the 'allocation' attribute of a tag is either "instance" or "class".
+     * The return value defaults to "instance".
+     * @param element a method or attribute element
+     * @return an AttributeSpec allocation type (either 'instance' or 'class')
+     */
+    String getAllocation(Element element) {
+        // allocation type defaults to 'instance'
+        String allocation = element.getAttributeValue("allocation");
+        if (allocation == null) {
+            allocation = NodeModel.ALLOCATION_INSTANCE;
+        } else if (!(allocation.equals(NodeModel.ALLOCATION_INSTANCE) ||
+                     allocation.equals(NodeModel.ALLOCATION_CLASS))) {
+          throw new CompilationError(
+              "the value of the 'allocation' attribute must be either 'instance', or 'class'" , element);
+        }
+        return allocation;
+
+    }
+     
     /** Parse out an XML class definition, add the superclass and
      * attribute types to the schema.
      *
@@ -142,10 +162,12 @@
                                     "'name' is a required attribute of <" + child.getName() + "> and must be a valid identifier", child);
                             }
                         }
+                        String allocation = getAllocation(child);
                         ViewSchema.Type attrType = ViewSchema.METHOD_TYPE;
                         AttributeSpec attrSpec = 
                             new AttributeSpec(attrName, attrType, null, null, child);
                         attrSpec.isfinal = child.getAttributeValue("final");
+                        attrSpec.allocation = allocation;
                         attributeDefs.add(attrSpec);
                     }
                     
@@ -173,12 +195,13 @@
                     String attrDefault = child.getAttributeValue("default");
                     String attrSetter = child.getAttributeValue("setter");
                     String attrRequired = child.getAttributeValue("required");
+                    String allocation = getAllocation(child);
                     
                     ViewSchema.Type attrType;
                     if (attrTypeName == null) {
                         // Check if this attribute exists in ancestor classes,
                         // and if so, default to that type.
-                        attrType = superclassinfo.getAttributeType(attrName);
+                        attrType = superclassinfo.getAttributeType(attrName, allocation);
                         if (attrType == null) {
                             // The default attribute type
                             attrType = ViewSchema.EXPRESSION_TYPE;
@@ -202,6 +225,7 @@
                     AttributeSpec attrSpec = 
                         new AttributeSpec(attrName, attrType, attrDefault,
                                           attrSetter, child);
+                    attrSpec.allocation = allocation;
                     attrSpec.isfinal = child.getAttributeValue("final");
                     if (attrName.equals("text") && attrTypeName != null) {
                         if ("text".equals(attrTypeName))

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java	2008-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java	2008-05-07 16:21:16 UTC (rev 9030)
@@ -38,6 +38,7 @@
     protected boolean supportsTextAttribute = false;
     /** Map attribute name to type */
     protected final Map attributeSpecs = new LinkedHashMap();
+    protected final Map classAttributeSpecs = new LinkedHashMap();
 
     protected boolean inline = false;
     protected String sortkey = null;
@@ -180,7 +181,7 @@
       Map.Entry entry = (Map.Entry) i.next();
       String key = (String) entry.getKey();
       Object value = entry.getValue();
-      boolean redeclared = (superclassModel.getAttribute(key) != null);
+      boolean redeclared = (superclassModel.getAttribute(key, NodeModel.ALLOCATION_INSTANCE) != null);
       if ((value instanceof NodeModel.BindingExpr)) {
         // Bindings always have to be installed as an init
         if (! redeclared) {
@@ -197,7 +198,7 @@
       } else if (value != null) {
         // If this is a re-declared attribute, we just init it,
         // don't re-declare it
-        if (superclassModel.getAttribute(key) != null) {
+        if (superclassModel.getAttribute(key, NodeModel.ALLOCATION_INSTANCE) != null) {
           inits.put(key, value);
         }
         // If there is a setter for this attribute, or this is a
@@ -373,20 +374,26 @@
         Only returns locally defined attribute, does not follow up the
         class hierarchy.
     */
-    AttributeSpec getLocalAttribute(String attrName) {
-      return (AttributeSpec) attributeSpecs.get(attrName);
+    AttributeSpec getLocalAttribute(String attrName, String allocation) {
+      if (allocation.equals(NodeModel.ALLOCATION_INSTANCE)) {
+        return (AttributeSpec) attributeSpecs.get(attrName);
+      } else {
+        return (AttributeSpec) classAttributeSpecs.get(attrName);
+      }
     }
 
+
     /** Return the AttributeSpec for the attribute named attrName.  If
      * the attribute is not defined on this class, look up the
      * superclass chain.
      */
-    AttributeSpec getAttribute(String attrName) {
-        AttributeSpec attr = (AttributeSpec) attributeSpecs.get(attrName);
+  AttributeSpec getAttribute(String attrName, String allocation) {
+        Map attrtable = allocation.equals(NodeModel.ALLOCATION_INSTANCE) ? attributeSpecs : classAttributeSpecs;
+        AttributeSpec attr = (AttributeSpec) attrtable.get(attrName);
         if (attr != null) {
             return attr;
         } else if (superclass != null) {
-            return(superclass.getAttribute(attrName));
+          return(superclass.getAttribute(attrName, allocation));
         } else {
             return null;
         }
@@ -413,10 +420,10 @@
         }
     }
 
-    ViewSchema.Type getAttributeTypeOrException(String attrName)
+  ViewSchema.Type getAttributeTypeOrException(String attrName, String allocation)
         throws UnknownAttributeException
     {
-        AttributeSpec attr = getAttribute(attrName);
+      AttributeSpec attr = getAttribute(attrName, allocation);
         if (attr != null) {
             return attr.type;
         }  
@@ -430,8 +437,8 @@
         return type;
     }
     
-    ViewSchema.Type getAttributeType(String attrName) {
-        AttributeSpec attr = getAttribute(attrName);
+    ViewSchema.Type getAttributeType(String attrName, String allocation) {
+        AttributeSpec attr = getAttribute(attrName, allocation);
         if (attr != null) {
             return attr.type;
         }  

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-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java	2008-05-07 16:21:16 UTC (rev 9030)
@@ -563,7 +563,7 @@
         // TODO: [2008-05-05 ptw] Schema needs to learn about
         // allocation
         assert ALLOCATION_INSTANCE.equals(allocation);
-        return schema.getAttributeType(parent, attrname);
+        return schema.getAttributeType(parent, attrname, allocation);
     }
 
     ViewSchema.Type getAttributeTypeInfoFromParent(
@@ -597,14 +597,14 @@
 
         // Check if this attribute is defined on the parent class, if
         // so, return that type
-        AttributeSpec attr = superclassModel.getAttribute(attrname);
+        AttributeSpec attr = superclassModel.getAttribute(attrname, allocation);
         if (attr != null) {
             return attr.type;
         }
         // Otherwise, check if it's defined on the "class" element
         // (e.g., 'name', 'extends', or 'with')
         superclassModel = schema.getClassModel("class");
-        return superclassModel.getAttributeTypeOrException(attrname);
+        return superclassModel.getAttributeTypeOrException(attrname, allocation);
     }
 
     ViewSchema.Type getAttributeTypeInfoFromSuperclass(
@@ -626,7 +626,7 @@
         // Look for an inherited value
         if (this.parentClassModel != null) {
             AttributeSpec attrSpec =
-                this.parentClassModel.getAttribute(attribute);
+              this.parentClassModel.getAttribute(attribute, allocation);
             if (attrSpec != null) {
                 Element source = attrSpec.source;
                 if (source != null) {
@@ -859,7 +859,7 @@
                     // Special case for "state", it can have any attribute
                     // which belongs to the parent. 
                     try {
-                        type = schema.getAttributeType(element, name);
+                      type = schema.getAttributeType(element, name, ALLOCATION_INSTANCE);
                     } catch (UnknownAttributeException e) {
                         type = getAttributeTypeInfoFromParent(element, name);
                     }
@@ -870,7 +870,7 @@
                     // width and height!
                     // NOTE: [2008-05-05 ptw] These are instance
                     // attributes by definition
-                    type = schema.getAttributeType(element, name);
+                  type = schema.getAttributeType(element, name, ALLOCATION_INSTANCE);
                 }
 
             } catch (UnknownAttributeException e) {
@@ -1139,8 +1139,10 @@
      */
     void checkChildNameConflict(String parentName, Element child, CompilationEnvironment env) {
         String attrName = child.getAttributeValue("name");
+        String allocation = child.getAttributeValue("allocation", ALLOCATION_INSTANCE);
+
         if (attrName != null) {
-            AttributeSpec attrSpec = schema.getClassAttribute ( parentName, attrName) ;
+          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) {
                 // TODO [2007-09-26 hqm] i18n this
@@ -1355,6 +1357,7 @@
     void addMethodElement(Element element) {
         String name = element.getAttributeValue("name");
         String event = element.getAttributeValue("event");
+        String allocation = XMLUtils.getAttributeValue(element, "allocation", ALLOCATION_INSTANCE);
         String args = CompilerUtils.attributeLocationDirective(element, "args") +
             XMLUtils.getAttributeValue(element, "args", "");
         String body = element.getText();
@@ -1406,10 +1409,10 @@
             return;
         }
 
-        addMethodInternal(name, args, body, element);
+        addMethodInternal(name, args, body, element, allocation);
     }
 
-    void addMethodInternal(String name, String args, String body, Element element) {
+  void addMethodInternal(String name, String args, String body, Element element, String allocation) {
         String srcloc = CompilerUtils.sourceLocationDirective(element, true);
         ClassModel superclassModel = getParentClassModel();
         // Override will be required if there is an inherited method
@@ -1417,14 +1420,13 @@
         boolean override = 
             // This gets methods from the schema, in particular, the
             // LFC interface
-            superclassModel.getAttribute(name) != null ||
+          superclassModel.getAttribute(name, allocation) != null ||
             // This gets methods the compiler has added, in
             // particular, setter methods
             superclassModel.getMergedMethods().containsKey(name) ||
             // And the user may know better than any of us
             "true".equals(element.getAttributeValue("override"));
         boolean isfinal = "true".equals(element.getAttributeValue("final"));
-        String allocation = XMLUtils.getAttributeValue(element, "allocation", ALLOCATION_INSTANCE);
 
         if (!override) {
             // Just check method declarations on regular node.
@@ -1718,18 +1720,20 @@
 
         // Class methods are not inherited, hence do not override
         if (ALLOCATION_INSTANCE.equals(allocation)) {
-          AttributeSpec parentAttrSpec = schema.getAttributeSpec(parent.getName(), name);
+          AttributeSpec parentAttrSpec = schema.getAttributeSpec(parent.getName(), name, allocation);
           forceOverride = parentAttrSpec != null && "false".equals(parentAttrSpec.isfinal);
         }
 
         try {
             if ("class".equals(className) || "interface".equals(className)) {
-              parenttype = getAttributeTypeInfoFromSuperclass(parent, name, allocation);
+              if (allocation.equals(ALLOCATION_INSTANCE)) {
+                parenttype = getAttributeTypeInfoFromSuperclass(parent, name, allocation);
+              }
             }  else {
               // TODO: [2008-05-05 ptw] Schema needs to learn about
               // allocation
               assert ALLOCATION_INSTANCE.equals(allocation);
-              parenttype = schema.getAttributeType(parent, name);
+              parenttype = schema.getAttributeType(parent, name, allocation);
             }
         } catch (UnknownAttributeException e) {
             // If attribute type is not defined on parent, leave
@@ -1819,7 +1823,8 @@
                 name,
                 // The body of the setter method
                 setter,
-                element);
+                element,
+                allocation);
 
             // This is just for nice error messages
             if (setters.get(name) != null) {

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-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java	2008-05-07 16:21:16 UTC (rev 9030)
@@ -156,7 +156,8 @@
                 ViewSchema.class.getName(),"051018-168", new Object[] {classname})
             );
         }
-        if (classModel.attributeSpecs.get(attrName) != null) {
+        if (classModel.getLocalAttribute(attrName, attrspec.allocation) != null) {
+            AttributeSpec conf = classModel.getLocalAttribute(attrName, attrspec.allocation);
             throw new CompilationError(
 /* (non-Javadoc)
  * @i18n.test
@@ -166,7 +167,11 @@
                 ViewSchema.class.getName(),"051018-178", new Object[] {classname, attrName})
                 , elt);
         }
-        classModel.attributeSpecs.put(attrName, attrspec);
+        if (attrspec.allocation.equals(NodeModel.ALLOCATION_INSTANCE)) {
+            classModel.attributeSpecs.put(attrName, attrspec);
+        } else {
+            classModel.classAttributeSpecs.put(attrName, attrspec);
+        }
 
         if (attrName.equals("text")) {
             classModel.supportsTextAttribute = true;
@@ -179,6 +184,7 @@
      * Does the superclass allow overriding of this method?
      */
     public void checkMethodDeclaration (Element elt, String classname, String methodName,
+                                        String allocation,
                                         CompilationEnvironment env) {
         ClassModel classModel = getClassModel(classname);
         if (classModel == null) {
@@ -191,7 +197,7 @@
                 ViewSchema.class.getName(),"051018-168", new Object[] {classname})
                                        );
         }
-        AttributeSpec localAttr = classModel.getLocalAttribute(methodName);
+        AttributeSpec localAttr = classModel.getLocalAttribute(methodName, allocation);
         if ( localAttr != null) {
             if (localAttr.type == METHOD_TYPE) {
                 env.warn(
@@ -210,7 +216,7 @@
             }
         }
 
-        if (!methodOverrideAllowed(classname, methodName)) {
+        if (!methodOverrideAllowed(classname, methodName, allocation)) {
             env.warn("Method "+classname+"."+methodName+" is overriding a superclass method"
                      + " of the same name which has been declared final" , elt);
         }
@@ -233,7 +239,7 @@
                 ViewSchema.class.getName(),"051018-168", new Object[] {classname})
                                        );
         }
-        AttributeSpec attrspec = classModel.getAttribute(methodName);
+        AttributeSpec attrspec = classModel.getAttribute(methodName, NodeModel.ALLOCATION_INSTANCE);
         if ( attrspec != null) {
             if (attrspec.type != METHOD_TYPE) {
                 env.warn(
@@ -243,7 +249,7 @@
             }
         }
 
-        if (!methodOverrideAllowed(classname, methodName)) {
+        if (!methodOverrideAllowed(classname, methodName, NodeModel.ALLOCATION_INSTANCE)) {
             env.warn("Method "+classname+"."+methodName+" is overriding a superclass method"
                      + " of the same name which has been declared final" , elt);
         }
@@ -280,14 +286,19 @@
         return superclass;
     }
 
-    /** Does this class or its ancestors have this attribute declared for it? */
-    AttributeSpec getClassAttribute (String classname, String attrName) {
+    /** Get the AttributeSpec for an attribute named ATTRNAME, on class CLASNAME.
+     * Default to 'instance' allocation type
+     * @param classname the name of the class
+     * @param attrName the name of the attribute
+     * @param allocation 'class' or 'instance'
+     */
+    AttributeSpec getClassAttribute (String classname, String attrName, String allocation) {
         // OK, walk up the superclasses, checking for existence of this attribute
         ClassModel info = getClassModel(classname);
         if (info == null) {
             return null;
         } else {
-            return info.getAttribute(attrName);
+            return info.getAttribute(attrName, allocation);
         }
     }
 
@@ -299,7 +310,7 @@
      * @param attributeDefs list of attribute name/type defs
      */
     public void addElement (Element elt, String className,
-                            String superclassName, List attributeDefs,
+                            String superclassName, List attributeDefs, 
                             CompilationEnvironment env)
     {
         ClassModel superclass = getClassModel(superclassName);
@@ -405,13 +416,13 @@
                 // different type.
 
                 Type parentType = null;
-                if (getClassAttribute(classname, attr.name) != null) {
+                if (getClassAttribute(classname, attr.name, attr.allocation) != null) {
                     // Check that the overriding type is the same as the superclass' type
-                    parentType = getAttributeType(classname, attr.name);
+                    parentType = getAttributeType(classname, attr.name, attr.allocation);
 
                     // Does the parent attribute definition have final=false or final=null?
                     // If not, we're not going to warn if the types mismatch.
-                    AttributeSpec parentAttrSpec = getAttributeSpec(classname, attr.name);
+                    AttributeSpec parentAttrSpec = getAttributeSpec(classname, attr.name, attr.allocation);
                     boolean forceOverride = parentAttrSpec != null && (! "true".equals(parentAttrSpec.isfinal));
 
                     if (!forceOverride &&  (parentType != attr.type)) {
@@ -428,7 +439,7 @@
                 }
 
                 if (attr.type == ViewSchema.METHOD_TYPE && !("false".equals(attr.isfinal))) {
-                    checkMethodDeclaration(sourceElement, classname, attr.name, env);
+                    checkMethodDeclaration(sourceElement, classname, attr.name, attr.allocation, env);
                 }
 
                 // Update the in-memory attribute type table
@@ -472,8 +483,8 @@
      * @param attrName an attribute name
      * @return a value represting the type of the attribute's
      */
-    public Type getAttributeType(Element e, String attrName) {
-        return getAttributeType(e.getName(), attrName);
+    public Type getAttributeType(Element e, String attrName, String allocation) {
+        return getAttributeType(e.getName(), attrName, allocation);
     }
 
     /**
@@ -484,7 +495,7 @@
      * @param attrName an attribute name
      * @return a value represting the type of the attribute's
      */
-    public Type getAttributeType(String elt, String attrName)
+    public Type getAttributeType(String elt, String attrName, String allocation)
         throws UnknownAttributeException
     {
         String elementName = elt.intern();
@@ -506,7 +517,7 @@
         
         if (classModel != null) {
             try {
-                type = classModel.getAttributeTypeOrException(attrName);
+                type = classModel.getAttributeTypeOrException(attrName, allocation);
             } catch (UnknownAttributeException e) {
                 e.setName(attrName);
                 e.setElementName(elt);
@@ -530,13 +541,14 @@
         for (Iterator iter = elt.getAttributes().iterator(); iter.hasNext(); ) {
             Attribute attr = (Attribute) iter.next();
             String name = attr.getName();
-            AttributeSpec attrspec = getAttributeSpec(elt.getName(), name);
+            AttributeSpec attrspec  = getAttributeSpec(elt.getName(), name, NodeModel.ALLOCATION_INSTANCE);
             if (attrspec == null) {
                 throw new CompilationError("Unknown attribute '"+name+"' on tag "+elt.getName(), elt);
             }
         }
     }
 
+
     /**
      * Finds the AttributeSpec definition of an attribute, on a class
      * or by searching up it's parent class chain.
@@ -545,7 +557,7 @@
      * @param attrName an attribute name
      * @return the AttributeSpec or null
      */
-    public AttributeSpec getAttributeSpec(String elt, String attrName)
+    public AttributeSpec getAttributeSpec(String elt, String attrName, String allocation)
     {
         String elementName = elt.intern();
 
@@ -553,7 +565,7 @@
         ClassModel classModel = getClassModel(elementName);
         
         if (classModel != null) {
-            return classModel.getAttribute(attrName);
+            return classModel.getAttribute(attrName, allocation);
         } else {
             return null;
         }
@@ -565,9 +577,9 @@
      * @param methodName a method name
      * @return boolean if the method exists on the class or superclass
      */
-    public boolean methodOverrideAllowed(String classname, String methodName)
+    public boolean methodOverrideAllowed(String classname, String methodName, String allocation)
     {
-        AttributeSpec methodspec = getClassAttribute(classname, methodName);
+        AttributeSpec methodspec = getClassAttribute(classname, methodName, allocation);
 
         if (methodspec == null) {
             return true;

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema_Test.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema_Test.java	2008-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema_Test.java	2008-05-07 16:21:16 UTC (rev 9030)
@@ -3,7 +3,7 @@
  * ****************************************************************************/
 
 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2007 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * J_LZ_COPYRIGHT_END *********************************************************/
 
@@ -127,25 +127,25 @@
 
         assertEquals("mynewclass foo-width type",
                      schema.SIZE_EXPRESSION_TYPE,
-                     schema.getAttributeType(class1, "foo-width"));
+                     schema.getAttributeType(class1, "foo-width", NodeModel.ALLOCATION_INSTANCE));
 
         assertEquals("mynewclass barbaz type",
                      schema.STRING_TYPE,
-                     schema.getAttributeType(class1, "barbaz"));
+                     schema.getAttributeType(class1, "barbaz", NodeModel.ALLOCATION_INSTANCE));
 
         // Check subclass attribute types
         assertEquals("mynewsubclass foo-width type",
                      schema.SIZE_EXPRESSION_TYPE,
-                     schema.getAttributeType(subclass, "foo-width"));
+                     schema.getAttributeType(subclass, "foo-width", NodeModel.ALLOCATION_INSTANCE));
 
         assertEquals("mynewsubclass baz-width type",
                      schema.SIZE_EXPRESSION_TYPE,
-                     schema.getAttributeType(subclass, "baz-width"));
+                     schema.getAttributeType(subclass, "baz-width", NodeModel.ALLOCATION_INSTANCE));
 
         // Attribute type of subclass should override superclass type
         assertEquals("mynewsubclass barbaz type",
                      schema.EVENT_HANDLER_TYPE,
-                     schema.getAttributeType(subclass, "barbaz"));
+                     schema.getAttributeType(subclass, "barbaz", NodeModel.ALLOCATION_INSTANCE));
 
         // test for duplicate attributes, undefined superclass, redefined class, attr inheritance
 

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/xml/internal/Schema.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/xml/internal/Schema.java	2008-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/xml/internal/Schema.java	2008-05-07 16:21:16 UTC (rev 9030)
@@ -70,7 +70,7 @@
     public static final Schema DEFAULT_SCHEMA =
         new Schema() {
             /** @see Schema */
-            public Type getAttributeType(Element element, String name) {
+            public Type getAttributeType(Element element, String name, String allocation) {
                 return UNKNOWN_TYPE;
             }
         };
@@ -84,5 +84,6 @@
      * @return a value represting the type of the attribute's
      */
     public abstract Type getAttributeType(Element element,
-                                         String attributeName);
+                                          String attributeName,
+                                          String allocation);
 }

Deleted: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/xml/internal/XMLCompiler.java

Added: openlaszlo/trunk/test/lztest/lztest-static-attrs.lzx


Property changes on: openlaszlo/trunk/test/lztest/lztest-static-attrs.lzx
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: openlaszlo/trunk/test/lztest/rhino.txt
===================================================================
--- openlaszlo/trunk/test/lztest/rhino.txt	2008-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/test/lztest/rhino.txt	2008-05-07 16:21:16 UTC (rev 9030)
@@ -1,4 +1,5 @@
-# Copyright 2007 Laszlo Systems
+# Copyright 2007, 2008 Laszlo Systems
+test/lztest/lztest-static-attrs.lzx
 test/lztest/lztest-textstyle.lzx
 test/lztest/lztest-align.lzx
 # test/lztest/lztest-animator.lzx

Modified: openlaszlo/trunk/test/lztest/smoketest.txt
===================================================================
--- openlaszlo/trunk/test/lztest/smoketest.txt	2008-05-07 12:00:10 UTC (rev 9029)
+++ openlaszlo/trunk/test/lztest/smoketest.txt	2008-05-07 16:21:16 UTC (rev 9030)
@@ -1,4 +1,5 @@
-# Copyright 2006 Laszlo Systems
+# Copyright 2006, 2008 Laszlo Systems
+test/lztest/lztest-static-attrs.lzx
 test/lztest/lztest-textstyle.lzx
 test/lztest/lztest-align.lzx
 # test/lztest/lztest-animator.lzx



More information about the Laszlo-checkins mailing list