royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Dove <greg.d...@gmail.com>
Subject Re: Reflection TypeDefinition API gives unexpected results
Date Sat, 06 Oct 2018 22:26:24 GMT
Hi Carlos,

There could still be bugs, but there are some unit tests. You might find
some useful reference in the unit tests :
https://github.com/apache/royale-asjs/blob/develop/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTest.as

And some of the test classes used:
https://github.com/apache/royale-asjs/tree/develop/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support

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
> http://about.me/carlosrovira
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message