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