[Laszlo-checkins] r8569 - openlaszlo/trunk/WEB-INF/lps/lfc/data

bargull@openlaszlo.org bargull at openlaszlo.org
Sun Apr 6 08:50:07 PDT 2008


Author: bargull
Date: 2008-04-06 08:50:03 -0700 (Sun, 06 Apr 2008)
New Revision: 8569

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParsedPath.lzs
Log:
Change 20080403-bargull-0 by bargull at dell--p4--2-53 on 2008-04-03 17:49:17
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: change LzDataset default-name to new regime

New Features:

Bugs Fixed:

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

Documentation:

Release Notes:

Details:
- change default-name for LzDataset to new regime
- update AnonDatasetGenerator to use new regime
- add more type-information to LzParsedPath


Tests:
alldata.lzx still works



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs	2008-04-06 12:50:44 UTC (rev 8568)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs	2008-04-06 15:50:03 UTC (rev 8569)
@@ -98,7 +98,9 @@
   */
 static var tagname = 'dataset';
 /** @access private */
-  static var attributes = new LzInheritedHash(LzNode.attributes);
+static var attributes = new LzInheritedHash(LzNode.attributes);
+/** @access private */
+LzDataset.attributes.name = 'localdata';
  
 static var slashPat = "/";
 
@@ -236,17 +238,12 @@
 
     this.oncanvas = parent == canvas || parent == null;
 
-    if (this._instanceAttrs['name'] == null) {
-        this._instanceAttrs['name'] = 'localdata';
-    }
-
     // bwcompat 1.0 support for port
     if (('port' in args && args.port) && !('secureport' in args && args.secureport)) {
         args.secureport = args.port;
     }
 
     this.ownerDocument = this;
-
     
     if ('timeout' in args && args.timeout) {
         this.timeout = args.timeout;
@@ -254,7 +251,6 @@
         this.timeout = canvas.dataloadtimeout;
     }
 
-
     super.construct.apply(this, arguments);
 }
 
@@ -265,36 +261,42 @@
 override function $lzc$set_name(name) {
     super.$lzc$set_name.apply(this, arguments);
 
-    //for compatibility with dataNode API
-    this.nodeName = name;
-
-    if (!('datasets' in canvas) || null == canvas.datasets ) {
-        canvas.datasets = {};
-    }
-
-    //support "name is global identifier on canvas" behavior
-    if ( this.oncanvas ){
-        if ($debug) {
-          if (global[name] && global[name] !== this) {
-            Debug.warn('Redefining #%s from %w to %w', 
-                       name, global[name], this);
-          }
+    // @devnote: Name is permitted to be null or undefined, meaning
+    // "don't name me", see LzNode#$lzc$set_name(..).
+    // But name shouldn't be set explictly to null for a dataset, 
+    // unless you know what you're doing, see AnonDatasetGenerator#getContext(..)!
+    if (name != null) {
+        //for compatibility with dataNode API
+        this.nodeName = name;
+        
+        if (!('datasets' in canvas) || null == canvas.datasets ) {
+            canvas.datasets = {};
         }
-        global[ name ] = this;
-        canvas[ name ] = this;
-    } else {
-        // it's local - add the parent's UID
-        name = this.parent.getUID() + '.' + name;
-    }
-
-    if (null != canvas.datasets[name]) {
-        if ($debug) {
-            Debug.warn("A dataset already exists with the name '%s': %w",
-                       name, canvas.datasets[name]);
+        
+        //support "name is global identifier on canvas" behavior
+        if ( this.oncanvas ){
+            if ($debug) {
+              if (global[name] && global[name] !== this) {
+                Debug.warn('Redefining #%s from %w to %w', 
+                           name, global[name], this);
+              }
+            }
+            global[ name ] = this;
+            canvas[ name ] = this;
+        } else {
+            // it's local - add the parent's UID
+            name = this.parent.getUID() + '.' + name;
         }
+        
+        if (null != canvas.datasets[name]) {
+            if ($debug) {
+                Debug.warn("A dataset already exists with the name '%s': %w",
+                           name, canvas.datasets[name]);
+            }
+        }
+        
+        canvas.datasets[name] = this;
     }
-
-    canvas.datasets[name] = this;
 }
 
 /**

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParsedPath.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParsedPath.lzs	2008-04-06 12:50:44 UTC (rev 8568)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParsedPath.lzs	2008-04-06 15:50:03 UTC (rev 8569)
@@ -18,14 +18,14 @@
     * 
     * @access private
     */
-  var path = null;
+  var path:String = null;
   
   /** 
     * Array containing selector-operations for this LzParsedPath
     * 
     * @access private
     */
-  var selectors = null;
+  var selectors:Array = null;
   
   /** 
     * Pointer to the dataset (if part of the path) otherwise null
@@ -34,28 +34,28 @@
     * @access private
     * @deprecated may lead to memory leaks (LPP-4214)
     */
-  var context = null;
+  var context:* = null;
   
   /** 
     * Name of the dataset (if part of the path)
     * 
     * @access private
     */
-  var dsetname = null;
+  var dsetname:String = null;
   
   /** 
     * Name of the datasource (if part of the path)
     * 
     * @access private
     */
-  var dsrcname = null;
+  var dsrcname:String = null;
   
   /** 
     * Array containing the path to the local-dataset
     * 
     * @access private
     */
-  var islocaldata = null;
+  var islocaldata:Array = null;
   
   /* Parsing information */
   
@@ -65,42 +65,42 @@
     * 
     * @access private
     */
-  var operator = null;
+  var operator:String = null;
   
   /** 
     * One of: "position" or "last" 
     * 
     * @access private
     */
-  var aggOperator = null;
+  var aggOperator:String = null;
   
   /** 
     * null or 0
     * 
     * @access private
     */
-  var operatorArgs = null;
+  var operatorArgs:* = null;
   
   /** 
     * true if terminal operator is a attribute-selector, otherwise false
     * 
     * @access private
     */
-  var hasAttrOper = false;
+  var hasAttrOper:Boolean = false;
   
   /** 
     * true if path contains a attribute-predicate
     * 
     * @access private
     */
-  var hasOpSelector = false;
+  var hasOpSelector:Boolean = false;
   
   /** 
     * true if path contains ".." or "//", otherwise false
     * 
     * @access private
     */
-  var hasDotDot = false;
+  var hasDotDot:Boolean = false;
   
   /** 
     * Return the context for this LzParsedPath
@@ -108,7 +108,7 @@
     *
     * @access private
     */
-  function getContext ( dp ) {
+  function getContext (dp:LzDatapointer) {
       if (this.context != null) {
           return this.context;
       } else {
@@ -126,17 +126,13 @@
       }
       return null;
   }
-  
-  function LzParsedPath ( pa, node ){
-    //split context part
+
+function LzParsedPath (pa:String, node:*) {
     this.path = pa;
     this.selectors = [];
-    var nowarn = false;
-
+    
     var sourceindex = pa.indexOf( ":/" );
 
-    //this.context = pointer to the dataset (if part of the path) otherwise null
-
     if ( sourceindex > -1 ){
         //we have a dset and possible dsource
         var sourceparts = pa.substring( 0 , sourceindex ).split( ":" );
@@ -144,11 +140,15 @@
             var dsrc = LzParsedPath.trim( sourceparts[ 0 ] );
             var dset = LzParsedPath.trim( sourceparts[ 1 ] );
             if (dsrc == 'local') {
-                nowarn=true;
                 this.islocaldata = dset.split('.');
             } else {
+                //TODO: [20080321-anba] do we still support datasources?
                 //we have a datasource and a dataset
-                nowarn = ((canvas[ dsrc ])[ dset ] != null);
+                if ($debug) {
+                    if ((canvas[ dsrc ])[ dset ] == null) {
+                        Debug.error( "couldn't find dataset for %w", pa );
+                    }
+                }
                 this.dsrcname = dsrc;
                 this.dsetname = dset;
             }
@@ -163,15 +163,14 @@
                 this.islocaldata = true; 
         */
             } else {
-                nowarn = (canvas.datasets[ name ] != null);
+                if ($debug) {
+                    if (canvas.datasets[ name ] == null) {
+                        Debug.error( "couldn't find dataset for %w", pa );
+                    }
+                }
                 this.dsetname = name;
             }
         }
-        if (nowarn != true){
-            if ($debug) {
-                Debug.error( "couldn't find dataset for %w", pa );
-            }
-        }
 
         var rest = pa.substring( sourceindex + 2 );
     } else {
@@ -239,9 +238,8 @@
                     } else if ( cnode.indexOf( "serialize" ) > -1 ){
                         this.operator = "serialize";
                         this.operatorArgs = 0;
-                    } else {
-// [2008-03-18 pbr] no gotError in this class
-//                        this.gotError( "Unknown operator: " + cnode );
+                    } else if ($debug) {
+                        Debug.warn( "Unknown operator: '%s'", cnode);
                     }
                     continue;
                 } else if ( cnode == "" ){
@@ -313,32 +311,22 @@
             }
         }
     }
-        
-    //this.nodearray = an array of strings and offset pairs that represent the 
-    //slash-separated path for the datapath, with the dataset and operator 
-    //removed. The offset part of the pair can be:
-    //*null  if there is no offset given
-    //*int   if the offset is a single number
-    //*array if the offset is dash separated
-    
-    //this.operator = "t" , "n" , or "a" plus "." and the attribute name 
-    //text, name or attribute, respectively
 }
 
 /**
   * @access private
   */
-static function trim ( s ){
-    var st = 0;
-    var dotrim = false;
-    while( s.charAt( st ) == " " ){
+static function trim (s:String):String {
+    var st:Number = 0;
+    var dotrim:Boolean = false;
+    while (s.charAt( st ) == " ") {
         st++;
         dotrim = true;
     }
 
-    var len = s.length - st;
+    var len:Number = s.length - st;
 
-    while( s.charAt( st + len - 1 ) == " " ){
+    while (s.charAt( st + len - 1 ) == " ") {
         len--;
         dotrim = true;
     } 
@@ -353,6 +341,8 @@
 }
 
 /**
+  * TODO: [20080321-anba] only used for 'test/lfc/data/testdatapointer.lzx'? Deprecate and remove?
+  * 
   * @access private
   */
 function debugWrite (  ){
@@ -373,32 +363,45 @@
   */
 class AnonDatasetGenerator {
 
-var pp;
-
-/**
-  * @access private
-  */
-function AnonDatasetGenerator  ( pp ){
-    this.pp = pp;
-}
-
-/**
-  * @access private
-  */
-function getContext (){
-    var d = new LzDataset( );
-    var dp = d.getPointer();
-    //start at 1 to skip '/'
-    if (this.pp.selectors != null) {
-        for ( var i = 0; i < this.pp.selectors.length; i++ ){
-            if ( this.pp.selectors[ i ] == "/" ) continue;
-            dp.addNode( this.pp.selectors[ i ] );
-            dp.selectChild();
+    /**
+      * @access private
+      */
+    var pp:LzParsedPath = null;
+    
+    /**
+      * TODO: [20080321-anba] Where is this property used? Can it be removed?
+      * 
+      * @access private
+      */
+    var noncontext:Boolean = true;
+    
+    /**
+      * @access private
+      */
+    function AnonDatasetGenerator (pp:LzParsedPath) {
+        this.pp = pp;
+    }
+    
+    /** 
+      * This is the shared interface with datapointer
+      * @access private
+      */
+    function getContext () {
+        //@devnote: this creates an anonymous dataset
+        var d = new LzDataset(null, {name: null});
+        
+        var ppsel = this.pp.selectors;
+        if (ppsel != null) {
+            var dp = d.getPointer();
+            for (var i = 0; i < ppsel.length; i++) {
+                if (ppsel[ i ] == "/") continue;
+                //TODO: test selector-type?
+                dp.addNode( ppsel[ i ] );
+                dp.selectChild();
+            }
         }
+            
+        return d;
     }
-        
-    return d;
-}
 
-var noncontext = true;
 } // End of AnonDatasetGenerator



More information about the Laszlo-checkins mailing list