[Laszlo-dev] [UPDATED^3] For Review: Change 20080313-ptw-5 Summary: LZX classes as JS2 classes
P T Withington
ptw at pobox.com
Mon Mar 17 08:41:03 PDT 2008
I think a better way to do this might be:
class LzNode {
static var options = {};
var options;
function LzNode () {
options = LzNode.options;
function $lzc$set_options (hash) {
if (this.options == LzNode.options) {
this.options = new LzInheritedHash(this.options);
Options don't really need to be created/inherited for each subclass,
because they come across as an arg, and we have the magic structured-
args-get-merged-feature:
<canvas debug="true">
<include href="lzunit/lzunit.lzx" />
<class name="foo" extends="TestCase" options="bar: 1; baz:
'wrong'" />
<class name="zot" extends="foo" options="baz: 2" />
<TestSuite>
<zot options="crud: 42">
<method name="testOptionInheritance">
assertEquals(getOption('bar'), 1);
assertEquals(getOption('baz'), 2);
assertEquals(getOption('crud'), 42);
</method>
</zot>
</TestSuite>
</canvas>
Passes just fine.
On 2008-03-17, at 11:04 EDT, Henry Minsky wrote:
> question about porting to AS3:
>
> in LzNode:
>
> function $lzc$set_options(hash) {
> // Ensure you have your own private options dictionary, not the one
> // inherited from your class, nor the default empty one inherited
> // from LzNode!
> if (this.options === this['constructor'].prototype.options) {
> this.options = new LzInheritedHash(this.options);
> }
> for (var key in hash) {
> this.options[ key ] = hash[key];
> }
> }
>
>
>
> In order to get the class static var "options", I wonder if
> this['constructor'].prototype.options will work in AS3 to get the
> class var? Maybe it will have to be conditionalized to be
> this['constructor'].options in for the SWF9 case?
>
>
>
>
>
> On Sun, Mar 16, 2008 at 4:33 PM, P T Withington <ptw at pobox.com> wrote:
>> [UPDATED: Ok, with this update, the smokecheck passes and Amazon
>> seems
>> to work for me. I'd like to check this in so Henry/Don can work on
>> porting it to devildog while Max/I continue debugging in trunk.]
>>
>> Change 20080313-ptw-5 by ptw at dueling-banjos.local on 2008-03-13
>> 10:54:50 EDT
>> in /Users/ptw/OpenLaszlo/ringding-clean
>> for http://svn.openlaszlo.org/openlaszlo/trunk
>>
>> Summary: LZX classes as JS2 classes
>>
>> New Features: The tag compiler now emits LZX classes as JS2 class
>> declarations
>>
>> Bugs Fixed:
>> LPP-1587 'ECMA4: Compile LZX declarations as JS
>> declarations' (partial)
>>
>> Technical Reviewer: henry.minsky at gmail.com (pending)
>> QA Reviewer: max at openlaszlo.org (pending)
>> Doc Reviewer: lou at louiorio.com (pending)
>>
>> Release Notes:
>> Classes defined using the <class name="name"> _must_ be
>> referenced
>> in script as `lz.name`, there will no longer be a global alias
>> `name` that refers to the class implementing the tag.
>>
>> getAttribute is deprecated. You should just reference the
>> attribute directly. getters are no longer supported.
>>
>> Details:
>> Highlights: The tag compiler now emits user classes as a JS2
>> class declaration. UserClass.lzs is dead. Setters are now just
>> methods on a class with a distinctive name, so the whole setters
>> table inheritance mechanism is gone. Early/delayed setters is a
>> private protocol between LzNode and LzView. All classes have a
>> uniform 'namespace' naming scheme: $lzc$class_<tagname>, old LFC
>> class names are maintained for compatibility, but there are NO
>> global class names any more. All user code will have to be
>> updated to use lz.<tagname> to address classes for `new` or
>> `instanceof` tests.
>>
>> Every LFC Class: Use new static `attributes` mechanism, new
>> setters methods naming scheme, remove old setters table.
>>
>> LzNode: Implement new static `attributes` mechanism. Break out
>> mergeAttributes and mergeChildren as class methods so they can be
>> used by user classes. Fetch default attributes from constructor.
>> Install decls compiler can't detect. Merge with instantiation
>> attributes. Use common merge subroutines. Install namespace
>> alias. Remove all obsolete inherited hashes now that we use
>> class
>> inheritance to manage that. Early/delayed setters are now a
>> private protocol between Node and View. No other classes should
>> use these. In applyArgs look for setters as methods. Deprecate
>> getAttribute, getters have not been supported for a long time.
>> Update setAttribute to use setter methods. Remove old setters
>> mechanism. Deprecate __LZaddSetter, __LZstoreRefs -- private
>> protocol no longer supported. Change options setters to create
>> necessary inherited hash on the fly.
>>
>> UserClass: Empty, save for documentation and the placement
>> kludge.
>>
>> LzDefs: Flatten inherited hash so we can dispense with
>> _ignoreAttribute (and be portable!).
>>
>> LzView, LzCanvas: Cooperate with LzNode on early/late setters.
>>
>> LzState: Adapt to new user class implementation which may place
>> state methods in the wrong place, and won't allow dynamically
>> adding setters.
>>
>> TODO: Clean up the setter trampolines to be the actual setters
>> and have the old public setXXX methods call them (with a
>> deprecation warning where appropriate).
>>
>> Schema: intern types.
>>
>> JavascriptGenerator: Don't make checked nodes outside of a
>> function context (you won't have a 'this').
>>
>> JavascriptGenerator, CodeGenerator: Temporarily turn of
>> setAttribute inlining until it can be updated.
>>
>> CommonGenerator: Translate declared attributes as having an
>> undefined
>> initial value.
>>
>> ScriptCompiler: Support for converting objects to script,
>> including undefined values.
>>
>> ScriptClass: Complete implementation that writes out a class as a
>> JS2 class declaration.
>>
>> ClassCompiler: Compile user classes to JS2 class declarations,
>> which mostly involves mimicing the way UserClass used to
>> initialize according to the various types of initial values,
>> setters, and stateliness that you might have.
>>
>> CanvasCompiler, CompilationEnvironment, etc.: Eliminate vestigial
>> support for case-insensitive runtimes
>>
>> NodeModel: Support class compilation by delaying conversion of
>> bindings for attributes.
>>
>> ClassModel: Support for (not yet used) merging of superclass
>> attributes and setters. Missing modelling of built-in classes.
>>
>> Tests:
>> smokecheck (minus broken test LPP-5610) passes in both runtimes,
>> amazon runs in both runtimes
>>
>> Files:
>> M WEB-INF/lps/lfc/kernel/swf/LzLibrary.lzs
>> M WEB-INF/lps/lfc/kernel/dhtml/LzLibrary.js
>> M WEB-INF/lps/lfc/kernel/swf9/LzLibrary.lzs
>> M WEB-INF/lps/lfc/kernel/LzLibraryCleanup.lzs
>> M WEB-INF/lps/lfc/core/LzNode.lzs
>> M WEB-INF/lps/lfc/core/UserClass.lzs
>> M WEB-INF/lps/lfc/core/LzDefs.lzs
>> M WEB-INF/lps/lfc/views/LzInputText.lzs
>> M WEB-INF/lps/lfc/views/LzScript.lzs
>> M WEB-INF/lps/lfc/views/LzText.lzs
>> M WEB-INF/lps/lfc/views/LaszloView.lzs
>> M WEB-INF/lps/lfc/views/LaszloCanvas.lzs
>> M WEB-INF/lps/lfc/helpers/LzDataSelectionManager.lzs
>> M WEB-INF/lps/lfc/helpers/LzCommand.lzs
>> M WEB-INF/lps/lfc/helpers/LzSelectionManager.lzs
>> M WEB-INF/lps/lfc/helpers/LzState.lzs
>> M WEB-INF/lps/lfc/controllers/LzAnimatorGroup.lzs
>> M WEB-INF/lps/lfc/controllers/LaszloLayout.lzs
>> M WEB-INF/lps/lfc/controllers/LaszloAnimation.lzs
>> M WEB-INF/lps/lfc/data/LzReplicationManager.lzs
>> M WEB-INF/lps/lfc/data/platform/swf/LzConnectionDatasource.lzs
>> M WEB-INF/lps/lfc/data/platform/swf/LzConnection.lzs
>> M WEB-INF/lps/lfc/data/LzDatapointer.lzs
>> M WEB-INF/lps/lfc/data/LzDataText.lzs
>> M WEB-INF/lps/lfc/data/LzDataRequest.lzs
>> M WEB-INF/lps/lfc/data/LzDataElement.lzs
>> M WEB-INF/lps/lfc/data/LzDataProvider.lzs
>> M WEB-INF/lps/lfc/data/LzDataset.lzs
>> M WEB-INF/lps/lfc/data/LzDatapath.lzs
>> M WEB-INF/lps/lfc/data/LzHTTPDatasource.lzs
>> M WEB-INF/lps/lfc/data/LzParam.lzs
>> M WEB-INF/lps/server/src/org/openlaszlo/xml/internal/Schema.java
>> M WEB-INF/lps/server/src/org/openlaszlo/sc/
>> JavascriptGenerator.java
>> M WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
>> M WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java
>> M WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
>> M WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptClass.java
>> M WEB-INF/lps/server/src/org/openlaszlo/compiler/
>> ClassCompiler.java
>> M WEB-INF/lps/server/src/org/openlaszlo/compiler/
>> CanvasCompiler.java
>> M WEB-INF/lps/server/src/org/openlaszlo/compiler/
>> CompilationEnvironment.java
>> M WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
>> M WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
>>
>> Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20080313-ptw-5.tar
>>
>
>
>
> --
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com
More information about the Laszlo-dev
mailing list