[Laszlo-checkins] r9354 - in openlaszlo/trunk/WEB-INF/lps/lfc: data views
bargull@openlaszlo.org
bargull at openlaszlo.org
Wed May 28 09:53:39 PDT 2008
Author: bargull
Date: 2008-05-28 09:53:32 -0700 (Wed, 28 May 2008)
New Revision: 9354
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataAttrBind.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapath.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/data/LzResizeReplicationManager.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
Log:
Change 20080526-bargull-hoc by bargull at dell--p4--2-53 on 2008-05-26 16:34:18
in /home/Admin/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Add type information to LFC (partial)
New Features:
Bugs Fixed: LPP-5893
Technical Reviewer: hminsky
QA Reviewer: promanik
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
Added type information for LzDatapointer, LzDatapath, LzReplicationManager, LzDataAttrBind.
Adjusted methods in LzLazyReplicationManager, LzResizeReplicationManager to conform method-declarations from superclass.
Changed LzDatapointer#__LZdoSelect(..) to fix LPP-5893.
Tests:
ant lztest, ant runlzunit, swf9-datatests (except for data-6, which is broken atm)
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataAttrBind.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataAttrBind.lzs 2008-05-28 16:45:00 UTC (rev 9353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataAttrBind.lzs 2008-05-28 16:53:32 UTC (rev 9354)
@@ -11,8 +11,8 @@
/** @access private */
class LzDataAttrBind extends LzDatapointer {
-function LzDataAttrBind ( ndpath , attr, path ){
- super (ndpath, attr)
+function LzDataAttrBind ( ndpath:LzDatapath, attr:String, path:String ){
+ super (ndpath);
this.setAttr = attr;
this.pathparent = ndpath;
this.node = ndpath.immediateparent;
@@ -28,26 +28,29 @@
// prototype.rerunxpath = true; // Override value defined in LzDatapointer
+
/** @access private */
-var $pathbinding = true;
+var $pathbinding :Boolean = true;
/** @access private */
-var setAttr;
+var setAttr :String;
/** @access private */
-var pathparent;
+var pathparent :LzDatapath;
/** @access private */
-var node;
+var node :LzNode;
-override function __LZsendUpdate ( a = null , b = null ){
+/**
+ * @access private
+ */
+override function __LZsendUpdate (upd:Boolean = false, upp:Boolean = false) :Boolean {
var pchg = this.__LZpchanged;
- if ( ! super.__LZsendUpdate.apply(this, arguments) ) return;
- if ( pchg ||
- this.node[ this.setAttr ] != this.data ||
- this.parsedPath.operator == "attributes" ){
- this.node.setAttribute( this.setAttr , this.data == null ?
- null : this.data );
- //this test is necessary or
- //or properties get set to
- //undefined
+ if ( super.__LZsendUpdate(upd, upp) ) {
+ var data:* = this.data;
+ var node:LzNode = this.node;
+ var attr:String = this.setAttr;
+ if (pchg || node[ attr ] != data || this.parsedPath.operator == "attributes") {
+ //this test is necessary or properties get set to undefined
+ node.setAttribute( attr, data == null ? null : data );
+ }
}
}
@@ -56,12 +59,12 @@
* This matches the LzDelegate method of the same name so that these objects
* can be stored in a node's __LZdelegates array.
*/
-function unregisterAll ( ){
- var dca = this.pathparent.__LZdepChildren;
+function unregisterAll () :void {
+ var dca:Array = this.pathparent.__LZdepChildren;
if (dca != null) {
- for ( var i = 0; i < dca.length ; i++ ){
- if ( dca [ i ] == this ){
+ for (var i:int = 0; i < dca.length; i++) {
+ if ( dca [ i ] === this ){
dca.splice( i , 1 );
break;
}
@@ -71,9 +74,11 @@
this.destroy();
}
-
-override function setDataContext ( dc, implicit = null ){
- super.setDataContext( dc || this.pathparent, implicit );
+/**
+ * @access private
+ */
+override function setDataContext (dc, implicit:Boolean = false) :void {
+ super.setDataContext(dc || this.pathparent, implicit);
}
/**
@@ -107,7 +112,7 @@
}
}
-override function toString ( ){
+override function toString () :String {
return 'binder ' + this.xpath;
}
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapath.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapath.lzs 2008-05-28 16:45:00 UTC (rev 9353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapath.lzs 2008-05-28 16:53:32 UTC (rev 9354)
@@ -72,9 +72,9 @@
/** @access private
* @modifiers override
*/
-static var tagname = 'datapath';
+static var tagname :String = 'datapath';
/** @access private */
- static var attributes = new LzInheritedHash(LzDatapointer.attributes);
+static var attributes :Object = new LzInheritedHash(LzDatapointer.attributes);
/** By default, this is false for instances
* of <classname>datapointer</classname>, and true for instances of
@@ -87,19 +87,21 @@
* @type Boolean
* @access private
*/
-var datacontrolsvisibility = true;
+var datacontrolsvisibility :Boolean = true;
/** @access private */
-var __LZtakeDPSlot = true;
+var __LZtakeDPSlot :Boolean = true;
/** @access private */
-var storednodes;
+var storednodes :Array = null;
/** @access private */
-var __LZneedsUpdateAfterInit;
+var __LZneedsUpdateAfterInit :Boolean = false;
/** @access private */
-var __LZdepChildren;
+var __LZdepChildren :Array = null;
/** @access private */
-var sel:Boolean = false;
+var sel :Boolean = false;
+/** @access private */
+var __LZisclone :Boolean = false;
/** Sent when the datapath's data changes.
*/
@@ -130,7 +132,7 @@
* @lzxdefault false
* @keywords final
*/
-var pooling = false;
+var pooling :Boolean = false;
/**
* Determines whether to use normal or lazy replication, if the
@@ -145,7 +147,7 @@
* @lzxdefault 'normal'
* @keywords final
*/
-var replication;
+var replication :String;
/**
* An XPath to use to obtain the sort key for sorting if replication
@@ -155,9 +157,9 @@
* @type String
* @lzxtype string
*/
-var sortpath;
+var sortpath :String;
/** @access private */
-function $lzc$set_sortpath (xpath) {
+function $lzc$set_sortpath (xpath:String) :void {
this.setOrder(xpath);
}
@@ -170,7 +172,7 @@
*
* @access private
*/
-function setOrder( xpath , comparator=null ) {
+function setOrder( xpath:String , comparator:* = null ) :void {
if ( this.__LZisclone ){
this.immediateparent.cloneManager.setOrder( xpath , comparator );
} else {
@@ -193,9 +195,9 @@
* @type String|Function
* @lzxtype expression
*/
-var sortorder;
+var sortorder :*;
/** @access private */
-function $lzc$set_sortorder( comparator) {
+function $lzc$set_sortorder( comparator:* ) :void {
this.setComparator(comparator);
}
/**
@@ -209,7 +211,7 @@
*
* @access private
*/
-function setComparator( comparator ) {
+function setComparator( comparator:* ) :void {
if ( this.__LZisclone ){
this.immediateparent.cloneManager.setComparator( comparator );
} else {
@@ -225,7 +227,7 @@
}
/** @access private */
-override function construct ( v , args ){
+override function construct ( v , args ) :void {
this.rerunxpath = true; // Defined in LzDatapointer
super.construct.apply(this, arguments);
@@ -240,35 +242,35 @@
}
if ( this.__LZtakeDPSlot ){
+ if ($debug) {
+ if (this.immediateparent.datapath != null) {
+ Debug.warn("overring datapath %w with %w", this.immediateparent.datapath, this);
+ }
+ }
this.immediateparent.datapath = this;
- var pdp = null;
- var tarr = null;
-// [2008-03-12 pbr] Removed the 'in' test. not needed
-// if ('searchParents' in this.immediateparent) {
- pdp = this.immediateparent.searchParents( "datapath" ).datapath;
-
- tarr = pdp.__LZdepChildren;
-// }
-
- //set it early, so that it's right when xpath first runs
- if ( tarr != null ){
- pdp.__LZdepChildren = [];
-
- for ( var i = tarr.length - 1 ; i >= 0 ; i-- ){
- var c = tarr[ i ];
- if ( c != this &&
- !(c is LzDataAttrBind) &&
-// [2008-03-12 pbr] Changed check because swf9 doesn't like it
-// !c.$pathbinding &&
- c.immediateparent != this.immediateparent &&
- c.immediateparent.childOf( this.immediateparent )){
- c.setDataContext( this ,true );
- } else {
- pdp.__LZdepChildren.push( c );
+ var pdp:LzDatapath = this.immediateparent.searchParents( "datapath" ).datapath;
+
+ if (pdp != null) {
+ //set it early, so that it's right when xpath first runs
+ var tarr:Array = pdp.__LZdepChildren;
+ if ( tarr != null ){
+ pdp.__LZdepChildren = [];
+
+ for ( var i:int = tarr.length - 1; i >= 0; i-- ){
+ var c:* = tarr[ i ];
+ if ( c !== this && !(c is LzDataAttrBind) &&
+ c.immediateparent != this.immediateparent &&
+ c.immediateparent.childOf( this.immediateparent )){
+ c.setDataContext( this ,true );
+ } else {
+ pdp.__LZdepChildren.push( c );
+ }
}
}
+ } else if ($debug) {
+ Debug.warn("unexpected state for '%w', couldn't find parent-datapath!", this);
}
}
}
@@ -276,7 +278,7 @@
/**
* @access private
*/
-override function __LZHandleMultiNodes ( nodes ){
+override function __LZHandleMultiNodes ( nodes:Array ) :LzReplicationManager {
//uhoh! this should be a clone
//Because we're about to start making siblings to this view,
@@ -286,6 +288,7 @@
//ok to call if already added
+ //FIXME: type? Function or Class?
var clonetype;
switch ( this.replication ){
case "lazy":
@@ -302,7 +305,7 @@
//TODO: [20080327 anba] "storednodes" should be passed directly
// to the ReplicationManager, instead of doing this kludge
this.storednodes = nodes;
- var rman = new clonetype( this, this._instanceAttrs);
+ var rman:LzReplicationManager = new clonetype( this, this._instanceAttrs);
this.storednodes = null;
return rman;
@@ -320,12 +323,12 @@
*
* @param Array nodes: A list of LzDataElements to replicate over.
*/
-function setNodes ( nodes ){
+function setNodes ( nodes:Array ) :void {
//Debug.write( "before context" ,this.context );
//this.setDataContext( nodes , false );
//Debug.write( "context" ,this.context );
- var rman = this.__LZHandleMultiNodes( nodes );
+ var rman:LzDatapath = this.__LZHandleMultiNodes( nodes );
//__LZHandleMultiNodes will return the replication manager if "this" is a
//datapath
@@ -334,9 +337,9 @@
rman.__LZsetTracking( null );
if (nodes) {
- for ( var i = 0; i < nodes.length; i++ ){
- var n = nodes[ i ];
- var own = n.ownerDocument;
+ for ( var i:int = 0; i < nodes.length; i++ ){
+ var n:LzDataElement = nodes[ i ];
+ var own:LzDataElementMixin = n.ownerDocument;
//third arg is an optimization -- if the node is unique, then we
//know we're not tracking it
rman.__LZsetTracking( own , true , n != own );
@@ -347,9 +350,9 @@
/**
* @access private
*/
-override function __LZsendUpdate( upd = null, upp = null ) {
- var pchg = this.__LZpchanged;
- if ( !super.__LZsendUpdate.apply(this, arguments) ){
+override function __LZsendUpdate( upd:Boolean = false, upp:Boolean = false ) :Boolean {
+ var pchg:Boolean = this.__LZpchanged;
+ if ( !super.__LZsendUpdate(upd, upp) ){
return false;
}
@@ -366,55 +369,57 @@
/**
* @access private
*/
-function __LZApplyDataOnInit( ) {
+function __LZApplyDataOnInit( ) :void {
if ( this.__LZneedsUpdateAfterInit ){
this.__LZApplyData();
- this.__LZneedsUpdateAfterInit = null;
+ this.__LZneedsUpdateAfterInit = false;
}
}
/**
* @access private
*/
-function __LZApplyData( force = null) {
+function __LZApplyData( force:Boolean = false) :void {
+ var ip:LzNode = this.immediateparent;
- var ip = this.immediateparent;
-
if ( this.datacontrolsvisibility ){
- this.immediateparent.__LZvizDat = this.p != null;
+ ip.__LZvizDat = this.p != null;
// [2008-03-12 pbr] Removed because swf9 doesn't like it. It can
// also be a LZMiniNode but it's a null def.
- if (this.immediateparent is LzView)
-// if ('__LZupdateShown' in this.immediateparent)
- this.immediateparent.__LZupdateShown();
+ if (ip is LzView)
+// if ('__LZupdateShown' in ip)
+ ip.__LZupdateShown();
}
- var cdat = force ||
+ var cdat:Boolean = force ||
ip.data != this.data ||
(this.parsedPath && this.parsedPath.operator == "attributes");
this.data = this.data == null ? null : this.data;
ip.data = this.data;
-
-
- if ( cdat && ip.ondata.ready){
- ip.ondata.sendEvent( this.data );
+
+ if (cdat) {
+ if (ip.ondata.ready) ip.ondata.sendEvent( this.data );
+
+ var ppath:LzParsedPath = this.parsedPath;
+ if (ppath && (ppath.operator != null || ppath.aggOperator != null)) {
+ ip.applyData( this.data );
+ }
}
- if ( this.parsedPath && ( this.parsedPath.operator != null ||
- this.parsedPath.aggOperator != null ) && cdat ){
- if (ip.applyData) ip.applyData( this.data );
- }
-
}
/**
* @access private
*/
-override function setDataContext ( p , implicit = null ){
+override function setDataContext ( p, implicit:Boolean = false) :void {
if (p == null && this.immediateparent != null) {
p = this.immediateparent.searchParents( "datapath" ).datapath;
implicit = true;
+ } else if ($debug) {
+ if (this.immediateparent == null) {
+ Debug.warn("immediateparent is null for %w in '%s'", this, arguments.callee);
+ }
}
if ( p == this.context ) return;
@@ -428,19 +433,19 @@
} else {
//not a depedent child
- var dclist = null;
+ var dclist:Array = null;
if ( this.context ) dclist = this.context.__LZdepChildren;
if ( dclist ){
//remove self from list
- for ( var i = 0; i < dclist.length; i++ ){
- if ( dclist[ i ] == this ){
+ for ( var i:int = 0; i < dclist.length; i++ ){
+ if ( dclist[ i ] === this ){
dclist.splice( i , 1 );
break;
}
}
}
}
- // this.callInherited
+
super.setDataContext( p );
}
@@ -452,15 +457,14 @@
override function destroy(){
this.__LZupdateLocked = true; //so won't set data
- if ( this.context && !this.context.__LZdeleted &&
- this.context is LzDatapath ){
-// this.context.__LZdepChildren ){
+ var context:* = this.context;
+ if ( context && !context.__LZdeleted && context is LzDatapath ){
//remove self from __LZdepChildren
- var dca = this.context.__LZdepChildren;
+ var dca:Array = context.__LZdepChildren;
if (dca != null) {
- for ( var i = 0; i < dca.length ; i++ ){
- if ( dca [ i ] == this ){
+ for ( var i:int = 0; i < dca.length; i++ ){
+ if ( dca [ i ] === this ){
dca.splice( i , 1 );
break;
}
@@ -469,24 +473,26 @@
}
+ var ip:LzNode = this.immediateparent;
+
//if immediate parent was deleted, don't worry about the datapaths dependent
//on this one -- they'll be deleted too
- if ( ! this.immediateparent.__LZdeleted ){
- if ( this.__LZdepChildren != null &&
- this.__LZdepChildren.length ){
+ if ( ! ip.__LZdeleted ){
+ var depChildren = this.__LZdepChildren;
+ if (depChildren != null && depChildren.length > 0) {
//need to assign __LZdepChildren to parent
- var dnpar = this.immediateparent.searchParents( "datapath" ).
- datapath;
-
- for ( var i = 0; i < this.__LZdepChildren.length ; i++ ){
- this.__LZdepChildren[ i ].setDataContext( dnpar , true );
+ var dnpar:LzDatapath = ip.searchParents( "datapath" ).datapath;
+
+ for ( var i:int = 0; i < depChildren.length; i++ ){
+ depChildren[ i ].setDataContext( dnpar, true );
}
-
+
+ this.__LZdepChildren = null;
}
}
- if ( this.immediateparent.datapath == this ){
- this.immediateparent.datapath = null;
+ if (ip.datapath === this) {
+ ip.datapath = null;
}
super.destroy.apply(this, arguments);
@@ -525,7 +531,7 @@
this.p.__LZlockFromUpdate( this );
}
- var ppdo = this.parsedPath ? this.parsedPath.operator : null;
+ var ppdo:String = this.parsedPath ? this.parsedPath.operator : null;
if (ppdo != null) {
var dat = (this.immediateparent cast LzNode).updateData();
if (dat !== void(0)) {
@@ -558,28 +564,21 @@
/**
* @access private
*/
-override function toString( ){
+override function toString() :String {
return "Datapath for " + this.immediateparent;
}
-
/**
- * these are the events that datapaths publish. This is used by the replication
- * manager to copy and delegates that are registered when it replaces the
- * original datapath
* @access private
*/
-var _dpevents = [ 'ondata' , 'onerror' , 'ontimeout' ];
-
-/**
- * @access private
- */
-override function __LZcheckChange ( chgpkg ){
- if ( !super.__LZcheckChange.apply(this, arguments) ){
+override function __LZcheckChange (chgpkg:Object) :Boolean {
+ if ( !super.__LZcheckChange(chgpkg) ){
if ( chgpkg.who.childOfNode( this.p , true ) && this.onDocumentChange.ready){
this.onDocumentChange.sendEvent( chgpkg );
}
}
+
+ return false;
}
@@ -594,17 +593,15 @@
*
* @access private
*/
-override function __LZsetTracking ( who, additive = null, needscheck = null ) {
+override function __LZsetTracking ( who, additive:Boolean = false, needscheck:Boolean = false) :void {
#pragma 'warnUndefinedReferences=true'
- var tracking;
- var trackDel;
// If setting tracking to null or not in additive mode, just
// invoke the superclass method, forcing tracking
if ((! who) || (! additive)) {
return super.__LZsetTracking(who, true);
}
- tracking = this.__LZtracking;
- trackDel = this.__LZtrackDel;
+ var tracking:Array = this.__LZtracking;
+ var trackDel:LzDelegate = this.__LZtrackDel;
// This appears to be an assumption of the previous
// implementation. Check that it is true.
if ($debug) {
@@ -614,8 +611,8 @@
}
// Are we already tracking this?
if ( needscheck ){
- var l = tracking.length;
- for ( var i = 0; i < l; i++ ) {
+ var len:int = tracking.length;
+ for ( var i:int = 0; i < len; i++ ) {
if( tracking[ i ] === who ) {
return;
}
@@ -632,21 +629,19 @@
trackDel.register( who , "onDocumentChange" );
}
-/** @access private */
-var __LZisclone = false;
-
/**
* @access private
* @devnote Setter for datacontrolsvisiblity
*/
-function $lzc$set_datacontrolsvisibility (v)
-{ this.datacontrolsvisibility = v;}
+function $lzc$set_datacontrolsvisibility (v) :void {
+ this.datacontrolsvisibility = v;
+}
/**
* @access private
* @devnote Setter for __LZmanager
*/
-function $lzc$set___LZmanager (m) {
+function $lzc$set___LZmanager ( m:LzReplicationManager ) :void {
this.__LZisclone = true;
this.immediateparent.cloneManager = m;
this.parsedPath = m.parsedPath;
@@ -658,9 +653,9 @@
* Called by the clone manager to point the datapath to the right node
* @access private
*/
-function setClonePointer( p ) {
+function setClonePointer( p /*:LzDataNodeMixin*/ ) :void {
//Debug.write("%s: for %w, was %w (dp.sel=%w, p.sel=%w)", arguments.callee, p, this.p, this.sel, p.sel);
- var pc = this.p !=p;
+ var pc:Boolean = this.p != p;
this.p = p;
//FIXME: [20080327 anba] LPP-5328
@@ -680,7 +675,7 @@
/**
* @access private
*/
-override function setSelected (torf:Boolean) {
+override function setSelected (torf:Boolean) :void {
this.p.sel = torf;
this.sel = torf;
@@ -690,29 +685,33 @@
/**
* @access private
*/
-override function __LZgetLast( ){
- if ( this.__LZisclone ) return this.context.nodes.length;
-
- else if ( this.p == this.context.getContext() &&
- this.context.__LZgetLast ){
- return this.context.__LZgetLast();
+override function __LZgetLast() :int {
+ var context:* = this.context;
+ if ( this.__LZisclone ) {
+ return context.nodes.length;
+ } else if ( this.p == context.getContext() &&
+ context is LzDatapointer ){
+ return context.__LZgetLast();
+ } else {
+ return 1;
}
-
- return 1;
}
/**
* @access private
*/
-override function __LZgetPosition( ){
- if ( this.__LZisclone ) return this.immediateparent.clonenumber + 1;
-
- else if ( this.p == this.context.getContext() &&
- this.context.__LZgetPosition ){
- return this.context.__LZgetPosition();
+override function __LZgetPosition() :int {
+ if ( this.__LZisclone ) {
+ return this.immediateparent.clonenumber + 1;
+ } else {
+ var context:* = this.context;
+ if ( this.p == context.getContext() &&
+ context is LzDatapointer ){
+ return context.__LZgetPosition();
+ } else {
+ return 1;
+ }
}
-
- return 1;
}
} // End of LzDatapth
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs 2008-05-28 16:45:00 UTC (rev 9353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs 2008-05-28 16:53:32 UTC (rev 9354)
@@ -78,58 +78,70 @@
/** @access private
* @modifiers override
*/
-static var tagname = 'datapointer';
+static var tagname :String = 'datapointer';
// static var attributes = new LzInheritedHash(LzNode.attributes);
// [2006-07-25 pbr] This clears out what is defined in LzNode. Is this
// ok?
/** @access private */
- static var attributes = {ignoreplacement: true};
+static var attributes :Object = {ignoreplacement: true};
- // swf9 issues a runtime error without this
- /** @access private */
- function $lzc$set_ignoreplacement (v) {this.ignoreplacement = v;}
+// swf9 issues a runtime error without this
+/** @access private */
+function $lzc$set_ignoreplacement (v) :void {
+ this.ignoreplacement = v;
+}
- /** @access private */
- function $lzc$set_xpath (v) { this.setXPath(v); }
- /** @access private */
- function $lzc$set_context (v) { this.setDataContext(v); }
+/** @access private */
+function $lzc$set_xpath (v) :void {
+ this.setXPath(v);
+}
- /** @access private */
- function $lzc$set_pointer (v) { this.setPointer(v); }
- /** @access private */
- function $lzc$set_p (v) { this.setPointer(v); }
+/** @access private */
+function $lzc$set_context (v) :void {
+ this.setDataContext(v);
+}
+/** @access private */
+function $lzc$set_pointer (v) :void {
+ this.setPointer(v);
+}
+
+/** @access private */
+function $lzc$set_p (v) :void {
+ this.setPointer(v);
+}
+
/** The LzDataNodeMixin that the datapointer is pointing
* to. Calling <method>setAttribute</method> on attribute calls
* <method>LzDatapointer.setPointer</method>.
* @type LzDataNodeMixin
*/
-var p = null;
+var p /*:LzDataNodeMixin*/ = null;//TODO: uncomment after LPP-5840
// var data = null;
/** The reference to a clonemanager from a clone.
@modifiers readonly */
-var context = null;
+var context :* = null;
/** @access private */
-var __LZtracking = null;
+var __LZtracking :Array = null;
/** @access private */
-var __LZtrackDel = null;
+var __LZtrackDel :LzDelegate = null;
/** @access private */
-var xpath = null;
+var xpath :String = null;
/** @access private */
-var parsedPath = null;
+var parsedPath :LzParsedPath = null;
/** @access private */
-var __LZlastdotdot = null;
+var __LZlastdotdot :LzDataElementMixin = null;
/** @access private */
-var __LZspecialDotDot = false;
+var __LZspecialDotDot :Boolean = false;
/** @access private */
-var __LZdotdotCheckDel;
+var __LZdotdotCheckDel :LzDelegate = null;
/** @access private */
-var errorDel;
+var errorDel :LzDelegate = null;
/** @access private */
-var timeoutDel;
+var timeoutDel :LzDelegate = null;
/** This determines the behavior of the
@@ -146,12 +158,15 @@
*
* @type Boolean
*/
-var rerunxpath = false;
+var rerunxpath :Boolean = false;
+
/** @lzxtype event
@access private */
-var onp = LzDeclaredEvent;
+var onp :LzDeclaredEventClass = LzDeclaredEvent;
/** @lzxtype event
- * @access private
+ * @access private */
+var onDocumentChange :LzDeclaredEventClass = LzDeclaredEvent;
+/** @lzxtype event
* Sent when the data selected by this datapointer's <attribute>xpath</attribute>
* changes. For XPaths which select a datanode, this means that the
* datapointer is pointing to a new node. For XPaths which select text data,
@@ -159,39 +174,23 @@
* text selected by the <attribute>xpath</attribute> has changed. Note that a datapointer mapped to
* a data node will not receive <event>ondata</event> when the node, say, changes one of
* its attributes. */
-var onDocumentChange = LzDeclaredEvent;
-/** @lzxtype event */
// var ondata = LzDeclaredEvent;
/** Sent when the dataset that the datapointer
* is pointing to generates an error.
* @lzxtype event
*/
-var onerror = LzDeclaredEvent;
+var onerror :LzDeclaredEventClass = LzDeclaredEvent;
/** Sent when a request by the dataset that
* the datapointer is pointing to times out.
* @lzxtype event
*/
-var ontimeout = LzDeclaredEvent;
+var ontimeout :LzDeclaredEventClass = LzDeclaredEvent;
/** @lzxtype event
* @access private */
-var onrerunxpath = LzDeclaredEvent;
+var onrerunxpath :LzDeclaredEventClass = LzDeclaredEvent;
- function LzDatapointer ( parent:* = null , attrs:* = null, children:* = null, instcall:* = null) {
- super (parent, attrs, children, instcall);
- }
-
-//to set datapointer to datasource:dataset
-//<datapointer xpath="foo:bar/">
-//or just dataset
-//<datapointer xpath="bar/">
-
-/** @access private */
-function childOrSelf ( p ){
- var cp = this.p;
- do {
- if ( cp == p ) return true;
- cp = cp.$p;
- } while( cp && cp.$n <= this.p.$n );
+function LzDatapointer ( parent:* = null , attrs:* = null, children:* = null, instcall:* = null) {
+ super (parent, attrs, children, instcall);
}
/**
@@ -199,16 +198,16 @@
* the dataset it's pointing to.
* @access private
*/
-function gotError ( msg ){
- if (this.onerror.ready) this.onerror.sendEvent( msg );
+function gotError ( ds:LzDataset ) :void {
+ if (this.onerror.ready) this.onerror.sendEvent( ds );
}
/**
* Called when the datapointer's dataset's request times out...
* @access private
*/
-function gotTimeout ( msg ){
- if (this.ontimeout.ready) this.ontimeout.sendEvent( msg );
+function gotTimeout ( ds:LzDataset ) :void {
+ if (this.ontimeout.ready) this.ontimeout.sendEvent( ds );
}
/**
@@ -222,19 +221,26 @@
* <dt>an array of <classname>LzDataElement</classname></dt><dd>if the query resolves to multiple nodes</dd>
* </dl>
*/
-function xpathQuery ( p ){
- var pp = this.parsePath ( p );
- var ppcontext = pp.getContext(this);
- var nodes = this.__LZgetNodes( pp , ppcontext ? ppcontext : this.p);
- if ( ! nodes ) return null;
+function xpathQuery ( p:Object ) :* {
+ var pp:LzParsedPath = this.parsePath( p );
+ //LzParsedPath#getContext(LzDatapointer) returns either
+ //LzDataset or AnonDatasetGenerator -> make interface?
+ var ppcontext:* = pp.getContext( this );
+ var nodes:* = this.__LZgetNodes( pp , ppcontext ? ppcontext : this.p );
+
+ if ( nodes == null ) return null;
if ( pp.aggOperator != null ){
if ( pp.aggOperator == 'last' ){
- return nodes.length || this.__LZgetLast();
- } if ( pp.aggOperator == 'position' ){
- if ( nodes.length ){
- var rarr = [];
- for ( var i =0; i < nodes.length; i++ ){
+ if (nodes is Array) {
+ return nodes.length;
+ } else {
+ return this.__LZgetLast();
+ }
+ } else if (pp.aggOperator == 'position') {
+ if (nodes is Array) {
+ var rarr:Array = [];
+ for (var i:int = 0; i < nodes.length; i++) {
rarr.push( i + 1 );
}
return rarr;
@@ -243,9 +249,9 @@
}
}
} else if ( pp.operator != null ){
- if ( nodes.length ){
- var oarr = [];
- for ( var i = 0; i < nodes.length; i++ ){
+ if (nodes is Array) {
+ var oarr:Array = [];
+ for (var i:int = 0; i < nodes.length; i++) {
oarr.push( this.__LZprocessOperator( nodes[ i ] , pp ) );
}
return oarr;
@@ -257,9 +263,9 @@
}
}
/** @access private */
-function $lzc$xpathQuery_dependencies ( who , self , p ){
- if (this.parsePath) {
- var pp = this.parsePath( p );
+function $lzc$xpathQuery_dependencies (who, self, p) :Array {
+ if (this['parsePath']) {
+ var pp:LzParsedPath = this.parsePath( p );
return [ pp.hasDotDot ? self.context.getContext().ownerDocument : self ,
"DocumentChange" ];
} else {
@@ -271,7 +277,7 @@
* Points this datapointer at p.
* @param LzDataNodeMixin p: The new target for this datapointer.
*/
-function setPointer ( p ) {
+function setPointer ( p /*:LzDataNodeMixin*/ ) :Boolean {
this.setXPath( null );
if ( p != null ){
this.setDataContext( p.ownerDocument );
@@ -279,8 +285,8 @@
this.__LZsetTracking( null );
}
- var dc = this.data != p;
- var pc = this.p != p;
+ var dc:Boolean = this.data != p;
+ var pc:Boolean = this.p != p;
this.p = p;
this.data = p;
@@ -293,12 +299,16 @@
* Returns a reference to the datapointer's dataset.
* @return LzDataset: The datapointer's dataset
*/
-function getDataset ( ){
- if ( this.p == null ) {
- if ( this.context == this ) return null;
- return this.context.getDataset();
+function getDataset () :LzDataset {
+ if (this.p == null) {
+ if (this.context === this) {
+ return null;
+ } else {
+ return this.context.getDataset();
+ }
+ } else {
+ return this.p.ownerDocument;
}
- return this.p.ownerDocument;
}
/**
@@ -315,9 +325,8 @@
* single node, <code>false</code> if no or multiple nodes are
* matched, <code>undefined</code> if the path is invalid.
*/
-function setXPath ( p ){
- var hasxpath = p;
- if (! hasxpath) {
+function setXPath ( p:String ) :Boolean? {
+ if (! p) {
this.xpath = null;
this.parsedPath = null;
// track if there's an ownerDocument
@@ -327,7 +336,7 @@
this.xpath = p;
this.parsedPath = this.parsePath( p );
- var ppcontext = this.parsedPath.getContext(this);
+ var ppcontext:* = this.parsedPath.getContext(this);
if ( this.rerunxpath &&
this.parsedPath.hasDotDot &&
@@ -346,12 +355,12 @@
}
/** @access private */
-function runXPath ( ){
+function runXPath () :Boolean {
if ( !this.parsedPath ) {
return;
}
- var newc = null;
+ var newc /*:LzDataNodeMixin*/ = null;
// [2008-04-03 pbr] Find a simpler way to represent this
// if ( this.context && 'getContext' in this.context ){
if ( this.context && (this.context is LzDatapointer || this.context is LzDataset || this.context is AnonDatasetGenerator)) {
@@ -359,47 +368,44 @@
}
if ( newc ) {
- var n = this.__LZgetNodes( this.parsedPath , newc , 0 );
+ var n:* = this.__LZgetNodes( this.parsedPath , newc , 0 );
} else {
- var n = null;
+ var n:* = null;
}
- if ( !n ){
+ if ( n == null ) {
//no node found
this.__LZHandleNoNodes();
return false;
// [2008-03-12 pbr] Use 'is' to see if it's an array, not n.length
// }else if ( n.length ) {
- }else if ( n is Array ) {
+ } else if ( n is Array ) {
this.__LZHandleMultiNodes( n );
return false;
} else {
this.__LZHandleSingleNode( n );
return true;
}
-
}
/** @access private */
-function __LZsetupDotDot ( p ){
+function __LZsetupDotDot ( p ) :void {
if ( this.__LZlastdotdot != p.ownerDocument ){
//this requires special processing, since it doesn't only depend
//on its context
- if ( !this.__LZdotdotCheckDel ){
- this.__LZdotdotCheckDel = new LzDelegate( this ,
- "__LZcheckDotDot" );
+ if ( this.__LZdotdotCheckDel == null ){
+ this.__LZdotdotCheckDel = new LzDelegate( this, "__LZcheckDotDot" );
} else {
this.__LZdotdotCheckDel.unregisterAll();
}
this.__LZlastdotdot = p.ownerDocument;
- this.__LZdotdotCheckDel.register( this.__LZlastdotdot ,
- "onDocumentChange" );
+ this.__LZdotdotCheckDel.register( this.__LZlastdotdot cast LzEventable, "onDocumentChange" );
}
}
/** @access private */
-function __LZHandleSingleNode ( n ){
+function __LZHandleSingleNode ( n /*:LzDataNodeMixin*/ ) :void {
if ( this.__LZspecialDotDot ) this.__LZsetupDotDot( n );
this.__LZupdateLocked = true;
@@ -416,10 +422,9 @@
}
/** @access private */
-function __LZHandleNoNodes ( ){
-
- var pc = this.p != null;
- var dc = this.data != null;
+function __LZHandleNoNodes () :void {
+ var pc:Boolean = this.p != null;
+ var dc:Boolean = this.data != null;
this.p = null;
this.data = null
this.__LZsendUpdate( dc , pc );
@@ -427,20 +432,22 @@
/** @access private */
-function __LZHandleMultiNodes ( n ){
+function __LZHandleMultiNodes ( n:Array ) :LzReplicationManager {
if ($debug) {
Debug.error("%w matched %d nodes", this, n.length);
}
this.__LZHandleNoNodes();
+
+ return void(0);
}
/** @access private */
-function __LZsetData ( ){
+function __LZsetData () :void {
if ( this.parsedPath && this.parsedPath.aggOperator != null ){
if ( this.parsedPath.aggOperator == 'last' ){
this.data = this.__LZgetLast();
this.__LZsendUpdate( true );
- } if ( this.parsedPath.aggOperator == 'position' ){
+ } else if ( this.parsedPath.aggOperator == 'position' ){
this.data = this.__LZgetPosition();
this.__LZsendUpdate( true );
}
@@ -455,26 +462,26 @@
}
/** @access private */
-function __LZgetLast ( ){
- if ( this.context == this ) return 1;
+function __LZgetLast () :int {
+ if ( this.context === this ) return 1;
return this.context.__LZgetLast() || 1;
}
/** @access private */
-function __LZgetPosition ( ){
- if ( this.context == this ) return 1;
+function __LZgetPosition () :int {
+ if ( this.context === this ) return 1;
return this.context.__LZgetPosition() || 1;
}
/** @access private */
-var __LZupdateLocked = false;
+var __LZupdateLocked :Boolean = false;
/** @access private */
-var __LZpchanged = false;
+var __LZpchanged :Boolean = false;
/** @access private */
-var __LZdchanged = false;
+var __LZdchanged :Boolean = false;
/** @access private */
-function __LZsendUpdate ( upd = null, upp = null ){
+function __LZsendUpdate (upd:Boolean = false, upp:Boolean = false) :Boolean {
this.__LZdchanged = upd || this.__LZdchanged;
this.__LZpchanged = upp || this.__LZpchanged;
@@ -503,15 +510,15 @@
* Tests whether or not this datapointer is pointing to a valid node.
* @return Boolean: True if the current node is valid.
*/
-function isValid ( ){
+function isValid () :Boolean {
return this.p != null;
}
/** @access private */
-function __LZsimpleOperatorUpdate ( ){
- var ndat = this.__LZprocessOperator( this.p , this.parsedPath );
+function __LZsimpleOperatorUpdate () :void {
+ var ndat:* = this.__LZprocessOperator( this.p , this.parsedPath );
//second clause is necessary to process updates for @*
- var dchanged = false;
+ var dchanged:Boolean = false;
if ( this.data != ndat || this.parsedPath.operator == "attributes" ){
this.data = ndat;
dchanged = true;
@@ -520,7 +527,7 @@
}
/** @access private */
-static var ppcache = {};
+static var ppcache :Object = {};
/**
* Parses a fully qualified XPath and yields an object with the components
@@ -533,14 +540,18 @@
* Canonical xpath: dsrc:dset:/nodea/nodeb[2-8]
* @access private
*/
-function parsePath ( pa ){
- if (pa instanceof LzDatapath) pa = pa.xpath;
+function parsePath (pa:*) :LzParsedPath {
+ if (pa is LzDatapath) {
+ var xp:String = (pa cast LzDatapath).xpath;
+ } else {
+ var xp:String = (pa cast String);
+ }
- var ppc = LzDatapointer.ppcache;
- var q = ppc[ pa ];
+ var ppc:Object = LzDatapointer.ppcache;
+ var q:LzParsedPath = ppc[ xp ];
if (q == null) {
- q = new LzParsedPath(pa, this);
- ppc[ pa ] = q;
+ q = new LzParsedPath(xp, this);
+ ppc[ xp ] = q;
}
return q;
@@ -550,21 +561,20 @@
* Locates a local data context based on the parsed path
* @access private
*/
-function getLocalDataContext(pp) {
- var n = this.parent;
+function getLocalDataContext(pp:Array) :LzDataset {
+ var n:LzNode = this.parent;
if (pp) {
- var a = pp;
- for (var i = 0; i < a.length; i++) {
- //Debug.write(n + '.' + a[i] + '=' + n[a[i]]);
- if (n) n = n[a[i]];
+ var a:Array = pp;
+ for (var i:int = 0; i < a.length && n != null; i++) {
+ n = n[a[i]];
}
- if (n && n instanceof LzDataset == false && n['localdata'] instanceof LzDataset == true) {
+ if (n != null && !(n is LzDataset) && n['localdata'] is LzDataset) {
n = n['localdata']
+ return n;
}
}
- if (n != null && n instanceof LzDataset) {
- //Debug.write('found local dataset', n);
+ if (n != null && n is LzDataset) {
return n;
} else {
if ($debug) {
@@ -577,12 +587,11 @@
//Table of xpath node operator symbols and the functions they call
/** @access private */
-var pathSymbols= { '/': 1, '..': 2, '*': 3, '.': 4};
+static const pathSymbols :Object = { '/': 1, '..': 2, '*': 3, '.': 4};
/** @access private */
-function __LZgetNodes ( pathobj , p , startpoint = null ){
- var np;
+function __LZgetNodes (pathobj:LzParsedPath, p:*, startpoint:int = 0) :* {
if ( p == null ){
if ( $debug ) {
@@ -593,37 +602,36 @@
if (pathobj.selectors != null) {
- var pathlen = pathobj.selectors.length;
- var ignorenext = 0;
+ var pathlen:int = pathobj.selectors.length;
+
+ for ( var i:int = startpoint; i < pathlen; i++ ){
- for ( var i = startpoint ? startpoint : 0 ; i < pathlen; i++ ){
-
- var cp = pathobj.selectors[ i ];
- var specialop = this.pathSymbols [ cp ];
- var posnext = pathobj.selectors[ i+1 ];
+ var cp:* = pathobj.selectors[ i ];
+ var specialop:int = LzDatapointer.pathSymbols[ cp ] || 0;
+ var posnext:* = pathobj.selectors[ i+1 ];
if ( posnext && !(posnext is String) && posnext['pred'] == "range" ){
//next is range operator
//we'll handle that in this pass, so increment counter again
- var range = pathobj.selectors[ ++i ];
+ var range:Array = (pathobj.selectors[ ++i ] cast Array);
} else {
- var range = null;
+ var range:Array = null;
}
- np = null;
+ var np:Array = null;
// [2008-04-01 pbr] Make sure cp is an Object (ie. hash)
if ( cp is Object && 'pred' in cp && null != cp.pred ){
if ( cp.pred == "hasattr" ){
- p = p.hasAttr( cp.attr ) ? p : false;
+ p = p.hasAttr( cp.attr ) ? p : null;
} else if ( cp.pred == "attrval" ){
if (p.attributes != null) {
- p = p.attributes[ cp.attr ] == cp.val ? p : false;
+ p = p.attributes[ cp.attr ] == cp.val ? p : null;
} else {
- p = false;
+ p = null;
}
}
- } else if ( !specialop ){
+ } else if ( specialop == 0 ){
//named node
np = this.nodeByName( cp , range , p );
} else if ( specialop == 1 ){
@@ -635,17 +643,22 @@
} else if ( specialop == 3 ) {
//all children
np = [];
- var cnt = 0;
if (p.childNodes) {
- for ( var j = 0; j < p.childNodes.length;j++ ){
- //remove nulls and text nodes
- if ( p.childNodes[ j ].nodeType==LzDataElement.ELEMENT_NODE){
+ var cnodes:Array = p.childNodes;
+ var len:int = cnodes.length;
+ var rleft:int = range != null ? range[0] : 0;
+ var rright:int = range != null ? range[1] : len;
+ var cnt:int = 0;
+ for ( var j:int = 0; j < len; j++ ){
+ //remove text nodes
+ var cn /*:LzDataNodeMixin*/ = cnodes[j];
+ if (cn.nodeType == LzDataElement.ELEMENT_NODE) {
cnt++;
- if ( !range || cnt >= range[ 0 ] ){
- np.push( p.childNodes[ j ] );
+ if (cnt >= rleft) {
+ np.push( cn );
}
- if ( range && cnt == range[ 1 ] ){
+ if (cnt == rright) {
break;
}
}
@@ -658,35 +671,40 @@
if ( np != null ){
if ( np.length > 1 ){
- var rval = [];
if ( i == pathlen - 1 ){
return np;
} //else
-
- for ( var j = 0; j < np.length; j++ ){
- var r = this.__LZgetNodes( pathobj , np[ j ], i+1 );
-
- if ( r != null && r.length > 0 ){
- for ( var n= 0; n < r.length; n++ ){
- if ( r[ n ]) rval.push( r[ n ] );
+
+ var rval:Array = [];
+ for ( var j:int = 0; j < np.length; j++ ){
+ var r:* = this.__LZgetNodes( pathobj , np[ j ], i+1 );
+
+ if (r != null) {
+ if (r is Array) {
+ for ( var n:int = 0; n < r.length; n++ ){
+ rval.push( r[ n ] );
+ }
+ } else {
+ rval.push( r );
}
- } else if ( r ) rval.push ( r );
-
+ }
}
-
- if ( !rval.length ) {
+
+ if ( rval.length == 0 ) {
return null;
}else if (rval.length == 1){
return rval[ 0 ];
- } else return rval;
+ } else {
+ return rval;
+ }
} else {
p = np [ 0 ];//I've finally proven it!
}
}
-
- if ( ! p ){
- return false;
+
+ if (p == null) {
+ return null;
}
}
}
@@ -699,7 +717,7 @@
* one datapointer to function as the datacontext for another
* @access private
*/
-function getContext ( chgpkg = null ){
+function getContext ( chgpkg = null ) :* {
return this.p;
}
@@ -711,35 +729,40 @@
* @param range: range string
* @return: null or an offset
*/
-function nodeByName ( name, range , p) {
- var o = [];
- var cnt = 0;
- if ( !p ){
- var p = this.p;
+function nodeByName (name:String, range:Array, p/*:LzDataNodeMixin*/) :Array {
+ if ( !p ) {
+ p = this.p;
if ( ! this.p ) return null;
}
- if (p.childNodes) {
- for ( var i = 0; i < p.childNodes.length; i++ ){
- var cn = p.childNodes[i];
- if ( cn && cn.nodeName == name ){
+ var o:Array = [];
+
+ if (p.childNodes != null) {
+ var cnodes:Array = p.childNodes;
+ var len:int = cnodes.length;
+ var rleft:int = range != null ? range[0] : 0;
+ var rright:int = range != null ? range[1] : len;
+ var cnt:int = 0;
+ for (var i:int = 0; i < len; i++) {
+ var cn /*:LzDataNodeMixin*/ = cnodes[i];
+ if (cn.nodeName == name) {
//match
cnt++;
- if ( !range || cnt >= range[ 0 ] ){
+ if (cnt >= rleft) {
o.push( cn );
}
- if ( range && cnt == range[ 1 ] ){
+ if (cnt == rright) {
break;
}
}
}
}
- //Debug.write( "node by name returning: " + o + " for " + name );
+
return o;
}
/** @access private */
-function $lzc$set_rerunxpath ( rrx ){
+function $lzc$set_rerunxpath (rrx:Boolean) :void {
this.rerunxpath = rrx;
if (this.onrerunxpath.ready) this.onrerunxpath.sendEvent( rrx );
@@ -749,25 +772,25 @@
* Return a new datapointer that points to the same node, has a
* <code>null</code> <attribute>xpath</attribute> and a
* <code>false</code> <attribute>rerunxpath</attribute> attribute.
- * @return LzDataPointer: A new datapointer that points to the same spot as this
+ * @return LzDatapointer: A new datapointer that points to the same spot as this
* one, but
*/
-function dupePointer (){
- var dp = new LzDatapointer( );
+function dupePointer () :LzDatapointer {
+ var dp:LzDatapointer = new LzDatapointer();
dp.setFromPointer( this );
return dp;
}
/** @access private */
-function __LZdoSelect (selector, amnt) {
- amnt = amnt ? amnt : 1;
- var np = this.p;
+function __LZdoSelect (selector:String, amnt:int) :Boolean {
+ var np /*:LzDataNodeMixin*/ = this.p;
for (; np != null && amnt > 0; amnt--) {
- if (typeof (np[selector]) == 'function') {
- np = np[selector]();
- }
+ if (np.nodeType == LzDataNode.TEXT_NODE) {
+ if (selector == 'getFirstChild') break;
+ }
+ np = np[selector]();
}
- if (np != null) {
+ if (np != null && amnt == 0) {
this.setPointer( np );
return true;
}
@@ -781,8 +804,8 @@
* <param>amnt</param> is <code>1</code>.
* @return Boolean: True if the pointer was able to move forward <param>amnt</param> nodes.
*/
-function selectNext ( amnt = null ) {
- return this.__LZdoSelect('getNextSibling', amnt);
+function selectNext (amnt = null) :Boolean {
+ return this.__LZdoSelect('getNextSibling', amnt ? amnt : 1);
}
/**
@@ -792,8 +815,8 @@
* @return Boolean: True if the pointer was able to move back
* <param>amnt</param> nodes.
*/
-function selectPrev ( amnt ){
- return this.__LZdoSelect('getPreviousSibling', amnt);
+function selectPrev (amnt = null) :Boolean {
+ return this.__LZdoSelect('getPreviousSibling', amnt ? amnt : 1);
}
/**
@@ -803,8 +826,8 @@
* <code>null</code>, <param>amnt</param> is <code>1</code>.
* @return Boolean: True if the pointer was able to move down <param>amnt</param> nodes.
*/
-function selectChild ( amnt ) {
- return this.__LZdoSelect('getFirstChild', amnt);
+function selectChild (amnt = null) :Boolean {
+ return this.__LZdoSelect('getFirstChild', amnt ? amnt : 1);
}
/**
@@ -815,13 +838,13 @@
* @return Boolean: A Boolean indicating if the pointer was able to move up
* <param>amnt</param> nodes.
*/
-function selectParent ( amnt = null ){
- return this.__LZdoSelect('getParent', amnt);
+function selectParent (amnt = null) :Boolean {
+ return this.__LZdoSelect('getParent', amnt ? amnt : 1);
}
/** @access private */
-function selectNextParent ( ){
- var op = this.p;
+function selectNextParent () :Boolean {
+ var op /* :LzDataNodeMixin*/ = this.p;
if ( this.selectParent() && this.selectNext() ){
return true;
} else {
@@ -836,7 +859,7 @@
* LzDataElement.DOCUMENT_NODE or <code>undefined</code> if this datapointer
* does not point to a valid node
*/
-function getNodeType (){
+function getNodeType () /*:Number?*/ :* {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -851,7 +874,7 @@
* Gets the name of the node that the datapointer is pointing to.
* @return String: The name of the datapointer's node
*/
-function getNodeName (){
+function getNodeName () :String {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -865,7 +888,7 @@
* Sets the name of the current element to the <param>name</param>.
* @param String name: The new name for the datapointer's node
*/
-function setNodeName (name){
+function setNodeName (name:String) :void {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -873,9 +896,9 @@
return;
}
if (this.p.nodeType != LzDataElement.TEXT_NODE) {
- this.p.setNodeName( name );
+ this.p.setNodeName( name );
+ }
}
-}
/**
* Returns the attributes of the node pointed to by the datapointer in an
@@ -884,7 +907,7 @@
* @return Object: An Object which represents the keys and values of the node
* attributes
*/
-function getNodeAttributes (){
+function getNodeAttributes () :Object {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -901,7 +924,7 @@
* @param String name: The attribute to retrieve.
* @return String: The value of the attribute.
*/
-function getNodeAttribute (name){
+function getNodeAttribute (name:String) :String {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -919,7 +942,7 @@
* @param String name: The name of the attribute to set
* @param String val: The value for the attribute
*/
-function setNodeAttribute (name, val) {
+function setNodeAttribute (name:String, val:String) :void {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -935,7 +958,7 @@
* Removes the <param>name</param> attribute from the current node.
* @param String name: The name of the attribute to delete.
*/
-function deleteNodeAttribute (name) {
+function deleteNodeAttribute (name:String) :void {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -954,7 +977,7 @@
* non-element data nodes.
* @return String: The text in the node pointed to by the datapointer.
*/
-function getNodeText (){
+function getNodeText () :String {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -975,7 +998,7 @@
*
* @param String val: The new string for the node's text
*/
-function setNodeText (val) {
+function setNodeText (val:String) :void {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -985,10 +1008,12 @@
if (this.p.nodeType != LzDataElement.TEXT_NODE) {
// set the first text node you find; otherwise add one
- var foundit = false;
- for (var i = 0; i < this.p.childNodes.length; i++) {
- if ( this.p.childNodes[i].nodeType == LzDataElement.TEXT_NODE ) {
- this.p.childNodes[i].setData( val );
+ var foundit:Boolean = false;
+ var cnodes:Array = this.p.childNodes;
+ for (var i:int = 0; i < cnodes.length; i++) {
+ var cn /*:LzDataNodeMixin*/ = cnodes[i];
+ if (cn.nodeType == LzDataElement.TEXT_NODE) {
+ cn.setData( val );
foundit = true;
break;
}
@@ -1005,7 +1030,7 @@
* datapointer is pointing to.
* @return Integer: The number of child nodes for the current node
*/
-function getNodeCount (){
+function getNodeCount () :int {
if (! this.p || this.p.nodeType == LzDataElement.TEXT_NODE) return 0;
return this.p.childNodes.length || 0;
}
@@ -1020,7 +1045,7 @@
* attributes for this node.
* @return LzDataElement: the new node
*/
-function addNode ( name, text , attrs ){
+function addNode (name:String, text:String = null, attrs:Object = null) :LzDataElement {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -1028,7 +1053,7 @@
return;
}
- var nn = new LzDataElement( name , attrs );
+ var nn:LzDataElement = new LzDataElement( name , attrs );
if ( text != null ){
nn.appendChild( new LzDataText( text ) );
}
@@ -1047,7 +1072,7 @@
* has a following sibling, the pointer is repositioned at that sibling.
* Otherwise the pointer is set to <code>null</code>.
*/
-function deleteNode(){
+function deleteNode() /*:LzDataNodeMixin*/ {
if ( ! this.p ) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -1055,7 +1080,7 @@
return;
}
- var op = this.p
+ var op /*:LzDataNodeMixin*/ = this.p
if ( !this.rerunxpath ){
//move the pointer to the next sibling
if (!this.selectNext() ) {
@@ -1071,7 +1096,7 @@
}
/** @access private */
-function sendDataChange ( chgpkg ){
+function sendDataChange ( chgpkg ) :void {
//chgpkg.a(ction): d: delete, m:modify , a:add , null - refreshall
//chgpkg.p(ointer))
this.getDataset().sendDataChange( chgpkg );
@@ -1082,7 +1107,7 @@
* @param LzDatapointer ptr: The datapointer to compare to this one.
* @return Boolean: True if the datapointers are pointing to the same node.
*/
-function comparePointer ( ptr ){
+function comparePointer (ptr:LzDatapointer) :Boolean {
return this.p == ptr.p;
}
@@ -1092,7 +1117,7 @@
* @param LzDatapointer dp: A pointer to the node to add
* @return LzDatapointer: A pointer to the new node
*/
-function addNodeFromPointer ( dp ){
+function addNodeFromPointer (dp:LzDatapointer) :LzDatapointer {
if ( ! dp.p ) return;
if ( ! this.p ) {
if ( $debug ) {
@@ -1101,10 +1126,10 @@
return;
}
- var n = dp.p.cloneNode( true );
+ var n/*:LzDataNodeMixin*/ = dp.p.cloneNode( true );
if (this.p.nodeType != LzDataElement.TEXT_NODE) {
- this.p.appendChild( n );
+ this.p.appendChild( n );
}
return new LzDatapointer( null , { pointer : n } );
@@ -1112,16 +1137,16 @@
/**
* Sets this datapointer to the location of the given datapointer
- * @param LzDataPointer dp: The datapointer which has the desired location for
+ * @param LzDatapointer dp: The datapointer which has the desired location for
* this datapointer.
*/
-function setFromPointer ( dp ){
+function setFromPointer ( dp:LzDatapointer ) :void {
this.setPointer( dp.p );
}
/** @access private */
-function __LZprocessOperator ( p , pp , depends = null ){
+function __LZprocessOperator (p, pp, depends = null) :* {
if (p == null) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -1129,26 +1154,28 @@
return;
}
- if ( pp.operatorArgs != null ){
+ if (pp.operatorArgs != null) {
+ //"text()" [__LZgetText()] or "serialize()"
return p[ pp.operator ] ( pp.operatorArgs );
}
// LzParsedPath.initialize() created pp.operator. If 'attributes',
// don't use split(".") to separate the string because '.' is
// a valid XML character.
- var parts;
+ var parts:Array;
if (pp.operator.indexOf("attributes.") == 0) {
+ //operator: "attributes.xxx"
parts = ['attributes', pp.operator.substr(11)]
+ } else {
+ //operator: "attributes", "nodeName"
+ parts = [pp.operator];
}
- else {
- parts = pp.operator.split(".");
- }
- var val = p;
+ var val:* = p;
// TODO: [2008-3-12 pbr] Verify this works for all cases
// I found that val can be an LzDataElement or a hash (from LzDataElement)
- for (var i = 0; i < parts.length; i++) {
- var pathElt = parts[i];
+ for (var i:int = 0; i < parts.length; i++) {
+ var pathElt:String = parts[i];
// if (val == null || !(pathElt in val)) {
if (val == null || (!(val is LzDataElement) && !(pathElt in val))) {
// TODO: [2007-3-16 hqm] I'll do what Ben did, return undefined
@@ -1163,29 +1190,28 @@
////////////////////////////////////////////////////////////////
/** @access private */
-function makeRootNode (){
+function makeRootNode () :LzDataElement {
// create the root node
return new LzDataElement( "root" );
}
/** @access private */
-function finishRootNode (n){
+function finishRootNode (n) /*:LzDataNodeMixin*/ {
// create the root node
return n.childNodes[ 0 ];
}
/** @access private */
-function makeElementNode (attrs, name, par) {
- //Debug.write( 'make ' + name );
- var tn = new LzDataElement( name , attrs );
+function makeElementNode (attrs, name, par) :LzDataElement {
+ var tn:LzDataElement = new LzDataElement( name, attrs );
par.appendChild( tn );
return tn;
}
/** @access private */
-function makeTextNode (text, par){
- var tn = new LzDataText( text );
+function makeTextNode (text, par) :LzDataText {
+ var tn:LzDataText = new LzDataText( text );
par.appendChild( tn );
return tn;
}
@@ -1214,7 +1240,7 @@
* @return String: A string of XML that represents all of the datapointer's
* contents.
*/
-function serialize ( ){
+function serialize () :String {
if ( this.p == null) {
if ( $debug ) {
Debug.info("%s: p is null in %s", arguments.callee, this);
@@ -1227,17 +1253,17 @@
if ($debug) {
/** @access private */
-function _dbg_name () {
- if (this.p) {
- return this.p._dbg_name();
- }
+function _dbg_name () :String {
+ if (this.p) {
+ return this.p._dbg_name();
+ }
}
}
/** @access private */
// The optional argument is used by LzDatapath
-function setDataContext ( dc, ignore = null ){
+function setDataContext (dc, ignore:Boolean = false) :void {
if ( dc == null ){
this.context = this;
if (this.p) {
@@ -1255,7 +1281,7 @@
this.__LZsetTracking( dc );
// When you have an xpath, register on the new context
- var hasxpath = this.xpath
+ var hasxpath:Boolean = this.xpath != null;
if (hasxpath) {
if ( this.errorDel == null ){
this.errorDel = new LzDelegate( this , "gotError" );
@@ -1269,7 +1295,7 @@
}
/** @access private */
-function __LZcheckChange ( chgpkg ){
+function __LZcheckChange ( chgpkg:Object ) :Boolean {
if ( !this.rerunxpath ){
//if no pointer or who changed was the context I point to
if ( !this.p || chgpkg.who == this.context ){
@@ -1278,6 +1304,7 @@
//only update my data if my node changed and I have an operator
this.__LZsimpleOperatorUpdate();
}
+ return false;
} else {
//type 2 change means datapointer I depend on moved
if ( chgpkg.type == 2 ||
@@ -1299,51 +1326,46 @@
}
/** @access private */
-function __LZneedsOpUpdate ( chgpkg = null ){
-
- //case 1 -- normal operator and node changed
- //case 2 -- this node is mapped to text()
- // case 2.1 -- a text node changed
- // case 2.2 -- a text node was added or removed
-
- return ( this.parsedPath && this.parsedPath.operator != null )&&
- ( this.parsedPath.operator == "__LZgetText" ?
- ( ( chgpkg.type == 0 &&
- chgpkg.who == this.p
- ) ||
- ( chgpkg.who.parentNode == this.p &&
- chgpkg.who.nodeType == LzDataElement.TEXT_NODE
- )
- )
- :
- ( chgpkg.type == 1 &&
- chgpkg.who == this.p
- )
- )
-
+function __LZneedsOpUpdate ( chgpkg:Object? = null ) :Boolean {
+ var ppath:LzParsedPath = this.parsedPath;
+ if (ppath != null && ppath.operator != null) {
+ var who /*:LzDataNodeMixin*/ = chgpkg.who;
+ var type:int = chgpkg.type;
+ if (ppath.operator != "__LZgetText") {
+ //case 1 -- normal operator and node changed
+ return (type == 1 && who == this.p);
+ } else {
+ //case 2 -- this node is mapped to text()
+ // case 2.1 -- a text node changed
+ // case 2.2 -- a text node was added or removed
+ return (type == 0 && who == this.p) ||
+ (who.parentNode == this.p && who.nodeType == LzDataElement.TEXT_NODE);
+ }
+ } else {
+ return false;
+ }
}
/** @access private */
-function __LZcheckDotDot ( chgpkg ){
+function __LZcheckDotDot ( chgpkg:Object ) :void {
//the case where I need a special update is the one where the
//change is above me, but my parent quelled it
//second clause checks that the change is above my context --
//if it's below my context, then my context will pas it on
- var who = chgpkg.who;
- if ( ( chgpkg.type == 0 ||
- ( chgpkg.type == 1 && this.parsedPath.hasOpSelector ) )
- &&
- ( this.context.getContext().childOfNode( who ) )
- ){
+ var who /*:LzDataNodeMixin*/ = chgpkg.who;
+ var type:int = chgpkg.type;
+ if ((type == 0 ||
+ (type == 1 && this.parsedPath.hasOpSelector))
+ && this.context.getContext().childOfNode( who )) {
this.runXPath();
}
}
/** @access private */
-override function destroy () {
+override function destroy () :void {
this.__LZsetTracking( null );
if ( this.errorDel ) this.errorDel.unregisterAll();
if ( this.timeoutDel ) this.timeoutDel.unregisterAll();
@@ -1371,20 +1393,20 @@
*
* @access private
*/
-function __LZsetTracking ( who, force = null, needscheck = null ){
+function __LZsetTracking (who, force:Boolean = false, needscheck:Boolean = false) :void {
#pragma 'warnUndefinedReferences=true'
- var tracking = this.__LZtracking;
- var trackDel = this.__LZtrackDel;
+ var tracking:Array = this.__LZtracking;
+ var trackDel:LzDelegate = this.__LZtrackDel;
if ( who ) {
// This appears to be an assumption of the previous
// implementation. Check that it is true.
if ($debug) {
- if (tracking instanceof Array && tracking.length > 1) {
+ if (tracking != null && tracking.length > 1) {
Debug.error('%w.__LZtracking is %w, expecting an array of length 1', this, this.__LZtracking);
}
}
// Are we already tracking this?
- if ( tracking instanceof Array &&
+ if (tracking != null &&
tracking.length == 1 &&
tracking[0] === who ) {
return;
@@ -1393,7 +1415,7 @@
// We are only tracking a single, so unregister any previous
trackDel.unregisterAll();
}
- var hasxpath = force || this.xpath;
+ var hasxpath:Boolean = force || this.xpath;
// Only track if there is an xpath
if ( hasxpath ) {
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs 2008-05-28 16:45:00 UTC (rev 9353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs 2008-05-28 16:53:32 UTC (rev 9354)
@@ -158,7 +158,7 @@
* Need to adjust the arglist coming from the event
* @access private
*/
-function __LZhandleUpdate (ignore) {
+function __LZhandleUpdate (ignore) :void {
this.__LZadjustVisibleClones(null, null);
}
@@ -170,7 +170,7 @@
/**
* @access private
*/
-override function __LZsetCloneAttrs (){
+override function __LZsetCloneAttrs () :void {
var cloneopt = { ignorelayout : true };
if ( this.cloneAttrs.options != null ){
cloneopt = new LzInheritedHash(this.cloneAttrs.options);
@@ -181,7 +181,7 @@
/**
* @access private
*/
-override function __LZHandleNoNodes( ) {
+override function __LZHandleNoNodes() :void {
this.__LZHandleMultiNodes( [ ] );
}
@@ -209,7 +209,7 @@
*
* @access private
*/
-override function __LZadjustVisibleClones (ln,nn){
+override function __LZadjustVisibleClones (ln:Array, nn:Boolean) :void {
var nodelen = null;
if (this.nodes) {
nodelen = this.nodes.length;
@@ -318,15 +318,15 @@
/**
* @access private
*/
-override function toString (){
+override function toString () :String {
return "Lazy clone manager in " + this.cloneimmediateparent;
}
/**
* @access private
*/
-override function getCloneForNode ( p , dontmake = null ){
- var cl = super.getCloneForNode( p ) ||
+override function getCloneForNode ( p , dontmake:Boolean = false ) :LzNode {
+ var cl:LzNode = super.getCloneForNode( p ) ||
null;
if ( !cl && !dontmake ){
//even though we're going to return this to the pool immediately,
@@ -345,7 +345,7 @@
/**
* @access private
*/
-override function getCloneNumber ( n ){
+override function getCloneNumber ( n:int ) :LzNode {
return this.getCloneForNode(this.nodes[n]);
}
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs 2008-05-28 16:45:00 UTC (rev 9353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs 2008-05-28 16:53:32 UTC (rev 9354)
@@ -83,25 +83,23 @@
override function $lzc$set_datapath(v) { this.setXPath(v); }
/** @access private */
-var asyncnew = true;
+var asyncnew :Boolean = true;
/** @access private */
-var initialnodes;
+var initialnodes :Array;
/** @access private */
-var clonePool;
+var clonePool :Array;
/** @access private */
var cloneClass;
/** @access private */
-var cloneParent;
+var cloneParent :LzNode;
/** @access private */
-var cloneAttrs;
+var cloneAttrs :Object;
/** @access private */
-var cloneChildren;
+var cloneChildren :Array;
/** @access private */
-var hasdata;
+var hasdata :Boolean;
/** @access private */
-var _t;
-/** @access private */
-var orderpath;
+var orderpath :*;
/** @access private */
var comp_orderf; // Was this.orderf.comp
@@ -124,39 +122,39 @@
* @lzxdefault true
* @keywords final
*/
-var visible = true;
+var visible :Boolean = true;
/** @access private */
-var __LZpreventXPathUpdate = false;
+var __LZpreventXPathUpdate :Boolean = false;
/**
* The data that this replication manager will map to views
* @type [*]
*/
-var nodes;
+var nodes :Array;
/**
* The views which this LzReplicationManager has created.
* @type [LzNode]
*/
-var clones;
+var clones :Array;
/** @access private */
-var __LZdataoffset = 0;
+var __LZdataoffset :int = 0;
/**
* Sent when <code>nodes</code> is changed
* @lzxtype event
*/
-var onnodes = LzDeclaredEvent;
+var onnodes :LzDeclaredEventClass = LzDeclaredEvent;
/**
* Sent when <code>clones</code> is changed
* @lzxtype event
*/
-var onclones = LzDeclaredEvent;
+var onclones :LzDeclaredEventClass = LzDeclaredEvent;
/**
* Sent when <code>visible</code> is changed
* @lzxtype event
*/
-var onvisible = LzDeclaredEvent;
+var onvisible :LzDeclaredEventClass = LzDeclaredEvent;
/**
* @access private
@@ -175,7 +173,7 @@
this.pooling = false; // Defined in LzDatapath
//odp: original datapath
- var view = odp.immediateparent;
+ var view:LzNode = odp.immediateparent;
if (view === canvas) {
// Initialize vars to reduce dhtml errors
this.nodes = [];
@@ -193,7 +191,7 @@
// replace the view with us,
// fixing up any name or id
- var name = view.name;
+ var name:String = view.name;
if (name != null) {
args.name = name;
// remove view we replace to avoid warning in LzNode.$lzc$set_name
@@ -201,7 +199,7 @@
view.parent[name] = null;
}
// ditto with global binders
- var idbinder = view.$lzc$bind_id;
+ var idbinder:Function = view.$lzc$bind_id;
if (idbinder != null) {
// remove view binding
idbinder.call(null, view, false);
@@ -209,7 +207,7 @@
this.$lzc$bind_id = idbinder;
idbinder.call(null, this);
}
- var namebinder = view.$lzc$bind_name;
+ var namebinder:Function = view.$lzc$bind_name;
if (namebinder != null) {
// remove view binding
namebinder.call(null, view, false);
@@ -274,9 +272,9 @@
}
}
- var hadxpathconstraint = false;
- var ia = view._instanceAttrs;
- var oa = odp._instanceAttrs;
+ var hadxpathconstraint:Boolean = false;
+ var ia:Object = view._instanceAttrs;
+ var oa:Object = odp._instanceAttrs;
if (ia && 'datapath' in ia && ia.datapath instanceof LzConstraintExpr) {
// <view datapath="${ ... }"/>
hadxpathconstraint = true;
@@ -321,7 +319,7 @@
this.pooling = args.pooling;
}
- var mycontext = odp.context;
+ var mycontext:* = odp.context;
//clone pool is used to store available views
this.clones = [];
@@ -351,7 +349,7 @@
* @access private
*/
// See subclasses for definition
-function __LZsetCloneAttrs () {}
+function __LZsetCloneAttrs () :void {}
/**
* @access private
@@ -374,23 +372,25 @@
/**
* @access private
*/
-override function setDataContext ( p , implicit = null ){
- var args = arguments;
- if (p == null && this.immediateparent != null && 'datapath' in this.immediateparent && this.immediateparent.datapath != null){
- args[0] = this.immediateparent.datapath;
- args[1] = true;
+override function setDataContext (p, implicit:Boolean = false) :void {
+ if (p == null && this.immediateparent != null && this.immediateparent['datapath'] != null){
+ p = this.immediateparent.datapath;
+ implicit = true;
}
- super.setDataContext.apply(this, args);
+ super.setDataContext(p, implicit);
}
/**
+ * TODO: [20080428 anba] no reference to this function in the LFC, remove it?
+ *
* @access private
*/
-function getNodeOffset ( p ){
- if (this.nodes != null) {
- var l = this.nodes.length;
- for ( var i = 0; i < l; i++ ){
- if ( p == this.nodes[ i ] ){
+function getNodeOffset ( p ) :Number? {
+ var nds:Array = this.nodes;
+ if (nds != null) {
+ var len:int = nds.length;
+ for ( var i:int = 0; i < len; i++ ){
+ if ( p == nds[ i ] ){
return i;
}
}
@@ -402,20 +402,21 @@
* @param Number n: The zero-based offset of the clone to retrieve
* @return LzView: A pointer to the nth clone
*/
-function getCloneNumber ( n ){
+function getCloneNumber ( n:int ) :LzNode {
return this.clones[ n ];
}
/**
* @access private
*/
-override function __LZHandleNoNodes() {
+override function __LZHandleNoNodes() :void {
this.nodes = [];
- while ( this.clones.length ){
+ var cls:Array = this.clones;
+ while ( cls.length ){
if ( this.pooling ){
this.poolClone();
} else {
- var v = this.clones.pop();
+ var v:LzNode = cls.pop();
this.destroyClone( v );
}
}
@@ -424,31 +425,30 @@
/**
* @access private
*/
-override function __LZHandleSingleNode ( n ){
+override function __LZHandleSingleNode ( n/*:LzDataNodeMixin*/ ) :void {
this.__LZHandleMultiNodes( [n] );
}
/**
* @access private
*/
-function mergesort ( arr , l , h ) {
- if ( l < h ) {
- var m = l + Math.floor ( (h - l) / 2 );
- var a = this.mergesort( arr , l , m );
- var b = this.mergesort( arr , m+1 , h );
+function mergesort ( arr:Array, lo:int, hi:int ) :Array {
+ if ( lo < hi ) {
+ var mid:int = lo + Math.floor ( (hi - lo) / 2 );
+ var a:Array = this.mergesort( arr, lo, mid );
+ var b:Array = this.mergesort( arr, mid + 1, hi );
} else if( arr.length == 0 ) {
return [];
+ } else {
+ return [ arr[ lo ] ];
}
- else {
- return [ arr[ l ] ];
- }
//now merge
- var r=[];
- var ia = 0;
- var ib = 0;
- var al = a.length
- var bl = b.length
+ var r:Array = [];
+ var ia:int = 0;
+ var ib:int = 0;
+ var al:int = a.length;
+ var bl:int = b.length;
while ( ia < al && ib < bl ){
if ( this.orderf( b[ ib ] , a[ ia ] ) == 1 ){
r.push( b[ ib++ ] );
@@ -465,13 +465,13 @@
/**
* @access private
*/
-override function __LZHandleMultiNodes ( n ){
- var layouts = this.parent && this.parent.layouts ? this.parent.layouts : [];
- for (var i in layouts) {
+override function __LZHandleMultiNodes ( n:Array ) :LzReplicationManager {
+ var layouts:Array = this.parent && this.parent.layouts ? this.parent.layouts : [];
+ for (var i:int = 0; i < layouts.length; ++i) {
layouts[i].lock();
}
this.hasdata = true;
- var lastnodes = this.nodes;
+ var lastnodes:Array = this.nodes;
this.nodes = n;
if (this.onnodes.ready) this.onnodes.sendEvent( this.nodes );
@@ -483,33 +483,35 @@
this.__LZadjustVisibleClones( lastnodes , true );
+ var len:int = this.clones.length;
+ for (var i:int = 0; i < len; i++ ){
+ var cl:LzNode = this.clones[ i ];
+ var iplusoffset:int = i + this.__LZdataoffset;
+ cl.clonenumber = iplusoffset;
- var l = this.clones.length;
- for (var i = 0; i < l; i++ ){
- var cl = this.clones[ i ] ;
- var iplusoffset = i + this.__LZdataoffset;
- cl.clonenumber = iplusoffset ;
-
if (this.nodes) {
cl.datapath.setClonePointer( this.nodes[ iplusoffset ] );
}
if (cl.onclonenumber.ready) cl.onclonenumber.sendEvent( iplusoffset );
}
if (this.onclones.ready) this.onclones.sendEvent( this.clones );
- for (var i in layouts) {
+
+ for (var i:int = 0; i < layouts.length; ++i) {
layouts[i].unlock();
}
+
+ return void(0);
}
/**
* @access private
*/
-function __LZadjustVisibleClones( lastnodes , newnodes){
- var stpt = this.__LZdiffArrays( lastnodes , this.nodes);
+function __LZadjustVisibleClones( lastnodes:Array , newnodes:Boolean) :void {
+ var stpt:int = this.__LZdiffArrays( lastnodes , this.nodes);
if ( ! this.pooling ) {
while ( this.clones.length > stpt ){
- var v = this.clones.pop();
+ var v:LzNode = this.clones.pop();
this.destroyClone( v );
}
}
@@ -519,7 +521,7 @@
LzInstantiator.enableDataReplicationQueuing( );
while ( this.nodes && this.nodes.length > this.clones.length ){
- var cl = this.getNewClone();
+ var cl:LzNode = this.getNewClone();
if (!cl)
break;
this.clones.push( cl );
@@ -562,15 +564,23 @@
/**
* @access private
*/
-function ascDict ( a , b ){
- if ( a.toLowerCase() < b.toLowerCase() ) return 1;
+function ascDict ( a:String, b:String ) :int {
+ if (a.toLowerCase() < b.toLowerCase()) {
+ return 1;
+ } else {
+ return 0;
+ }
}
/**
* @access private
*/
-function descDict ( a , b ){
- if ( a.toLowerCase() > b.toLowerCase() ) return 1;
+function descDict ( a:String, b:String ) :int {
+ if (a.toLowerCase() > b.toLowerCase()) {
+ return 1;
+ } else {
+ return 0;
+ }
}
@@ -582,7 +592,7 @@
* @param Function|String comparator: See the <code>comparator</code> paramater
* of <code>setComparator</code> for details.
*/
-override function setOrder( xpath , comparator=null ) {
+override function setOrder( xpath:String, comparator:* = null ) :void {
this.orderpath = null;
if ( comparator != null ){
@@ -609,7 +619,7 @@
* first, -1 if the first argument should follow the second, and 0 if the two
* arguments are equivalent
*/
-override function setComparator( comparator ){
+override function setComparator( comparator:* ) :void {
if ( comparator == "descending" ){
comparator = this.descDict;
} else if ( comparator == "ascending" ){
@@ -630,16 +640,16 @@
/**
* @access private
*/
-function getNewClone ( forceNew = null ){
+function getNewClone ( forceNew = null ) :LzNode {
if (!this.cloneParent) {
return null;
}
if ( this.clonePool.length ){
- var v = this.reattachClone( this.clonePool.pop() );
+ var v:LzNode = this.reattachClone( this.clonePool.pop() );
} else {
- var v = new this.cloneClass( this.cloneParent , this.cloneAttrs ,
+ var v:LzNode = new this.cloneClass( this.cloneParent , this.cloneAttrs ,
this.cloneChildren,
- forceNew == null ?this.asyncnew: !forceNew);
+ forceNew == null ? this.asyncnew : !forceNew);
}
if ( this.visible == false ) v.$lzc$set_visible( false );
return v;
@@ -648,16 +658,18 @@
/**
* @access private
*/
-function poolClone ( ){
- var v = this.clones.pop();
+function poolClone ( ) :void {
+ var v:LzNode = this.clones.pop();
this.detachClone( v );
this.clonePool.push ( v );
}
/**
+ * TODO: [20080428 anba] do we still need this overhead?
+ *
* @access private
*/
-function destroyClone ( v ) {
+function destroyClone (v:LzNode) :void {
v.destroy();
}
@@ -676,16 +688,18 @@
/**
* @access private
*/
-override function setXPath ( xp ){
+override function setXPath ( xp:String ) :Boolean? {
if ( this.__LZpreventXPathUpdate ) return;
super.setXPath.apply(this, arguments);
}
/**
+ * TODO: [20080428 anba] no reference to this function in the LFC, remove it?
+ *
* @access private
*/
-function handleDeletedNode ( c ){
- var tclone = this.clones[ c ];
+function handleDeletedNode ( c:int ) :void {
+ var tclone:LzNode = this.clones[ c ];
if ( this.pooling ){
this.detachClone( tclone );
this.clonePool.push ( tclone );
@@ -701,11 +715,12 @@
* @param LzDataElement p: The data node for which to return the clone.
* @return LzView: A clone mapped to the given data.
*/
-function getCloneForNode ( p, dontmake=null ){
- var l = this.clones.length;
- for ( var i = 0; i < l; i++ ){
- if ( this.clones[ i ].datapath.p == p ){
- return this.clones[ i ];
+function getCloneForNode ( p, dontmake:Boolean = false ){
+ var cls:Array = this.clones;
+ var len:int = cls.length;
+ for ( var i:int = 0; i < len; i++ ){
+ if ( cls[ i ].datapath.p == p ){
+ return cls[ i ];
}
}
}
@@ -713,7 +728,7 @@
/**
* @access private
*/
-override function toString (){
+override function toString () :String {
return "ReplicationManager in " + this.immediateparent;
}
@@ -726,11 +741,12 @@
* but I didn't want to mess with that now. In any case, there is no
* reason for this to be a public method.
*/
-function setVisible ( vis ){
+function setVisible ( vis:Boolean ) :void {
this.visible = vis;
- var l = this.clones.length;
- for ( var i = 0; i < l; i++ ){
- this.clones[ i ].$lzc$set_visible( vis );
+ var cls:Array = this.clones;
+ var len:int = cls.length;
+ for ( var i:int = 0; i < len; i++ ){
+ cls[ i ].$lzc$set_visible( vis );
}
if (this.onvisible.ready) this.onvisible.sendEvent( vis );
}
@@ -738,48 +754,55 @@
/**
* @access private
*/
-override function __LZcheckChange ( chgpkg ){
+override function __LZcheckChange (chgpkg:Object) :Boolean {
this.p = this.nodes[ 0 ];
- var didrun = super.__LZcheckChange.apply(this, arguments);
+ var didrun:Boolean = super.__LZcheckChange.apply(this, arguments);
this.p = null;
if ( !didrun ){
var who = chgpkg.who;
- var l = this.clones.length;
- for ( var i = 0; i < l; i++ ){
- var cl = this.clones[ i ];
- if ( cl.datapath.__LZneedsOpUpdate( chgpkg ) ){
- cl.datapath.__LZsetData();
+ var cls:Array = this.clones;
+ var len:int = cls.length;
+ for ( var i:int = 0; i < len; i++ ){
+ var cl:LzNode = cls[ i ];
+ var dp:LzDatapath = cl.datapath;
+ if ( dp.__LZneedsOpUpdate( chgpkg ) ){
+ dp.__LZsetData();
}
- if ( who.childOfNode( cl.datapath.p , true ) ){
- if (cl.datapath.onDocumentChange.ready) cl.datapath.onDocumentChange.sendEvent( chgpkg ) ;
+ if ( who.childOfNode( dp.p , true ) ){
+ if (dp.onDocumentChange.ready) dp.onDocumentChange.sendEvent( chgpkg ) ;
}
}
}
+
+ return false;
}
/** @access private */
-override function __LZneedsOpUpdate ( chgpkg = null ){ return false }
+override function __LZneedsOpUpdate (chgpkg:Object? = null) :Boolean {
+ return false;
+}
/**
* @access private
*/
-override function getContext ( chgpkg = null ){
+override function getContext ( chgpkg = null ) :* {
return this.nodes[ 0 ];
}
/**
* @access private
*/
-function detachClone ( cl ){
+function detachClone ( cl:LzNode ){
+ //cl is instance of LzView
if ( cl.isdetatchedclone ) return;
cl.$lzc$set_visible(false);
cl.addedToParent = false;
- var svs = cl.immediateparent.subviews;
- for( var i = svs.length - 1; i >= 0; i-- ){
+ var svs:Array = cl.immediateparent.subviews;
+ for( var i:int = svs.length - 1; i >= 0; i-- ){
if ( svs[ i ] == cl ){
svs.splice( i , 1 );
break;
@@ -795,7 +818,7 @@
/**
* @access private
*/
-function reattachClone ( cl ){
+function reattachClone ( cl:LzView ) :LzView {
if ( !cl.isdetatchedclone ) return cl;
cl.immediateparent.addSubview( cl );
@@ -808,11 +831,11 @@
* returns the index at which the arrays differ
* @access private
*/
-function __LZdiffArrays ( a , b ){
- var i = 0;
+function __LZdiffArrays ( a:Array, b:Array ) :int {
+ var i:int = 0;
- var al = a ? a.length : 0;
- var bl = b ? b.length : 0;
+ var al:int = a ? a.length : 0;
+ var bl:int = b ? b.length : 0;
while( i < al && i < bl ){
if ( a[ i ] != b[ i ] ){
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzResizeReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzResizeReplicationManager.lzs 2008-05-28 16:45:00 UTC (rev 9353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzResizeReplicationManager.lzs 2008-05-28 16:53:32 UTC (rev 9354)
@@ -125,7 +125,7 @@
var osize = this.datapath.p[ datasizevar ] || cloneManager.viewsize;
if ( s != osize ){
this.datapath.p[ datasizevar ] = s;
- cloneManager.__LZadjustVisibleClones(null, null);
+ cloneManager.__LZadjustVisibleClones(null, false);
}
}
@@ -180,7 +180,7 @@
* (as opposed to, for example, when
* the mask changes its height or item changes size
*/
-override function __LZadjustVisibleClones(ln,nn){
+override function __LZadjustVisibleClones(ln:Array, nn:Boolean) :void {
//if the mask doesn't have a set size in the replication axis, don't affect
//it
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs 2008-05-28 16:45:00 UTC (rev 9353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs 2008-05-28 16:53:32 UTC (rev 9354)
@@ -165,8 +165,8 @@
if ($profile) {
Profiler.event('start: #canvas');
}
- this.datapath = {};
this.immediateparent = this;
+ this.datapath = new LzDatapath(this);
this.mask = null;
More information about the Laszlo-checkins
mailing list