}
}
- int oldtop = sq_gettop(vm);
+ SQInteger oldtop = sq_gettop(vm);
try {
if(SQ_FAILED(sq_compilebuffer(vm, command.c_str(), command.length(),
"", SQTrue)))
} 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 {
}
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");
}
{
}
- 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);
}
void
-DisplayEffect::expose(HSQUIRRELVM vm, int table_idx)
+DisplayEffect::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
Scripting::DisplayEffect* interface = static_cast<Scripting::DisplayEffect*> (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");
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);
}
void
-Player::expose(HSQUIRRELVM vm, int table_idx)
+Player::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
Scripting::Player* interface = static_cast<Scripting::Player*> (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");
}
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()
}
void
-ScriptedObject::expose(HSQUIRRELVM vm, int table_idx)
+ScriptedObject::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
Scripting::ScriptedObject* interface = static_cast<Scripting::ScriptedObject*> (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);
}
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);
}
void
-TextObject::expose(HSQUIRRELVM vm, int table_idx)
+TextObject::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
Scripting::Text* interface = static_cast<Scripting::Text*> (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");
}
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);
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
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;
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<int> (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<float> (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<const char*> (str));
break;
}
case OT_TABLE: {
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);
}
#endif
}
-std::string squirrel2string(HSQUIRRELVM v, int i)
+std::string squirrel2string(HSQUIRRELVM v, SQInteger i)
{
std::ostringstream os;
switch(sq_gettype(v, 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;
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;
{
compile_script(vm, in, sourcename);
- int oldtop = sq_gettop(vm);
+ SQInteger oldtop = sq_gettop(vm);
try {
sq_pushroottable(vm);
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);
const std::string& sourcename);
template<typename T>
- 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);
}
}
- 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());
ScriptInterface* interface = dynamic_cast<ScriptInterface*> (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);
// $Id$
//
// SuperTux
-// Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
-// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// $Id$
//
// SuperTux
-// Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
-// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License