[Gambas-user] Enumerate all classes inheriting X

Benoît Minisini gambas at ...1...
Sat Nov 7 15:20:30 CET 2015


Le 06/11/2015 06:04, Tobias Boege a écrit :
> Hi,
>
> in my project I have the need to enumerate all classes from my current
> project (not from components) for which
>
>    hClass Is X
>
> is true for some fixed class X, once at startup. I think I tried
>
>    For Each hClass In Classes
>      hCurrent = hClass
>      While hCurrent.Parent
>        If hCurrent.Parent = Classes["X"] Then
>          aRes.Add(hClass)
>          Break
>        Endif
>        hCurrent = hCurrent.Parent
>      Wend
>    Next
>
> (written from memory, but it gets the idea across). However, this does not
> work as Classes can only access the already loaded classes.
>
> Is there a way to enumerate _all_ classes in the current project or to force
> loading of all remaining classes from the project? I have no particular
> technical problem with hard-coding the desired list instead of computing it
> but I want to know if I *could* compute it.
>
> Regards,
> Tobi
>

At the moment, you can't get any information on a class without loading 
it into the interpreterer, which may have unwanted effects...

I have the same need, so I may provide a solution in the future!

-- 
Benoît Minisini




More information about the User mailing list