[aspectc-user] context of a cflow pointcut?

Panu Bloigu panu.bloigu at mbnet.fi
Mon Feb 19 10:49:38 CET 2007


Hello Daniel,

thanks for taking the time to answer this. Could you please explain why 
the caller it self does not exist? Clearly there is an instance of B 
from which A::target() is called, isn't there? I'm inserting the call to 
the code of B::wrapper() with the execution pointcut, so I can't 
understand why there wouldn't be a pointer to an instance of B within 
B::wrapper().

There's more to it also. After replacing that() with target() the errors 
go away, but the pointcut is not matched! In other words, id() doesn't 
get called and the word "Success" doesn't get printed. What I can 
understand from the generated repository file, the pointcut is indeed 
recognized, but somehow the call inserted by the other advice doesn't 
seem to be considered to happen in the cflow of B::wrapper().

Could you please help me to understand what's going on here?

Thanks,

Panu.

================================================================






Daniel Lohmann wrote:
> 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
>>     
>
>
>
> _______________________________________________
> 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