Merge pull request #38 from zeromus/master
releasehook APIs and docs fixes
This commit is contained in:
commit
35ab252494
@ -57,7 +57,7 @@ Global Symbols
|
|||||||
|
|
||||||
.. js:function:: startswith(str, cmp)
|
.. js:function:: startswith(str, cmp)
|
||||||
|
|
||||||
returns `true` if the beginning of the string `str` matches a the string `cmp` otherwise returns `false`
|
returns `true` if the beginning of the string `str` matches the string `cmp`; otherwise returns `false`
|
||||||
|
|
||||||
.. js:function:: strip(str)
|
.. js:function:: strip(str)
|
||||||
|
|
||||||
@ -162,13 +162,13 @@ The regexp class
|
|||||||
|
|
||||||
.. js:function:: regexp.capture(str [, start])
|
.. js:function:: regexp.capture(str [, start])
|
||||||
|
|
||||||
returns an array of tables containing two indexs("begin" and "end")of
|
returns an array of tables containing two indexes ("begin" and "end") of
|
||||||
the first match of the regular expression in the string `str`.
|
the first match of the regular expression in the string `str`.
|
||||||
An array entry is created for each captured sub expressions. If no match occurs returns null.
|
An array entry is created for each captured sub expressions. If no match occurs returns null.
|
||||||
The search starts from the index `start`
|
The search starts from the index `start`
|
||||||
of the string, if `start` is omitted the search starts from the beginning of the string.
|
of the string; if `start` is omitted the search starts from the beginning of the string.
|
||||||
|
|
||||||
the first element of the returned array(index 0) always contains the complete match.
|
The first element of the returned array(index 0) always contains the complete match.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ The regexp class
|
|||||||
|
|
||||||
returns a table containing two indexes ("begin" and "end") of the first match of the regular expression in
|
returns a table containing two indexes ("begin" and "end") of the first match of the regular expression in
|
||||||
the string `str`, otherwise if no match occurs returns null. The search starts from the index `start`
|
the string `str`, otherwise if no match occurs returns null. The search starts from the index `start`
|
||||||
of the string, if `start` is omitted the search starts from the beginning of the string.
|
of the string; if `start` is omitted the search starts from the beginning of the string.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ Regular Expessions
|
|||||||
|
|
||||||
searches the first match of the expression in the string delimited
|
searches the first match of the expression in the string delimited
|
||||||
by the parameter text_begin and text_end.
|
by the parameter text_begin and text_end.
|
||||||
if the match is found returns SQTrue and the sets out_begin to the beginning of the
|
if the match is found returns SQTrue and sets out_begin to the beginning of the
|
||||||
match and out_end at the end of the match; otherwise returns SQFalse.
|
match and out_end at the end of the match; otherwise returns SQFalse.
|
||||||
|
|
||||||
.. c:function:: SQInteger sqstd_rex_getsubexpcount(SQRex * exp)
|
.. c:function:: SQInteger sqstd_rex_getsubexpcount(SQRex * exp)
|
||||||
@ -305,7 +305,7 @@ Regular Expessions
|
|||||||
:param SQRex* exp: a compiled expression
|
:param SQRex* exp: a compiled expression
|
||||||
:param SQInteger n: the index of the submatch(0 is the complete match)
|
:param SQInteger n: the index of the submatch(0 is the complete match)
|
||||||
:param SQRexMatch* a: pointer to structure that will store the result
|
:param SQRexMatch* a: pointer to structure that will store the result
|
||||||
:returns: the function returns SQTrue if n is valid index otherwise SQFalse.
|
:returns: the function returns SQTrue if n is a valid index; otherwise SQFalse.
|
||||||
|
|
||||||
retrieve the begin and and pointer to the length of the sub expression indexed
|
retrieve the begin and and pointer to the length of the sub expression indexed
|
||||||
by n. The result is passed through the struct SQRexMatch.
|
by n. The result is passed through the struct SQRexMatch.
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#define SQSTD_STREAM_TYPE_TAG 0x80000000
|
#define SQSTD_STREAM_TYPE_TAG 0x80000000
|
||||||
|
|
||||||
struct SQStream {
|
struct SQStream {
|
||||||
|
virtual ~SQStream() {}
|
||||||
virtual SQInteger Read(void *buffer, SQInteger size) = 0;
|
virtual SQInteger Read(void *buffer, SQInteger size) = 0;
|
||||||
virtual SQInteger Write(void *buffer, SQInteger size) = 0;
|
virtual SQInteger Write(void *buffer, SQInteger size) = 0;
|
||||||
virtual SQInteger Flush() = 0;
|
virtual SQInteger Flush() = 0;
|
||||||
|
@ -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)
|
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))) {
|
if(SQ_SUCCEEDED(sqstd_loadfile(v,filename,printerror))) {
|
||||||
sq_push(v,-2);
|
sq_push(v,-2);
|
||||||
if(SQ_SUCCEEDED(sq_call(v,1,retval,SQTrue))) {
|
if(SQ_SUCCEEDED(sq_call(v,1,retval,SQTrue))) {
|
||||||
|
@ -1199,30 +1199,25 @@ SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool wakeupret,SQBool retval,SQBool raiseer
|
|||||||
|
|
||||||
void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook)
|
void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook)
|
||||||
{
|
{
|
||||||
if(sq_gettop(v) >= 1){
|
|
||||||
SQObjectPtr &ud=stack_get(v,idx);
|
SQObjectPtr &ud=stack_get(v,idx);
|
||||||
switch( type(ud) ) {
|
switch( type(ud) ) {
|
||||||
case OT_USERDATA: _userdata(ud)->_hook = hook; break;
|
case OT_USERDATA: _userdata(ud)->_hook = hook; break;
|
||||||
case OT_INSTANCE: _instance(ud)->_hook = hook; break;
|
case OT_INSTANCE: _instance(ud)->_hook = hook; break;
|
||||||
case OT_CLASS: _class(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)
|
SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQInteger idx)
|
||||||
{
|
{
|
||||||
if(sq_gettop(v) >= 1){
|
|
||||||
SQObjectPtr &ud=stack_get(v,idx);
|
SQObjectPtr &ud=stack_get(v,idx);
|
||||||
switch( type(ud) ) {
|
switch( type(ud) ) {
|
||||||
case OT_USERDATA: return _userdata(ud)->_hook; break;
|
case OT_USERDATA: return _userdata(ud)->_hook; break;
|
||||||
case OT_INSTANCE: return _instance(ud)->_hook; break;
|
case OT_INSTANCE: return _instance(ud)->_hook; break;
|
||||||
case OT_CLASS: return _class(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)
|
void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user