1
#LyX 1.4.3 created this file. For more info see http://www.lyx.org/
7
%--------------------------------------------------------------------
9
%--------------------------------------------------------------------
11
\ifx\pdfoutput\undefined
12
\pdffalse % we are not running PDFLaTeX
14
\pdfoutput=1 % we are running PDFLaTeX
18
%--------------------------------------------------------------------
20
%--------------------------------------------------------------------
27
%% general document information
28
pdftitle = {AspectC++ Language Reference},
29
pdfsubject = {Dokumentation},
30
pdfkeywords = {AOP, AspectC++, pure-systems},
31
pdfauthor = {\textcopyright\ pure-systems GmbH and Olaf Spinczyk},
32
pdfcreator = {\LaTeX\ with package \flqq hyperref\frqq},
33
pdfproducer = {pdfTeX-0.\the\pdftexversion\pdftexrevision},
36
colorlinks=true, % colored link
37
urlcolor=blue, % blue URL links
38
bookmarks=true, % generate bookmarks
39
bookmarksnumbered=true, % generate section numbers
40
pdfpagemode=None % don't open bookmarks
43
%% set document creation date to 10.7.2003 00:00
44
\pdfinfo {/CreationDate (D:20051206000000)}
47
%--------------------------------------------------------------------
48
% create hyperrefs depending on the use of pdflatex
49
%--------------------------------------------------------------------
50
\newcommand\depref[2]{%
58
%--------------------------------------------------------------------
59
% setup pure-systems style
60
%--------------------------------------------------------------------
62
\usepackage{../styles/pure-systems}
63
\doctype{Documentation:}
65
\noindent\small{(c) 2002-2005 Olaf Spinczyk and pure-systems GmbH\\All rights reserved.}}
67
\resizebox{6cm}{!}{\includegraphics{../images/ps-logo}}}
69
\resizebox{4cm}{!}{\includegraphics{../images/ac++logo}}}
72
\small{(c) 2002-2005 Olaf Spinczyk$^1$ and pure-systems GmbH$^2$\\~\\
73
$^1$\depref{mailto:os@aspectc.org}{os@aspectc.org}\\
74
\depref{http://www.aspectc.org}{www.aspectc.org}\\~\\
75
$^2$\depref{mailto:aspectc@pure-systems.com}{aspectc@pure-systems.com}\\
76
\depref{http://www.pure-systems.com}{www.pure-systems.com}\\
83
%--------------------------------------------------------------------
84
% place footnotes at the bottom of the page
85
%--------------------------------------------------------------------
86
\renewcommand\footnoterule{%
89
\hrule\@width.3\columnwidth
92
%--------------------------------------------------------------------
93
% leave less than one and a half space between lines
94
%--------------------------------------------------------------------
97
%--------------------------------------------------------------------
98
% 'list of examples' environment
99
%--------------------------------------------------------------------
100
\newcommand\examplesname{List of Examples}
101
\newenvironment{examples}
102
{\section*{\examplesname}%
103
\@mkboth{\MakeUppercase\examplesname}%
104
{\MakeUppercase\examplesname}%
105
\thispagestyle{plain}
106
\parindent\z@ \parskip\z@ \@plus .3\p@\relax} %
109
%--------------------------------------------------------------------
110
% environment 'comment'
111
%--------------------------------------------------------------------
114
%--------------------------------------------------------------------
115
% add 'Index' to table of contents
116
%--------------------------------------------------------------------
117
\let\old@theindex\theindex
120
\addcontentsline{toc}{section}{\indexname}}
133
\paperorientation portrait
136
\paragraph_separation indent
138
\quotes_language english
141
\paperpagestyle default
142
\tracking_changes false
151
AspectC++ Language Reference
163
\begin_layout Standard
175
\begin_layout Standard
176
\begin_inset LatexCommand \tableofcontents{}
184
\begin_layout Standard
196
\begin_layout Section
200
\begin_layout Standard
201
This document is intended to be used as a reference book for the AspectC++
203
It describes in-depth the use and meaning of each element providing examples.
204
For experienced users the contents of this document is summarized in the
212
\begin_layout Standard
216
depref{http://www.aspectc.com/ac++quickref.pdf}{
218
emph{AspectC++ Quick Reference}}
226
A step-by-step introduction how to program with AspectC++ is given in the
231
\begin_layout Standard
235
depref{http://www.aspectc.com/doc.html}{
237
emph{AspectC++ Programming Guide}}
248
\begin_layout Standard
249
Sorry, but the Programming Guide is not written yet
257
Detailed information about the AspectC++ compiler
262
\begin_inset LatexCommand \index{ac++@\texttt{ac++}}
266
can be looked up in the
270
\begin_layout Standard
274
depref{http://www.aspectc.com/ac++compilerman.pdf}{
276
emph{AC++ Compiler Manual}}
287
\begin_layout Standard
288
AspectC++ is an aspect-oriented extension to the C++ language
292
\begin_layout Standard
293
defined in the ISO/IEC 14882:1998(E) standard
299
It is similar to AspectJ
303
\begin_layout Standard
309
\begin_layout Standard
313
depref{http://www.aspectj.org}{
315
texttt{www.aspectj.org}}
325
but, due to the nature of C++, in some points completely different.
326
The first part of this document introduces the basic concepts of the AspectC++
328
The in-depth description of each language element is subject of the second
332
\begin_layout Section
336
\begin_layout Subsection
338
\begin_inset LatexCommand \index{pointcut|(}
345
\begin_layout Standard
346
Aspects in AspectC++ implement crosscutting concerns
347
\begin_inset LatexCommand \index{crosscutting concern}
352
With this in mind the most important element of the AspectC++ language
354
Pointcuts describe a set of join points
355
\begin_inset LatexCommand \index{join point}
359
by determining on which condition an aspect shall take effect.
360
Thereby each join point can either refer to a function, an attribute, a
361
type, a variable, or a point from which a join point is accessed so that
362
this condition can be for instance the event of reaching a designated code
367
\begin_layout Standard
376
or the allocation of a variable with a certain value
380
\begin_layout Standard
384
\begin_layout Standard
388
\begin_layout Standard
395
\begin_layout Standard
402
Depending on the kind of pointcuts, they are evaluated at compile time
406
\begin_layout Subsubsection
408
\begin_inset LatexCommand \index{match expression|(}
413
\begin_inset LatexCommand \index{search pattern!match expression|(}
420
\begin_layout Standard
421
There are two types of pointcuts in AspectC++:
431
\begin_inset LatexCommand \index{name pointcut}
436
\begin_inset LatexCommand \index{pointcut!name}
440
describe a set of (statically) known program entities like types, attributes,
441
functions, variables, or namespaces.
442
All name pointcuts are based on match expressions.
443
A match expression can be understood as a search pattern
444
\begin_inset LatexCommand \index{search pattern}
449
\begin_inset LatexCommand \index{match expression!search pattern}
454
In such a search pattern the special character
455
\begin_inset Quotes eld
459
\begin_inset Quotes erd
462
is interpreted as a wildcard for names or parts of a signature.
463
The special character sequence
464
\begin_inset Quotes eld
468
\begin_inset Quotes erd
471
matches any number of parameters in a function signature or any number
472
of scopes in a qualified name.
473
A match expression is a quoted string.
476
\begin_layout Subsubsection*
477
Example: match expressions (name pointcuts)
478
\begin_inset LatexCommand \label{exa:match-expressions}
485
\begin_layout Description
500
matches all member functions of the class C that return an
505
\begin_layout Description
515
matches any class, struct, union, or enum whose name ends with
516
\begin_inset Quotes eld
520
\begin_inset Quotes erd
526
\begin_layout Description
532
printf(const char *, ...)"
541
(defined in the global scope) having at least one parameter of type
547
and returning any type
550
\begin_layout Description
567
matches all functions that return a reference to a constant object
570
\begin_layout Standard
571
Match expressions select program entities with respect to their definition
572
scope, their type, and their name.
573
A detailed description of the match expression semantics follows in section
575
\begin_inset LatexCommand \vref{sec:Match-Expressions}
580
The grammar which defines syntactically valid match expressions is shown
582
\begin_inset LatexCommand \vref{sec:Match-Expression-Grammar}
588
\begin_inset LatexCommand \index{match expression|)}
593
\begin_inset LatexCommand \index{search pattern!match expression|)}
600
\begin_layout Subsubsection
602
\begin_inset LatexCommand \index{pointcut!expression|(}
609
\begin_layout Standard
610
The other type of pointcuts, the code pointcuts
611
\begin_inset LatexCommand \index{code pointcut}
616
\begin_inset LatexCommand \index{pointcut!code}
620
, describe an intersection through the set of the points in the control
622
\begin_inset LatexCommand \index{control flow}
627
A code pointcut can refer to a call or execution point of a function
631
\begin_layout Standard
640
but also to write and read points of attributes and variables
644
\begin_layout Standard
648
\begin_layout Standard
652
\begin_layout Standard
659
\begin_layout Standard
666
They can only be created with the help of name pointcuts because all join
667
points supported by AspectC++ require at least one name to be defined.
668
This is done by calling predefined pointcut functions
669
\begin_inset LatexCommand \index{pointcut function}
674
\begin_inset LatexCommand \index{pointcut!function}
678
in a pointcut expression that expect a pointcut as argument.
679
Such a pointcut function is for instance
687
), which filters all join points that are within the functions or classes
688
in the given pointcut.
691
\begin_layout Standard
692
Name and code pointcuts can be combined in pointcut expressions by using
693
the algebraic operators
694
\begin_inset Quotes eld
698
\begin_inset Quotes erd
702
\begin_inset Quotes eld
706
\begin_inset Quotes erd
710
\begin_inset Quotes eld
714
\begin_inset Quotes erd
720
\begin_layout Subsubsection*
721
Example: pointcut expressions
722
\begin_inset LatexCommand \label{exa:pointcut-expressions}
729
\begin_layout Description
741
describes the set of classes with names that end with
742
\begin_inset Quotes eld
746
\begin_inset Quotes erd
749
and that are not derived from the class
754
\begin_layout Description
778
describes the set of calls to the function
782
that are within methods of the class
787
\begin_inset LatexCommand \index{pointcut!expression|)}
794
\begin_layout Subsubsection
796
\begin_inset LatexCommand \index{join point|(}
803
\begin_layout Standard
804
According to the two types of pointcuts supported by AspectC++ there are
805
also two types of join points.
806
Based on a short code fragment the differences and relations between these
807
two types of join points shall be clarified.
810
\begin_layout LyX-Code
819
typedef int PRECISION;
824
class S_Circle : public Shape {
833
\begin_layout LyX-Code
834
void radius(PRECISION r) { m_radius=r; }
844
\begin_layout LyX-Code
848
\begin_layout LyX-Code
852
\begin_layout LyX-Code
870
\begin_layout Standard
872
\begin_inset LatexCommand \index{code join point}
877
\begin_inset LatexCommand \index{join point!code}
881
are used to form code pointcuts and name join points (i.e.\InsetSpace ~
883
to form name pointcuts.
885
\begin_inset LatexCommand \vref{fig:join-points}
889
shows some join points of the code fragment and how they correlate.
893
\begin_layout Standard
894
\begin_inset Float figure
899
\begin_layout Standard
901
\begin_inset Graphics
902
filename ../images/JoinPointModel.eps
910
\begin_layout Caption
911
\begin_inset LatexCommand \label{fig:join-points}
915
join points and their relations
923
\begin_layout Standard
929
\begin_inset LatexCommand \index{execution join point}
934
\begin_inset LatexCommand \index{join point!execution}
938
join point is associated with the name of an executable function.
939
Pure virtual functions
940
\begin_inset LatexCommand \index{pure virtual!functions}
945
Thus, advice code for execution join points would never be triggered for
946
this kind of function.
947
However, the call of such a function, i.e.\InsetSpace ~
952
join point with this function as target, is absolutely possible.
955
\begin_layout Standard
961
\begin_inset LatexCommand \index{call join point}
966
\begin_inset LatexCommand \index{join point!call}
970
join point is associated with two names: the name of the source and the
971
target function of a function call.
972
As there can be multiple function calls within the same function, each
973
function name can be associated with a list of
978
\begin_inset LatexCommand \index{join point|)}
987
\begin_layout Standard
1001
\begin_inset LatexCommand \index{set join point}
1006
\begin_inset LatexCommand \index{join point!set}
1015
\begin_inset LatexCommand \index{get join point}
1020
\begin_inset LatexCommand \index{join point!get}
1024
join points, which represent write resp.\InsetSpace ~
1025
read operations on attributes or
1027
Each of these join points is associated with the name of the function that
1028
contains the join point and the name of the accessed attribute or global
1033
\begin_layout Standard
1037
\begin_layout Standard
1041
\begin_layout Standard
1048
\begin_layout Standard
1058
joinpoint means the class specific instruction sequence executed when an
1059
instance is created.
1064
joinpoint means the object destruction.
1067
\begin_layout Subsubsection
1068
Pointcut declarations
1071
\begin_inset LatexCommand \index{pointcut!declaration|(}
1078
\begin_layout Standard
1079
AspectC++ provides the possibility to name pointcut
1080
\begin_inset LatexCommand \index{name pointcut}
1085
\begin_inset LatexCommand \index{pointcut!name}
1089
expressions with the help of pointcut declarations.
1090
This makes it possible to reuse pointcut expressions in different parts
1092
They are allowed where C++ declarations are allowed.
1093
Thereby the usual C++ name lookup and inheritance rules are also applicable
1094
for pointcut declarations.
1097
\begin_layout Standard
1098
A pointcut declaration is introduced by the keyword
1106
\begin_layout Subsubsection*
1107
Example: pointcut declaration
1108
\begin_inset LatexCommand \label{exa:pointcut-declaration}
1115
\begin_layout Description
1124
lists()\InsetSpace ~
1140
can now be used everywhere in a program where a pointcut expression can
1146
\begin_layout Standard
1147
Furthermore pointcut declarations can be used to define pure virtual pointcuts
1148
\begin_inset LatexCommand \index{pure virtual!pointcut}
1153
\begin_inset LatexCommand \index{pointcut!pure virtual}
1158
This enables the possibility of having re-usable abstract aspects
1159
\begin_inset LatexCommand \index{aspect}
1164
\begin_inset LatexCommand \index{abstract aspect}
1169
\begin_inset LatexCommand \index{aspect!abstract}
1173
that are discussed in section
1174
\begin_inset LatexCommand \ref{sub:Aspects}
1179
The syntax of pure virtual pointcut declarations is the same as for usual
1180
pointcut declarations except the keyword
1188
and that the pointcut expression is
1189
\begin_inset Quotes eld
1193
\begin_inset Quotes erd
1199
\begin_layout Subsubsection*
1200
Example: pure virtual pointcut declaration
1201
\begin_inset LatexCommand \label{exa:pure-virtual}
1208
\begin_layout Description
1217
virtual\InsetSpace ~
1218
methods()\InsetSpace ~
1234
is a pure virtual pointcut that has to be redefined in a derived aspect
1235
to refer to the actual pointcut
1236
\begin_inset LatexCommand \index{pointcut|)}
1243
\begin_inset LatexCommand \index{pointcut!declaration|)}
1250
\begin_layout Subsection
1252
\begin_inset LatexCommand \index{slice|(}
1259
\begin_layout Standard
1264
is a fragment of a C++ language element that defines a scope.
1265
It can be used by advice to extend the static structure of the programm.
1266
For example, the elements of a class slice can be merged into one or more
1267
target classes by introduction advice.
1268
The following example shows a simple class slice declaration.
1271
\begin_layout Subsubsection*
1272
Example: class slice declaration
1273
\begin_inset LatexCommand \label{exa:class-slice-declaration}
1280
\begin_layout LyX-Code
1284
\begin_layout LyX-Code
1288
\begin_layout LyX-Code
1292
\begin_layout LyX-Code
1293
Chain *next () const { return _next; }
1296
\begin_layout LyX-Code
1300
\begin_layout Standard
1301
\begin_inset LatexCommand \index{slice|)}
1308
\begin_layout Subsection
1310
\begin_inset LatexCommand \index{advice|(}
1315
\begin_inset LatexCommand \index{advice!code|(}
1322
\begin_layout Standard
1323
To a code join point
1324
\begin_inset LatexCommand \index{code join point}
1329
\begin_inset LatexCommand \index{join point!code}
1333
so-called advice code can be bound.
1334
Advice code can be understood as an action
1335
\begin_inset LatexCommand \index{action}
1340
\begin_inset LatexCommand \index{runtime support!action}
1344
activated by an aspect when a corresponding code join point in a program
1346
The activation of the advice code can happen before
1347
\begin_inset LatexCommand \index{before}
1352
\begin_inset LatexCommand \index{advice!before}
1357
\begin_inset LatexCommand \index{after}
1362
\begin_inset LatexCommand \index{advice!after}
1366
, or before and after the code join point is reached.
1367
The AspectC++ language element to specify advice code is the advice declaration
1368
\begin_inset LatexCommand \index{advice!declaration}
1373
It is introduced by the keyword
1377
followed by a pointcut expression defining where and under which conditions
1378
the advice code shall be activated.
1382
\begin_layout Subsubsection*
1383
Example: advice declaration
1384
\begin_inset LatexCommand \label{exa:advice-declaration}
1391
\begin_layout LyX-Code
1392
advice execution("void login(...)") : before() {
1394
cout << "Logging in." << endl;
1399
\begin_layout Standard
1404
following the pointcut expression determines that the advice code shall
1405
be activated directly
1410
\begin_inset LatexCommand \index{before}
1415
\begin_inset LatexCommand \index{advice!before}
1419
the code join point is reached.
1420
It is also possible here to use
1429
\begin_inset LatexCommand \index{after}
1434
\begin_inset LatexCommand \index{advice!after}
1438
reaching the code join point respectively
1442
which means that the advice code shall be executed instead of the code
1443
described by the code join point.
1449
\begin_inset LatexCommand \index{around}
1454
\begin_inset LatexCommand \index{advice!around}
1458
advice the advice code can explicitly trigger the execution of the program
1459
code at the join point so that advice code can be executed
1468
There are no special access rights of advice code regarding to program
1469
code at a join point.
1472
\begin_layout Standard
1473
Beside the pure description of join points pointcuts can also bind variables
1475
\begin_inset LatexCommand \index{context variables}
1479
information of a join point.
1480
Thus for instance the actual argument values of a function call can be
1481
made accessible to the advice code.
1484
\begin_layout Subsubsection*
1485
Example: advice declaration with access to context information
1486
\begin_inset LatexCommand \label{exa:advice-declaration-with}
1493
\begin_layout LyX-Code
1494
pointcut new_user(const char *name) =
1496
execution("void login(...)") && args(name);
1501
advice new_user(name) : before(const char *name) {
1504
name << " is logging in." << endl;
1509
\begin_layout Standard
1510
In the example above at first the pointcut
1514
is defined including a context variable
1515
\begin_inset LatexCommand \index{context variables}
1523
that is bound to it.
1524
This means that a value of type
1528
is supplied every time the join point described by the pointcut
1533
The pointcut function
1537
used in the pointcut expression delivers all join points in the program
1538
where an argument of type
1552
\begin_inset LatexCommand \index{execution join point}
1557
\begin_inset LatexCommand \index{join point!execution}
1565
to the first and only parameter of the function
1573
\begin_layout Standard
1574
The advice declaration in the example above following the pointcut declaration
1575
binds the execution of advice code to the event when a join point described
1581
The context variable
1582
\begin_inset LatexCommand \index{context variables}
1586
that holds the actual value of the parameter of the reached join point
1587
has to be declared as a formal parameter of
1600
This parameter can be used in the advice code like an oridinary function
1604
\begin_layout Standard
1605
Beside the pointcut function
1610
\begin_inset LatexCommand \index{args@\texttt{args()}}
1615
\begin_inset LatexCommand \index{pointcut function!args@\texttt{args()}}
1619
the binding of context variables is performed by
1624
\begin_inset LatexCommand \index{that@\texttt{that()}}
1629
\begin_inset LatexCommand \index{pointcut function!that@\texttt{that()}}
1638
\begin_inset LatexCommand \index{target@\texttt{target()}}
1643
\begin_inset LatexCommand \index{pointcut function!target@\texttt{target()}}
1652
\begin_inset LatexCommand \index{result@\texttt{result()}}
1657
\begin_inset LatexCommand \index{pointcut function!base@\texttt{base()}}
1662
At the same time these pointcut functions act as filters corresponding
1663
to the type of the context variable.
1668
in the example above filters all join points having an argument of type
1674
\begin_inset LatexCommand \index{advice!code|)}
1681
\begin_layout Subsubsection
1683
\begin_inset LatexCommand \index{introduction|(}
1688
\begin_inset LatexCommand \index{advice!introduction|(}
1695
\begin_layout Standard
1696
The second type of advice supported by AspectC++ are the introductions.
1697
Introductions are used to extend program code and data structures in particular.
1698
The following example extends two classes each by an attribute and a method.
1701
\begin_layout Subsubsection*
1702
Example: introductions
1703
\begin_inset LatexCommand \label{exa:introductions}
1710
\begin_layout LyX-Code
1711
pointcut shapes() = "Circle" || "Polygon";
1715
advice shapes() : slice class
1720
void shaded(bool state) {
1729
\begin_layout Standard
1730
Like an ordinary advice declaration an introduction is introduced by the
1736
If the following pointcut is a name pointcut
1737
\begin_inset LatexCommand \index{name pointcut}
1742
\begin_inset LatexCommand \index{pointcut!name}
1746
the slice declaration following the token
1747
\begin_inset Quotes eld
1751
\begin_inset Quotes erd
1754
is introduced in the classes and aspects described by the pointcut.
1755
Introduced code can then be used in normal program code like any other
1756
function, attribute, etc.
1757
Advice code in introductions has full access rights
1758
\begin_inset LatexCommand \index{introduction!access rights}
1762
regarding to program code at a join point, i.e.\InsetSpace ~
1763
a method introduced in a class
1764
has access even to private members of that class.
1767
\begin_layout Standard
1768
Slices can also be used to introduce new base classes.
1769
In the first line of the following example it is made sure that every class
1770
with a name that ends with
1771
\begin_inset Quotes eld
1775
\begin_inset Quotes erd
1778
is derived from a class
1783
This class may implement an own memory management by overloading the
1792
Classes that inherit from
1796
must redefine the pure virtual method
1800
that is part of the implemented memory management.
1801
This is done in the second line for all classes in the pointcut
1802
\begin_inset LatexCommand \index{advice|)}
1807
\begin_inset LatexCommand \index{introduction|)}
1812
\begin_inset LatexCommand \index{advice!introduction|)}
1819
\begin_layout Subsubsection*
1820
Example: base class introduction
1821
\begin_inset LatexCommand \label{exa:base-class-intro}
1828
\begin_layout LyX-Code
1829
advice "%Object" : slice class : public MemoryPool {
1831
virtual void release()
1837
\begin_layout Subsubsection
1839
\begin_inset LatexCommand \index{ordering|(}
1846
\begin_layout Standard
1847
If more than one advice affects the same join point it might be necessary
1848
to define an order of advice execution if there is a dependency between
1850
\begin_inset Quotes eld
1854
\begin_inset Quotes erd
1858
\begin_inset LatexCommand \index{aspect interaction}
1863
The following example shows how the precedence of advice code can be defined
1867
\begin_layout Subsubsection*
1868
Example: advice ordering
1869
\begin_inset LatexCommand \label{exa:order}
1876
\begin_layout LyX-Code
1877
advice execution("void send(...)") : order("Encrypt", "Log")
1878
\begin_inset LatexCommand \index{order}
1883
\begin_inset LatexCommand \index{advice!order}
1890
\begin_layout Standard
1891
If advice of both aspects (see
1892
\begin_inset LatexCommand \ref{sub:Aspects}
1904
should be run when the function
1908
is executed this order declaration defines that the advice of
1912
has a higher precedence.
1913
More details on advice ordering and precedence
1914
\begin_inset LatexCommand \index{precedence}
1918
can be found in section
1919
\begin_inset LatexCommand \vref{sec:ordering}
1926
\begin_layout Subsection
1928
\begin_inset LatexCommand \label{sub:Aspects}
1933
\begin_inset LatexCommand \index{aspect|(}
1940
\begin_layout Standard
1941
The aspect is the language element of AspectC++ to collect introductions
1942
and advice code implementing a common crosscutting concern
1943
\begin_inset LatexCommand \index{crosscutting concern}
1948
This put aspects in a position to manage common state information.
1949
They are formulated by means of aspect declarations
1950
\begin_inset LatexCommand \index{aspect!declaration}
1954
as a extension to the class concept of C++.
1955
The basic structure of an aspect declaration is exactly the same as an
1956
usual C++ class definition, except for the keyword
1973
According to that, aspects can have attributes and methods and can inherit
1974
from classes and even other aspects.
1977
\begin_layout Subsubsection*
1978
Example: aspect declaration
1979
\begin_inset LatexCommand \label{exa:aspect-decl}
1986
\begin_layout LyX-Code
1993
pointcut counted() = "Circle"
1998
advice counted() : slice struct {
2003
Helper() { Counter::m_count++; }
2012
main(...)") : after() {
2014
cout << "Final count: " << m_count << " objects"
2022
and at an appropriate place
2024
#include "Counter.ah"
2026
int Counter::m_count = 0;
2029
\begin_layout Standard
2030
In this example the count of object instantiations for a set of classes
2032
Therefore, an attribute
2036
is introduced into the classes described by the pointcut incrementing a
2037
global counter on construction time.
2038
By applying advice code for the function
2042
the final count of object instantiations is displayed when the program
2047
\begin_layout Standard
2048
This example can also be rewritten as an abstract aspect
2049
\begin_inset LatexCommand \index{abstract aspect}
2054
\begin_inset LatexCommand \index{aspect!abstract}
2058
that can for instance be archived in an aspect library for the purpose
2060
It only require to reimplement the pointcut declaration to be pure virtual
2061
\begin_inset LatexCommand \index{pure virtual!pointcut}
2068
\begin_layout Subsubsection*
2069
Example: abstract aspect
2070
\begin_inset LatexCommand \label{exa:abstract-aspect}
2077
\begin_layout LyX-Code
2082
Counter() : m_count(0) {}
2087
virtual counted() = 0;
2094
\begin_layout Standard
2095
It is now possible to inherit from
2099
to reuse its functionality by reimplementing
2103
to refer to the actual pointcut expression.
2106
\begin_layout Subsubsection*
2107
Example: reused abstract aspect
2108
\begin_inset LatexCommand \label{exa:reused-abstract}
2115
\begin_layout LyX-Code
2116
aspect MyCounter : public Counter {
2118
pointcut counted() = derived("Shape");
2123
\begin_layout Subsubsection
2124
Aspect Instantiation
2125
\begin_inset LatexCommand \index{aspect!instantiation|(}
2132
\begin_layout Standard
2133
By default aspects in AspectC++ are automatically instantiated as global
2135
The idea behind it is that aspects can also provide global program properties
2136
and therefore have to be always accessible.
2137
However in some special cases it may be desired to change this behavior,
2139
in the context of operating systems when an aspect shall be instantiated
2140
per process or per thread.
2144
\begin_layout Standard
2145
The default instantiation scheme can be changed by defining the static method
2151
\begin_inset LatexCommand \index{aspectof@\texttt{aspectof()}}
2161
\begin_inset LatexCommand \index{aspectOf@\texttt{aspectOf()}}
2165
that is otherwise generated for an aspect.
2166
This method is intended to be always able to return an instance of the
2170
\begin_layout Subsubsection*
2171
Example: aspect instantiation using
2174
\begin_inset LatexCommand \label{exa:aspect-aspectof}
2181
\begin_layout LyX-Code
2182
aspect ThreadCounter : public Counter {
2184
pointcut counted() = "Thread";
2189
advice counted() : ThreadCounter m_instance;
2193
static ThreadCounter
2196
return tjp->target()->m_instance;
2203
\begin_layout Standard
2212
guarantees that every thread object has an instance of the aspect.
2217
it is possible to get this instance at any join point which is essential
2218
for accessing advice code and members of the aspect.
2219
For this purpose code in
2223
has full access to the actual join point in a way described in the next
2225
\begin_inset LatexCommand \index{aspect|)}
2230
\begin_inset LatexCommand \index{aspect!instantiation|)}
2237
\begin_layout Subsection
2239
\begin_inset LatexCommand \index{runtime support|(}
2246
\begin_layout Subsubsection
2247
Support for Advice Code
2248
\begin_inset LatexCommand \index{runtime support!for advice code|(}
2253
\begin_inset LatexCommand \index{advice!runtime support|(}
2260
\begin_layout Standard
2261
For many aspects access to context variables
2262
\begin_inset LatexCommand \index{context variables}
2266
may not be sufficient to get enough information about the join point where
2267
advice code was activated.
2268
For instance a control flow
2269
\begin_inset LatexCommand \index{control flow}
2273
aspect for a complete logging of function calls in a program would need
2274
information about function arguments and its types on runtime to be able
2275
to produce a type-compatible output.
2279
\begin_layout Standard
2280
In AspectC++ this information is provided by the members of the class
2285
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}}
2290
\begin_inset LatexCommand \index{runtime support!JoinPoint@\texttt{JoinPoint}}
2298
\begin_layout Standard
2307
available both in advice code and introductions
2311
\begin_layout Standard
2315
\begin_layout Standard
2319
\begin_layout Standard
2326
\begin_layout Standard
2336
\begin_layout Standard
2337
\begin_inset Tabular
2338
<lyxtabular version="3" rows="21" columns="2">
2339
<features islongtable="true">
2340
<column alignment="center" valignment="top" leftline="true" width="0cm">
2341
<column alignment="center" valignment="top" leftline="true" rightline="true" width="0cm">
2342
<row topline="true">
2343
<cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2346
\begin_layout Standard
2354
<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2357
\begin_layout Standard
2364
<row topline="true">
2365
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2368
\begin_layout Standard
2376
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2379
\begin_layout Standard
2386
<row topline="true">
2387
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2390
\begin_layout Standard
2398
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2401
\begin_layout Standard
2408
<row topline="true">
2409
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2412
\begin_layout Standard
2420
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2423
\begin_layout Standard
2430
<row topline="true">
2431
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2434
\begin_layout Standard
2442
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2445
\begin_layout Standard
2446
encoded type of an object
2452
<row topline="true" bottomline="true">
2453
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2456
\begin_layout Standard
2464
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2467
\begin_layout Standard
2474
<row topline="true">
2475
<cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2478
\begin_layout Standard
2486
<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2489
\begin_layout Standard
2496
<row topline="true">
2497
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2500
\begin_layout Standard
2508
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2511
\begin_layout Standard
2518
<row topline="true">
2519
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2522
\begin_layout Standard
2530
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2533
\begin_layout Standard
2534
typ of the function or attribute
2540
<row topline="true">
2541
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2544
\begin_layout Standard
2547
AC::Type argtype(int)
2552
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2555
\begin_layout Standard
2556
types of the arguments
2562
<row topline="true">
2563
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2566
\begin_layout Standard
2569
const char *signature()
2574
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2577
\begin_layout Standard
2578
signature of the function or attribute
2584
<row topline="true">
2585
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2588
\begin_layout Standard
2596
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2599
\begin_layout Standard
2600
identification of the join point
2606
<row topline="true">
2607
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2610
\begin_layout Standard
2613
AC::Type resulttype()
2618
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2621
\begin_layout Standard
2628
<row topline="true" bottomline="true">
2629
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2632
\begin_layout Standard
2640
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2643
\begin_layout Standard
2650
<row topline="true">
2651
<cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2654
\begin_layout Standard
2662
<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2665
\begin_layout Standard
2672
<row topline="true">
2673
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2676
\begin_layout Standard
2684
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2687
\begin_layout Standard
2694
<row topline="true">
2695
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2698
\begin_layout Standard
2706
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2709
\begin_layout Standard
2716
<row topline="true">
2717
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2720
\begin_layout Standard
2728
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2731
\begin_layout Standard
2732
object refered to by
2741
<row topline="true">
2742
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2745
\begin_layout Standard
2753
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2756
\begin_layout Standard
2757
target object of a call
2763
<row topline="true">
2764
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2767
\begin_layout Standard
2775
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2778
\begin_layout Standard
2779
execute join point code
2785
<row topline="true" bottomline="true">
2786
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2789
\begin_layout Standard
2792
AC::Action &action()
2797
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2800
\begin_layout Standard
2818
\begin_layout Standard
2820
Table 1: API of class
2824
available in advice code
2827
\begin_layout Standard
2828
Types and static methods of the
2832
API deliver information that is the same for every advice code activation.
2833
The non-static methods deliver information that differ from one activation
2835
These methods are accessed by the object
2840
\begin_inset LatexCommand \index{tjp@\texttt{tjp}}
2845
\begin_inset LatexCommand \index{runtime support!thisJoinPoint@\texttt{thisJoinPoint}}
2855
\begin_inset LatexCommand \index{thisJoinPoint@\texttt{thisJoinPoint}}
2860
\begin_inset LatexCommand \index{runtime support!thisJoinPoint@\texttt{thisJoinPoint}}
2868
and is always available in advice code
2872
\begin_layout Standard
2885
\begin_layout Standard
2889
\begin_layout Standard
2893
\begin_layout Standard
2900
\begin_layout Standard
2909
\begin_layout Standard
2910
The following example illustrates how to implement a re-usable control flow
2911
\begin_inset LatexCommand \index{control flow}
2923
\begin_layout Subsubsection*
2924
Example: re-usable trace aspect
2925
\begin_inset LatexCommand \label{exa:re-usable-trace}
2932
\begin_layout LyX-Code
2935
pointcut virtual methods() = 0;
2939
advice execution(methods())
2942
cout << "before " << JoinPoint::signature() << "(";
2945
\begin_layout LyX-Code
2946
for (unsigned i = 0; i < JoinPoint::args(); i++)
2948
printvalue(tjp->arg(i)
2949
, JoinPoint::argtype(i));
2951
cout << ")" << endl;
2959
cout << "after" << endl;
2966
\begin_layout Standard
2967
This aspect weaves tracing code into every function specified by the virtual
2969
\begin_inset LatexCommand \index{pure virtual!pointcut}
2973
redefined in a derived aspect.
2978
is responsible for the formated output of the arguments given at the function
2984
for every argument the program code of the actual join point is executed
2990
\begin_inset LatexCommand \index{proceed@\texttt{proceed()}}
2995
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!proceed()@\texttt{proceed()}}
3004
The functionality of
3008
is achieved by making use of the so-called actions.
3011
\begin_layout Subsubsection
3013
\begin_inset LatexCommand \index{action|(}
3018
\begin_inset LatexCommand \index{runtime support!action|(}
3025
\begin_layout Standard
3026
In AspectC++ an action is the statement sequence that would follow a reached
3027
join point in a running program if advice code would not have been activated.
3033
\begin_inset LatexCommand \index{proceed@\texttt{proceed()}}
3038
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!proceed()@\texttt{proceed()}}
3042
triggers the execution of the program code of a join point.
3043
This can be the call or execution of a function
3047
\begin_layout Standard
3056
as well as the writing or reading of attributes or variables
3060
\begin_layout Standard
3064
\begin_layout Standard
3068
\begin_layout Standard
3075
\begin_layout Standard
3082
The actions concept is realized in the
3096
\begin_inset LatexCommand \index{trigger@\texttt{trigger()}}
3101
\begin_inset LatexCommand \index{action!trigger@\texttt{trigger()}}
3109
may also be replaced by
3111
tjp->action().trigger()
3119
\begin_inset LatexCommand \index{action@\texttt{action()}}
3124
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!action@\texttt{action()}}
3133
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}}
3138
\begin_inset LatexCommand \index{runtime support!JoinPoint@\texttt{JoinPoint}}
3142
API returns the actual action object for a join point.
3143
\begin_inset LatexCommand \index{runtime support!for advice code|)}
3148
\begin_inset LatexCommand \index{advice!runtime support|)}
3153
\begin_inset LatexCommand \index{action|)}
3158
\begin_inset LatexCommand \index{runtime support!action|)}
3165
\begin_layout Standard
3169
\begin_layout Standard
3181
\begin_layout Subsubsection
3182
Support for Introductions
3183
\begin_inset LatexCommand \index{runtime support!for introductions|(}
3188
\begin_inset LatexCommand \index{introduction!runtime support|(}
3195
\begin_layout Standard
3200
API available in code introduced by an introduction is listed in the following
3204
\begin_layout Standard
3205
\begin_inset Float table
3211
\begin_layout Standard
3213
\begin_inset Tabular
3214
<lyxtabular version="3" rows="6" columns="2">
3216
<column alignment="center" valignment="top" leftline="true" width="0pt">
3217
<column alignment="center" valignment="top" leftline="true" rightline="true" width="0cm">
3218
<row topline="true">
3219
<cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3222
\begin_layout Standard
3230
<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3233
\begin_layout Standard
3240
<row topline="true">
3241
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3244
\begin_layout Standard
3247
const char *signature()
3252
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3255
\begin_layout Standard
3256
signature of the function or attribute
3262
<row topline="true">
3263
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3266
\begin_layout Standard
3274
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3277
\begin_layout Standard
3278
identification of the join point
3284
<row topline="true">
3285
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3288
\begin_layout Standard
3296
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3299
\begin_layout Standard
3306
<row topline="true">
3307
<cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3310
\begin_layout Standard
3318
<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3321
\begin_layout Standard
3328
<row topline="true" bottomline="true">
3329
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3332
\begin_layout Standard
3340
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3343
\begin_layout Standard
3357
\begin_layout Caption
3362
API for introductions
3370
\begin_layout Standard
3371
In difference to the API available for advice code the API for introduction
3372
only provides static information about a join point.
3373
A nice demonstration of this API is shown in the following example.
3376
\begin_layout Subsubsection*
3377
Example: static type identification using introductions
3378
\begin_inset LatexCommand \label{exa:static-type-id}
3385
\begin_layout LyX-Code
3388
pointcut virtual typed() = 0;
3392
advice typed() : static
3393
unsigned type_id() {
3395
return JoinPoint::id();
3402
virtual unsigned type() {
3411
\begin_layout Standard
3412
The first introduction of this aspect introduces a static method
3416
into a set of classes returning an unique integer value.
3417
By introducing a second non-static but virtual method type into these classes
3418
also returning the unique integer value a type identification can be realized
3422
\begin_layout LyX-Code
3423
if (obj->type() == AClass::type_id())
3427
else if (obj->type() == AnotherClass::typ
3433
\begin_layout Standard
3434
This implements a nice alternative to the C++ RTTI mechanism especially
3435
when the RTTI support of a compiler is switched off.
3439
\begin_layout Standard
3440
Code of introductions have to use the type
3445
\begin_inset LatexCommand \index{Aspect@\texttt{Aspect}}
3450
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!Aspect@\texttt{Aspect}}
3454
to get access to the methods and attributes of an aspect, e.g.\InsetSpace ~
3461
Because the static function
3466
\begin_inset LatexCommand \index{aspectof@\texttt{aspectof()}}
3470
is always generated for an aspect, except when it is already explicitly
3475
always returns the actual aspect instance.
3476
By courtesy of this technique the example
3477
\begin_inset LatexCommand \vpageref{exa:aspect-decl}
3481
can be changed to provide not only the count of all threads but to provide
3482
a count for every thread.
3485
\begin_layout Subsubsection*
3487
\begin_inset LatexCommand \label{exa:extended-thread}
3491
extended thread counting
3492
\begin_inset LatexCommand \index{runtime support|)}
3497
\begin_inset LatexCommand \index{runtime support!for introductions|)}
3502
\begin_inset LatexCommand \index{introduction!runtime support|)}
3509
\begin_layout LyX-Code
3516
advice counted() : class Helper {
3519
Helper() { Aspect::aspectof()->m_count++; }
3528
\begin_layout Standard
3532
\begin_layout Standard
3536
\begin_layout Standard
3540
\begin_layout Standard
3547
\begin_layout Standard
3556
\begin_layout Section
3557
\begin_inset LatexCommand \label{sec:Match-Expressions}
3562
\begin_inset LatexCommand \index{match expression|(}
3567
\begin_inset LatexCommand \index{search pattern!match expression|(}
3574
\begin_layout Standard
3575
Match expressions are a used to describe a set of statically known program
3576
entities in an AspectC++ program.
3577
They can either be match expressions for functions or for types.
3578
A class is seen as a special kind of type in this context.
3582
\begin_layout Standard
3583
For function matching a match expression is internally decomposed into the
3584
function type pattern
3585
\begin_inset LatexCommand \index{type pattern}
3590
\begin_inset LatexCommand \index{scope pattern}
3594
, and the name pattern
3595
\begin_inset LatexCommand \index{name pattern}
3602
\begin_layout Subsubsection*
3603
Example: type, scope, and name parts of a function match expression
3606
\begin_inset LatexCommand \label{exa:match-expr-parts}
3613
\begin_layout LyX-Code
3614
"const % Puma::...::parse_% (Token *)"
3617
\begin_layout Standard
3618
This match expression describes the following requirements on a compared
3622
\begin_layout Description
3623
name: the function name has to match the name pattern
3628
\begin_layout Description
3629
scope: the scope in which the function is defined has to match
3634
\begin_layout Description
3635
type: the function type has to match
3640
\begin_layout Standard
3641
For classes and other types this decomposion is not necessary.
3642
For example, the type name
3643
\begin_inset Quotes eld
3651
\begin_inset Quotes erd
3654
is sufficient to describe a class, because this is the same as the class
3658
\begin_layout Standard
3659
If an entity matches all parts of the match expression, it becomes an element
3660
of the set, which should be defined by the match expression.
3663
\begin_layout Standard
3664
The grammar used for match expression parsing is shown in appendix
3665
\begin_inset LatexCommand \vref{sec:Match-Expression-Grammar}
3670
The following subsections separately describe the name, scope, and type
3671
matching mechanisms.
3672
Note, that name and scope matching is used for matching of function names
3673
as well as matching of named types like classes.
3676
\begin_layout Subsection
3677
\begin_inset LatexCommand \label{sub:Name-Matching}
3682
\begin_inset LatexCommand \index{match expression!name matching|(}
3687
\begin_inset LatexCommand \index{name matching|(}
3694
\begin_layout Subsubsection
3695
Simple Name Matching
3698
\begin_layout Standard
3699
Name matching is trivial as long as the compared name is a normal C++ identifier.
3705
\begin_inset LatexCommand \index{name pattern}
3713
contain the special wildcard character %
3714
\begin_inset LatexCommand \index{\%}
3718
, it matches a name only if it is exactly the same.
3719
Otherwise each wildcard character matches an arbitrary sequence of characters
3720
in the compared name.
3721
The wildcard character also matches an empty sequence.
3724
\begin_layout Subsubsection*
3725
Example: simple name patterns
3728
\begin_inset LatexCommand \label{exa:match-name-patterns}
3735
\begin_inset LatexCommand \index{match expression!simple name pattern}
3740
\begin_inset LatexCommand \index{simple name pattern}
3747
\begin_layout Standard
3748
\begin_inset Tabular
3749
<lyxtabular version="3" rows="5" columns="2">
3751
<column alignment="left" valignment="top" width="0">
3752
<column alignment="block" valignment="top" width="12cm">
3754
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3757
\begin_layout Standard
3765
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3768
\begin_layout Standard
3778
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3781
\begin_layout Standard
3789
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3792
\begin_layout Standard
3800
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3803
\begin_layout Standard
3811
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3814
\begin_layout Standard
3815
matches any name beginning with
3832
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3835
\begin_layout Standard
3843
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3846
\begin_layout Standard
3853
parse_private_identifier
3862
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3865
\begin_layout Standard
3873
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3876
\begin_layout Standard
3877
matches all names that end with
3902
\begin_inset VSpace bigskip
3908
\begin_layout Subsubsection
3909
Operator Function and Conversion Function Name Matching
3912
\begin_layout Standard
3913
The name matching mechanism is more complicated if the pattern is compared
3914
with the name of a conversion function or an operator function.
3915
Both are matched by the name pattern
3920
\begin_inset LatexCommand \index{\%}
3925
However, with a different name pattern than
3929
they are only matched if the pattern begins with "
3937
operator\InsetSpace ~
3940
" matches any operator function or conversion function name.
3943
\begin_layout Standard
3944
C++ defines a fixed set of operators which are allowed to be overloaded.
3945
In a name pattern the same operators may be used after the "
3950
" prefix to match a specific operator function name.
3951
Operator names in name patterns are not allowed to contain the wildcard
3953
For ambiguity resolution the operators
3970
\begin_inset LatexCommand \index{\%\%}
3977
\begin_layout Subsubsection*
3978
Example: operator name patterns
3979
\begin_inset LatexCommand \index{match expression!operator name pattern}
3984
\begin_inset LatexCommand \index{operator name pattern}
3991
\begin_inset LatexCommand \label{exa:match-operator-name-patterns}
3998
\begin_layout Standard
3999
\begin_inset Tabular
4000
<lyxtabular version="3" rows="3" columns="2">
4002
<column alignment="left" valignment="top" width="0">
4003
<column alignment="block" valignment="top" width="11cm">
4005
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4008
\begin_layout Standard
4011
operator\InsetSpace ~
4017
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4020
\begin_layout Standard
4021
matches any operator function name (as well as any conversion function name)
4028
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4031
\begin_layout Standard
4034
operator\InsetSpace ~
4040
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4043
\begin_layout Standard
4044
matches only the name of a
4055
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4058
\begin_layout Standard
4061
operator\InsetSpace ~
4067
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4070
\begin_layout Standard
4071
matches the name of an
4073
operator\InsetSpace ~
4085
\begin_inset VSpace bigskip
4091
\begin_layout Standard
4092
Conversion functions don't have a real name.
4093
For example, the conversion function
4101
defines a conversion from a
4105
instance into an object of type
4110
To match conversion functions the name pattern may contain a type pattern
4116
The type matching mechanism is explained in section
4117
\begin_inset LatexCommand \ref{sub:Type-Matching}
4124
\begin_layout Subsubsection*
4125
Example: conversion function name patterns
4126
\begin_inset LatexCommand \index{match expression!conversion function name pattern}
4131
\begin_inset LatexCommand \index{conversion function name pattern}
4138
\begin_inset LatexCommand \label{exa:match-conversion-function-name-patterns}
4145
\begin_layout Standard
4146
\begin_inset Tabular
4147
<lyxtabular version="3" rows="3" columns="2">
4149
<column alignment="left" valignment="top" width="0">
4150
<column alignment="block" valignment="top" width="11cm">
4152
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4155
\begin_layout Standard
4158
operator\InsetSpace ~
4164
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4167
\begin_layout Standard
4168
matches any conversion function name
4175
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4178
\begin_layout Standard
4181
operator\InsetSpace ~
4187
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4190
\begin_layout Standard
4191
matches any name of a conversion that converts something into an
4202
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4205
\begin_layout Standard
4208
operator\InsetSpace ~
4214
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4217
\begin_layout Standard
4218
matches any conversion function name if that function converts something
4230
\begin_inset VSpace bigskip
4236
\begin_layout Subsubsection
4237
Constructors and Destructors
4240
\begin_layout Standard
4241
Name patterns cannot be used to match constructor or destructor names.
4244
\begin_layout Subsubsection
4248
\begin_layout Standard
4249
In a match expression a name pattern can optionally be prefixed by a scope
4251
A scope pattern (see section
4252
\begin_inset LatexCommand \ref{sub:Scope-Matching}
4256
) is used to describe restrictions on the definition scope of matched entities.
4257
If no scope pattern is given, a compared function or type has to be defined
4258
in the global scope to be matched.
4259
\begin_inset LatexCommand \index{name matching|)}
4264
\begin_inset LatexCommand \index{match expression!name matching|)}
4269
\begin_inset VSpace bigskip
4275
\begin_layout Subsection
4276
\begin_inset LatexCommand \label{sub:Scope-Matching}
4281
\begin_inset LatexCommand \index{match expression!scope matching|(}
4286
\begin_inset LatexCommand \index{scope matching|(}
4293
\begin_layout Standard
4294
Restrictions on definition scopes can be described by
4299
\begin_inset LatexCommand \index{scope pattern}
4304
This is a sequence of name patterns (or the special
4309
\begin_inset LatexCommand \index{any scope sequence}
4318
\begin_inset LatexCommand \index{...}
4322
), which are separated by
4331
A scope pattern always ends with
4335
and should never start with
4339
, because scope patterns are interpreted relative to the global scope anyway
4343
\begin_layout Standard
4344
This restriction is also needed to avoid ambiguities in the match expression
4346
\begin_inset Quotes eld
4358
\begin_inset Quotes erd
4362
\begin_inset Quotes eld
4371
\begin_inset Quotes erd
4375
\begin_inset Quotes eld
4384
\begin_inset Quotes erd
4393
The definition scope can either be a namespace or a class.
4396
\begin_layout Standard
4397
A scope pattern matches the definition scope of a compared function or type
4398
if every part can successfully be matched with a corresponding part in
4399
the qualified name of the definition scope.
4400
The compared qualified name has to be relative to the global scope and
4401
should not start with
4405
, which is optional in a C++ nested-name-specifier.
4411
pattern matches any (even empty) sequence of scope names.
4414
\begin_layout Subsubsection*
4415
Example: scope patterns
4418
\begin_inset LatexCommand \label{exa:match-scope-patterns}
4425
\begin_inset LatexCommand \index{match expression!scope pattern}
4430
\begin_inset LatexCommand \index{scope pattern}
4437
\begin_layout Standard
4438
\begin_inset Tabular
4439
<lyxtabular version="3" rows="4" columns="2">
4441
<column alignment="left" valignment="top" width="0">
4442
<column alignment="block" valignment="top" width="11cm">
4444
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4447
\begin_layout Standard
4455
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4458
\begin_layout Standard
4459
matches any definition scope, even the global scope
4466
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4469
\begin_layout Standard
4477
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4480
\begin_layout Standard
4492
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4495
\begin_layout Standard
4503
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4506
\begin_layout Standard
4507
matches any class or namespace, which matches the name pattern
4518
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4521
\begin_layout Standard
4529
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4532
\begin_layout Standard
4533
matches any scope defined within the class or namespace
4552
\begin_inset LatexCommand \index{scope matching|)}
4557
\begin_inset LatexCommand \index{match expression!scope matching|)}
4562
\begin_inset VSpace bigskip
4568
\begin_layout Subsection
4569
\begin_inset LatexCommand \label{sub:Type-Matching}
4574
\begin_inset LatexCommand \index{match expression!type matching|(}
4579
\begin_inset LatexCommand \index{type matching|(}
4586
\begin_layout Subsubsection
4590
\begin_layout Standard
4591
C++ types can be represented as a tree.
4592
For example, the function type
4596
is a function type node with two children, one is an
4605
Both children are leafs of the tree.
4608
\begin_layout Standard
4609
The types used in match expressions can also be interpreted as trees.
4610
As an addition to normal C++ types they can also contain the %
4611
\begin_inset LatexCommand \index{\%}
4615
wildcard character, name patterns, and scope patterns.
4616
A single wildcard character in a type pattern becomes a special
4621
\begin_inset LatexCommand \index{any type node}
4625
in the tree representation.
4628
\begin_layout Standard
4629
For comparing a type pattern with a specific type the tree representation
4634
matches an arbitrary type (sub-)tree.
4638
\begin_layout Subsubsection*
4639
Example: type patterns with the wildcard character
4642
\begin_inset LatexCommand \label{exa:match-type-patterns-wildcard}
4649
\begin_inset LatexCommand \index{match expression!type pattern with \%}
4654
\begin_inset LatexCommand \index{type pattern with \%}
4661
\begin_layout Standard
4662
\begin_inset Tabular
4663
<lyxtabular version="3" rows="3" columns="2">
4665
<column alignment="left" valignment="top" width="0">
4666
<column alignment="block" valignment="top" width="11cm">
4668
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4671
\begin_layout Standard
4679
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4682
\begin_layout Standard
4690
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4693
\begin_layout Standard
4701
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4704
\begin_layout Standard
4705
matches any pointer type that points to functions with a single argument
4717
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4720
\begin_layout Standard
4726
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4729
\begin_layout Standard
4730
matches any pointer type
4741
\begin_inset VSpace bigskip
4747
\begin_layout Subsubsection
4748
Matching of Named Types
4751
\begin_layout Standard
4752
Type patterns may also contain name and scope patterns.
4756
\begin_inset LatexCommand \index{named type}
4762
in the tree representation and match any union, struct, class, or enumeration
4763
type if its name and scope match the given pattern (see section
4764
\begin_inset LatexCommand \ref{sub:Name-Matching}
4769
\begin_inset LatexCommand \ref{sub:Scope-Matching}
4776
\begin_layout Subsubsection
4778
\begin_inset Quotes eld
4782
\begin_inset Quotes erd
4788
\begin_layout Standard
4789
Patterns for pointers to members
4790
\begin_inset LatexCommand \index{pointer to member}
4794
also contain a scope pattern, e.g.
4798
(Puma::CSyntax::*)()
4801
In this context the scope pattern is mandatory.
4802
The pattern is used for matching the class associated with a pointer to
4806
\begin_layout Subsubsection
4807
Matching of Qualified Types (
4818
\begin_layout Standard
4819
Many C++ types can be qualified as
4824
\begin_inset LatexCommand \index{const}
4833
\begin_inset LatexCommand \index{volatile}
4838
In a type pattern these qualifier can also be used, but they are interpreted
4848
qualifier is given in a type pattern, the pattern also matches qualified
4853
\begin_layout Standard
4854
Matching only non-constant or non-volatile types can be achieved by using
4855
the operators explained in section
4856
\begin_inset LatexCommand \vref{sub:Algebraic-Operators}
4863
!"const\InsetSpace ~
4866
describes all types which are not constant.
4874
\begin_layout Subsubsection*
4875
Example: type patterns with
4886
\begin_inset LatexCommand \label{exa:match-type-patterns-cv}
4893
\begin_inset LatexCommand \index{match expression!type pattern with cv qualifier}
4898
\begin_inset LatexCommand \index{type pattern with cv qualifier}
4905
\begin_layout Standard
4906
\begin_inset Tabular
4907
<lyxtabular version="3" rows="3" columns="2">
4909
<column alignment="left" valignment="top" width="0">
4910
<column alignment="block" valignment="top" width="9cm">
4912
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4915
\begin_layout Standard
4923
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4926
\begin_layout Standard
4927
matches any type, even types qualified with
4942
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4945
\begin_layout Standard
4953
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4956
\begin_layout Standard
4957
matches only types qualified by
4966
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4969
\begin_layout Standard
4972
% (*)() const volatile
4977
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4980
\begin_layout Standard
4981
matches the type of all pointers to functions that are qualified by
4998
\begin_inset VSpace bigskip
5004
\begin_layout Subsubsection
5005
Handling of Conversion Function Types
5008
\begin_layout Standard
5009
The result type of conversion functions is interpreted as a special
5013
type in type patterns as well as in compared types.
5019
\begin_inset LatexCommand \index{undefined type}
5023
type is only matched by the
5034
\begin_layout Subsubsection
5035
Ellipses in Function Type Patterns
5038
\begin_layout Standard
5039
In the list of function argument types the type pattern
5045
\begin_inset LatexCommand \index{...}
5049
can be used to match an arbitrary (even empty) list of types.
5055
pattern should not be followed by other argument type patterns in the list
5059
\begin_layout Subsubsection
5060
Matching of Virtual Functions
5063
\begin_layout Standard
5068
of a function type match expression may include the keyword
5075
In this case the function type match expression only matches virtual or
5076
pure virtual member functions.
5095
keyword is regarded as a restriction.
5096
This means that a function type match expression without
5102
matches virtual and non-virtual functions.
5105
\begin_layout Subsubsection*
5106
Example: type patterns with
5113
\begin_inset LatexCommand \label{exa:match-type-patterns-virtual}
5120
\begin_inset LatexCommand \index{match expression!type pattern with virtual keyword}
5125
\begin_inset LatexCommand \index{type pattern with virtual keyword}
5132
\begin_layout Standard
5133
\begin_inset Tabular
5134
<lyxtabular version="3" rows="2" columns="2">
5136
<column alignment="left" valignment="top" width="0">
5137
<column alignment="block" valignment="top" width="9cm">
5139
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5142
\begin_layout Standard
5145
virtual % ...::%(...)
5150
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
5153
\begin_layout Standard
5154
matches all virtual or pure virtual functions in any scope
5161
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5164
\begin_layout Standard
5172
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
5175
\begin_layout Standard
5176
matches all member functions of C, even if they are virtual
5187
\begin_inset VSpace bigskip
5193
\begin_layout Subsubsection
5194
Argument Type Adjustment
5197
\begin_layout Standard
5199
\begin_inset LatexCommand \index{argument types}
5203
in type patterns are adjusted according to the usual C++ rules, i.e.
5204
array and function types are converted to pointers to the given type and
5213
qualifiers are removed.
5214
Futhermore, argument type lists containing a single
5218
type are converted into an empty argument type list.
5219
\begin_inset LatexCommand \index{type matching|)}
5224
\begin_inset LatexCommand \index{match expression!type matching|)}
5231
\begin_layout Description
5232
\begin_inset LatexCommand \index{match expression|)}
5237
\begin_inset LatexCommand \index{search pattern!match expression|)}
5244
\begin_layout Section
5245
Predefined Pointcut Functions
5246
\begin_inset LatexCommand \label{sec:Predefined}
5251
\begin_inset LatexCommand \index{pointcut function|(}
5256
\begin_inset LatexCommand \index{pointcut!function|(}
5263
\begin_layout Standard
5264
On the following pages a complete list of the pointcut functions supported
5265
by AspectC++ is presented.
5266
For every pointcut function it is indicated which type of pointcut is expected
5267
as argument(s) and of which type the result pointcut is.
5269
\begin_inset Quotes eld
5273
\begin_inset Quotes erd
5276
stands for name pointcut and
5277
\begin_inset Quotes eld
5281
\begin_inset Quotes erd
5285
The optionally given index is an assurance about the type of join point(s)
5286
described by the result pointcut
5290
\begin_layout Standard
5292
\begin_inset Formula $_{\textrm{C}}$
5296
\begin_inset Formula $_{\textrm{E}}$
5300
\begin_inset Formula $_{\textrm{S}}$
5304
\begin_inset Formula $_{\textrm{G}}$
5336
\begin_inset Formula $_{N}$
5340
\begin_inset Formula $_{C}$
5344
\begin_inset Formula $_{F}$
5348
\begin_inset Formula $_{T}$
5388
\begin_layout Subsection
5392
\begin_layout Description
5405
\begin_inset LatexCommand \index{base@\texttt{base()}}
5410
\begin_inset LatexCommand \index{pointcut function!base@\texttt{base()}}
5418
\begin_layout Standard
5428
\begin_inset Formula $\rightarrow$
5432
\begin_inset Formula $_{C,F}$
5437
returns all base classes
5441
\begin_layout Standard
5455
\begin_layout Standard
5459
\begin_layout Standard
5463
\begin_layout Standard
5470
\begin_layout Standard
5476
of classes in the pointcut
5479
\begin_layout Description
5492
\begin_inset LatexCommand \index{derived@\texttt{derived()}}
5497
\begin_inset LatexCommand \index{pointcut function!derived@\texttt{derived()}}
5505
\begin_layout Standard
5515
\begin_inset Formula $\rightarrow$
5519
\begin_inset Formula $_{C,F}$
5524
returns all classes in the pointcut and all classes derived from them
5528
\begin_layout Standard
5538
all redefined functions of derived classes
5542
\begin_layout Standard
5546
\begin_layout Standard
5550
\begin_layout Standard
5557
\begin_layout Standard
5566
\begin_layout Subsubsection*
5567
Example: type matching
5568
\begin_inset LatexCommand \label{exa:type-matching}
5575
\begin_layout Standard
5576
A software may contain the following class hierarchy.
5580
\begin_layout LyX-Code
5584
class Point : public Shape { ...
5589
class Rectangle : public Line, public Rotatable { ...
5593
\begin_layout Standard
5594
With the following aspect a special feature is added to a designated set
5595
of classes of this class hierarchy.
5598
\begin_layout LyX-Code
5601
pointcut scalable() =
5603
(base("Rectangle") && derived("Point")
5608
advice "Point" : baseclass("Scalable");
5611
: void scale(int value) { ...
5617
\begin_layout Standard
5618
The pointcut describes the classes
5626
and all classes derived from
5630
that are direct or indirect base classes of
5635
With the first advice
5639
gets a new base class.
5640
The second advice adds a corresponding method to all classes in the pointcut.
5643
\begin_layout Subsection
5645
\begin_inset LatexCommand \index{control flow|(}
5652
\begin_layout Description
5665
\begin_inset LatexCommand \index{cflow@\texttt{cflow()}}
5670
\begin_inset LatexCommand \index{pointcut function!cflow@\texttt{cflow()}}
5678
\begin_layout Standard
5688
\begin_inset Formula $\rightarrow$
5693
captures join points occuring in the dynamic execution context of join
5694
points in the pointcut.
5695
Currently the language features being used in the argument pointcut are
5697
The argument ist not allowed to contain any context variable bindings (see
5699
\begin_inset LatexCommand \ref{sub:context}
5703
) or other pointcut functions which have to be evaluated at runtime like
5715
\begin_layout Subsubsection*
5716
Example: control flow dependant advice activation
5717
\begin_inset LatexCommand \label{exa:control-flow}
5724
\begin_layout Standard
5725
The following example demonstrates the use of the
5732
\begin_layout LyX-Code
5735
void out (unsigned char);
5737
unsigned char in ();
5742
\begin_layout Standard
5748
It might be part of an operating system kernel and is used there to access
5749
peripheral devices via a special I/O bus.
5750
The execution of the member functions
5758
should not be interrupted, because this would break the timing of the bus
5760
Therefore, we decide to implement an interrupt synchronization aspect that
5761
disables interrupts during the execution of in() and out():
5764
\begin_layout LyX-Code
5767
pointcut critical() = execution("% Bus::%(...)");
5770
critical() && !cflow(execution("% os::int_handler()")) :
5786
\begin_layout Standard
5787
As the bus driver code might also be called from an interrupt handler, the
5788
interrupts should not be disabled in any case.
5789
Therefore, the pointcut expression exploits the
5793
pointcut function to add a runtime condition for the advice activation.
5794
The advice body should only be executed if the control flow did not come
5795
from the interrupt handler
5799
, because it is not interruptable by definition and
5803
in the advice body would turn on the interrupts too early.
5804
\begin_inset LatexCommand \index{control flow|)}
5811
\begin_layout Subsection
5815
\begin_layout Description
5828
\begin_inset LatexCommand \index{within@\texttt{within()}}
5833
\begin_inset LatexCommand \index{pointcut function!within@\texttt{within()}}
5841
\begin_layout Standard
5851
\begin_inset Formula $\rightarrow$
5856
filters all join points that are within the functions or classes in the
5860
\begin_layout Subsubsection*
5861
Example: matching in scopes
5862
\begin_inset LatexCommand \label{exa:matching-in-scopes}
5869
\begin_layout LyX-Code
5874
call("void transmit()") && within("Trans
5879
advice calls() : around() {
5881
cout << "transmitting ...
5886
cout << "finished." << endl;
5893
\begin_layout Standard
5894
This aspect inserts code logging all calls to
5898
that are within the methods of class
5906
\begin_layout Subsection
5910
\begin_layout Description
5923
\begin_inset LatexCommand \index{call@\texttt{call()}}
5928
\begin_inset LatexCommand \index{pointcut function!call@\texttt{call()}}
5936
\begin_layout Standard
5946
\begin_inset Formula $\rightarrow$
5950
\begin_inset Formula $_{C}$
5955
Provides all join points where a named entity in the pointcut is called.
5956
The pointcut may contain function names or class names.
5957
In the case of a class name all calls to methods of that class are provided.
5960
\begin_layout Description
5973
\begin_inset LatexCommand \index{execution@\texttt{execution()}}
5978
\begin_inset LatexCommand \index{pointcut function!execution@\texttt{execution()}}
5986
\begin_layout Standard
5996
\begin_inset Formula $\rightarrow$
6000
\begin_inset Formula $_{E}$
6005
provides all join points referring to the implementation of a named entity
6007
The pointcut may contain function names or class names.
6008
In the case of a class name all implementations of methods of that class
6012
\begin_layout Subsubsection*
6013
Example: function matching
6014
\begin_inset LatexCommand \label{exa:function-matching}
6021
\begin_layout Standard
6022
The following aspect weaves debugging code into a program that checks whether
6023
a method is called on a null pointer and whether the argument of the call
6027
\begin_layout LyX-Code
6030
pointcut fct() = "% MemPool::dealloc(void*)";
6033
exec() = execution(fct());
6035
pointcut calls() = call(fct());
6040
&& args(ptr) : before(void *ptr) {
6042
assert(ptr && "argument is NULL");
6047
advice calls() : before() {
6049
assert(tjp->target() && "'this' is NULL");
6057
\begin_layout Standard
6058
The first advice provides code to check the argument of the function
6062
before the function is executed.
6067
is called on a null object is provided by the second advice.
6068
This is realized by checking the target of the call.
6071
\begin_layout Subsection
6072
Object Construction and Destruction
6075
\begin_layout Description
6088
\begin_inset LatexCommand \index{construction@\texttt{construction()}}
6093
\begin_inset LatexCommand \index{pointcut function!construction@\texttt{construction()}}
6101
\begin_layout Standard
6111
\begin_inset Formula $\rightarrow$
6115
\begin_inset Formula $_{Cons}$
6120
all join points where an instance of the given class(es) is constructed.
6121
The construction joinpoint begins after all base class and member construction
6123
It can be imagined as the execution of the constructor.
6124
However, advice for construction joinpoints work, even if there is no construct
6125
or defined explicitly.
6126
A construction joinpoint has arguments and argument types, which can be
6127
exposed or filtered, e.g.
6135
\begin_layout Description
6148
\begin_inset LatexCommand \index{destruction@\texttt{destruction()}}
6153
\begin_inset LatexCommand \index{pointcut function!destruction@\texttt{destruction()}}
6161
\begin_layout Standard
6171
\begin_inset Formula $\rightarrow$
6175
\begin_inset Formula $_{Des}$
6180
all join points where an instance of the given class(es) is destructed.
6181
The destruction joinpoint ends before the destruction joinpoint of all
6182
members and base classes.
6183
It can be imagined as the execution of the destructor, although a destructor
6184
does not to be defined explicitly.
6185
A destruction joinpoint has an empty argument list.
6188
\begin_layout Subsubsection*
6189
Example: instance counting
6190
\begin_inset LatexCommand \label{exa:instance-counting}
6197
\begin_layout Standard
6198
The following aspect counts how many instances of the class
6202
are created and destroyed.
6205
\begin_layout LyX-Code
6206
aspect InstanceCounting {
6208
// the class for which instances should be counted
6211
pointcut observed() = "ClassOfInterest";
6213
// count constructions and
6216
advice construction (observed ()) : before () { _created++;
6219
advice destruction (observed ()) : after () { _destroyed++; }
6224
// Singleton aspects can have a default constructor
6227
() { _created = _destroyed = 0; }
6234
\begin_layout LyX-Code
6238
\begin_layout LyX-Code
6242
\begin_layout LyX-Code
6246
\begin_layout Standard
6247
The implementation of this aspect is straightforward.
6248
Two counters are initialized by the aspect constructor and incremented
6249
by the construction/destruction advice.
6254
as a pure virtual pointcut the aspect can easily be transformed into a
6255
reusable abstract aspect.
6258
\begin_layout Standard
6262
\begin_layout Standard
6274
\begin_layout Subsection
6278
\begin_layout Standard
6287
pointcut functions are not yet implemented in the AspectC++ compiler
6290
\begin_inset LatexCommand \index{ac++@\texttt{ac++}}
6299
\begin_layout Description
6309
\begin_inset LatexCommand \index{set@\texttt{set()}}
6314
\begin_inset LatexCommand \index{pointcut function!set@\texttt{set()}}
6322
\begin_layout Standard
6332
\begin_inset Formula $\rightarrow$
6336
\begin_inset Formula $_{S}$
6341
selects all join points where the value of an attribute or global variable
6345
\begin_layout Description
6358
\begin_inset LatexCommand \index{get@\texttt{get()}}
6363
\begin_inset LatexCommand \index{pointcut function!get@\texttt{get()}}
6371
\begin_layout Standard
6381
\begin_inset Formula $\rightarrow$
6385
\begin_inset Formula $_{G}$
6390
selects all join points where the value of an attribute or global variable
6394
\begin_layout Subsubsection*
6395
Example: attribute matching
6396
\begin_inset LatexCommand \label{exa:attribute-matching}
6403
\begin_layout Standard
6407
\begin_layout Standard
6411
\begin_layout Standard
6415
\begin_layout Standard
6422
\begin_layout Standard
6431
\begin_layout Subsection
6432
\begin_inset LatexCommand \label{sub:context}
6439
\begin_layout Description
6453
\begin_inset LatexCommand \index{that@\texttt{that()}}
6458
\begin_inset LatexCommand \index{pointcut function!that@\texttt{that()}}
6466
\begin_layout Standard
6476
\begin_inset Formula $\rightarrow$
6481
returns all join points where the current C++
6485
pointer refers to an object which is an instance of a type that is compatible
6486
to the type described by the type pattern
6489
\begin_layout Description
6503
\begin_inset LatexCommand \index{target@\texttt{target()}}
6508
\begin_inset LatexCommand \index{pointcut function!target@\texttt{target()}}
6516
\begin_layout Standard
6526
\begin_inset Formula $\rightarrow$
6531
returns all join points where the target object of a call is an instance
6536
that is compatible to the type described by the type pattern
6539
\begin_layout Description
6553
\begin_inset LatexCommand \index{result@\texttt{result()}}
6558
\begin_inset LatexCommand \index{pointcut function!base@\texttt{base()}}
6566
\begin_layout Standard
6576
\begin_inset Formula $\rightarrow$
6581
returns all join points where the result object of a call/execution is
6582
an instance of a type matched by the type pattern
6585
\begin_layout Description
6600
\begin_inset LatexCommand \index{args@\texttt{args()}}
6605
\begin_inset LatexCommand \index{pointcut function!args@\texttt{args()}}
6613
\begin_layout Standard
6623
\begin_inset Formula $\rightarrow$
6628
The argument list of
6632
contains type patterns that are used to filter all joinpoints, e.g.
6633
calls to functions or function executions, with a matching signature.
6637
\begin_layout Standard
6638
Instead of the type pattern it is also possible here to pass the name of
6639
a variable to which the context information is bound (a
6644
In this case the type of the variable is used for the type matching.
6645
Context variables must be declared in the argument list of
6657
and can be used like a function argument in the advice body.
6660
\begin_layout Standard
6669
pointcut functions are special, because they might cause a run-time type
6679
functions are evaluated at compile time.
6682
\begin_layout Subsubsection*
6683
Example: context matching
6684
\begin_inset LatexCommand \label{exa:context-matching}
6691
\begin_layout Subsection
6692
\begin_inset LatexCommand \label{sub:Algebraic-Operators}
6699
\begin_layout Description
6721
\begin_layout Standard
6731
\begin_inset Formula $\rightarrow$
6735
\begin_inset Formula $\rightarrow$
6740
intersection of the join points in the pointcuts
6743
\begin_layout Description
6765
\begin_layout Standard
6775
\begin_inset Formula $\rightarrow$
6779
\begin_inset Formula $\rightarrow$
6784
union of the join points in the pointcuts
6787
\begin_layout Description
6802
\begin_layout Standard
6812
\begin_inset Formula $\rightarrow$
6816
\begin_inset Formula $\rightarrow$
6821
exclusion of the join points in the pointcut
6824
\begin_layout Subsubsection*
6826
\begin_inset LatexCommand \label{exa:combining-pointcut}
6830
combining pointcut expressions
6831
\begin_inset LatexCommand \index{pointcut function|)}
6836
\begin_inset LatexCommand \index{pointcut!function|)}
6843
\begin_layout Section
6847
\begin_layout Standard
6848
This section defines the syntax and semantics of slice declarations.
6849
The next section will describe how slices can be used by advice in order
6851
Currently, only class slices are defined in AspectC++.
6854
\begin_layout Subsection
6855
Class Slice Declarations
6858
\begin_layout Standard
6859
Class slices may be declared in any class or namespace scope.
6860
They may be defined only once, but there may be an arbitrary number forward
6862
A qualified name may be used if a class slice that is already declared
6863
in a certain scope is redeclared or defined as shown in the following example:
6866
\begin_layout LyX-Code
6870
\begin_layout LyX-Code
6874
\begin_layout LyX-Code
6875
slice class ASlice; // a different slice!
6878
\begin_layout LyX-Code
6882
\begin_layout LyX-Code
6883
slice class ASlice { // definition of the ::ASlice
6886
\begin_layout LyX-Code
6890
\begin_layout LyX-Code
6894
\begin_layout LyX-Code
6895
slice class N::ASlice { // definition of the N::ASlice
6898
\begin_layout LyX-Code
6902
\begin_layout LyX-Code
6906
\begin_layout Standard
6907
If a class slice only defines a base class, an abbreviated syntax may be
6911
\begin_layout LyX-Code
6912
slice class Chained : public Chain;
6915
\begin_layout Standard
6916
Class slices may be anonymous.
6917
However, this only makes sense as part of an advice declaration.
6918
A class slice my also be declared with the
6931
While there is no difference between class and aspect slices, the default
6932
access rights to the elements of a struct slice in the target classes are
6933
public instead of private.
6934
It is forbidden to declare aspects, pointcuts, advice, or slices as members
6938
\begin_layout Standard
6939
Class slices may have members that are not defined within the body of a
6940
class slice declaration, e.g.
6941
static attributes or non-inline functions:
6944
\begin_layout LyX-Code
6948
\begin_layout LyX-Code
6952
\begin_layout LyX-Code
6956
\begin_layout LyX-Code
6960
\begin_layout LyX-Code
6964
\begin_layout LyX-Code
6965
slice int SL::answer = 42;
6968
\begin_layout LyX-Code
6969
slice void SL::f() { ...
6973
\begin_layout Standard
6974
These external member declarations have to appear after the corresponding
6975
slice declaration in the source code.
6978
\begin_layout Section
6980
\begin_inset LatexCommand \index{advice!declaration|(}
6987
\begin_layout Standard
6988
This section describes the different types of advice offered by AspectC++.
6989
Advice be categorized in advice for join points in the dynamic control
6990
flow of the running program, e.
6992
function call or executions, and advice for static join points like introductio
6996
\begin_layout Standard
6997
In either case the compiler makes sure that the code of the aspect header
6998
file, which contains the advice definition (if this is the case), is compiled
6999
prior to the affected join point location.
7002
\begin_layout Subsection
7003
Advice for Dynamic Join Points
7006
\begin_layout Description
7015
\begin_inset LatexCommand \index{before}
7020
\begin_inset LatexCommand \index{advice!before}
7027
the advice code is executed before the join points in the pointcut
7030
\begin_layout Description
7039
\begin_inset LatexCommand \index{after}
7044
\begin_inset LatexCommand \index{advice!after}
7051
the advice code is executed after the join points in the pointcut
7054
\begin_layout Description
7063
\begin_inset LatexCommand \index{around}
7068
\begin_inset LatexCommand \index{advice!around}
7075
the advice code is executed in place of the join points in the pointcut
7078
\begin_layout Subsection
7079
Advice for Static Join Points
7082
\begin_layout Standard
7083
Static join points in AspectC++ are classes or aspects.
7084
Advice for classes or aspects can introduce new members or add a base class.
7085
Whether the new member or base class becomes
7097
in the target class depends on the protection in the advice declaration
7101
\begin_layout Description
7114
\begin_inset LatexCommand \index{baseclass}
7119
\begin_inset LatexCommand \index{advice!baseclass}
7126
a new base class is introduced to the classes in the pointcut
7129
\begin_layout Description
7132
introduction\InsetSpace ~
7136
\begin_inset LatexCommand \index{introduction declaration}
7141
\begin_inset LatexCommand \index{advice!introduction declaration}
7148
a new attribute, member function, or type is introduced
7151
\begin_layout Standard
7152
Introduction declarations are only semantically analyzed in the context
7154
Therefore, the declaration may refer, for instance, to types or constants,
7155
which are not known in the aspect definition, but only in the target class
7157
To introduce a constructor or destructor the name of the aspect, to which
7158
the introduction belongs, has to be taken as the constructor/destructor
7162
\begin_layout Standard
7165
Non-inline introductions
7167
can be used for introductions of static attributes or member function introduct
7168
ion with separate declaration an definition.
7169
The name of the introduced member has to be a qualified name in which the
7170
nested name specifier is the name of the aspect to which the introduction
7174
\begin_layout Subsubsection*
7175
\begin_inset LatexCommand \index{advice!declaration|)}
7182
\begin_layout Section
7190
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}|(}
7195
\begin_inset LatexCommand \index{runtime support!JoinPoint@\texttt{JoinPoint}|(}
7202
\begin_layout Standard
7203
The following sections provide a complete description of the
7211
\begin_layout Subsection
7215
\begin_layout Description
7224
\begin_inset LatexCommand \index{Result@\texttt{Result}}
7229
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!Result@\texttt{Result}}
7236
result type of a function
7239
\begin_layout Description
7248
\begin_inset LatexCommand \index{That@\texttt{That}}
7253
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!That@\texttt{That}}
7260
object type (object initiating a call)
7263
\begin_layout Description
7272
\begin_inset LatexCommand \index{Target@\texttt{Target}}
7277
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!Target@\texttt{Target}}
7284
target object type (target object of a call)
7288
\begin_layout Standard
7300
\begin_layout Description
7308
\begin_inset LatexCommand \index{Aspect@\texttt{Aspect}}
7313
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!Aspect@\texttt{Aspect}}
7320
type of the aspect (only available in introductions)
7324
\begin_layout Standard
7328
\begin_layout Standard
7332
\begin_layout Standard
7339
\begin_layout Standard
7348
\begin_layout Subsubsection*
7350
\begin_inset LatexCommand \label{exa:type-usage}
7357
\begin_layout Subsection
7361
\begin_layout Description
7376
\begin_inset LatexCommand \index{type@\texttt{type()}}
7381
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!type@\texttt{type()}}
7388
returns the encoded type for the join point conforming with the C++ ABI
7393
\begin_layout Standard
7397
\begin_layout Standard
7401
depref{http://www.codesourcery.com/cxx-abi/abi.html
7405
texttt{www.codesourcery.com/cxx-abi/abi.html
7420
\begin_layout Description
7435
\begin_inset LatexCommand \index{args@\texttt{args()}}
7440
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!args@\texttt{args()}}
7447
returns the number of arguments of a function for call and execution join
7451
\begin_layout Description
7471
\begin_inset LatexCommand \index{argtype@\texttt{argtype()}}
7476
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!argtype@\texttt{argtype()}}
7483
returns the encoded type of an argument conforming with the C++ ABI V3 specifica
7487
\begin_layout Description
7505
\begin_inset LatexCommand \index{signature@\texttt{signature()}}
7510
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!signature@\texttt{signature()}}
7517
gives a textual description of the join point (function name, class name,
7521
\begin_layout Description
7526
unsigned\InsetSpace ~
7539
\begin_inset LatexCommand \index{id@\texttt{id()}}
7544
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!id@\texttt{id()}}
7551
returns a unique numeric identifier for this join point
7554
\begin_layout Description
7572
\begin_inset LatexCommand \index{filename@\texttt{filename()}}
7577
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!filename@\texttt{filename()}}
7584
returns the name of the file in which the join-point (shadow) is located
7587
\begin_layout Description
7604
\begin_inset LatexCommand \index{line@\texttt{line()}}
7609
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!line@\texttt{line()}}
7616
the number of the line in which the join-point (shadow) is located
7619
\begin_layout Description
7634
\begin_inset LatexCommand \index{resulttype@\texttt{resulttype()}}
7639
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!resulttype@\texttt{resulttype()}}
7646
returns the encoded type of the result type conforming with the C++ ABI
7650
\begin_layout Description
7665
\begin_inset LatexCommand \index{jptype@\texttt{jptype()}}
7670
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!jptype@\texttt{jptype()}}
7677
returns a unique identifier describing the type of the join point
7680
\begin_layout Subsubsection*
7681
Example: static function usage
7682
\begin_inset LatexCommand \label{exa:static-function-usage}
7689
\begin_layout Description
7703
\begin_inset LatexCommand \index{arg@\texttt{arg()}}
7708
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!arg@\texttt{arg()}}
7715
returns a pointer to the memory position holding the argument value with
7721
\begin_layout Description
7736
\begin_inset LatexCommand \index{result@\texttt{result()}}
7743
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!result@\texttt{result()}}
7750
returns a pointer to the memory location designated for the result value
7751
or 0 if the function has no result value
7754
\begin_layout Description
7765
\begin_inset LatexCommand \index{that@\texttt{that()}}
7772
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!that@\texttt{that()}}
7779
returns a pointer to the object initiating a call or 0 if it is a static
7780
method or a global function
7783
\begin_layout Description
7794
\begin_inset LatexCommand \index{target@\texttt{target()}}
7801
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!target@\texttt{target()}}
7808
returns a pointer to the object that is the target of a call or 0 if it
7809
is a static method or a global function
7812
\begin_layout Description
7821
\begin_inset LatexCommand \index{proceed@\texttt{proceed()}}
7826
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!proceed()@\texttt{proceed()}}
7833
executes the original join point code in an around advice by calling
7838
\begin_layout Description
7842
AC::Action\InsetSpace ~
7847
\begin_inset LatexCommand \index{action@\texttt{action()}}
7852
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}!action@\texttt{action()}}
7859
returns the runtime action object containing the execution environment to
7860
execute the original functionality encapsulated by an around advice
7863
\begin_layout Subsubsection*
7865
\begin_inset LatexCommand \label{exa:non-static-function-usage}
7869
non-static function usage
7872
\begin_inset LatexCommand \index{JoinPoint@\texttt{JoinPoint}|)}
7877
\begin_inset LatexCommand \index{runtime support!JoinPoint@\texttt{JoinPoint}|)}
7884
\begin_layout Section
7885
\begin_inset LatexCommand \label{sec:ordering}
7890
\begin_inset LatexCommand \index{advice!ordering|(}
7897
\begin_layout Subsection
7898
\begin_inset LatexCommand \label{sub:aspect-precedence}
7903
\begin_inset LatexCommand \index{precedence!of aspects|(}
7910
\begin_layout Standard
7911
AspectC++ provides a very flexible mechanism to define aspect precedence.
7912
The precedence is used to determine the execution order of advice code
7913
if more than one aspect affect the same join point.
7914
The precedence in AspectC++ is an attribute of a join point.
7915
This means that the precedence relationship between two aspects might vary
7916
in different parts of the system.
7917
The compiler checks the following conditions to determine the precendence
7921
\begin_layout Description
7923
declaration: if the programmer provides an order declaration, which
7924
defines the precedence relationship between two aspects for a join point,
7925
the compiler will obey this definition or abort with a compile-time error
7926
if there is a cycle in the precedence graph.
7927
Order declarations have the following syntax:
7972
The argument list of
7976
has to contain at least two elements.
7977
Each element is a pointcut expression, which describes a set of aspects.
7978
Each aspect in a certain set has a higher precedence than all aspects,
7979
which are part of a set following later in the list (on the right hand
7983
("A1"||"A2","A3"||"A4")
8010
This order directive does
8014
define the relation between
8031
Of course, the pointcut expressions in the argument list of
8035
may contain named pointcuts and even pure virtual pointcuts.
8038
\begin_layout Description
8039
inheritance\InsetSpace ~
8040
relation: if there is no order declaration given and one aspect
8041
has a base aspect the derived aspect has a higher precedence than the base
8045
\begin_layout Subsection
8046
\begin_inset LatexCommand \label{sub:advice-precedence}
8051
\begin_inset LatexCommand \index{precedence!of advice|(}
8058
\begin_layout Standard
8059
The precedence of advice is determined with a very simple scheme:
8062
\begin_layout Itemize
8063
if two advice declarations belong to different aspects and there is a precedence
8064
relation between these aspects (see section
8065
\begin_inset LatexCommand \vref{sub:aspect-precedence}
8069
) the same relation will be assumed for the advice.
8072
\begin_layout Itemize
8073
if two advice declarations belong to the same aspect the one that is declared
8074
first has the higher precedence.
8077
\begin_layout Subsection
8078
Effects of Advice Precedence
8079
\begin_inset LatexCommand \index{precedence!effects|(}
8086
\begin_layout Standard
8087
Only advice predecence has an effect on the generated code.
8088
The effect depends on the kind of join point, which is affected by two
8089
advice declarations.
8092
\begin_layout Subsubsection*
8096
\begin_layout Standard
8097
Advice on class join points can extend the attribute list or base class
8099
If advice has a higher precedence than another it will be handled first.
8100
For example, an introduced new base class of advice with a high precedence
8101
will appear in the base class list on the left side of a base class, which
8102
was inserted by advice with lower precedence.
8103
This means that the execution order of the constructors of introduced base
8104
classes can be influenced, for instance, by order declarations.
8107
\begin_layout Standard
8108
The order of introduced attributes also has an impact on the constructor/destruc
8109
tor execution order as well as the object layout.
8112
\begin_layout Subsubsection*
8116
\begin_layout Standard
8117
Advice on code join points can be
8138
advice a higher precedence means that the corresponding advice code will
8144
advice a higher precedence means that the advice code will be run later.
8147
\begin_layout Standard
8152
advice code does not call
8160
on the action object no advice code with lower precedence will be run.
8161
The execution of advice with higher precedence is not affected by
8165
advice with lower precedence.
8168
\begin_layout Standard
8169
For example, consider an aspect that defines advice
8173
\begin_layout Standard
8191
in the following order: BE1, AF1, AF2, AR1, BE2, AR2, AF3.
8192
As described in section
8193
\begin_inset LatexCommand \vref{sub:advice-precedence}
8197
the declaration order also defines the precedence: BE1 has the highest
8199
The result is the following advice code execution sequence:
8202
\begin_layout Enumerate
8203
BE1 (highest precedence)
8206
\begin_layout Enumerate
8207
AR1 (the indented advice will only be executed if
8215
\begin_layout Enumerate
8216
BE2 (before AR2, buts depends on AR1)
8219
\begin_layout Enumerate
8220
AR2 (the indented code will only be executed if
8228
\begin_layout Enumerate
8229
original code under the join point
8232
\begin_layout Enumerate
8238
\begin_layout Enumerate
8239
AF2 (does not depend on AR1 and AR2, because of higher precedence)
8242
\begin_layout Enumerate
8243
AF1 (run after AF2, because it has a higher precedence)
8246
\begin_layout Section
8249
\begin_inset LatexCommand \index{grammar}
8256
\begin_layout Standard
8257
The AspectC++ syntax is an extension to the C++ syntax.
8258
It adds four new keywords to the C++ language:
8275
Additionally it extends the C++ language by advice and pointcut declarations.
8276
In contrast to pointcut declarations, advice declarations may only occur
8277
in aspect declarations.
8281
\begin_layout Description
8299
\begin_layout Description
8308
pointcut-declaration
8315
\begin_layout Description
8324
pointcut-declaration
8331
\begin_layout Description
8335
pointcut-declaration:
8340
\begin_inset LatexCommand \index{pointcut!declaration}
8359
\begin_layout Description
8363
pointcut-expression:
8368
\begin_inset LatexCommand \index{pointcut!expression}
8380
\begin_layout Description
8387
\begin_inset LatexCommand \index{advice!declaration}
8401
pointcut-expression\InsetSpace ~
8418
pointcut-expression\InsetSpace ~
8435
pointcut-expression\InsetSpace ~
8446
\begin_layout Description
8453
\begin_inset LatexCommand \index{order!declaration}
8467
pointcur-expression-seq\InsetSpace ~
8474
\begin_layout Description
8481
\begin_inset LatexCommand \index{slice!reference}
8496
\begin_inset Formula $_{\textrm{opt}}$
8500
nested-name-specifier
8501
\begin_inset Formula $_{\textrm{opt}}$
8504
unqualified-id\InsetSpace ~
8511
\begin_layout Description
8518
\begin_inset LatexCommand \index{slice!declaration}
8535
\begin_layout Section
8536
\begin_inset LatexCommand \label{sec:Match-Expression-Grammar}
8540
Match Expression Grammar
8541
\begin_inset LatexCommand \index{match expression!grammar}
8546
\begin_inset LatexCommand \index{match expression grammar}
8553
\begin_layout Standard
8554
Match expression in AspectC++ are used to define a type pattern and an optional
8555
object name pattern to select a subset of the known program entities like
8556
functions, attributes, or argument/result types.
8557
The grammer is very similar to the grammer of C++ declarations.
8558
Any rules, which are referenced here but not defined, should be looked
8559
up in the ISO C++ standard.
8562
\begin_layout Description
8583
\begin_layout Description
8626
\begin_layout Description
8638
match-decl-specifier-seq
8639
\begin_inset Formula $_{\textrm{opt}}$
8645
\begin_layout Description
8649
match-decl-specifier-seq:
8657
match-decl-specifier-seq
8658
\begin_inset Formula $_{\textrm{opt}}$
8661
match-decl-specifier
8664
\begin_layout Description
8668
match-decl-specifier:
8676
nested-match-name-specifier
8677
\begin_inset Formula $_{\textrm{opt}}$
8684
match-function-specifier
8712
\begin_layout Description
8716
match-function-specifier:
8727
\begin_layout Description
8731
nested-match-name-specifier:
8747
nested-match-name-specifier
8748
\begin_inset Formula $_{\textrm{opt}}$
8761
nested-match-name-specifier
8762
\begin_inset Formula $_{\textrm{opt}}$
8768
\begin_layout Description
8780
direct-match-declarator
8782
match-ptr-declarator match-declarator
8785
\begin_layout Description
8789
abstract-match-declarator
8797
direct-abstract-match-declarator
8799
match-ptr-declarator abstract-match-declarator
8802
\begin_layout Description
8806
direct-match-declarator:
8816
direct-match-declarator
8822
match-parameter-declaration-clause
8829
\begin_inset Formula $_{\textrm{opt}}$
8834
direct-match-declarator
8846
\begin_layout Description
8850
direct-abstract-match-declarator:
8858
direct-abstract-match-declarator
8864
match-parameter-declaration-clause
8871
\begin_inset Formula $_{\textrm{opt}}$
8876
direct-abstract-match-declarator
8888
\begin_layout Description
8909
\begin_layout Description
8926
\begin_inset Formula $_{\textrm{opt}}$
8941
nested-match-name-specifier
8950
\begin_inset Formula $_{\textrm{opt}}$
8956
\begin_layout Description
8960
match-parameter-declaration-clause:
8973
match-parameter-declaration-list
8974
\begin_inset Formula $_{\textrm{opt}}$
8979
match-parameter-declaration-list
8984
\begin_layout Description
8988
match-parameter-declaration-list:
8996
match-parameter-declaration
8998
match-parameter-declaration-list
9002
match-parameter-declaration
9005
\begin_layout Description
9009
match-parameter-declaration:
9017
matct-decl-specifier-seq match-abstract-declarator
9018
\begin_inset Formula $_{\textrm{opt}}$
9024
\begin_layout Description
9028
match-declarator-id:
9036
nested-match-name-specifier
9037
\begin_inset Formula $_{\textrm{opt}}$
9042
nested-match-name-specifier
9043
\begin_inset Formula $_{\textrm{opt}}$
9046
match-operator-function-id
9048
nested-match-name-specifier
9049
\begin_inset Formula $_{\textrm{opt}}$
9052
match-conversion-function-id
9055
\begin_layout Description
9059
match-operator-function-id:
9080
\begin_layout Description
9090
\begin_inset Tabular
9091
<lyxtabular version="3" rows="4" columns="13">
9093
<column alignment="block" valignment="top" width="0.6cm">
9094
<column alignment="block" valignment="top" width="0.6cm">
9095
<column alignment="block" valignment="top" width="0.6cm">
9096
<column alignment="block" valignment="top" width="0.6cm">
9097
<column alignment="block" valignment="top" width="0.6cm">
9098
<column alignment="block" valignment="top" width="0.6cm">
9099
<column alignment="block" valignment="top" width="0.6cm">
9100
<column alignment="block" valignment="top" width="0.6cm">
9101
<column alignment="block" valignment="top" width="0.6cm">
9102
<column alignment="block" valignment="top" width="0.6cm">
9103
<column alignment="block" valignment="top" width="0.6cm">
9104
<column alignment="block" valignment="top" width="0.6cm">
9105
<column alignment="block" valignment="top" width="0.6cm">
9107
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
9110
\begin_layout Standard
9118
<cell multicolumn="1" alignment="center" valignment="top" usebox="none">
9121
\begin_layout Standard
9129
<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9132
\begin_layout Standard
9138
<cell multicolumn="1" alignment="center" valignment="top" usebox="none">
9141
\begin_layout Standard
9149
<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9152
\begin_layout Standard
9158
<cell multicolumn="1" alignment="center" valignment="top" usebox="none">
9161
\begin_layout Standard
9169
<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9172
\begin_layout Standard
9178
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9181
\begin_layout Standard
9187
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9190
\begin_layout Standard
9196
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9199
\begin_layout Standard
9205
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9208
\begin_layout Standard
9214
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9217
\begin_layout Standard
9223
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9226
\begin_layout Standard
9234
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9237
\begin_layout Standard
9245
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9248
\begin_layout Standard
9256
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9259
\begin_layout Standard
9267
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9270
\begin_layout Standard
9278
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9281
\begin_layout Standard
9289
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9292
\begin_layout Standard
9300
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9303
\begin_layout Standard
9311
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9314
\begin_layout Standard
9322
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9325
\begin_layout Standard
9333
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9336
\begin_layout Standard
9344
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9347
\begin_layout Standard
9355
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9358
\begin_layout Standard
9366
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9369
\begin_layout Standard
9379
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9382
\begin_layout Standard
9390
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9393
\begin_layout Standard
9401
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9404
\begin_layout Standard
9412
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9415
\begin_layout Standard
9423
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9426
\begin_layout Standard
9434
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9437
\begin_layout Standard
9445
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9448
\begin_layout Standard
9456
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9459
\begin_layout Standard
9467
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9470
\begin_layout Standard
9478
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9481
\begin_layout Standard
9489
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9492
\begin_layout Standard
9500
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9503
\begin_layout Standard
9511
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9514
\begin_layout Standard
9524
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9527
\begin_layout Standard
9535
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9538
\begin_layout Standard
9546
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9549
\begin_layout Standard
9557
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9560
\begin_layout Standard
9568
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9571
\begin_layout Standard
9579
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9582
\begin_layout Standard
9590
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9593
\begin_layout Standard
9601
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9604
\begin_layout Standard
9612
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9615
\begin_layout Standard
9623
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9626
\begin_layout Standard
9634
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9637
\begin_layout Standard
9645
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
9648
\begin_layout Standard
9656
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
9659
\begin_layout Standard
9673
\begin_layout Description
9677
match-conversion-function-id:
9689
match-conversion-type-id
9692
\begin_layout Description
9696
match-conversion-type-id:
9704
match-type-specifier-seq match-conversion-declarator
9705
\begin_inset Formula $_{\textrm{opt}}$
9711
\begin_layout Description
9715
match-conversion-declarator:
9723
match-ptr-operator match-conversion-declarator
9724
\begin_inset Formula $_{\textrm{opt}}$
9730
\begin_layout Standard
9734
\begin_layout Standard
9748
\begin_layout Standard
9750
match expressions (name pointcuts),
9751
\begin_inset LatexCommand \pageref{exa:match-expressions}
9758
\begin_layout Standard
9760
pointcut expressions,
9761
\begin_inset LatexCommand \pageref{exa:pointcut-expressions}
9768
\begin_layout Standard
9770
pointcut declaration,
9771
\begin_inset LatexCommand \pageref{exa:pointcut-declaration}
9778
\begin_layout Standard
9780
pure virtual pointcut declaration,
9781
\begin_inset LatexCommand \pageref{exa:pure-virtual}
9788
\begin_layout Standard
9790
class slice declaration,
9791
\begin_inset LatexCommand \pageref{exa:class-slice-declaration}
9798
\begin_layout Standard
9801
\begin_inset LatexCommand \pageref{exa:advice-declaration}
9808
\begin_layout Standard
9810
advice declaration with access to context information,
9811
\begin_inset LatexCommand \pageref{exa:advice-declaration-with}
9818
\begin_layout Standard
9821
\begin_inset LatexCommand \pageref{exa:introductions}
9828
\begin_layout Standard
9830
base class introduction,
9831
\begin_inset LatexCommand \pageref{exa:base-class-intro}
9838
\begin_layout Standard
9841
\begin_inset LatexCommand \pageref{exa:order}
9848
\begin_layout Standard
9851
\begin_inset LatexCommand \pageref{exa:aspect-decl}
9858
\begin_layout Standard
9861
\begin_inset LatexCommand \pageref{exa:abstract-aspect}
9868
\begin_layout Standard
9870
reused abstract aspect,
9871
\begin_inset LatexCommand \pageref{exa:reused-abstract}
9878
\begin_layout Standard
9880
aspect instantiation using
9885
\begin_inset LatexCommand \pageref{exa:aspect-aspectof}
9892
\begin_layout Standard
9894
re-usable trace aspect,
9895
\begin_inset LatexCommand \pageref{exa:re-usable-trace}
9902
\begin_layout Standard
9907
\begin_layout Standard
9916
static type identification using introductions,
9917
\begin_inset LatexCommand \pageref{exa:static-type-id}
9925
\begin_layout Standard
9929
\begin_layout Standard
9933
\begin_layout Standard
9940
\begin_layout Standard
9949
\begin_layout Standard
9954
\begin_layout Standard
9963
extended thread counting,
9964
\begin_inset LatexCommand \pageref{exa:extended-thread}
9972
\begin_layout Standard
9976
\begin_layout Standard
9980
\begin_layout Standard
9987
\begin_layout Standard
9996
\begin_layout Standard
9998
type, scope, and name parts of a function match expression,
9999
\begin_inset LatexCommand \pageref{exa:match-expr-parts}
10006
\begin_layout Standard
10008
simple name patterns,
10009
\begin_inset LatexCommand \pageref{exa:match-name-patterns}
10016
\begin_layout Standard
10018
operator name patterns,
10019
\begin_inset LatexCommand \pageref{exa:match-operator-name-patterns}
10026
\begin_layout Standard
10028
conversion function name patterns,
10029
\begin_inset LatexCommand \pageref{exa:match-conversion-function-name-patterns}
10036
\begin_layout Standard
10039
\begin_inset LatexCommand \pageref{exa:match-scope-patterns}
10046
\begin_layout Standard
10048
type patterns with the wildcard character,
10049
\begin_inset LatexCommand \pageref{exa:match-type-patterns-wildcard}
10056
\begin_layout Standard
10067
\begin_inset LatexCommand \pageref{exa:match-type-patterns-cv}
10074
\begin_layout Standard
10081
\begin_inset LatexCommand \pageref{exa:match-type-patterns-virtual}
10088
\begin_layout Standard
10091
\begin_inset LatexCommand \pageref{exa:type-matching}
10098
\begin_layout Standard
10100
control flow dependant advice activation,
10101
\begin_inset LatexCommand \pageref{exa:control-flow}
10108
\begin_layout Standard
10110
matching in scopes,
10111
\begin_inset LatexCommand \pageref{exa:matching-in-scopes}
10118
\begin_layout Standard
10121
\begin_inset LatexCommand \pageref{exa:function-matching}
10128
\begin_layout Standard
10131
\begin_inset LatexCommand \label{exa:instance-counting}
10138
\begin_layout Standard
10143
\begin_layout Standard
10152
attribute matching,
10153
\begin_inset LatexCommand \pageref{exa:attribute-matching}
10161
\begin_layout Standard
10165
\begin_layout Standard
10169
\begin_layout Standard
10176
\begin_layout Standard
10185
\begin_layout Standard
10188
\begin_inset LatexCommand \pageref{exa:context-matching}
10195
\begin_layout Standard
10197
combining pointcut expressions,
10198
\begin_inset LatexCommand \pageref{exa:combining-pointcut}
10205
\begin_layout Standard
10208
\begin_inset LatexCommand \pageref{exa:advice-placement}
10215
\begin_layout Standard
10218
\begin_inset LatexCommand \pageref{exa:type-usage}
10225
\begin_layout Standard
10227
static function usage,
10228
\begin_inset LatexCommand \pageref{exa:static-function-usage}
10235
\begin_layout Standard
10237
non-static function usage,
10238
\begin_inset LatexCommand \pageref{exa:non-static-function-usage}
10245
\begin_layout Standard
10249
\begin_layout Standard
10255
addcontentsline{toc}{section}{
10265
\begin_layout Standard
10266
\begin_inset LatexCommand \printindex{}