Re: [abc-dev] Custom context exposure

From: Rodolfo Toledo <>
Date: Wed, 16 Apr 2008 23:33:04 -0400

Dear Eric,

Thanks for your reply! I will try to clarify myself and answer your

> I will attempt to answer your question, however I still have trouble
> understanding what the problem is.

Yes, sure. I have to admit that it was very late when I sent this mail
last night.

>> This is an example of this pointcut:
>> aspect XYZ{
>> double around(double x) : customPointcut(x){
>> ...
>> }
>> }
> So does this pointcut use x or does it bind x? I am confused. From
> this code I would assume that it binds x, just as this/target/args.

The customPointcut binds x. I just like this/target/args as you
correctly pointed out.

>> The code above should generate something like:
>> double d;
>> if(someCondition){
>> XYZ.aspectOf();
>> d = XYZ.inline$0$around$0(customParameter);
>> }
>> else{
>> ...
>> }
> Where does someCondition come from? Furthermore, what's
> customParameter? Where does this value come from? And am I right that
> d is actually x from above?

- someCondition is a method call associated to customPointcut that
restricts the execution of the advice.

- customParameter is a value associated to customPointcut. I
oversimplified the example but customPointcut can be parametrized and
depending on that parametrization, customParameter (that is also a
method call) is calculated.

- d is only the result of the around. This is the standard code
generated by abc for around advices.

>> Right now, I've implemented the conditional part of the pointcut. But I
>> can't get the customParameter generation to work (customParameter can be a
>> method invocation, so it is not already available as a local var).
> I still don't understand. What's customParameter? Can you give a 100%
> concrete example please?

Here you have a more detailed example. Although not concrete, I think
it should serve to clarify this.

aspect XYZ{
   double around(double x) : customPointcut(someIdentifier(x)){

This pointcut should produce two things when weaving:

- A restriction over the advice that depends on someIdentifier.
Something like ConditionClass.isActive("someIdentifier"). Very similar
to an If, but without creating an extra method. I have managed to do this.

- A bind for the x argument of the advice (also depending on
someIdentifier). Something like ValuesClass.getParam("someIdentifier").

>> I have
>> the following classes:
>> CustomPC_c (extends Pointcut_c)
>> --> CustomPCCondition (this works OK, including its residue)
>> --> CustomPCArgs
>> Instances of CustomPCCondition and CustomPCArgs are returned as a
>> conjunction using AndPointcut.construct by CustomPC_c.makeAIPointcut.
> I am not sure whether you need this. I think actually you want one
> single CustomPointcut class and just generate a special residue for
> it. (The residue itself can be constructed hierarchically, using
> AndResidue etc.).

OK, I did it this way just to separate both concerns. But I will try to
do it the way you say.

>> At this moment, I'm having problems trying to implement the matchesAt
>> method in CustomPCArgs as I don't really know how to implement the Residue
>> class I have to return.
> You should first make up your mind about:
> 1.) what to test on

This is working now. I have managed to add a custom method invocation
to the advice execution restriction.

> 2.) which advice variables should be bound to which values
> The rest is then relatively easy, as one can just combine IfResidues
> and Bind residues to achieve both, test and binding.

This is what I have not been able to do. In my initial implementation I
was using Bind to associate "x" to a local variable whose value is
"ValuesClass.getParam("someIdentifier")" but it didn't work. I think
the reason is that the this local variable is not being properly added.

So, I think that my problem reduces to: how to add a local variable
whose value is a method invocation and then bind it to an advice parameter?

(Maybe the step of using a local variable can be avoided but I don't know)

Best Regards,
Rodolfo Toledo.
Received on Thu Apr 17 2008 - 04:32:27 BST

This archive was generated by hypermail 2.2.0 : Wed Apr 30 2008 - 23:50:04 BST