[aspectc-user] Aspects advicing aspects

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Wed Jan 3 12:26:14 CET 2007


Hi,

your code perfectly valid AspectC++, but the ac++ compiler generates
incorrect code in this case. It is a known bug (#263). :-(

As a workaround you could move the f() call into a helper member
function of the aspect:

aspect Base
{
  void helper () { f(); }
  advice execution("int main()") : around()
  {
    helper();
    tjp->proceed();
  }
  advice call("void f()") : around()
  {
    std::cout<<"Before f()\n";
    tjp->proceed();
    std::cout<<"After f()\n";
  }
};

==>

Before f()
f()
After f()

I'm sorry, it is an ugly solution, but the best we have at the moment.
We will fix this bug as soon as possible.

Best regards,

Olaf


Panu Bloigu wrote:
> Hello.
> 
> My question concerns aspects "accidentally" advicing each others code. Or
> more specifically, aspects advicing other aspects' advices. To make any
> sense of this, please consider the following three files:
> 
> ===================
> File 1: main.cpp
> ===================
> int main()
> {
> 	return 0;
> }
> ===================
> File 2: Base.ah
> ===================
> #ifndef BASE_AH_
> #define BASE_AH_
> #include <iostream>
> #include "functions.h"
> aspect Base
> {
> 	advice execution("int main()") : around()
> 	{
> 		f();
> 		tjp->proceed();
> 	}
> 	advice call("void f()") : around()
> 	{
> 		std::cout<<"Before f()\n";
> 		tjp->proceed();
> 		std::cout<<"After f()\n";
> 	}
> };
> #endif /*BASE_AH_*/
> ===================
> File 3: Functions.h
> ===================
> #ifndef FUNCTIONS_H_
> #define FUNCTIONS_H_
> #include <iostream>
> void f()
> {
> 	std::cout<<"f()\n";
> }
> #endif /*FUNCTIONS_H_*/
> ===================
> 
> 
> Now the compiler presents me with plethora of errors. My question is twofold:
> 
> 1) Is there something (semantically if not even syntactically) wrong with my
> code or is the above presented construction illegal in AspectC++?
> 
> 2) If it is illegal, then what should I do if I need to add a call to f()
> before main() executes and at the same time want to decorate all calls to
> f() with an around advice (f() is called from other places in my program
> too)?
> 
> Panu.
> 
> 
> _______________________________________________
> 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