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();
}
bool SQDbgServer::Init()
{
	//creates  an environment table for the debugger
	
	sq_newtable(_v);
	sq_getstackobj(_v,-1,&_debugroot);
	sq_addref(_v,&_debugroot);

	//creates a emptyslot to store the watches
	sq_pushstring(_v,_SC("watches"),-1);
	sq_pushnull(_v);
	sq_createslot(_v,-3);

	sq_pushstring(_v,_SC("beginelement"),-1);
	sq_pushuserpointer(_v,this);
	sq_newclosure(_v,beginelement,1);
	sq_setparamscheck(_v,2,_SC(".s"));
	sq_createslot(_v,-3);

	sq_pushstring(_v,_SC("endelement"),-1);
	sq_pushuserpointer(_v,this);
	sq_newclosure(_v,endelement,1);
	sq_setparamscheck(_v,2,_SC(".s"));
	sq_createslot(_v,-3);

	sq_pushstring(_v,_SC("attribute"),-1);
	sq_pushuserpointer(_v,this);
	sq_newclosure(_v,attribute,1);
	sq_setparamscheck(_v,3,_SC(".ss"));
	sq_createslot(_v,-3);

	sq_pop(_v,1);

	//stores debug hook and error handler in the registry
	sq_pushregistrytable(_v);

	sq_pushstring(_v,SQDBG_DEBUG_HOOK,-1);
	sq_pushuserpointer(_v,this);
	sq_newclosure(_v,debug_hook,1);
	sq_createslot(_v,-3);
	
	sq_pushstring(_v,SQDBG_ERROR_HANDLER,-1);
	sq_pushuserpointer(_v,this);
	sq_newclosure(_v,error_handler,1);
	sq_createslot(_v,-3);

	
	sq_pop(_v,1);

	//sets the error handlers
	SetErrorHandlers();
	return true;
}
Esempio n. 3
0
void SQDbgServer::SerializeState(HSQUIRRELVM v)
{
    sq_pushnull(v);
    sq_setdebughook(v);
    sq_pushnull(v);
    sq_seterrorhandler(v);
    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(), (SQInteger) i->_exp.length());
        sq_createslot(v, -3);
    }
    sq_rawset(v, -3);
    if (SQ_SUCCEEDED(sq_call(v, 1, SQTrue, SQFalse))) {
        //if(SQ_SUCCEEDED(sqstd_getblob(v,-1,(SQUserPointer*)&sz)))
        //SendChunk(sz);
    }
    sq_pop(v, 2);

    SetErrorHandlers(v);
}