7 #include "sqstdstream.h" 8 #include "sqstdblobimpl.h" 10 #define SQSTD_BLOB_TYPE_TAG (SQSTD_STREAM_TYPE_TAG | 0x00000002) 15 #define SETUP_BLOB(v) \ 16 SQBlob *self = NULL; \ 17 { if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_BLOB_TYPE_TAG))) \ 26 if(!self->Resize(size))
33 *n=(
unsigned int)(((*n&0xFF000000)>>24) |
34 ((*n&0x00FF0000)>>8) |
35 ((*n&0x0000FF00)<<8) |
36 ((*n&0x000000FF)<<24));
41 *n=(
unsigned short)((*n>>8)&0x00FF)| ((*n<<8)&0xFF00);
47 SQInteger num=(
self->Len()-(
self->Len()%4))>>2;
48 unsigned int *t=(
unsigned int *)self->GetBuf();
49 for(SQInteger i = 0; i < num; i++) {
58 SQInteger num=(
self->Len()-(
self->Len()%2))>>1;
59 unsigned short *t = (
unsigned short *)self->GetBuf();
60 for(SQInteger i = 0; i < num; i++) {
72 if(idx < 0 || idx >= self->Len())
74 ((
unsigned char *)self->GetBuf())[idx] = (
unsigned char) val;
84 if(idx < 0 || idx >= self->Len())
99 if(idx+1 < self->Len()) {
106 return sq_throwerror(v,_SC(
"internal error (_nexti) wrong argument type"));
118 SQBlob *
self = (SQBlob*)p;
130 if(size < 0)
return sq_throwerror(v, _SC(
"cannot create blob with negative size"));
131 SQBlob *b =
new SQBlob(size);
134 return sq_throwerror(v, _SC(
"cannot create blob with negative size"));
140 #define _DECL_BLOB_FUNC(name,nparams,typecheck) {_SC(#name),_blob_##name,nparams,typecheck} 186 unsigned int t4 = (
unsigned int)i;
201 #define _DECL_GLOBALBLOB_FUNC(name,nparams,typecheck) {_SC(#name),_g_blob_##name,nparams,typecheck} 216 *ptr = blob->GetBuf();
233 if(SQ_SUCCEEDED(
sq_get(v,-2))) {
238 if(SQ_SUCCEEDED(
sq_call(v,2,SQTrue,SQFalse))
241 return blob->GetBuf();
SQRESULT sq_get(HSQUIRRELVM v, SQInteger idx)
static SQInteger _g_blob_castf2i(HSQUIRRELVM v)
static SQInteger _blob__get(HSQUIRRELVM v)
SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p, SQUserPointer typetag)
#define SQSTD_BLOB_TYPE_TAG
static SQInteger _g_blob_swap2(HSQUIRRELVM v)
static SQInteger _g_blob_swapfloat(HSQUIRRELVM v)
SQRESULT sq_throwerror(HSQUIRRELVM v, const SQChar *err)
SQUserPointer sqstd_createblob(HSQUIRRELVM v, SQInteger size)
void sq_pushnull(HSQUIRRELVM v)
#define _DECL_BLOB_FUNC(name, nparams, typecheck)
void sq_pushregistrytable(HSQUIRRELVM v)
void sq_pushfloat(HSQUIRRELVM v, SQFloat n)
SQRESULT sq_getinteger(HSQUIRRELVM v, SQInteger idx, SQInteger *i)
static SQInteger _blob__nexti(HSQUIRRELVM v)
static SQInteger _blob_constructor(HSQUIRRELVM v)
SQInteger sq_gettop(HSQUIRRELVM v)
void sq_pushinteger(HSQUIRRELVM v, SQInteger n)
SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror)
void sq_push(HSQUIRRELVM v, SQInteger idx)
void sq_settop(HSQUIRRELVM v, SQInteger newtop)
SQRESULT sq_getfloat(HSQUIRRELVM v, SQInteger idx, SQFloat *f)
static SQInteger _blob__typeof(HSQUIRRELVM v)
static SQInteger _blob_swap2(HSQUIRRELVM v)
void sq_remove(HSQUIRRELVM v, SQInteger idx)
static SQRegFunction _blob_methods[]
SQInteger sqstd_getblobsize(HSQUIRRELVM v, SQInteger idx)
void sq_pushstring(HSQUIRRELVM v, const SQChar *s, SQInteger len)
SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
static void __swap_word(unsigned short *n)
SQObjectType sq_gettype(HSQUIRRELVM v, SQInteger idx)
static SQInteger _blob_swap4(HSQUIRRELVM v)
SQRESULT sqstd_getblob(HSQUIRRELVM v, SQInteger idx, SQUserPointer *ptr)
SQRESULT declare_stream(HSQUIRRELVM v, const SQChar *name, SQUserPointer typetag, const SQChar *reg_name, SQRegFunction *methods, SQRegFunction *globals)
static SQInteger _blob__set(HSQUIRRELVM v)
static SQInteger _g_blob_swap4(HSQUIRRELVM v)
const wxString ptr(_T("*"))
static SQRegFunction bloblib_funcs[]
static void __swap_dword(unsigned int *n)
#define _DECL_GLOBALBLOB_FUNC(name, nparams, typecheck)
void sq_setreleasehook(HSQUIRRELVM v, SQInteger idx, SQRELEASEHOOK hook)
static SQInteger _blob_resize(HSQUIRRELVM v)
SQRESULT sqstd_register_bloblib(HSQUIRRELVM v)
static SQInteger _g_blob_casti2f(HSQUIRRELVM v)
static SQInteger _blob_releasehook(SQUserPointer p, SQInteger)