[aspectc-user] reset tjp->that()?

Panu Bloigu panu.bloigu at mbnet.fi
Fri Dec 8 08:22:06 CET 2006


> I'd like to ask, if it is possible to reset the pointer tjp->that() of

Well, AFAIK, no. tjp->that() gives you a pointer to what ever 'this' points
in the join point and you can not go about assigning to 'this'.

> say i have an object pointer, after i use it, i release it, and i wnat to
> set it as NULL with AOP.

To my knowledge there's nothing stopping you from doing that. However,
tjp->that() is not what you want.

> //the C++ code
> ClassA *p = new ClassA();
> p->DoSomething();
> p->Release();
> //now i want to set p=NULL with AOP
> //the AOP Code:
> advice call("% ...::Release()"):after(){
>   tjp->that()=NULL;
> }

Here tjp->that() gives you what ever 'this' points to at the join point.
After the weave your code would be in effect the following (the actual code
given to C++ compiler is much more complicated, but this is how it's
semantics are):

ClassA *p = new ClassA();

This can not work. However, you can get 'p' by doing tjp->that()->p. To my
knowledge there's one requirement for this to work, though. Your 'p' can not
be a function/method local variable. If it is, then I do not know how to
access it from advice code. I hope this helps. What I've written here is
something that I *think* is correct, but I'm still learning AspectC++
myself, so don't be surprised if you get different (presumably, more
correct) answers.


More information about the aspectc-user mailing list