[aspectc-user] context of a cflow pointcut?

Daniel Lohmann daniel.lohmann at informatik.uni-erlangen.de
Mon Feb 19 10:06:00 CET 2007


Hi Panu,

advice call("void A::target()") && cflow(execution("void B::wrapper()"))
: around()
{
tjp->that()->id(); // This causes trouble!
std::cout<<"Success!\n";
tjp->proceed();
}

You probably want to write tjp->target()->id();

In call advice, tjp->that() gives the pointer to the caller's instance,
which does not exist in this case.


Daniel


Panu Bloigu wrote:
> Hello again.
> 
> I'm not sure if the things I'm going to present indicate a bug in the
> weaver or just plain misunderstanding from my side, but could you please
> take the time to look at it and comment? The problem is that there seems
> to be something weird with the execution context of a cflow pointcut.
> This is best explained with code, so please consider the following file.
> I'm sorry, it's a bit lengthy.
> 
> ================================================================
> #include <iostream>
> class A
> {
> public:
> A(){}
> virtual ~A(){}
> void id()
> {
> std::cout<<"ClassA";
> }
> void target()
> {
> std::cout<<"A::target() executing!\n";
> }
> };
> 
> class B
> {
> public:
> B(){}
> virtual ~B(){}
> void id()
> {
> std::cout<<"ClassB";
> }
> void wrapper()
> {
> std::cout<<"B::wrapper() executing!\n";
> }
> };
> 
> aspect Test
> {
> advice call("void A::target()") && cflow(execution("void B::wrapper()"))
> : around()
> {
> tjp->that()->id(); // This causes trouble!
> std::cout<<"Success!\n";
> tjp->proceed();
> }
> 
> advice execution("void B::wrapper()") : before()
> {
> A a;
> a.target();
> }
> };
> 
> 
> int main()
> {
> B b;
> std::cout<<"Calling B::wrapper...\n";
> b.wrapper();
> A a;
> std::cout<<"\n\nCalling A::target() directly...\n";
> a.target();
> return 0;
> }
> ================================================================
> 
> After issuing the command:
> 
> ag++ -k --keep_acc cflow.cpp -o cflow
> 
> the compiler gives me the following:
> 
> ================================================================
> cflow.cpp: In member function ‘void Test::__a0_around(JoinPoint*) [with
> JoinPoint = Test::TJP__ZN4Test11__a1_beforeEv_0_0]’:
> cflow.acc:247: instantiated from ‘void
> AC::invoke_Test_Test_a0_around(JoinPoint*) [with JoinPoint =
> Test::TJP__ZN4Test11__a1_beforeEv_0_0]’
> cflow.acc:216: instantiated from here
> cflow.cpp:36: error: ‘class Test’ has no member named ‘id’
> cflow.cpp: In member function ‘void Test::__a0_around(JoinPoint*) [with
> JoinPoint = TJP__ZN4mainEv_1_0]’:
> cflow.acc:247: instantiated from ‘void
> AC::invoke_Test_Test_a0_around(JoinPoint*) [with JoinPoint =
> TJP__ZN4mainEv_1_0]’
> cflow.acc:298: instantiated from here
> cflow.cpp:36: error: ‘void*’ is not a pointer-to-object type
> error: Execution failed: "g++" -xc++ "cflow.acc" -xnone -I"." -o "cflow"
> ================================================================
> 
> So, to me it seems like the context of executing an advice with cflow
> pointcut, is the context of the aspect! What I'm asking is that whether
> this is the correct behavior or a bug? If this is indeed the way it's
> supposed to work, then could someone please explain a little, what's
> behind the implementation of this.
> 
> Thanks,
> 
> 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