[aspectc-user] help: how can I modify the result returned from a function/method
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Fri Jun 18 11:52:02 CEST 2004
Hi Paolo,
Paolo Calafiura schrieb:
> 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...
>
> Thanks for any suggestion
After calling lessThan() indirectly with tjp->proceed() you can read
*and modify* the result value. "tjp->result()" gives you a pointer to
the returned object. It is not a "read-only" handle. You change modify
the result value for example with "*tjp->result() = false;".
Olaf
More information about the aspectc-user
mailing list