Merge branch master

This commit is contained in:
Fabian Wolff 2016-03-08 13:59:33 +01:00
commit d9ce07f065
16 changed files with 37 additions and 35 deletions

View File

@ -12,7 +12,7 @@ project(squirrel C CXX)
include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_SOURCE_DIR}/include)
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
set(SQ_FLAGS -fno-exceptions -fno-strict-aliasing -Wall -Wextra) set(SQ_FLAGS -fno-exceptions -fno-strict-aliasing -Wall -Wextra -pedantic)
if(CMAKE_BUILD_TYPE STREQUAL "Release") if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(SQ_FLAGS ${SQ_FLAGS} -O3) set(SQ_FLAGS ${SQ_FLAGS} -O3)
@ -26,7 +26,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(${SQ_FLAGS}) add_definitions(${SQ_FLAGS})
endif() endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -std=c++0x")
elseif(MSVC) elseif(MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif() endif()

View File

@ -60,10 +60,10 @@ typedef wchar_t SQChar;
#define scstrcmp wcscmp #define scstrcmp wcscmp
#ifdef _MSC_VER #ifdef _WIN32
#define scsprintf _snwprintf #define scsprintf _snwprintf
#else #else
#define scsprintf snwprintf #define scsprintf swprintf
#endif #endif
#define scstrlen wcslen #define scstrlen wcslen
#define scstrtod wcstod #define scstrtod wcstod

View File

@ -52,6 +52,7 @@ void printfunc(HSQUIRRELVM SQ_UNUSED_ARG(v),const SQChar *s,...)
va_start(vl, s); va_start(vl, s);
scvprintf(stdout, s, vl); scvprintf(stdout, s, vl);
va_end(vl); va_end(vl);
(void)v; /* UNUSED */
} }
void errorfunc(HSQUIRRELVM SQ_UNUSED_ARG(v),const SQChar *s,...) void errorfunc(HSQUIRRELVM SQ_UNUSED_ARG(v),const SQChar *s,...)
@ -87,6 +88,9 @@ int getargs(HSQUIRRELVM v,int argc, char* argv[],SQInteger *retval)
{ {
int i; int i;
int compiles_only = 0; int compiles_only = 0;
#ifdef SQUNICODE
static SQChar temp[500];
#endif
char * output = NULL; char * output = NULL;
*retval = 0; *retval = 0;
if(argc>1) if(argc>1)

View File

@ -172,7 +172,7 @@ static const SQRegFunction _blob_methods[] = {
_DECL_BLOB_FUNC(_typeof,1,_SC("x")), _DECL_BLOB_FUNC(_typeof,1,_SC("x")),
_DECL_BLOB_FUNC(_nexti,2,_SC("x")), _DECL_BLOB_FUNC(_nexti,2,_SC("x")),
_DECL_BLOB_FUNC(_cloned,2,_SC("xx")), _DECL_BLOB_FUNC(_cloned,2,_SC("xx")),
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
@ -230,7 +230,7 @@ static const SQRegFunction bloblib_funcs[]={
_DECL_GLOBALBLOB_FUNC(swap2,2,_SC(".n")), _DECL_GLOBALBLOB_FUNC(swap2,2,_SC(".n")),
_DECL_GLOBALBLOB_FUNC(swap4,2,_SC(".n")), _DECL_GLOBALBLOB_FUNC(swap4,2,_SC(".n")),
_DECL_GLOBALBLOB_FUNC(swapfloat,2,_SC(".n")), _DECL_GLOBALBLOB_FUNC(swapfloat,2,_SC(".n")),
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr) SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr)

View File

@ -168,7 +168,7 @@ static const SQRegFunction _file_methods[] = {
_DECL_FILE_FUNC(constructor,3,_SC("x")), _DECL_FILE_FUNC(constructor,3,_SC("x")),
_DECL_FILE_FUNC(_typeof,1,_SC("x")), _DECL_FILE_FUNC(_typeof,1,_SC("x")),
_DECL_FILE_FUNC(close,1,_SC("x")), _DECL_FILE_FUNC(close,1,_SC("x")),
{0,0,0,0}, {NULL,(SQFUNCTION)0,0,NULL}
}; };
@ -463,7 +463,7 @@ static const SQRegFunction iolib_funcs[]={
_DECL_GLOBALIO_FUNC(loadfile,-2,_SC(".sb")), _DECL_GLOBALIO_FUNC(loadfile,-2,_SC(".sb")),
_DECL_GLOBALIO_FUNC(dofile,-2,_SC(".sb")), _DECL_GLOBALIO_FUNC(dofile,-2,_SC(".sb")),
_DECL_GLOBALIO_FUNC(writeclosuretofile,3,_SC(".sc")), _DECL_GLOBALIO_FUNC(writeclosuretofile,3,_SC(".sc")),
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
SQRESULT sqstd_register_iolib(HSQUIRRELVM v) SQRESULT sqstd_register_iolib(HSQUIRRELVM v)

View File

@ -78,7 +78,7 @@ static const SQRegFunction mathlib_funcs[] = {
_DECL_FUNC(rand,1,NULL), _DECL_FUNC(rand,1,NULL),
_DECL_FUNC(fabs,2,_SC(".n")), _DECL_FUNC(fabs,2,_SC(".n")),
_DECL_FUNC(abs,2,_SC(".n")), _DECL_FUNC(abs,2,_SC(".n")),
{0,0,0,0}, {NULL,(SQFUNCTION)0,0,NULL}
}; };
#undef _DECL_FUNC #undef _DECL_FUNC

View File

@ -550,7 +550,7 @@ static const SQChar *sqstd_rex_matchnode(SQRex* exp,SQRexNode *node,const SQChar
/* public api */ /* public api */
SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error) SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error)
{ {
SQRex *exp = (SQRex *)sq_malloc(sizeof(SQRex)); SQRex * volatile exp = (SQRex *)sq_malloc(sizeof(SQRex)); // "volatile" is needed for setjmp()
exp->_eol = exp->_bol = NULL; exp->_eol = exp->_bol = NULL;
exp->_p = pattern; exp->_p = pattern;
exp->_nallocated = (SQInteger)scstrlen(pattern) * sizeof(SQChar); exp->_nallocated = (SQInteger)scstrlen(pattern) * sizeof(SQChar);
@ -578,7 +578,7 @@ SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error)
scprintf(_SC("[%02d] %10s "),i,g_nnames[exp->_nodes[i].type-MAX_CHAR]); scprintf(_SC("[%02d] %10s "),i,g_nnames[exp->_nodes[i].type-MAX_CHAR]);
else else
scprintf(_SC("[%02d] %10c "),i,exp->_nodes[i].type); scprintf(_SC("[%02d] %10c "),i,exp->_nodes[i].type);
scprintf(_SC("left %02d right %02d next %02d\n"),exp->_nodes[i].left,exp->_nodes[i].right,exp->_nodes[i].next); 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")); scprintf(_SC("\n"));
} }

View File

@ -249,7 +249,7 @@ static const SQRegFunction _stream_methods[] = {
_DECL_STREAM_FUNC(eos,1,_SC("x")), _DECL_STREAM_FUNC(eos,1,_SC("x")),
_DECL_STREAM_FUNC(flush,1,_SC("x")), _DECL_STREAM_FUNC(flush,1,_SC("x")),
_DECL_STREAM_FUNC(_cloned,0,NULL), _DECL_STREAM_FUNC(_cloned,0,NULL),
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
void init_streamclass(HSQUIRRELVM v) void init_streamclass(HSQUIRRELVM v)

View File

@ -94,9 +94,9 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
if(n < 0) return -1; if(n < 0) return -1;
SQInteger addlen = 0; SQInteger addlen = 0;
SQInteger valtype = 0; SQInteger valtype = 0;
const SQChar *ts; const SQChar *ts = NULL;
SQInteger ti; SQInteger ti = 0;
SQFloat tf; SQFloat tf = 0;
switch(format[n]) { switch(format[n]) {
case 's': case 's':
if(SQ_FAILED(sq_getstring(v,nparam,&ts))) if(SQ_FAILED(sq_getstring(v,nparam,&ts)))
@ -452,7 +452,7 @@ static const SQRegFunction rexobj_funcs[]={
_DECL_REX_FUNC(capture,-2,_SC("xsn")), _DECL_REX_FUNC(capture,-2,_SC("xsn")),
_DECL_REX_FUNC(subexpcount,1,_SC("x")), _DECL_REX_FUNC(subexpcount,1,_SC("x")),
_DECL_REX_FUNC(_typeof,1,_SC("x")), _DECL_REX_FUNC(_typeof,1,_SC("x")),
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
#undef _DECL_REX_FUNC #undef _DECL_REX_FUNC
@ -466,7 +466,7 @@ static const SQRegFunction stringlib_funcs[]={
_DECL_FUNC(escape,2,_SC(".s")), _DECL_FUNC(escape,2,_SC(".s")),
_DECL_FUNC(startswith,3,_SC(".ss")), _DECL_FUNC(startswith,3,_SC(".ss")),
_DECL_FUNC(endswith,3,_SC(".ss")), _DECL_FUNC(endswith,3,_SC(".ss")),
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
#undef _DECL_FUNC #undef _DECL_FUNC

View File

@ -126,7 +126,7 @@ static const SQRegFunction systemlib_funcs[]={
_DECL_FUNC(date,-1,_SC(".nn")), _DECL_FUNC(date,-1,_SC(".nn")),
_DECL_FUNC(remove,2,_SC(".s")), _DECL_FUNC(remove,2,_SC(".s")),
_DECL_FUNC(rename,3,_SC(".ss")), _DECL_FUNC(rename,3,_SC(".ss")),
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
#undef _DECL_FUNC #undef _DECL_FUNC

View File

@ -296,7 +296,7 @@ static const SQRegFunction base_funcs[]={
{_SC("collectgarbage"),base_collectgarbage,0, NULL}, {_SC("collectgarbage"),base_collectgarbage,0, NULL},
{_SC("resurrectunreachable"),base_resurectureachable,0, NULL}, {_SC("resurrectunreachable"),base_resurectureachable,0, NULL},
#endif #endif
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
void sq_base_register(HSQUIRRELVM v) void sq_base_register(HSQUIRRELVM v)
@ -475,7 +475,7 @@ const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
{_SC("clear"),obj_clear,1, _SC(".")}, {_SC("clear"),obj_clear,1, _SC(".")},
{_SC("setdelegate"),table_setdelegate,2, _SC(".t|o")}, {_SC("setdelegate"),table_setdelegate,2, _SC(".t|o")},
{_SC("getdelegate"),table_getdelegate,1, _SC(".")}, {_SC("getdelegate"),table_getdelegate,1, _SC(".")},
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
//ARRAY DEFAULT DELEGATE/////////////////////////////////////// //ARRAY DEFAULT DELEGATE///////////////////////////////////////
@ -794,7 +794,7 @@ const SQRegFunction SQSharedState::_array_default_delegate_funcz[]={
{_SC("reduce"),array_reduce,2, _SC("ac")}, {_SC("reduce"),array_reduce,2, _SC("ac")},
{_SC("filter"),array_filter,2, _SC("ac")}, {_SC("filter"),array_filter,2, _SC("ac")},
{_SC("find"),array_find,2, _SC("a.")}, {_SC("find"),array_find,2, _SC("a.")},
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
//STRING DEFAULT DELEGATE////////////////////////// //STRING DEFAULT DELEGATE//////////////////////////
@ -863,7 +863,7 @@ const SQRegFunction SQSharedState::_string_default_delegate_funcz[]={
{_SC("tolower"),string_tolower,-1, _SC("s n n")}, {_SC("tolower"),string_tolower,-1, _SC("s n n")},
{_SC("toupper"),string_toupper,-1, _SC("s n n")}, {_SC("toupper"),string_toupper,-1, _SC("s n n")},
{_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
//INTEGER DEFAULT DELEGATE////////////////////////// //INTEGER DEFAULT DELEGATE//////////////////////////
@ -873,7 +873,7 @@ const SQRegFunction SQSharedState::_number_default_delegate_funcz[]={
{_SC("tostring"),default_delegate_tostring,1, _SC(".")}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{_SC("tochar"),number_delegate_tochar,1, _SC("n|b")}, {_SC("tochar"),number_delegate_tochar,1, _SC("n|b")},
{_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
//CLOSURE DEFAULT DELEGATE////////////////////////// //CLOSURE DEFAULT DELEGATE//////////////////////////
@ -983,7 +983,7 @@ const SQRegFunction SQSharedState::_closure_default_delegate_funcz[]={
{_SC("getinfos"),closure_getinfos,1, _SC("c")}, {_SC("getinfos"),closure_getinfos,1, _SC("c")},
{_SC("getroot"),closure_getroot,1, _SC("c")}, {_SC("getroot"),closure_getroot,1, _SC("c")},
{_SC("setroot"),closure_setroot,2, _SC("ct")}, {_SC("setroot"),closure_setroot,2, _SC("ct")},
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
//GENERATOR DEFAULT DELEGATE //GENERATOR DEFAULT DELEGATE
@ -1002,7 +1002,7 @@ const SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={
{_SC("getstatus"),generator_getstatus,1, _SC("g")}, {_SC("getstatus"),generator_getstatus,1, _SC("g")},
{_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{_SC("tostring"),default_delegate_tostring,1, _SC(".")}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
//THREAD DEFAULT DELEGATE //THREAD DEFAULT DELEGATE
@ -1162,7 +1162,7 @@ const SQRegFunction SQSharedState::_thread_default_delegate_funcz[] = {
{_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{_SC("getstackinfos"),thread_getstackinfos,2, _SC("vn")}, {_SC("getstackinfos"),thread_getstackinfos,2, _SC("vn")},
{_SC("tostring"),default_delegate_tostring,1, _SC(".")}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0,0,0}, {NULL,(SQFUNCTION)0,0,NULL}
}; };
static SQInteger class_getattributes(HSQUIRRELVM v) static SQInteger class_getattributes(HSQUIRRELVM v)
@ -1229,7 +1229,7 @@ const SQRegFunction SQSharedState::_class_default_delegate_funcz[] = {
{_SC("getbase"),class_getbase,1, _SC("y")}, {_SC("getbase"),class_getbase,1, _SC("y")},
{_SC("newmember"),class_newmember,-3, _SC("y")}, {_SC("newmember"),class_newmember,-3, _SC("y")},
{_SC("rawnewmember"),class_rawnewmember,-3, _SC("y")}, {_SC("rawnewmember"),class_rawnewmember,-3, _SC("y")},
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
@ -1247,7 +1247,7 @@ const SQRegFunction SQSharedState::_instance_default_delegate_funcz[] = {
{_SC("rawin"),container_rawexists,2, _SC("x")}, {_SC("rawin"),container_rawexists,2, _SC("x")},
{_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{_SC("tostring"),default_delegate_tostring,1, _SC(".")}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };
static SQInteger weakref_ref(HSQUIRRELVM v) static SQInteger weakref_ref(HSQUIRRELVM v)
@ -1261,6 +1261,5 @@ const SQRegFunction SQSharedState::_weakref_default_delegate_funcz[] = {
{_SC("ref"),weakref_ref,1, _SC("r")}, {_SC("ref"),weakref_ref,1, _SC("r")},
{_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{_SC("tostring"),default_delegate_tostring,1, _SC(".")}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0,0,0} {NULL,(SQFUNCTION)0,0,NULL}
}; };

View File

@ -982,7 +982,7 @@ public:
SQInteger val = _fs->PopTarget(); SQInteger val = _fs->PopTarget();
SQInteger key = _fs->PopTarget(); SQInteger key = _fs->PopTarget();
SQInteger attrs = hasattrs ? _fs->PopTarget():-1; SQInteger attrs = hasattrs ? _fs->PopTarget():-1;
((void)attrs); ((void)attrs);
assert((hasattrs && (attrs == key-1)) || !hasattrs); assert((hasattrs && (attrs == key-1)) || !hasattrs);
unsigned char flags = (hasattrs?NEW_SLOT_ATTRIBUTES_FLAG:0)|(isstatic?NEW_SLOT_STATIC_FLAG:0); unsigned char flags = (hasattrs?NEW_SLOT_ATTRIBUTES_FLAG:0)|(isstatic?NEW_SLOT_STATIC_FLAG:0);
SQInteger table = _fs->TopTarget(); //<<BECAUSE OF THIS NO COMMON EMIT FUNC IS POSSIBLE SQInteger table = _fs->TopTarget(); //<<BECAUSE OF THIS NO COMMON EMIT FUNC IS POSSIBLE

View File

@ -379,7 +379,7 @@ SQInteger SQLexer::ReadString(SQInteger ndelim,bool verbatim)
APPEND_CHAR((SQChar)scstrtoul(temp, &stemp, 16)); APPEND_CHAR((SQChar)scstrtoul(temp, &stemp, 16));
} }
break; break;
case _SC('U'): case _SC('U'):
case _SC('u'): { case _SC('u'): {
const SQInteger maxdigits = x == 'u' ? 4 : 8; const SQInteger maxdigits = x == 'u' ? 4 : 8;
SQChar temp[8 + 1]; SQChar temp[8 + 1];

View File

@ -30,7 +30,7 @@ private:
#endif #endif
#else #else
SQInteger AddUTF8(SQUnsignedInteger ch); SQInteger AddUTF8(SQUnsignedInteger ch);
#endif #endif
SQInteger ProcessStringHexEscape(SQChar *dest, SQInteger maxdigits); SQInteger ProcessStringHexEscape(SQChar *dest, SQInteger maxdigits);
SQInteger _curtoken; SQInteger _curtoken;
SQTable *_keywords; SQTable *_keywords;

View File

@ -110,7 +110,7 @@ struct SQInstruction
{ {
SQInstruction(){}; SQInstruction(){};
SQInstruction(SQOpcode _op,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0) SQInstruction(SQOpcode _op,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0)
{ op = _op; { op = (unsigned char)_op;
_arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1; _arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1;
_arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3; _arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3;
} }

View File

@ -250,7 +250,6 @@ void SQSharedState::MarkObject(SQObjectPtr &o,SQCollectable **chain)
} }
} }
void SQSharedState::RunMark(SQVM SQ_UNUSED_ARG(*vm),SQCollectable **tchain) void SQSharedState::RunMark(SQVM SQ_UNUSED_ARG(*vm),SQCollectable **tchain)
{ {
SQVM *vms = _thread(_root_vm); SQVM *vms = _thread(_root_vm);