[Laszlo-checkins] r10461 - openlaszlo/trunk/WEB-INF/lps/lfc/data
bargull@openlaszlo.org
bargull at openlaszlo.org
Thu Jul 24 06:01:57 PDT 2008
Author: bargull
Date: 2008-07-24 06:01:53 -0700 (Thu, 24 Jul 2008)
New Revision: 10461
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
Log:
Change 20080708-bargull-rwY by bargull at dell--p4--2-53 on 2008-07-08 20:14:02
in /home/Admin/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: replication-manager takes datapath-slot in swf9
New Features:
Bugs Fixed: LPP-6539
Technical Reviewer: ptw
QA Reviewer: hminsky
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
moved some code and learned that swf9 initializes _all_ class members in the constructor (in constrast to a prototype based system).
Later:
> Rather than move the inits completely out of the constructor and in to the `construct` method,
> why not just move them to after the super call?
That won't work, because the LzNode constructor calls its construct-method, so everything after the super-call
in the constructor will happen after LzNode#construct() has been called. Which means the LzDatapath
"take datapath-slot of immediateparent"-logic did already happen.
> There's a bunch of changes in here that are not related to the title of the patch.
> They look ok, but maybe you should at least make a comment about them in your change message?
- added typing for LzReplicationManager#getCloneForNode(..)
- added typing for LzReplicationManager#setVisible(..)
- removed LzReplicationManager#op_orderf, because it was superfluous (the same information as in LzReplicationManager#orderpath)
- renamed LzReplicationManager#comp_orderf to LzReplicationManager#comparator
- moved LzReplicationManager#mergesort() (simply for legibility and consistency, first __LZHandle*Nodes() and then helper-methods)
- added doc LzReplicationManager#mergesort()
Tests:
attached at bugreport
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs 2008-07-24 08:30:05 UTC (rev 10460)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs 2008-07-24 13:01:53 UTC (rev 10461)
@@ -140,10 +140,11 @@
this.cloneAttrs.options = cloneopt;
var v:LzView = this.getNewClone( true );
- //datamap the new view, to make sure that any members which are datamapped
- //are shown
this.cloneimmediateparent = v.immediateparent;
+
if (this.initialnodes) {
+ //datamap the new view, to make sure that any members which are datamapped
+ //are shown
v.datapath.setClonePointer( this.initialnodes[ 1 ] );
}
@@ -336,7 +337,7 @@
/**
* @access private
*/
-override function getCloneForNode ( p , dontmake:Boolean = false ) :LzNode {
+override function getCloneForNode ( p:LzDataElement, dontmake:Boolean = false ) :LzNode {
var cl:LzView = (super.getCloneForNode( p ) cast LzView) || null;
if ( !cl && !dontmake ){
//even though we're going to return this to the pool immediately,
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs 2008-07-24 08:30:05 UTC (rev 10460)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs 2008-07-24 13:01:53 UTC (rev 10461)
@@ -101,11 +101,8 @@
var hasdata :Boolean;
/** @access private */
var orderpath :String;
-
/** @access private */
-var comp_orderf :Function; // Was this.orderf.comp
-/** @access private */
-var op_orderf :String; // Was this.orderf.op
+var comparator :Function;
/** Slot for constraint-method, see LzReplicationManager#construct(..)
* @access private
@@ -170,9 +167,6 @@
* @access private
*/
function LzReplicationManager ( odp , args, children:* = null, instcall:* = null ){
- this.pooling = this.getDefaultPooling(); // Defined in LzDatapath
- this.__LZtakeDPSlot = false; // Defined in LzDatapath
- this.datacontrolsvisibility = false; // Defined in LzDatapath
//the real parent for this is datapaths view's (immediateparent) parent
super(odp, args, children, instcall);
}
@@ -184,6 +178,10 @@
/** @access private */
override function construct ( odp , args ){
+ this.pooling = this.getDefaultPooling(); // Defined in LzDatapath
+ this.__LZtakeDPSlot = false; // Defined in LzDatapath
+ this.datacontrolsvisibility = false; // Defined in LzDatapath
+
//odp: original datapath
var view:LzNode = odp.immediateparent;
if (view === canvas) {
@@ -455,39 +453,6 @@
/**
* @access private
*/
-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 ] ];
- }
-
- //now merge
- 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++ ] );
- } else {
- r.push( a[ ia++ ] );
- }
- }
- while ( ia < al ) r.push( a[ ia++ ] );
- while ( ib < bl ) r.push( b[ ib++ ] );
-
- return r;
-}
-
-/**
- * @access private
- */
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) {
@@ -560,13 +525,50 @@
}
/**
+ * @devnote: We are using merge-sort instead of Array#sort(..), because we
+ * want to have a stable sorting algorithm.
+ *
+ * @param [LzDataNodeMixin] arr: Array of LzDataNodeMixin to sort, within range [<code>lo</code>..<code>hi</code>]
+ * @param int lo: lower bound in <code>arr</code> (inclusive)
+ * @param int hi: upper bound in <code>arr</code> (inclusive)
* @access private
*/
-//PBR TODO
-function orderf ( a , b ) :int {
- //a and b are dataset nodes
- var op:String = this.op_orderf;
+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 ] ];
+ }
+ //now merge
+ 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++ ] );
+ } else {
+ r.push( a[ ia++ ] );
+ }
+ }
+ while ( ia < al ) r.push( a[ ia++ ] );
+ while ( ib < bl ) r.push( b[ ib++ ] );
+
+ return r;
+}
+
+/**
+ * @access private
+ */
+function orderf ( a /*:LzDataNodeMixin*/, b /*:LzDataNodeMixin*/ ) :int {
+ var op:String = this.orderpath;
+
this.p = a;
var aa:* = this.xpathQuery( op );
this.p = b;
@@ -578,7 +580,7 @@
if ( aa == null || aa == "" ) aa ="\n";
if ( bb == null || bb == "" ) bb ="\n";
- return this.comp_orderf( aa , bb )
+ return this.comparator( aa , bb )
}
@@ -616,6 +618,7 @@
* of <code>setComparator</code> for details.
*/
override function setOrder( xpath:String, comparator:* = null ) :void {
+ //setting orderpath to null, so setComparator() won't run __LZHandleMultiNodes()
this.orderpath = null;
if ( comparator != null ){
@@ -624,8 +627,6 @@
this.orderpath = xpath;
- this.op_orderf = this.orderpath;
-
if ( this.nodes.length ){
//reset nodes in order now
this.__LZHandleMultiNodes( this.nodes );
@@ -643,21 +644,21 @@
* arguments are equivalent
*/
override function setComparator( comparator:* ) :void {
- if ( comparator == "descending" ){
- comparator = this.descDict;
- } else if ( comparator == "ascending" ){
- comparator = this.ascDict;
- } else if ( comparator is Function ) {
- // Just use it
- } else if ($debug) {
- Debug.error("Invalid comparator: %s", comparator);
- }
-
- this.comp_orderf = comparator;
- if ( this.orderpath != null && this.nodes.length ){
- //reset nodes in order now
- this.__LZHandleMultiNodes( this.nodes );
- }
+ if ( comparator == "descending" ){
+ comparator = this.descDict;
+ } else if ( comparator == "ascending" ){
+ comparator = this.ascDict;
+ } else if ( comparator is Function ) {
+ // Just use it
+ } else if ($debug) {
+ Debug.error("Invalid comparator: %s", comparator);
+ }
+
+ this.comparator = comparator;
+ if ( this.orderpath != null && this.nodes.length ){
+ //reset nodes in order now
+ this.__LZHandleMultiNodes( this.nodes );
+ }
}
/**
@@ -744,7 +745,7 @@
* @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:Boolean = false ) :LzNode {
+function getCloneForNode ( p:LzDataElement, dontmake:Boolean = false ) :LzNode {
var cls:Array = this.clones;
var len:int = cls.length;
for ( var i:int = 0; i < len; i++ ){
@@ -771,9 +772,9 @@
* reason for this to be a public method.
* @deprecated Use setAttribute('visible', ...) instead.
*/
-function setVisible(v) {
+function setVisible(v:Boolean) :void {
if ($debug) Debug.deprecated(this, arguments.callee, this.setAttribute);
- this.$lzc$set_visible(v)
+ this.$lzc$set_visible(v);
}
/** @access private */
More information about the Laszlo-checkins
mailing list