Author: pbr
Date: 2007-08-08 13:42:10 -0700 (Wed, 08 Aug 2007)
New Revision: 5968

Added:
   openlaszlo/branches/wafflecone/test/lztest/lztest-lzdatapointer.lzx
Modified:
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDatapointer.lzs
Log:
(Note: I took Tucker's suggestion and modified the warning message)

Change 20070802-Philip-2 by [EMAIL PROTECTED] on 2007-08-02 11:34:48 EST
   in /cygdrive/f/laszlo/svn/src/svn/openlaszlo/branches/wafflecone
   for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: Fix how LzDatapointer handles null values

New Features:

Bugs Fixed: LPP-2760

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

Documentation:

Release Notes:

Details:
The decision is to return undefined when the internal pointer is null (same as 3
.4). This was the current behavior of wafflecone. I added warning messages in de
bug mode whenever this condition is found. The new test file, lztest-lzdatapoint
er.lzx, only tests the undefined behavior of LzDatapointer.


Tests:
 Run new unit test, /test/lztest/lztest-lzdatapointer.lzx

Files:
A      test/lztest/lztest-lzdatapointer.lzx
M      WEB-INF/lps/lfc/data/LzDatapointer.lzs

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20070802-Philip-2.tar


Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDatapointer.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDatapointer.lzs       
2007-08-08 17:39:37 UTC (rev 5967)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDatapointer.lzs       
2007-08-08 20:42:10 UTC (rev 5968)
@@ -629,8 +629,10 @@
   var np;
 
   if ( p == null ){
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?
-    return false;
+      if ( $debug ) {
+          Debug.warn("%s: p is null in %s", arguments.callee, this);
+      }
+      return false;
   }
 
   if (pathobj.selectors != null) {
@@ -888,8 +890,12 @@
   * @return String: The name of the datapointer's node
   */
 function getNodeName (){ 
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?        
-    if ( ! this.p ) return;
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
     return this.p.nodeName;
 }
 
@@ -898,8 +904,12 @@
   * @param String name: The new name for the datapointer's node
   */
 function setNodeName (name){
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?            
-    if ( ! this.p ) return;
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
     this.p.setNodeName( name );
 }
 
@@ -911,8 +921,12 @@
   * attributes
   */
 function getNodeAttributes (){ 
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?            
-    if ( ! this.p ) return;        
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
     return this.p.attributes;
 }
 
@@ -922,8 +936,12 @@
   * @return String: The value of the attribute.
   */
 function getNodeAttribute (name){ 
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?            
-    if ( ! this.p ) return;        
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
     return this.p.attributes[ name ];
 }
 
@@ -934,8 +952,12 @@
   * @param String val: The value for the attribute
   */
 function setNodeAttribute (name, val) {    
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?            
-    if (! this.p) return;    
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
     this.p.setAttr( name, val );
 }
 
@@ -944,8 +966,12 @@
   * @param String name: The name of the attribute to delete.
   */
 function deleteNodeAttribute (name) {
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?            
-    if ( ! this.p ) return;
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
     this.p.removeAttr( name );
 }
 
@@ -957,8 +983,12 @@
   * @return String: The text in the node pointed to by the datapointer.
   */
 function getNodeText (){ 
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?            
-    if (! this.p) return;
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
     return this.p.__LZgetText();
 }
 
@@ -1000,8 +1030,13 @@
   * @param String val: The new string for the node's text
   */
 function setNodeText (val) {
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?            
-    if ( ! this.p ) return;
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
+
     // set the first text node you find; otherwise add one
     var foundit = false;
     for (var i = 0; i < this.p.childNodes.length; i++) {
@@ -1038,9 +1073,12 @@
   * @return LzDataElement: the new node
   */
 function addNode ( name, text , attrs ){
-    // FIXME: [2006-10-04 pbr] (LPP-2760) Should this return a type-safe null, 
or undefined?            
-    if ( !this.p )
-      return;
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
 
     var nn = new LzDataElement( name , attrs );
     if ( text != null ){
@@ -1059,8 +1097,13 @@
   * Otherwise the pointer is set to <code>null</code>.
   */
 function deleteNode ( ){
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?            
-    if ( !this.p ) return;
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
+
     var op = this.p
     if ( !this.rerunxpath ){
         //move the pointer to the next sibling
@@ -1108,9 +1151,14 @@
   * @return LzDatapointer: A pointer to the new node
   */
 function addNodeFromPointer ( dp ){
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?            
     if ( ! dp.p ) return;
-    if ( ! this.p ) return;
+    if ( ! this.p ) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
+
     var n = dp.p.cloneNode( true );
     this.p.appendChild( n );
     return new LzDatapointer( null , { pointer : n } );
@@ -1128,10 +1176,13 @@
 
 /** @access private */
 function __LZprocessOperator ( p , pp , depends ){
+    if (p == null) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
 
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?
-    if (p == null) return;
-
     if ( pp.operatorArgs != null ){
         return p[ pp.operator ] ( pp.operatorArgs );
     }
@@ -1215,8 +1266,12 @@
   * contents.
   */
 function serialize ( ){ 
-    // FIXME: [2006-09-25 ben] (LPP-2760) Should this return a type-safe null, 
or undefined?
-    if (this.p == null) return;
+    if ( this.p == null) {
+        if ( $debug ) {
+            Debug.warn("%s: p is null in %s", arguments.callee, this);
+        }
+        return;
+    }
     return this.p.serialize();
 }
 

Added: openlaszlo/branches/wafflecone/test/lztest/lztest-lzdatapointer.lzx


Property changes on: 
openlaszlo/branches/wafflecone/test/lztest/lztest-lzdatapointer.lzx
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to