Debian Codegraph @

3rdparty/toluapp/src/tests/tarraybind.c

raw
1 /*
2 ** Lua binding: tarray
3 ** Generated automatically by tolua 5.0a-CDLVS2 on 08/08/03 17:06:22.
4 */
5
6 #ifndef __cplusplus
7 #include "stdlib.h"
8 #endif
9 #include "string.h"
10
11 #include "tolua.h"
12
13 /* Exported function */
14 TOLUA_API int tolua_tarray_open (lua_State* tolua_S);
15
16 #include "tarray.h"
17
18 /* function to release collected object via destructor */
19 #ifdef __cplusplus
20
21 static int tolua_collect_Point (lua_State* tolua_S)
22 {
23 Point* self = (Point*) tolua_tousertype(tolua_S,1,0);
24 delete self;
25 return 0;
26 }
27 #endif
28
29
30 /* function to register type */
31 static void tolua_reg_types (lua_State* tolua_S)
32 {
33 tolua_usertype(tolua_S,"Array");
34 tolua_usertype(tolua_S,"Point");
35 }
36
37 /* get function: x of class Point */
38 static int tolua_get_Point_x(lua_State* tolua_S)
39 {
40 Point* self = (Point*) tolua_tousertype(tolua_S,1,0);
41 #ifndef TOLUA_RELEASE
42 if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL);
43 #endif
44 tolua_pushnumber(tolua_S,(double)self->x);
45 return 1;
46 }
47
48 /* set function: x of class Point */
49 static int tolua_set_Point_x(lua_State* tolua_S)
50 {
51 Point* self = (Point*) tolua_tousertype(tolua_S,1,0);
52 #ifndef TOLUA_RELEASE
53 tolua_Error tolua_err;
54 if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL);
55 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
56 tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
57 #endif
58 self->x = ((float) tolua_tonumber(tolua_S,2,0));
59 return 0;
60 }
61
62 /* get function: y of class Point */
63 static int tolua_get_Point_y(lua_State* tolua_S)
64 {
65 Point* self = (Point*) tolua_tousertype(tolua_S,1,0);
66 #ifndef TOLUA_RELEASE
67 if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL);
68 #endif
69 tolua_pushnumber(tolua_S,(double)self->y);
70 return 1;
71 }
72
73 /* set function: y of class Point */
74 static int tolua_set_Point_y(lua_State* tolua_S)
75 {
76 Point* self = (Point*) tolua_tousertype(tolua_S,1,0);
77 #ifndef TOLUA_RELEASE
78 tolua_Error tolua_err;
79 if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL);
80 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
81 tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
82 #endif
83 self->y = ((float) tolua_tonumber(tolua_S,2,0));
84 return 0;
85 }
86
87 /* get function: a */
88 static int tolua_get_tarray_a(lua_State* tolua_S)
89 {
90 int tolua_index;
91 #ifndef TOLUA_RELEASE
92 {
93 tolua_Error tolua_err;
94 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
95 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
96 }
97 #endif
98 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
99 #ifndef TOLUA_RELEASE
100 if (tolua_index<0 || tolua_index>=10)
101 tolua_error(tolua_S,"array indexing out of range.",NULL);
102 #endif
103 tolua_pushnumber(tolua_S,(double)a[tolua_index]);
104 return 1;
105 }
106
107 /* set function: a */
108 static int tolua_set_tarray_a(lua_State* tolua_S)
109 {
110 int tolua_index;
111 #ifndef TOLUA_RELEASE
112 {
113 tolua_Error tolua_err;
114 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
115 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
116 }
117 #endif
118 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
119 #ifndef TOLUA_RELEASE
120 if (tolua_index<0 || tolua_index>=10)
121 tolua_error(tolua_S,"array indexing out of range.",NULL);
122 #endif
123 a[tolua_index] = ((int) tolua_tonumber(tolua_S,3,0));
124 return 0;
125 }
126
127 /* get function: p */
128 static int tolua_get_tarray_p(lua_State* tolua_S)
129 {
130 int tolua_index;
131 #ifndef TOLUA_RELEASE
132 {
133 tolua_Error tolua_err;
134 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
135 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
136 }
137 #endif
138 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
139 #ifndef TOLUA_RELEASE
140 if (tolua_index<0 || tolua_index>=10)
141 tolua_error(tolua_S,"array indexing out of range.",NULL);
142 #endif
143 tolua_pushusertype(tolua_S,(void*)&p[tolua_index],"const Point");
144 return 1;
145 }
146
147 /* get function: pp */
148 static int tolua_get_tarray_pp(lua_State* tolua_S)
149 {
150 int tolua_index;
151 #ifndef TOLUA_RELEASE
152 {
153 tolua_Error tolua_err;
154 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
155 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
156 }
157 #endif
158 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
159 #ifndef TOLUA_RELEASE
160 if (tolua_index<0 || tolua_index>=10)
161 tolua_error(tolua_S,"array indexing out of range.",NULL);
162 #endif
163 tolua_pushusertype(tolua_S,(void*)pp[tolua_index],"Point");
164 return 1;
165 }
166
167 /* set function: pp */
168 static int tolua_set_tarray_pp(lua_State* tolua_S)
169 {
170 int tolua_index;
171 #ifndef TOLUA_RELEASE
172 {
173 tolua_Error tolua_err;
174 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
175 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
176 }
177 #endif
178 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
179 #ifndef TOLUA_RELEASE
180 if (tolua_index<0 || tolua_index>=10)
181 tolua_error(tolua_S,"array indexing out of range.",NULL);
182 #endif
183 pp[tolua_index] = ((Point*) tolua_tousertype(tolua_S,3,0));
184 return 0;
185 }
186
187 /* get function: ma */
188 static int tolua_get_tarray_M_ma(lua_State* tolua_S)
189 {
190 int tolua_index;
191 #ifndef TOLUA_RELEASE
192 {
193 tolua_Error tolua_err;
194 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
195 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
196 }
197 #endif
198 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
199 #ifndef TOLUA_RELEASE
200 if (tolua_index<0 || tolua_index>=10)
201 tolua_error(tolua_S,"array indexing out of range.",NULL);
202 #endif
203 tolua_pushnumber(tolua_S,(double)ma[tolua_index]);
204 return 1;
205 }
206
207 /* set function: ma */
208 static int tolua_set_tarray_M_ma(lua_State* tolua_S)
209 {
210 int tolua_index;
211 #ifndef TOLUA_RELEASE
212 {
213 tolua_Error tolua_err;
214 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
215 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
216 }
217 #endif
218 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
219 #ifndef TOLUA_RELEASE
220 if (tolua_index<0 || tolua_index>=10)
221 tolua_error(tolua_S,"array indexing out of range.",NULL);
222 #endif
223 ma[tolua_index] = ((int) tolua_tonumber(tolua_S,3,0));
224 return 0;
225 }
226
227 /* get function: mp */
228 static int tolua_get_tarray_M_mp(lua_State* tolua_S)
229 {
230 int tolua_index;
231 #ifndef TOLUA_RELEASE
232 {
233 tolua_Error tolua_err;
234 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
235 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
236 }
237 #endif
238 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
239 #ifndef TOLUA_RELEASE
240 if (tolua_index<0 || tolua_index>=10)
241 tolua_error(tolua_S,"array indexing out of range.",NULL);
242 #endif
243 tolua_pushusertype(tolua_S,(void*)&mp[tolua_index],"const Point");
244 return 1;
245 }
246
247 /* get function: mpp */
248 static int tolua_get_tarray_M_mpp(lua_State* tolua_S)
249 {
250 int tolua_index;
251 #ifndef TOLUA_RELEASE
252 {
253 tolua_Error tolua_err;
254 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
255 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
256 }
257 #endif
258 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
259 #ifndef TOLUA_RELEASE
260 if (tolua_index<0 || tolua_index>=10)
261 tolua_error(tolua_S,"array indexing out of range.",NULL);
262 #endif
263 tolua_pushusertype(tolua_S,(void*)mpp[tolua_index],"Point");
264 return 1;
265 }
266
267 /* set function: mpp */
268 static int tolua_set_tarray_M_mpp(lua_State* tolua_S)
269 {
270 int tolua_index;
271 #ifndef TOLUA_RELEASE
272 {
273 tolua_Error tolua_err;
274 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
275 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
276 }
277 #endif
278 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
279 #ifndef TOLUA_RELEASE
280 if (tolua_index<0 || tolua_index>=10)
281 tolua_error(tolua_S,"array indexing out of range.",NULL);
282 #endif
283 mpp[tolua_index] = ((Point*) tolua_tousertype(tolua_S,3,0));
284 return 0;
285 }
286
287 /* get function: a of class Array */
288 static int tolua_get_tarray_Array_a(lua_State* tolua_S)
289 {
290 int tolua_index;
291 Array* self;
292 lua_pushstring(tolua_S,".self");
293 lua_rawget(tolua_S,1);
294 self = (Array*) lua_touserdata(tolua_S,-1);
295 #ifndef TOLUA_RELEASE
296 {
297 tolua_Error tolua_err;
298 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
299 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
300 }
301 #endif
302 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
303 #ifndef TOLUA_RELEASE
304 if (tolua_index<0 || tolua_index>=10)
305 tolua_error(tolua_S,"array indexing out of range.",NULL);
306 #endif
307 tolua_pushnumber(tolua_S,(double)self->a[tolua_index]);
308 return 1;
309 }
310
311 /* set function: a of class Array */
312 static int tolua_set_tarray_Array_a(lua_State* tolua_S)
313 {
314 int tolua_index;
315 Array* self;
316 lua_pushstring(tolua_S,".self");
317 lua_rawget(tolua_S,1);
318 self = (Array*) lua_touserdata(tolua_S,-1);
319 #ifndef TOLUA_RELEASE
320 {
321 tolua_Error tolua_err;
322 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
323 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
324 }
325 #endif
326 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
327 #ifndef TOLUA_RELEASE
328 if (tolua_index<0 || tolua_index>=10)
329 tolua_error(tolua_S,"array indexing out of range.",NULL);
330 #endif
331 self->a[tolua_index] = ((int) tolua_tonumber(tolua_S,3,0));
332 return 0;
333 }
334
335 /* get function: p of class Array */
336 static int tolua_get_tarray_Array_p(lua_State* tolua_S)
337 {
338 int tolua_index;
339 Array* self;
340 lua_pushstring(tolua_S,".self");
341 lua_rawget(tolua_S,1);
342 self = (Array*) lua_touserdata(tolua_S,-1);
343 #ifndef TOLUA_RELEASE
344 {
345 tolua_Error tolua_err;
346 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
347 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
348 }
349 #endif
350 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
351 #ifndef TOLUA_RELEASE
352 if (tolua_index<0 || tolua_index>=10)
353 tolua_error(tolua_S,"array indexing out of range.",NULL);
354 #endif
355 tolua_pushusertype(tolua_S,(void*)&self->p[tolua_index],"Point");
356 return 1;
357 }
358
359 /* set function: p of class Array */
360 static int tolua_set_tarray_Array_p(lua_State* tolua_S)
361 {
362 int tolua_index;
363 Array* self;
364 lua_pushstring(tolua_S,".self");
365 lua_rawget(tolua_S,1);
366 self = (Array*) lua_touserdata(tolua_S,-1);
367 #ifndef TOLUA_RELEASE
368 {
369 tolua_Error tolua_err;
370 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
371 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
372 }
373 #endif
374 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
375 #ifndef TOLUA_RELEASE
376 if (tolua_index<0 || tolua_index>=10)
377 tolua_error(tolua_S,"array indexing out of range.",NULL);
378 #endif
379 self->p[tolua_index] = *((Point*) tolua_tousertype(tolua_S,3,0));
380 return 0;
381 }
382
383 /* get function: pp of class Array */
384 static int tolua_get_tarray_Array_pp(lua_State* tolua_S)
385 {
386 int tolua_index;
387 Array* self;
388 lua_pushstring(tolua_S,".self");
389 lua_rawget(tolua_S,1);
390 self = (Array*) lua_touserdata(tolua_S,-1);
391 #ifndef TOLUA_RELEASE
392 {
393 tolua_Error tolua_err;
394 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
395 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
396 }
397 #endif
398 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
399 #ifndef TOLUA_RELEASE
400 if (tolua_index<0 || tolua_index>=10)
401 tolua_error(tolua_S,"array indexing out of range.",NULL);
402 #endif
403 tolua_pushusertype(tolua_S,(void*)self->pp[tolua_index],"Point");
404 return 1;
405 }
406
407 /* set function: pp of class Array */
408 static int tolua_set_tarray_Array_pp(lua_State* tolua_S)
409 {
410 int tolua_index;
411 Array* self;
412 lua_pushstring(tolua_S,".self");
413 lua_rawget(tolua_S,1);
414 self = (Array*) lua_touserdata(tolua_S,-1);
415 #ifndef TOLUA_RELEASE
416 {
417 tolua_Error tolua_err;
418 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
419 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
420 }
421 #endif
422 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
423 #ifndef TOLUA_RELEASE
424 if (tolua_index<0 || tolua_index>=10)
425 tolua_error(tolua_S,"array indexing out of range.",NULL);
426 #endif
427 self->pp[tolua_index] = ((Point*) tolua_tousertype(tolua_S,3,0));
428 return 0;
429 }
430
431 /* get function: array */
432 static int tolua_get_array(lua_State* tolua_S)
433 {
434 tolua_pushusertype(tolua_S,(void*)&array,"Array");
435 return 1;
436 }
437
438 /* set function: array */
439 static int tolua_set_array(lua_State* tolua_S)
440 {
441 #ifndef TOLUA_RELEASE
442 tolua_Error tolua_err;
443 if (!tolua_isusertype(tolua_S,2,"Array",0,&tolua_err))
444 tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
445 #endif
446 array = *((Array*) tolua_tousertype(tolua_S,2,0));
447 return 0;
448 }
449
450 /* get function: parray */
451 static int tolua_get_parray_ptr(lua_State* tolua_S)
452 {
453 tolua_pushusertype(tolua_S,(void*)parray,"Array");
454 return 1;
455 }
456
457 /* set function: parray */
458 static int tolua_set_parray_ptr(lua_State* tolua_S)
459 {
460 #ifndef TOLUA_RELEASE
461 tolua_Error tolua_err;
462 if (!tolua_isusertype(tolua_S,2,"Array",0,&tolua_err))
463 tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
464 #endif
465 parray = ((Array*) tolua_tousertype(tolua_S,2,0));
466 return 0;
467 }
468
469 /* Open function */
470 TOLUA_API int tolua_tarray_open (lua_State* tolua_S)
471 {
472 tolua_open(tolua_S);
473 tolua_reg_types(tolua_S);
474 tolua_module(tolua_S,NULL,1);
475 tolua_beginmodule(tolua_S,NULL);
476 #ifdef __cplusplus
477 tolua_cclass(tolua_S,"Point","Point","",tolua_collect_Point);
478 #else
479 tolua_cclass(tolua_S,"Point","Point","",NULL);
480 #endif
481 tolua_beginmodule(tolua_S,"Point");
482 tolua_variable(tolua_S,"x",tolua_get_Point_x,tolua_set_Point_x);
483 tolua_variable(tolua_S,"y",tolua_get_Point_y,tolua_set_Point_y);
484 tolua_endmodule(tolua_S);
485 tolua_array(tolua_S,"a",tolua_get_tarray_a,tolua_set_tarray_a);
486 tolua_array(tolua_S,"p",tolua_get_tarray_p,NULL);
487 tolua_array(tolua_S,"pp",tolua_get_tarray_pp,tolua_set_tarray_pp);
488 tolua_module(tolua_S,"M",1);
489 tolua_beginmodule(tolua_S,"M");
490 tolua_array(tolua_S,"a",tolua_get_tarray_M_ma,tolua_set_tarray_M_ma);
491 tolua_array(tolua_S,"p",tolua_get_tarray_M_mp,NULL);
492 tolua_array(tolua_S,"pp",tolua_get_tarray_M_mpp,tolua_set_tarray_M_mpp);
493 tolua_endmodule(tolua_S);
494 tolua_cclass(tolua_S,"Array","Array","",NULL);
495 tolua_beginmodule(tolua_S,"Array");
496 tolua_array(tolua_S,"a",tolua_get_tarray_Array_a,tolua_set_tarray_Array_a);
497 tolua_array(tolua_S,"p",tolua_get_tarray_Array_p,tolua_set_tarray_Array_p);
498 tolua_array(tolua_S,"pp",tolua_get_tarray_Array_pp,tolua_set_tarray_Array_pp);
499 tolua_endmodule(tolua_S);
500 tolua_variable(tolua_S,"array",tolua_get_array,tolua_set_array);
501 tolua_variable(tolua_S,"parray",tolua_get_parray_ptr,tolua_set_parray_ptr);
502 tolua_endmodule(tolua_S);
503 return 1;
504 }