[aspectc-user] matching string argument type

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Fri Apr 1 12:52:59 CEST 2005


Hi Pablo,

Pablo Casado wrote:
> Hi,
> 
> I'm trying to match a string argument as follows
> 
> aspect TestTrace3 : public Trace {
>  public:
>    pointcut methods() = call ("% Base::%(std::string)");
> };
> 
> but ac does not match with the following
> 
> class Derived : public Test
> {
>    void abar(std::string) {
>        printf("Derived::abar()\n");
>    }
> };
> 
> I also tried the the following patterns
> "% Base::%(string)"
> "% Base::%(...)"
> 
> regards
> Pablo.

first of all, you probably did not use AspectC++ in the "real-instances" 
mode. The problem is that string is a typedef for some 
std::basic_string<...>, i.e. a template class instance. In the default 
mode AspectC++ is currently not able to resolve any function calls that 
depend on template instantiation. However, the "real-instances" mode, 
which solves this problem already works quite well. It will become the 
default mode in the near future, but today you have to use an additional 
AspectC++ option. If you use ac++ you can either add --real-instances to 
the command line options or add --real-instances in the parser 
configuration file. Due to a bug in the latest ag++, the 
"real-instances" mode can only be used with ag++ if you use a parser 
configuration file with the --real-instances option. The ag++ command 
line does not support this option in this release.

The second problem is that currently match expressions match only 
classes and *not* typedefs for class. Therefore, you can't match 
"string". You would have to use "std::basic_string<...>".

The third problem is that even if you used the "real-instances" mode and 
the right match expression, it won't work, because the match expression 
parser crashes when it analyzes "std::..". I didn't have time to find 
this bug, yet :-(, but it can't be very complicated. Remember that 
template support is still experimental!

If you use the "real-instances" mode and match e.g. call("% ...::%(%)") 
(any function call with one argument) your call will be detected and 
advice will be woven.

-Olaf



More information about the aspectc-user mailing list