[aspectc-user] context of a cflow pointcut?

Panu Bloigu panu.bloigu at mbnet.fi
Mon Feb 19 09:37:36 CET 2007


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.













More information about the aspectc-user mailing list