Exemplo n.º 1
0
/**
 * Send a request to register a game to the server.
 *
 * @param data A JS array of game attributes
 */
void XmppClient::SendIqRegisterGame(ScriptInterface& scriptInterface, CScriptVal data)
{
	glooxwrapper::JID xpartamuppJid(m_xpartamuppId);
	jsval dataval = data.get();

	// Setup some base stanza attributes
	GameListQuery* g = new GameListQuery();
	g->m_Command = "register";
	glooxwrapper::Tag* game = glooxwrapper::Tag::allocate("game");
	// Add a fake ip which will be overwritten by the ip stamp XMPP module on the server.
	game->addAttribute("ip", "fake");

	// Iterate through all the properties reported and add them to the stanza.
	std::vector<std::string> properties;
	scriptInterface.EnumeratePropertyNamesWithPrefix(dataval, "", properties);
	for (std::vector<int>::size_type i = 0; i != properties.size(); i++)
	{
		std::wstring value;
		scriptInterface.GetProperty(dataval, properties[i].c_str(), value);
		game->addAttribute(properties[i], utf8_from_wstring(value));
	}

	// Push the stanza onto the IQ
	g->m_GameList.push_back(game);

	// Send IQ
	glooxwrapper::IQ iq(gloox::IQ::Set, xpartamuppJid);
	iq.addExtension(g);
	DbgXMPP("SendIqRegisterGame [" << tag_xml(iq) << "]");
	m_client->send(iq);
}
Exemplo n.º 2
0
/**
 * Send game report containing numerous game properties to the server.
 *
 * @param data A JS array of game statistics
 */
void XmppClient::SendIqGameReport(ScriptInterface& scriptInterface, CScriptVal data)
{
	glooxwrapper::JID xpartamuppJid(m_xpartamuppId);
	jsval dataval = data.get();

	// Setup some base stanza attributes
	GameReport* game = new GameReport();
	glooxwrapper::Tag* report = glooxwrapper::Tag::allocate("game");

	// Iterate through all the properties reported and add them to the stanza.
	std::vector<std::string> properties;
	scriptInterface.EnumeratePropertyNamesWithPrefix(dataval, "", properties);
	for (std::vector<int>::size_type i = 0; i != properties.size(); i++)
	{
		std::wstring value;
		scriptInterface.GetProperty(dataval, properties[i].c_str(), value);
		report->addAttribute(properties[i], utf8_from_wstring(value));
	}

	// Add stanza to IQ
	game->m_GameReport.push_back(report);

	// Send IQ
	glooxwrapper::IQ iq(gloox::IQ::Set, xpartamuppJid);
	iq.addExtension(game);
	DbgXMPP("SendGameReport [" << tag_xml(iq) << "]");
	m_client->send(iq);
};
Exemplo n.º 3
0
CBinarySerializerScriptImpl::CBinarySerializerScriptImpl(ScriptInterface& scriptInterface, ISerializer& serializer) :
	m_ScriptInterface(scriptInterface), m_Serializer(serializer), m_ScriptBackrefs(scriptInterface.GetRuntime()),
	m_SerializablePrototypes(new ObjectIdCache<std::wstring>(scriptInterface.GetRuntime())), m_ScriptBackrefsNext(1)
{
	m_ScriptBackrefs.init();
	m_SerializablePrototypes->init();
}
Exemplo n.º 4
0
void
Sector::try_expose(GameObject* object)
{
  ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
  if(interface != NULL) {
    HSQUIRRELVM vm = Scripting::global_vm;
    sq_pushobject(vm, sector_table);
    interface->expose(vm, -1);
    sq_pop(vm, 1);
  }
}
Exemplo n.º 5
0
	static std::vector<SimulationCommand> CloneCommandsFromOtherContext(ScriptInterface& oldScript, ScriptInterface& newScript,
		const std::vector<SimulationCommand>& commands)
	{
		std::vector<SimulationCommand> newCommands = commands;
		for (size_t i = 0; i < newCommands.size(); ++i)
		{
			newCommands[i].data = CScriptValRooted(newScript.GetContext(),
				newScript.CloneValueFromOtherContext(oldScript, newCommands[i].data.get()));
		}
		return newCommands;
	}
Exemplo n.º 6
0
int main(int argc, char* argv[])
{
  QCoreApplication app(argc, argv);
  QCoreApplication::setOrganizationName("SL Studios");
  QCoreApplication::setOrganizationDomain("SLStudios.org");
  QCoreApplication::setApplicationName("PortalCalibration");

  ScriptInterface scriptInterface;

  // Add our types
  scriptInterface.AddObject(scriptInterface, "Global");
  #ifdef USE_LIGHTCRAFTER_PROJECTOR
  scriptInterface.AddObjectType<LightCrafter>( "LightCrafterProjector" );
  #endif

  #ifdef USE_LIGHTCOMMANDER_PROJECTOR
  scriptInterface.AddObjectType<LightCommanderProjector>( "LightCommanderProjector" );
  #endif

  #ifdef  USE_QTFULLSCREEN
  scriptInterface.AddObjectType<QTFullscreen>("QTFullscreen");
  #endif
  
  scriptInterface.AddObjectType<CalibrationData>( "CalibrationData" );
  scriptInterface.AddObjectType<JSSerializer, QString>( "JSSerializer" );
  scriptInterface.AddObjectType<CalibrationEngine, int, int, float>( "CalibrationEngine" );
  
  // Add our camera types
  scriptInterface.AddObjectType<lens::OpenCVCamera>( "OpenCVCamera" );
  #ifdef USE_FILE_CAMERA
  scriptInterface.AddObjectType<lens::FileCamera>( "FileCamera" );
  #endif
  #ifdef USE_IC_CAMERA
  scriptInterface.AddObjectType<lens::ICCamera>( "ICCamera" );
  #endif
  #ifdef USE_JAI_CAMERA
  scriptInterface.AddObjectType<lens::JAICamera>( "JAICamera" );
  #endif
  #ifdef USE_POINT_GREY_CAMERA
  scriptInterface.AddObjectType<lens::PointGreyCamera>( "PointGreyCamera" );
  scriptInterface.AddObjectType<lens::PointGreyCamera, unsigned int>( "PointGreyCamera" );
  #endif
  #ifdef USE_PHANTOM_CAMERA
  scriptInterface.AddObjectType<lens::PhantomCamera>( "PhantomCamera" );
  #endif

  // Register types we want to pass around
  scriptInterface.RegisterMetaObjectType<CalibrationData>( );

  scriptInterface.RunScript("Calibrate.js");

  return 0;
}
Exemplo n.º 7
0
JS::Value CProfileViewer::SaveToJS(ScriptInterface& scriptInterface)
{
	JSContext* cx = scriptInterface.GetContext();
	JSAutoRequest rq(cx);
		
	JS::RootedValue root(cx);
	scriptInterface.Eval("({})", &root);

	std::vector<AbstractProfileTable*> tables = m->rootTables;
	sort(tables.begin(), tables.end(), SortByName);
	for_each(tables.begin(), tables.end(), DumpTable(scriptInterface, root));

	return root;
}
Exemplo n.º 8
0
JSBool JSI_GUIMouse::toString(JSContext* cx, uint argc, jsval* vp)
{
    UNUSED2(argc);

    i32 x, y, buttons;
    ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface;
    pScriptInterface->GetProperty(JS_THIS_VALUE(cx, vp), "x", x);
    pScriptInterface->GetProperty(JS_THIS_VALUE(cx, vp), "y", y);
    pScriptInterface->GetProperty(JS_THIS_VALUE(cx, vp), "buttons", buttons);

    char buffer[256];
    snprintf(buffer, 256, "%d %d %d", x, y, buttons);
    JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buffer)));
    return JS_TRUE;
}
Exemplo n.º 9
0
std::vector<CScriptValRooted> SavedGames::GetSavedGames(ScriptInterface& scriptInterface)
{
	TIMER(L"GetSavedGames");

	std::vector<CScriptValRooted> games;

	Status err;

	VfsPaths pathnames;
	err = vfs::GetPathnames(g_VFS, "saves/", L"*.0adsave", pathnames);
	WARN_IF_ERR(err);

	for (size_t i = 0; i < pathnames.size(); ++i)
	{
		OsPath realPath;
		err = g_VFS->GetRealPath(pathnames[i], realPath);
		if (err < 0)
		{
			DEBUG_WARN_ERR(err);
			continue; // skip this file
		}

		PIArchiveReader archiveReader = CreateArchiveReader_Zip(realPath);
		if (!archiveReader)
		{
			// Triggered by e.g. the file being open in another program
			LOGWARNING(L"Failed to read saved game '%ls'", realPath.string().c_str());
			continue; // skip this file
		}

		CScriptValRooted metadata;
		CGameLoader loader(scriptInterface, &metadata, NULL);
		err = archiveReader->ReadEntries(CGameLoader::ReadEntryCallback, (uintptr_t)&loader);
		if (err < 0)
		{
			DEBUG_WARN_ERR(err);
			continue; // skip this file
		}

		CScriptValRooted game;
		scriptInterface.Eval("({})", game);
		scriptInterface.SetProperty(game.get(), "id", pathnames[i].Basename());
		scriptInterface.SetProperty(game.get(), "metadata", metadata);
		games.push_back(game);
	}

	return games;
}
Exemplo n.º 10
0
JS::Value CMessage::ToJSValCached(ScriptInterface& scriptInterface) const
{
	if (!m_Cached)
		m_Cached.reset(new JS::PersistentRootedValue(scriptInterface.GetJSRuntime(), ToJSVal(scriptInterface)));

	return m_Cached->get();
}
Exemplo n.º 11
0
jsval CMessage::ToJSValCached(ScriptInterface& scriptInterface) const
{
	if (m_Cached.uninitialised())
		m_Cached = CScriptValRooted(scriptInterface.GetContext(), ToJSVal(scriptInterface));

	return m_Cached.get();
}
Exemplo n.º 12
0
void
Sector::try_unexpose(GameObject* object)
{
  ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
  if(interface != NULL) {
    HSQUIRRELVM vm = Scripting::global_vm;
    SQInteger oldtop = sq_gettop(vm);
    sq_pushobject(vm, sector_table);
    try {
      interface->unexpose(vm, -1);
    } catch(std::exception& e) {
      log_warning << "Couldn't unregister object: " << e.what() << std::endl;
    }
    sq_settop(vm, oldtop);
  }
}
Exemplo n.º 13
0
	static std::vector<SimulationCommand> CloneCommandsFromOtherContext(ScriptInterface& oldScript, ScriptInterface& newScript,
		const std::vector<SimulationCommand>& commands)
	{
		JSContext* cxOld = oldScript.GetContext();
		JSAutoRequest rqOld(cxOld);
		
		std::vector<SimulationCommand> newCommands;
		newCommands.reserve(commands.size());
		for (const SimulationCommand& command : commands)
		{
			JSContext* cxNew = newScript.GetContext();
			JSAutoRequest rqNew(cxNew);
			JS::RootedValue tmpCommand(cxNew, newScript.CloneValueFromOtherContext(oldScript, command.data));
			SimulationCommand cmd(command.player, cxNew, tmpCommand);
			newCommands.emplace_back(std::move(cmd));
		}
		return newCommands;
	}
Exemplo n.º 14
0
JS::Value ScriptInterface::CloneValueFromOtherContext(ScriptInterface& otherContext, JS::HandleValue val)
{
	PROFILE("CloneValueFromOtherContext");
	JSAutoRequest rq(m->m_cx);
	JS::RootedValue out(m->m_cx);
	shared_ptr<StructuredClone> structuredClone = otherContext.WriteStructuredClone(val);
	ReadStructuredClone(structuredClone, &out);
	return out.get();
}
Exemplo n.º 15
0
void CNetServer::UpdateGameAttributes(JS::MutableHandleValue attrs, ScriptInterface& scriptInterface)
{
	// Pass the attributes as JSON, since that's the easiest safe
	// cross-thread way of passing script data
	std::string attrsJSON = scriptInterface.StringifyJSON(attrs, false);

	CScopeLock lock(m_Worker->m_WorkerMutex);
	m_Worker->m_GameAttributesQueue.push_back(attrsJSON);
}
Exemplo n.º 16
0
/**
 * Handle requests from the GUI for the list of players.
 *
 * @return A JS array containing all known players and their presences
 */
CScriptValRooted XmppClient::GUIGetPlayerList(ScriptInterface& scriptInterface)
{
	std::string presence;
	CScriptValRooted playerList;
	scriptInterface.Eval("({})", playerList);
	for(std::map<std::string, gloox::Presence::PresenceType>::const_iterator it = m_PlayerMap.begin(); it != m_PlayerMap.end(); ++it)
	{
		CScriptValRooted player;
		GetPresenceString(it->second, presence);
		scriptInterface.Eval("({})", player);
		scriptInterface.SetProperty(player.get(), "name", wstring_from_utf8(it->first));
		scriptInterface.SetProperty(player.get(), "presence", wstring_from_utf8(presence));

		scriptInterface.SetProperty(playerList.get(), wstring_from_utf8(it->first).c_str(), player);
	}

	return playerList;
}
Exemplo n.º 17
0
	Ability::Ability(AbilityID id, const Name &name, const DescriptionText &desc, ScriptInterface &scriptIF)
		:m_scriptIF(scriptIF)
	{
		//Verify input parameters
		assert(id > 0);
		assert(name.length() > 0);
		assert(desc.length() > 0);

		m_ID = id;
		m_name.assign(name);
		m_description.assign(desc);

		char file[64], moduleName[64];
		sprintf(file, "data/scripts/afx/0x%03x.as", id);
		sprintf(moduleName, "afx:0x%03x", id);
		m_scriptModuleID = scriptIF.createModuleFromFile(Name(moduleName), Filename(file));
		m_scriptContextID = scriptIF.createContext();
	}
Exemplo n.º 18
0
/**
 * Handle requests from the GUI for leaderboard data.
 *
 * @return A JS array containing all known leaderboard data
 */
CScriptValRooted XmppClient::GUIGetBoardList(ScriptInterface& scriptInterface)
{
	CScriptValRooted boardList;
	scriptInterface.Eval("([])", boardList);
	for(std::vector<const glooxwrapper::Tag*>::const_iterator it = m_BoardList.begin(); it != m_BoardList.end(); ++it)
	{
		CScriptValRooted board;
		scriptInterface.Eval("({})", board);

		const char* attributes[] = { "name", "rank", "rating" };
		short attributes_length = 3;
		for (short i = 0; i < attributes_length; i++)
			scriptInterface.SetProperty(board.get(), attributes[i], wstring_from_utf8((*it)->findAttribute(attributes[i]).to_string()));

		scriptInterface.CallFunctionVoid(boardList.get(), "push", board);
	}

	return boardList;
}
Exemplo n.º 19
0
/**
 * Handle requests from the GUI for the list of all active games.
 *
 * @return A JS array containing all known games
 */
CScriptValRooted XmppClient::GUIGetGameList(ScriptInterface& scriptInterface)
{
	CScriptValRooted gameList;
	scriptInterface.Eval("([])", gameList);
	for(std::vector<const glooxwrapper::Tag*>::const_iterator it = m_GameList.begin(); it != m_GameList.end(); ++it)
	{
		CScriptValRooted game;
		scriptInterface.Eval("({})", game);

		const char* stats[] = { "name", "ip", "state", "nbp", "tnbp", "players", "mapName", "niceMapName", "mapSize", "mapType", "victoryCondition" };
		short stats_length = 11;
		for (short i = 0; i < stats_length; i++)
			scriptInterface.SetProperty(game.get(), stats[i], wstring_from_utf8((*it)->findAttribute(stats[i]).to_string()));

		scriptInterface.CallFunctionVoid(gameList.get(), "push", game);
	}

	return gameList;
}
Exemplo n.º 20
0
CScriptVal CProfileViewer::SaveToJS(ScriptInterface& scriptInterface)
{
    CScriptVal root;
    scriptInterface.Eval("({})", root);

    std::vector<AbstractProfileTable*> tables = m->rootTables;
    sort(tables.begin(), tables.end(), SortByName);
    for_each(tables.begin(), tables.end(), DumpTable(scriptInterface, root));

    return root;
}
Exemplo n.º 21
0
JSBool JSI_GUIColor::toString(JSContext* cx, uint argc, jsval* vp)
{
    UNUSED2(argc);

    double r, g, b, a;
    ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface;
    pScriptInterface->GetProperty(JS_THIS_VALUE(cx, vp), "r", r);
    pScriptInterface->GetProperty(JS_THIS_VALUE(cx, vp), "g", g);
    pScriptInterface->GetProperty(JS_THIS_VALUE(cx, vp), "b", b);
    pScriptInterface->GetProperty(JS_THIS_VALUE(cx, vp), "a", a);
    char buffer[256];
    // Convert to integers, to be compatible with the GUI's string SetSetting
    snprintf(buffer, 256, "%d %d %d %d",
             (int)(255.0 * r),
             (int)(255.0 * g),
             (int)(255.0 * b),
             (int)(255.0 * a));
    JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buffer)));
    return JS_TRUE;
}
Exemplo n.º 22
0
void ConvertCaches(ScriptInterface& scriptInterface, x86_x64::IdxCache idxCache, JS::MutableHandleValue ret)
{
	JSContext* cx = scriptInterface.GetContext();
	JSAutoRequest rq(cx);
	
	scriptInterface.Eval("[]", ret);
	for (size_t idxLevel = 0; idxLevel < x86_x64::Cache::maxLevels; ++idxLevel)
	{
		const x86_x64::Cache* pcache = x86_x64::Caches(idxCache+idxLevel);
		if (pcache->type == x86_x64::Cache::kNull || pcache->numEntries == 0)
			continue;
		JS::RootedValue cache(cx);
		scriptInterface.Eval("({})", &cache);
		scriptInterface.SetProperty(cache, "type", (u32)pcache->type);
		scriptInterface.SetProperty(cache, "level", (u32)pcache->level);
		scriptInterface.SetProperty(cache, "associativity", (u32)pcache->associativity);
		scriptInterface.SetProperty(cache, "linesize", (u32)pcache->entrySize);
		scriptInterface.SetProperty(cache, "sharedby", (u32)pcache->sharedBy);
		scriptInterface.SetProperty(cache, "totalsize", (u32)pcache->TotalSize());
		scriptInterface.SetPropertyInt(ret, idxLevel, cache);
	}
}
Exemplo n.º 23
0
CStdDeserializer::CStdDeserializer(ScriptInterface& scriptInterface, std::istream& stream) :
	m_ScriptInterface(scriptInterface), m_Stream(stream),
	m_dummyObject(scriptInterface.GetJSRuntime())
{
	JSContext* cx = m_ScriptInterface.GetContext();
	JSAutoRequest rq(cx);

	JS_AddExtraGCRootsTracer(m_ScriptInterface.GetJSRuntime(), CStdDeserializer::Trace, this);

	// Add a dummy tag because the serializer uses the tag 0 to indicate that a value
	// needs to be serialized and then tagged
	m_dummyObject = JS_NewPlainObject(cx);
	m_ScriptBackrefs.push_back(JS::Heap<JSObject*>(m_dummyObject));
}
Exemplo n.º 24
0
void ScriptTestSetup(ScriptInterface& ifc)
{
	ifc.RegisterFunction<void, std::wstring, script_TS_FAIL>("TS_FAIL");

	// Load the TS_* function definitions
	// (We don't use VFS because tests might not have the normal VFS paths loaded)
	OsPath path = DataDir()/"tests"/"test_setup.js";
	std::ifstream ifs(OsString(path).c_str());
	ENSURE(ifs.good());
	std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
	std::wstring wcontent(content.begin(), content.end());
	bool ok = ifc.LoadScript(L"test_setup.js", wcontent);
	ENSURE(ok);
}
Exemplo n.º 25
0
CScriptVal ConvertCaches(ScriptInterface& scriptInterface, x86_x64::IdxCache idxCache)
{
	CScriptVal ret;
	scriptInterface.Eval("[]", ret);
	for (size_t idxLevel = 0; idxLevel < x86_x64::Cache::maxLevels; ++idxLevel)
	{
		const x86_x64::Cache* pcache = x86_x64::Caches(idxCache+idxLevel);
		if (pcache->type == x86_x64::Cache::kNull || pcache->numEntries == 0)
			continue;
		CScriptVal cache;
		scriptInterface.Eval("({})", cache);
		scriptInterface.SetProperty(cache.get(), "type", (u32)pcache->type);
		scriptInterface.SetProperty(cache.get(), "level", (u32)pcache->level);
		scriptInterface.SetProperty(cache.get(), "associativity", (u32)pcache->associativity);
		scriptInterface.SetProperty(cache.get(), "linesize", (u32)pcache->entrySize);
		scriptInterface.SetProperty(cache.get(), "sharedby", (u32)pcache->sharedBy);
		scriptInterface.SetProperty(cache.get(), "totalsize", (u32)pcache->TotalSize());
		scriptInterface.SetPropertyInt(ret.get(), idxLevel, cache);
	}
	return ret;
}
Exemplo n.º 26
0
CComponentTypeScript::CComponentTypeScript(ScriptInterface& scriptInterface, JS::HandleValue instance) :
	m_ScriptInterface(scriptInterface), m_Instance(scriptInterface.GetJSRuntime(), instance)
{
	// Cache the property detection for efficiency
	JSContext* cx = m_ScriptInterface.GetContext();
	JSAutoRequest rq(cx);
	
	m_HasCustomSerialize = m_ScriptInterface.HasProperty(m_Instance, "Serialize");
	m_HasCustomDeserialize = m_ScriptInterface.HasProperty(m_Instance, "Deserialize");

	m_HasNullSerialize = false;
	if (m_HasCustomSerialize)
	{
		JS::RootedValue val(cx);
		if (m_ScriptInterface.GetProperty(m_Instance, "Serialize", &val) && val.isNull())
			m_HasNullSerialize = true;
	}
}
Exemplo n.º 27
0
void ConvertTLBs(ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
{
	JSContext* cx = scriptInterface.GetContext();
	JSAutoRequest rq(cx);
	
	scriptInterface.Eval("[]", ret);
	for(size_t i = 0; ; i++)
	{
		const x86_x64::Cache* ptlb = x86_x64::Caches(x86_x64::TLB+i);
		if (!ptlb)
			break;
		JS::RootedValue tlb(cx);
		scriptInterface.Eval("({})", &tlb);
		scriptInterface.SetProperty(tlb, "type", (u32)ptlb->type);
		scriptInterface.SetProperty(tlb, "level", (u32)ptlb->level);
		scriptInterface.SetProperty(tlb, "associativity", (u32)ptlb->associativity);
		scriptInterface.SetProperty(tlb, "pagesize", (u32)ptlb->entrySize);
		scriptInterface.SetProperty(tlb, "entries", (u32)ptlb->numEntries);
		scriptInterface.SetPropertyInt(ret, i, tlb);
	}
}
Exemplo n.º 28
0
/**
 * Handle requests from the GUI for the list of players.
 *
 * @return A JS array containing all known players and their presences
 */
CScriptValRooted XmppClient::GUIGetPlayerList(ScriptInterface& scriptInterface)
{
	CScriptValRooted playerList;
	scriptInterface.Eval("([])", playerList);

	// Convert the internal data structure to a Javascript object.
	for (std::map<std::string, std::vector<std::string> >::const_iterator it = m_PlayerMap.begin(); it != m_PlayerMap.end(); ++it)
	{
		CScriptValRooted player;
		scriptInterface.Eval("({})", player);
		scriptInterface.SetProperty(player.get(), "name", wstring_from_utf8(it->first));
		scriptInterface.SetProperty(player.get(), "presence", wstring_from_utf8(it->second[0]));
		scriptInterface.SetProperty(player.get(), "rating", wstring_from_utf8(it->second[1]));
		scriptInterface.SetProperty(player.get(), "role", wstring_from_utf8(it->second[2]));
		scriptInterface.CallFunctionVoid(playerList.get(), "push", player);
	}

	return playerList;
}
Exemplo n.º 29
0
CScriptVal ConvertTLBs(ScriptInterface& scriptInterface)
{
	CScriptVal ret;
	scriptInterface.Eval("[]", ret);
	for(size_t i = 0; ; i++)
	{
		const x86_x64::Cache* ptlb = x86_x64::Caches(x86_x64::TLB+i);
		if (!ptlb)
			break;
		CScriptVal tlb;
		scriptInterface.Eval("({})", tlb);
		scriptInterface.SetProperty(tlb.get(), "type", (u32)ptlb->type);
		scriptInterface.SetProperty(tlb.get(), "level", (u32)ptlb->level);
		scriptInterface.SetProperty(tlb.get(), "associativity", (u32)ptlb->associativity);
		scriptInterface.SetProperty(tlb.get(), "pagesize", (u32)ptlb->entrySize);
		scriptInterface.SetProperty(tlb.get(), "entries", (u32)ptlb->numEntries);
		scriptInterface.SetPropertyInt(ret.get(), i, tlb);
	}
	return ret;
}
Exemplo n.º 30
0
/**
 * Send GUI message queue when queried.
 */
CScriptValRooted XmppClient::GuiPollMessage(ScriptInterface& scriptInterface)
{
	if (m_GuiMessageQueue.empty())
		return CScriptValRooted();

	GUIMessage message = m_GuiMessageQueue.front();
	CScriptValRooted messageVal;

	scriptInterface.Eval("({})", messageVal);
	scriptInterface.SetProperty(messageVal.get(), "type", message.type);
	if (!message.from.empty())
		scriptInterface.SetProperty(messageVal.get(), "from", message.from);
	if (!message.text.empty())
		scriptInterface.SetProperty(messageVal.get(), "text", message.text);
	if (!message.level.empty())
		scriptInterface.SetProperty(messageVal.get(), "level", message.level);
	if (!message.message.empty())
		scriptInterface.SetProperty(messageVal.get(), "message", message.message);
	if (!message.data.empty())
		scriptInterface.SetProperty(messageVal.get(), "data", message.data);
	
	m_GuiMessageQueue.pop_front();
	return messageVal;
}