[aspectc-user] Can "tjp" be used in advice "construction" ?

Olaf Spinczyk os at aspectc.org
Tue Apr 28 14:55:13 CEST 2009


Dear Feng Liu,

you can use tjp in advice for construction join points. I think your 
problems are related to minor syntactic issues: You forgot semi colons 
after the definition of class A and after the aspect. Here is some code, 
which I tried successfully:

-----
#include <stdio.h>

struct B {
  void method1(int) { printf ("in B::method1()\n"); }
};

struct C {
  int variable1;
};

class A {
 
  class B  *c_b;
  class C  *c_c;

public:
  A() {
    c_b= new B();
    c_c= new C();
  }
};

aspect my_aspect {
  advice construction("A") : after() {
    tjp->that()->c_b->method1( tjp->that()->c_c->variable1);
  };
};

int main () { A a; return 0; }
---

It was directly derived from your code, which was incomplete. This is 
the result:

os at ios:~/ac-liu$ ~/ac-1.0pre3/ag++ -k -o t t.cc
os at ios:~/ac-liu$ ./t
in B::method1()

I hope that you can fix the problem if you use my code as an example.

Best regards,

Olaf


feng liu wrote:
>  
> I have the following class A :
>  
>  class A {
>  
>     class B  *c_b; 
>     class C  *c_c;
>  
>     A() {
>  
>       c_b= new B();
>       c_c= new C();
>  
>      }
>  
> }
>
> And then, I defined an aspect as following:
>  
> aspect my_aspect {
>  
> advice construction("A"):after(){
>  
> tjp->that()->c_b->method1( tjp->that()->c_c->variable1);
>  
> };
>  
> }
>  
> there is an error.  So, maybe I can't use "tjp" in advice "construction" ?
>  
> but if I want to call a method of c_b using the variables fo c_c when 
> constructing the class A. And I want to do this job using aspect. What 
> should i do?
>
> -- 
> Best regards,
> Feng Liu
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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