From 6822172f6a9ed89b661dc2146887392b0f86b625 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sun, 22 May 2016 22:51:59 +0300 Subject: [PATCH] Updated the Squirrel and Sqrat libraries to the latest development versions. --- cbp/Squirrel.cbp | 1 + external/Squirrel/COPYRIGHT | 2 +- external/Squirrel/Lib/sqstdaux.cpp | 4 +- external/Squirrel/Lib/sqstdio.cpp | 6 +- external/Squirrel/Lib/sqstdrex.cpp | 3 + external/Squirrel/Lib/sqstdstring.cpp | 16 +- external/Squirrel/sqapi.cpp | 40 ++-- external/Squirrel/sqbaselib.cpp | 7 +- external/Squirrel/sqlexer.cpp | 2 +- external/Squirrel/sqstate.cpp | 52 ++--- external/Squirrel/sqvm.cpp | 9 +- external/Squirrel/sqvm.h | 3 - include/sqrat/sqratObject.h | 38 ++++ include/sqstdio.h | 1 + include/squirrel.h | 7 +- shared/SqAPI.h | 307 +++++++++++++------------- shared/SqMod.inl | 3 + source/Exports.cpp | 1 + 18 files changed, 283 insertions(+), 219 deletions(-) diff --git a/cbp/Squirrel.cbp b/cbp/Squirrel.cbp index edf0dbe7..143e947b 100644 --- a/cbp/Squirrel.cbp +++ b/cbp/Squirrel.cbp @@ -165,6 +165,7 @@ + diff --git a/external/Squirrel/COPYRIGHT b/external/Squirrel/COPYRIGHT index 4530d81b..3adb5e7b 100644 --- a/external/Squirrel/COPYRIGHT +++ b/external/Squirrel/COPYRIGHT @@ -1,4 +1,4 @@ -Copyright (c) 2003-2015 Alberto Demichelis +Copyright (c) 2003-2016 Alberto Demichelis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/external/Squirrel/Lib/sqstdaux.cpp b/external/Squirrel/Lib/sqstdaux.cpp index a2bb7293..3c478fcf 100644 --- a/external/Squirrel/Lib/sqstdaux.cpp +++ b/external/Squirrel/Lib/sqstdaux.cpp @@ -103,10 +103,10 @@ static SQInteger _sqstd_aux_printerror(HSQUIRRELVM v) const SQChar *sErr = 0; if(sq_gettop(v)>=1) { if(SQ_SUCCEEDED(sq_getstring(v,2,&sErr))) { - pf(v,_SC("\nAN ERROR HAS OCCURED [%s]\n"),sErr); + pf(v,_SC("\nAN ERROR HAS OCCURRED [%s]\n"),sErr); } else{ - pf(v,_SC("\nAN ERROR HAS OCCURED [unknown]\n")); + pf(v,_SC("\nAN ERROR HAS OCCURRED [unknown]\n")); } sqstd_printcallstack(v); } diff --git a/external/Squirrel/Lib/sqstdio.cpp b/external/Squirrel/Lib/sqstdio.cpp index 273bb5cc..3a862626 100644 --- a/external/Squirrel/Lib/sqstdio.cpp +++ b/external/Squirrel/Lib/sqstdio.cpp @@ -372,7 +372,7 @@ SQRESULT sqstd_loadfile(HSQUIRRELVM v,const SQChar *filename,SQBool printerror) } if(uc != 0xBF) { sqstd_fclose(file); - return sq_throwerror(v,_SC("Unrecognozed ecoding")); + return sq_throwerror(v,_SC("Unrecognized encoding")); } #ifdef SQUNICODE func = _io_file_lexfeed_UTF8; @@ -399,6 +399,10 @@ SQRESULT sqstd_loadfile(HSQUIRRELVM v,const SQChar *filename,SQBool printerror) SQRESULT sqstd_dofile(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool printerror) { + //at least one entry must exist in order for us to push it as the environment + if(sq_gettop(v) == 0) + return sq_throwerror(v,_SC("environment table expected")); + if(SQ_SUCCEEDED(sqstd_loadfile(v,filename,printerror))) { sq_push(v,-2); if(SQ_SUCCEEDED(sq_call(v,1,retval,SQTrue))) { diff --git a/external/Squirrel/Lib/sqstdrex.cpp b/external/Squirrel/Lib/sqstdrex.cpp index 9390c2dc..38a85085 100644 --- a/external/Squirrel/Lib/sqstdrex.cpp +++ b/external/Squirrel/Lib/sqstdrex.cpp @@ -153,6 +153,9 @@ static SQInteger sqstd_rex_charnode(SQRex *exp,SQBool isclass) exp->_nodes[node].right = ce; return node; } + case 0: + sqstd_rex_error(exp,_SC("letter expected for argument of escape sequence")); + break; case 'b': case 'B': if(!isclass) { diff --git a/external/Squirrel/Lib/sqstdstring.cpp b/external/Squirrel/Lib/sqstdstring.cpp index 6190edda..9e42dba4 100644 --- a/external/Squirrel/Lib/sqstdstring.cpp +++ b/external/Squirrel/Lib/sqstdstring.cpp @@ -89,7 +89,7 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen else { n++; if( nparam > sq_gettop(v) ) - return sq_throwerror(v,_SC("not enough paramters for the given format string")); + return sq_throwerror(v,_SC("not enough parameters for the given format string")); n = validate_format(v,fmt,format,n,w); if(n < 0) return -1; SQInteger addlen = 0; @@ -150,6 +150,19 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen return SQ_OK; } +static SQInteger _string_printf(HSQUIRRELVM v) +{ + SQChar *dest = NULL; + SQInteger length = 0; + if(SQ_FAILED(sqstd_format(v,2,&length,&dest))) + return -1; + + SQPRINTFUNCTION printfunc = sq_getprintfunc(v); + if(printfunc) printfunc(v,dest); + + return 0; +} + static SQInteger _string_format(HSQUIRRELVM v) { SQChar *dest = NULL; @@ -459,6 +472,7 @@ static const SQRegFunction rexobj_funcs[]={ #define _DECL_FUNC(name,nparams,pmask) {_SC(#name),_string_##name,nparams,pmask} static const SQRegFunction stringlib_funcs[]={ _DECL_FUNC(format,-2,_SC(".s")), + _DECL_FUNC(printf,-2,_SC(".s")), _DECL_FUNC(strip,2,_SC(".s")), _DECL_FUNC(lstrip,2,_SC(".s")), _DECL_FUNC(rstrip,2,_SC(".s")), diff --git a/external/Squirrel/sqapi.cpp b/external/Squirrel/sqapi.cpp index 56187b0f..c5a70d64 100644 --- a/external/Squirrel/sqapi.cpp +++ b/external/Squirrel/sqapi.cpp @@ -680,6 +680,15 @@ SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b) return SQ_ERROR; } +SQRESULT sq_getstringandsize(HSQUIRRELVM v,SQInteger idx,const SQChar **c,SQInteger *size) +{ + SQObjectPtr *o = NULL; + _GETSAFE_OBJ(v, idx, OT_STRING,o); + *c = _stringval(*o); + *size = _string(*o)->_len; + return SQ_OK; +} + SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c) { SQObjectPtr *o = NULL; @@ -1128,7 +1137,7 @@ SQRESULT sq_reservestack(HSQUIRRELVM v,SQInteger nsize) { if (((SQUnsignedInteger)v->_top + nsize) > v->_stack.size()) { if(v->_nmetamethodscall) { - return sq_throwerror(v,_SC("cannot resize stack while in a metamethod")); + return sq_throwerror(v,_SC("cannot resize stack while in a metamethod")); } v->_stack.resize(v->_stack.size() + ((v->_top + nsize) - v->_stack.size())); } @@ -1199,29 +1208,24 @@ SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool wakeupret,SQBool retval,SQBool raiseer void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook) { - if(sq_gettop(v) >= 1){ - SQObjectPtr &ud=stack_get(v,idx); - switch( type(ud) ) { - case OT_USERDATA: _userdata(ud)->_hook = hook; break; - case OT_INSTANCE: _instance(ud)->_hook = hook; break; - case OT_CLASS: _class(ud)->_hook = hook; break; - default: break; //shutup compiler - } + SQObjectPtr &ud=stack_get(v,idx); + switch( type(ud) ) { + case OT_USERDATA: _userdata(ud)->_hook = hook; break; + case OT_INSTANCE: _instance(ud)->_hook = hook; break; + case OT_CLASS: _class(ud)->_hook = hook; break; + default: return; } } SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQInteger idx) { - if(sq_gettop(v) >= 1){ - SQObjectPtr &ud=stack_get(v,idx); - switch( type(ud) ) { - case OT_USERDATA: return _userdata(ud)->_hook; break; - case OT_INSTANCE: return _instance(ud)->_hook; break; - case OT_CLASS: return _class(ud)->_hook; break; - default: break; //shutup compiler - } + SQObjectPtr &ud=stack_get(v,idx); + switch( type(ud) ) { + case OT_USERDATA: return _userdata(ud)->_hook; break; + case OT_INSTANCE: return _instance(ud)->_hook; break; + case OT_CLASS: return _class(ud)->_hook; break; + default: return NULL; } - return NULL; } void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f) diff --git a/external/Squirrel/sqbaselib.cpp b/external/Squirrel/sqbaselib.cpp index 71dfc26e..662aeac8 100644 --- a/external/Squirrel/sqbaselib.cpp +++ b/external/Squirrel/sqbaselib.cpp @@ -17,12 +17,13 @@ static bool str2num(const SQChar *s,SQObjectPtr &res,SQInteger base) { SQChar *end; const SQChar *e = s; - SQBool isfloat = SQFalse; + bool iseintbase = base > 13; //to fix error converting hexadecimals with e like 56f0791e + bool isfloat = false; SQChar c; while((c = *e) != _SC('\0')) { - if(c == _SC('.') || c == _SC('E')|| c == _SC('e')) { //e and E is for scientific notation - isfloat = SQTrue; + if (c == _SC('.') || (!iseintbase && (c == _SC('E') || c == _SC('e')))) { //e and E is for scientific notation + isfloat = true; break; } e++; diff --git a/external/Squirrel/sqlexer.cpp b/external/Squirrel/sqlexer.cpp index 88112104..51158ba5 100644 --- a/external/Squirrel/sqlexer.cpp +++ b/external/Squirrel/sqlexer.cpp @@ -389,7 +389,7 @@ SQInteger SQLexer::ReadString(SQInteger ndelim,bool verbatim) #if WCHAR_SIZE == 2 AddUTF16(scstrtoul(temp, &stemp, 16)); #else - ADD_CHAR((SQChar)scstrtoul(temp, &stemp, 16)); + APPEND_CHAR((SQChar)scstrtoul(temp, &stemp, 16)); #endif #else AddUTF8(scstrtoul(temp, &stemp, 16)); diff --git a/external/Squirrel/sqstate.cpp b/external/Squirrel/sqstate.cpp index c6a5cf7a..2711306d 100644 --- a/external/Squirrel/sqstate.cpp +++ b/external/Squirrel/sqstate.cpp @@ -12,12 +12,6 @@ #include "squserdata.h" #include "sqclass.h" -//SQObjectPtr _null_; -//SQObjectPtr _true_(true); -//SQObjectPtr _false_(false); -//SQObjectPtr _one_((SQInteger)1); -//SQObjectPtr _minusone_((SQInteger)-1); - SQSharedState::SQSharedState() { _compilererrorhandler = NULL; @@ -41,31 +35,29 @@ SQSharedState::SQSharedState() bool CompileTypemask(SQIntVec &res,const SQChar *typemask) { SQInteger i = 0; - SQInteger mask = 0; while(typemask[i] != 0) { - - switch(typemask[i]){ - case 'o': mask |= _RT_NULL; break; - case 'i': mask |= _RT_INTEGER; break; - case 'f': mask |= _RT_FLOAT; break; - case 'n': mask |= (_RT_FLOAT | _RT_INTEGER); break; - case 's': mask |= _RT_STRING; break; - case 't': mask |= _RT_TABLE; break; - case 'a': mask |= _RT_ARRAY; break; - case 'u': mask |= _RT_USERDATA; break; - case 'c': mask |= (_RT_CLOSURE | _RT_NATIVECLOSURE); break; - case 'b': mask |= _RT_BOOL; break; - case 'g': mask |= _RT_GENERATOR; break; - case 'p': mask |= _RT_USERPOINTER; break; - case 'v': mask |= _RT_THREAD; break; - case 'x': mask |= _RT_INSTANCE; break; - case 'y': mask |= _RT_CLASS; break; - case 'r': mask |= _RT_WEAKREF; break; - case '.': mask = -1; res.push_back(mask); i++; mask = 0; continue; - case ' ': i++; continue; //ignores spaces - default: - return false; + switch(typemask[i]) { + case 'o': mask |= _RT_NULL; break; + case 'i': mask |= _RT_INTEGER; break; + case 'f': mask |= _RT_FLOAT; break; + case 'n': mask |= (_RT_FLOAT | _RT_INTEGER); break; + case 's': mask |= _RT_STRING; break; + case 't': mask |= _RT_TABLE; break; + case 'a': mask |= _RT_ARRAY; break; + case 'u': mask |= _RT_USERDATA; break; + case 'c': mask |= (_RT_CLOSURE | _RT_NATIVECLOSURE); break; + case 'b': mask |= _RT_BOOL; break; + case 'g': mask |= _RT_GENERATOR; break; + case 'p': mask |= _RT_USERPOINTER; break; + case 'v': mask |= _RT_THREAD; break; + case 'x': mask |= _RT_INSTANCE; break; + case 'y': mask |= _RT_CLASS; break; + case 'r': mask |= _RT_WEAKREF; break; + case '.': mask = -1; res.push_back(mask); i++; mask = 0; continue; + case ' ': i++; continue; //ignores spaces + default: + return false; } i++; if(typemask[i] == '|') { @@ -160,7 +152,6 @@ void SQSharedState::Init() _class_default_delegate = CreateDefaultDelegate(this,_class_default_delegate_funcz); _instance_default_delegate = CreateDefaultDelegate(this,_instance_default_delegate_funcz); _weakref_default_delegate = CreateDefaultDelegate(this,_weakref_default_delegate_funcz); - } SQSharedState::~SQSharedState() @@ -282,7 +273,6 @@ SQInteger SQSharedState::ResurrectUnreachable(SQVM *vm) SQCollectable *resurrected = _gc_chain; SQCollectable *t = resurrected; - //SQCollectable *nx = NULL; _gc_chain = tchain; diff --git a/external/Squirrel/sqvm.cpp b/external/Squirrel/sqvm.cpp index 455f92b9..757f4382 100644 --- a/external/Squirrel/sqvm.cpp +++ b/external/Squirrel/sqvm.cpp @@ -15,6 +15,8 @@ #include "sqclass.h" #define TOP() (_stack._vals[_top-1]) +#define TARGET _stack._vals[_stackbase+arg0] +#define STK(a) _stack._vals[_stackbase+(a)] bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2) { @@ -301,7 +303,7 @@ bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) SQObjectPtr closure; if(_delegable(o)->GetMetaMethod(this, MT_TOSTRING, closure)) { Push(o); - if(CallMetaMethod(closure,MT_TOSTRING,1,res)) {; + if(CallMetaMethod(closure,MT_TOSTRING,1,res)) { if(type(res) == OT_STRING) return true; } @@ -1367,9 +1369,8 @@ SQInteger SQVM::FallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const return FALLBACK_OK; } else { + Pop(3); if(type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found) - //error - Pop(3); return FALLBACK_ERROR; } } @@ -1632,7 +1633,7 @@ bool SQVM::EnterFrame(SQInteger newbase, SQInteger newtop, bool tailcall) _top = newtop; if(newtop + MIN_STACK_OVERHEAD > (SQInteger)_stack.size()) { if(_nmetamethodscall) { - Raise_Error(_SC("stack overflow, cannot resize stack while in a metamethod")); + Raise_Error(_SC("stack overflow, cannot resize stack while in a metamethod")); return false; } _stack.resize(newtop + (MIN_STACK_OVERHEAD << 2)); diff --git a/external/Squirrel/sqvm.h b/external/Squirrel/sqvm.h index 2138fb30..35fef5bd 100644 --- a/external/Squirrel/sqvm.h +++ b/external/Squirrel/sqvm.h @@ -28,9 +28,6 @@ struct SQExceptionTrap{ #define _INLINE -#define STK(a) _stack._vals[_stackbase+(a)] -#define TARGET _stack._vals[_stackbase+arg0] - typedef sqvector ExceptionsTraps; struct SQVM : public CHAINABLE_OBJ diff --git a/include/sqrat/sqratObject.h b/include/sqrat/sqratObject.h index bf553df2..20f503cb 100644 --- a/include/sqrat/sqratObject.h +++ b/include/sqrat/sqratObject.h @@ -281,6 +281,44 @@ public: #endif } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Checks if the object has a slot with a specified key + /// + /// \param key Name of the key + /// + /// \return True if the Object has a value associated with key, otherwise false + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool HasKey(const SQChar* key) const { + sq_pushobject(vm, GetObject()); + sq_pushstring(vm, key, -1); + if (SQ_FAILED(sq_get(vm, -2))) { + sq_pop(vm, 1); + return false; + } + sq_pop(vm, 2); + return true; + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Checks if the object has a slot with a specified index + /// + /// \param index Index to check + /// + /// \return True if the Object has a value associated with index, otherwise false + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool HasKey(SQInteger index) const { + sq_pushobject(vm, GetObject()); + sq_pushinteger(vm, index); + if (SQ_FAILED(sq_get(vm, -2))) { + sq_pop(vm, 1); + return false; + } + sq_pop(vm, 2); + return true; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Casts the object to a certain C++ type /// diff --git a/include/sqstdio.h b/include/sqstdio.h index d19ec2ed..fbc74510 100644 --- a/include/sqstdio.h +++ b/include/sqstdio.h @@ -7,6 +7,7 @@ #define SQSTD_STREAM_TYPE_TAG 0x80000000 struct SQStream { + virtual ~SQStream() {} virtual SQInteger Read(void *buffer, SQInteger size) = 0; virtual SQInteger Write(void *buffer, SQInteger size) = 0; virtual SQInteger Flush() = 0; diff --git a/include/squirrel.h b/include/squirrel.h index e93bf5da..d41fd784 100644 --- a/include/squirrel.h +++ b/include/squirrel.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2014 Alberto Demichelis +Copyright (c) 2003-2016 Alberto Demichelis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -62,7 +62,7 @@ struct SQOuter; #include "sqconfig.h" #define SQUIRREL_VERSION _SC("Squirrel 3.1 stable") -#define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2015 Alberto Demichelis") +#define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2016 Alberto Demichelis") #define SQUIRREL_AUTHOR _SC("Alberto Demichelis") #define SQUIRREL_VERSION_NUMBER 310 @@ -195,6 +195,7 @@ typedef struct tagSQFunctionInfo { }SQFunctionInfo; #ifndef SQMOD_PLUGIN_API + /*vm*/ SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize); SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize); @@ -259,6 +260,7 @@ SQUIRREL_API SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQBool sq_instanceof(HSQUIRRELVM v); SQUIRREL_API SQRESULT sq_tostring(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b); +SQUIRREL_API SQRESULT sq_getstringandsize(HSQUIRRELVM v,SQInteger idx,const SQChar **c,SQInteger *size); SQUIRREL_API SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c); SQUIRREL_API SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i); SQUIRREL_API SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f); @@ -362,6 +364,7 @@ SQUIRREL_API void sq_free(void *p,SQUnsignedInteger size); SQUIRREL_API SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si); SQUIRREL_API void sq_setdebughook(HSQUIRRELVM v); SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook); + #endif // SQMOD_PLUGIN_API /*UTILITY MACRO*/ diff --git a/shared/SqAPI.h b/shared/SqAPI.h index f539ec5c..27174696 100644 --- a/shared/SqAPI.h +++ b/shared/SqAPI.h @@ -98,6 +98,7 @@ extern "C" { typedef SQBool (*sqapi_instanceof)(HSQUIRRELVM v); typedef SQRESULT (*sqapi_tostring)(HSQUIRRELVM v,SQInteger idx); typedef void (*sqapi_tobool)(HSQUIRRELVM v, SQInteger idx, SQBool *b); + typedef SQRESULT (*sqapi_getstringandsize)(HSQUIRRELVM v,SQInteger idx,const SQChar **c,SQInteger *size); typedef SQRESULT (*sqapi_getstring)(HSQUIRRELVM v,SQInteger idx,const SQChar **c); typedef SQRESULT (*sqapi_getinteger)(HSQUIRRELVM v,SQInteger idx,SQInteger *i); typedef SQRESULT (*sqapi_getfloat)(HSQUIRRELVM v,SQInteger idx,SQFloat *f); @@ -285,6 +286,7 @@ extern "C" { sqapi_instanceof instanceof; sqapi_tostring tostring; sqapi_tobool tobool; + sqapi_getstringandsize getstringandsize; sqapi_getstring getstring; sqapi_getinteger getinteger; sqapi_getfloat getfloat; @@ -406,184 +408,185 @@ extern "C" { #ifdef SQMOD_PLUGIN_API /*vm*/ - extern sqapi_open sq_open; - extern sqapi_newthread sq_newthread; - extern sqapi_seterrorhandler sq_seterrorhandler; - extern sqapi_close sq_close; - extern sqapi_setforeignptr sq_setforeignptr; - extern sqapi_getforeignptr sq_getforeignptr; - extern sqapi_setsharedforeignptr sq_setsharedforeignptr; - extern sqapi_getsharedforeignptr sq_getsharedforeignptr; - extern sqapi_setvmreleasehook sq_setvmreleasehook; - extern sqapi_getvmreleasehook sq_getvmreleasehook; - extern sqapi_setsharedreleasehook sq_setsharedreleasehook; - extern sqapi_getsharedreleasehook sq_getsharedreleasehook; - extern sqapi_setprintfunc sq_setprintfunc; - extern sqapi_getprintfunc sq_getprintfunc; - extern sqapi_geterrorfunc sq_geterrorfunc; - extern sqapi_suspendvm sq_suspendvm; - extern sqapi_wakeupvm sq_wakeupvm; - extern sqapi_getvmstate sq_getvmstate; - extern sqapi_getversion sq_getversion; + extern sqapi_open sq_open; + extern sqapi_newthread sq_newthread; + extern sqapi_seterrorhandler sq_seterrorhandler; + extern sqapi_close sq_close; + extern sqapi_setforeignptr sq_setforeignptr; + extern sqapi_getforeignptr sq_getforeignptr; + extern sqapi_setsharedforeignptr sq_setsharedforeignptr; + extern sqapi_getsharedforeignptr sq_getsharedforeignptr; + extern sqapi_setvmreleasehook sq_setvmreleasehook; + extern sqapi_getvmreleasehook sq_getvmreleasehook; + extern sqapi_setsharedreleasehook sq_setsharedreleasehook; + extern sqapi_getsharedreleasehook sq_getsharedreleasehook; + extern sqapi_setprintfunc sq_setprintfunc; + extern sqapi_getprintfunc sq_getprintfunc; + extern sqapi_geterrorfunc sq_geterrorfunc; + extern sqapi_suspendvm sq_suspendvm; + extern sqapi_wakeupvm sq_wakeupvm; + extern sqapi_getvmstate sq_getvmstate; + extern sqapi_getversion sq_getversion; /*compiler*/ - extern sqapi_compile sq_compile; - extern sqapi_compilebuffer sq_compilebuffer; - extern sqapi_enabledebuginfo sq_enabledebuginfo; - extern sqapi_notifyallexceptions sq_notifyallexceptions; - extern sqapi_setcompilererrorhandler sq_setcompilererrorhandler; + extern sqapi_compile sq_compile; + extern sqapi_compilebuffer sq_compilebuffer; + extern sqapi_enabledebuginfo sq_enabledebuginfo; + extern sqapi_notifyallexceptions sq_notifyallexceptions; + extern sqapi_setcompilererrorhandler sq_setcompilererrorhandler; /*stack operations*/ - extern sqapi_push sq_push; - extern sqapi_pop sq_pop; - extern sqapi_poptop sq_poptop; - extern sqapi_remove sq_remove; - extern sqapi_gettop sq_gettop; - extern sqapi_settop sq_settop; - extern sqapi_reservestack sq_reservestack; - extern sqapi_cmp sq_cmp; - extern sqapi_move sq_move; + extern sqapi_push sq_push; + extern sqapi_pop sq_pop; + extern sqapi_poptop sq_poptop; + extern sqapi_remove sq_remove; + extern sqapi_gettop sq_gettop; + extern sqapi_settop sq_settop; + extern sqapi_reservestack sq_reservestack; + extern sqapi_cmp sq_cmp; + extern sqapi_move sq_move; /*object creation handling*/ - extern sqapi_newuserdata sq_newuserdata; - extern sqapi_newtable sq_newtable; - extern sqapi_newtableex sq_newtableex; - extern sqapi_newarray sq_newarray; - extern sqapi_newclosure sq_newclosure; - extern sqapi_setparamscheck sq_setparamscheck; - extern sqapi_bindenv sq_bindenv; - extern sqapi_setclosureroot sq_setclosureroot; - extern sqapi_getclosureroot sq_getclosureroot; - extern sqapi_pushstring sq_pushstring; - extern sqapi_pushfloat sq_pushfloat; - extern sqapi_pushinteger sq_pushinteger; - extern sqapi_pushbool sq_pushbool; - extern sqapi_pushuserpointer sq_pushuserpointer; - extern sqapi_pushnull sq_pushnull; - extern sqapi_pushthread sq_pushthread; - extern sqapi_gettype sq_gettype; - extern sqapi_typeof sq_typeof; - extern sqapi_getsize sq_getsize; - extern sqapi_gethash sq_gethash; - extern sqapi_getbase sq_getbase; - extern sqapi_instanceof sq_instanceof; - extern sqapi_tostring sq_tostring; - extern sqapi_tobool sq_tobool; - extern sqapi_getstring sq_getstring; - extern sqapi_getinteger sq_getinteger; - extern sqapi_getfloat sq_getfloat; - extern sqapi_getbool sq_getbool; - extern sqapi_getthread sq_getthread; - extern sqapi_getuserpointer sq_getuserpointer; - extern sqapi_getuserdata sq_getuserdata; - extern sqapi_settypetag sq_settypetag; - extern sqapi_gettypetag sq_gettypetag; - extern sqapi_setreleasehook sq_setreleasehook; - extern sqapi_getreleasehook sq_getreleasehook; - extern sqapi_getscratchpad sq_getscratchpad; - extern sqapi_getfunctioninfo sq_getfunctioninfo; - extern sqapi_getclosureinfo sq_getclosureinfo; - extern sqapi_getclosurename sq_getclosurename; - extern sqapi_setnativeclosurename sq_setnativeclosurename; - extern sqapi_setinstanceup sq_setinstanceup; - extern sqapi_getinstanceup sq_getinstanceup; - extern sqapi_setclassudsize sq_setclassudsize; - extern sqapi_newclass sq_newclass; - extern sqapi_createinstance sq_createinstance; - extern sqapi_setattributes sq_setattributes; - extern sqapi_getattributes sq_getattributes; - extern sqapi_getclass sq_getclass; - extern sqapi_weakref sq_weakref; - extern sqapi_getdefaultdelegate sq_getdefaultdelegate; - extern sqapi_getmemberhandle sq_getmemberhandle; - extern sqapi_getbyhandle sq_getbyhandle; - extern sqapi_setbyhandle sq_setbyhandle; + extern sqapi_newuserdata sq_newuserdata; + extern sqapi_newtable sq_newtable; + extern sqapi_newtableex sq_newtableex; + extern sqapi_newarray sq_newarray; + extern sqapi_newclosure sq_newclosure; + extern sqapi_setparamscheck sq_setparamscheck; + extern sqapi_bindenv sq_bindenv; + extern sqapi_setclosureroot sq_setclosureroot; + extern sqapi_getclosureroot sq_getclosureroot; + extern sqapi_pushstring sq_pushstring; + extern sqapi_pushfloat sq_pushfloat; + extern sqapi_pushinteger sq_pushinteger; + extern sqapi_pushbool sq_pushbool; + extern sqapi_pushuserpointer sq_pushuserpointer; + extern sqapi_pushnull sq_pushnull; + extern sqapi_pushthread sq_pushthread; + extern sqapi_gettype sq_gettype; + extern sqapi_typeof sq_typeof; + extern sqapi_getsize sq_getsize; + extern sqapi_gethash sq_gethash; + extern sqapi_getbase sq_getbase; + extern sqapi_instanceof sq_instanceof; + extern sqapi_tostring sq_tostring; + extern sqapi_tobool sq_tobool; + extern sqapi_getstringandsize sq_getstringandsize; + extern sqapi_getstring sq_getstring; + extern sqapi_getinteger sq_getinteger; + extern sqapi_getfloat sq_getfloat; + extern sqapi_getbool sq_getbool; + extern sqapi_getthread sq_getthread; + extern sqapi_getuserpointer sq_getuserpointer; + extern sqapi_getuserdata sq_getuserdata; + extern sqapi_settypetag sq_settypetag; + extern sqapi_gettypetag sq_gettypetag; + extern sqapi_setreleasehook sq_setreleasehook; + extern sqapi_getreleasehook sq_getreleasehook; + extern sqapi_getscratchpad sq_getscratchpad; + extern sqapi_getfunctioninfo sq_getfunctioninfo; + extern sqapi_getclosureinfo sq_getclosureinfo; + extern sqapi_getclosurename sq_getclosurename; + extern sqapi_setnativeclosurename sq_setnativeclosurename; + extern sqapi_setinstanceup sq_setinstanceup; + extern sqapi_getinstanceup sq_getinstanceup; + extern sqapi_setclassudsize sq_setclassudsize; + extern sqapi_newclass sq_newclass; + extern sqapi_createinstance sq_createinstance; + extern sqapi_setattributes sq_setattributes; + extern sqapi_getattributes sq_getattributes; + extern sqapi_getclass sq_getclass; + extern sqapi_weakref sq_weakref; + extern sqapi_getdefaultdelegate sq_getdefaultdelegate; + extern sqapi_getmemberhandle sq_getmemberhandle; + extern sqapi_getbyhandle sq_getbyhandle; + extern sqapi_setbyhandle sq_setbyhandle; /*object manipulation*/ - extern sqapi_pushroottable sq_pushroottable; - extern sqapi_pushregistrytable sq_pushregistrytable; - extern sqapi_pushconsttable sq_pushconsttable; - extern sqapi_setroottable sq_setroottable; - extern sqapi_setconsttable sq_setconsttable; - extern sqapi_newslot sq_newslot; - extern sqapi_deleteslot sq_deleteslot; - extern sqapi_set sq_set; - extern sqapi_get sq_get; - extern sqapi_rawget sq_rawget; - extern sqapi_rawset sq_rawset; - extern sqapi_rawdeleteslot sq_rawdeleteslot; - extern sqapi_newmember sq_newmember; - extern sqapi_rawnewmember sq_rawnewmember; - extern sqapi_arrayappend sq_arrayappend; - extern sqapi_arraypop sq_arraypop; - extern sqapi_arrayresize sq_arrayresize; - extern sqapi_arrayreverse sq_arrayreverse; - extern sqapi_arrayremove sq_arrayremove; - extern sqapi_arrayinsert sq_arrayinsert; - extern sqapi_setdelegate sq_setdelegate; - extern sqapi_getdelegate sq_getdelegate; - extern sqapi_clone sq_clone; - extern sqapi_setfreevariable sq_setfreevariable; - extern sqapi_next sq_next; - extern sqapi_getweakrefval sq_getweakrefval; - extern sqapi_clear sq_clear; + extern sqapi_pushroottable sq_pushroottable; + extern sqapi_pushregistrytable sq_pushregistrytable; + extern sqapi_pushconsttable sq_pushconsttable; + extern sqapi_setroottable sq_setroottable; + extern sqapi_setconsttable sq_setconsttable; + extern sqapi_newslot sq_newslot; + extern sqapi_deleteslot sq_deleteslot; + extern sqapi_set sq_set; + extern sqapi_get sq_get; + extern sqapi_rawget sq_rawget; + extern sqapi_rawset sq_rawset; + extern sqapi_rawdeleteslot sq_rawdeleteslot; + extern sqapi_newmember sq_newmember; + extern sqapi_rawnewmember sq_rawnewmember; + extern sqapi_arrayappend sq_arrayappend; + extern sqapi_arraypop sq_arraypop; + extern sqapi_arrayresize sq_arrayresize; + extern sqapi_arrayreverse sq_arrayreverse; + extern sqapi_arrayremove sq_arrayremove; + extern sqapi_arrayinsert sq_arrayinsert; + extern sqapi_setdelegate sq_setdelegate; + extern sqapi_getdelegate sq_getdelegate; + extern sqapi_clone sq_clone; + extern sqapi_setfreevariable sq_setfreevariable; + extern sqapi_next sq_next; + extern sqapi_getweakrefval sq_getweakrefval; + extern sqapi_clear sq_clear; /*calls*/ - extern sqapi_call sq_call; - extern sqapi_resume sq_resume; - extern sqapi_getlocal sq_getlocal; - extern sqapi_getcallee sq_getcallee; - extern sqapi_getfreevariable sq_getfreevariable; - extern sqapi_throwerror sq_throwerror; - extern sqapi_throwobject sq_throwobject; - extern sqapi_reseterror sq_reseterror; - extern sqapi_getlasterror sq_getlasterror; + extern sqapi_call sq_call; + extern sqapi_resume sq_resume; + extern sqapi_getlocal sq_getlocal; + extern sqapi_getcallee sq_getcallee; + extern sqapi_getfreevariable sq_getfreevariable; + extern sqapi_throwerror sq_throwerror; + extern sqapi_throwobject sq_throwobject; + extern sqapi_reseterror sq_reseterror; + extern sqapi_getlasterror sq_getlasterror; /*raw object handling*/ - extern sqapi_getstackobj sq_getstackobj; - extern sqapi_pushobject sq_pushobject; - extern sqapi_addref sq_addref; - extern sqapi_release sq_release; - extern sqapi_getrefcount sq_getrefcount; - extern sqapi_resetobject sq_resetobject; - extern sqapi_objtostring sq_objtostring; - extern sqapi_objtobool sq_objtobool; - extern sqapi_objtointeger sq_objtointeger; - extern sqapi_objtofloat sq_objtofloat; - extern sqapi_objtouserpointer sq_objtouserpointer; - extern sqapi_getobjtypetag sq_getobjtypetag; - extern sqapi_getvmrefcount sq_getvmrefcount; + extern sqapi_getstackobj sq_getstackobj; + extern sqapi_pushobject sq_pushobject; + extern sqapi_addref sq_addref; + extern sqapi_release sq_release; + extern sqapi_getrefcount sq_getrefcount; + extern sqapi_resetobject sq_resetobject; + extern sqapi_objtostring sq_objtostring; + extern sqapi_objtobool sq_objtobool; + extern sqapi_objtointeger sq_objtointeger; + extern sqapi_objtofloat sq_objtofloat; + extern sqapi_objtouserpointer sq_objtouserpointer; + extern sqapi_getobjtypetag sq_getobjtypetag; + extern sqapi_getvmrefcount sq_getvmrefcount; /*GC*/ - extern sqapi_collectgarbage sq_collectgarbage; - extern sqapi_resurrectunreachable sq_resurrectunreachable; + extern sqapi_collectgarbage sq_collectgarbage; + extern sqapi_resurrectunreachable sq_resurrectunreachable; /*serialization*/ - extern sqapi_writeclosure sq_writeclosure; - extern sqapi_readclosure sq_readclosure; + extern sqapi_writeclosure sq_writeclosure; + extern sqapi_readclosure sq_readclosure; /*mem allocation*/ - extern sqapi_malloc sq_malloc; - extern sqapi_realloc sq_realloc; - extern sqapi_free sq_free; + extern sqapi_malloc sq_malloc; + extern sqapi_realloc sq_realloc; + extern sqapi_free sq_free; /*debug*/ - extern sqapi_stackinfos sq_stackinfos; - extern sqapi_setdebughook sq_setdebughook; - extern sqapi_setnativedebughook sq_setnativedebughook; + extern sqapi_stackinfos sq_stackinfos; + extern sqapi_setdebughook sq_setdebughook; + extern sqapi_setnativedebughook sq_setnativedebughook; /*compiler helpers*/ - extern sqapi_loadfile sqstd_loadfile; - extern sqapi_dofile sqstd_dofile; - extern sqapi_writeclosuretofile sqstd_writeclosuretofile; + extern sqapi_loadfile sqstd_loadfile; + extern sqapi_dofile sqstd_dofile; + extern sqapi_writeclosuretofile sqstd_writeclosuretofile; /*blob*/ - extern sqapi_createblob sqstd_createblob; - extern sqapi_getblob sqstd_getblob; - extern sqapi_getblobsize sqstd_getblobsize; + extern sqapi_createblob sqstd_createblob; + extern sqapi_getblob sqstd_getblob; + extern sqapi_getblobsize sqstd_getblobsize; /*string*/ - extern sqapi_format sqstd_format; + extern sqapi_format sqstd_format; #endif // SQMOD_PLUGIN_API diff --git a/shared/SqMod.inl b/shared/SqMod.inl index 58c6ada1..bc858f5c 100644 --- a/shared/SqMod.inl +++ b/shared/SqMod.inl @@ -65,6 +65,7 @@ sqapi_getbase sq_getbase = NULL; sqapi_instanceof sq_instanceof = NULL; sqapi_tostring sq_tostring = NULL; sqapi_tobool sq_tobool = NULL; +sqapi_getstringandsize sq_getstringandsize = NULL; sqapi_getstring sq_getstring = NULL; sqapi_getinteger sq_getinteger = NULL; sqapi_getfloat sq_getfloat = NULL; @@ -277,6 +278,7 @@ SQRESULT sq_api_expand(HSQAPI sqapi) sq_instanceof = sqapi->instanceof; sq_tostring = sqapi->tostring; sq_tobool = sqapi->tobool; + sq_getstringandsize = sqapi->getstringandsize; sq_getstring = sqapi->getstring; sq_getinteger = sqapi->getinteger; sq_getfloat = sqapi->getfloat; @@ -467,6 +469,7 @@ void sq_api_collapse() sq_instanceof = NULL; sq_tostring = NULL; sq_tobool = NULL; + sq_getstringandsize = NULL; sq_getstring = NULL; sq_getinteger = NULL; sq_getfloat = NULL; diff --git a/source/Exports.cpp b/source/Exports.cpp index 67607ef4..ee7c29cf 100644 --- a/source/Exports.cpp +++ b/source/Exports.cpp @@ -348,6 +348,7 @@ void InitExports() g_SqAPI.instanceof = sq_instanceof; g_SqAPI.tostring = sq_tostring; g_SqAPI.tobool = sq_tobool; + g_SqAPI.getstringandsize = sq_getstringandsize; g_SqAPI.getstring = sq_getstring; g_SqAPI.getinteger = sq_getinteger; g_SqAPI.getfloat = sq_getfloat;