-fixed _set method in userdata deelegates

-fixed some warnings
-sq_gettypetag doesn't set last error(it's treated as SQBool function but keeps a SQRESULT for backward compatibility)
This commit is contained in:
albertodemichelis 2017-01-02 18:21:41 +08:00
parent fae1cabb51
commit be35cf850b
9 changed files with 27 additions and 21 deletions

View File

@ -1,3 +1,8 @@
***version 3.1.1 stable***
-sq_gettypetag doesn't set last error(it's treated as SQBool function but keeps a SQRESULT for backward compatibility)
-fixed _set method in userdata deelegates
-fixed some warnings
***version 3.1 stable***
-added slice range for tolower and toupper
-added startswith() and endswith() in string lib

View File

@ -7,7 +7,7 @@
#include "sqstdstream.h"
#include "sqstdblobimpl.h"
#define SQSTD_BLOB_TYPE_TAG (SQSTD_STREAM_TYPE_TAG | 0x00000002)
#define SQSTD_BLOB_TYPE_TAG ((SQUnsignedInteger)(SQSTD_STREAM_TYPE_TAG | 0x00000002))
//Blob

View File

@ -5,7 +5,7 @@
#include <sqstdio.h>
#include "sqstdstream.h"
#define SQSTD_FILE_TYPE_TAG (SQSTD_STREAM_TYPE_TAG | 0x00000001)
#define SQSTD_FILE_TYPE_TAG ((SQUnsignedInteger)(SQSTD_STREAM_TYPE_TAG | 0x00000001))
//basic API
SQFILE sqstd_fopen(const SQChar *filename ,const SQChar *mode)
{

View File

@ -578,9 +578,9 @@ SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error)
scprintf(_SC("\n"));
for(i = 0;i < nsize; i++) {
if(exp->_nodes[i].type>MAX_CHAR)
scprintf(_SC("[%02d] %10s "),i,g_nnames[exp->_nodes[i].type-MAX_CHAR]);
scprintf(_SC("[%02d] %10s "), (SQInt32)i,g_nnames[exp->_nodes[i].type-MAX_CHAR]);
else
scprintf(_SC("[%02d] %10c "),i,exp->_nodes[i].type);
scprintf(_SC("[%02d] %10c "), (SQInt32)i,exp->_nodes[i].type);
scprintf(_SC("left %02d right %02d next %02d\n"), (SQInt32)exp->_nodes[i].left, (SQInt32)exp->_nodes[i].right, (SQInt32)exp->_nodes[i].next);
}
scprintf(_SC("\n"));

View File

@ -11,7 +11,7 @@
#define SETUP_STREAM(v) \
SQStream *self = NULL; \
if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_STREAM_TYPE_TAG))) \
if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)((SQUnsignedInteger)SQSTD_STREAM_TYPE_TAG)))) \
return sq_throwerror(v,_SC("invalid type tag")); \
if(!self || !self->IsValid()) \
return sq_throwerror(v,_SC("the stream is invalid"));
@ -259,7 +259,7 @@ void init_streamclass(HSQUIRRELVM v)
if(SQ_FAILED(sq_get(v,-2))) {
sq_pushstring(v,_SC("std_stream"),-1);
sq_newclass(v,SQFalse);
sq_settypetag(v,-1,(SQUserPointer)SQSTD_STREAM_TYPE_TAG);
sq_settypetag(v,-1,(SQUserPointer)((SQUnsignedInteger)SQSTD_STREAM_TYPE_TAG));
SQInteger i = 0;
while(_stream_methods[i].name != 0) {
const SQRegFunction &f = _stream_methods[i];

View File

@ -776,8 +776,8 @@ SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag)
SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag)
{
SQObjectPtr &o = stack_get(v,idx);
if(SQ_FAILED(sq_getobjtypetag(&o,typetag)))
return sq_throwerror(v,_SC("invalid object type"));
if (SQ_FAILED(sq_getobjtypetag(&o, typetag)))
return SQ_ERROR;// this is not an error it should be a bool but would break backward compatibility
return SQ_OK;
}

View File

@ -107,7 +107,7 @@ void SQVM::Raise_ParamTypeError(SQInteger nparam,SQInteger typemask,SQInteger ty
SQInteger found = 0;
for(SQInteger i=0; i<16; i++)
{
SQInteger mask = 0x00000001 << i;
SQInteger mask = ((SQInteger)1) << i;
if(typemask & (mask)) {
if(found>0) StringCat(exptypes,SQString::Create(_ss(this), _SC("|"), -1), exptypes);
found ++;

View File

@ -117,8 +117,8 @@ void SQFuncState::Dump(SQFunctionProto *func)
{
SQUnsignedInteger n=0,i;
SQInteger si;
scprintf(_SC("SQInstruction sizeof %d\n"),sizeof(SQInstruction));
scprintf(_SC("SQObject sizeof %d\n"),sizeof(SQObject));
scprintf(_SC("SQInstruction sizeof %d\n"),(SQInt32)sizeof(SQInstruction));
scprintf(_SC("SQObject sizeof %d\n"), (SQInt32)sizeof(SQObject));
scprintf(_SC("--------------------------------------------------------------------\n"));
scprintf(_SC("*****FUNCTION [%s]\n"),type(func->_name)==OT_STRING?_stringval(func->_name):_SC("unknown"));
scprintf(_SC("-----LITERALS\n"));
@ -131,7 +131,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
templiterals[_integer(val)]=key;
}
for(i=0;i<templiterals.size();i++){
scprintf(_SC("[%d] "),n);
scprintf(_SC("[%d] "), (SQInt32)n);
DumpLiteral(templiterals[i]);
scprintf(_SC("\n"));
n++;
@ -141,7 +141,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
scprintf(_SC("<<VARPARAMS>>\n"));
n=0;
for(i=0;i<_parameters.size();i++){
scprintf(_SC("[%d] "),n);
scprintf(_SC("[%d] "), (SQInt32)n);
DumpLiteral(_parameters[i]);
scprintf(_SC("\n"));
n++;
@ -149,13 +149,13 @@ void SQFuncState::Dump(SQFunctionProto *func)
scprintf(_SC("-----LOCALS\n"));
for(si=0;si<func->_nlocalvarinfos;si++){
SQLocalVarInfo lvi=func->_localvarinfos[si];
scprintf(_SC("[%d] %s \t%d %d\n"),lvi._pos,_stringval(lvi._name),lvi._start_op,lvi._end_op);
scprintf(_SC("[%d] %s \t%d %d\n"), (SQInt32)lvi._pos,_stringval(lvi._name), (SQInt32)lvi._start_op, (SQInt32)lvi._end_op);
n++;
}
scprintf(_SC("-----LINE INFO\n"));
for(i=0;i<_lineinfos.size();i++){
SQLineInfo li=_lineinfos[i];
scprintf(_SC("op [%d] line [%d] \n"),li._op,li._line);
scprintf(_SC("op [%d] line [%d] \n"), (SQInt32)li._op, (SQInt32)li._line);
n++;
}
scprintf(_SC("-----dump\n"));
@ -165,7 +165,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
if(inst.op==_OP_LOAD || inst.op==_OP_DLOAD || inst.op==_OP_PREPCALLK || inst.op==_OP_GETK ){
SQInteger lidx = inst._arg1;
scprintf(_SC("[%03d] %15s %d "),n,g_InstrDesc[inst.op].name,inst._arg0);
scprintf(_SC("[%03d] %15s %d "), (SQInt32)n,g_InstrDesc[inst.op].name,inst._arg0);
if(lidx >= 0xFFFFFFFF)
scprintf(_SC("null"));
else {
@ -196,18 +196,18 @@ void SQFuncState::Dump(SQFunctionProto *func)
}
}
else if(inst.op==_OP_LOADFLOAT) {
scprintf(_SC("[%03d] %15s %d %f %d %d\n"),n,g_InstrDesc[inst.op].name,inst._arg0,*((SQFloat*)&inst._arg1),inst._arg2,inst._arg3);
scprintf(_SC("[%03d] %15s %d %f %d %d\n"), (SQInt32)n,g_InstrDesc[inst.op].name,inst._arg0,*((SQFloat*)&inst._arg1),inst._arg2,inst._arg3);
}
/* else if(inst.op==_OP_ARITH){
scprintf(_SC("[%03d] %15s %d %d %d %c\n"),n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
}*/
else {
scprintf(_SC("[%03d] %15s %d %d %d %d\n"),n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
scprintf(_SC("[%03d] %15s %d %d %d %d\n"), (SQInt32)n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
}
n++;
}
scprintf(_SC("-----\n"));
scprintf(_SC("stack size[%d]\n"),func->_stacksize);
scprintf(_SC("stack size[%d]\n"), (SQInt32)func->_stacksize);
scprintf(_SC("--------------------------------------------------------------------\n\n"));
}
#endif

View File

@ -1330,6 +1330,7 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr
return false;
}
return true;
case OT_USERDATA: break; // must fall back
default:
Raise_Error(_SC("trying to set '%s'"),GetTypeName(self));
return false;
@ -1717,10 +1718,10 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall)
for(SQInteger i=0;i<size;i++){
SQObjectPtr &obj=_stack[i];
if(stackbase==i)scprintf(_SC(">"));else scprintf(_SC(" "));
scprintf(_SC("[%d]:"),n);
scprintf(_SC("[" _PRINT_INT_FMT "]:"),n);
switch(type(obj)){
case OT_FLOAT: scprintf(_SC("FLOAT %.3f"),_float(obj));break;
case OT_INTEGER: scprintf(_SC("INTEGER %d"),_integer(obj));break;
case OT_INTEGER: scprintf(_SC("INTEGER " _PRINT_INT_FMT),_integer(obj));break;
case OT_BOOL: scprintf(_SC("BOOL %s"),_integer(obj)?"true":"false");break;
case OT_STRING: scprintf(_SC("STRING %s"),_stringval(obj));break;
case OT_NULL: scprintf(_SC("NULL")); break;