Scheme | Example | Kind of Release/Meaning |
<version>.<release> | 0.7 | A regular release 0.7. |
<version>.<release>.<fix-no> | 0.7.3 | Bug fix release number 3 of 0.7 |
<version>.<release>pre<no> | 0.8pre1 | Pre-Release number 1 for 0.8 |
Option | WPT | STU | Description
|
-p|--path <arg> | X | X | Defines a project directory
|
-e|--extension <arg> | X | – | Filename extension of translation units
|
-v|--verbose <arg> | X | X | Level of verbosity (0-9)
|
-c|--compile <arg> | – | X | Name of the input file
|
-o|--output <arg> | – | X | Name of the output file
|
-g|--generate | – | X | Generate link-once code
|
-i|--include_files | – | X | Generate manipulated header files
|
-a|--aspect_header <arg> | X | X | Name of aspect header file or 0
|
-r|--repository <arg> | X | X | Name of the project repository
|
-x|--expr <arg> | – | – | Match a pointcut expression (arg) agaist the project repository
|
--config <arg> | X | X | Parser configuration file
|
-k|--keywords | X | X | Allow AspectC++ keywords in normal project files
|
--introduction_depth <arg> | X | X | Set the maximum depth for nested introductions
|
--no_line | X | X | Disable generation of #line directives
|
--gen_size_type <arg> | X | X | use a specific string as size_t
|
--warn... | X | X | enable a weaver warning that is suppressed by default
|
--no_warn... | X | X | suppress a specific weaver warning
|
--problem... | X | X | enable back-end compiler problem workaround (see 4.2)
|
--no_problem... | X | X | disable back-end compiler problem workaround
|
--builtin_operators | X | X | Support advice on built-in operator calls
|
--data_joinpoints | X | X | Support data-based join points, e.g. get(), set(), ...
|
--attributes | X | X | Support C++11-attribute-based join points
|
--no_attributes | X | X | Disable support user-defined attributes
|
-I <arg> | X | X | Include file search path
|
-D <name>[=<value>] | X | X | Macro definitions
|
-U <name> | X | X | Undefine a macro
|
--include <arg> | X | X | Forced include
|
prompt> ac++ -x ’"%::%"’ -r PragmaOnceObserver/repo.acp ObserverPattern.ah:12: Class "ObserverPattern::Subject" ObserverPattern.ah:13: Class "ObserverPattern::Observer"
prompt> ac++ -x ’call("%") && within("% main()")’ -r ... main.cc:29: Call "void ObserverPattern::addObserver( ... main.cc:32: Call "void ObserverPattern::addObserver( ... main.cc:34: Call "void ClockTimer::Tick()" main.cc:37: Call "void ClockTimer::Tick()"
namespace AC { ... #Typedefs, Templates & Functions usable by Aspects ... }
// commented out by ac++: #include "hello.h" #line 1 "example/hello.h" #ifndef __HELLO_H__ #define __HELLO_H__ #include <iostream> void hello(){ std::cout << "Hello" << std::endl; } #endif #line 94 "example/main.cc" int main(){ hello(); //print "Hello" return 0; }
#line 1 "example/hello.h" #ifndef __HELLO_H__ #define __HELLO_H__ #include <iostream> void hello(){ std::cout << "Hello" << std::endl; } #endif
aspect World { advice execution("void hello()") : after() { //print "World" after execution of the ’hello()’ function std::cout << "World" << std::endl; } };
class World { public: void __a0_after() { std::cout << "World" << std::endl; } ... }
public: static World *aspectof () { static World __instance; return &__instance; } static World *aspectOf () { return aspectof (); }
namespace AC { __attribute((always_inline)) inline void invoke_World_World__a0_after () { ::World::aspectof()->__a0_after (); } }
aspect World { advice execution("void hello()") : after() { //print "World" after execution of ’void hello()’ std::cout << "World" << std::endl; } };
void hello(){ std::cout << "Hello" << std::endl; } int main(){ hello(); return 0; }
class World{ public: void __a0_after() { std::cout << "World" << std::endl; } }; inline void __exec_old_hello(){ std::cout << "Hello" << std::endl; } void hello(){ ::__exec_old_hello(); // print “Hello” AC::invoke_World_World__a0_after (); // print “World” } int main(){ hello(); return 0; }
aspect Hello { advice call("void world()") : before() { // print “Hello” before void world() is called std::cout << "Hello" << std::endl; } };
void world(){ std::cout << "World" << std::endl; } int main(){ world(); return 0; }
class Hello{ public: void __a0_before() { std::cout << "Hello" << std::endl; } }; void world(){ std::cout << "World" << std::endl; } inline void __Call__Z4mainv_0_0 (){ AC::invoke_Hello_Hello__a0_before (); // print “Hello” ::world(); // print “World” } int main(){ __Call__Z4mainv_0_0 ( ); return 0; }
aspect Hello { advice construction("World") : after() { std::cout << "- Hello World" << std::endl; } // printed when World instance is constructed };
class World{ // Class with simple constructor public: World(){std::cout << “New World created”;} }; int main(){ World A = World(); //Construct “World” instance return 0; }
class Hello{ public: void __a0_after() { std::cout << "- Hello World" << std::endl; } }; class World{ public: World(){ this->__exec_old_C1(); // Call old constructor AC::invoke_Hello_Hello__a0_after (); // Call advice } inline void __exec_old_C1(){std::cout << “New World created”;} }; int main(){ World A = World(); // Construct temporary World instance return 0; }
aspect Goodbye { advice destruction("World") : after() { //print "Goodbye World" after destructing a World instance std::cout << "- Goodbye World" << std::endl; } };
class World{ public: ~World(){std::cout << “Cleanup”;} // Example destructor }; int main(){ World A = World(); // World instance return 0; }
class Goodbye{ public: void __a0_after() { std::cout << "- Goodbye World" << std::endl; } }; class World{ public: inline ~World () { this->__exec_old_D1(); // Call old destructor AC::invoke_Goodbye_Goodbye__a0_after (); // Call advice } // Old destructor inline void __exec_old_D1(){std::cout << “Cleanup”;} }; int main(){ World A = World(); // World instance return 0; } // World gets destructed at end of main
aspect Example { advice "Laptop": slice class SL { // Add to Laptop private: int ram; public: int get_ram(){return ram;} }; advice "Laptop": slice class : public ShopItem{}; // Add base class };
class ShopItem{int price;}; class Laptop{int threads;}; int main(){ Laptop abc = Laptop(); return 0; }
// Aspect class empty besides default content (aspectof getter) class Example {}; class ShopItem{int price;}; // New base class, new variable, new getter class Laptop: public ShopItem{ private: int threads; private: typedef Laptop SL; // Typedef for slice name SL private : int ram ; public : int get_ram ( ) { return ram ; } }; int main(){ Laptop abc = Laptop(); return 0; }
aspect Hello { advice get("char %") : before() { //print "Hello World" before a char is get std::cout << "Hello World"; } };
char exclamation = ’!’; int main(){ // get and print exclamation mark std::cout << exclamation << std::endl; return 0; }
class Hello { public: inline void __a0_before() { std::cout << "Hello World"; } }; char exclamation = ’!’; template <typename TResult, typename TEntity> inline TResult __Get__Z4mainv_0_0 (TEntity &ent, AC::RT<TResult>) { TResult __result_buffer; AC::invoke_Hello_Hello__a0_before (); //print Hello World __result_buffer = ::exclamation; return (TResult &)__result_buffer; } int main(){ std::cout << __Get__Z4mainv_0_0< > (exclamation, __AC_TYPEOF((exclamation)) ) << std::endl; return 0; }
aspect Hello { advice ref("char %") : before() { std::cout << "Hello World"; } //print "Hello World" before a char is referenced };
char exclamation = ’!’; int main(){ char * exclamation_mark = &exclamation; std::cout << *exclamation_mark << std::endl; return 0; }
class Hello { public: inline void __a0_before() { std::cout << "Hello World"; } }; template <typename TResult, typename TEntity> inline TResult __Ref__Z4mainv_1_0 (TEntity &ent, AC::RT<TResult>) { TResult __result_buffer; AC::invoke_Hello_Hello__a0_before (); // call advice __result_buffer = &( ::exclamation ); // buffers reference return (TResult &)__result_buffer; // returns buffered reference } char exclamation = ’!’; int main(){ char * exclamation_mark = __Ref__Z4mainv_1_0< > (exclamation, __AC_TYPEOF((&exclamation)) ); std::cout << *exclamation_mark << std::endl; return 0; }
aspect Example { advice set("int %") : after() { std::cout << "Finished" << std::endl; } //print "Finished" after setting an int };
int i; int main(){ i = 42; //setting int return 0; }
class Example { public: inline void __a0_after() { std::cout << "Finished" << std::endl; } }; template <typename TArg0, typename TEntity> inline void __Set__Z4mainv_1_0 (TEntity &ent, TArg0 arg0) { ::i = (arg0); // Setting value AC::invoke_Example_Example__a0_after (); // Calling advice } template <typename TArg0, typename TArg1, typename TResult> inline TResult &__Builtin__Z4mainv_0_0 (TArg0 arg0, TArg1 arg1, AC::RT<TResult>) { TResult *__result_buffer; __Set__Z4mainv_1_0< int > (arg0, arg1 ); // Calling set function __result_buffer = &arg0; return *(TResult *&)__result_buffer; } int i; int main(){ __Builtin__Z4mainv_0_0< int &, int > (i , 42, __AC_TYPEOF((i = 42)) ); return 0; }
aspect Example { advice execution("void give_int(%)") : before() { std::cout << *tjp->arg<0>() << std::endl; } //print first parameter of give_int() };
void give_int(int i){ std::cout << "Got the Int!" << std::endl; } int main(){ give_int(42); return 0; }
class Example { public: template <typename JoinPoint> void __a0_before(JoinPoint *tjp) { std::cout << *tjp->template arg<0>() << std::endl; } }; namespace AC { // different invoke function passing JoinPoint Type template <class JoinPoint> __attribute((always_inline)) inline void invoke_Example_Example__a0_before (JoinPoint *tjp) { ::Example::aspectof()->__a0_before (tjp); } } inline void __exec_old_give_int(int i){ std::cout << "Got the Int!" << std::endl; } void give_int(int i) { typedef TJP__Z8give_inti_0< void, void, void, void (int), AC::TL< int, AC::TLE > > __TJP; __TJP tjp; tjp._args[0] = (void*)&i; AC::invoke_Example_Example__a0_before<__TJP> (&tjp); ::__exec_old_give_int(i); } int main(){ give_int(42); return 0; }
aspect Example { advice execution("void give_int(%)") && args(wert) : before(int wert) { std::cout << wert << std::endl; } };
void give_int(int i){ std::cout << "Got the Int!" << std::endl; } int main(){ give_int(42); return 0; }
class Example{ public: void __a0_before(int wert) { std::cout << wert << std::endl; } }; // Invoke function typecasting JoinPoint to advice parameter namespace AC { template <class JoinPoint> __attribute((always_inline)) inline void invoke_Example_Example__a0_before (JoinPoint *tjp) { typedef typename JoinPoint::Binding_Example_Example\ __a0_before::template Arg<0> Arg0; ::Example::aspectof()->__a0_before ((int)Arg0::val (tjp)); } } inline void __exec_old_give_int(int i){ std::cout << "Got the Int!" << std::endl; } void give_int(int i){ // Wrapper function typedef TJP__Z8give_inti_0< void, void, void, void (int), AC::TL< int, AC::TLE > > __TJP; __TJP tjp; tjp._args[0] = (void*)&i; AC::invoke_Example_Example__a0_before<__TJP> (&tjp); // Advice ::__exec_old_give_int(i); // Calling old code } int main(){ give_int(42); return 0; }