Not necessarily ready to submit this change, see my concerns regarding "requires".

Change bargull-20110204-KsZ by bargull@Bargull02 on 2011-02-04 15:55:18
in /home/anba/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Generate accessor methods for public var declarations in mixins

New Features: LPP-5840 (SWF9: Auto-generate getters/setters for var declarations in mixins)

Technical Reviewer: ptw
QA Reviewer: (pending)

Documentation:

Release Notes:

Overview:
For every public, instance-allocated variable declaration in a mixin, the mixin interface will declare a getter/setter pair. And for every class the mixin get mixed-in, matching implementations of the getter/setter pairs are added. This approach almost worked for the data-mixins except for the case when an instance of LzDataElementMixin was treated as a LzDataNodeMixin. The flex compiler does not know that every LzDataElementMixin is a LzDataNodeMixin as well, therefore there were tons of "Access of possibly undefined property `foo` through a reference with static type `bar`" warnings. In order to overcome this error, I've added the "requires" keyword for mixin definitions. Basically "requires" should express that one mixin requires another mixin (or multiple mixins) on the class it's mixed-in. This is implemented by the means of the "extends" keyword in the swf9/10 backend. In ActionScript3, an "interface" can extend another interface (or multiple interfaces) similar to Java.
Gotchas:
- "requires" doesn't ensure the referred mixins are really used, only implementing the methods defined in the interface is actually sufficient for the flex compiler - "requires" only works with mixins, so you cannot require a class or whatsoever

Because of the outlined gotchas, the current implementation of "requires" is quite limited, I've merely used it to show that we need better means to describe requirements for mixins.


Details:
Parser.jjt:
- add "requires" keyword for mixin definitions

CommonGenerator.java:
- warn when mixins extend another mixin, see SWF9Generator
- added methods to generate the accesor and internal properties for public, instance-allocated variable declarations in mixins - don't emit interface methods for overriden methods, see LzDataElementMixin#cloneNode()

Compiler.java:
- remove unused import statement, dead code
- add support to substitute ClassProperty production
- handle FormalParameterList in visit() to be able to specify method return types in substituted code patterns

ParseTreePrinter.java:
- emit "requires" keyword for mixins

SWF9Generator.java:
- process "requires" keyword for mixins
- transform MixinsList to ExpressionList similar to the "implements" keyword

LzDataText.lzs, LzDataNode.lzs, LzDataElement.lzs:
- type declarations no longer need to be commented out
- publicize variable declarations which need to have the auto-generated accessor methods

LzDataElement.lzs:
- add "requires LzDataNodeMixin" so the flex compiler knows that every LzDataElementMixin is also a LzDataNodeMixin

LzXMLTranslator.as:
- change to LzDataElementMixin otherwise the flex compiler will complain

Tests:
compile lfc for swf10, alldata, smokecheck

Files:
M WEB-INF/lps/lfc/kernel/swf9/LzXMLTranslator.as
M WEB-INF/lps/lfc/data/LzDataText.lzs
M WEB-INF/lps/lfc/data/LzDataNode.lzs
M WEB-INF/lps/lfc/data/LzDataElement.lzs
M WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
M WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/bargull-20110204-KsZ.tar

Reply via email to