royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com.INVALID>
Subject Re: Reflection TypeDefinition API gives unexpected results
Date Mon, 08 Oct 2018 03:00:21 GMT
I'm pretty sure I saw Metadata work in manualtests/ReflectionTest at one point in time.  It
could be broken now, or maybe you can follow that example in your code.

HTH,
-Alex

´╗┐On 10/7/18, 9:12 AM, "Carlos Rovira" <carlosrovira@apache.org> wrote:

    Thanks Greg, Alex,
    
    I now understand that Bindable in a property introduces EventDispatcher,
    now that has more sense. What confuse me is that Bindable is on property
    not in class, but is normal that class has event dispatcher.
    
    For me now the problem is just about the const and the metadata. For the
    latest, where I should retrieve the [injection] and [Bindable] metadata?
    
    I'm going to check the test and try the class in my example. I'll report if
    something goes wrong so you can take a look at it.
    
    El dom., 7 oct. 2018 a las 0:26, Greg Dove (<greg.dove@gmail.com>) escribi├│:
    
    > Hi Carlos,
    >
    > There could still be bugs, but there are some unit tests. You might find
    > some useful reference in the unit tests :
    >
    > https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Froyale-asjs%2Fblob%2Fdevelop%2Fmanualtests%2FUnitTests%2Fsrc%2Fmain%2Froyale%2FflexUnitTests%2Freflection%2FReflectionTesterTest.as&amp;data=02%7C01%7Caharui%40adobe.com%7Cee518d80d49d4283762a08d62c6fb7b7%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636745255666448646&amp;sdata=oBsEe5MN2ley3qJQ%2BRtXnyqF%2B3fOokzxgPZdnEqJhnw%3D&amp;reserved=0
    >
    > And some of the test classes used:
    >
    > https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Froyale-asjs%2Ftree%2Fdevelop%2Fmanualtests%2FUnitTests%2Fsrc%2Fmain%2Froyale%2FflexUnitTests%2Freflection%2Fsupport&amp;data=02%7C01%7Caharui%40adobe.com%7Cee518d80d49d4283762a08d62c6fb7b7%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636745255666458656&amp;sdata=rcnxH4LtYdEx1MsJNCTeMiSaU7D0XNRJDGZ1bdWyKCU%3D&amp;reserved=0
    >
    > If there is a case not working, then the coverage would need to include
    > that. I can take a look at this in the coming week if you add a failing
    > case.
    >
    > I can't recall offhand about whether consts (static or instance) were
    > included as part of the reflection data. But I can see at least one Test
    > Class that includes both static and instance consts, so the reflection data
    > should either intentionally include or exclude them - if the tests fail
    > then something may have changed.
    >
    > In terms of EventDispatcher as base class, I did not check, but maybe this
    > class is bindable? In which case it will have EventDispatcher injected as a
    > base class by the compiler. Because the reflection data is collected from
    > the runtime inheritance chain in javascript, it should be related to
    > whatever the compiler provided as output code. This would apply in flash as
    > well as javascript, although flash would have more data below the Royale
    > EventDispatcher as the native classes are reflectable (not the case with
    > the google event base classes on the js side).
    >
    > Hope there is something helpful there for now.
    >
    > -Greg
    >
    >
    > On Sun, Oct 7, 2018 at 7:33 AM Carlos Rovira <carlosrovira@apache.org>
    > wrote:
    >
    > > Hi,
    > >
    > > I'm trying to do some Reflection work and finding some unexpected
    > results.
    > > Given this example class:
    > >
    > > package controllers
    > > {
    > > import interfaces.IController;
    > >
    > > import models.User;
    > >
    > > import services.UserService;
    > >
    > > public class UserController implements IController
    > > {
    > > public static const USER_CONTROLLER_EVENT:String = "userControllerEvent";
    > >
    > > /**
    > >          * Constructor
    > >          */
    > > public function UserController()
    > > {
    > > trace("UserController constructor");
    > > }
    > >
    > > private var _userService:UserService;
    > >
    > > [Inject]
    > > public function get userService():UserService
    > > {
    > >     return _userService;
    > > }
    > > public function set userService(value:UserService):void
    > > {
    > > trace("setting userService: ", value);
    > >     _userService = value;
    > > }
    > > [Bindable]
    > > public var currentUser:User;
    > > }
    > > }
    > >
    > > I want to retrieve, super class, interface, metadata, const and vars and
    > > methods, so I think I should use this:
    > >
    > > var typeDefinition:TypeDefinition = describeType(target);
    > >
    > > To see what this retrieves for this email the toString method is great:
    > >
    > > typeDefinition.toString(true);
    > >
    > > RESULT:
    > >
    > > *typeDefinition.toString  Typedefinition: controllers.UserController,
    > > kind:class*
    > > *constructor :*
    > > * method: 'UserController', returnType:''
    > > declaredBy:controllers.UserController*
    > > * {No parameters}*
    > > *interfaces :*
    > > * Typedefinition: interfaces.IController, kind:interface*
    > > * Typedefinition: org.apache.royale.events.IEventDispatcher,
    > > kind:interface. <---- this is unexpected*
    > > *baseClasses :*
    > > * Typedefinition: org.apache.royale.events.EventDispatcher, kind:class.
    > > **<----
    > > this is unexpected*
    > > *variables :*
    > > * {none}*
    > > *accessors :*
    > > * accessor: 'currentUser' access:readwrite, type:models.User,
    > > declaredBy:controllers.UserController*
    > > * accessor: 'userService' access:readwrite, type:services.UserService,
    > > declaredBy:controllers.UserController*
    > > *methods :*
    > > * method: 'hasEventListener', returnType:Boolean
    > > declaredBy:org.apache.royale.events.EventDispatcher.  **<---- this is
    > > unexpected (but normal due to EventDispatcher listed as base class*
    > > * parameter 1, optional:false, type:String*
    > > * method: 'dispatchEvent', returnType:Boolean
    > > declaredBy:org.apache.royale.events.EventDispatcher.  * *<---- this is
    > > unexpected (but normal due to EventDispatcher listed as base class*
    > > * parameter 1, optional:false, type:Object*
    > > * method: 'toString', returnType:String
    > > declaredBy:org.apache.royale.events.EventDispatcher * *<---- this is
    > > unexpected (but normal due to EventDispatcher listed as base class*
    > > * {No parameters}*
    > > *static variables :*
    > > * {none} *  *<---- this is unexpected where is *USER_CONTROLLER_EVENT*?*
    > > *static accessors :*
    > > * {none}*
    > > *static methods :*
    > > * {none}*
    > >
    > > As I stated in other email, the most annoying thing is the
    > > *EventDispatcher*
    > > and *methods* listed as super class of this class...
    > > the other is no *static var* listed
    > >
    > > One thing I need most is to retrieve new *Metadata* I want to insert, I'm
    > > taking about the [Inject] metadata, I put [Bindable] as well since is
    > > already used, but I don't see any signals of any one of them
    > >
    > > I must say that I have in config/compile-swf-config.xml this code:
    > >
    > > <keep-as3-metadata>
    > > <name>Bindable</name>
    > > ...
    > > ...
    > > <name>Inject</name>
    > > </keep-as3-metadata>
    > >
    > > and building with maven
    > >
    > > Is this a bug, or maybe this API is unfinished ? or maybe I'm missing
    > > something ?
    > >
    > > Thanks
    > >
    > >
    > > --
    > > Carlos Rovira
    > > https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&amp;data=02%7C01%7Caharui%40adobe.com%7Cee518d80d49d4283762a08d62c6fb7b7%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636745255666458656&amp;sdata=dV0n8IOhs6PhVzzNZ2llCtTCO2TYt%2BNujqVsdL6wQx0%3D&amp;reserved=0
    > >
    >
    
    
    -- 
    Carlos Rovira
    https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&amp;data=02%7C01%7Caharui%40adobe.com%7Cee518d80d49d4283762a08d62c6fb7b7%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636745255666458656&amp;sdata=dV0n8IOhs6PhVzzNZ2llCtTCO2TYt%2BNujqVsdL6wQx0%3D&amp;reserved=0
    

Mime
View raw message