../../AspectXLib/CodeInstrumentation/Base/aspects/TraceMethodLeave.axprintf instruction that
writes a message to the output device stating the name of the method, the name of the class
to which it belongs and the return statement.
This aspect defines seven advices that describe seven separate but related
changes. The first two advices inserts comments to describe the changes made in the base code.
The next three advices inserts tracing instructions in the methods and the sixth advice inserts
declaration of helper variable needed for temporal storage of the return value. The last advice
inserts a new include statement to include the stdio library that is
required by the printf method.
This sample aspect program targets all method definitions.
Pointcuts | |
| function | targetIntMethodImplementation |
| Points to the implementations of the methods that must be modified | |
| function | targetNonIntMethodImplementation |
| Points to the implementations of the methods that must be modified | |
| return | targetIntMethodReturn |
| Points to return statement that must be modified | |
| return | targetNonIntMethodReturn |
| >Points to return statement that must be modified | |
| function_decl | targetMethodDeclaration |
| Points to all declarations of the target methods | |
| comment | targetMethodDeclarationComment |
| Points to the method comments that must be modified | |
| class | targetClass |
| Points to all classes that contain a target method | |
| comment | targetClassComment |
| Points to the class comments that must be modified | |
| unit | targetImplementationUnit |
| Points to all the units that contain implementations of methods that must be
modified | |
Advices | |
| end | insertClassComment |
| Add a comment at the end of the comment of the classes that are modified by other advices | |
| end | insertMethodComment |
| Add a comment at the end of the comment of the methods that are modified by other advices | |
| replace | insertIntTraceBeforeReturn |
| Insert the tracing instruction in the target methods | |
| before | insertNonIntTraceBeforeReturn |
| Insert the tracing instruction in the target methods | |
| end | insertTraceAtFunctionEnd |
| Insert the tracing instruction in the target methods | |
| end | insertTraceAtContructorEnd |
| Insert the tracing instruction in the target constructor | |
| begin | insertVariableDeclaration |
| Insert the declaration of integer local variable at the beginning of target methods | |
| add | addInclude |
| Add the #include statement for the stdio library | |
int.
This pointcut only points to the method implementation. A second pointcut
(targetMethodDeclaration) points to the method declarations.
int.
This pointcut only points to the method implementation. A second pointcut
(targetMethodDeclaration) points to the method declarations.
int.
int.
targetMethodImplementation).
Note that this pointcut also excludes pure virtual declarations using examination
of the specifier subelement of the function_decl element.targetMethodDeclaration pointcut. targetMethodDeclaration pointcut targetClass
pointcut. Triplet: comment end comment
Refers to global pointcut: comment targetClassComment
Triplet: comment end comment
Refers to global pointcut: comment targetMethodDeclarationComment
Triplet: return replace codeFragment
xsl:value-of.
Refers to global pointcut: return targetIntMethodReturn
Triplet: return before codeFragment
xsl:value-of XSLT instruction is used
to access the method name and calss name. Dollar variables cannot be used within the
xsl element.Refers to global pointcut: return targetNonIntMethodReturn
Triplet: function end codeFragment
Local Pointcut: function (source)
Triplet: constructor end codeFragment
substring-before(src:name,'::') is used to
query srcML for the name of of the class.Local Pointcut: constructor (source)
Triplet: function begin codeFragment
Refers to global pointcut: function targetIntMethodImplementation
Triplet: unit add include
#include statement for the stdio library.
Inclusion of this library is necessary because the code that is woven into the target methods
calls the stdio function printf. Note that the code to be added by this advice is
specified using the CDATA section because otherwise the braces around "stdio" would be
interpreted as XML braces by the XWeaver program.Refers to global pointcut: unit targetImplementationUnit