From: Matthias Braun Date: Sun, 30 Apr 2006 16:27:33 +0000 (+0000) Subject: blind commit, please test: use squirrel datatypes X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=fe138b9ec292ca9679b43cf5c4555f0193bab25d;p=supertux.git blind commit, please test: use squirrel datatypes SVN-Revision: 3466 --- diff --git a/src/console.cpp b/src/console.cpp index 4cfa87412..ee6f843ab 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -115,7 +115,7 @@ Console::execute_script(const std::string& command) } } - int oldtop = sq_gettop(vm); + SQInteger oldtop = sq_gettop(vm); try { if(SQ_FAILED(sq_compilebuffer(vm, command.c_str(), command.length(), "", SQTrue))) @@ -130,7 +130,7 @@ Console::execute_script(const std::string& command) } catch(std::exception& e) { addLine(e.what()); } - int newtop = sq_gettop(vm); + SQInteger newtop = sq_gettop(vm); if(newtop < oldtop) { log_fatal << "Script destroyed squirrel stack..." << std::endl; } else { diff --git a/src/object/camera.cpp b/src/object/camera.cpp index 9edc02060..d10476915 100644 --- a/src/object/camera.cpp +++ b/src/object/camera.cpp @@ -50,14 +50,14 @@ Camera::~Camera() } void -Camera::expose(HSQUIRRELVM vm, int table_idx) +Camera::expose(HSQUIRRELVM vm, SQInteger table_idx) { Scripting::Camera* interface = new Scripting::Camera(this); expose_object(vm, table_idx, interface, "Camera", true); } void -Camera::unexpose(HSQUIRRELVM vm, int table_idx) +Camera::unexpose(HSQUIRRELVM vm, SQInteger table_idx) { Scripting::unexpose_object(vm, table_idx, "Camera"); } diff --git a/src/object/camera.hpp b/src/object/camera.hpp index 16e320387..07a92d001 100644 --- a/src/object/camera.hpp +++ b/src/object/camera.hpp @@ -62,8 +62,8 @@ public: { } - virtual void expose(HSQUIRRELVM vm, int table_idx); - virtual void unexpose(HSQUIRRELVM vm, int table_idx); + virtual void expose(HSQUIRRELVM vm, SQInteger table_idx); + virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx); // shake camera in a direction 1 time void shake(float speed, float x, float y); diff --git a/src/object/display_effect.cpp b/src/object/display_effect.cpp index 62128b97a..88a17d11c 100644 --- a/src/object/display_effect.cpp +++ b/src/object/display_effect.cpp @@ -39,14 +39,14 @@ DisplayEffect::~DisplayEffect() } void -DisplayEffect::expose(HSQUIRRELVM vm, int table_idx) +DisplayEffect::expose(HSQUIRRELVM vm, SQInteger table_idx) { Scripting::DisplayEffect* interface = static_cast (this); expose_object(vm, table_idx, interface, "Effect", false); } void -DisplayEffect::unexpose(HSQUIRRELVM vm, int table_idx) +DisplayEffect::unexpose(HSQUIRRELVM vm, SQInteger table_idx) { try { Scripting::unexpose_object(vm, table_idx, "Effect"); diff --git a/src/object/display_effect.hpp b/src/object/display_effect.hpp index 0a858b773..017daff41 100644 --- a/src/object/display_effect.hpp +++ b/src/object/display_effect.hpp @@ -31,8 +31,8 @@ public: DisplayEffect(); virtual ~DisplayEffect(); - void expose(HSQUIRRELVM vm, int table_idx); - void unexpose(HSQUIRRELVM vm, int table_idx); + void expose(HSQUIRRELVM vm, SQInteger table_idx); + void unexpose(HSQUIRRELVM vm, SQInteger table_idx); void update(float elapsed_time); void draw(DrawingContext& context); diff --git a/src/object/player.cpp b/src/object/player.cpp index 59b7d5760..3d33ce731 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -153,14 +153,14 @@ Player::init() } void -Player::expose(HSQUIRRELVM vm, int table_idx) +Player::expose(HSQUIRRELVM vm, SQInteger table_idx) { Scripting::Player* interface = static_cast (this); Scripting::expose_object(vm, table_idx, interface, "Tux", false); } void -Player::unexpose(HSQUIRRELVM vm, int table_idx) +Player::unexpose(HSQUIRRELVM vm, SQInteger table_idx) { Scripting::unexpose_object(vm, table_idx, "Tux"); } diff --git a/src/object/player.hpp b/src/object/player.hpp index f113104d3..3d7a239a3 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -123,8 +123,8 @@ public: Player(PlayerStatus* player_status); virtual ~Player(); - virtual void expose(HSQUIRRELVM vm, int table_idx); - virtual void unexpose(HSQUIRRELVM vm, int table_idx); + virtual void expose(HSQUIRRELVM vm, SQInteger table_idx); + virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx); void set_controller(Controller* controller); Controller* get_controller() diff --git a/src/object/scripted_object.cpp b/src/object/scripted_object.cpp index 67ca8b1a8..feace6c07 100644 --- a/src/object/scripted_object.cpp +++ b/src/object/scripted_object.cpp @@ -66,14 +66,14 @@ ScriptedObject::~ScriptedObject() } void -ScriptedObject::expose(HSQUIRRELVM vm, int table_idx) +ScriptedObject::expose(HSQUIRRELVM vm, SQInteger table_idx) { Scripting::ScriptedObject* interface = static_cast (this); expose_object(vm, table_idx, interface, name, false); } void -ScriptedObject::unexpose(HSQUIRRELVM vm, int table_idx) +ScriptedObject::unexpose(HSQUIRRELVM vm, SQInteger table_idx) { Scripting::unexpose_object(vm, table_idx, name); } diff --git a/src/object/scripted_object.hpp b/src/object/scripted_object.hpp index e1bc6663f..5bebd0c95 100644 --- a/src/object/scripted_object.hpp +++ b/src/object/scripted_object.hpp @@ -35,8 +35,8 @@ public: ScriptedObject(const lisp::Lisp& lisp); virtual ~ScriptedObject(); - virtual void expose(HSQUIRRELVM vm, int table_idx); - virtual void unexpose(HSQUIRRELVM vm, int table_idx); + virtual void expose(HSQUIRRELVM vm, SQInteger table_idx); + virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx); void update(float elapsed_time); void draw(DrawingContext& context); diff --git a/src/object/text_object.cpp b/src/object/text_object.cpp index acf48dd73..ef591eeb2 100644 --- a/src/object/text_object.cpp +++ b/src/object/text_object.cpp @@ -39,14 +39,14 @@ TextObject::~TextObject() } void -TextObject::expose(HSQUIRRELVM vm, int table_idx) +TextObject::expose(HSQUIRRELVM vm, SQInteger table_idx) { Scripting::Text* interface = static_cast (this); Scripting::expose_object(vm, table_idx, interface, "Text", false); } void -TextObject::unexpose(HSQUIRRELVM vm, int table_idx) +TextObject::unexpose(HSQUIRRELVM vm, SQInteger table_idx) { Scripting::unexpose_object(vm, table_idx, "Text"); } diff --git a/src/object/text_object.hpp b/src/object/text_object.hpp index 46337ec0c..c324e839c 100644 --- a/src/object/text_object.hpp +++ b/src/object/text_object.hpp @@ -34,8 +34,8 @@ public: TextObject(); virtual ~TextObject(); - void expose(HSQUIRRELVM vm, int table_idx); - void unexpose(HSQUIRRELVM vm, int table_idx); + void expose(HSQUIRRELVM vm, SQInteger table_idx); + void unexpose(HSQUIRRELVM vm, SQInteger table_idx); void set_text(const std::string& text); void set_font(const std::string& name); diff --git a/src/script_interface.hpp b/src/script_interface.hpp index 2cc422273..61226705b 100644 --- a/src/script_interface.hpp +++ b/src/script_interface.hpp @@ -32,8 +32,8 @@ public: virtual ~ScriptInterface() {} - virtual void expose(HSQUIRRELVM vm, int table_idx) = 0; - virtual void unexpose(HSQUIRRELVM vm, int table_idx) = 0; + virtual void expose(HSQUIRRELVM vm, SQInteger table_idx) = 0; + virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx) = 0; }; #endif diff --git a/src/scripting/serialize.cpp b/src/scripting/serialize.cpp index 1aee22aad..9ed5d23f0 100644 --- a/src/scripting/serialize.cpp +++ b/src/scripting/serialize.cpp @@ -30,7 +30,7 @@ namespace Scripting { -void load_squirrel_table(HSQUIRRELVM vm, int table_idx, const lisp::Lisp* lisp) +void load_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, const lisp::Lisp* lisp) { using namespace lisp; @@ -92,27 +92,27 @@ void save_squirrel_table(HSQUIRRELVM vm, int table_idx, lisp::Writer& writer) switch(sq_gettype(vm, -1)) { case OT_INTEGER: { - int val; + SQInteger val; sq_getinteger(vm, -1, &val); - writer.write_int(key, val); + writer.write_int(key, static_cast (val)); break; } case OT_FLOAT: { - float val; + SQFloat val; sq_getfloat(vm, -1, &val); - writer.write_float(key, val); + writer.write_float(key, static_cast (val)); break; } case OT_BOOL: { SQBool val; sq_getbool(vm, -1, &val); - writer.write_bool(key, val); + writer.write_bool(key, val == SQTrue); break; } case OT_STRING: { - const char* str; + const SQChar* str; sq_getstring(vm, -1, &str); - writer.write_string(key, str); + writer.write_string(key, reinterpret_cast (str)); break; } case OT_TABLE: { diff --git a/src/scripting/serialize.hpp b/src/scripting/serialize.hpp index 14fc068c4..3e9142a3c 100644 --- a/src/scripting/serialize.hpp +++ b/src/scripting/serialize.hpp @@ -28,8 +28,8 @@ namespace Scripting { - void save_squirrel_table(HSQUIRRELVM vm, int table_idx, lisp::Writer& writer); - void load_squirrel_table(HSQUIRRELVM vm, int table_idx, const lisp::Lisp* lisp); + void save_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, lisp::Writer& writer); + void load_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, const lisp::Lisp* lisp); } diff --git a/src/scripting/squirrel_util.cpp b/src/scripting/squirrel_util.cpp index 664e54830..161705629 100644 --- a/src/scripting/squirrel_util.cpp +++ b/src/scripting/squirrel_util.cpp @@ -135,7 +135,7 @@ void update_debugger() #endif } -std::string squirrel2string(HSQUIRRELVM v, int i) +std::string squirrel2string(HSQUIRRELVM v, SQInteger i) { std::ostringstream os; switch(sq_gettype(v, i)) @@ -153,19 +153,19 @@ std::string squirrel2string(HSQUIRRELVM v, int i) break; } case OT_INTEGER: { - int val; + SQInteger val; sq_getinteger(v, i, &val); os << val; break; } case OT_FLOAT: { - float val; + SQFloat val; sq_getfloat(v, i, &val); os << val; break; } case OT_STRING: { - const char* val; + const SQChar* val; sq_getstring(v, i, &val); os << "\"" << val << "\""; break; @@ -258,19 +258,19 @@ void print_squirrel_stack(HSQUIRRELVM v) printf("null"); break; case OT_INTEGER: { - int val; + SQInteger val; sq_getinteger(v, i, &val); printf("integer (%d)", val); break; } case OT_FLOAT: { - float val; + SQFloat val; sq_getfloat(v, i, &val); printf("float (%f)", val); break; } case OT_STRING: { - const char* val; + const SQChar* val; sq_getstring(v, i, &val); printf("string (%s)", val); break; @@ -337,7 +337,7 @@ void compile_and_run(HSQUIRRELVM vm, std::istream& in, { compile_script(vm, in, sourcename); - int oldtop = sq_gettop(vm); + SQInteger oldtop = sq_gettop(vm); try { sq_pushroottable(vm); diff --git a/src/scripting/squirrel_util.hpp b/src/scripting/squirrel_util.hpp index f7cbf65a2..874bb8eb0 100644 --- a/src/scripting/squirrel_util.hpp +++ b/src/scripting/squirrel_util.hpp @@ -35,7 +35,7 @@ namespace Scripting void exit_squirrel(); void update_debugger(); - std::string squirrel2string(HSQUIRRELVM vm, int i); + std::string squirrel2string(HSQUIRRELVM vm, SQInteger i); void print_squirrel_stack(HSQUIRRELVM vm); HSQOBJECT create_thread(HSQUIRRELVM vm); @@ -48,7 +48,7 @@ namespace Scripting const std::string& sourcename); template - void expose_object(HSQUIRRELVM v, int table_idx, T* object, + void expose_object(HSQUIRRELVM v, SQInteger table_idx, T* object, const std::string& name, bool free = false) { sq_pushstring(v, name.c_str(), -1); @@ -65,7 +65,7 @@ namespace Scripting } } - static inline void unexpose_object(HSQUIRRELVM v, int table_idx, + static inline void unexpose_object(HSQUIRRELVM v, SQInteger table_idx, const std::string& name) { sq_pushstring(v, name.c_str(), name.length()); diff --git a/src/sector.cpp b/src/sector.cpp index 295c57dbb..1df58d4a1 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -710,7 +710,7 @@ Sector::try_unexpose(GameObject* object) ScriptInterface* interface = dynamic_cast (object); if(interface != NULL) { HSQUIRRELVM vm = Scripting::global_vm; - int oldtop = sq_gettop(vm); + SQInteger oldtop = sq_gettop(vm); sq_pushobject(vm, sector_table); try { interface->unexpose(vm, -1); diff --git a/src/worldmap/sprite_change.cpp b/src/worldmap/sprite_change.cpp index 2516ad6e5..9ac536ecd 100644 --- a/src/worldmap/sprite_change.cpp +++ b/src/worldmap/sprite_change.cpp @@ -1,8 +1,7 @@ // $Id$ // // SuperTux -// Copyright (C) 2004 Ingo Ruhnke -// Copyright (C) 2006 Christoph Sommer +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/worldmap/sprite_change.hpp b/src/worldmap/sprite_change.hpp index 354e32c05..7bf2f8cd3 100644 --- a/src/worldmap/sprite_change.hpp +++ b/src/worldmap/sprite_change.hpp @@ -1,8 +1,7 @@ // $Id$ // // SuperTux -// Copyright (C) 2004 Ingo Ruhnke -// Copyright (C) 2006 Christoph Sommer +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License