Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 03, 2017 Finding all the interfaces and their inheritance relationships at runtime | ||||
---|---|---|---|---|
| ||||
I know how to find all the classes: foreach (mod; ModuleInfo) { foreach (c; mod.localClasses) { // use c.base to construct inheritance graph } } Can I do the same with all the interfaces? Looking at object.d gives no clue... |
July 03, 2017 Re: Finding all the interfaces and their inheritance relationships at runtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jean-Louis Leroy | On Monday, 3 July 2017 at 13:54:42 UTC, Jean-Louis Leroy wrote:
> I know how to find all the classes:
>
> foreach (mod; ModuleInfo) {
> foreach (c; mod.localClasses) {
> // use c.base to construct inheritance graph
> }
> }
>
> Can I do the same with all the interfaces? Looking at object.d gives no clue...
Is there a reason you need to do it with runtime and can't use __traits?
|
July 03, 2017 Re: Finding all the interfaces and their inheritance relationships at runtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to bauss | On Monday, 3 July 2017 at 20:45:19 UTC, bauss wrote:
> On Monday, 3 July 2017 at 13:54:42 UTC, Jean-Louis Leroy wrote:
>> I know how to find all the classes:
>>
>> foreach (mod; ModuleInfo) {
>> foreach (c; mod.localClasses) {
>> // use c.base to construct inheritance graph
>> }
>> }
>>
>> Can I do the same with all the interfaces? Looking at object.d gives no clue...
>
> Is there a reason you need to do it with runtime and can't use __traits?
He didn't say *with* runtime but *at*. Changes the whole meaning ;)
|
July 04, 2017 Re: Finding all the interfaces and their inheritance relationships at runtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to FoxyBrown | On Monday, 3 July 2017 at 22:34:51 UTC, FoxyBrown wrote:
> On Monday, 3 July 2017 at 20:45:19 UTC, bauss wrote:
>> On Monday, 3 July 2017 at 13:54:42 UTC, Jean-Louis Leroy wrote:
>>> I know how to find all the classes:
>>>
>>> foreach (mod; ModuleInfo) {
>>> foreach (c; mod.localClasses) {
>>> // use c.base to construct inheritance graph
>>> }
>>> }
>>>
>>> Can I do the same with all the interfaces? Looking at object.d gives no clue...
>>
>> Is there a reason you need to do it with runtime and can't use __traits?
>
> He didn't say *with* runtime but *at*. Changes the whole meaning ;)
It's OK I found how to achieve what I want. I'll enumerate the classes an dfrom there work my way down via ClassInfo.interfaces. It turns out that Interface.classinfocontains the interface's inherited interfaces; the 'classinfo' name is a bit misleading though...
|
Copyright © 1999-2021 by the D Language Foundation