X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscripting%2Fwrapper.cpp;h=56d56b2c9bc1fed66d48864847e436527a5d50f7;hb=071c31e7fcf8bfbd00ec8d7d19313d7f6e433885;hp=aae11d85abc8359485a319e890e9c9fdef160746;hpb=fd8c5a479875510f3171ad1e07a4ba4a375de2b8;p=supertux.git diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index aae11d85a..56d56b2c9 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -1,29 +1,104 @@ /** - * WARNING: This file is automatically generated from './build/i686-pc-linux-gnu/optimize/miniswig.tmp' - do not change + * WARNING: This file is automatically generated from: + * 'src/scripting/wrapper.interface.hpp' + * DO NOT CHANGE */ - #include + #include #include #include +#include #include -#include "wrapper_util.h" -#include "wrapper.interface.h" +#include "squirrel_error.hpp" +#include "wrapper.interface.hpp" + +namespace Scripting +{ +namespace Wrapper +{ -using namespace Scripting; +static int DisplayEffect_release_hook(SQUserPointer ptr, int ) +{ + Scripting::DisplayEffect* _this = reinterpret_cast (ptr); + delete _this; + return 0; +} -static int Display_set_effect_wrapper(HSQUIRRELVM v) +static int DisplayEffect_fade_out_wrapper(HSQUIRRELVM v) { - Scripting::Display* _this; + Scripting::DisplayEffect* _this; sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); - const char* arg0; - sq_getstring(v, 2, &arg0); + float arg0; + sq_getfloat(v, 2, &arg0); - _this->set_effect(arg0); + _this->fade_out(arg0); return 0; } +static int DisplayEffect_fade_in_wrapper(HSQUIRRELVM v) +{ + Scripting::DisplayEffect* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + float arg0; + sq_getfloat(v, 2, &arg0); + + _this->fade_in(arg0); + + return 0; +} + +static int DisplayEffect_set_black_wrapper(HSQUIRRELVM v) +{ + Scripting::DisplayEffect* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + SQBool arg0; + sq_getbool(v, 2, &arg0); + + _this->set_black(arg0); + + return 0; +} + +static int DisplayEffect_is_black_wrapper(HSQUIRRELVM v) +{ + Scripting::DisplayEffect* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + + bool return_value = _this->is_black(); + + sq_pushbool(v, return_value); + return 1; +} + +static int DisplayEffect_sixteen_to_nine_wrapper(HSQUIRRELVM v) +{ + Scripting::DisplayEffect* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + + _this->sixteen_to_nine(); + + return 0; +} + +static int DisplayEffect_four_to_three_wrapper(HSQUIRRELVM v) +{ + Scripting::DisplayEffect* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + + _this->four_to_three(); + + return 0; +} + +static int Camera_release_hook(SQUserPointer ptr, int ) +{ + Scripting::Camera* _this = reinterpret_cast (ptr); + delete _this; + return 0; +} + static int Camera_shake_wrapper(HSQUIRRELVM v) { Scripting::Camera* _this; @@ -66,6 +141,13 @@ static int Camera_set_mode_wrapper(HSQUIRRELVM v) return 0; } +static int Level_release_hook(SQUserPointer ptr, int ) +{ + Scripting::Level* _this = reinterpret_cast (ptr); + delete _this; + return 0; +} + static int Level_finish_wrapper(HSQUIRRELVM v) { Scripting::Level* _this; @@ -90,6 +172,23 @@ static int Level_spawn_wrapper(HSQUIRRELVM v) return 0; } +static int Level_flip_vertically_wrapper(HSQUIRRELVM v) +{ + Scripting::Level* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + + _this->flip_vertically(); + + return 0; +} + +static int ScriptedObject_release_hook(SQUserPointer ptr, int ) +{ + Scripting::ScriptedObject* _this = reinterpret_cast (ptr); + delete _this; + return 0; +} + static int ScriptedObject_set_animation_wrapper(HSQUIRRELVM v) { Scripting::ScriptedObject* _this; @@ -233,6 +332,13 @@ static int ScriptedObject_get_name_wrapper(HSQUIRRELVM v) return 1; } +static int Sound_release_hook(SQUserPointer ptr, int ) +{ + Scripting::Sound* _this = reinterpret_cast (ptr); + delete _this; + return 0; +} + static int Sound_play_music_wrapper(HSQUIRRELVM v) { Scripting::Sound* _this; @@ -245,18 +351,25 @@ static int Sound_play_music_wrapper(HSQUIRRELVM v) return 0; } -static int Sound_play_sound_wrapper(HSQUIRRELVM v) +static int Sound_play_wrapper(HSQUIRRELVM v) { Scripting::Sound* _this; sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); const char* arg0; sq_getstring(v, 2, &arg0); - _this->play_sound(arg0); + _this->play(arg0); return 0; } +static int Text_release_hook(SQUserPointer ptr, int ) +{ + Scripting::Text* _this = reinterpret_cast (ptr); + delete _this; + return 0; +} + static int Text_set_text_wrapper(HSQUIRRELVM v) { Scripting::Text* _this; @@ -317,16 +430,75 @@ static int Text_set_visible_wrapper(HSQUIRRELVM v) return 0; } -static int set_wakeup_time_wrapper(HSQUIRRELVM v) +static int Player_release_hook(SQUserPointer ptr, int ) +{ + Scripting::Player* _this = reinterpret_cast (ptr); + delete _this; + return 0; +} + +static int Player_make_invincible_wrapper(HSQUIRRELVM v) +{ + Scripting::Player* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + + _this->make_invincible(); + + return 0; +} + +static int Player_deactivate_wrapper(HSQUIRRELVM v) +{ + Scripting::Player* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + + _this->deactivate(); + + return 0; +} + +static int Player_activate_wrapper(HSQUIRRELVM v) +{ + Scripting::Player* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + + _this->activate(); + + return 0; +} + +static int Player_walk_wrapper(HSQUIRRELVM v) { + Scripting::Player* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); float arg0; sq_getfloat(v, 2, &arg0); - Scripting::set_wakeup_time(arg0); + _this->walk(arg0); return 0; } +static int display_text_file_wrapper(HSQUIRRELVM v) +{ + const char* arg0; + sq_getstring(v, 2, &arg0); + + Scripting::display_text_file(arg0); + + return 0; +} + +static int wait_wrapper(HSQUIRRELVM v) +{ + float arg0; + sq_getfloat(v, 2, &arg0); + + Scripting::wait(arg0); + + return sq_suspendvm(v); +} + static int translate_wrapper(HSQUIRRELVM v) { const char* arg0; @@ -338,62 +510,669 @@ static int translate_wrapper(HSQUIRRELVM v) return 1; } -WrappedFunction supertux_global_functions[] = { - { "set_wakeup_time", &set_wakeup_time_wrapper }, - { "translate", &translate_wrapper }, - { 0, 0 } -}; - -static WrappedFunction supertux_Display_methods[] = { - { "set_effect", &Display_set_effect_wrapper }, -}; - -static WrappedFunction supertux_Camera_methods[] = { - { "shake", &Camera_shake_wrapper }, - { "set_pos", &Camera_set_pos_wrapper }, - { "set_mode", &Camera_set_mode_wrapper }, -}; - -static WrappedFunction supertux_Level_methods[] = { - { "finish", &Level_finish_wrapper }, - { "spawn", &Level_spawn_wrapper }, -}; - -static WrappedFunction supertux_ScriptedObject_methods[] = { - { "set_animation", &ScriptedObject_set_animation_wrapper }, - { "get_animation", &ScriptedObject_get_animation_wrapper }, - { "move", &ScriptedObject_move_wrapper }, - { "set_pos", &ScriptedObject_set_pos_wrapper }, - { "get_pos_x", &ScriptedObject_get_pos_x_wrapper }, - { "get_pos_y", &ScriptedObject_get_pos_y_wrapper }, - { "set_velocity", &ScriptedObject_set_velocity_wrapper }, - { "get_velocity_x", &ScriptedObject_get_velocity_x_wrapper }, - { "get_velocity_y", &ScriptedObject_get_velocity_y_wrapper }, - { "set_visible", &ScriptedObject_set_visible_wrapper }, - { "is_visible", &ScriptedObject_is_visible_wrapper }, - { "get_name", &ScriptedObject_get_name_wrapper }, -}; - -static WrappedFunction supertux_Sound_methods[] = { - { "play_music", &Sound_play_music_wrapper }, - { "play_sound", &Sound_play_sound_wrapper }, -}; - -static WrappedFunction supertux_Text_methods[] = { - { "set_text", &Text_set_text_wrapper }, - { "set_font", &Text_set_font_wrapper }, - { "fade_in", &Text_fade_in_wrapper }, - { "fade_out", &Text_fade_out_wrapper }, - { "set_visible", &Text_set_visible_wrapper }, -}; - -WrappedClass supertux_classes[] = { - { "Display", supertux_Display_methods }, - { "Camera", supertux_Camera_methods }, - { "Level", supertux_Level_methods }, - { "ScriptedObject", supertux_ScriptedObject_methods }, - { "Sound", supertux_Sound_methods }, - { "Text", supertux_Text_methods }, - { 0, 0 } -}; +static int import_wrapper(HSQUIRRELVM v) +{ + HSQUIRRELVM arg0 = v; + const char* arg1; + sq_getstring(v, 2, &arg1); + + Scripting::import(arg0, arg1); + + return 0; +} + +static int add_key_wrapper(HSQUIRRELVM v) +{ + int arg0; + sq_getinteger(v, 2, &arg0); + + Scripting::add_key(arg0); + + return 0; +} + +} // end of namespace Wrapper + +void create_squirrel_instance(HSQUIRRELVM v, Scripting::DisplayEffect* object, bool setup_releasehook) +{ + using namespace Wrapper; + + sq_pushroottable(v); + sq_pushstring(v, "DisplayEffect", -1); + if(SQ_FAILED(sq_get(v, -2))) { + std::ostringstream msg; + msg << "Couldn't resolved squirrel type 'DisplayEffect'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) { + std::ostringstream msg; + msg << "Couldn't setup squirrel instance for object of type 'DisplayEffect'"; + throw SquirrelError(v, msg.str()); + } + sq_remove(v, -2); // remove object name + + if(setup_releasehook) { + sq_setreleasehook(v, -1, DisplayEffect_release_hook); + } + + sq_remove(v, -2); // remove root table +} + +void create_squirrel_instance(HSQUIRRELVM v, Scripting::Camera* object, bool setup_releasehook) +{ + using namespace Wrapper; + + sq_pushroottable(v); + sq_pushstring(v, "Camera", -1); + if(SQ_FAILED(sq_get(v, -2))) { + std::ostringstream msg; + msg << "Couldn't resolved squirrel type 'Camera'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) { + std::ostringstream msg; + msg << "Couldn't setup squirrel instance for object of type 'Camera'"; + throw SquirrelError(v, msg.str()); + } + sq_remove(v, -2); // remove object name + + if(setup_releasehook) { + sq_setreleasehook(v, -1, Camera_release_hook); + } + + sq_remove(v, -2); // remove root table +} + +void create_squirrel_instance(HSQUIRRELVM v, Scripting::Level* object, bool setup_releasehook) +{ + using namespace Wrapper; + + sq_pushroottable(v); + sq_pushstring(v, "Level", -1); + if(SQ_FAILED(sq_get(v, -2))) { + std::ostringstream msg; + msg << "Couldn't resolved squirrel type 'Level'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) { + std::ostringstream msg; + msg << "Couldn't setup squirrel instance for object of type 'Level'"; + throw SquirrelError(v, msg.str()); + } + sq_remove(v, -2); // remove object name + + if(setup_releasehook) { + sq_setreleasehook(v, -1, Level_release_hook); + } + + sq_remove(v, -2); // remove root table +} + +void create_squirrel_instance(HSQUIRRELVM v, Scripting::ScriptedObject* object, bool setup_releasehook) +{ + using namespace Wrapper; + + sq_pushroottable(v); + sq_pushstring(v, "ScriptedObject", -1); + if(SQ_FAILED(sq_get(v, -2))) { + std::ostringstream msg; + msg << "Couldn't resolved squirrel type 'ScriptedObject'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) { + std::ostringstream msg; + msg << "Couldn't setup squirrel instance for object of type 'ScriptedObject'"; + throw SquirrelError(v, msg.str()); + } + sq_remove(v, -2); // remove object name + + if(setup_releasehook) { + sq_setreleasehook(v, -1, ScriptedObject_release_hook); + } + + sq_remove(v, -2); // remove root table +} + +void create_squirrel_instance(HSQUIRRELVM v, Scripting::Sound* object, bool setup_releasehook) +{ + using namespace Wrapper; + + sq_pushroottable(v); + sq_pushstring(v, "Sound", -1); + if(SQ_FAILED(sq_get(v, -2))) { + std::ostringstream msg; + msg << "Couldn't resolved squirrel type 'Sound'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) { + std::ostringstream msg; + msg << "Couldn't setup squirrel instance for object of type 'Sound'"; + throw SquirrelError(v, msg.str()); + } + sq_remove(v, -2); // remove object name + + if(setup_releasehook) { + sq_setreleasehook(v, -1, Sound_release_hook); + } + + sq_remove(v, -2); // remove root table +} + +void create_squirrel_instance(HSQUIRRELVM v, Scripting::Text* object, bool setup_releasehook) +{ + using namespace Wrapper; + + sq_pushroottable(v); + sq_pushstring(v, "Text", -1); + if(SQ_FAILED(sq_get(v, -2))) { + std::ostringstream msg; + msg << "Couldn't resolved squirrel type 'Text'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) { + std::ostringstream msg; + msg << "Couldn't setup squirrel instance for object of type 'Text'"; + throw SquirrelError(v, msg.str()); + } + sq_remove(v, -2); // remove object name + + if(setup_releasehook) { + sq_setreleasehook(v, -1, Text_release_hook); + } + + sq_remove(v, -2); // remove root table +} + +void create_squirrel_instance(HSQUIRRELVM v, Scripting::Player* object, bool setup_releasehook) +{ + using namespace Wrapper; + + sq_pushroottable(v); + sq_pushstring(v, "Player", -1); + if(SQ_FAILED(sq_get(v, -2))) { + std::ostringstream msg; + msg << "Couldn't resolved squirrel type 'Player'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) { + std::ostringstream msg; + msg << "Couldn't setup squirrel instance for object of type 'Player'"; + throw SquirrelError(v, msg.str()); + } + sq_remove(v, -2); // remove object name + + if(setup_releasehook) { + sq_setreleasehook(v, -1, Player_release_hook); + } + + sq_remove(v, -2); // remove root table +} + +void register_supertux_wrapper(HSQUIRRELVM v) +{ + using namespace Wrapper; + + sq_pushroottable(v); + sq_pushstring(v, "KEY_BRASS", -1); + sq_pushinteger(v, 1); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register constant'KEY_BRASS'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "KEY_IRON", -1); + sq_pushinteger(v, 2); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register constant'KEY_IRON'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "KEY_BRONZE", -1); + sq_pushinteger(v, 4); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register constant'KEY_BRONZE'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "KEY_SILVER", -1); + sq_pushinteger(v, 8); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register constant'KEY_SILVER'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "KEY_GOLD", -1); + sq_pushinteger(v, 16); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register constant'KEY_GOLD'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "display_text_file", -1); + sq_newclosure(v, &display_text_file_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'display_text_file'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "wait", -1); + sq_newclosure(v, &wait_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'wait'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "translate", -1); + sq_newclosure(v, &translate_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'translate'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "import", -1); + sq_newclosure(v, &import_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'import'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "add_key", -1); + sq_newclosure(v, &add_key_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'add_key'"; + throw SquirrelError(v, msg.str()); + } + + // Register class DisplayEffect + sq_pushstring(v, "DisplayEffect", -1); + if(sq_newclass(v, SQFalse) < 0) { + std::ostringstream msg; + msg << "Couldn't create new class 'DisplayEffect'"; + throw SquirrelError(v, msg.str()); + } + sq_pushstring(v, "fade_out", -1); + sq_newclosure(v, &DisplayEffect_fade_out_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'fade_out'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "fade_in", -1); + sq_newclosure(v, &DisplayEffect_fade_in_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'fade_in'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "set_black", -1); + sq_newclosure(v, &DisplayEffect_set_black_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_black'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "is_black", -1); + sq_newclosure(v, &DisplayEffect_is_black_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'is_black'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "sixteen_to_nine", -1); + sq_newclosure(v, &DisplayEffect_sixteen_to_nine_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'sixteen_to_nine'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "four_to_three", -1); + sq_newclosure(v, &DisplayEffect_four_to_three_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'four_to_three'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register class'DisplayEffect'"; + throw SquirrelError(v, msg.str()); + } + + // Register class Camera + sq_pushstring(v, "Camera", -1); + if(sq_newclass(v, SQFalse) < 0) { + std::ostringstream msg; + msg << "Couldn't create new class 'Camera'"; + throw SquirrelError(v, msg.str()); + } + sq_pushstring(v, "shake", -1); + sq_newclosure(v, &Camera_shake_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'shake'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "set_pos", -1); + sq_newclosure(v, &Camera_set_pos_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_pos'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "set_mode", -1); + sq_newclosure(v, &Camera_set_mode_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_mode'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register class'Camera'"; + throw SquirrelError(v, msg.str()); + } + + // Register class Level + sq_pushstring(v, "Level", -1); + if(sq_newclass(v, SQFalse) < 0) { + std::ostringstream msg; + msg << "Couldn't create new class 'Level'"; + throw SquirrelError(v, msg.str()); + } + sq_pushstring(v, "finish", -1); + sq_newclosure(v, &Level_finish_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'finish'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "spawn", -1); + sq_newclosure(v, &Level_spawn_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'spawn'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "flip_vertically", -1); + sq_newclosure(v, &Level_flip_vertically_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'flip_vertically'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register class'Level'"; + throw SquirrelError(v, msg.str()); + } + + // Register class ScriptedObject + sq_pushstring(v, "ScriptedObject", -1); + if(sq_newclass(v, SQFalse) < 0) { + std::ostringstream msg; + msg << "Couldn't create new class 'ScriptedObject'"; + throw SquirrelError(v, msg.str()); + } + sq_pushstring(v, "set_animation", -1); + sq_newclosure(v, &ScriptedObject_set_animation_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_animation'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "get_animation", -1); + sq_newclosure(v, &ScriptedObject_get_animation_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'get_animation'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "move", -1); + sq_newclosure(v, &ScriptedObject_move_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'move'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "set_pos", -1); + sq_newclosure(v, &ScriptedObject_set_pos_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_pos'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "get_pos_x", -1); + sq_newclosure(v, &ScriptedObject_get_pos_x_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'get_pos_x'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "get_pos_y", -1); + sq_newclosure(v, &ScriptedObject_get_pos_y_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'get_pos_y'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "set_velocity", -1); + sq_newclosure(v, &ScriptedObject_set_velocity_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_velocity'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "get_velocity_x", -1); + sq_newclosure(v, &ScriptedObject_get_velocity_x_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'get_velocity_x'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "get_velocity_y", -1); + sq_newclosure(v, &ScriptedObject_get_velocity_y_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'get_velocity_y'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "set_visible", -1); + sq_newclosure(v, &ScriptedObject_set_visible_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_visible'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "is_visible", -1); + sq_newclosure(v, &ScriptedObject_is_visible_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'is_visible'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "get_name", -1); + sq_newclosure(v, &ScriptedObject_get_name_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'get_name'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register class'ScriptedObject'"; + throw SquirrelError(v, msg.str()); + } + + // Register class Sound + sq_pushstring(v, "Sound", -1); + if(sq_newclass(v, SQFalse) < 0) { + std::ostringstream msg; + msg << "Couldn't create new class 'Sound'"; + throw SquirrelError(v, msg.str()); + } + sq_pushstring(v, "play_music", -1); + sq_newclosure(v, &Sound_play_music_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'play_music'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "play", -1); + sq_newclosure(v, &Sound_play_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'play'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register class'Sound'"; + throw SquirrelError(v, msg.str()); + } + + // Register class Text + sq_pushstring(v, "Text", -1); + if(sq_newclass(v, SQFalse) < 0) { + std::ostringstream msg; + msg << "Couldn't create new class 'Text'"; + throw SquirrelError(v, msg.str()); + } + sq_pushstring(v, "set_text", -1); + sq_newclosure(v, &Text_set_text_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_text'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "set_font", -1); + sq_newclosure(v, &Text_set_font_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_font'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "fade_in", -1); + sq_newclosure(v, &Text_fade_in_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'fade_in'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "fade_out", -1); + sq_newclosure(v, &Text_fade_out_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'fade_out'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "set_visible", -1); + sq_newclosure(v, &Text_set_visible_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'set_visible'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register class'Text'"; + throw SquirrelError(v, msg.str()); + } + + // Register class Player + sq_pushstring(v, "Player", -1); + if(sq_newclass(v, SQFalse) < 0) { + std::ostringstream msg; + msg << "Couldn't create new class 'Player'"; + throw SquirrelError(v, msg.str()); + } + sq_pushstring(v, "make_invincible", -1); + sq_newclosure(v, &Player_make_invincible_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'make_invincible'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "deactivate", -1); + sq_newclosure(v, &Player_deactivate_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'deactivate'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "activate", -1); + sq_newclosure(v, &Player_activate_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'activate'"; + throw SquirrelError(v, msg.str()); + } + + sq_pushstring(v, "walk", -1); + sq_newclosure(v, &Player_walk_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register function'walk'"; + throw SquirrelError(v, msg.str()); + } + + if(SQ_FAILED(sq_createslot(v, -3))) { + std::ostringstream msg; + msg << "Couldn't register class'Player'"; + throw SquirrelError(v, msg.str()); + } + + sq_pop(v, 1); +} + +} // end of namespace Scripting