[aspectc-user] pointcut on new and delete operator
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Fri May 19 09:19:45 CEST 2006
Hi,
the problem with your example is that execution advice only affects
functions that are *defined* in a file that belongs to your project. It
never affects builtin functions such as the builtin new and delete
operators. If you would define a new class with a new/delete operator or
(as a possible workaround) you own global new/delete operator, your
advice would match.
There is a plan to support *call* advice on builtin functions, but I
don't know when this feature will be integrated.
Best regards,
Olaf
Terry wrote:
> Hi,
>
> I am experimenting ac++ (version 1.0pre3) with ACDT in eclipse. I
> declared my aspect as following, however, the advice on the pointcut
> doesn't seem to work at all. Any clue to solve the problem is appreciated.
>
> ** aspect:
> #include <iostream>
> using namespace std;
> aspect myAspect {
> pointcut locked () = execution ("% ...::operator new(...)") ||
> execution ("% ...::operator new[](...)") ||
> execution ("% ...::operator delete(...)") ||
> execution ("% ...::operator delete[](...)");
>
> advice locked () : after ()
> {
> cout << "new or delete operator executed" << endl;
> }
> };
>
> ** c++ code
> #include <iostream>
> #include <stdlib.h>
> #include <cmath>
>
> using namespace std;
>
> class A {};
>
> int main () {
>
> int* pInt = new int;
> A* pA = new A;
>
> delete pInt;
> pInt = 0;
> delete pA;
> pA = 0;
>
> return 0;
> }
>
> Thanks!
>
> Terry
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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