Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
February 04, 2016 Iterating over modules | ||||
---|---|---|---|---|
| ||||
Hi, is there any way how to iterate over every module/submodule? I have project like Rikarin Rikarin/AppKit Rikarin/Drawing Rikarin/Runtime etc. In every directory, I have package.d file where I include every .d file from the dir. And the think what I want to do is to define UDA's like @Action, @Outlet, etc. for methods and generate runtime info for them. I know I can use something like mixin(generate!...); in every file where I used that UDA's, but its not the best idea for me. |
February 04, 2016 Re: Iterating over modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Satoshi | On Thursday, 4 February 2016 at 15:45:03 UTC, Satoshi wrote: > Hi, > is there any way how to iterate over every module/submodule? > > I have project like > Rikarin > Rikarin/AppKit > Rikarin/Drawing > Rikarin/Runtime > etc. > > In every directory, I have package.d file where I include every .d file from the dir. > > And the think what I want to do is to define UDA's like @Action, @Outlet, etc. for methods and generate runtime info for them. > > I know I can use something like mixin(generate!...); in every file where I used that UDA's, but its not the best idea for me. No, there isn't, and I feel your pain. The only way is to do something similar to what dtest does for unit-threaded, i.e. have a 1st run-time that reads all directories and writes the equivalent source for you, or simply write it by hand and maintain whenever you add/delete a module: https://github.com/atilaneves/dtest https://github.com/atilaneves/unit-threaded Atila |
February 05, 2016 Re: Iterating over modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Satoshi | On 05/02/16 4:45 AM, Satoshi wrote:
> Hi,
> is there any way how to iterate over every module/submodule?
>
> I have project like
> Rikarin
> Rikarin/AppKit
> Rikarin/Drawing
> Rikarin/Runtime
> etc.
>
> In every directory, I have package.d file where I include every .d file
> from the dir.
>
> And the think what I want to do is to define UDA's like @Action,
> @Outlet, etc. for methods and generate runtime info for them.
>
> I know I can use something like mixin(generate!...); in every file where
> I used that UDA's, but its not the best idea for me.
I would suggest __traits(allMembers to grab public imports, but it is bugged.
There was a fix I had, but it wasn't merged :(
|
February 04, 2016 Re: Iterating over modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Satoshi | On Thursday, 4 February 2016 at 15:45:03 UTC, Satoshi wrote:
> Hi,
> is there any way how to iterate over every module/submodule?
>
> I have project like
> Rikarin
> Rikarin/AppKit
> Rikarin/Drawing
> Rikarin/Runtime
> etc.
>
> In every directory, I have package.d file where I include every .d file from the dir.
>
> And the think what I want to do is to define UDA's like @Action, @Outlet, etc. for methods and generate runtime info for them.
>
> I know I can use something like mixin(generate!...); in every file where I used that UDA's, but its not the best idea for me.
disclaimer: I don't know if this works.
enum fileContent = import(__FILE__);
parse imports and repeat this recursivly for all found imports
|
February 04, 2016 Re: Iterating over modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zoadian | On Thu, 04 Feb 2016 16:57:09 +0000, Zoadian wrote:
> enum fileContent = import(__FILE__);
>
> parse imports and repeat this recursivly for all found imports
The path for module imports is not the same as the path for file imports, so this might not do everything you want.
|
Copyright © 1999-2021 by the D Language Foundation