[aspectc-user] Matching Constructors

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Wed Nov 16 14:34:45 CET 2005


Hi,

you have to use the "construction" pointcut function for this purpose 
(have a look into our quick reference sheet):

advice construction("Foo") : before () {
   cout << "a Foo instance is about to be created" << endl;
}

Note that before advice will be executed before the *body* of the 
constructor. Base class constructors are already executed at that time.

Be careful with using pointcut expressions like construction("%"). This 
leads to lots of transformations. If there are any problems with the 
code that ac++ generates, it can hardly be localized. Better start with 
a single class and increase the amount of matched classes step by step. 
Report any problems on this list or, even better, in our bugzilla system 
at http://www.aspectc.org/bugzilla.

Best regards,

Olaf

PS: for an example you can look into the AspectC++ example "Instances".

Mark Hennessy wrote:
> Is there any similar functionality within AspectC similar
> to the match ( *.new(..) ) within AspectJ?
> 
> I am trying to trace all the object creation within a system
> and thus far using a pattern like ("% Scope::Scope(...)")
> to match a constructor doesn't work.
> 
> Cheers,
> 
> Mark Hennessy
> 
> Maynooth
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user




More information about the aspectc-user mailing list