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 <class C, typename R> |
---|
14 | class method0 : public object_cmd_base |
---|
15 | { |
---|
16 | typedef R (C::*mem_type)(); |
---|
17 | typedef R (C::*cmem_type)() const; |
---|
18 | |
---|
19 | public: |
---|
20 | method0(mem_type f) : f_(f), cmem_(false) {} |
---|
21 | method0(cmem_type f) : cf_(f), cmem_(true) {} |
---|
22 | |
---|
23 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
24 | int, Tcl_Obj * CONST [], policies const &) |
---|
25 | { |
---|
26 | C *p = static_cast<C*>(pv); |
---|
27 | if (cmem_) |
---|
28 | { |
---|
29 | dispatch<R>::do_dispatch(interp, boost::bind(cf_, p)); |
---|
30 | } |
---|
31 | else |
---|
32 | { |
---|
33 | dispatch<R>::do_dispatch(interp, boost::bind(f_, p)); |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | private: |
---|
38 | mem_type f_; |
---|
39 | cmem_type cf_; |
---|
40 | bool cmem_; |
---|
41 | }; |
---|
42 | |
---|
43 | template <class C, typename R, typename T1> |
---|
44 | class method1 : public object_cmd_base |
---|
45 | { |
---|
46 | typedef R (C::*mem_type)(T1); |
---|
47 | typedef R (C::*cmem_type)(T1) const; |
---|
48 | |
---|
49 | public: |
---|
50 | method1(mem_type f) : f_(f), cmem_(false) {} |
---|
51 | method1(cmem_type f) : cf_(f), cmem_(true) {} |
---|
52 | |
---|
53 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
54 | int objc, Tcl_Obj * CONST objv[], policies const &) |
---|
55 | { |
---|
56 | check_params_no(objc, 3); |
---|
57 | |
---|
58 | C *p = static_cast<C*>(pv); |
---|
59 | if (cmem_) |
---|
60 | { |
---|
61 | dispatch<R>::template do_dispatch<T1>( |
---|
62 | interp, boost::bind(cf_, p, _1), |
---|
63 | tcl_cast<T1>::from(interp, objv[2])); |
---|
64 | } |
---|
65 | else |
---|
66 | { |
---|
67 | dispatch<R>::template do_dispatch<T1>( |
---|
68 | interp, boost::bind(f_, p, _1), |
---|
69 | tcl_cast<T1>::from(interp, objv[2])); |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | private: |
---|
74 | mem_type f_; |
---|
75 | cmem_type cf_; |
---|
76 | bool cmem_; |
---|
77 | }; |
---|
78 | |
---|
79 | template <class C, typename R, typename T1, typename T2> |
---|
80 | class method2 : public object_cmd_base |
---|
81 | { |
---|
82 | typedef R (C::*mem_type)(T1, T2); |
---|
83 | typedef R (C::*cmem_type)(T1, T2) const; |
---|
84 | |
---|
85 | public: |
---|
86 | method2(mem_type f) : f_(f), cmem_(false) {} |
---|
87 | method2(cmem_type f) : cf_(f), cmem_(true) {} |
---|
88 | |
---|
89 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
90 | int objc, Tcl_Obj * CONST objv[], policies const &) |
---|
91 | { |
---|
92 | check_params_no(objc, 4); |
---|
93 | |
---|
94 | C *p = static_cast<C*>(pv); |
---|
95 | if (cmem_) |
---|
96 | { |
---|
97 | dispatch<R>::template do_dispatch<T1, T2>( |
---|
98 | interp, boost::bind(cf_, p, _1, _2), |
---|
99 | tcl_cast<T1>::from(interp, objv[2]), |
---|
100 | tcl_cast<T2>::from(interp, objv[3])); |
---|
101 | } |
---|
102 | else |
---|
103 | { |
---|
104 | dispatch<R>::template do_dispatch<T1, T2>( |
---|
105 | interp, boost::bind(f_, p, _1, _2), |
---|
106 | tcl_cast<T1>::from(interp, objv[2]), |
---|
107 | tcl_cast<T2>::from(interp, objv[3])); |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | private: |
---|
112 | mem_type f_; |
---|
113 | cmem_type cf_; |
---|
114 | bool cmem_; |
---|
115 | }; |
---|
116 | |
---|
117 | template <class C, typename R, typename T1, typename T2, typename T3> |
---|
118 | class method3 : public object_cmd_base |
---|
119 | { |
---|
120 | typedef R (C::*mem_type)(T1, T2, T3); |
---|
121 | typedef R (C::*cmem_type)(T1, T2, T3) const; |
---|
122 | |
---|
123 | public: |
---|
124 | method3(mem_type f) : f_(f), cmem_(false) {} |
---|
125 | method3(cmem_type f) : cf_(f), cmem_(true) {} |
---|
126 | |
---|
127 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
128 | int objc, Tcl_Obj * CONST objv[], policies const &) |
---|
129 | { |
---|
130 | check_params_no(objc, 5); |
---|
131 | |
---|
132 | C *p = static_cast<C*>(pv); |
---|
133 | if (cmem_) |
---|
134 | { |
---|
135 | dispatch<R>::template do_dispatch<T1, T2, T3>( |
---|
136 | interp, boost::bind(cf_, p, _1, _2, _3), |
---|
137 | tcl_cast<T1>::from(interp, objv[2]), |
---|
138 | tcl_cast<T2>::from(interp, objv[3]), |
---|
139 | tcl_cast<T3>::from(interp, objv[4])); |
---|
140 | } |
---|
141 | else |
---|
142 | { |
---|
143 | dispatch<R>::template do_dispatch<T1, T2, T3>( |
---|
144 | interp, boost::bind(f_, p, _1, _2, _3), |
---|
145 | tcl_cast<T1>::from(interp, objv[2]), |
---|
146 | tcl_cast<T2>::from(interp, objv[3]), |
---|
147 | tcl_cast<T3>::from(interp, objv[4])); |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | private: |
---|
152 | mem_type f_; |
---|
153 | cmem_type cf_; |
---|
154 | bool cmem_; |
---|
155 | }; |
---|
156 | |
---|
157 | template <class C, typename R, typename T1, typename T2, typename T3, |
---|
158 | typename T4> |
---|
159 | class method4 : public object_cmd_base |
---|
160 | { |
---|
161 | typedef R (C::*mem_type)(T1, T2, T3, T4); |
---|
162 | typedef R (C::*cmem_type)(T1, T2, T3, T4) const; |
---|
163 | |
---|
164 | public: |
---|
165 | method4(mem_type f) : f_(f), cmem_(false) {} |
---|
166 | method4(cmem_type f) : cf_(f), cmem_(true) {} |
---|
167 | |
---|
168 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
169 | int objc, Tcl_Obj * CONST objv[], policies const &) |
---|
170 | { |
---|
171 | check_params_no(objc, 6); |
---|
172 | |
---|
173 | C *p = static_cast<C*>(pv); |
---|
174 | if (cmem_) |
---|
175 | { |
---|
176 | dispatch<R>::template do_dispatch<T1, T2, T3, T4>( |
---|
177 | interp, boost::bind(cf_, p, _1, _2, _3, _4), |
---|
178 | tcl_cast<T1>::from(interp, objv[2]), |
---|
179 | tcl_cast<T2>::from(interp, objv[3]), |
---|
180 | tcl_cast<T3>::from(interp, objv[4]), |
---|
181 | tcl_cast<T4>::from(interp, objv[5])); |
---|
182 | } |
---|
183 | else |
---|
184 | { |
---|
185 | dispatch<R>::template do_dispatch<T1, T2, T3, T4>( |
---|
186 | interp, boost::bind(f_, p, _1, _2, _3, _4), |
---|
187 | tcl_cast<T1>::from(interp, objv[2]), |
---|
188 | tcl_cast<T2>::from(interp, objv[3]), |
---|
189 | tcl_cast<T3>::from(interp, objv[4]), |
---|
190 | tcl_cast<T4>::from(interp, objv[5])); |
---|
191 | } |
---|
192 | } |
---|
193 | |
---|
194 | private: |
---|
195 | mem_type f_; |
---|
196 | cmem_type cf_; |
---|
197 | bool cmem_; |
---|
198 | }; |
---|
199 | |
---|
200 | template <class C, typename R, typename T1, typename T2, typename T3, |
---|
201 | typename T4, typename T5> |
---|
202 | class method5 : public object_cmd_base |
---|
203 | { |
---|
204 | typedef R (C::*mem_type)(T1, T2, T3, T4, T5); |
---|
205 | typedef R (C::*cmem_type)(T1, T2, T3, T4, T5) const; |
---|
206 | |
---|
207 | public: |
---|
208 | method5(mem_type f) : f_(f), cmem_(false) {} |
---|
209 | method5(cmem_type f) : cf_(f), cmem_(true) {} |
---|
210 | |
---|
211 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
212 | int objc, Tcl_Obj * CONST objv[], policies const &) |
---|
213 | { |
---|
214 | check_params_no(objc, 7); |
---|
215 | |
---|
216 | C *p = static_cast<C*>(pv); |
---|
217 | if (cmem_) |
---|
218 | { |
---|
219 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>( |
---|
220 | interp, boost::bind(cf_, p, _1, _2, _3, _4, _5), |
---|
221 | tcl_cast<T1>::from(interp, objv[2]), |
---|
222 | tcl_cast<T2>::from(interp, objv[3]), |
---|
223 | tcl_cast<T3>::from(interp, objv[4]), |
---|
224 | tcl_cast<T4>::from(interp, objv[5]), |
---|
225 | tcl_cast<T5>::from(interp, objv[6])); |
---|
226 | } |
---|
227 | else |
---|
228 | { |
---|
229 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>( |
---|
230 | interp, boost::bind(f_, p, _1, _2, _3, _4, _5), |
---|
231 | tcl_cast<T1>::from(interp, objv[2]), |
---|
232 | tcl_cast<T2>::from(interp, objv[3]), |
---|
233 | tcl_cast<T3>::from(interp, objv[4]), |
---|
234 | tcl_cast<T4>::from(interp, objv[5]), |
---|
235 | tcl_cast<T5>::from(interp, objv[6])); |
---|
236 | } |
---|
237 | } |
---|
238 | |
---|
239 | private: |
---|
240 | mem_type f_; |
---|
241 | cmem_type cf_; |
---|
242 | bool cmem_; |
---|
243 | }; |
---|
244 | |
---|
245 | template <class C, typename R, typename T1, typename T2, typename T3, |
---|
246 | typename T4, typename T5, typename T6> |
---|
247 | class method6 : public object_cmd_base |
---|
248 | { |
---|
249 | typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6); |
---|
250 | typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6) const; |
---|
251 | |
---|
252 | public: |
---|
253 | method6(mem_type f) : f_(f), cmem_(false) {} |
---|
254 | method6(cmem_type f) : cf_(f), cmem_(true) {} |
---|
255 | |
---|
256 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
257 | int objc, Tcl_Obj * CONST objv[], policies const &) |
---|
258 | { |
---|
259 | check_params_no(objc, 8); |
---|
260 | |
---|
261 | C *p = static_cast<C*>(pv); |
---|
262 | if (cmem_) |
---|
263 | { |
---|
264 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>( |
---|
265 | interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6), |
---|
266 | tcl_cast<T1>::from(interp, objv[2]), |
---|
267 | tcl_cast<T2>::from(interp, objv[3]), |
---|
268 | tcl_cast<T3>::from(interp, objv[4]), |
---|
269 | tcl_cast<T4>::from(interp, objv[5]), |
---|
270 | tcl_cast<T5>::from(interp, objv[6]), |
---|
271 | tcl_cast<T6>::from(interp, objv[7])); |
---|
272 | } |
---|
273 | else |
---|
274 | { |
---|
275 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>( |
---|
276 | interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6), |
---|
277 | tcl_cast<T1>::from(interp, objv[2]), |
---|
278 | tcl_cast<T2>::from(interp, objv[3]), |
---|
279 | tcl_cast<T3>::from(interp, objv[4]), |
---|
280 | tcl_cast<T4>::from(interp, objv[5]), |
---|
281 | tcl_cast<T5>::from(interp, objv[6]), |
---|
282 | tcl_cast<T6>::from(interp, objv[7])); |
---|
283 | } |
---|
284 | } |
---|
285 | |
---|
286 | private: |
---|
287 | mem_type f_; |
---|
288 | cmem_type cf_; |
---|
289 | bool cmem_; |
---|
290 | }; |
---|
291 | |
---|
292 | template <class C, typename R, typename T1, typename T2, typename T3, |
---|
293 | typename T4, typename T5, typename T6, typename T7> |
---|
294 | class method7 : public object_cmd_base |
---|
295 | { |
---|
296 | typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7); |
---|
297 | typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7) const; |
---|
298 | |
---|
299 | public: |
---|
300 | method7(mem_type f) : f_(f), cmem_(false) {} |
---|
301 | method7(cmem_type f) : cf_(f), cmem_(true) {} |
---|
302 | |
---|
303 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
304 | int objc, Tcl_Obj * CONST objv[], policies const &) |
---|
305 | { |
---|
306 | check_params_no(objc, 9); |
---|
307 | |
---|
308 | C *p = static_cast<C*>(pv); |
---|
309 | if (cmem_) |
---|
310 | { |
---|
311 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>( |
---|
312 | interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6, _7), |
---|
313 | tcl_cast<T1>::from(interp, objv[2]), |
---|
314 | tcl_cast<T2>::from(interp, objv[3]), |
---|
315 | tcl_cast<T3>::from(interp, objv[4]), |
---|
316 | tcl_cast<T4>::from(interp, objv[5]), |
---|
317 | tcl_cast<T5>::from(interp, objv[6]), |
---|
318 | tcl_cast<T6>::from(interp, objv[7]), |
---|
319 | tcl_cast<T7>::from(interp, objv[8])); |
---|
320 | } |
---|
321 | else |
---|
322 | { |
---|
323 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>( |
---|
324 | interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6, _7), |
---|
325 | tcl_cast<T1>::from(interp, objv[2]), |
---|
326 | tcl_cast<T2>::from(interp, objv[3]), |
---|
327 | tcl_cast<T3>::from(interp, objv[4]), |
---|
328 | tcl_cast<T4>::from(interp, objv[5]), |
---|
329 | tcl_cast<T5>::from(interp, objv[6]), |
---|
330 | tcl_cast<T6>::from(interp, objv[7]), |
---|
331 | tcl_cast<T7>::from(interp, objv[8])); |
---|
332 | } |
---|
333 | } |
---|
334 | |
---|
335 | private: |
---|
336 | mem_type f_; |
---|
337 | cmem_type cf_; |
---|
338 | bool cmem_; |
---|
339 | }; |
---|
340 | |
---|
341 | template <class C, typename R, typename T1, typename T2, typename T3, |
---|
342 | typename T4, typename T5, typename T6, typename T7, typename T8> |
---|
343 | class method8 : public object_cmd_base |
---|
344 | { |
---|
345 | typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8); |
---|
346 | typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8) const; |
---|
347 | |
---|
348 | public: |
---|
349 | method8(mem_type f) : f_(f), cmem_(false) {} |
---|
350 | method8(cmem_type f) : cf_(f), cmem_(true) {} |
---|
351 | |
---|
352 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
353 | int objc, Tcl_Obj * CONST objv[], policies const &) |
---|
354 | { |
---|
355 | check_params_no(objc, 10); |
---|
356 | |
---|
357 | C *p = static_cast<C*>(pv); |
---|
358 | if (cmem_) |
---|
359 | { |
---|
360 | dispatch<R>::template do_dispatch< |
---|
361 | T1, T2, T3, T4, T5, T6, T7, T8>( |
---|
362 | interp, boost::bind(cf_, p, |
---|
363 | _1, _2, _3, _4, _5, _6, _7, _8), |
---|
364 | tcl_cast<T1>::from(interp, objv[2]), |
---|
365 | tcl_cast<T2>::from(interp, objv[3]), |
---|
366 | tcl_cast<T3>::from(interp, objv[4]), |
---|
367 | tcl_cast<T4>::from(interp, objv[5]), |
---|
368 | tcl_cast<T5>::from(interp, objv[6]), |
---|
369 | tcl_cast<T6>::from(interp, objv[7]), |
---|
370 | tcl_cast<T7>::from(interp, objv[8]), |
---|
371 | tcl_cast<T8>::from(interp, objv[9])); |
---|
372 | } |
---|
373 | else |
---|
374 | { |
---|
375 | dispatch<R>::template do_dispatch< |
---|
376 | T1, T2, T3, T4, T5, T6, T7, T8>( |
---|
377 | interp, boost::bind(f_, p, |
---|
378 | _1, _2, _3, _4, _5, _6, _7, _8), |
---|
379 | tcl_cast<T1>::from(interp, objv[2]), |
---|
380 | tcl_cast<T2>::from(interp, objv[3]), |
---|
381 | tcl_cast<T3>::from(interp, objv[4]), |
---|
382 | tcl_cast<T4>::from(interp, objv[5]), |
---|
383 | tcl_cast<T5>::from(interp, objv[6]), |
---|
384 | tcl_cast<T6>::from(interp, objv[7]), |
---|
385 | tcl_cast<T7>::from(interp, objv[8]), |
---|
386 | tcl_cast<T8>::from(interp, objv[9])); |
---|
387 | } |
---|
388 | } |
---|
389 | |
---|
390 | private: |
---|
391 | mem_type f_; |
---|
392 | cmem_type cf_; |
---|
393 | bool cmem_; |
---|
394 | }; |
---|
395 | |
---|
396 | template <class C, typename R, typename T1, typename T2, typename T3, |
---|
397 | typename T4, typename T5, typename T6, typename T7, typename T8, |
---|
398 | typename T9> |
---|
399 | class method9 : public object_cmd_base |
---|
400 | { |
---|
401 | typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9); |
---|
402 | typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const; |
---|
403 | |
---|
404 | public: |
---|
405 | method9(mem_type f) : f_(f), cmem_(false) {} |
---|
406 | method9(cmem_type f) : cf_(f), cmem_(true) {} |
---|
407 | |
---|
408 | virtual void invoke(void *pv, Tcl_Interp *interp, |
---|
409 | int objc, Tcl_Obj * CONST objv[], policies const &) |
---|
410 | { |
---|
411 | check_params_no(objc, 11); |
---|
412 | |
---|
413 | C *p = static_cast<C*>(pv); |
---|
414 | if (cmem_) |
---|
415 | { |
---|
416 | dispatch<R>::template do_dispatch< |
---|
417 | T1, T2, T3, T4, T5, T6, T7, T8, T9>( |
---|
418 | interp, boost::bind(cf_, p, |
---|
419 | _1, _2, _3, _4, _5, _6, _7, _8, _9), |
---|
420 | tcl_cast<T1>::from(interp, objv[2]), |
---|
421 | tcl_cast<T2>::from(interp, objv[3]), |
---|
422 | tcl_cast<T3>::from(interp, objv[4]), |
---|
423 | tcl_cast<T4>::from(interp, objv[5]), |
---|
424 | tcl_cast<T5>::from(interp, objv[6]), |
---|
425 | tcl_cast<T6>::from(interp, objv[7]), |
---|
426 | tcl_cast<T7>::from(interp, objv[8]), |
---|
427 | tcl_cast<T8>::from(interp, objv[9]), |
---|
428 | tcl_cast<T9>::from(interp, objv[10])); |
---|
429 | } |
---|
430 | else |
---|
431 | { |
---|
432 | dispatch<R>::template do_dispatch< |
---|
433 | T1, T2, T3, T4, T5, T6, T7, T8, T9>( |
---|
434 | interp, boost::bind(f_, p, |
---|
435 | _1, _2, _3, _4, _5, _6, _7, _8, _9), |
---|
436 | tcl_cast<T1>::from(interp, objv[2]), |
---|
437 | tcl_cast<T2>::from(interp, objv[3]), |
---|
438 | tcl_cast<T3>::from(interp, objv[4]), |
---|
439 | tcl_cast<T4>::from(interp, objv[5]), |
---|
440 | tcl_cast<T5>::from(interp, objv[6]), |
---|
441 | tcl_cast<T6>::from(interp, objv[7]), |
---|
442 | tcl_cast<T7>::from(interp, objv[8]), |
---|
443 | tcl_cast<T8>::from(interp, objv[9]), |
---|
444 | tcl_cast<T9>::from(interp, objv[10])); |
---|
445 | } |
---|
446 | } |
---|
447 | |
---|
448 | private: |
---|
449 | mem_type f_; |
---|
450 | cmem_type cf_; |
---|
451 | bool cmem_; |
---|
452 | }; |
---|