add SQPString and sq_getpstring() - an easy way to retrieve strings along with their size, to avoid useless strlens later. it's named PString to suggest that it's like a pascal-style PSTring, prefixed with the length--that's basically what it is.
This commit is contained in:
parent
16ab1fd6c0
commit
656c6a0d68
@ -156,6 +156,12 @@ typedef struct tagSQObject
|
||||
SQObjectValue _unVal;
|
||||
}SQObject;
|
||||
|
||||
typedef struct tagSQPString
|
||||
{
|
||||
SQInteger len;
|
||||
SQChar* str;
|
||||
} SQPString;
|
||||
|
||||
typedef struct tagSQMemberHandle{
|
||||
SQBool _static;
|
||||
SQInteger _index;
|
||||
@ -259,6 +265,7 @@ 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_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c);
|
||||
SQUIRREL_API SQRESULT sq_getpstring(HSQUIRRELVM v,SQInteger idx,SQPString *pstr);
|
||||
SQUIRREL_API SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i);
|
||||
SQUIRREL_API SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f);
|
||||
SQUIRREL_API SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b);
|
||||
|
@ -680,6 +680,15 @@ SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b)
|
||||
return SQ_ERROR;
|
||||
}
|
||||
|
||||
SQRESULT sq_getpstring(HSQUIRRELVM v,SQInteger idx,SQPString *pstr)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
_GETSAFE_OBJ(v, idx, OT_STRING,o);
|
||||
pstr->len = _stringlen(*o);
|
||||
pstr->str = _stringval(*o);
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user