Source code of a method.
Gary Willoughby
dev at nomad.so
Sat Oct 26 14:58:59 PDT 2013
On Saturday, 26 October 2013 at 20:38:14 UTC, TheFlyingFiddle
wrote:
> On Saturday, 26 October 2013 at 19:04:09 UTC, Gary Willoughby
> wrote:
>> On Saturday, 26 October 2013 at 16:36:35 UTC, TheFlyingFiddle
>> wrote:
>>> Is there a way to extract the source code of a method at
>>> compiletime?
>>
>> Nope. What do you need to do?
>
>
> I'm currently making an AOP framework. I use UDA's to handle
> logging, exception handling ect.
>
> It looks something like this currently.
>
> class Foo : IFoo
> {
> @Log("bar.txt") @DLLException()
> void bar(...params...)
> {
> //dosomething
> }
> }
>
> unittest
> {
> alias TypeTuple!(LogWrapper, DLLExeWrapper, ...) wrappers;
>
> //Normal foo
> auto fooProto = new Foo();
>
> //Wrapped foo having some nice extra functionallity for
> Foo.bar
> IFoo foo = new wrap!(Foo, IFoo, wrappers)(fooProto);
> }
>
> Currently the wrappped foo delegates to fooProto aswell as
> adding the functinallity specified by the UDA's. I basically
> wanted to remove the
> delegation. And just put the source code in the newly created
> foo specialisation.
I kind of did the same thing here in the Mockable mixin:
https://github.com/nomad-software/dunit Instead of wrapping i
simply extended the target class so i have access to
'super.bar()'. Then i can add the specialisation code and/or call
the original method too.
More information about the Digitalmars-d-learn
mailing list