[aspectc-user] calls to members through a pointer to member

Daniel Lohmann daniel.lohmann at informatik.uni-erlangen.de
Thu Nov 29 14:44:07 CET 2007


Hi Panu,

> It seems that ag++ currently can't trap calls to member methods if the 
> member is called through a pointer-to-member, e.g.:
> 
> 
> =============================================================
> void (Base::* ptr_to_member)() = &Base::some_method;
> Base b;
> (b.*ptr_to_member)(); // Trap this call...
> 
> // with this advice:
> advice call("void Base::some_method()") : before(){/* ... */}
> =============================================================
> 
> Same seems to go for function calls occurring through a 
> pointer-to-function.
> 
> Is this correct, or do I need to use some special match expression in 
> the call() join point function argument to trap function/method calls 
> occurring through a pointer-to-function/pointer-to-member?

This is correct, ac++ does not support matching calls via function pointers.

> If this indeed is possible, and I'm doing something wrong, it would be 
> interesting to hear how this feature is implemented. As far as I can 
> see, weaver has to somehow gain awareness of the actual value (the 
> pointed-to function/method) of a pointer-to-function/pointer-to-member 
> to be able to tell the target of the call.

Right, and this is the main reason ac++ we hesitate to support this. It 
could lead to significant extra runtime costs, which is somewhat against 
the AspectC++ philosophy.

Daniel




More information about the aspectc-user mailing list