[aspectc-user] a few problem or bug

Olaf Spinczyk os at aspectc.org
Tue Apr 26 18:33:08 CEST 2011


Hi!

I'll comment the three problems below ...

On 04/26/2011 03:18 PM, sh jalilian wrote:
> hi dear
> Recently I have reported a problem about args() and I test your 
> solution but yet there is some problems I want to report here:
> ------------------ main code -------------------------------
> void f1(int i, char *str) {}
> void main()
> {
> f1(1, "test");
> }
> ------------------ aspect code -------------------------------
> aspect A1{
> advice call("% f%(...)") : after() {
>   cout << "int value= " << *(int *)tjp->arg(0) << "char * string= " << 
> (char *)tjp->arg(1) << endl;
> }
> };
>  problem 1) -----------------
> arg(0) output is OK for int type but arg(1) does not work for "char *" 
> and
> -------------------------------------------------------------------

tjp->arg(1) points to a char* object. Therefore, it has to be casted to 
(char**). Then the pointer has to be dereferenced:

cout ... << *(char**)tjp->arg(1) ...

Alternatively, you could use the type-safe variant:

cout ... << *tjp->arg<1>() ...

> problem 2) ----------------------------------------------
> function args() can return arguments (you should specify all arguments 
> in args() ) but args() has problem when you want to use by "within" 
> statement:
> aspect A2{
> pointcut PC1 = call("%  f%(int i, char *s)") && !within("A2") && 
> args(i, s);
> advice PC1(i, s) : after(int i, char *s) {
> cout <<  "func call" << endl;
> f1(5, "test2");
> }
> }

Your aspect is syntactically wrong. Here is the corrected version:

aspect A2{
   pointcut PC1(int i, char *s) = call("%  f%(int, char *)") && 
!within("A2") && args(i, s);
advice PC1(i, s) : after(int i, char *s) {
cout <<  "func call" << endl;
f1(5, "test2");
}
};

I tried it and it works as expected.

> ----------------------------------------------------------------------------
> problem 3) a general bug in Aspectc is that it is not capture 
> joinpoints such as "unsigned char" objects.

What does that mean? Could you give me a concrete example? "unsigned 
char objects" are no joinpoints in the AspectC++ joinpoint model.

Best regards,

Olaf

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20110426/57907bf1/attachment.html>


More information about the aspectc-user mailing list