class Shape { /*...*/ }; void draw(Shape& shape) { /*...*/ } namespace Circle { typedef int PRECISION; class S_Circle : public Shape { PRECISION m_radius; public: void radius(PRECISION r) { m_radius = r; } ~S_Circle() { /*...*/ } }; void draw(PRECISION r) { S_Circle circle; circle.radius(r); draw(circle); } } int main() { Circle::draw(10); return 0; }
types: | |
Result | result type |
That | object type |
Target | target type |
AC::Type | encoded type of an object |
AC::JPType | join point types |
static methods: | |
int args() | number of arguments |
AC::Type type() | type of the function or attribute |
AC::Type argtype(int) | types of the arguments |
const char *signature() | signature of the function or variable |
unsigned id() | identification of the join point |
AC::Type resulttype() | result type |
AC::JPType jptype() | type of join point |
non-static methods: | |
void *arg(int) | actual argument |
Result *result() | result value |
That *that() | object referred to by this |
Target *target() | target object of a call |
void proceed() | execute join point code |
AC::Action &action() | Action structure |
static methods: | |
const char *signature() | signature of the function or member variable |
unsigned id() | identification of the join point |
AC::JPType jptype() | type of join point |
types: | |
Aspect | type of the aspect |
Token | only matches Token
|
% | matches any name
|
parse_% | matches any name beginning with parse_ like parse_declarator or parse_
|
parse_%_id% | matches names like parse_type_id, parse_private_identifier, etc.
|
%_token | matches all names that end with _token like start_token, end_token, and _token
|
...:: | matches any definition scope, even the global scope
|
Puma::CCParser:: | matches the scope Puma::CCParser exactly
|
...::%Compiler%:: | matches any class or namespace, which matches the name pattern %Compiler%, in any scope
|
Puma::...:: | matches any scope defined within the class or namespace Puma and Puma itself
|
% | matches any type
|
void (*)(%) | matches any pointer type that points to functions with a single argument and a void result type
|
%* | matches any pointer type
|
% | matches any type, even types qualified with const or volatile
|
const % | matches only types qualified by const
|
% (*)() const volatile | matches the type of all pointers to functions that are qualified by const and volatile
|
virtual % ...::%(...) | matches all virtual or pure virtual functions in any scope
|
% C::%(...) | matches all member functions of C, even if they are virtual
|
static % ...::%(...) | matches all static member and non-member functions in any scope
|
% C::%(...) | matches all member functions of C, even if they are static
|
after step one
|
result
|
|
Token | only matches namespaces or classes with the name Token that are directly inside the global namespace
|
|
...::Token | matches Token at arbitrary location
|
|
% | matches any namespace or class that is directly located in the global namespace but not the global namespace itself
|
matches any namespace except the global namespace, any class that is arbitrary nested in a non-global namespace, any class directly located in the global namespace and all functions, member functions, variables, data members, constructors and destructors that are contained in one of the just mentioned entities
|
:: | matches the global namespace
|
matches any function, variable, (nested) class, member function, data member, constructor or destructor
|
after step one
|
result
|
|
OOStuBS::CGA% | matches any namespace or class inside OOStuBS beginning with CGA like OOStuBS::CGA, OOStuBS::CGA_Screen or OOStuBS::CGA_Stream. Note that this matches OOStuBS only inside the global namespace.
|
|
%::Smtp%Bldr% | matches namespaces and classes like SmtpBldr, SmtpClientBldr or SmtpServerBldrCreator, that are nested in exact one namespace or class.
|
|
%Node | matches any namespace or class ending with Node like ModelNode, GraphNode and Node
|
operator % | matches any operator function name (as well as any conversion function name)
|
operator += | matches only the name of a += operator
|
operator %% | matches the name of an operator %
|
operator % | matches any conversion function name
|
operator int* | matches any name of a conversion that converts something into an int* object
|
operator %* | matches any conversion function name if that function converts something into a pointer
|
aspect BusIntSync { pointcut critical() = execution("% Bus::%(...)"); advice critical() && !cflow(execution("% os::int_handler()")) : around() { os::disable_ints(); tjp->proceed(); os::enable_ints(); } };
aspect Debug { pointcut fct() = "% MemPool::dealloc(void*)"; pointcut exec() = execution(fct()); pointcut calls() = call(fct()); advice exec() && args(ptr) : before(void *ptr) { assert(ptr && "argument is NULL"); } advice calls() : before() { assert(tjp->target() && "’this’ is NULL"); } };
aspect ProblemReporter { advice builtin("% operator *(%)") : before() { if(*tjp->arg<0>() == 0) { cerr << tjp->filename() << " (Line " << tjp->line() << "): dereferencing of null-pointer!" << endl; } } };
class ExampleClass { static const int const_member = 5 * 2; unsigned int bitfield : 4 / 2; }; const int const_two = 3 - 1; static char char_array[const_two + 5]; enum ExampleEnum { ENUM_VALUE = const_two + 1 }; switch(const int const_temp = 1) { case const_temp + 1: { // ... break; } }
advice builtin("% operator &&(bool, bool)") && args("%", b2) : before(bool b2) { // advice code }
operator and example | ++ | ||
---|---|---|---|
ternary | ?: | a?b:c | limitations due to short-circuit evaluation (see 4.5.1) |
unary | ++ | a++ | postfix operator (second argument of type ) |
unary | -- | a-- | postfix operator (second argument of type ) |
unary | ++ | ++a | prefix operator; not supported if is a bit-field |
unary | -- | --a | prefix operator; not supported if is a bit-field |
unary | & | &a | not supported if is a member |
unary | * | *a | |
unary | + | +a | |
unary | - | -a | |
unary | a | ||
unary | ! | !a | |
binary | .* | a.*b | not supported if is a member function pointer |
binary | ->* | a->*b | not supported if is a member function pointer |
binary | * | a*b | |
binary | / | a/b | |
binary | % | a%b | in match expressions: escape % with %% |
binary | + | a+b | |
binary | - | a-b | |
binary | << | a<<b | |
binary | >> | a>>b | |
binary | < | a<b | |
binary | > | a>b | |
binary | <= | a<=b | |
binary | >= | a>=b | |
binary | == | a==b | |
binary | != | a!=b | |
binary | & | a&b | |
binary | ‸ | a‸b | |
binary | | | a|b | |
binary | && | a&&b | limitations due to short-circuit evaluation (see 4.5.1) |
binary | || | a||b | limitations due to short-circuit evaluation (see 4.5.1) |
binary | = | a=b | copy-assignment not supported; |
not supported if is a bit-field | |||
binary | *= | a*=b | not supported if is a bit-field |
binary | /= | a/=b | not supported if is a bit-field |
binary | %= | a%=b | in match expressions: escape %= with %%=; |
not supported if is a bit-field | |||
binary | += | a+=b | not supported if is a bit-field |
binary | -= | a-=b | not supported if is a bit-field |
binary | <<= | a<<=b | not supported if is a bit-field |
binary | >>= | a>>=b | not supported if is a bit-field |
binary | &= | a&=b | not supported if is a bit-field |
binary | |= | a|=b | not supported if is a bit-field |
binary | ‸= | a‸=b | not supported if is a bit-field |
binary | [] | a[b] |
operator and example | ||||
---|---|---|---|---|
binary | , | a,b | ||
binary | -> | a->b | ||
binary | . | a.b | ||
new | delete | |||
delete | new[] | |||
new[] | delete[] | |||
delete[] | implicit conversions | |||
implicit conversions | ||||
operators in constant expressions (see 4.5.1) | ||||
operators with an anonymous/unnamed or local type (see 4.5.1) | ||||
operators that have a type with no linkage (see 4.5.1) |
aspect IntegerModification { advice set("int ...::%") : after() { cout << "Setting variable " << tjp->signature() << " to " << *tjp->entity() << endl; } };
Code-Element | Positions |
namespaces | namespace [[...]] myNamespace {} |
classes | class [[...]] myClass {}; |
functions | [[...]] void myFunc [[...]] (); |
variables | [[...]] int myVar [[...]]; |
statements | [[...]] i += 1; [[...]] { i--; } |
new
|
delete | delete[] | +
|
-
|
*
|
|||||||
+
|
-
|
*
|
/
|
%%
|
^
|
&
|
|
|
~
|
!
|
=
|
<
|
>
|
+=
|
-=
|
*=
|
/=
|
%%=
|
^=
|
&=
|
|=
|
<<
|
>>
|
>>=
|
<<=
|
==
|
!=
|
<=
|
>=
|
&&
|
||
|
++
|
--
|
,
|
.*
|
->*
|
->
|
()
|
[]
|
?:
|
<?xml version="1.0"?> <ac-model version="1.2" ids="7"> <files> <TUnit filename="shape.cpp" len="42" time="1442951698" id="0"/> </files> <root> <Namespace name="::"> <children> <Class name="Shape" id="1"> <children> <Function kind="8" cv_qualifiers="0" name="~Shape" builtin="true"> <children> <Destruction/> </children> </Function> <Function kind="7" cv_qualifiers="0" name="Shape" builtin="true"> <children> <Construction/> </children> </Function> <Function kind="7" cv_qualifiers="0" name="Shape" builtin="true"> <arg_types> <Type signature="const Shape &"/> </arg_types> <children> <Construction/> </children> </Function> </children> <source> <Source kind="1" file="0" line="1" len="1"/> <Source kind="2" file="0" line="1" len="1"/> </source> </Class> <Namespace name="Circle"> <children> <Class bases="1" name="S_Circle" id="4"> <children> <Function kind="7" cv_qualifiers="0" name="S_Circle" builtin="true"> <children> <Construction/> </children> </Function> <Function kind="7" cv_qualifiers="0" name="S_Circle" builtin="true"> <arg_types> <Type signature="const Circle::S_Circle &"/> </arg_types> <children> <Construction/> </children> </Function> <Variable kind="3" name="m_radius"> <type> <Type signature="int"/> </type> <source> <Source kind="1" file="0" line="8" len="1"/> </source> </Variable> <Function kind="3" cv_qualifiers="0" name="radius" id="3"> <result_type> <Type signature="void"/> </result_type> <arg_types> <Type signature="int"/> </arg_types> <children> <Execution/> <Builtin target="2" lid="0"> <source> <Source kind="0" file="0" line="11" len="1"/> </source> </Builtin> </children> <source> <Source kind="1" file="0" line="10" len="3"/> </source> </Function> <Function kind="8" cv_qualifiers="0" name="~S_Circle"> <children> <Destruction/> </children> <source> <Source kind="1" file="0" line="13" len="1"/> </source> </Function> </children> <source> <Source kind="1" file="0" line="7" len="8"/> <Source kind="2" file="0" line="7" len="1"/> </source> </Class> <Function kind="1" cv_qualifiers="0" name="draw" id="6"> <result_type> <Type signature="void"/> </result_type> <arg_types> <Type signature="int"/> </arg_types> <children> <Execution/> <Call target="3" lid="0" target_class="4"> <source> <Source kind="0" file="0" line="18" len="1"/> </source> </Call> <Call target="5" lid="1"> <source> <Source kind="0" file="0" line="19" len="1"/> </source> </Call> </children> <source> <Source kind="1" file="0" line="16" len="5"/> </source> </Function> </children> <source> <Source kind="0" file="0" line="4" len="18"/> </source> </Namespace> <Function kind="1" cv_qualifiers="0" name="draw" id="5"> <result_type> <Type signature="void"/> </result_type> <arg_types> <Type signature="Shape &"/> </arg_types> <children> <Execution/> </children> <source> <Source kind="1" file="0" line="2" len="1"/> </source> </Function> <Function kind="1" cv_qualifiers="0" name="operator =" builtin="true" tunits="0" id="2"> <result_type> <Type signature="int &"/> </result_type> <arg_types> <Type signature="int &"/> <Type signature="int"/> </arg_types> </Function> <Function kind="1" cv_qualifiers="0" name="main"> <result_type> <Type signature="int"/> </result_type> <children> <Execution/> <Call target="6" lid="0"> <source> <Source kind="0" file="0" line="24" len="1"/> </source> </Call> </children> <source> <Source kind="1" file="0" line="23" len="4"/> </source> </Function> </children> </Namespace> </root> </ac-model>