// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <config.h>
#include "serialize.hpp"
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;
if(table_idx < 0)
- table_idx -= 2;
-
+ table_idx -= 2;
+
lisp::ListIterator iter(lisp);
- while(iter.next()) {
+ while(iter.next() && iter.lisp() != NULL) {
const std::string& token = iter.item();
sq_pushstring(vm, token.c_str(), token.size());
}
}
-void save_squirrel_table(HSQUIRRELVM vm, int table_idx, lisp::Writer& writer)
+void save_squirrel_table(HSQUIRRELVM vm, SQInteger table_idx, lisp::Writer& writer)
{
// offset because of sq_pushnull
if(table_idx < 0)
table_idx -= 1;
-
+
//iterator table
sq_pushnull(vm);
while(SQ_SUCCEEDED(sq_next(vm, table_idx))) {
std::cerr << "Table contains non-string key\n";
continue;
}
- const char* key;
+ const SQChar* key;
sq_getstring(vm, -2, &key);
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: {
}
}
-