mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Updated the Squirrel and Sqrat libraries to the latest development versions.
This commit is contained in:
parent
40a2ba46f5
commit
6822172f6a
@ -165,6 +165,7 @@
|
||||
<Add option="-fno-rtti" />
|
||||
<Add option="-fno-strict-aliasing" />
|
||||
<Add option="-Wno-unused-variable" />
|
||||
<Add option="-Wno-unused-but-set-variable" />
|
||||
<Add option="-DGARBAGE_COLLECTOR" />
|
||||
<Add directory="../include" />
|
||||
<Add directory="../config/common" />
|
||||
|
2
external/Squirrel/COPYRIGHT
vendored
2
external/Squirrel/COPYRIGHT
vendored
@ -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
|
||||
|
4
external/Squirrel/Lib/sqstdaux.cpp
vendored
4
external/Squirrel/Lib/sqstdaux.cpp
vendored
@ -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);
|
||||
}
|
||||
|
6
external/Squirrel/Lib/sqstdio.cpp
vendored
6
external/Squirrel/Lib/sqstdio.cpp
vendored
@ -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))) {
|
||||
|
3
external/Squirrel/Lib/sqstdrex.cpp
vendored
3
external/Squirrel/Lib/sqstdrex.cpp
vendored
@ -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) {
|
||||
|
16
external/Squirrel/Lib/sqstdstring.cpp
vendored
16
external/Squirrel/Lib/sqstdstring.cpp
vendored
@ -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")),
|
||||
|
18
external/Squirrel/sqapi.cpp
vendored
18
external/Squirrel/sqapi.cpp
vendored
@ -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;
|
||||
@ -1199,30 +1208,25 @@ 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
|
||||
}
|
||||
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
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f)
|
||||
{
|
||||
|
7
external/Squirrel/sqbaselib.cpp
vendored
7
external/Squirrel/sqbaselib.cpp
vendored
@ -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++;
|
||||
|
2
external/Squirrel/sqlexer.cpp
vendored
2
external/Squirrel/sqlexer.cpp
vendored
@ -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));
|
||||
|
10
external/Squirrel/sqstate.cpp
vendored
10
external/Squirrel/sqstate.cpp
vendored
@ -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,10 +35,8 @@ 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;
|
||||
@ -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;
|
||||
|
||||
|
7
external/Squirrel/sqvm.cpp
vendored
7
external/Squirrel/sqvm.cpp
vendored
@ -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 {
|
||||
if(type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
|
||||
//error
|
||||
Pop(3);
|
||||
if(type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
|
||||
return FALLBACK_ERROR;
|
||||
}
|
||||
}
|
||||
|
3
external/Squirrel/sqvm.h
vendored
3
external/Squirrel/sqvm.h
vendored
@ -28,9 +28,6 @@ struct SQExceptionTrap{
|
||||
|
||||
#define _INLINE
|
||||
|
||||
#define STK(a) _stack._vals[_stackbase+(a)]
|
||||
#define TARGET _stack._vals[_stackbase+arg0]
|
||||
|
||||
typedef sqvector<SQExceptionTrap> ExceptionsTraps;
|
||||
|
||||
struct SQVM : public CHAINABLE_OBJ
|
||||
|
@ -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
|
||||
///
|
||||
|
@ -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;
|
||||
|
@ -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*/
|
||||
|
@ -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;
|
||||
@ -469,6 +471,7 @@ extern "C" {
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user