fix cr/lfs and remove trailing whitespaces...
[supertux.git] / src / squirrel / sqstdlib / sqstdaux.cpp
index 62a1598..da014f5 100644 (file)
@@ -1,6 +1,7 @@
 /* see copyright notice in squirrel.h */
 #include <squirrel.h>
 #include <sqstdaux.h>
+#include <assert.h>
 
 void sqstd_printcallstack(HSQUIRRELVM v)
 {
@@ -10,9 +11,9 @@ void sqstd_printcallstack(HSQUIRRELVM v)
                SQInteger i;
                SQFloat f;
                const SQChar *s;
-               int level=1; //1 is to skip this function that is level 0
-               const SQChar *name=0; 
-               int seq=0;
+               SQInteger level=1; //1 is to skip this function that is level 0
+               const SQChar *name=0;
+               SQInteger seq=0;
                pf(v,_SC("\nCALLSTACK\n"));
                while(SQ_SUCCEEDED(sq_stackinfos(v,level,&si)))
                {
@@ -28,7 +29,7 @@ void sqstd_printcallstack(HSQUIRRELVM v)
 
                for(level=0;level<10;level++){
                        seq=0;
-                       while(name=sq_getlocal(v,level,seq))
+                       while((name = sq_getlocal(v,level,seq)))
                        {
                                seq++;
                                switch(sq_gettype(v,-1))
@@ -63,6 +64,9 @@ void sqstd_printcallstack(HSQUIRRELVM v)
                                case OT_NATIVECLOSURE:
                                        pf(v,_SC("[%s] NATIVECLOSURE\n"),name);
                                        break;
+                               case OT_GENERATOR:
+                                       pf(v,_SC("[%s] NATIVECLOSURE\n"),name);
+                                       break;
                                case OT_USERDATA:
                                        pf(v,_SC("[%s] USERDATA\n"),name);
                                        break;
@@ -75,6 +79,15 @@ void sqstd_printcallstack(HSQUIRRELVM v)
                                case OT_INSTANCE:
                                        pf(v,_SC("[%s] INSTANCE\n"),name);
                                        break;
+                               case OT_WEAKREF:
+                                       pf(v,_SC("[%s] INSTANCE\n"),name);
+                                       break;
+                               case OT_BOOL:{
+                                       sq_getinteger(v,-1,&i);
+                                       pf(v,_SC("[%s] %s\n"),name,i?_SC("true"):_SC("false"));
+                                                        }
+                                       break;
+                               default: assert(0); break;
                                }
                                sq_pop(v,1);
                        }
@@ -82,7 +95,7 @@ void sqstd_printcallstack(HSQUIRRELVM v)
        }
 }
 
-static int _sqstd_aux_printerror(HSQUIRRELVM v)
+static SQInteger _sqstd_aux_printerror(HSQUIRRELVM v)
 {
        SQPRINTFUNCTION pf = sq_getprintfunc(v);
        if(pf) {
@@ -100,11 +113,11 @@ static int _sqstd_aux_printerror(HSQUIRRELVM v)
        return 0;
 }
 
-void _sqstd_compiler_error(HSQUIRRELVM v,const SQChar *sErr,const SQChar *sSource,int line,int column)
+void _sqstd_compiler_error(HSQUIRRELVM v,const SQChar *sErr,const SQChar *sSource,SQInteger line,SQInteger column)
 {
        SQPRINTFUNCTION pf = sq_getprintfunc(v);
        if(pf) {
-               pf(v,_SC("ERROR %s line=(%d) column=(%d) [%s]\n"),sErr,line,column,sSource);
+               pf(v,_SC("%s line = (%d) column = (%d) : error %s\n"),sSource,line,column,sErr);
        }
 }