[aspectc-user] help: how can I modify the result returned from a function/method

Bartosz Blimke masb at chorwacja.com
Fri Jun 18 11:42:58 CEST 2004


> newbie question: I inserted a new data member into a Key class, and I
want to use the data member to redefine sorting based on this key. This
boils down to changing the return value of a method of this Key class
>  bool Key::lessThan(const Key& rhs) const;
> using the extra data member. I can insert a new method
>  bool Key::threadedLessThan(const Key& rhs) const;
> but I have found no way to replace all calls to lessThan with calls to
threadedLessThan. I can of course define an around advice for lessThan and
call threadedLessThan from inside there, but I don't see how to pass the
bool returned by threadedLessThan out to the caller of the original
lessThan.
>  Using either tjp->result() or the result context seems to give me
> read-only access to the result...

AFAIR I used tjp->result() to modify the memory with return value and that
worked. I dont have aspectc++ environment here to test it, but isn't such
a soution working ?:

advice execution("bool  Key::lessThan(...)") : around
{
   *(tjp->result()) =  threadedLessThan(...
}

Greets from ECOOP 2004, Oslo :)

Bartosz








More information about the aspectc-user mailing list