[aspectc-user] Using aspects on template classes

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Fri Mar 10 10:35:11 CET 2006


Hi Frederic,

I'm sorry, but template support in the weaver ist still incomplete. This 
means that the weaver can't transform templates or template instances. 
The --real-instances option is only relevant for the parser, which then 
performs a more sophisticated template analysis, but it doesn't make the 
weaver itself any better :-(.

The only template-related weaving, which should already work, affects 
*calls* to template methods if the call is not located within a template.

Best regards,

Olaf

Frederic Saunier wrote:
> Hi,
> 
> When trying using aspects on template classes, I got troubles:
> - to match the methods of template class as pointcuts.
> Do I need to specific a wildcard or anything else to match the template
> parameters ? Can I eventually do it ?
> - to match constructor of template class: "ac++ -v 9 --real-instances"
> identifies the constrcutor as a joint point but ends up with a segment
> violation
> 
> Here is a short sample that reproduces the behavior. Any hints ?
> 
> Best regards,
> -- Frederic
> 
> ---- Aspect.ah ----
> 
> #ifndef __SIMPLE_ASPECT__
> #define __SIMPLE_ASPECT__
> 
> #include <iostream>
> 
> aspect Tracer {
> 
>  pointcut methods()   = execution("% ...::container(...)");
>  pointcut instances() = construction("container") || destruction("container");
> 
>  advice methods() : before() {
>      std::cout << "Entering> " << JoinPoint::signature() << std::endl;
>  }
>  advice methods() : after() {
>      std::cout << "<Exitting " << JoinPoint::signature() << std::endl;
>  }
> 
>  advice instances() : before() {
>      std::cout << "CTOR" << std::endl;
>  }
>  advice instances() : after() {
>      std::cout << "DTOR" << std::endl;
>  }
> 
> };
> 
> #endif // __SIMPLE_ASPECT__
> // EOF
> 
> ---- sample.cpp ----
> 
> #include <iostream>
> 
> template <typename INDEX, typename DATA>
> class container {
> 
> public:
>     container(unsigned int size);
>     ~container();
> 
>     void put(INDEX at, DATA value);
>     DATA get(INDEX at);
> };
> 
> template <typename INDEX, typename DATA>
> container<INDEX,DATA>::container(unsigned int size) {
>    std::cout << "In Constructor" << std::endl;
> }
> 
> template <typename INDEX, typename DATA>
> container<INDEX,DATA>::~container() {
>    std::cout << "In Destructor" << std::endl;
> }
> 
> template <typename INDEX, typename DATA>
> DATA
> container<INDEX,DATA>::get(INDEX at) {
>    std::cout << "In Get" << std::endl;
> }
> 
> template <typename INDEX, typename DATA>
> void
> container<INDEX,DATA>::put(INDEX at, DATA value) {
>    std::cout << "In Put" << std::endl;
> }
> 
> int main(int argc, char *argv[]) {
>    container<unsigned int,int> container_instance(0x1000);
> 
>    container<unsigned int,int> * aux_container_prt = new container<unsigned
> int,int> (0x100);
> }
> // EOF
> 
> --
> Open WebMail Project (http://openwebmail.org)
> 
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user




More information about the aspectc-user mailing list