[aspectc-user] (no subject)
Olaf Spinczyk
olaf at ivs.cs.uni-magdeburg.de
Thu May 30 13:38:40 CEST 2002
Hi,
On Thursday, 30. May 2002 13:18, you wrote:
> Hello !
>
> I am a new user of aspectc, but I know a little bit
> aspectj.
>
> I would like to know if it is possible to have the
> returned value of a proceed() inside an around advice.
> To be clear, why this is not correct :
>
>
> aspect TraceAllFunctions {
>
> pointcut FctCalls() = call("ReturnError
> RepositoryContext::%()");
>
> advice FctCalls() : ReturnError around() {
>
> ReturnError
> theError=thisJoinPoint->action().trigger();
> if (theError != rcNoError) {
> //log the error
> cout<<"Error ! "<<theError<<endl;
> }else {
> cout<<"NoError !"<<endl;
> }
>
> return theError;
> }
> };
>
> Thanks,
> Florin Cremenescu
This scheme doesn't work if the pointcut used for the around advice contains
join points (functions) with different result types. We therefore define
around advice like this:
advice FctCalls() : around() { ... }
The trigger() method does not return a value, but you can get the result
value of the triggered function call/execution with
"thisJoinPoint->result()". This is a pointer (void*) to the object that was
calculated in trigger() and that will be returned, when the end of the around
advice is reached. If you know the result type you can directly cast the
pointer to a pointer to that type and read or manipulate the value by
dereferencing. If you have no information about the type you can interpret
the typecode by using thisJoinPoint->resulttype ().
I hope that helps,
Olaf
More information about the aspectc-user
mailing list