History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-2302
Type: Task Task
Status: Resolved Resolved
Resolution: Fixed
Priority: P0 P0
Assignee: Unassigned
Reporter: P T Withington
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

Implement LZX <mixin> tag

Created: 06/Jul/06 01:54 PM   Updated: 09/Dec/08 06:21 AM
Component/s: Compiler - Schema, LFC - Object System
Affects Version/s: Legals PR1
Fix Version/s: MisterDonut (4.2 Final)

Time Tracking:
Not Specified

Severity: Major
Fixed in Change#: 12,023
Runtime: N/A
Release Note Text: The <mixin> tag was not implemented in time for this release. Mixins can be written in JavaScript and inherited from in LZX using the 'with' attribute.
Fix in hand: False


 Description  « Hide
Legal's PR1 implements mixins in core/Class now, so core/LzTrait is obsolete and should be eliminated, but this also requires compiler work to pass mixins from LZX to the core correctly.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jim Grandy - 22/Aug/06 04:43 PM
We need to either fix this or wait on CSS integration.

P T Withington - 30/Nov/06 09:13 AM
As part of this, remove all uses of the term 'trait/inherits' from LFC/Compiler/LZX, replace with 'mixin/with'.

Benjamin Shine - 02/Aug/07 05:02 PM
See also LPP-2894, which a note in that bug indicates is blocked waiting on this.

P T Withington - 21/Apr/08 10:45 AM
If this is feasible for Ringding, IWBRN to have

P T Withington - 28/Oct/08 12:43 PM
I was initially thinking this would be trivial, it would just be XML that translated directly to JS. But I bet that is not what people will have in mind at all. I bet they will be thinking they can write anything that they can write in a <class> tag (like constraints, setters, handlers, events) and have those correctly 'mixed in' to their class. I'm not sure I want to open that can of worms. Is this really a feature that users need? We added mixins to our JS because we needed them to implement the LFC, but I haven't heard a crying need for these at the LZX level.

P T Withington - 28/Oct/08 12:46 PM
r11630 | ptw | 2008-10-28 16:45:21 -0400 (Tue, 28 Oct 2008) | 21 lines
Changed paths:
   M /openlaszlo/trunk/WEB-INF/lps/lfc/compiler/Class.lzs
   M /openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataElement.lzs
   M /openlaszlo/trunk/WEB-INF/lps/lfc/glue/LaszloInitiator.lzs
   M /openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/js2doc/PropertyReference.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java

Change 20081028-ptw-u by ptw@dueling-banjos.home on 2008-10-28 14:30:21 EDT
    in /Users/ptw/OpenLaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Replace `trait` with `mixin`

Bugs Fixed:
LPP-2302 Implement LZX <mixin> tag (partial)

Technical Reviewer: dda@ddanderson.com (Message-Id: <F85D0082-2BF5-437B-A86F-69F77AF77FC6@ddanderson.com>)
QA Reviewer: max (pending)

Details:
    Just stamping out the use of `trait`, which we decided was
    inaccurate, with its approved replacement `mixin`. Also removed
    the obsolete `inherits` synonym for `with`.

Tests:
    smokecheck


P T Withington - 10/Nov/08 05:10 PM
I have a very rough draft of this working, taking a completely different tack: Instead of trying to translate an LZX mixin to a JS mixin, I take the same approach as for JS, but at the LZX level. To wit: when I see an LZX <class> that has a 'with' property, I iterate through the list of mixin's, cloning them and re-jiggering them to represent the 'interstitial', that is I create 'anonymous' classes that are copies of the mixin, inserted into the correct spot in the class heirarchy. These anonymous classes are inserted into the LZX DOM at schema creation time, and will subsequently be compiled into JS classes.

Thus, an LZX mixin becomes effectively a macro for defining a class that adds all the properties of the mixin (everything, attributes, methods, events, handlers, setters, children, constraints, etc.) to an intermediate class that inherits from the superclass and becomes the superclass of the class being defined. It's somewhat dangerous, because it gives the LZX programmer a _significant_ amount of rope. Used judiciously, it will be very powerful, but used inexpertly, it will be a disaster.



P T Withington - 20/Nov/08 08:24 AM
r11841 | ptw | 2008-11-20 11:23:14 -0500 (Thu, 20 Nov 2008) | 67 lines
Changed paths:
   M /openlaszlo/trunk/WEB-INF/lps/lfc/core/LzConstants.lzs
   M /openlaszlo/trunk/WEB-INF/lps/schema/lfc-undeclared.lzx
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassCompiler.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ElementWithLocationInfo.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/InterfaceCompiler.java
   A /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/MixinCompiler.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ToplevelCompiler.java
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
   M /openlaszlo/trunk/lps/components/base/colors.lzx
   A /openlaszlo/trunk/test/mixins.lzx

Change 20081118-ptw-u by ptw@dueling-banjos.home on 2008-11-18 17:14:04 EST
    in /Users/ptw/OpenLaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: First pass at <mixin>

New Features: <mixin>

Bugs Fixed:
LPP-2302 Implement LZX <mixin> tag
LPP-7365 Update color names to use CSS3 standard

Technical Reviewer: max (pending)
QA Reviewer: hminsky (verbal)
Doc Reviewer: lou@louiorio.com (pending)

Documentation:

    <mixin> is like <class> but rather than creating something you can
    instantiate, creates a template that can be 'mixed in' (added to)
    more than one other class. A <mixin> is like an interface, but it
    is allowed to have state and implementation.

    <mixin> is an advanced feature. To add a mixin to a class you
    say:

    <class name="icecream" ... />
    <class name="walnuts" ... />

    <mixin name="toppings">
      <attribute name="sauce" type="color" value="lavender" />
      <attribute name="whippedcream" type="boolean" value="true" />
      <attribute name="cherry" type="boolean" value="true" />
      ...
    </mixin>

    <class name="sundae" extends="icecream" with="toppings />

    <sundae name="chocfulla"
      flavor="honeydew"
      sauce="lemonchiffon">
      <walnuts ground="true" />
    </sundae>

    See tests/mixins.lzx for a more complete example

Details:
    test/mixins: An example using classes and mixins

    lfc-undeclared: Add <mixin>

    LzConstants, ViewSchema: Update color tokes to CSS3 standard

    ClassCompiler: Learn how to create interstitial <nodes>, insert
    them into the schema.

    Compiler, MixinCompiler: For now, just compiles the mixin as a class.

    NodeModel: Only classes can have `extends` or `with` attributes.

    ElementWithLocationInfo: Support cloning of elements (to make
    mixin interstitials).

Tests:
    smokecheck, test/classes.lzx


Mamye Kratt - 21/Nov/08 03:50 PM
(trunk 4 build r11853)

Tucker, Can you reply in this bug?
Thanks,
Mamye

Results of testing:

Is this okay?
WEB-INF/lps/schema/lfc-undeclared.lzx --> has <element>traits<element>

I'm guessing this is not ok?
test/classes.lzx?debug=true&lzr=swf9 compiles successfuly
test/classes.lzx?debug=true&lzr=dhtml fails to compile (spins)
test/classes.lzx?debug=true&lzr=swf9 fails to display text

Mamye Kratt - 21/Nov/08 03:51 PM
Tucker, Please look at previous comments.

P T Withington - 09/Dec/08 06:21 AM
r12023 | ptw | 2008-12-09 09:21:02 -0500 (Tue, 09 Dec 2008) | 24 lines
Changed paths:
   M /openlaszlo/trunk/WEB-INF/lps/schema/lfc-undeclared.lzx
   M /openlaszlo/trunk/lps/components/utils/replicator/replicator.lzx
   M /openlaszlo/trunk/test/classes.lzx
   M /openlaszlo/trunk/test/lfc/states.lzx

Change 20081206-ptw-c by ptw@dueling-banjos.home on 2008-12-06 12:17:44 EST
    in /Users/ptw/OpenLaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Review comments on r11841

Bugs Fixed:
LPP-2302 Implement LZX <mixin> tag

Technical Reviewer: mamye@comcast.net (pending)

Details:
    classes: remove call to non-existent method

    states: rewrite in the modern way

    lfc-undeclared: trait -> mixin

    replicator: silence warning

Tests:
    classes.lzx, mixins.lzx, lfc/states.lzx