1 | // |
---|
2 | // Copyright (C) 2004-2006, Maciej Sobczak |
---|
3 | // |
---|
4 | // Permission to copy, use, modify, sell and distribute this software |
---|
5 | // is granted provided this copyright notice appears in all copies. |
---|
6 | // This software is provided "as is" without express or implied |
---|
7 | // warranty, and with no claim as to its suitability for any purpose. |
---|
8 | // |
---|
9 | |
---|
10 | // Note: this file is not supposed to be a stand-alone header |
---|
11 | |
---|
12 | |
---|
13 | template <typename R> |
---|
14 | class callback0 : public callback_base |
---|
15 | { |
---|
16 | typedef R (*functor_type)(); |
---|
17 | |
---|
18 | public: |
---|
19 | callback0(functor_type f) : f_(f) {} |
---|
20 | |
---|
21 | virtual void invoke(Tcl_Interp *interp, |
---|
22 | int, Tcl_Obj * CONST [], |
---|
23 | policies const &) |
---|
24 | { |
---|
25 | dispatch<R>::do_dispatch(interp, f_); |
---|
26 | } |
---|
27 | |
---|
28 | private: |
---|
29 | functor_type f_; |
---|
30 | }; |
---|
31 | |
---|
32 | template <typename R, typename T1> |
---|
33 | class callback1 : public callback_base |
---|
34 | { |
---|
35 | typedef R (*functor_type)(T1); |
---|
36 | |
---|
37 | public: |
---|
38 | callback1(functor_type f) : f_(f) {} |
---|
39 | |
---|
40 | virtual void invoke(Tcl_Interp *interp, |
---|
41 | int objc, Tcl_Obj * CONST objv[], |
---|
42 | policies const &) |
---|
43 | { |
---|
44 | check_params_no(objc, 2); |
---|
45 | |
---|
46 | dispatch<R>::template do_dispatch<T1>(interp, f_, |
---|
47 | tcl_cast<T1>::from(interp, objv[1])); |
---|
48 | } |
---|
49 | |
---|
50 | private: |
---|
51 | functor_type f_; |
---|
52 | }; |
---|
53 | |
---|
54 | template <typename R, typename T1, typename T2> |
---|
55 | class callback2 : public callback_base |
---|
56 | { |
---|
57 | typedef R (*functor_type)(T1, T2); |
---|
58 | |
---|
59 | public: |
---|
60 | callback2(functor_type f) : f_(f) {} |
---|
61 | |
---|
62 | virtual void invoke(Tcl_Interp *interp, |
---|
63 | int objc, Tcl_Obj * CONST objv[], |
---|
64 | policies const &) |
---|
65 | { |
---|
66 | check_params_no(objc, 3); |
---|
67 | |
---|
68 | dispatch<R>::template do_dispatch<T1, T2>(interp, f_, |
---|
69 | tcl_cast<T1>::from(interp, objv[1]), |
---|
70 | tcl_cast<T2>::from(interp, objv[2])); |
---|
71 | } |
---|
72 | |
---|
73 | private: |
---|
74 | functor_type f_; |
---|
75 | }; |
---|
76 | |
---|
77 | template <typename R, typename T1, typename T2, typename T3> |
---|
78 | class callback3 : public callback_base |
---|
79 | { |
---|
80 | typedef R (*functor_type)(T1, T2, T3); |
---|
81 | |
---|
82 | public: |
---|
83 | callback3(functor_type f) : f_(f) {} |
---|
84 | |
---|
85 | virtual void invoke(Tcl_Interp *interp, |
---|
86 | int objc, Tcl_Obj * CONST objv[], |
---|
87 | policies const &) |
---|
88 | { |
---|
89 | check_params_no(objc, 4); |
---|
90 | |
---|
91 | dispatch<R>::template do_dispatch<T1, T2, T3>(interp, f_, |
---|
92 | tcl_cast<T1>::from(interp, objv[1]), |
---|
93 | tcl_cast<T2>::from(interp, objv[2]), |
---|
94 | tcl_cast<T3>::from(interp, objv[3])); |
---|
95 | } |
---|
96 | |
---|
97 | private: |
---|
98 | functor_type f_; |
---|
99 | }; |
---|
100 | |
---|
101 | template <typename R, typename T1, typename T2, typename T3, typename T4> |
---|
102 | class callback4 : public callback_base |
---|
103 | { |
---|
104 | typedef R (*functor_type)(T1, T2, T3, T4); |
---|
105 | |
---|
106 | public: |
---|
107 | callback4(functor_type f) : f_(f) {} |
---|
108 | |
---|
109 | virtual void invoke(Tcl_Interp *interp, |
---|
110 | int objc, Tcl_Obj * CONST objv[], |
---|
111 | policies const &) |
---|
112 | { |
---|
113 | check_params_no(objc, 5); |
---|
114 | |
---|
115 | dispatch<R>::template do_dispatch<T1, T2, T3, T4>(interp, f_, |
---|
116 | tcl_cast<T1>::from(interp, objv[1]), |
---|
117 | tcl_cast<T2>::from(interp, objv[2]), |
---|
118 | tcl_cast<T3>::from(interp, objv[3]), |
---|
119 | tcl_cast<T4>::from(interp, objv[4])); |
---|
120 | } |
---|
121 | |
---|
122 | private: |
---|
123 | functor_type f_; |
---|
124 | }; |
---|
125 | |
---|
126 | template <typename R, typename T1, typename T2, typename T3, typename T4, |
---|
127 | typename T5> |
---|
128 | class callback5 : public callback_base |
---|
129 | { |
---|
130 | typedef R (*functor_type)(T1, T2, T3, T4, T5); |
---|
131 | |
---|
132 | public: |
---|
133 | callback5(functor_type f) : f_(f) {} |
---|
134 | |
---|
135 | virtual void invoke(Tcl_Interp *interp, |
---|
136 | int objc, Tcl_Obj * CONST objv[], |
---|
137 | policies const &) |
---|
138 | { |
---|
139 | check_params_no(objc, 6); |
---|
140 | |
---|
141 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(interp, f_, |
---|
142 | tcl_cast<T1>::from(interp, objv[1]), |
---|
143 | tcl_cast<T2>::from(interp, objv[2]), |
---|
144 | tcl_cast<T3>::from(interp, objv[3]), |
---|
145 | tcl_cast<T4>::from(interp, objv[4]), |
---|
146 | tcl_cast<T5>::from(interp, objv[5])); |
---|
147 | } |
---|
148 | |
---|
149 | private: |
---|
150 | functor_type f_; |
---|
151 | }; |
---|
152 | |
---|
153 | template <typename R, typename T1, typename T2, typename T3, typename T4, |
---|
154 | typename T5, typename T6> |
---|
155 | class callback6 : public callback_base |
---|
156 | { |
---|
157 | typedef R (*functor_type)(T1, T2, T3, T4, T5, T6); |
---|
158 | |
---|
159 | public: |
---|
160 | callback6(functor_type f) : f_(f) {} |
---|
161 | |
---|
162 | virtual void invoke(Tcl_Interp *interp, |
---|
163 | int objc, Tcl_Obj * CONST objv[], |
---|
164 | policies const &) |
---|
165 | { |
---|
166 | check_params_no(objc, 7); |
---|
167 | |
---|
168 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>( |
---|
169 | interp, f_, |
---|
170 | tcl_cast<T1>::from(interp, objv[1]), |
---|
171 | tcl_cast<T2>::from(interp, objv[2]), |
---|
172 | tcl_cast<T3>::from(interp, objv[3]), |
---|
173 | tcl_cast<T4>::from(interp, objv[4]), |
---|
174 | tcl_cast<T5>::from(interp, objv[5]), |
---|
175 | tcl_cast<T6>::from(interp, objv[6])); |
---|
176 | } |
---|
177 | |
---|
178 | private: |
---|
179 | functor_type f_; |
---|
180 | }; |
---|
181 | |
---|
182 | template <typename R, typename T1, typename T2, typename T3, typename T4, |
---|
183 | typename T5, typename T6, typename T7> |
---|
184 | class callback7 : public callback_base |
---|
185 | { |
---|
186 | typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7); |
---|
187 | |
---|
188 | public: |
---|
189 | callback7(functor_type f) : f_(f) {} |
---|
190 | |
---|
191 | virtual void invoke(Tcl_Interp *interp, |
---|
192 | int objc, Tcl_Obj * CONST objv[], |
---|
193 | policies const &) |
---|
194 | { |
---|
195 | check_params_no(objc, 8); |
---|
196 | |
---|
197 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>( |
---|
198 | interp, f_, |
---|
199 | tcl_cast<T1>::from(interp, objv[1]), |
---|
200 | tcl_cast<T2>::from(interp, objv[2]), |
---|
201 | tcl_cast<T3>::from(interp, objv[3]), |
---|
202 | tcl_cast<T4>::from(interp, objv[4]), |
---|
203 | tcl_cast<T5>::from(interp, objv[5]), |
---|
204 | tcl_cast<T6>::from(interp, objv[6]), |
---|
205 | tcl_cast<T7>::from(interp, objv[7])); |
---|
206 | } |
---|
207 | |
---|
208 | private: |
---|
209 | functor_type f_; |
---|
210 | }; |
---|
211 | |
---|
212 | template <typename R, typename T1, typename T2, typename T3, typename T4, |
---|
213 | typename T5, typename T6, typename T7, typename T8> |
---|
214 | class callback8 : public callback_base |
---|
215 | { |
---|
216 | typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8); |
---|
217 | |
---|
218 | public: |
---|
219 | callback8(functor_type f) : f_(f) {} |
---|
220 | |
---|
221 | virtual void invoke(Tcl_Interp *interp, |
---|
222 | int objc, Tcl_Obj * CONST objv[], |
---|
223 | policies const &) |
---|
224 | { |
---|
225 | check_params_no(objc, 9); |
---|
226 | |
---|
227 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7, T8>( |
---|
228 | interp, f_, |
---|
229 | tcl_cast<T1>::from(interp, objv[1]), |
---|
230 | tcl_cast<T2>::from(interp, objv[2]), |
---|
231 | tcl_cast<T3>::from(interp, objv[3]), |
---|
232 | tcl_cast<T4>::from(interp, objv[4]), |
---|
233 | tcl_cast<T5>::from(interp, objv[5]), |
---|
234 | tcl_cast<T6>::from(interp, objv[6]), |
---|
235 | tcl_cast<T7>::from(interp, objv[7]), |
---|
236 | tcl_cast<T8>::from(interp, objv[8])); |
---|
237 | } |
---|
238 | |
---|
239 | private: |
---|
240 | functor_type f_; |
---|
241 | }; |
---|
242 | |
---|
243 | template <typename R, typename T1, typename T2, typename T3, typename T4, |
---|
244 | typename T5, typename T6, typename T7, typename T8, typename T9> |
---|
245 | class callback9 : public callback_base |
---|
246 | { |
---|
247 | typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9); |
---|
248 | |
---|
249 | public: |
---|
250 | callback9(functor_type f) : f_(f) {} |
---|
251 | |
---|
252 | virtual void invoke(Tcl_Interp *interp, |
---|
253 | int objc, Tcl_Obj * CONST objv[], |
---|
254 | policies const &) |
---|
255 | { |
---|
256 | check_params_no(objc, 10); |
---|
257 | |
---|
258 | dispatch<R>::template do_dispatch< |
---|
259 | T1, T2, T3, T4, T5, T6, T7, T8, T9>(interp, f_, |
---|
260 | tcl_cast<T1>::from(interp, objv[1]), |
---|
261 | tcl_cast<T2>::from(interp, objv[2]), |
---|
262 | tcl_cast<T3>::from(interp, objv[3]), |
---|
263 | tcl_cast<T4>::from(interp, objv[4]), |
---|
264 | tcl_cast<T5>::from(interp, objv[5]), |
---|
265 | tcl_cast<T6>::from(interp, objv[6]), |
---|
266 | tcl_cast<T7>::from(interp, objv[7]), |
---|
267 | tcl_cast<T8>::from(interp, objv[8]), |
---|
268 | tcl_cast<T9>::from(interp, objv[9])); |
---|
269 | } |
---|
270 | |
---|
271 | private: |
---|
272 | functor_type f_; |
---|
273 | }; |
---|