File: PointerTracker.ah

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 (30 lines) | stat: -rw-r--r-- 869 bytes parent folder | download | duplicates (5)
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
#ifndef __PointerTracker_ah__
#define __PointerTracker_ah__

#include <stdio.h>

aspect PointerTracker {
  advice call ("% ...::%(...)") && result("% *") : before () {
    printf ("  call to '%s'\n", tjp->signature ());
  }

  advice execution ("% ...::%(...)") && result("% *") : after () {
    printf ("  executed '%s' -> 0x%lu\n", tjp->signature (),
                                     (unsigned long)*(void**)tjp->result ());
  }

  advice call ("% %(...)") && result(res) : after (long **res) {
    printf ("  result after call: 0x%lu\n", (unsigned long)res);
  }
};

aspect ResultManipulator {
  advice call ("% select_v()") && result ("int &") : after () {
    static int new_result = 815;
    JoinPoint::Result * result = tjp->result ();
    printf ("  changing result! now: %d\n", **result);
    *result = &new_result;
  }
};

#endif // __PointerTracker_ah__