[aspectc-user] argument capturing

Fabian Scheler Fabian.Scheler at gmx.de
Wed May 11 09:06:24 CEST 2005


Hi,

> advice execution("int A::a(...)") : around() {
>     cout << "arg1 : " << *static_cast<int*>(tjp->arg(0)) << endl;
>     cout << "arg2 : " << *static_cast<float*>(tjp->arg(1)) << endl;
> }
>
> should do the trick...
> If you don't cast you get a 'dereferencing pointer to void' error.

yep, I didn't check it, but this should work. A cleaner solution might look
like

advice execution("int A::a(...)") && args(i,b) : around(int i,float b) {
  cout << "arg1: " << i << endl;
  cout << "arg2: " << b << endl;
}

but as far as I can remember this way you are not able to manipulate your
values, another possiblity might look like:

advice execution("int A::a(...)") : around() {
  cout << "arg1: " << *tjp->arg<0>() << endl;
  cout << "arg2: " << *tjp->arg<1>() << endl;
}

the only difference to the solution proposed by Hans is that you don't have
to do the cast by yourself as this is already done within the template
method. Here also a manipulation of your parameters is possible.

Ciao, Fabian


-- 
+++ Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS +++
GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail



More information about the aspectc-user mailing list