Author: hqm
Date: 2007-11-09 06:25:10 -0800 (Fri, 09 Nov 2007)
New Revision: 7200
Modified:
openlaszlo/trunk/WEB-INF/lps/misc/lzx-autoincludes.properties
openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
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 20071109-hqm-6 by [EMAIL PROTECTED] on 2007-11-09 09:23:21 EST
in /cygdrive/c/users/hqm/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: prevent spurious compiler warnings when overriding apply()
method on subclases of <state>
New Features:
Bugs Fixed: LPP-5067, LPP-5065
Technical Reviewer: ptw
QA Reviewer: pbr
Doc Reviewer:
Documentation:
Release Notes:
Details:
I modified the compiler to not warn if the attribute being overriden
was declared explicitly with a value of "true" for it's 'override' property.
So in lfc.lzx, we declare apply as non overridable, on the base Instance
<interface name="Instance" extends="Object">
<method name="apply" override="false"/>
but "state" declares it overridable, so any subclass of state can override it
<interface name="state" extends="node">
<attribute name="apply" override="true" />
I made the compiler not only not warn if you override the method with
another method, but not warn if you override an attribute with a
method. That is a little too loose I guess, but it only happens when you
declare "override=true" on an attribute.
Tests:
test/compiler_errors/override-state.lzx
override-builtin.lzx
smokecheck
amazon
calendar
examples/components/style_example.lzx
Modified: openlaszlo/trunk/WEB-INF/lps/misc/lzx-autoincludes.properties
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/misc/lzx-autoincludes.properties
2007-11-09 04:16:09 UTC (rev 7199)
+++ openlaszlo/trunk/WEB-INF/lps/misc/lzx-autoincludes.properties
2007-11-09 14:25:10 UTC (rev 7200)
@@ -6,125 +6,125 @@
# * Use is subject to license terms. *
# * P_LZ_COPYRIGHT_END ********************************************************
-basebutton: base/basebutton.lzx
-multistatebutton: base/multistatebutton.lzx
-basecomponent: base/basecomponent.lzx
-statictext: base/basecomponent.lzx
-basevaluecomponent: base/basevaluecomponent.lzx
-baseform: base/baseform.lzx
-submit: base/submit.lzx
-baseformitem: base/baseformitem.lzx
-baselist: base/baselist.lzx
-baselistitem: base/baselistitem.lzx
-basescrollbar: base/basescrollbar.lzx
-baseslider: base/baseslider.lzx
-basesliderthumb: base/baseslider.lzx
-baseslidertrack: base/baseslider.lzx
-basetabs: base/basetabs.lzx
-basetabslider: base/basetabslider.lzx
-basetabelement: base/basetabelement.lzx
-basetrackgroup: base/basetrackgroup.lzx
-basetree: base/basetree.lzx
-basewindow: base/basewindow.lzx
-basecombobox: base/basecombobox.lzx
-basedatacombobox: base/basedatacombobox.lzx
-resizeview_x: base/resizeview.lzx
-resizeview_y: base/resizeview.lzx
-style: base/style.lzx
-swatchview: base/swatchview.lzx
-basegrid: base/basegrid.lzx
-basedatepicker: base/basedatepicker.lzx
-basedatepickerday: base/basedatepickerday.lzx
-basedatepickerweek: base/basedatepickerweek.lzx
+basebutton: /base/basebutton.lzx
+multistatebutton: /base/multistatebutton.lzx
+basecomponent: /base/basecomponent.lzx
+statictext: /base/basecomponent.lzx
+basevaluecomponent: /base/basevaluecomponent.lzx
+baseform: /base/baseform.lzx
+submit: /base/submit.lzx
+baseformitem: /base/baseformitem.lzx
+baselist: /base/baselist.lzx
+baselistitem: /base/baselistitem.lzx
+basescrollbar: /base/basescrollbar.lzx
+baseslider: /base/baseslider.lzx
+basesliderthumb: /base/baseslider.lzx
+baseslidertrack: /base/baseslider.lzx
+basetabs: /base/basetabs.lzx
+basetabslider: /base/basetabslider.lzx
+basetabelement: /base/basetabelement.lzx
+basetrackgroup: /base/basetrackgroup.lzx
+basetree: /base/basetree.lzx
+basewindow: /base/basewindow.lzx
+basecombobox: /base/basecombobox.lzx
+basedatacombobox: /base/basedatacombobox.lzx
+resizeview_x: /base/resizeview.lzx
+resizeview_y: /base/resizeview.lzx
+style: /base/style.lzx
+swatchview: /base/swatchview.lzx
+basegrid: /base/basegrid.lzx
+basedatepicker: /base/basedatepicker.lzx
+basedatepickerday: /base/basedatepickerday.lzx
+basedatepickerweek: /base/basedatepickerweek.lzx
-constantlayout: utils/layouts/constantlayout.lzx
-resizelayout: utils/layouts/resizelayout.lzx
-simplelayout: utils/layouts/simplelayout.lzx
-stableborderlayout: utils/layouts/stableborderlayout.lzx
-wrappinglayout: utils/layouts/wrappinglayout.lzx
-reverselayout: utils/layouts/reverselayout.lzx
-dragstate: utils/states/dragstate.lzx
-resizestate: utils/states/resizestate.lzx
+constantlayout: /utils/layouts/constantlayout.lzx
+resizelayout: /utils/layouts/resizelayout.lzx
+simplelayout: /utils/layouts/simplelayout.lzx
+stableborderlayout: /utils/layouts/stableborderlayout.lzx
+wrappinglayout: /utils/layouts/wrappinglayout.lzx
+reverselayout: /utils/layouts/reverselayout.lzx
+dragstate: /utils/states/dragstate.lzx
+resizestate: /utils/states/resizestate.lzx
-inittimer: utils/diagnostic/inittimer.lzx
-frametimer: utils/diagnostic/frametimer.lzx
-versioninfo: utils/diagnostic/versioninfo.lzx
-inspector: utils/diagnostic/inspector/inspector.lzx
+inittimer: /utils/diagnostic/inittimer.lzx
+frametimer: /utils/diagnostic/frametimer.lzx
+versioninfo: /utils/diagnostic/versioninfo.lzx
+inspector: /utils/diagnostic/inspector/inspector.lzx
-checkbox: lz/checkbox.lzx
-button: lz/button.lzx
-combobox: lz/combobox.lzx
-datacombobox: lz/datacombobox.lzx
-menu: lz/menu.lzx
-menubar: lz/menu.lzx
-menuitem: lz/menu.lzx
-menuseparator: lz/menu.lzx
-radiogroup: lz/radio.lzx
-radiobutton: lz/radio.lzx
-slider: lz/slider.lzx
-slidertrack: lz/slider.lzx
-sliderthumb: lz/slider.lzx
-scrollbar: lz/scrollbar.lzx
-hscrollbar: lz/hscrollbar.lzx
-vscrollbar: lz/vscrollbar.lzx
-window: lz/window.lzx
-modaldialog: lz/window.lzx
-alert: lz/window.lzx
-edittext: lz/edittext.lzx
-simpleinputtext: lz/simpletext.lzx
-form: lz/form.lzx
-tabs: lz/tabs.lzx
-tabpane: lz/tabs.lzx
-tabbar: lz/tabs.lzx
-list: lz/list.lzx
-listitem: lz/listitem.lzx
-textlistitem: lz/textlistitem.lzx
-basefloatinglist: lz/basefloatinglist.lzx
-floatinglist: lz/floatinglist.lzx
-plainfloatinglist: lz/plainfloatinglist.lzx
-windowpanel: lz/windowpanel.lzx
-tabslider: lz/tabslider.lzx
-tabelement: lz/tabelement.lzx
-tree: lz/tree.lzx
-grid: lz/grid.lzx
-datepicker: lz/datepicker.lzx
+checkbox: /lz/checkbox.lzx
+button: /lz/button.lzx
+combobox: /lz/combobox.lzx
+datacombobox: /lz/datacombobox.lzx
+menu: /lz/menu.lzx
+menubar: /lz/menu.lzx
+menuitem: /lz/menu.lzx
+menuseparator: /lz/menu.lzx
+radiogroup: /lz/radio.lzx
+radiobutton: /lz/radio.lzx
+slider: /lz/slider.lzx
+slidertrack: /lz/slider.lzx
+sliderthumb: /lz/slider.lzx
+scrollbar: /lz/scrollbar.lzx
+hscrollbar: /lz/hscrollbar.lzx
+vscrollbar: /lz/vscrollbar.lzx
+window: /lz/window.lzx
+modaldialog: /lz/window.lzx
+alert: /lz/window.lzx
+edittext: /lz/edittext.lzx
+simpleinputtext: /lz/simpletext.lzx
+form: /lz/form.lzx
+tabs: /lz/tabs.lzx
+tabpane: /lz/tabs.lzx
+tabbar: /lz/tabs.lzx
+list: /lz/list.lzx
+listitem: /lz/listitem.lzx
+textlistitem: /lz/textlistitem.lzx
+basefloatinglist: /lz/basefloatinglist.lzx
+floatinglist: /lz/floatinglist.lzx
+plainfloatinglist: /lz/plainfloatinglist.lzx
+windowpanel: /lz/windowpanel.lzx
+tabslider: /lz/tabslider.lzx
+tabelement: /lz/tabelement.lzx
+tree: /lz/tree.lzx
+grid: /lz/grid.lzx
+datepicker: /lz/datepicker.lzx
-whitestyle: base/defaultstyles.lzx
-silverstyle: base/defaultstyles.lzx
-bluestyle: base/defaultstyles.lzx
-greenstyle: base/defaultstyles.lzx
-goldstyle: base/defaultstyles.lzx
-purplestyle: base/defaultstyles.lzx
+whitestyle: /base/defaultstyles.lzx
+silverstyle: /base/defaultstyles.lzx
+bluestyle: /base/defaultstyles.lzx
+greenstyle: /base/defaultstyles.lzx
+goldstyle: /base/defaultstyles.lzx
+purplestyle: /base/defaultstyles.lzx
-javarpc: rpc/javarpc.lzx
-sessionrpc: rpc/sessionrpc.lzx
-webapprpc: rpc/webapprpc.lzx
-soap: rpc/soap.lzx
-xmlrpc: rpc/xmlrpc.lzx
+javarpc: /rpc/javarpc.lzx
+sessionrpc: /rpc/sessionrpc.lzx
+webapprpc: /rpc/webapprpc.lzx
+soap: /rpc/soap.lzx
+xmlrpc: /rpc/xmlrpc.lzx
-richinputtext: extensions/views/richinputtext.lzx
+richinputtext: /extensions/views/richinputtext.lzx
-html: extensions/html.lzx
-drawview: extensions/drawview.lzx
+html: /extensions/html.lzx
+drawview: /extensions/drawview.lzx
-rtmpconnection: extensions/av/rtmpconnection.lzx
-mediastream: extensions/av/mediastream.lzx
-mediadevice: extensions/av/mediadevice.lzx
-camera: extensions/av/camera.lzx
-microphone: extensions/av/microphone.lzx
-videoview: extensions/av/videoview.lzx
+rtmpconnection: /extensions/av/rtmpconnection.lzx
+mediastream: /extensions/av/mediastream.lzx
+mediadevice: /extensions/av/mediadevice.lzx
+camera: /extensions/av/camera.lzx
+microphone: /extensions/av/microphone.lzx
+videoview: /extensions/av/videoview.lzx
-rtmpstatus: av/rtmpstatus.lzx
+rtmpstatus: /av/rtmpstatus.lzx
-hbox: base/hbox.lzx
-vbox: base/vbox.lzx
-image: base/image.lzx
+hbox: /base/hbox.lzx
+vbox: /base/vbox.lzx
+image: /base/image.lzx
-barchart: charts/barchart/barchart.lzx
-columnchart: charts/columnchart/columnchart.lzx
-linechart: charts/linechart/linechart.lzx
-piechart: charts/piechart/piechart.lzx
+barchart: /charts/barchart/barchart.lzx
+columnchart: /charts/columnchart/columnchart.lzx
+linechart: /charts/linechart/linechart.lzx
+piechart: /charts/piechart/piechart.lzx
-lazyreplicator: utils/replicator/lazyreplicator.lzx
-replicator: utils/replicator/replicator.lzx
+lazyreplicator: /utils/replicator/lazyreplicator.lzx
+replicator: /utils/replicator/replicator.lzx
Modified: openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx 2007-11-09 04:16:09 UTC (rev
7199)
+++ openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx 2007-11-09 14:25:10 UTC (rev
7200)
@@ -25,12 +25,7 @@
<method name="isPrototypeOf" override="false"/>
<method name="toLocaleString" override="false"/>
<method name="prototype" override="false"/>
- <!--
- 'apply' is ambiguous because <state> is
- using it for both a method and an attribute. Just omit it from
- the declarations for now.
<method name="apply" override="false"/>
- -->
<method name="call" override="false"/>
</interface>
@@ -244,13 +239,13 @@
</containsElements>
</interface>
-<interface name="class" extends="view">
+<interface name="class" extends="node">
<attribute name="extends" type="token" value="view"/>
<!-- The comma-separated list of mixins, applied in order -->
<attribute name="with" type="string"/>
</interface>
-<interface name="interface" extends="view">
+<interface name="interface" extends="node">
<attribute name="extends" type="token" value="view"/>
<!-- The comma-separated list of mixins, applied in order -->
<attribute name="with" type="string"/>
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
2007-11-09 04:16:09 UTC (rev 7199)
+++
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
2007-11-09 14:25:10 UTC (rev 7200)
@@ -1527,6 +1527,9 @@
Schema.Type type = null;
Schema.Type parenttype = null;
+ AttributeSpec parentAttrSpec =
schema.getAttributeSpec(parent.getName(), name);
+ boolean forceOverride = parentAttrSpec != null &&
"true".equals(parentAttrSpec.override);
+
try {
if (parent.getName().equals("class")) {
parenttype = getAttributeTypeInfoFromSuperclass(parent, name);
@@ -1562,9 +1565,10 @@
NodeModel.class.getName(),"051018-1211", new Object[]
{typestr})
, element);
}
+
// If we are trying to declare the attribute with a
// conflicting type to the parent, throw an error
- if (parenttype != null && type != parenttype) {
+ if (!forceOverride && parenttype != null && type != parenttype) {
env.warn(
new CompilationError(
element,
@@ -1581,11 +1585,14 @@
}
}
+
+
// Warn if we are overidding a method, handler, or other function
- if (parenttype == schema.METHOD_TYPE ||
- parenttype == schema.EVENT_HANDLER_TYPE ||
- parenttype == schema.SETTER_TYPE ||
- parenttype == schema.REFERENCE_TYPE) {
+ if (!forceOverride &&
+ (parenttype == schema.METHOD_TYPE ||
+ parenttype == schema.EVENT_HANDLER_TYPE ||
+ parenttype == schema.SETTER_TYPE ||
+ parenttype == schema.REFERENCE_TYPE)) {
env.warn( "In element '" + parent.getName()
+ "' attribute '" + name
+ "' is overriding parent class attribute which has the
same name but type: "
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
2007-11-09 04:16:09 UTC (rev 7199)
+++
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
2007-11-09 14:25:10 UTC (rev 7200)
@@ -396,7 +396,14 @@
// Check that the overriding type is the same as the
superclass' type
parentType = getAttributeType(classname, attr.name);
- if (parentType != attr.type) {
+ // Does the parent attribute definition assert
override=true?
+ // If so, we're not going to warn if the types mismatch.
+ AttributeSpec parentAttrSpec = getAttributeSpec(classname,
attr.name);
+ boolean forceOverride = parentAttrSpec != null &&
"true".equals(parentAttrSpec.override);
+
+ if (!forceOverride && (parentType != attr.type)) {
+ // get the parent attribute, so we can see if it says
override is allowed
+
env.warn(/* (non-Javadoc)
* @i18n.test
* @org-mes="In class '" + p[0] + "'
attribute '" + p[1] + "' with type '" + p[2] + "' is overriding superclass
attribute with same name but different type: " + p[3]
@@ -503,7 +510,30 @@
}
+
/**
+ * Finds the AttributeSpec definition of an attribute, on a class
+ * or by searching up it's parent class chain.
+ *
+ * @param elt an Element name
+ * @param attrName an attribute name
+ * @return the AttributeSpec or null
+ */
+ public AttributeSpec getAttributeSpec(String elt, String attrName)
+ {
+ String elementName = elt.intern();
+
+ // Look up attribute in type map for this element
+ ClassModel classModel = getClassModel(elementName);
+
+ if (classModel != null) {
+ return classModel.getAttribute(attrName);
+ } else {
+ return null;
+ }
+ }
+
+ /**
* checks whether a method with a given method is allowed to be overridden
* @param elt an Element name
* @param methodName a method name
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins