Exemplo n.º 1
0
void SQDbgServer::SerializeState()
{
	sq_pushnull(_v);
	sq_setdebughook(_v);
	sq_pushnull(_v);
	sq_seterrorhandler(_v);
	const SQChar *sz;
	sq_pushobject(_v,_serializefunc);
	sq_pushobject(_v,_debugroot);
	sq_pushstring(_v,_SC("watches"),-1);
	sq_newtable(_v);
	for(WatchSetItor i=_watches.begin(); i!=_watches.end(); ++i)
	{
		sq_pushinteger(_v,i->_id);
		sq_pushstring(_v,i->_exp.c_str(),(int)i->_exp.length());
		sq_createslot(_v,-3);
	}
	sq_rawset(_v,-3);
	if(SQ_SUCCEEDED(sq_call(_v,1,SQTrue,SQTrue))){
		if(SQ_SUCCEEDED(sqstd_getblob(_v,-1,(SQUserPointer*)&sz)))
			SendChunk(sz);
	}
	sq_pop(_v,2);
	
	SetErrorHandlers();
}
Exemplo n.º 2
0
SQInteger _stream_writeblob(HSQUIRRELVM v)
{
    SQUserPointer data;
    SQInteger size;
    SETUP_STREAM(v);
    if(SQ_FAILED(sqstd_getblob(v,2,&data)))
        return sq_throwerror(v,_SC("invalid parameter"));
    size = sqstd_getblobsize(v,2);
    if(self->Write(data,size) != size)
        return sq_throwerror(v,_SC("io error"));
    sq_pushinteger(v,size);
    return 1;
}
Exemplo n.º 3
0
static SQInteger sq_func__call(HSQUIRRELVM v)
{
    FFIFunc *ffibuf;
    sq_getuserdata(v, 1, (void**)&ffibuf, NULL);
    int top = sq_gettop(v);
//    printf("ffibuf %p top %d\n", ffibuf, top);

    if (ffibuf->cif.nargs != ((unsigned)(top - EXTRA_PARAMS)))
        return sq_throwerror(v, "Wrong number of args");

    SQInteger values[top - EXTRA_PARAMS];
    void *valueptrs[top - EXTRA_PARAMS];
    int i;
    for (i = EXTRA_PARAMS + 1; i <= top; i++) {
        #define pi (i - (EXTRA_PARAMS + 1))
        switch (sq_gettype(v, i)) {
        case OT_INTEGER:
            sq_getinteger(v, i, (SQInteger*)&values[pi]);
            break;
        case OT_STRING:
            sq_getstring(v, i, (const char**)&values[pi]);
            break;
        case OT_INSTANCE: {
            if (SQ_FAILED(sqstd_getblob(v, i, (SQUserPointer*)&values[pi])))
                return SQ_ERROR;
            break;
        }
        default:
            return sq_throwerror(v, "Unimplemented type");
        }
        valueptrs[pi] = &values[pi];
    }

    ptrdiff_t rc;
//    printf("Before call, %p\n", ffibuf->func);
    ffi_call(&ffibuf->cif, (void(*)())ffibuf->func, &rc, valueptrs);
    return_ffi_value(v, rc, ffibuf->rettype);
    return 1;
}