File: main.cc

package info (click to toggle)
aspectc%2B%2B 1.0pre4~svn.20080711-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 104,504 kB
  • ctags: 363,975
  • sloc: cpp: 1,645,814; ansic: 16,601; sh: 2,175; makefile: 1,043
file content (106 lines) | stat: -rw-r--r-- 2,367 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <stdio.h>

class X {
    struct Y; // this one is private!
public:
    static void fx();
};

struct X::Y {
    void fy(Y *arg);
};

// this is a member of a private class, thus Y cannot be used in TJP so far
void X::Y::fy(Y *arg) {
} 

// this function may call fy
void X::fx () {
    Y y;
    y.fy (&y);
}

aspect Bug316 {
  advice execution ("% ...::f%(...)") : around () {
    printf ("e1: before %s\n",JoinPoint::signature ());
    tjp->proceed ();
    printf ("e1: after %s\n",JoinPoint::signature ());
  }
  advice execution ("% ...::f%(...)") : around () {
    printf ("e2: before %s\n",JoinPoint::signature ());
    tjp->proceed ();
    printf ("e2: after %s\n",JoinPoint::signature ());
  }
  // this call advice still does not work!
//   advice call ("% ...::f%(...)") : around () {
//     printf ("c1: before %s\n",JoinPoint::signature ());
//     tjp->proceed ();
//     printf ("c1: after %s\n",JoinPoint::signature ());
//   }
//   advice call ("% ...::f%(...)") : around () {
//     printf ("c2: before %s\n",JoinPoint::signature ());
//     tjp->action ().trigger ();
//     printf ("c2: after %s\n",JoinPoint::signature ());
//   }
};

int main () {
    X::fx ();
    return 0;
}

// moegliche Loesung ...

// #include <stdio.h>

// template <int>
// struct TJP {};


// class X {
//     template <int> friend struct TJP;
//     struct Y; // this one is private!
// public:
//     static void fx();
// };

// struct X::Y {
//     void old_fy();
//     void fy();
// };

// template <> struct TJP<1> {
//     typedef X::Y That;
//     typedef X::Y Target;
//     X::Y *_that;
//     X::Y *that () { return _that; }
//     X::Y *target () { return 0; }
//     static const char *signature () { return "X::Y::fy"; }
//     void proceed () { _that->old_fy (); }
// };

// template <typename JP> void adv (JP *tjp) {
//     printf ("before %s\n", JP::signature ());
//     tjp->proceed ();
// }

// // this is a member of a private class, thus Y cannot be used in TJP so far
// void X::Y::fy() {
//     TJP<1> tjp = { this };
//     adv< TJP<1> >(&tjp);
// } 
// // this is a member of a private class, thus Y cannot be used in TJP so far
// void X::Y::old_fy() {
//     printf ("X::Y::old_fy\n");
// } 

// // this function may call fy
// void X::fx () {
//     Y y;
//     y.fy ();
// }

// int main () {
//     X::fx ();
//     return 0;
// }