I'll have a look at it today. EdB
On Wednesday, October 30, 2013, Peter Ent wrote: > Thanks, Erik. Interesting read. FlexJS uses a lot of interfaces so we'll > have to find a reasonable solution for this. We've managed to avoid the > situation in JavaScript but it is coming up quickly. > > --peter > > On 10/30/13 3:10 PM, "Erik de Bruin" <e...@ixsoftware.nl> wrote: > > >Some guidance can be found here [1] and here [2]. > > > >EdB > > > >1: > > > http://blogs.adobe.com/bparadie/2011/11/26/classes-inheritance-interfaces- > >packages-and-namespaces/ > >2: > > > https://cwiki.apache.org/confluence/display/FLEX/Simulating+AS3+language+f > >eatures+in+JavaScript+using+AMD+and+ES5 > > > > > > > >On Wed, Oct 30, 2013 at 8:07 PM, Erik de Bruin <e...@ixsoftware.nl> > wrote: > >> "instanceof" doesn't check if an interface is implemented, neither in > >> Flex nor using Closure inheritance in JavaScript. What we need for > >> runtime checking of interface implementation is an global "is" > >> function... I think I taught FalconJx to translate "ClassA is ClassB" > >> as "is(ClassA, ClassB)". All we need to do now is to implement a > >> global "is()" function and somehow teach the compiler to keep track of > >> which classes implement which interfaces - all the way up the chain > >> and sideways (interfaces can implement interfaces). > >> > >> EdB > >> > >> > >> > >> On Wed, Oct 30, 2013 at 6:34 PM, Alex Harui <aha...@adobe.com> wrote: > >>> Reviving this thread... > >>> > >>> Peter says he wants to test to see if an object implements an > >>>interface at > >>> runtime. What mechanism do we want to use? > >>> > >>> I don't think we need to make instanceof work, just have some test to > >>>call. > >>> > >>> -Alex > >>> > >>> On 7/30/13 12:46 AM, "Erik de Bruin" <e...@ixsoftware.nl> wrote: > >>> > >>>>When using interfaces for type checking, there are two 'kinds': at > >>>>compilation and at runtime. > >>>> > >>>>The @interface and @implements annotations are for compile time > >>>>checking. > >>>> > >>>>For runtime checking comes in two flavours: 'instanceof' and 'is'. > >>>> > >>>>Our method of setting up inheritance (goog.inherits) maintains the > >>>>inheritance chain, so 'instanceof' works out of the box. > >>>> > >>>>The work starts with 'is'. We want to story the 'extends' and > >>>>'implements' metadata from AS in the JS classes and create a method to > >>>>test against that metadata set. I have a pretty good idea on how to > >>>>implement such a beast, but it will require some (ha!) tinkering with > >>>>the FlexJS JS framework and FalconJx. That will take some time... > >>>> > >>>>EdB > >>>> > >>>> > >>>> > >>>>On Mon, Jul 29, 2013 at 9:17 PM, OmPrakash Muppirala > >>>><bigosma...@gmail.com> wrote: > >>>>> On Mon, Jul 29, 2013 at 11:20 AM, Alex Harui <aha...@adobe.com> > >>>>>wrote: > >>>>> > >>>>>> I think FalconJS was going to generate something like: > >>>>>> > >>>>>> if (child != undefined && > >>>>>> child.$implements["org.apache.flex.core.IChrome"]) > >>>>>> > >>>>>> Not sure what it was going to do for classes, maybe chase the > >>>>>>prototype > >>>>>> chain? > >>>>>> > >>>>>> The other thing that occurred to me about $implements or > >>>>>>child.is(IChrome) > >>>>>> is that all objects must then have these properties or functions > >>>>>>where > >>>>>>the > >>>>>> global function -- Ix Multimedia Software Jan Luykenstraat 27 3521 VB Utrecht T. 06-51952295 I. www.ixsoftware.nl