Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
rw_sigdefs.h
Go to the documentation of this file.
1
28#ifndef RW_SIGDEFS_H_INCLUDED
29#define RW_SIGDEFS_H_INCLUDED
30
31// FCAT() concatenates prefix, underscrore, and suffix
32#define _FCAT(a, b) a ## b
33#define FCAT(a, b) _FCAT (a ## _, b)
34
35// FID_N() constructs the name for an overload of a container function
36#define FID_0(f) FCAT (f, void)
37#define FID_1(f, a) FCAT (f, a)
38#define FID_2(f, a, b) FID_1 (FCAT (f, a), b)
39#define FID_3(f, a, b, c) FID_2 (FCAT (f, a), b, c)
40#define FID_4(f, a, b, c, d) FID_3 (FCAT (f, a), b, c, d)
41#define FID_5(f, a, b, c, d, e) FID_4 (FCAT (f, a), b, c, d, e)
42
43// ARG() creates a bitmap of an argument type at the given position
44#define ARG(a, N) ((arg_ ## a << (N * arg_bits)) << fid_bits)
45
46// SIG_N() creates an argument bitmap for the given function signature
47#define SIG_0(f) fid_ ## f
48#define SIG_1(f, a) SIG_0 (f) | ARG (a, 0)
49#define SIG_2(f, a, b) SIG_1 (f, a) | ARG (b, 1)
50#define SIG_3(f, a, b, c) SIG_2 (f, a, b) | ARG (c, 2)
51#define SIG_4(f, a, b, c, d) SIG_3 (f, a, b, c) | ARG (d, 3)
52#define SIG_5(f, a, b, c, d, e) SIG_4 (f, a, b, c, d) | ARG (e, 4)
53#define SIG_6(f, a, b, c, d, e, g) SIG_5 (f, a, b, c, d, e) | ARG (g, 5)
54
55// convenience macro to define member function overload id's
56// where the first argument encodes the constness of the member
57// function (or the lack thereof)
58#define MEMBER_0(f, self) \
59 FID_0 (f) = SIG_1 (f, self) | bit_member
60#define MEMBER_1(f, self, a) \
61 FID_1 (f, a) = SIG_2 (f, self, a) | bit_member
62#define MEMBER_2(f, self, a, b) \
63 FID_2 (f, a, b) = SIG_3 (f, self, a, b) | bit_member
64#define MEMBER_3(f, self, a, b, c) \
65 FID_3 (f, a, b, c) = SIG_4 (f, self, a, b, c) | bit_member
66#define MEMBER_4(f, self, a, b, c, d) \
67 FID_4 (f, a, b, c, d) = SIG_5 (f, self, a, b, c, d) | bit_member
68#define MEMBER_5(f, self, a, b, c, d, e) \
69 FID_5 (f, a, b, c, d, e) = SIG_6 (f, self, a, b, c, d, e) | bit_member
70
71// convenience macro to define non-member function overload id's
72#define NON_MEMBER_0(f) \
73 FID_0 (f) = SIG_0 (f)
74#define NON_MEMBER_1(f, a) \
75 FID_1 (f, a) = SIG_1 (f, a)
76#define NON_MEMBER_2(f, a, b) \
77 FID_2 (f, a, b) = SIG_2 (f, a, b)
78#define NON_MEMBER_3(f, a, b, c) \
79 FID_3 (f, a, b, c) = SIG_3 (f, a, b, c)
80#define NON_MEMBER_4(f, a, b, c, d) \
81 FID_4 (f, a, b, c, d) = SIG_4 (f, a, b, c, d)
82#define NON_MEMBER_5(f, a, b, c, d, e) \
83 FID_5 (f, a, b, c, d, e) = SIG_5 (f, a, b, c, d, e)
84
85#else // #ifdef RW_SIGDEFS_H_INCLUDED
86
87// clean up helper macros used above
88#undef _FCAT
89#undef FCAT
90#undef FID_0
91#undef FID_1
92#undef FID_2
93#undef FID_3
94#undef FID_4
95#undef FID_5
96
97#undef ARG
98
99#undef SIG_0
100#undef SIG_1
101#undef SIG_2
102#undef SIG_3
103#undef SIG_4
104#undef SIG_5
105
106#undef MEMBER_0
107#undef MEMBER_1
108#undef MEMBER_2
109#undef MEMBER_3
110#undef MEMBER_4
111#undef MEMBER_5
112
113#undef RW_SIGDEFS_H_INCLUDED
114
115#endif // RW_SIGDEFS_H_INCLUDED