[aspectc-user] Intercepting execution of nested class

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Tue Jun 8 08:53:53 CEST 2004


Hi Bartosz,

Bartosz Blimke wrote:
> Another problem :)
> 
> During experiments on previosu problem I have found another one:
> 
> lets take a code like this:
> 
> //main.cpp
> #include <stdio.h>
> 
> 
> void func () {
> 
>    printf ("func\n");
> }
> 
> 
> class Class1
> {
> public:
> 	class Class2
> 	{
> 	public:
> 	  void func1()
> 	  {
> 		  printf("Class1::Class2::func1\n");
> 	  }
> 	} class2Instance;
> };
> 
> 
> int main (int argc, char * argv[]) {
>    func ();
>    Class1 class1;
>    class1.class2Instance.func1();
>    return 0;
> }
> //end of main.cpp
> 
> 
> 
> //Aspect.ah
> #ifndef __Aspect_ah__
> #define __Aspect_ah__
> 
> #include <stdio.h>
> 
> aspect Aspect {
> 
> 	pointcut methods() = execution("% ...::func1(...)");
> 
> 	advice methods() : before()
> 	{
>             printf("before %s\n", thisJoinPoint->signature());
> 	}

> };
> #endif // __Aspect_ah__
> //endo of Aspect.ah
> 
> 
> 
> This code doesnt work becouse pointcut doesn't seem to
> be correct.
> How can I define pointcut to intercept method of nested class:
> 
> "% Class1::Class2::func1(...)" doesnt work too.
> 
> 
> Greets,
> 
> Bartosz Blimke
> masb at chorwacja.com

The match expression "% ...::func1(...)" only works with the new (and 
unpublished) version 0.9pre1. It does not work with 0.8.1. For 0.8.1 you 
have to write "% Class1::Class2::func1(...)".

I tried to compile your code. The match expression matches, but the 
generated code is wrong. Therefore, the C++ compiler is not able to 
produce an executable program. Thank you for reporting this bug! I'll 
look into the problem immediately.

Best regards,

Olaf



More information about the aspectc-user mailing list