Getters/setters generator
Eugene Wissner via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Mon Jan 16 22:09:25 PST 2017
On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote:
> Hello,
>
> we've just open sourced a small module ("accessors") that helps
> to generate getters and setters automatically:
> https://github.com/funkwerk/accessors
> http://code.dlang.org/packages/accessors
>
> It takes advantage of the UDAs and mixins. A simple example
> would be:
>
> import accessors;
>
> class WithAccessors
> {
> @Read @Write
> private int num_;
>
> mixin(GenerateFieldAccessors);
> }
>
> It would generate 2 methods "num": one to set num_ and one to
> get its value. Of cause you can generate only @Read without
> @Write and vice versa. There are some more features, you can
> find the full documentation in the README.
> "GenerateFieldAccessors" mixin should be added into each
> class/struct that wants to use auto generated accessors.
We just released the next version of the accessors: v1.1.0
- One problem with inheritance was fixed.
- And the generated accessors are always properties know.
More information about the Digitalmars-d-announce
mailing list