[aspectc-user] Access to vars in scope of calling function?

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Tue Nov 15 08:58:49 CET 2005


Hi John,

currently, execution advice for A() is the only solution to your 
problem. The feature that is missing here is the "cflow pointcut 
function with context variables" as it is implemented in AspectJ. The 
code *would* look like this:

advice call("% B()") && cflow(execution("% A(...)") && args(i)) :
before (int i) {
   cout << "B was called within the control flow of A." << endl;
   cout << "The argument of A was " << i << endl;
}

This feature is not implemented yet, but it is on the roadmap for 
version 1.0.

On the implementation level ac++ would, of course, also generate a 
wrapper function for A, but on the language level you could avoid a 
second advice.

Best regards,

Olaf


John C. Weicher wrote:
> I have the following simplified situation:
> 
> function A(){
> 
>    // blah blah blah
> 
>    B();
> 
>   // blah blah
> }
> 
> I am currently applying call/around advice to function B.  I would like 
> to have access to a variable that is an argument to A.  The problem is 
> that the functionality that I really want to wrap is only that of B’s, 
> so I’d rather not have to wrap A as well.  I don’t need to wrap any 
> functionality of A, I just need one of it’s args while I’m wrapping B.  
> Of course I could wrap A as well just to get access to variable to store 
> it globally or something, so that when calling around B I can still have 
> access to it that way, but that seems messy.
> 
> Is there another way to do this? 



More information about the aspectc-user mailing list