sq_getstring( v, 2, &pattern ); SQRex *rex = sqstd_rex_compile( pattern, &error ); if ( !rex ) return sq_throwerror( v, error ); sq_setinstanceup( v, 1, rex ); sq_setreleasehook( v, 1, _rexobj_releasehook ); return 0; } static SQInteger _regexp__typeof( HSQUIRRELVM v ) { sq_pushstring( v, _SC( "regexp" ), -1 ); return 1; } #define _DECL_REX_FUNC(name,nparams,pmask) {_SC(#name),_regexp_##name,nparams,pmask} static SQRegFunction rexobj_funcs[] = { _DECL_REX_FUNC( constructor, 2, _SC( ".s" ) ), _DECL_REX_FUNC( search, -2, _SC( "xsn" ) ), _DECL_REX_FUNC( match, 2, _SC( "xs" ) ), _DECL_REX_FUNC( capture, -2, _SC( "xsn" ) ), _DECL_REX_FUNC( subexpcount, 1, _SC( "x" ) ), _DECL_REX_FUNC( _typeof, 1, _SC( "x" ) ), {0, 0} }; #define _DECL_FUNC(name,nparams,pmask) {_SC(#name),_string_##name,nparams,pmask} static SQRegFunction stringlib_funcs[] = { _DECL_FUNC( format, -2, _SC( ".s" ) ), {0, 0} };
return 1; } static SQInteger _regexp_help(HSQUIRRELVM v) { SQPRINTFUNCTION pf = sq_getprintfunc(v); pf(v, _SC("%s"), _SC("*** DEPRECATED - USE nit.RegExp instead! ***")); sq_pushbool(v, SQTrue); return 1; } #define _DECL_REX_FUNC(name,nparams,pmask,help) {_SC(#name),_regexp_##name,nparams,pmask,__FILE__,_SC(help)} static SQRegFunction rexobj_funcs[]={ _DECL_REX_FUNC(constructor,2,_SC(".s"), "(pattern: string): regex"), _DECL_REX_FUNC(search,-2,_SC("xsn"), "(string, [start: int]): {begin=?, end=?}"), _DECL_REX_FUNC(match,2,_SC("xs"), "(string): bool"), _DECL_REX_FUNC(capture,-2,_SC("xsn"), "(string, [start: int]): array of { begin=?, end=? }"), _DECL_REX_FUNC(subexpcount,1,_SC("x"), "(): int"), _DECL_REX_FUNC(_typeof,1,_SC("x"), NULL), _DECL_REX_FUNC(help,1,_SC("."), NULL), {0,0} }; #define _DECL_FUNC(name,nparams,pmask,help) {_SC(#name),_string_##name,nparams,pmask,__FILE__,_SC(help)} static SQRegFunction stringlib_funcs[]={ _DECL_FUNC(format,-2,_SC(".s"), "(fmt: string, ...): string"), {0,0} };