[aspectc-user] usage of typedefed type names in pcds

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Wed Jan 24 12:54:57 CET 2007


Hello Panu,

it is not a bug, it is a missing feature. The match mechanism in AspectC++
simply ignores typedefs. Match expressions are always matched against the real
types, i.e. "T f()" would only match if T was a type such as a class T -- and
not a typedef.

The reason for not having this nice feature is that the same typedef name T
could have a different meaning in different translation units. For example:

T-Unit 1: typedef int T;    int f();
T-Unit 2: typedef double T; int f();

With a match expression "T f()" the weaver would transform f() in T-Unit 1, but
not in T-Unit 2. f() might be declared and/or defined in a header file that is
included by both *.cpp files, i.e. it is the *same* f(). However, the weaver
would transform f() inconsistently. The resulting code would not work as expected.

We are thinking about a solution that avoids the aforementioned problem by
forcing the programmer to define T in all translations units in the same way,
e.g. like this:

typedef int T; // or include "T.h" ...
pointcut typeT() = type(T); // the weaver checks if T exists here!
advice execution("% f()") && result(typeT()) : ...

However, this hasn't been implemented yet.

- Olaf

Panu Bloigu wrote:
> Hello.
> 
> I'm having problems with matching of pointcuts when pointcut expression
> includes types defined with typedef. They simply don't seem to be get
> matched. To see what I mean, please consider the following two files:
> 
> =================
> File 1: main.cpp
> =================
> #include <iostream>
> typedef int T;
> T f(){return 10;}
> int main()
> {
> 	std::cout<<f()<<"\n";
> 	return 0;
> };
> 
> =================
> File 2: Aspect.ah
> =================
> #ifndef ASPECT_AH_
> #define ASPECT_AH_
> #include <iostream>
> aspect Aspect
> {
> 	advice call("T f()") : before()
> 	{
> 		std::cout<<"Before call.\n";
> 	}
> };
> #endif /*ASPECT_AH_*/
> 
> =====================================================
> 
> The call to f() isn't matched. If I change the expression so that instead of
> T there is int, then the call gets matched. % works for this too.
> 
> There seem to be some bugs in BZ which concern typedef, but they seemed to
> deal with a lot more complex examples than this. What I'm asking is
> 
> a) is this an instance of one of the bugs in BZ
> 
> or
> 
> b) is this an unlisted bug
> 
> or
> 
> c) Am I doing something wrong here?
> 
> Thanks is advance,
> 
> Panu.
> 
> _______________________________________________
> 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