We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
AspectC++ Quick Reference Namespace and Class Matching Functions / Variables
"Chain" call(pointcut) N→CC ‡‡
matches the class, struct or union Chain provides all join points where a named and user provided entity in the Concepts pointcut is called. "Memory%" Aspects are modular implementations of crosscutting concerns. They can matches any class, struct or union whose name starts with “Memory” builtin(pointcut)‡ N→CB affect join points in the component code, e.g. class definitions, or in the provides all join points where a named built-in operator in the point- dynamic control flow, e.g. function calls, by advice. A set of related join cut is called. points is called pointcut and defined by a pointcut expression. Function Matching execution(pointcut) N→CE provides all join points referring to the implementation of a named "void reset()" entity in the pointcut. Aspects matches the function reset having no parameters and returning void construction(pointcut) N→CCons Aspects extend the concept of C++ classes. They may define ordinary "% printf(...)" all join points where an instance of the given class(es) is constructed. class members as well as advice. matches the function printf having any number of parameters and destruction(pointcut) N→CDes returning any type all join points where an instance of the given class(es) is destructed. aspect A : public B { ... }; "% ...::%(...)" get(pointcut) N→CG defines the aspect A, which inherits from class or aspect B matches any function, operator function, or type conversion function provides all join points where a global variable or data member in the (in any class or namespace) pointcut is read. Slices "% ...::Service::%(...) const" set(pointcut) N→CS matches any const member-function of the class Service defined provides all join points where a global variable or data member in the A slice is a fragment of a C++ element like a class. It may be used by in any scope pointcut is written. introduction advice to implemented static extensions of the program. "% ...::operator %(...)" ref(pointcut) N→CR matches any type conversion function provides all join points where a reference (reference type or pointer) slice class ASlice { ... void f (); ... }; defines a class slice called ASlice "virtual % C::%(...)" to a global variable or data member in the pointcut is created. slice void ASlice::f () { ... } matches any virtual member function of C defines a non-inline member function f() of slice ASlice "static % ...::%(...)" pointcut may contain function, variable, namespace or class names. A matches any static member or non-member function namespace or class name is equivalent to the names of all functions and variables defined within its scope combined with the || operator (see be- Advice low). Variable Matching An advice declaration specifies how an aspect affects a set of join points. Control Flow advice pointcut : around(...) {...} "int counter" the advice code is executed in place of the join points in the pointcut matches the variable counter of type int cflow(pointcut) C→C advice pointcut : before/after(...) {...} "% guard" captures join points occuring in the dynamic execution context of join the advice code is executed before/after the join points in the pointcut matches the global variable guard of any type points in the pointcut. The argument pointcut is forbidden to contain advice pointcut : order(high, ...low); "% ...::%" context variables or join points with runtime conditions (currently high and low are pointcuts, which describe sets of aspects. Aspects matches any variable (in any class or namespace) cflow, that, or target). on the left side of the argument list always have a higher precedence "static % ...::%" than aspects on the right hand side at the join points, where the order matches any static member or non-member variable declaration is applied. Types advice pointcut : slice class : public Base {...} base(pointcut) N→NC,F introduces a new base class Base and members into the target classes Template Matching † returns all base classes resp. redefined functions of classes in the matched by pointcut. pointcut advice pointcut : slice ASlice ; "std::set<...>" introduces the slice ASlice into the target classes matched by pointcut. derived(pointcut) N→NC,F matches all template instances of the class std::set returns all classes in the pointcut and all classes derived from them "std::set<int>" resp. all redefined functions of derived classes Match Expressions matches only the template instance std::set<int> "% ...::%<...>::%(...)" Match expressions are primitive pointcut expressions. They filter program matches any member function from any template class instance in Scope entities based on their signature. any scope within(pointcut) N→C filters all join points that are within the functions or classes in the Type Matching pointcut Predefined Pointcut Functions member(pointcut) N→N "int" maps the scopes given in pointcut to any contained named entities. matches the C++ built-in scalar type int Predefined pointcut functions are used to filter, map, join, or intersect Thus a class name for example is mapped to all contained member "% *" pointcuts. functions, variables and nested types. matches any pointer type Context Result [type] Runtime Type Information type of the object, used to store the result of the join point that(type pattern) N→C Res::Type, Res::ReferredType [type] static AC::Type resulttype() returns all join points where the current C++ this pointer refers to result type of the affected function or entity access static AC::Type argtype(int i) an object which is an instance of a type that is compatible to the type Arg<i>::Type, Arg<i>::ReferredType [type] return a C++ ABI V3†† conforming string representation of the result described by the type pattern type of the i th argument of the affected join point (with 0 ≤ i < ARGS) type / argument type of the affected function target(type pattern) N→C ARGS [const] returns all join points where the target object of a call or other access number of arguments is an instance of a type that is compatible to the type described by the Array [type] JoinPoint-API for Slices type pattern type of an accessed array result(type pattern) N→C The JoinPoint-API is provided within introduced slices by the built-in Dim<i>::Idx, Dim<i>::Size [type], [const] class JoinPoint (state of target class before introduction). returns all join points where the result object of a call/execution or type of used index and size of the i th dimension (with 0 ≤ i < DIMS) other access join point is an instance of a type described by the type DIMS [const] pattern static const char *signature() number of dimensions of an accessed array or 0 otherwise returns the target class name as a string args(type pattern, ...) (N,...)→C JPID [const] a list of type patterns is used to provide all joinpoints with matching That [type] unique numeric identifier for this join point The (incomplete) target type of the introduction argument signatures JPTYPE [const] BASECLASSES [const] numeric identifier describing the type of this join point (AC::CALL, number of baseclasses of the target class Instead of the type pattern it is possible here to pass the name of a context AC::BUILTIN, AC::EXECUTION, AC::CONSTRUCTION, BaseClass<I>::Type [type] variable to which the context information is bound. In this case the type AC::DESTRUCTION, AC::GET , AC::SET or AC::REF ) type of the I th baseclass of the variable is used for the type matching. BaseClass<I>::prot, BaseClass<I>::spec [const] Runtime Functions and State Protection level (AC::PROT_NONE /PRIVATE /PROTECTED Algebraic Operators /PUBLIC) and additional specifiers (AC::SPEC_NONE /VIRTUAL) static const char *signature() of the I th baseclass pointcut && pointcut (N,N)→N, (C,C)→C gives a textual description of the join point (type + name) MEMBERS [const] intersection of the join points in the pointcuts static const char *filename() number of member variables of the target class pointcut || pointcut (N,N)→N, (C,C)→C returns the name of the file in which the joinpoint shadow is located Member<I>::Type, Member<I>::ReferredType [type] union of the join points in the pointcuts static int line() type of the I th member variable of the target class ! pointcut N→N, C→C the source code line number in which the joinpoint shadow is located Member<I>::prot, Member<I>::spec [const] exclusion of the join points in the pointcut That *that() Protection level (see BaseClass<I>::prot) and additional member returns a pointer to the object initiating a call or 0 if it is a static variable specifiers (AC::SPEC_NONE /STATIC /MUTABLE) Named Pointcuts and Attributes method or a global function static ReferredType *Member<I>::pointer(T *obj=0) Target *target() returns a typed pointer to the I th member variable (obj is needed for Pointcut expressions can also refer to user-defined pointcuts. returns a pointer to the object that is the target of a call or 0 if it is a non-static members) static method or a global function class [[myns::myattr]] C {...} static const char *Member<I>::name() Entity *entity() annotates class C with the attribute myattr from the namespace myns. returns a pointer to the accessed entity (function or variable) or 0 for returns the name of the I th member variable pointcut mypct() = “C”; member functions or builtin operators defines a “named pointcut” mypct(), which represents the class “C” MemberPtr memberptr() attribute myattr (); // in myns returns a member pointer to entity or 0 for nonmembers Example (simple tracing aspect) declares a user-defined attribute myattr(), which also represents “C” Result *result() aspect Tracing { returns a typed pointer to the result value or 0 if there is none advice execution(“% Business::%(...)”) : before() { Arg<i>::ReferredType *arg<i>() JoinPoint-API for Advice Code returns a typed pointer to the i th argument value (with 0 ≤ i < ARGS) cout << "before " << JoinPoint::signature() << endl; } }; The JoinPoint-API is provided within every advice code body by the built- void *arg(int i) in object tjp of class JoinPoint. returns a pointer to the i th argument memory location (0 ≤ i < ARGS) Reference sheet corresponding to AspectC++ 2.3, July 12, 2022. For void proceed() more information visit http://www.aspectc.org. executes the original code in an around advice (should be called at Compile-time Types and Constants most once in around advice) (c) Copyright 2021, AspectC++ developers. All rights reserved. That [type] AC::Action &action() returns the runtime action object containing the execution environ- † object type (object initiating a call or entity access) support for template instance matching is an experimental feature ment to execute ( trigger() ) the original code encapsulated by an ‡ Target [type] This feature has limitations. Please see the AspectC++ Language Reference. around advice †† target object type (target object of a call or entity access) ‡‡ https://mentorembedded.github.io/cxx-abi/abi.html#mangling Entity [type] Array *array() C, CC , CB , CE , CCons , CDes , CG , CS , CR : Code (any, only Call, only Builtin, only Execution, returns a typed pointer to the accessed array only object Construction, only object Destruction, only Get, only Set, only Ref) type of the primary referenced entity (function or variable) N, NN , NC , NF , NV , NT : Names (any, only Namespace, only Class, only Function, only MemberPtr [type] Dim<i>::Idx idx<i>() Variables, only Type) type of the member pointer for entity or “void *” for nonmembers. returns the value of the i th used index