2dd0c8f3cf6f5e9d3c05ee82fa65b10e4e2c927c
[supertux.git] / src / scripting / wrapper.cpp
1 /**
2  * WARNING: This file is automatically generated from:
3  *  'src/scripting/wrapper.interface.hpp'
4  * DO NOT CHANGE
5  */
6 #include <config.h>
7
8 #include <new>
9 #include <assert.h>
10 #include <string>
11 #include <sstream>
12 #include <squirrel.h>
13 #include "squirrel_error.hpp"
14 #include "wrapper.interface.hpp"
15
16 namespace Scripting
17 {
18 namespace Wrapper
19 {
20
21 static int DisplayEffect_release_hook(SQUserPointer ptr, int )
22 {
23   Scripting::DisplayEffect* _this = reinterpret_cast<Scripting::DisplayEffect*> (ptr);
24   delete _this;
25   return 0;
26 }
27
28 static int DisplayEffect_fade_out_wrapper(HSQUIRRELVM v)
29 {
30   Scripting::DisplayEffect* _this;
31   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
32   float arg0;
33   sq_getfloat(v, 2, &arg0);
34   
35   _this->fade_out(arg0);
36   
37   return 0;
38 }
39
40 static int DisplayEffect_fade_in_wrapper(HSQUIRRELVM v)
41 {
42   Scripting::DisplayEffect* _this;
43   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
44   float arg0;
45   sq_getfloat(v, 2, &arg0);
46   
47   _this->fade_in(arg0);
48   
49   return 0;
50 }
51
52 static int DisplayEffect_set_black_wrapper(HSQUIRRELVM v)
53 {
54   Scripting::DisplayEffect* _this;
55   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
56   SQBool arg0;
57   sq_getbool(v, 2, &arg0);
58   
59   _this->set_black(arg0);
60   
61   return 0;
62 }
63
64 static int DisplayEffect_is_black_wrapper(HSQUIRRELVM v)
65 {
66   Scripting::DisplayEffect* _this;
67   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
68   
69   bool return_value = _this->is_black();
70   
71   sq_pushbool(v, return_value);
72   return 1;
73 }
74
75 static int DisplayEffect_sixteen_to_nine_wrapper(HSQUIRRELVM v)
76 {
77   Scripting::DisplayEffect* _this;
78   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
79   float arg0;
80   sq_getfloat(v, 2, &arg0);
81   
82   _this->sixteen_to_nine(arg0);
83   
84   return 0;
85 }
86
87 static int DisplayEffect_four_to_three_wrapper(HSQUIRRELVM v)
88 {
89   Scripting::DisplayEffect* _this;
90   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
91   float arg0;
92   sq_getfloat(v, 2, &arg0);
93   
94   _this->four_to_three(arg0);
95   
96   return 0;
97 }
98
99 static int Camera_release_hook(SQUserPointer ptr, int )
100 {
101   Scripting::Camera* _this = reinterpret_cast<Scripting::Camera*> (ptr);
102   delete _this;
103   return 0;
104 }
105
106 static int Camera_shake_wrapper(HSQUIRRELVM v)
107 {
108   Scripting::Camera* _this;
109   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
110   float arg0;
111   sq_getfloat(v, 2, &arg0);
112   float arg1;
113   sq_getfloat(v, 3, &arg1);
114   float arg2;
115   sq_getfloat(v, 4, &arg2);
116   
117   _this->shake(arg0, arg1, arg2);
118   
119   return 0;
120 }
121
122 static int Camera_set_pos_wrapper(HSQUIRRELVM v)
123 {
124   Scripting::Camera* _this;
125   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
126   float arg0;
127   sq_getfloat(v, 2, &arg0);
128   float arg1;
129   sq_getfloat(v, 3, &arg1);
130   
131   _this->set_pos(arg0, arg1);
132   
133   return 0;
134 }
135
136 static int Camera_set_mode_wrapper(HSQUIRRELVM v)
137 {
138   Scripting::Camera* _this;
139   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
140   const char* arg0;
141   sq_getstring(v, 2, &arg0);
142   
143   _this->set_mode(arg0);
144   
145   return 0;
146 }
147
148 static int Camera_scroll_to_wrapper(HSQUIRRELVM v)
149 {
150   Scripting::Camera* _this;
151   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
152   float arg0;
153   sq_getfloat(v, 2, &arg0);
154   float arg1;
155   sq_getfloat(v, 3, &arg1);
156   float arg2;
157   sq_getfloat(v, 4, &arg2);
158   
159   _this->scroll_to(arg0, arg1, arg2);
160   
161   return 0;
162 }
163
164 static int Level_release_hook(SQUserPointer ptr, int )
165 {
166   Scripting::Level* _this = reinterpret_cast<Scripting::Level*> (ptr);
167   delete _this;
168   return 0;
169 }
170
171 static int Level_finish_wrapper(HSQUIRRELVM v)
172 {
173   Scripting::Level* _this;
174   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
175   
176   _this->finish();
177   
178   return 0;
179 }
180
181 static int Level_spawn_wrapper(HSQUIRRELVM v)
182 {
183   Scripting::Level* _this;
184   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
185   const char* arg0;
186   sq_getstring(v, 2, &arg0);
187   const char* arg1;
188   sq_getstring(v, 3, &arg1);
189   
190   _this->spawn(arg0, arg1);
191   
192   return 0;
193 }
194
195 static int Level_flip_vertically_wrapper(HSQUIRRELVM v)
196 {
197   Scripting::Level* _this;
198   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
199   
200   _this->flip_vertically();
201   
202   return 0;
203 }
204
205 static int ScriptedObject_release_hook(SQUserPointer ptr, int )
206 {
207   Scripting::ScriptedObject* _this = reinterpret_cast<Scripting::ScriptedObject*> (ptr);
208   delete _this;
209   return 0;
210 }
211
212 static int ScriptedObject_set_action_wrapper(HSQUIRRELVM v)
213 {
214   Scripting::ScriptedObject* _this;
215   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
216   const char* arg0;
217   sq_getstring(v, 2, &arg0);
218   
219   _this->set_action(arg0);
220   
221   return 0;
222 }
223
224 static int ScriptedObject_get_action_wrapper(HSQUIRRELVM v)
225 {
226   Scripting::ScriptedObject* _this;
227   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
228   
229   std::string return_value = _this->get_action();
230   
231   sq_pushstring(v, return_value.c_str(), return_value.size());
232   return 1;
233 }
234
235 static int ScriptedObject_move_wrapper(HSQUIRRELVM v)
236 {
237   Scripting::ScriptedObject* _this;
238   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
239   float arg0;
240   sq_getfloat(v, 2, &arg0);
241   float arg1;
242   sq_getfloat(v, 3, &arg1);
243   
244   _this->move(arg0, arg1);
245   
246   return 0;
247 }
248
249 static int ScriptedObject_set_pos_wrapper(HSQUIRRELVM v)
250 {
251   Scripting::ScriptedObject* _this;
252   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
253   float arg0;
254   sq_getfloat(v, 2, &arg0);
255   float arg1;
256   sq_getfloat(v, 3, &arg1);
257   
258   _this->set_pos(arg0, arg1);
259   
260   return 0;
261 }
262
263 static int ScriptedObject_get_pos_x_wrapper(HSQUIRRELVM v)
264 {
265   Scripting::ScriptedObject* _this;
266   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
267   
268   float return_value = _this->get_pos_x();
269   
270   sq_pushfloat(v, return_value);
271   return 1;
272 }
273
274 static int ScriptedObject_get_pos_y_wrapper(HSQUIRRELVM v)
275 {
276   Scripting::ScriptedObject* _this;
277   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
278   
279   float return_value = _this->get_pos_y();
280   
281   sq_pushfloat(v, return_value);
282   return 1;
283 }
284
285 static int ScriptedObject_set_velocity_wrapper(HSQUIRRELVM v)
286 {
287   Scripting::ScriptedObject* _this;
288   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
289   float arg0;
290   sq_getfloat(v, 2, &arg0);
291   float arg1;
292   sq_getfloat(v, 3, &arg1);
293   
294   _this->set_velocity(arg0, arg1);
295   
296   return 0;
297 }
298
299 static int ScriptedObject_get_velocity_x_wrapper(HSQUIRRELVM v)
300 {
301   Scripting::ScriptedObject* _this;
302   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
303   
304   float return_value = _this->get_velocity_x();
305   
306   sq_pushfloat(v, return_value);
307   return 1;
308 }
309
310 static int ScriptedObject_get_velocity_y_wrapper(HSQUIRRELVM v)
311 {
312   Scripting::ScriptedObject* _this;
313   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
314   
315   float return_value = _this->get_velocity_y();
316   
317   sq_pushfloat(v, return_value);
318   return 1;
319 }
320
321 static int ScriptedObject_set_visible_wrapper(HSQUIRRELVM v)
322 {
323   Scripting::ScriptedObject* _this;
324   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
325   SQBool arg0;
326   sq_getbool(v, 2, &arg0);
327   
328   _this->set_visible(arg0);
329   
330   return 0;
331 }
332
333 static int ScriptedObject_is_visible_wrapper(HSQUIRRELVM v)
334 {
335   Scripting::ScriptedObject* _this;
336   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
337   
338   bool return_value = _this->is_visible();
339   
340   sq_pushbool(v, return_value);
341   return 1;
342 }
343
344 static int ScriptedObject_get_name_wrapper(HSQUIRRELVM v)
345 {
346   Scripting::ScriptedObject* _this;
347   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
348   
349   std::string return_value = _this->get_name();
350   
351   sq_pushstring(v, return_value.c_str(), return_value.size());
352   return 1;
353 }
354
355 static int Sound_release_hook(SQUserPointer ptr, int )
356 {
357   Scripting::Sound* _this = reinterpret_cast<Scripting::Sound*> (ptr);
358   delete _this;
359   return 0;
360 }
361
362 static int Sound_play_music_wrapper(HSQUIRRELVM v)
363 {
364   Scripting::Sound* _this;
365   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
366   const char* arg0;
367   sq_getstring(v, 2, &arg0);
368   
369   _this->play_music(arg0);
370   
371   return 0;
372 }
373
374 static int Sound_play_wrapper(HSQUIRRELVM v)
375 {
376   Scripting::Sound* _this;
377   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
378   const char* arg0;
379   sq_getstring(v, 2, &arg0);
380   
381   _this->play(arg0);
382   
383   return 0;
384 }
385
386 static int Text_release_hook(SQUserPointer ptr, int )
387 {
388   Scripting::Text* _this = reinterpret_cast<Scripting::Text*> (ptr);
389   delete _this;
390   return 0;
391 }
392
393 static int Text_set_text_wrapper(HSQUIRRELVM v)
394 {
395   Scripting::Text* _this;
396   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
397   const char* arg0;
398   sq_getstring(v, 2, &arg0);
399   
400   _this->set_text(arg0);
401   
402   return 0;
403 }
404
405 static int Text_set_font_wrapper(HSQUIRRELVM v)
406 {
407   Scripting::Text* _this;
408   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
409   const char* arg0;
410   sq_getstring(v, 2, &arg0);
411   
412   _this->set_font(arg0);
413   
414   return 0;
415 }
416
417 static int Text_fade_in_wrapper(HSQUIRRELVM v)
418 {
419   Scripting::Text* _this;
420   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
421   float arg0;
422   sq_getfloat(v, 2, &arg0);
423   
424   _this->fade_in(arg0);
425   
426   return 0;
427 }
428
429 static int Text_fade_out_wrapper(HSQUIRRELVM v)
430 {
431   Scripting::Text* _this;
432   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
433   float arg0;
434   sq_getfloat(v, 2, &arg0);
435   
436   _this->fade_out(arg0);
437   
438   return 0;
439 }
440
441 static int Text_set_visible_wrapper(HSQUIRRELVM v)
442 {
443   Scripting::Text* _this;
444   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
445   SQBool arg0;
446   sq_getbool(v, 2, &arg0);
447   
448   _this->set_visible(arg0);
449   
450   return 0;
451 }
452
453 static int Text_set_centered_wrapper(HSQUIRRELVM v)
454 {
455   Scripting::Text* _this;
456   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
457   SQBool arg0;
458   sq_getbool(v, 2, &arg0);
459   
460   _this->set_centered(arg0);
461   
462   return 0;
463 }
464
465 static int Player_release_hook(SQUserPointer ptr, int )
466 {
467   Scripting::Player* _this = reinterpret_cast<Scripting::Player*> (ptr);
468   delete _this;
469   return 0;
470 }
471
472 static int Player_make_invincible_wrapper(HSQUIRRELVM v)
473 {
474   Scripting::Player* _this;
475   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
476   
477   _this->make_invincible();
478   
479   return 0;
480 }
481
482 static int Player_deactivate_wrapper(HSQUIRRELVM v)
483 {
484   Scripting::Player* _this;
485   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
486   
487   _this->deactivate();
488   
489   return 0;
490 }
491
492 static int Player_activate_wrapper(HSQUIRRELVM v)
493 {
494   Scripting::Player* _this;
495   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
496   
497   _this->activate();
498   
499   return 0;
500 }
501
502 static int Player_walk_wrapper(HSQUIRRELVM v)
503 {
504   Scripting::Player* _this;
505   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
506   float arg0;
507   sq_getfloat(v, 2, &arg0);
508   
509   _this->walk(arg0);
510   
511   return 0;
512 }
513
514 static int Player_set_visible_wrapper(HSQUIRRELVM v)
515 {
516   Scripting::Player* _this;
517   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
518   SQBool arg0;
519   sq_getbool(v, 2, &arg0);
520   
521   _this->set_visible(arg0);
522   
523   return 0;
524 }
525
526 static int Player_get_visible_wrapper(HSQUIRRELVM v)
527 {
528   Scripting::Player* _this;
529   sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
530   
531   bool return_value = _this->get_visible();
532   
533   sq_pushbool(v, return_value);
534   return 1;
535 }
536
537 static int display_text_file_wrapper(HSQUIRRELVM v)
538 {
539   const char* arg0;
540   sq_getstring(v, 2, &arg0);
541   
542   Scripting::display_text_file(arg0);
543   
544   return 0;
545 }
546
547 static int wait_wrapper(HSQUIRRELVM v)
548 {
549   float arg0;
550   sq_getfloat(v, 2, &arg0);
551   
552   Scripting::wait(arg0);
553   
554   return sq_suspendvm(v);
555 }
556
557 static int translate_wrapper(HSQUIRRELVM v)
558 {
559   const char* arg0;
560   sq_getstring(v, 2, &arg0);
561   
562   std::string return_value = Scripting::translate(arg0);
563   
564   sq_pushstring(v, return_value.c_str(), return_value.size());
565   return 1;
566 }
567
568 static int import_wrapper(HSQUIRRELVM v)
569 {
570   HSQUIRRELVM arg0 = v;
571   const char* arg1;
572   sq_getstring(v, 2, &arg1);
573   
574   Scripting::import(arg0, arg1);
575   
576   return 0;
577 }
578
579 static int add_key_wrapper(HSQUIRRELVM v)
580 {
581   int arg0;
582   sq_getinteger(v, 2, &arg0);
583   
584   Scripting::add_key(arg0);
585   
586   return 0;
587 }
588
589 } // end of namespace Wrapper
590
591 void create_squirrel_instance(HSQUIRRELVM v, Scripting::DisplayEffect* object, bool setup_releasehook)
592 {
593   using namespace Wrapper;
594
595   sq_pushroottable(v);
596   sq_pushstring(v, "DisplayEffect", -1);
597   if(SQ_FAILED(sq_get(v, -2))) {
598     std::ostringstream msg;
599     msg << "Couldn't resolved squirrel type 'DisplayEffect'";
600     throw SquirrelError(v, msg.str());
601   }
602
603   if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) {
604     std::ostringstream msg;
605     msg << "Couldn't setup squirrel instance for object of type 'DisplayEffect'";
606     throw SquirrelError(v, msg.str());
607   }
608   sq_remove(v, -2); // remove object name
609
610   if(setup_releasehook) {
611     sq_setreleasehook(v, -1, DisplayEffect_release_hook);
612   }
613
614   sq_remove(v, -2); // remove root table
615 }
616
617 void create_squirrel_instance(HSQUIRRELVM v, Scripting::Camera* object, bool setup_releasehook)
618 {
619   using namespace Wrapper;
620
621   sq_pushroottable(v);
622   sq_pushstring(v, "Camera", -1);
623   if(SQ_FAILED(sq_get(v, -2))) {
624     std::ostringstream msg;
625     msg << "Couldn't resolved squirrel type 'Camera'";
626     throw SquirrelError(v, msg.str());
627   }
628
629   if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) {
630     std::ostringstream msg;
631     msg << "Couldn't setup squirrel instance for object of type 'Camera'";
632     throw SquirrelError(v, msg.str());
633   }
634   sq_remove(v, -2); // remove object name
635
636   if(setup_releasehook) {
637     sq_setreleasehook(v, -1, Camera_release_hook);
638   }
639
640   sq_remove(v, -2); // remove root table
641 }
642
643 void create_squirrel_instance(HSQUIRRELVM v, Scripting::Level* object, bool setup_releasehook)
644 {
645   using namespace Wrapper;
646
647   sq_pushroottable(v);
648   sq_pushstring(v, "Level", -1);
649   if(SQ_FAILED(sq_get(v, -2))) {
650     std::ostringstream msg;
651     msg << "Couldn't resolved squirrel type 'Level'";
652     throw SquirrelError(v, msg.str());
653   }
654
655   if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) {
656     std::ostringstream msg;
657     msg << "Couldn't setup squirrel instance for object of type 'Level'";
658     throw SquirrelError(v, msg.str());
659   }
660   sq_remove(v, -2); // remove object name
661
662   if(setup_releasehook) {
663     sq_setreleasehook(v, -1, Level_release_hook);
664   }
665
666   sq_remove(v, -2); // remove root table
667 }
668
669 void create_squirrel_instance(HSQUIRRELVM v, Scripting::ScriptedObject* object, bool setup_releasehook)
670 {
671   using namespace Wrapper;
672
673   sq_pushroottable(v);
674   sq_pushstring(v, "ScriptedObject", -1);
675   if(SQ_FAILED(sq_get(v, -2))) {
676     std::ostringstream msg;
677     msg << "Couldn't resolved squirrel type 'ScriptedObject'";
678     throw SquirrelError(v, msg.str());
679   }
680
681   if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) {
682     std::ostringstream msg;
683     msg << "Couldn't setup squirrel instance for object of type 'ScriptedObject'";
684     throw SquirrelError(v, msg.str());
685   }
686   sq_remove(v, -2); // remove object name
687
688   if(setup_releasehook) {
689     sq_setreleasehook(v, -1, ScriptedObject_release_hook);
690   }
691
692   sq_remove(v, -2); // remove root table
693 }
694
695 void create_squirrel_instance(HSQUIRRELVM v, Scripting::Sound* object, bool setup_releasehook)
696 {
697   using namespace Wrapper;
698
699   sq_pushroottable(v);
700   sq_pushstring(v, "Sound", -1);
701   if(SQ_FAILED(sq_get(v, -2))) {
702     std::ostringstream msg;
703     msg << "Couldn't resolved squirrel type 'Sound'";
704     throw SquirrelError(v, msg.str());
705   }
706
707   if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) {
708     std::ostringstream msg;
709     msg << "Couldn't setup squirrel instance for object of type 'Sound'";
710     throw SquirrelError(v, msg.str());
711   }
712   sq_remove(v, -2); // remove object name
713
714   if(setup_releasehook) {
715     sq_setreleasehook(v, -1, Sound_release_hook);
716   }
717
718   sq_remove(v, -2); // remove root table
719 }
720
721 void create_squirrel_instance(HSQUIRRELVM v, Scripting::Text* object, bool setup_releasehook)
722 {
723   using namespace Wrapper;
724
725   sq_pushroottable(v);
726   sq_pushstring(v, "Text", -1);
727   if(SQ_FAILED(sq_get(v, -2))) {
728     std::ostringstream msg;
729     msg << "Couldn't resolved squirrel type 'Text'";
730     throw SquirrelError(v, msg.str());
731   }
732
733   if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) {
734     std::ostringstream msg;
735     msg << "Couldn't setup squirrel instance for object of type 'Text'";
736     throw SquirrelError(v, msg.str());
737   }
738   sq_remove(v, -2); // remove object name
739
740   if(setup_releasehook) {
741     sq_setreleasehook(v, -1, Text_release_hook);
742   }
743
744   sq_remove(v, -2); // remove root table
745 }
746
747 void create_squirrel_instance(HSQUIRRELVM v, Scripting::Player* object, bool setup_releasehook)
748 {
749   using namespace Wrapper;
750
751   sq_pushroottable(v);
752   sq_pushstring(v, "Player", -1);
753   if(SQ_FAILED(sq_get(v, -2))) {
754     std::ostringstream msg;
755     msg << "Couldn't resolved squirrel type 'Player'";
756     throw SquirrelError(v, msg.str());
757   }
758
759   if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) {
760     std::ostringstream msg;
761     msg << "Couldn't setup squirrel instance for object of type 'Player'";
762     throw SquirrelError(v, msg.str());
763   }
764   sq_remove(v, -2); // remove object name
765
766   if(setup_releasehook) {
767     sq_setreleasehook(v, -1, Player_release_hook);
768   }
769
770   sq_remove(v, -2); // remove root table
771 }
772
773 void register_supertux_wrapper(HSQUIRRELVM v)
774 {
775   using namespace Wrapper;
776
777   sq_pushroottable(v);
778   sq_pushstring(v, "KEY_BRASS", -1);
779   sq_pushinteger(v, 1);
780   if(SQ_FAILED(sq_createslot(v, -3))) {
781     std::ostringstream msg;
782     msg << "Couldn't register constant'KEY_BRASS'";
783     throw SquirrelError(v, msg.str());
784   }
785
786   sq_pushstring(v, "KEY_IRON", -1);
787   sq_pushinteger(v, 2);
788   if(SQ_FAILED(sq_createslot(v, -3))) {
789     std::ostringstream msg;
790     msg << "Couldn't register constant'KEY_IRON'";
791     throw SquirrelError(v, msg.str());
792   }
793
794   sq_pushstring(v, "KEY_BRONZE", -1);
795   sq_pushinteger(v, 4);
796   if(SQ_FAILED(sq_createslot(v, -3))) {
797     std::ostringstream msg;
798     msg << "Couldn't register constant'KEY_BRONZE'";
799     throw SquirrelError(v, msg.str());
800   }
801
802   sq_pushstring(v, "KEY_SILVER", -1);
803   sq_pushinteger(v, 8);
804   if(SQ_FAILED(sq_createslot(v, -3))) {
805     std::ostringstream msg;
806     msg << "Couldn't register constant'KEY_SILVER'";
807     throw SquirrelError(v, msg.str());
808   }
809
810   sq_pushstring(v, "KEY_GOLD", -1);
811   sq_pushinteger(v, 16);
812   if(SQ_FAILED(sq_createslot(v, -3))) {
813     std::ostringstream msg;
814     msg << "Couldn't register constant'KEY_GOLD'";
815     throw SquirrelError(v, msg.str());
816   }
817
818   sq_pushstring(v, "display_text_file", -1);
819   sq_newclosure(v, &display_text_file_wrapper, 0);
820   if(SQ_FAILED(sq_createslot(v, -3))) {
821     std::ostringstream msg;
822     msg << "Couldn't register function'display_text_file'";
823     throw SquirrelError(v, msg.str());
824   }
825
826   sq_pushstring(v, "wait", -1);
827   sq_newclosure(v, &wait_wrapper, 0);
828   if(SQ_FAILED(sq_createslot(v, -3))) {
829     std::ostringstream msg;
830     msg << "Couldn't register function'wait'";
831     throw SquirrelError(v, msg.str());
832   }
833
834   sq_pushstring(v, "translate", -1);
835   sq_newclosure(v, &translate_wrapper, 0);
836   if(SQ_FAILED(sq_createslot(v, -3))) {
837     std::ostringstream msg;
838     msg << "Couldn't register function'translate'";
839     throw SquirrelError(v, msg.str());
840   }
841
842   sq_pushstring(v, "import", -1);
843   sq_newclosure(v, &import_wrapper, 0);
844   if(SQ_FAILED(sq_createslot(v, -3))) {
845     std::ostringstream msg;
846     msg << "Couldn't register function'import'";
847     throw SquirrelError(v, msg.str());
848   }
849
850   sq_pushstring(v, "add_key", -1);
851   sq_newclosure(v, &add_key_wrapper, 0);
852   if(SQ_FAILED(sq_createslot(v, -3))) {
853     std::ostringstream msg;
854     msg << "Couldn't register function'add_key'";
855     throw SquirrelError(v, msg.str());
856   }
857
858   // Register class DisplayEffect
859   sq_pushstring(v, "DisplayEffect", -1);
860   if(sq_newclass(v, SQFalse) < 0) {
861     std::ostringstream msg;
862     msg << "Couldn't create new class 'DisplayEffect'";
863     throw SquirrelError(v, msg.str());
864   }
865   sq_pushstring(v, "fade_out", -1);
866   sq_newclosure(v, &DisplayEffect_fade_out_wrapper, 0);
867   if(SQ_FAILED(sq_createslot(v, -3))) {
868     std::ostringstream msg;
869     msg << "Couldn't register function'fade_out'";
870     throw SquirrelError(v, msg.str());
871   }
872
873   sq_pushstring(v, "fade_in", -1);
874   sq_newclosure(v, &DisplayEffect_fade_in_wrapper, 0);
875   if(SQ_FAILED(sq_createslot(v, -3))) {
876     std::ostringstream msg;
877     msg << "Couldn't register function'fade_in'";
878     throw SquirrelError(v, msg.str());
879   }
880
881   sq_pushstring(v, "set_black", -1);
882   sq_newclosure(v, &DisplayEffect_set_black_wrapper, 0);
883   if(SQ_FAILED(sq_createslot(v, -3))) {
884     std::ostringstream msg;
885     msg << "Couldn't register function'set_black'";
886     throw SquirrelError(v, msg.str());
887   }
888
889   sq_pushstring(v, "is_black", -1);
890   sq_newclosure(v, &DisplayEffect_is_black_wrapper, 0);
891   if(SQ_FAILED(sq_createslot(v, -3))) {
892     std::ostringstream msg;
893     msg << "Couldn't register function'is_black'";
894     throw SquirrelError(v, msg.str());
895   }
896
897   sq_pushstring(v, "sixteen_to_nine", -1);
898   sq_newclosure(v, &DisplayEffect_sixteen_to_nine_wrapper, 0);
899   if(SQ_FAILED(sq_createslot(v, -3))) {
900     std::ostringstream msg;
901     msg << "Couldn't register function'sixteen_to_nine'";
902     throw SquirrelError(v, msg.str());
903   }
904
905   sq_pushstring(v, "four_to_three", -1);
906   sq_newclosure(v, &DisplayEffect_four_to_three_wrapper, 0);
907   if(SQ_FAILED(sq_createslot(v, -3))) {
908     std::ostringstream msg;
909     msg << "Couldn't register function'four_to_three'";
910     throw SquirrelError(v, msg.str());
911   }
912
913   if(SQ_FAILED(sq_createslot(v, -3))) {
914     std::ostringstream msg;
915     msg << "Couldn't register class'DisplayEffect'";
916     throw SquirrelError(v, msg.str());
917   }
918
919   // Register class Camera
920   sq_pushstring(v, "Camera", -1);
921   if(sq_newclass(v, SQFalse) < 0) {
922     std::ostringstream msg;
923     msg << "Couldn't create new class 'Camera'";
924     throw SquirrelError(v, msg.str());
925   }
926   sq_pushstring(v, "shake", -1);
927   sq_newclosure(v, &Camera_shake_wrapper, 0);
928   if(SQ_FAILED(sq_createslot(v, -3))) {
929     std::ostringstream msg;
930     msg << "Couldn't register function'shake'";
931     throw SquirrelError(v, msg.str());
932   }
933
934   sq_pushstring(v, "set_pos", -1);
935   sq_newclosure(v, &Camera_set_pos_wrapper, 0);
936   if(SQ_FAILED(sq_createslot(v, -3))) {
937     std::ostringstream msg;
938     msg << "Couldn't register function'set_pos'";
939     throw SquirrelError(v, msg.str());
940   }
941
942   sq_pushstring(v, "set_mode", -1);
943   sq_newclosure(v, &Camera_set_mode_wrapper, 0);
944   if(SQ_FAILED(sq_createslot(v, -3))) {
945     std::ostringstream msg;
946     msg << "Couldn't register function'set_mode'";
947     throw SquirrelError(v, msg.str());
948   }
949
950   sq_pushstring(v, "scroll_to", -1);
951   sq_newclosure(v, &Camera_scroll_to_wrapper, 0);
952   if(SQ_FAILED(sq_createslot(v, -3))) {
953     std::ostringstream msg;
954     msg << "Couldn't register function'scroll_to'";
955     throw SquirrelError(v, msg.str());
956   }
957
958   if(SQ_FAILED(sq_createslot(v, -3))) {
959     std::ostringstream msg;
960     msg << "Couldn't register class'Camera'";
961     throw SquirrelError(v, msg.str());
962   }
963
964   // Register class Level
965   sq_pushstring(v, "Level", -1);
966   if(sq_newclass(v, SQFalse) < 0) {
967     std::ostringstream msg;
968     msg << "Couldn't create new class 'Level'";
969     throw SquirrelError(v, msg.str());
970   }
971   sq_pushstring(v, "finish", -1);
972   sq_newclosure(v, &Level_finish_wrapper, 0);
973   if(SQ_FAILED(sq_createslot(v, -3))) {
974     std::ostringstream msg;
975     msg << "Couldn't register function'finish'";
976     throw SquirrelError(v, msg.str());
977   }
978
979   sq_pushstring(v, "spawn", -1);
980   sq_newclosure(v, &Level_spawn_wrapper, 0);
981   if(SQ_FAILED(sq_createslot(v, -3))) {
982     std::ostringstream msg;
983     msg << "Couldn't register function'spawn'";
984     throw SquirrelError(v, msg.str());
985   }
986
987   sq_pushstring(v, "flip_vertically", -1);
988   sq_newclosure(v, &Level_flip_vertically_wrapper, 0);
989   if(SQ_FAILED(sq_createslot(v, -3))) {
990     std::ostringstream msg;
991     msg << "Couldn't register function'flip_vertically'";
992     throw SquirrelError(v, msg.str());
993   }
994
995   if(SQ_FAILED(sq_createslot(v, -3))) {
996     std::ostringstream msg;
997     msg << "Couldn't register class'Level'";
998     throw SquirrelError(v, msg.str());
999   }
1000
1001   // Register class ScriptedObject
1002   sq_pushstring(v, "ScriptedObject", -1);
1003   if(sq_newclass(v, SQFalse) < 0) {
1004     std::ostringstream msg;
1005     msg << "Couldn't create new class 'ScriptedObject'";
1006     throw SquirrelError(v, msg.str());
1007   }
1008   sq_pushstring(v, "set_action", -1);
1009   sq_newclosure(v, &ScriptedObject_set_action_wrapper, 0);
1010   if(SQ_FAILED(sq_createslot(v, -3))) {
1011     std::ostringstream msg;
1012     msg << "Couldn't register function'set_action'";
1013     throw SquirrelError(v, msg.str());
1014   }
1015
1016   sq_pushstring(v, "get_action", -1);
1017   sq_newclosure(v, &ScriptedObject_get_action_wrapper, 0);
1018   if(SQ_FAILED(sq_createslot(v, -3))) {
1019     std::ostringstream msg;
1020     msg << "Couldn't register function'get_action'";
1021     throw SquirrelError(v, msg.str());
1022   }
1023
1024   sq_pushstring(v, "move", -1);
1025   sq_newclosure(v, &ScriptedObject_move_wrapper, 0);
1026   if(SQ_FAILED(sq_createslot(v, -3))) {
1027     std::ostringstream msg;
1028     msg << "Couldn't register function'move'";
1029     throw SquirrelError(v, msg.str());
1030   }
1031
1032   sq_pushstring(v, "set_pos", -1);
1033   sq_newclosure(v, &ScriptedObject_set_pos_wrapper, 0);
1034   if(SQ_FAILED(sq_createslot(v, -3))) {
1035     std::ostringstream msg;
1036     msg << "Couldn't register function'set_pos'";
1037     throw SquirrelError(v, msg.str());
1038   }
1039
1040   sq_pushstring(v, "get_pos_x", -1);
1041   sq_newclosure(v, &ScriptedObject_get_pos_x_wrapper, 0);
1042   if(SQ_FAILED(sq_createslot(v, -3))) {
1043     std::ostringstream msg;
1044     msg << "Couldn't register function'get_pos_x'";
1045     throw SquirrelError(v, msg.str());
1046   }
1047
1048   sq_pushstring(v, "get_pos_y", -1);
1049   sq_newclosure(v, &ScriptedObject_get_pos_y_wrapper, 0);
1050   if(SQ_FAILED(sq_createslot(v, -3))) {
1051     std::ostringstream msg;
1052     msg << "Couldn't register function'get_pos_y'";
1053     throw SquirrelError(v, msg.str());
1054   }
1055
1056   sq_pushstring(v, "set_velocity", -1);
1057   sq_newclosure(v, &ScriptedObject_set_velocity_wrapper, 0);
1058   if(SQ_FAILED(sq_createslot(v, -3))) {
1059     std::ostringstream msg;
1060     msg << "Couldn't register function'set_velocity'";
1061     throw SquirrelError(v, msg.str());
1062   }
1063
1064   sq_pushstring(v, "get_velocity_x", -1);
1065   sq_newclosure(v, &ScriptedObject_get_velocity_x_wrapper, 0);
1066   if(SQ_FAILED(sq_createslot(v, -3))) {
1067     std::ostringstream msg;
1068     msg << "Couldn't register function'get_velocity_x'";
1069     throw SquirrelError(v, msg.str());
1070   }
1071
1072   sq_pushstring(v, "get_velocity_y", -1);
1073   sq_newclosure(v, &ScriptedObject_get_velocity_y_wrapper, 0);
1074   if(SQ_FAILED(sq_createslot(v, -3))) {
1075     std::ostringstream msg;
1076     msg << "Couldn't register function'get_velocity_y'";
1077     throw SquirrelError(v, msg.str());
1078   }
1079
1080   sq_pushstring(v, "set_visible", -1);
1081   sq_newclosure(v, &ScriptedObject_set_visible_wrapper, 0);
1082   if(SQ_FAILED(sq_createslot(v, -3))) {
1083     std::ostringstream msg;
1084     msg << "Couldn't register function'set_visible'";
1085     throw SquirrelError(v, msg.str());
1086   }
1087
1088   sq_pushstring(v, "is_visible", -1);
1089   sq_newclosure(v, &ScriptedObject_is_visible_wrapper, 0);
1090   if(SQ_FAILED(sq_createslot(v, -3))) {
1091     std::ostringstream msg;
1092     msg << "Couldn't register function'is_visible'";
1093     throw SquirrelError(v, msg.str());
1094   }
1095
1096   sq_pushstring(v, "get_name", -1);
1097   sq_newclosure(v, &ScriptedObject_get_name_wrapper, 0);
1098   if(SQ_FAILED(sq_createslot(v, -3))) {
1099     std::ostringstream msg;
1100     msg << "Couldn't register function'get_name'";
1101     throw SquirrelError(v, msg.str());
1102   }
1103
1104   if(SQ_FAILED(sq_createslot(v, -3))) {
1105     std::ostringstream msg;
1106     msg << "Couldn't register class'ScriptedObject'";
1107     throw SquirrelError(v, msg.str());
1108   }
1109
1110   // Register class Sound
1111   sq_pushstring(v, "Sound", -1);
1112   if(sq_newclass(v, SQFalse) < 0) {
1113     std::ostringstream msg;
1114     msg << "Couldn't create new class 'Sound'";
1115     throw SquirrelError(v, msg.str());
1116   }
1117   sq_pushstring(v, "play_music", -1);
1118   sq_newclosure(v, &Sound_play_music_wrapper, 0);
1119   if(SQ_FAILED(sq_createslot(v, -3))) {
1120     std::ostringstream msg;
1121     msg << "Couldn't register function'play_music'";
1122     throw SquirrelError(v, msg.str());
1123   }
1124
1125   sq_pushstring(v, "play", -1);
1126   sq_newclosure(v, &Sound_play_wrapper, 0);
1127   if(SQ_FAILED(sq_createslot(v, -3))) {
1128     std::ostringstream msg;
1129     msg << "Couldn't register function'play'";
1130     throw SquirrelError(v, msg.str());
1131   }
1132
1133   if(SQ_FAILED(sq_createslot(v, -3))) {
1134     std::ostringstream msg;
1135     msg << "Couldn't register class'Sound'";
1136     throw SquirrelError(v, msg.str());
1137   }
1138
1139   // Register class Text
1140   sq_pushstring(v, "Text", -1);
1141   if(sq_newclass(v, SQFalse) < 0) {
1142     std::ostringstream msg;
1143     msg << "Couldn't create new class 'Text'";
1144     throw SquirrelError(v, msg.str());
1145   }
1146   sq_pushstring(v, "set_text", -1);
1147   sq_newclosure(v, &Text_set_text_wrapper, 0);
1148   if(SQ_FAILED(sq_createslot(v, -3))) {
1149     std::ostringstream msg;
1150     msg << "Couldn't register function'set_text'";
1151     throw SquirrelError(v, msg.str());
1152   }
1153
1154   sq_pushstring(v, "set_font", -1);
1155   sq_newclosure(v, &Text_set_font_wrapper, 0);
1156   if(SQ_FAILED(sq_createslot(v, -3))) {
1157     std::ostringstream msg;
1158     msg << "Couldn't register function'set_font'";
1159     throw SquirrelError(v, msg.str());
1160   }
1161
1162   sq_pushstring(v, "fade_in", -1);
1163   sq_newclosure(v, &Text_fade_in_wrapper, 0);
1164   if(SQ_FAILED(sq_createslot(v, -3))) {
1165     std::ostringstream msg;
1166     msg << "Couldn't register function'fade_in'";
1167     throw SquirrelError(v, msg.str());
1168   }
1169
1170   sq_pushstring(v, "fade_out", -1);
1171   sq_newclosure(v, &Text_fade_out_wrapper, 0);
1172   if(SQ_FAILED(sq_createslot(v, -3))) {
1173     std::ostringstream msg;
1174     msg << "Couldn't register function'fade_out'";
1175     throw SquirrelError(v, msg.str());
1176   }
1177
1178   sq_pushstring(v, "set_visible", -1);
1179   sq_newclosure(v, &Text_set_visible_wrapper, 0);
1180   if(SQ_FAILED(sq_createslot(v, -3))) {
1181     std::ostringstream msg;
1182     msg << "Couldn't register function'set_visible'";
1183     throw SquirrelError(v, msg.str());
1184   }
1185
1186   sq_pushstring(v, "set_centered", -1);
1187   sq_newclosure(v, &Text_set_centered_wrapper, 0);
1188   if(SQ_FAILED(sq_createslot(v, -3))) {
1189     std::ostringstream msg;
1190     msg << "Couldn't register function'set_centered'";
1191     throw SquirrelError(v, msg.str());
1192   }
1193
1194   if(SQ_FAILED(sq_createslot(v, -3))) {
1195     std::ostringstream msg;
1196     msg << "Couldn't register class'Text'";
1197     throw SquirrelError(v, msg.str());
1198   }
1199
1200   // Register class Player
1201   sq_pushstring(v, "Player", -1);
1202   if(sq_newclass(v, SQFalse) < 0) {
1203     std::ostringstream msg;
1204     msg << "Couldn't create new class 'Player'";
1205     throw SquirrelError(v, msg.str());
1206   }
1207   sq_pushstring(v, "make_invincible", -1);
1208   sq_newclosure(v, &Player_make_invincible_wrapper, 0);
1209   if(SQ_FAILED(sq_createslot(v, -3))) {
1210     std::ostringstream msg;
1211     msg << "Couldn't register function'make_invincible'";
1212     throw SquirrelError(v, msg.str());
1213   }
1214
1215   sq_pushstring(v, "deactivate", -1);
1216   sq_newclosure(v, &Player_deactivate_wrapper, 0);
1217   if(SQ_FAILED(sq_createslot(v, -3))) {
1218     std::ostringstream msg;
1219     msg << "Couldn't register function'deactivate'";
1220     throw SquirrelError(v, msg.str());
1221   }
1222
1223   sq_pushstring(v, "activate", -1);
1224   sq_newclosure(v, &Player_activate_wrapper, 0);
1225   if(SQ_FAILED(sq_createslot(v, -3))) {
1226     std::ostringstream msg;
1227     msg << "Couldn't register function'activate'";
1228     throw SquirrelError(v, msg.str());
1229   }
1230
1231   sq_pushstring(v, "walk", -1);
1232   sq_newclosure(v, &Player_walk_wrapper, 0);
1233   if(SQ_FAILED(sq_createslot(v, -3))) {
1234     std::ostringstream msg;
1235     msg << "Couldn't register function'walk'";
1236     throw SquirrelError(v, msg.str());
1237   }
1238
1239   sq_pushstring(v, "set_visible", -1);
1240   sq_newclosure(v, &Player_set_visible_wrapper, 0);
1241   if(SQ_FAILED(sq_createslot(v, -3))) {
1242     std::ostringstream msg;
1243     msg << "Couldn't register function'set_visible'";
1244     throw SquirrelError(v, msg.str());
1245   }
1246
1247   sq_pushstring(v, "get_visible", -1);
1248   sq_newclosure(v, &Player_get_visible_wrapper, 0);
1249   if(SQ_FAILED(sq_createslot(v, -3))) {
1250     std::ostringstream msg;
1251     msg << "Couldn't register function'get_visible'";
1252     throw SquirrelError(v, msg.str());
1253   }
1254
1255   if(SQ_FAILED(sq_createslot(v, -3))) {
1256     std::ostringstream msg;
1257     msg << "Couldn't register class'Player'";
1258     throw SquirrelError(v, msg.str());
1259   }
1260
1261   sq_pop(v, 1);
1262 }
1263
1264 } // end of namespace Scripting
1265