File: main.cc

package info (click to toggle)
aspectc%2B%2B 1.0pre4~svn.20090918-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 117,308 kB
  • ctags: 410,601
  • sloc: cpp: 1,883,007; ansic: 17,279; sh: 2,190; makefile: 1,088
file content (134 lines) | stat: -rw-r--r-- 2,884 bytes parent folder | download | duplicates (2)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <stdio.h>

class SomeBase1 {};
class SomeBase2 {};
class SomeBase3 {};

namespace Puma {

  class XXX {
  };

  slice class ACSemanticForC : public SomeBase2 {
    bool _in_advice;
    class Nested;
public:
    static int anon;
    ACSemanticForC () : _in_advice (false) {}
    explicit ACSemanticForC (bool a);
    virtual ~ACSemanticForC ();
    void enter_advice () {
      _in_advice = true;
    }
    void enter_advice2 () {
      _in_advice = true;
    }
    bool in_advice () const { return _in_advice; }
    void leave_advice ();
};

  slice class ACBuilder;
}

slice class Puma::ACBuilder;
slice class Puma::ACBuilder {};

slice struct InGlobal {
  int _in_global;
  void global ();
};

class WithBase : public SomeBase1 {};

namespace Puma {
  slice class Bla;
}

int main () {
  printf ("Slice: of few simple slice implementations\n");
  printf ("==========================================\n");
  Puma::XXX x(true);
  printf ("in: %d\n", x.in_advice ());
  x.enter_advice ();
  printf ("in: %d\n", x.in_advice ());
  x.leave_advice ();
  printf ("in: %d\n", x.in_advice ());
  x.g (); // from DefinedLater
  printf ("==========================================\n");
};

slice class DefinedLater;

aspect Foo {
  advice "Puma::XXX" : baseclass (SomeBase1);
  advice "Puma::XXX" : slice class U : public SomeBase3;
  advice "WithBase"  : slice struct : SomeBase2;

  advice "Puma::XXX" : slice Puma::Bla;

  slice class Local {
      typedef Local THIS;
  };
/*   advice "XXX" : slice class Bla; // wrong */
/*   advice "XXX" : slice struct ::Foo; // wrong */
  advice "Puma::XXX" : slice Puma::ACSemanticForC;
  advice "Puma::XXX" : slice InGlobal;

/*   advice "XXX" : { */
/*     void *blob; */
/*   }; */
  advice "Puma::XXX" : slice DefinedLater;
  slice struct Later2;
  advice "Puma::XXX" : slice Later2;
  advice "Puma::XXX" : slice class {}; // useless :-)
  advice "Puma::XXX" : slice class S {
    double murks;
    long long murks2;
  public:
//     S () {}
    explicit S(int) {}
    explicit S(double i) : murks(i) {}
    S(unsigned long long ll) : murks2(ll) {}
    int bar2;
    class Nested2;
  };
};

slice class Puma::Bla {
  void func ();
};

slice void Puma::Bla::func () {
}

slice struct Foo::Later2 { int _later2; };

slice class DefinedLater { int _def_later; public: void g (); };

slice void DefinedLater::g () {}

aspect Trace {
  advice execution ("Puma::XXX") /* || construction ("Puma::XXX")*/ : before () {
    printf ("before %s\n", JoinPoint::signature ());
  }
};

slice class Puma::ACSemanticForC::Nested {
  int i;
};

slice
void Puma::ACSemanticForC::leave_advice () { _in_advice = false; }


slice
int Puma::ACSemanticForC::anon = 0;

slice
class ::Foo::S::Nested2 {};

slice Puma::ACSemanticForC::~ACSemanticForC () {}

slice Puma::ACSemanticForC::ACSemanticForC (bool a) : _in_advice (a) {}

slice void InGlobal::global () {}