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 callback1<R, object const &> : public callback_base |
---|
15 | { |
---|
16 | typedef object const & T1; |
---|
17 | typedef R (*functor_type)(T1); |
---|
18 | enum { var_start = 1 }; |
---|
19 | |
---|
20 | public: |
---|
21 | callback1(functor_type f) : f_(f) {} |
---|
22 | |
---|
23 | virtual void invoke(Tcl_Interp *interp, |
---|
24 | int objc, Tcl_Obj * CONST objv[], |
---|
25 | policies const &pol) |
---|
26 | { |
---|
27 | object t1 = get_var_params(interp, objc, objv, var_start, pol); |
---|
28 | dispatch<R>::template do_dispatch<T1>(interp, f_, |
---|
29 | t1); |
---|
30 | } |
---|
31 | |
---|
32 | private: |
---|
33 | functor_type f_; |
---|
34 | }; |
---|
35 | |
---|
36 | template <typename R, typename T1> |
---|
37 | class callback2<R, T1, object const &> : public callback_base |
---|
38 | { |
---|
39 | typedef object const & T2; |
---|
40 | typedef R (*functor_type)(T1, T2); |
---|
41 | enum { var_start = 2 }; |
---|
42 | |
---|
43 | public: |
---|
44 | callback2(functor_type f) : f_(f) {} |
---|
45 | |
---|
46 | virtual void invoke(Tcl_Interp *interp, |
---|
47 | int objc, Tcl_Obj * CONST objv[], |
---|
48 | policies const &pol) |
---|
49 | { |
---|
50 | object t2 = get_var_params(interp, objc, objv, var_start, pol); |
---|
51 | dispatch<R>::template do_dispatch<T1, T2>(interp, f_, |
---|
52 | tcl_cast<T1>::from(interp, objv[1]), |
---|
53 | t2); |
---|
54 | } |
---|
55 | |
---|
56 | private: |
---|
57 | functor_type f_; |
---|
58 | }; |
---|
59 | |
---|
60 | template <typename R, typename T1, typename T2> |
---|
61 | class callback3<R, T1, T2, object const &> : public callback_base |
---|
62 | { |
---|
63 | typedef object const & T3; |
---|
64 | typedef R (*functor_type)(T1, T2, T3); |
---|
65 | enum { var_start = 3 }; |
---|
66 | |
---|
67 | public: |
---|
68 | callback3(functor_type f) : f_(f) {} |
---|
69 | |
---|
70 | virtual void invoke(Tcl_Interp *interp, |
---|
71 | int objc, Tcl_Obj * CONST objv[], |
---|
72 | policies const &pol) |
---|
73 | { |
---|
74 | object t3 = get_var_params(interp, objc, objv, var_start, pol); |
---|
75 | dispatch<R>::template do_dispatch<T1, T2, T3>(interp, f_, |
---|
76 | tcl_cast<T1>::from(interp, objv[1]), |
---|
77 | tcl_cast<T2>::from(interp, objv[2]), |
---|
78 | t3); |
---|
79 | } |
---|
80 | |
---|
81 | private: |
---|
82 | functor_type f_; |
---|
83 | }; |
---|
84 | |
---|
85 | template <typename R, typename T1, typename T2, typename T3> |
---|
86 | class callback4<R, T1, T2, T3, object const &> : public callback_base |
---|
87 | { |
---|
88 | typedef object const & T4; |
---|
89 | typedef R (*functor_type)(T1, T2, T3, T4); |
---|
90 | enum { var_start = 4 }; |
---|
91 | |
---|
92 | public: |
---|
93 | callback4(functor_type f) : f_(f) {} |
---|
94 | |
---|
95 | virtual void invoke(Tcl_Interp *interp, |
---|
96 | int objc, Tcl_Obj * CONST objv[], |
---|
97 | policies const &pol) |
---|
98 | { |
---|
99 | object t4 = get_var_params(interp, objc, objv, var_start, pol); |
---|
100 | dispatch<R>::template do_dispatch<T1, T2, T3, T4>(interp, f_, |
---|
101 | tcl_cast<T1>::from(interp, objv[1]), |
---|
102 | tcl_cast<T2>::from(interp, objv[2]), |
---|
103 | tcl_cast<T3>::from(interp, objv[3]), |
---|
104 | t4); |
---|
105 | } |
---|
106 | |
---|
107 | private: |
---|
108 | functor_type f_; |
---|
109 | }; |
---|
110 | |
---|
111 | template <typename R, typename T1, typename T2, typename T3, typename T4> |
---|
112 | class callback5<R, T1, T2, T3, T4, object const &> : public callback_base |
---|
113 | { |
---|
114 | typedef object const & T5; |
---|
115 | typedef R (*functor_type)(T1, T2, T3, T4, T5); |
---|
116 | enum { var_start = 5 }; |
---|
117 | |
---|
118 | public: |
---|
119 | callback5(functor_type f) : f_(f) {} |
---|
120 | |
---|
121 | virtual void invoke(Tcl_Interp *interp, |
---|
122 | int objc, Tcl_Obj * CONST objv[], |
---|
123 | policies const &pol) |
---|
124 | { |
---|
125 | object t5 = get_var_params(interp, objc, objv, var_start, pol); |
---|
126 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>( |
---|
127 | interp, f_, |
---|
128 | tcl_cast<T1>::from(interp, objv[1]), |
---|
129 | tcl_cast<T2>::from(interp, objv[2]), |
---|
130 | tcl_cast<T3>::from(interp, objv[3]), |
---|
131 | tcl_cast<T4>::from(interp, objv[4]), |
---|
132 | t5); |
---|
133 | } |
---|
134 | |
---|
135 | private: |
---|
136 | functor_type f_; |
---|
137 | }; |
---|
138 | |
---|
139 | template <typename R, typename T1, typename T2, typename T3, typename T4, |
---|
140 | typename T5> |
---|
141 | class callback6<R, T1, T2, T3, T4, T5, object const &> : public callback_base |
---|
142 | { |
---|
143 | typedef object const & T6; |
---|
144 | typedef R (*functor_type)(T1, T2, T3, T4, T5, T6); |
---|
145 | enum { var_start = 6 }; |
---|
146 | |
---|
147 | public: |
---|
148 | callback6(functor_type f) : f_(f) {} |
---|
149 | |
---|
150 | virtual void invoke(Tcl_Interp *interp, |
---|
151 | int objc, Tcl_Obj * CONST objv[], |
---|
152 | policies const &pol) |
---|
153 | { |
---|
154 | object t6 = get_var_params(interp, objc, objv, var_start, pol); |
---|
155 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>( |
---|
156 | interp, f_, |
---|
157 | tcl_cast<T1>::from(interp, objv[1]), |
---|
158 | tcl_cast<T2>::from(interp, objv[2]), |
---|
159 | tcl_cast<T3>::from(interp, objv[3]), |
---|
160 | tcl_cast<T4>::from(interp, objv[4]), |
---|
161 | tcl_cast<T5>::from(interp, objv[5]), |
---|
162 | t6); |
---|
163 | } |
---|
164 | |
---|
165 | private: |
---|
166 | functor_type f_; |
---|
167 | }; |
---|
168 | |
---|
169 | template <typename R, typename T1, typename T2, typename T3, typename T4, |
---|
170 | typename T5, typename T6> |
---|
171 | class callback7<R, T1, T2, T3, T4, T5, T6, object const &> |
---|
172 | : public callback_base |
---|
173 | { |
---|
174 | typedef object const & T7; |
---|
175 | typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7); |
---|
176 | enum { var_start = 7 }; |
---|
177 | |
---|
178 | public: |
---|
179 | callback7(functor_type f) : f_(f) {} |
---|
180 | |
---|
181 | virtual void invoke(Tcl_Interp *interp, |
---|
182 | int objc, Tcl_Obj * CONST objv[], |
---|
183 | policies const &pol) |
---|
184 | { |
---|
185 | object t7 = get_var_params(interp, objc, objv, var_start, pol); |
---|
186 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>( |
---|
187 | interp, f_, |
---|
188 | tcl_cast<T1>::from(interp, objv[1]), |
---|
189 | tcl_cast<T2>::from(interp, objv[2]), |
---|
190 | tcl_cast<T3>::from(interp, objv[3]), |
---|
191 | tcl_cast<T4>::from(interp, objv[4]), |
---|
192 | tcl_cast<T5>::from(interp, objv[5]), |
---|
193 | tcl_cast<T6>::from(interp, objv[6]), |
---|
194 | t7); |
---|
195 | } |
---|
196 | |
---|
197 | private: |
---|
198 | functor_type f_; |
---|
199 | }; |
---|
200 | |
---|
201 | template <typename R, typename T1, typename T2, typename T3, typename T4, |
---|
202 | typename T5, typename T6, typename T7> |
---|
203 | class callback8<R, T1, T2, T3, T4, T5, T6, T7, object const &> |
---|
204 | : public callback_base |
---|
205 | { |
---|
206 | typedef object const & T8; |
---|
207 | typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8); |
---|
208 | enum { var_start = 8 }; |
---|
209 | |
---|
210 | public: |
---|
211 | callback8(functor_type f) : f_(f) {} |
---|
212 | |
---|
213 | virtual void invoke(Tcl_Interp *interp, |
---|
214 | int objc, Tcl_Obj * CONST objv[], |
---|
215 | policies const &pol) |
---|
216 | { |
---|
217 | object t8 = get_var_params(interp, objc, objv, var_start, pol); |
---|
218 | dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7, T8>( |
---|
219 | interp, f_, |
---|
220 | tcl_cast<T1>::from(interp, objv[1]), |
---|
221 | tcl_cast<T2>::from(interp, objv[2]), |
---|
222 | tcl_cast<T3>::from(interp, objv[3]), |
---|
223 | tcl_cast<T4>::from(interp, objv[4]), |
---|
224 | tcl_cast<T5>::from(interp, objv[5]), |
---|
225 | tcl_cast<T6>::from(interp, objv[6]), |
---|
226 | tcl_cast<T7>::from(interp, objv[7]), |
---|
227 | t8); |
---|
228 | } |
---|
229 | |
---|
230 | private: |
---|
231 | functor_type f_; |
---|
232 | }; |
---|
233 | |
---|
234 | template <typename R, typename T1, typename T2, typename T3, typename T4, |
---|
235 | typename T5, typename T6, typename T7, typename T8> |
---|
236 | class callback9<R, T1, T2, T3, T4, T5, T6, T7, T8, object const &> |
---|
237 | : public callback_base |
---|
238 | { |
---|
239 | typedef object const & T9; |
---|
240 | typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9); |
---|
241 | enum { var_start = 9 }; |
---|
242 | |
---|
243 | public: |
---|
244 | callback9(functor_type f) : f_(f) {} |
---|
245 | |
---|
246 | virtual void invoke(Tcl_Interp *interp, |
---|
247 | int objc, Tcl_Obj * CONST objv[], |
---|
248 | policies const &pol) |
---|
249 | { |
---|
250 | object t9 = get_var_params(interp, objc, objv, var_start, pol); |
---|
251 | dispatch<R>::template do_dispatch< |
---|
252 | T1, T2, T3, T4, T5, T6, T7, T8, T9>( |
---|
253 | interp, f_, |
---|
254 | tcl_cast<T1>::from(interp, objv[1]), |
---|
255 | tcl_cast<T2>::from(interp, objv[2]), |
---|
256 | tcl_cast<T3>::from(interp, objv[3]), |
---|
257 | tcl_cast<T4>::from(interp, objv[4]), |
---|
258 | tcl_cast<T5>::from(interp, objv[5]), |
---|
259 | tcl_cast<T6>::from(interp, objv[6]), |
---|
260 | tcl_cast<T7>::from(interp, objv[7]), |
---|
261 | tcl_cast<T8>::from(interp, objv[8]), |
---|
262 | t9); |
---|
263 | } |
---|
264 | |
---|
265 | private: |
---|
266 | functor_type f_; |
---|
267 | }; |
---|