[Laszlo-checkins] r11729 - in openlaszlo/trunk: WEB-INF/lps/lfc/compiler WEB-INF/lps/lfc/core WEB-INF/lps/lfc/data WEB-INF/lps/lfc/debugger WEB-INF/lps/lfc/events WEB-INF/lps/lfc/helpers WEB-INF/lps/lfc/services docs/src/developers/programs

ptw@openlaszlo.org ptw at openlaszlo.org
Tue Nov 11 19:03:14 PST 2008


Author: ptw
Date: 2008-11-11 19:03:07 -0800 (Tue, 11 Nov 2008)
New Revision: 11729

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzMessage.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/core/LzEventable.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParsedPath.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzMemory.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzMessage.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzFont.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/services/LzURL.lzs
   openlaszlo/trunk/docs/src/developers/programs/databinding-$15.lzx
Log:
Change 20081111-ptw-E by ptw at dueling-banjos.home on 2008-11-11 13:56:20 EST
    in /Users/ptw/OpenLaszlo/trunk-2
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: LzBootstrapMessage needs to implement the String interface

Bugs Fixed:
LPP-7316  LzMessage missing substring in non-debug mode?
LPP-5934  declare public LFC methods and attributes as public (partial)

Technical Reviewer: a.bargull at intensis.de (pending)
QA Reviewer: etjabberwock at gmail.com (Message-ID: <491A14C8.5050406 at laszlosystems.com>)

Details:
    LzURL, LzMemory, LzFont, LaszloEvent, LzParsedPath,
    LzMessage:  These are all standalone classes, therefore they
    should simply declare their `toString` method public, so it will
    be correctly invoked by `String(...)` and `'' + ...`.

    LzEventable:  For swf9, install `prototype.toString` that
    trampolines to our private toString method.  This makes all
    descendants (i.e., nodes) print prettily in swf9 (or at least, as
    pretty as their toString method, instead of just printing [<class>
    object]).

    */LzMessage: Move the String interface implementation from the
    debugger to the boostrap so it is available in all runtimes.
    Override the important API's that create a new message in the
    debug version to update the object array.

    databinding-$15: Update example to more modern style:

    1) Break out the databinding as an attribute (named 'order') and
       give it a type, so that it will be automatically coerced
       (rather than poking directly at the datapath's data field).

    2) Fix logic in button's onclick handler to disable itself when
       there are no more children to select, instead of _after_ it
       fails because there are no more children.

    3) Fix the computation of the data set 'order' field to be a
       string when setting it.

    4) Add a text field to display the current values of 'order' and
       the datapath, rather than writing it out to the debugger.

    5) Make the green box visibility be a function of whether `order`
       is defined or not (to avoid edge case numerical computations on
       null).

Tests:
    smokecheck, test case from LPP-7316 runs in non-debug



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzMessage.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzMessage.lzs	2008-11-11 21:30:45 UTC (rev 11728)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzMessage.lzs	2008-11-12 03:03:07 UTC (rev 11729)
@@ -22,7 +22,7 @@
     }
   }
 
- function appendInternal (str:String, obj = null) {
+  function appendInternal (str:String, obj = null) {
     this.message += str;
     this.length = this.message.length;
   }
@@ -34,25 +34,55 @@
     }
   }
 
-  // Implements String interface (this is the only one we need early
-  // on, see LzDebugMessage)
+  /// These methods implement the String interface (since we are not
+  /// allowed to subclass String, apparently
+
+  // TODO: [2006-04-17 ptw] When javascript has getters and setters:
+  // function get length () { return this.message.length; };
+  // function set length (length) { this.message.length = length; return this.length; };
+
   /** @access private */
-  function indexOf (key) { return this.message.indexOf(key); }
-
-  // TODO: [2008-05-08 ptw] (LPP-5934) When toString is declared
-  // public, remove the swf9 special-case
-  if ($swf9) {
-    prototype.toString = function () { return this.message; }
-  } else {
-    function toString () {
-      return this.message;
-    }
+  public function charAt (index) { return this.message.charAt(index); }
+  /** @access private */
+  public function charCodeAt (index) { return this.message.charCodeAt(index); }
+  /** @access private */
+  public function indexOf (key) { return this.message.indexOf(key); }
+  /** @access private */
+  public function lastIndexOf (key) { return this.message.lastIndexOf(key); }
+  /** @access private */
+  public function toLowerCase ():LzMessage {
+    return new LzMessage(this.message.toLowerCase());
+  };
+  /** @access private */
+  public function toUpperCase ():LzMessage {
+    return new LzMessage(this.message.toUpperCase());
+  };
+  /** @access private */
+  public function toString () { return this.message; };
+  /** @access private */
+  public function valueOf () { return this.message.valueOf(); };
+  /** @access private */
+  public function concat (...args):LzMessage {
+    return new LzMessage(this.message.concat.apply(this.message, args));
   }
+  /** @access private */
+  public function slice (...args):String { return this.message.slice.apply(this.message, args); }
+  /** @access private */
+  public function split (...args):String { return this.message.split.apply(this.message, args); }
+  /** @access private */
+  public function substr (...args):String { return this.message.substr.apply(this.message, args); }
+  /** @access private */
+  public function substring (...args):String { return this.message.substring.apply(this.message, args); }
 
+  /// End of String interface
+
+
+  // Our extension
+  /** @access private */
   function toHTML () {
     // TODO: [2008-05-08 ptw] (LPP-5934) When toString is declared
     // public, remove the swf9 special-case
-      return this['toString']().toHTML();
+    return this['toString']().toHTML();
   }
 
   /**

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/core/LzEventable.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/core/LzEventable.lzs	2008-11-11 21:30:45 UTC (rev 11728)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/core/LzEventable.lzs	2008-11-12 03:03:07 UTC (rev 11729)
@@ -143,5 +143,14 @@
     LzEventable.prototype._dbg_typename = null;
     LzEventable.prototype._dbg_name = null;
   }
+
+  // TODO: [2008-05-08 ptw] (LPP-5934) When toString is declared
+  // public, remove this.  For now, this acts to trampoline `String(...)`
+  // and `'' + ...` to our private toString methods
+  if ($swf9) {
+    /** @access private */
+    prototype.toString = function () { return this.toString(); }
+  }
+
 } // End of LzEventable
 lz.Eventable = LzEventable;  // publish

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParsedPath.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParsedPath.lzs	2008-11-11 21:30:45 UTC (rev 11728)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParsedPath.lzs	2008-11-12 03:03:07 UTC (rev 11729)
@@ -327,7 +327,7 @@
 /**
   * @access private
   */
-function toString (  ){
+public function toString (  ){
     return  "Parsed path for path: " + this.path;
 }
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzMemory.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzMemory.lzs	2008-11-11 21:30:45 UTC (rev 11728)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzMemory.lzs	2008-11-12 03:03:07 UTC (rev 11729)
@@ -488,7 +488,7 @@
    * Describe an individual leak
    * @access private
    */
-  function toString () {
+  public function toString () {
     if (this.obj) {
       return Debug.formatToString("%=s.%s: (\xa3%d) %0.48#w", this['parent'], this.path, this.property, this.leaked, this['obj']);
     } else {

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzMessage.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzMessage.lzs	2008-11-11 21:30:45 UTC (rev 11728)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzMessage.lzs	2008-11-12 03:03:07 UTC (rev 11729)
@@ -39,57 +39,24 @@
     super(message);
   }
 
-  // TODO: [2006-04-17 ptw] When javascript has getters and setters:
-  // function get length () { return this.message.length; };
-  // function set length (length) { this.message.length = length; return this.length; };
+  /// These methods implement the String interface (since we are not
+  /// allowed to subclass String, apparently
 
-  // Implements String interface
   /** @access private */
-  function charAt (index) { return this.message.charAt(index); }
-  // Implements String interface
-  /** @access private */
-  function charCodeAt (index) { return this.message.charCodeAt(index); }
-  // indexOf in LzBootstrapMessage
-  // Implements String interface
-  /** @access private */
-
-  override function indexOf (key) { return this.message.indexOf(key); }
-  // Implements String interface
-  /** @access private */
-
-  function lastIndexOf (key) { return this.message.lastIndexOf(key); }
-  // Implements String interface
-  /** @access private */
-  function toLowerCase () {
-    var msg = new LzMessage(this.message.toLowerCase());
+  override public function toLowerCase ():LzMessage {
+    var msg:LzMessage = new LzMessage(this.message.toLowerCase());
     msg.objects = this.objects.concat();
     return msg;
   };
-  /**
-   * Implements String interface
-   * @access private
-   */
-  function toUpperCase () {
-    var msg = new LzDebugMessage(this.message.toUpperCase());
+  /** @access private */
+  override public function toUpperCase ():LzMessage {
+    var msg:LzMessage = new LzMessage(this.message.toUpperCase());
     msg.objects = this.objects.concat();
     return msg;
   };
-  /**
-   * Implements String interface
-   * @access private
-   */
-  function toString () { return this.message.toString(); };
-  /**
-   * Implements String interface
-   * @access private
-   */
-  function valueOf () { return this.message.valueOf(); };
-  /**
-   * Implements String interface
-   * @access private
-   */
-  function concat (...args):LzDebugMessage {
-    var msg = new LzDebugMessage(this.message.concat.apply(this.message, args));
+  /** @access private */
+  override public function concat (...args):LzMessage {
+    var msg:LzMessage = new LzMessage(this.message.concat.apply(this.message, args));
     var offset = this.message.length;
     for (var i = 0; i < args.length; i++) {
       var arg = args[i];
@@ -104,31 +71,21 @@
     }
     return msg;
   }
-  /**
-   * Implements String interface
-   * @access private
-   */
   // TODO: [2005-06-23 ptw] Make these methods maintain the objects array
-  function slice (...args):String { return this.message.slice.apply(this.message, args); }
-  /**
-   * Implements String interface
-   * @access private
-   */
+  /** @access private */
+  override public function slice (...args):String { return this.message.slice.apply(this.message, args); }
   // TODO: [2005-06-23 ptw] Make these methods maintain the objects array
-  function split (...args):String { return this.message.split.apply(this.message, args); }
-  /**
-   * Implements String interface
-   * @access private
-   */
+  /** @access private */
+  override public function split (...args):String { return this.message.split.apply(this.message, args); }
   // TODO: [2005-06-23 ptw] Make these methods maintain the objects array
-  function substr (...args):String { return this.message.substr.apply(this.message, args); }
-  /**
-   * Implements String interface
-   * @access private
-   */
+  /** @access private */
+  override public function substr (...args):String { return this.message.substr.apply(this.message, args); }
   // TODO: [2005-06-23 ptw] Make these methods maintain the objects array
-  function substring (...args):String { return this.message.substring.apply(this.message, args); }
+  /** @access private */
+  override public function substring (...args):String { return this.message.substring.apply(this.message, args); }
 
+  /// End of String interface
+
   /**
    * Appends str to the message.  If obj is passed, it is recorded as an
    * annotation permitting the object corresponding to the string to be
@@ -422,27 +379,17 @@
   var _dbg_name = function () {
     // Omit type from _dbg_name, since it is implicit in the class
     return this.locationString('') + this.message;
-  }
+  };
 
   /**
    * Convert a SourceMessage to a String
    * @access private
    */
-  // TODO: [2005-05-08 ptw] (LPP-5934) When toString is declared
-  // public, remove the swf9 special-case
-    if ($swf9) {
-      prototype.toString = function () {
-        // SourceMessages auto-append a newline (although they really just want to
-        // prepend a fresh-line)
-        return this.toStringInternal('toString') + '\n';
-      }
-    } else {
-      function toString () {
-        // SourceMessages auto-append a newline (although they really just want to
-        // prepend a fresh-line)
-        return this.toStringInternal('toString') + '\n';
-      }
-    }
+  public function toString () {
+    // SourceMessages auto-append a newline (although they really just want to
+    // prepend a fresh-line)
+    return this.toStringInternal('toString') + '\n';
+  }
 
 
   /**

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs	2008-11-11 21:30:45 UTC (rev 11728)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs	2008-11-12 03:03:07 UTC (rev 11729)
@@ -319,7 +319,7 @@
   }
 
 /** @access private */
-function toString (){
+public function toString (){
     return ("Delegate for " + this.c + " calls " + this.m + " " + this.__delegateID );
 }
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzFont.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzFont.lzs	2008-11-11 21:30:45 UTC (rev 11728)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzFont.lzs	2008-11-12 03:03:07 UTC (rev 11729)
@@ -380,7 +380,7 @@
   * value set in SWFWriter.java */
 var leading = 2;
 
-function toString (){
+public function toString (){
     return "Font style " + this.style + " of name " + this.name;
 }
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzURL.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzURL.lzs	2008-11-11 21:30:45 UTC (rev 11728)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzURL.lzs	2008-11-12 03:03:07 UTC (rev 11729)
@@ -202,7 +202,7 @@
     /**
      * Returns this URL as a string
      */
-    function toString () :String {
+    public function toString () :String {
         var out:String = "";
 
         if (this.protocol != null) {

Modified: openlaszlo/trunk/docs/src/developers/programs/databinding-$15.lzx
===================================================================
--- openlaszlo/trunk/docs/src/developers/programs/databinding-$15.lzx	2008-11-11 21:30:45 UTC (rev 11728)
+++ openlaszlo/trunk/docs/src/developers/programs/databinding-$15.lzx	2008-11-12 03:03:07 UTC (rev 11729)
@@ -1,28 +1,32 @@
-<canvas height="150" debug="true">
-  <debug x="150"/>
+<canvas height="155">
+  <debug x="50%" width="45%" y="5%" height="95%" />
   <dataset name="onion">
     <layer order="1"><layer><layer>core</layer></layer></layer>
   </dataset>
 
-  <view datapath="onion:/layer">
-     <simplelayout spacing="5"/>
-     <view width="${100 / this.data}" height="${100 / this.data}" 
-           bgcolor="0x09d055" datapath="@order" 
-           opacity="${Math.min(1, this.data / 3)}"/>
-    
+  <view datapath="onion:/layer" layout="spacing: 5">
     <button text="Peel next layer">
-      <handler name="onclick">
-        with (parent.datapath) {
-          Debug.write(data)
-          if (!selectChild()) this.setAttribute('enabled', false) 
-          else setNodeAttribute('order', Number(p.parentNode.attributes['order']) + 1)
-         }
-      </handler>
+      <handler name="onclick"><![CDATA[
+      with (parent.datapath) {
+      // Go down one layer
+      selectChild();
+      // If there are no more layers to go, disable ourself
+      if (getNodeCount() == 0) this.setAttribute('enabled', false);
+      // Finally, set the order attribute of the new layer to one more than it's parent
+      setNodeAttribute('order', String(Number(p.parentNode.attributes['order']) + 1));
+      }
+      ]]></handler>
     </button>
+    <attribute name="order" value="$path{'@order'}" type="number" />
+    <view width="${100 / parent.order}" height="${100 / parent.order}"
+          bgcolor="0x09d055"
+          opacity="${Math.min(1, parent.order / 3)}"
+          visible="${parent.order != null}" />
+    <text text="${this.escapeText(this.formatToString('order: %w, data: %#w', parent.order, parent.datapath.data))}" />
   </view>
 </canvas>
 
 <!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
-* Copyright 2007 Laszlo Systems, Inc.  All Rights Reserved.                   *
-* Use is subject to license terms.                                            *
-* X_LZ_COPYRIGHT_END ****************************************************** -->
+     * Copyright 2007, 2008 Laszlo Systems, Inc.  All Rights Reserved.        *
+     * Use is subject to license terms.                                       *
+     * X_LZ_COPYRIGHT_END ***************************************************** -->



More information about the Laszlo-checkins mailing list