[aspectc-user] Defining an Aspect Instantiation Model with ac++1.0

Dimple dkaul at isis.vanderbilt.edu
Wed Nov 9 07:19:38 CET 2005


Hi Olaf,
I have read your AspectC++ 2005 tutorial slides and 
I have been trying to implement aspects for the attached example program.
Based on your example code 
aspect AlwaysDoThirdBeforeSecond {
   advice execution("void C1::second()") : before () {
     tjp->that ()->third ();
   }
};
I tried all different types advices.
However, in this scenario I wanted to call child class instead of parent
class. I am not sure if this is possible in AspectC++.
I also tried using Ordering of aspects and using around for parent but that
is also not working.

Plz see enclosed example code.
Thanks,
Dimple


-----Original Message-----
From: Olaf Spinczyk [mailto:Olaf.Spinczyk at informatik.uni-erlangen.de] 
Sent: Friday, November 04, 2005 2:26 AM
To: dkaul at isis.vanderbilt.edu
Subject: Re: [aspectc-user] Defining an Aspect Instantiation Model with
ac++1.0

Hi,

you could use the following aspect:

aspect DoThirdBeforeSecondInMain {
   advice call("void C1::second()") && within("int main()") : before () {
     tjp->target ()->third ();
   }
};

It matches all calls to second that are located within main.

If you *always* want third to be executed before second, you could also use:

aspect AlwaysDoThirdBeforeSecond {
   advice execution("void C1::second()") : before () {
     tjp->that ()->third ();
   }
};

This one call third before every execution of second.

I hope this helps. Did you already read out AOSD 2005 tutorial slides? 
They contain a step-by-step introduction into the pointcut language.

Olaf

PS: You've sent your mail to (CC:) "aspectc-user-bounces at aspectc.org". 
This is probably not what you wanted. The mailing list is 
aspectc-user at aspectc.org.


Dimple wrote:
> Hi Olaf,
> I was trying out one example code
> 
> #include <stdio.h>
> 
> // ------------------------------- normal C++ ----------------------------
> class C1 {
> public:
>   void first()  { printf("First\n"); }
>   void second() { printf("Second\n"); }
>   void third() { printf("Third\n"); }
> };
> 
> int main () {
>   C1 c1;
> 
>   c1.first();
>  
>
printf("**************************************************************\n\n")
> ;
>   c1.second();
> }
> 
> 
> I wanted to figure out how I can do this in aspectc++
> What I want is I want to run c1.first() normally, then I want to call
> c1.third() before c1.second(). 
> Means to say that I want to insert c1.third() method between c1.first()
and
> c1.second().
> I checked all the examples given in aspectC++ but could not figure out how
> to do it.
> 
> Thanks in advance,
> Dimple
> 
> 
> 
> -----Original Message-----
> From: aspectc-user-bounces at aspectc.org
> [mailto:aspectc-user-bounces at aspectc.org] On Behalf Of Olaf Spinczyk
> Sent: Wednesday, November 02, 2005 9:41 AM
> To: Sergio Queiroz
> Cc: aspectc-user at aspectc.org
> Subject: Re: [aspectc-user] Defining an Aspect Instantiation Model with
> ac++1.0
> 
> Hi,
> 
> the bug has number 267 in bugzilla and I've just fixed it.
> 
> Thanks again for reporting this problem!
> 
> Olaf
> 
> 
> Olaf Spinczyk wrote:
>>Hi Sergio,
>>
>>I tried to compile your example and got the following error message:
>>
>><ac>: In member function `void 
>>TJP__ZN6DCache16page_replacementEv_0::proceed()
>>   ':
>><ac>:26: error: `_that' undeclared (first use this function)
>>
>>Did you mean this problem? It seems to be a code generation bug :-(. The 
>>member _that is referenced but not generated.
>>
>>As a workaround (until 1.0pre2) you can add the following line to your 
>>execution/around advice:
>>
>>if (0) tjp->proceed()
>>
>>After adding this line I was able to compile your example.
>>
>>-Olaf
>>
>>
>>Sergio Queiroz wrote:
>>>Hi!
>>>
>>>I downloaded the new AspectC++ version and I was trying to compile 
>>>some code
>>>that worked pretty nice with version 0.92.
>>>
>>>The problem is that ac++ 1.0 could not compile my examples :(
>>>
>>>I tried to reduce the source code and I am sending my files, some problem
>>>occurred during parsing. I am using linux.
>>>
>>>This is the output of the command "g++ -v":
>>>
>>>Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs
>>>Configured with: ../src/configure -v
>>>--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
>>>--mandir=/usr/share/man --infodir=/usr/share/info
>>>--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared 
>>>--with-system-zlib
>>>--enable-nls --without-included-gettext --enable-__cxa_atexit
>>>--enable-clocale=gnu --enable-debug --enable-java-gc=boehm
>>>--enable-java-awt=xlib --enable-objc-gc i486-linux
>>>Thread model: posix
>>>gcc version 3.3.5 (Debian 1:3.3.5-8)
>>>
>>>
>>>
>>>Sérgio
>>>
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>#include "DCache.h"
>>>
>>>void DCache::doit()
>>>{
>>>    total_cycles++;
>>>    
>>>}
>>>
>>>void DCache::reset()
>>>{        total_cycles = 0;
>>>}
>>>
>>>
>>>int DCache::page_replacement()
>>>{
>>>    return 0;
>>>}
>>>
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>#ifndef DCACHE_H
>>>#define DCACHE_H
>>>
>>>#include "systemc.h"
>>>#include <iostream.h>
>>>
>>>SC_MODULE (DCache)
>>>{
>>>   sc_in<bool> clock;
>>>      void doit();
>>>   void reset();
>>>   int page_replacement();
>>>      float total_cycles;
>>>          SC_CTOR(DCache)
>>>     {
>>>         reset();
>>>                  SC_METHOD(doit);
>>>         sensitive_pos << clock;
>>>     }
>>>};
>>>
>>>#endif
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>#include "DCache.h"
>>>
>>>int
>>>sc_main (int argc, char **argv) {
>>>    sc_signal <bool> clock;
>>>    
>>>    DCache dcache ("dcache");
>>>    dcache.clock (clock);
>>>    
>>>    int i = 0;
>>>
>>>    sc_initialize ();
>>>    
>>>    while (i++ < 10) {
>>>        clock.write (0);
>>>
>>>        cout << dcache.page_replacement () << endl;
>>>       
>>>        clock.write (1);
>>>    }
>>>    
>>>    return 0;
>>>}
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>aspectc-user mailing list
>>>aspectc-user at aspectc.org
>>>http://www.aspectc.org/mailman/listinfo/aspectc-user
>>_______________________________________________
>>aspectc-user mailing list
>>aspectc-user at aspectc.org
>>http://www.aspectc.org/mailman/listinfo/aspectc-user
> 
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
> 
> 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: main.cc
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20051109/c28dee19/attachment.ksh>


More information about the aspectc-user mailing list