Pass ScriptInterface as a const ref where possible.
Reviewed By: elexis Differential Revision: https://code.wildfiregames.com/D739 This was SVN commit r20028.
This commit is contained in:
parent
7970c3dc54
commit
9defd11440
@ -373,7 +373,7 @@ PSRETURN CMapSummaryReader::LoadMap(const VfsPath& pathname)
|
|||||||
return PSRETURN_OK;
|
return PSRETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapSummaryReader::GetMapSettings(ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
void CMapSummaryReader::GetMapSettings(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2016 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -176,7 +176,7 @@ public:
|
|||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
void GetMapSettings(ScriptInterface& scriptInterface, JS::MutableHandleValue);
|
void GetMapSettings(const ScriptInterface& scriptInterface, JS::MutableHandleValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CStr m_ScriptSettings;
|
CStr m_ScriptSettings;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -57,7 +57,7 @@ IMPLEMENT_BOOLEAN_SCRIPT_SETTING(ConstrainCamera);
|
|||||||
scriptInterface.RegisterFunction<bool, &JSI_GameView::Get##NAME##Enabled>("GameView_Get" #NAME "Enabled"); \
|
scriptInterface.RegisterFunction<bool, &JSI_GameView::Get##NAME##Enabled>("GameView_Get" #NAME "Enabled"); \
|
||||||
scriptInterface.RegisterFunction<void, bool, &JSI_GameView::Set##NAME##Enabled>("GameView_Set" #NAME "Enabled");
|
scriptInterface.RegisterFunction<void, bool, &JSI_GameView::Set##NAME##Enabled>("GameView_Set" #NAME "Enabled");
|
||||||
|
|
||||||
void JSI_GameView::RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
void JSI_GameView::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
REGISTER_BOOLEAN_SCRIPT_SETTING(Culling);
|
REGISTER_BOOLEAN_SCRIPT_SETTING(Culling);
|
||||||
REGISTER_BOOLEAN_SCRIPT_SETTING(LockCullCamera);
|
REGISTER_BOOLEAN_SCRIPT_SETTING(LockCullCamera);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace JSI_GameView
|
namespace JSI_GameView
|
||||||
{
|
{
|
||||||
void RegisterScriptFunctions(ScriptInterface& ScriptInterface);
|
void RegisterScriptFunctions(const ScriptInterface& ScriptInterface);
|
||||||
|
|
||||||
DECLARE_BOOLEAN_SCRIPT_SETTING(Culling);
|
DECLARE_BOOLEAN_SCRIPT_SETTING(Culling);
|
||||||
DECLARE_BOOLEAN_SCRIPT_SETTING(LockCullCamera);
|
DECLARE_BOOLEAN_SCRIPT_SETTING(LockCullCamera);
|
||||||
|
@ -965,7 +965,7 @@ static TimerUnit js_timer_overhead;
|
|||||||
static TimerClient js_timer_clients[MAX_JS_TIMERS];
|
static TimerClient js_timer_clients[MAX_JS_TIMERS];
|
||||||
static wchar_t js_timer_descriptions_buf[MAX_JS_TIMERS * 12]; // depends on MAX_JS_TIMERS and format string below
|
static wchar_t js_timer_descriptions_buf[MAX_JS_TIMERS * 12]; // depends on MAX_JS_TIMERS and format string below
|
||||||
|
|
||||||
static void InitJsTimers(ScriptInterface& scriptInterface)
|
static void InitJsTimers(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
wchar_t* pos = js_timer_descriptions_buf;
|
wchar_t* pos = js_timer_descriptions_buf;
|
||||||
for(size_t i = 0; i < MAX_JS_TIMERS; i++)
|
for(size_t i = 0; i < MAX_JS_TIMERS; i++)
|
||||||
|
@ -157,7 +157,7 @@ void JSI_L10n::ReevaluateCurrentLocaleAndReload(ScriptInterface::CxPrivate* UNUS
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSI_L10n::RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
void JSI_L10n::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
scriptInterface.RegisterFunction<std::wstring, std::wstring, &Translate>("Translate");
|
scriptInterface.RegisterFunction<std::wstring, std::wstring, &Translate>("Translate");
|
||||||
scriptInterface.RegisterFunction<std::wstring, std::string, std::wstring, &TranslateWithContext>("TranslateWithContext");
|
scriptInterface.RegisterFunction<std::wstring, std::string, std::wstring, &TranslateWithContext>("TranslateWithContext");
|
||||||
|
@ -42,7 +42,7 @@ namespace JSI_L10n
|
|||||||
*
|
*
|
||||||
* @sa GuiScriptingInit()
|
* @sa GuiScriptingInit()
|
||||||
*/
|
*/
|
||||||
void RegisterScriptFunctions(ScriptInterface& ScriptInterface);
|
void RegisterScriptFunctions(const ScriptInterface& ScriptInterface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the translation of the specified string to the
|
* Returns the translation of the specified string to the
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@ -129,7 +129,7 @@ std::vector<T> ts_make_vector(T* start, size_t size_bytes)
|
|||||||
|
|
||||||
class ScriptInterface;
|
class ScriptInterface;
|
||||||
// Script-based testing setup (defined in test_setup.cpp). Defines TS_* functions.
|
// Script-based testing setup (defined in test_setup.cpp). Defines TS_* functions.
|
||||||
void ScriptTestSetup(ScriptInterface&);
|
void ScriptTestSetup(const ScriptInterface&);
|
||||||
|
|
||||||
// Default game data directory
|
// Default game data directory
|
||||||
// (TODO: game-specific functions like this probably shouldn't be inside lib/, but it's useful
|
// (TODO: game-specific functions like this probably shouldn't be inside lib/, but it's useful
|
||||||
|
@ -36,8 +36,8 @@ public:
|
|||||||
virtual void recv() = 0;
|
virtual void recv() = 0;
|
||||||
virtual void SendIqGetBoardList() = 0;
|
virtual void SendIqGetBoardList() = 0;
|
||||||
virtual void SendIqGetProfile(const std::string& player) = 0;
|
virtual void SendIqGetProfile(const std::string& player) = 0;
|
||||||
virtual void SendIqGameReport(ScriptInterface& scriptInterface, JS::HandleValue data) = 0;
|
virtual void SendIqGameReport(const ScriptInterface& scriptInterface, JS::HandleValue data) = 0;
|
||||||
virtual void SendIqRegisterGame(ScriptInterface& scriptInterface, JS::HandleValue data) = 0;
|
virtual void SendIqRegisterGame(const ScriptInterface& scriptInterface, JS::HandleValue data) = 0;
|
||||||
virtual void SendIqUnregisterGame() = 0;
|
virtual void SendIqUnregisterGame() = 0;
|
||||||
virtual void SendIqChangeStateGame(const std::string& nbp, const std::string& players) = 0;
|
virtual void SendIqChangeStateGame(const std::string& nbp, const std::string& players) = 0;
|
||||||
virtual void SetNick(const std::string& nick) = 0;
|
virtual void SetNick(const std::string& nick) = 0;
|
||||||
@ -48,14 +48,14 @@ public:
|
|||||||
virtual void GetPresence(const std::string& nickname, std::string& presence) = 0;
|
virtual void GetPresence(const std::string& nickname, std::string& presence) = 0;
|
||||||
virtual void GetRole(const std::string& nickname, std::string& role) = 0;
|
virtual void GetRole(const std::string& nickname, std::string& role) = 0;
|
||||||
virtual void GetSubject(std::string& subject) = 0;
|
virtual void GetSubject(std::string& subject) = 0;
|
||||||
virtual void GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
virtual void GUIGetPlayerList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
||||||
virtual void ClearPresenceUpdates() = 0;
|
virtual void ClearPresenceUpdates() = 0;
|
||||||
virtual int GetMucMessageCount() = 0;
|
virtual int GetMucMessageCount() = 0;
|
||||||
virtual void GUIGetGameList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
virtual void GUIGetGameList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
||||||
virtual void GUIGetBoardList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
virtual void GUIGetBoardList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
||||||
virtual void GUIGetProfile(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
virtual void GUIGetProfile(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
||||||
|
|
||||||
virtual void GuiPollMessage(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
virtual void GuiPollMessage(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0;
|
||||||
virtual void SendMUCMessage(const std::string& message) = 0;
|
virtual void SendMUCMessage(const std::string& message) = 0;
|
||||||
|
|
||||||
virtual void SendStunEndpointToHost(StunClient::StunEndpoint* stunEndpoint, const std::string& hostJID) = 0;
|
virtual void SendStunEndpointToHost(StunClient::StunEndpoint* stunEndpoint, const std::string& hostJID) = 0;
|
||||||
|
@ -301,7 +301,7 @@ void XmppClient::SendIqGetProfile(const std::string& player)
|
|||||||
*
|
*
|
||||||
* @param data A JS array of game statistics
|
* @param data A JS array of game statistics
|
||||||
*/
|
*/
|
||||||
void XmppClient::SendIqGameReport(ScriptInterface& scriptInterface, JS::HandleValue data)
|
void XmppClient::SendIqGameReport(const ScriptInterface& scriptInterface, JS::HandleValue data)
|
||||||
{
|
{
|
||||||
glooxwrapper::JID xpartamuppJid(m_xpartamuppId);
|
glooxwrapper::JID xpartamuppJid(m_xpartamuppId);
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ void XmppClient::SendIqGameReport(ScriptInterface& scriptInterface, JS::HandleVa
|
|||||||
*
|
*
|
||||||
* @param data A JS array of game attributes
|
* @param data A JS array of game attributes
|
||||||
*/
|
*/
|
||||||
void XmppClient::SendIqRegisterGame(ScriptInterface& scriptInterface, JS::HandleValue data)
|
void XmppClient::SendIqRegisterGame(const ScriptInterface& scriptInterface, JS::HandleValue data)
|
||||||
{
|
{
|
||||||
glooxwrapper::JID xpartamuppJid(m_xpartamuppId);
|
glooxwrapper::JID xpartamuppJid(m_xpartamuppId);
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ void XmppClient::handleOOB(const glooxwrapper::JID&, const glooxwrapper::OOB&)
|
|||||||
*
|
*
|
||||||
* @return A JS array containing all known players and their presences
|
* @return A JS array containing all known players and their presences
|
||||||
*/
|
*/
|
||||||
void XmppClient::GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
void XmppClient::GUIGetPlayerList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
@ -478,7 +478,7 @@ void XmppClient::GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableH
|
|||||||
*
|
*
|
||||||
* @return A JS array containing all known games
|
* @return A JS array containing all known games
|
||||||
*/
|
*/
|
||||||
void XmppClient::GUIGetGameList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
void XmppClient::GUIGetGameList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
@ -502,7 +502,7 @@ void XmppClient::GUIGetGameList(ScriptInterface& scriptInterface, JS::MutableHan
|
|||||||
*
|
*
|
||||||
* @return A JS array containing all known leaderboard data
|
* @return A JS array containing all known leaderboard data
|
||||||
*/
|
*/
|
||||||
void XmppClient::GUIGetBoardList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
void XmppClient::GUIGetBoardList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
@ -526,7 +526,7 @@ void XmppClient::GUIGetBoardList(ScriptInterface& scriptInterface, JS::MutableHa
|
|||||||
*
|
*
|
||||||
* @return A JS array containing the specific user's profile data
|
* @return A JS array containing the specific user's profile data
|
||||||
*/
|
*/
|
||||||
void XmppClient::GUIGetProfile(ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
void XmppClient::GUIGetProfile(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
@ -552,7 +552,7 @@ void XmppClient::GUIGetProfile(ScriptInterface& scriptInterface, JS::MutableHand
|
|||||||
/**
|
/**
|
||||||
* Send GUI message queue when queried.
|
* Send GUI message queue when queried.
|
||||||
*/
|
*/
|
||||||
void XmppClient::GuiPollMessage(ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
void XmppClient::GuiPollMessage(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
||||||
{
|
{
|
||||||
if (m_GuiMessageQueue.empty())
|
if (m_GuiMessageQueue.empty())
|
||||||
{
|
{
|
||||||
|
@ -64,8 +64,8 @@ public:
|
|||||||
void recv();
|
void recv();
|
||||||
void SendIqGetBoardList();
|
void SendIqGetBoardList();
|
||||||
void SendIqGetProfile(const std::string& player);
|
void SendIqGetProfile(const std::string& player);
|
||||||
void SendIqGameReport(ScriptInterface& scriptInterface, JS::HandleValue data);
|
void SendIqGameReport(const ScriptInterface& scriptInterface, JS::HandleValue data);
|
||||||
void SendIqRegisterGame(ScriptInterface& scriptInterface, JS::HandleValue data);
|
void SendIqRegisterGame(const ScriptInterface& scriptInterface, JS::HandleValue data);
|
||||||
void SendIqUnregisterGame();
|
void SendIqUnregisterGame();
|
||||||
void SendIqChangeStateGame(const std::string& nbp, const std::string& players);
|
void SendIqChangeStateGame(const std::string& nbp, const std::string& players);
|
||||||
void SetNick(const std::string& nick);
|
void SetNick(const std::string& nick);
|
||||||
@ -77,16 +77,13 @@ public:
|
|||||||
void GetRole(const std::string& nickname, std::string& role);
|
void GetRole(const std::string& nickname, std::string& role);
|
||||||
void GetSubject(std::string& subject);
|
void GetSubject(std::string& subject);
|
||||||
|
|
||||||
void GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
void GUIGetPlayerList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
||||||
void GUIGetGameList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
void GUIGetGameList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
||||||
void GUIGetBoardList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
void GUIGetBoardList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
||||||
void GUIGetProfile(ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
void GUIGetProfile(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
||||||
|
|
||||||
void SendStunEndpointToHost(StunClient::StunEndpoint* stunEndpoint, const std::string& hostJID);
|
void SendStunEndpointToHost(StunClient::StunEndpoint* stunEndpoint, const std::string& hostJID);
|
||||||
|
|
||||||
//Script
|
|
||||||
ScriptInterface& GetScriptInterface();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* Xmpp handlers */
|
/* Xmpp handlers */
|
||||||
/* MUC handlers */
|
/* MUC handlers */
|
||||||
@ -146,7 +143,7 @@ public:
|
|||||||
std::wstring message;
|
std::wstring message;
|
||||||
std::time_t time;
|
std::time_t time;
|
||||||
};
|
};
|
||||||
void GuiPollMessage(ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
void GuiPollMessage(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret);
|
||||||
void SendMUCMessage(const std::string& message);
|
void SendMUCMessage(const std::string& message);
|
||||||
void ClearPresenceUpdates();
|
void ClearPresenceUpdates();
|
||||||
int GetMucMessageCount();
|
int GetMucMessageCount();
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "third_party/encryption/pkcs5_pbkdf2.h"
|
#include "third_party/encryption/pkcs5_pbkdf2.h"
|
||||||
#include "third_party/encryption/sha.h"
|
#include "third_party/encryption/sha.h"
|
||||||
|
|
||||||
void JSI_Lobby::RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
void JSI_Lobby::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
// Lobby functions
|
// Lobby functions
|
||||||
scriptInterface.RegisterFunction<bool, &JSI_Lobby::HasXmppClient>("HasXmppClient");
|
scriptInterface.RegisterFunction<bool, &JSI_Lobby::HasXmppClient>("HasXmppClient");
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
namespace JSI_Lobby
|
namespace JSI_Lobby
|
||||||
{
|
{
|
||||||
void RegisterScriptFunctions(ScriptInterface& scriptInterface);
|
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
|
||||||
|
|
||||||
bool HasXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
|
bool HasXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
|
||||||
bool IsRankedGame(ScriptInterface::CxPrivate* pCxPrivate);
|
bool IsRankedGame(ScriptInterface::CxPrivate* pCxPrivate);
|
||||||
|
@ -93,7 +93,7 @@ CStr CNetMessage::ToString() const
|
|||||||
|
|
||||||
CNetMessage* CNetMessageFactory::CreateMessage(const void* pData,
|
CNetMessage* CNetMessageFactory::CreateMessage(const void* pData,
|
||||||
size_t dataSize,
|
size_t dataSize,
|
||||||
ScriptInterface& scriptInterface)
|
const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
CNetMessage* pNewMessage = NULL;
|
CNetMessage* pNewMessage = NULL;
|
||||||
CNetMessage header;
|
CNetMessage header;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -103,7 +103,7 @@ public:
|
|||||||
* @param scriptInterface Script instance to use when constructing scripted messages
|
* @param scriptInterface Script instance to use when constructing scripted messages
|
||||||
* @return The new message created
|
* @return The new message created
|
||||||
*/
|
*/
|
||||||
static CNetMessage* CreateMessage(const void* pData, size_t dataSize, ScriptInterface& scriptInterface);
|
static CNetMessage* CreateMessage(const void* pData, size_t dataSize, const ScriptInterface& scriptInterface);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,8 +113,8 @@ public:
|
|||||||
class CSimulationMessage : public CNetMessage
|
class CSimulationMessage : public CNetMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CSimulationMessage(ScriptInterface& scriptInterface);
|
CSimulationMessage(const ScriptInterface& scriptInterface);
|
||||||
CSimulationMessage(ScriptInterface& scriptInterface, u32 client, i32 player, u32 turn, JS::HandleValue data);
|
CSimulationMessage(const ScriptInterface& scriptInterface, u32 client, i32 player, u32 turn, JS::HandleValue data);
|
||||||
|
|
||||||
/** The compiler can't create a copy constructor because of the PersistentRooted member,
|
/** The compiler can't create a copy constructor because of the PersistentRooted member,
|
||||||
* so we have to write it manually.
|
* so we have to write it manually.
|
||||||
@ -132,7 +132,7 @@ public:
|
|||||||
u32 m_Turn;
|
u32 m_Turn;
|
||||||
JS::PersistentRooted<JS::Value> m_Data;
|
JS::PersistentRooted<JS::Value> m_Data;
|
||||||
private:
|
private:
|
||||||
ScriptInterface* m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,8 +142,8 @@ class CGameSetupMessage : public CNetMessage
|
|||||||
{
|
{
|
||||||
NONCOPYABLE(CGameSetupMessage);
|
NONCOPYABLE(CGameSetupMessage);
|
||||||
public:
|
public:
|
||||||
CGameSetupMessage(ScriptInterface& scriptInterface);
|
CGameSetupMessage(const ScriptInterface& scriptInterface);
|
||||||
CGameSetupMessage(ScriptInterface& scriptInterface, JS::HandleValue data);
|
CGameSetupMessage(const ScriptInterface& scriptInterface, JS::HandleValue data);
|
||||||
virtual u8* Serialize(u8* pBuffer) const;
|
virtual u8* Serialize(u8* pBuffer) const;
|
||||||
virtual const u8* Deserialize(const u8* pStart, const u8* pEnd);
|
virtual const u8* Deserialize(const u8* pStart, const u8* pEnd);
|
||||||
virtual size_t GetSerializedLength() const;
|
virtual size_t GetSerializedLength() const;
|
||||||
@ -151,7 +151,7 @@ public:
|
|||||||
|
|
||||||
JS::PersistentRootedValue m_Data;
|
JS::PersistentRootedValue m_Data;
|
||||||
private:
|
private:
|
||||||
ScriptInterface& m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This time, the classes are created
|
// This time, the classes are created
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2011 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -59,7 +59,7 @@ public:
|
|||||||
class CBufferBinarySerializer : public CBinarySerializer<CBufferBinarySerializerImpl>
|
class CBufferBinarySerializer : public CBinarySerializer<CBufferBinarySerializerImpl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBufferBinarySerializer(ScriptInterface& scriptInterface, u8* buffer) :
|
CBufferBinarySerializer(const ScriptInterface& scriptInterface, u8* buffer) :
|
||||||
CBinarySerializer<CBufferBinarySerializerImpl>(scriptInterface, buffer)
|
CBinarySerializer<CBufferBinarySerializerImpl>(scriptInterface, buffer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ public:
|
|||||||
class CLengthBinarySerializer : public CBinarySerializer<CLengthBinarySerializerImpl>
|
class CLengthBinarySerializer : public CBinarySerializer<CLengthBinarySerializerImpl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CLengthBinarySerializer(ScriptInterface& scriptInterface) :
|
CLengthBinarySerializer(const ScriptInterface& scriptInterface) :
|
||||||
CBinarySerializer<CLengthBinarySerializerImpl>(scriptInterface)
|
CBinarySerializer<CLengthBinarySerializerImpl>(scriptInterface)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -109,19 +109,19 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CSimulationMessage::CSimulationMessage(ScriptInterface& scriptInterface) :
|
CSimulationMessage::CSimulationMessage(const ScriptInterface& scriptInterface) :
|
||||||
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(&scriptInterface), m_Data(scriptInterface.GetJSRuntime())
|
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(scriptInterface), m_Data(scriptInterface.GetJSRuntime())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSimulationMessage::CSimulationMessage(ScriptInterface& scriptInterface, u32 client, i32 player, u32 turn, JS::HandleValue data) :
|
CSimulationMessage::CSimulationMessage(const ScriptInterface& scriptInterface, u32 client, i32 player, u32 turn, JS::HandleValue data) :
|
||||||
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(&scriptInterface),
|
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(scriptInterface),
|
||||||
m_Client(client), m_Player(player), m_Turn(turn), m_Data(scriptInterface.GetJSRuntime(), data)
|
m_Client(client), m_Player(player), m_Turn(turn), m_Data(scriptInterface.GetJSRuntime(), data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSimulationMessage::CSimulationMessage(const CSimulationMessage& orig) :
|
CSimulationMessage::CSimulationMessage(const CSimulationMessage& orig) :
|
||||||
m_Data(orig.m_ScriptInterface->GetJSRuntime()),
|
m_Data(orig.m_ScriptInterface.GetJSRuntime()),
|
||||||
m_Client(orig.m_Client),
|
m_Client(orig.m_Client),
|
||||||
m_Player(orig.m_Player),
|
m_Player(orig.m_Player),
|
||||||
m_ScriptInterface(orig.m_ScriptInterface),
|
m_ScriptInterface(orig.m_ScriptInterface),
|
||||||
@ -136,7 +136,7 @@ u8* CSimulationMessage::Serialize(u8* pBuffer) const
|
|||||||
// TODO: ought to handle serialization exceptions
|
// TODO: ought to handle serialization exceptions
|
||||||
// TODO: ought to represent common commands more efficiently
|
// TODO: ought to represent common commands more efficiently
|
||||||
u8* pos = CNetMessage::Serialize(pBuffer);
|
u8* pos = CNetMessage::Serialize(pBuffer);
|
||||||
CBufferBinarySerializer serializer(*m_ScriptInterface, pos);
|
CBufferBinarySerializer serializer(m_ScriptInterface, pos);
|
||||||
serializer.NumberU32_Unbounded("client", m_Client);
|
serializer.NumberU32_Unbounded("client", m_Client);
|
||||||
serializer.NumberI32_Unbounded("player", m_Player);
|
serializer.NumberI32_Unbounded("player", m_Player);
|
||||||
serializer.NumberU32_Unbounded("turn", m_Turn);
|
serializer.NumberU32_Unbounded("turn", m_Turn);
|
||||||
@ -151,7 +151,7 @@ const u8* CSimulationMessage::Deserialize(const u8* pStart, const u8* pEnd)
|
|||||||
// TODO: ought to represent common commands more efficiently
|
// TODO: ought to represent common commands more efficiently
|
||||||
const u8* pos = CNetMessage::Deserialize(pStart, pEnd);
|
const u8* pos = CNetMessage::Deserialize(pStart, pEnd);
|
||||||
std::istringstream stream(std::string(pos, pEnd));
|
std::istringstream stream(std::string(pos, pEnd));
|
||||||
CStdDeserializer deserializer(*m_ScriptInterface, stream);
|
CStdDeserializer deserializer(m_ScriptInterface, stream);
|
||||||
deserializer.NumberU32_Unbounded("client", m_Client);
|
deserializer.NumberU32_Unbounded("client", m_Client);
|
||||||
deserializer.NumberI32_Unbounded("player", m_Player);
|
deserializer.NumberI32_Unbounded("player", m_Player);
|
||||||
deserializer.NumberU32_Unbounded("turn", m_Turn);
|
deserializer.NumberU32_Unbounded("turn", m_Turn);
|
||||||
@ -163,7 +163,7 @@ size_t CSimulationMessage::GetSerializedLength() const
|
|||||||
{
|
{
|
||||||
// TODO: serializing twice is stupidly inefficient - we should just
|
// TODO: serializing twice is stupidly inefficient - we should just
|
||||||
// do it once, store the result, and use it here and in Serialize
|
// do it once, store the result, and use it here and in Serialize
|
||||||
CLengthBinarySerializer serializer(*m_ScriptInterface);
|
CLengthBinarySerializer serializer(m_ScriptInterface);
|
||||||
serializer.NumberU32_Unbounded("client", m_Client);
|
serializer.NumberU32_Unbounded("client", m_Client);
|
||||||
serializer.NumberI32_Unbounded("player", m_Player);
|
serializer.NumberI32_Unbounded("player", m_Player);
|
||||||
serializer.NumberU32_Unbounded("turn", m_Turn);
|
serializer.NumberU32_Unbounded("turn", m_Turn);
|
||||||
@ -176,7 +176,7 @@ size_t CSimulationMessage::GetSerializedLength() const
|
|||||||
|
|
||||||
CStr CSimulationMessage::ToString() const
|
CStr CSimulationMessage::ToString() const
|
||||||
{
|
{
|
||||||
std::string source = m_ScriptInterface->ToString(const_cast<JS::PersistentRootedValue*>(&m_Data));
|
std::string source = m_ScriptInterface.ToString(const_cast<JS::PersistentRootedValue*>(&m_Data));
|
||||||
|
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << "CSimulationMessage { m_Client: " << m_Client << ", m_Player: " << m_Player << ", m_Turn: " << m_Turn << ", m_Data: " << source << " }";
|
stream << "CSimulationMessage { m_Client: " << m_Client << ", m_Player: " << m_Player << ", m_Turn: " << m_Turn << ", m_Data: " << source << " }";
|
||||||
@ -184,12 +184,12 @@ CStr CSimulationMessage::ToString() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CGameSetupMessage::CGameSetupMessage(ScriptInterface& scriptInterface) :
|
CGameSetupMessage::CGameSetupMessage(const ScriptInterface& scriptInterface) :
|
||||||
CNetMessage(NMT_GAME_SETUP), m_ScriptInterface(scriptInterface), m_Data(scriptInterface.GetJSRuntime())
|
CNetMessage(NMT_GAME_SETUP), m_ScriptInterface(scriptInterface), m_Data(scriptInterface.GetJSRuntime())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CGameSetupMessage::CGameSetupMessage(ScriptInterface& scriptInterface, JS::HandleValue data) :
|
CGameSetupMessage::CGameSetupMessage(const ScriptInterface& scriptInterface, JS::HandleValue data) :
|
||||||
CNetMessage(NMT_GAME_SETUP), m_ScriptInterface(scriptInterface),
|
CNetMessage(NMT_GAME_SETUP), m_ScriptInterface(scriptInterface),
|
||||||
m_Data(scriptInterface.GetJSRuntime(), data)
|
m_Data(scriptInterface.GetJSRuntime(), data)
|
||||||
{
|
{
|
||||||
|
@ -360,7 +360,7 @@ bool STUNRequestAndResponse(ENetHost* transactionHost)
|
|||||||
ParseStunResponse(buffer);
|
ParseStunResponse(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value StunClient::FindStunEndpointHost(ScriptInterface& scriptInterface, int port)
|
JS::Value StunClient::FindStunEndpointHost(const ScriptInterface& scriptInterface, int port)
|
||||||
{
|
{
|
||||||
ENetAddress hostAddr{ENET_HOST_ANY, (u16)port};
|
ENetAddress hostAddr{ENET_HOST_ANY, (u16)port};
|
||||||
ENetHost* transactionHost = enet_host_create(&hostAddr, 1, 1, 0, 0);
|
ENetHost* transactionHost = enet_host_create(&hostAddr, 1, 1, 0, 0);
|
||||||
|
@ -33,7 +33,7 @@ struct StunEndpoint {
|
|||||||
|
|
||||||
void SendStunRequest(ENetHost* transactionHost, u32 targetIp, u16 targetPort);
|
void SendStunRequest(ENetHost* transactionHost, u32 targetIp, u16 targetPort);
|
||||||
|
|
||||||
JS::Value FindStunEndpointHost(ScriptInterface& scriptInterface, int port);
|
JS::Value FindStunEndpointHost(const ScriptInterface& scriptInterface, int port);
|
||||||
|
|
||||||
StunEndpoint* FindStunEndpointJoin(ENetHost* transactionHost);
|
StunEndpoint* FindStunEndpointJoin(ENetHost* transactionHost);
|
||||||
|
|
||||||
|
@ -67,10 +67,10 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ReportGLLimits(ScriptInterface& scriptInterface, JS::HandleValue settings);
|
static void ReportGLLimits(const ScriptInterface& scriptInterface, JS::HandleValue settings);
|
||||||
|
|
||||||
#if ARCH_X86_X64
|
#if ARCH_X86_X64
|
||||||
void ConvertCaches(ScriptInterface& scriptInterface, x86_x64::IdxCache idxCache, JS::MutableHandleValue ret)
|
void ConvertCaches(const ScriptInterface& scriptInterface, x86_x64::IdxCache idxCache, JS::MutableHandleValue ret)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
@ -93,7 +93,7 @@ void ConvertCaches(ScriptInterface& scriptInterface, x86_x64::IdxCache idxCache,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertTLBs(ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
void ConvertTLBs(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
@ -351,7 +351,7 @@ void RunHardwareDetection()
|
|||||||
scriptInterface.CallFunctionVoid(global, "RunHardwareDetection", settings);
|
scriptInterface.CallFunctionVoid(global, "RunHardwareDetection", settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReportGLLimits(ScriptInterface& scriptInterface, JS::HandleValue settings)
|
static void ReportGLLimits(const ScriptInterface& scriptInterface, JS::HandleValue settings)
|
||||||
{
|
{
|
||||||
const char* errstr = "(error)";
|
const char* errstr = "(error)";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -484,9 +484,9 @@ namespace
|
|||||||
|
|
||||||
struct DumpTable
|
struct DumpTable
|
||||||
{
|
{
|
||||||
ScriptInterface& m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
JS::PersistentRooted<JS::Value> m_Root;
|
JS::PersistentRooted<JS::Value> m_Root;
|
||||||
DumpTable(ScriptInterface& scriptInterface, JS::HandleValue root) :
|
DumpTable(const ScriptInterface& scriptInterface, JS::HandleValue root) :
|
||||||
m_ScriptInterface(scriptInterface), m_Root(scriptInterface.GetJSRuntime(), root)
|
m_ScriptInterface(scriptInterface), m_Root(scriptInterface.GetJSRuntime(), root)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -600,7 +600,7 @@ void CProfileViewer::SaveToFile()
|
|||||||
m->outputStream.flush();
|
m->outputStream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value CProfileViewer::SaveToJS(ScriptInterface& scriptInterface)
|
JS::Value CProfileViewer::SaveToJS(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2009 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -191,7 +191,7 @@ public:
|
|||||||
* SaveToJS: Return a script value containing the current profiler data
|
* SaveToJS: Return a script value containing the current profiler data
|
||||||
* (for all profile tables).
|
* (for all profile tables).
|
||||||
*/
|
*/
|
||||||
JS::Value SaveToJS(ScriptInterface& scriptInterface);
|
JS::Value SaveToJS(const ScriptInterface& scriptInterface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ShowTable: Set the named profile table to be the displayed one. If it
|
* ShowTable: Set the named profile table to be the displayed one. If it
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
CReplayLogger::CReplayLogger(ScriptInterface& scriptInterface) :
|
CReplayLogger::CReplayLogger(const ScriptInterface& scriptInterface) :
|
||||||
m_ScriptInterface(scriptInterface), m_Stream(NULL)
|
m_ScriptInterface(scriptInterface), m_Stream(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ class CReplayLogger : public IReplayLogger
|
|||||||
{
|
{
|
||||||
NONCOPYABLE(CReplayLogger);
|
NONCOPYABLE(CReplayLogger);
|
||||||
public:
|
public:
|
||||||
CReplayLogger(ScriptInterface& scriptInterface);
|
CReplayLogger(const ScriptInterface& scriptInterface);
|
||||||
~CReplayLogger();
|
~CReplayLogger();
|
||||||
|
|
||||||
virtual void StartGame(JS::MutableHandleValue attribs);
|
virtual void StartGame(JS::MutableHandleValue attribs);
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
virtual OsPath GetDirectory() const;
|
virtual OsPath GetDirectory() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScriptInterface& m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
std::ostream* m_Stream;
|
std::ostream* m_Stream;
|
||||||
OsPath m_Directory;
|
OsPath m_Directory;
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2016 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -154,7 +154,7 @@ public:
|
|||||||
* for the metadata because it would be error prone with rooting and the stack-based rooting
|
* for the metadata because it would be error prone with rooting and the stack-based rooting
|
||||||
* types and confusing (a chain of pointers pointing to other pointers).
|
* types and confusing (a chain of pointers pointing to other pointers).
|
||||||
*/
|
*/
|
||||||
CGameLoader(ScriptInterface& scriptInterface, std::string* savedState) :
|
CGameLoader(const ScriptInterface& scriptInterface, std::string* savedState) :
|
||||||
m_ScriptInterface(scriptInterface),
|
m_ScriptInterface(scriptInterface),
|
||||||
m_Metadata(scriptInterface.GetJSRuntime()),
|
m_Metadata(scriptInterface.GetJSRuntime()),
|
||||||
m_SavedState(savedState)
|
m_SavedState(savedState)
|
||||||
@ -192,12 +192,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ScriptInterface& m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
JS::PersistentRooted<JS::Value> m_Metadata;
|
JS::PersistentRooted<JS::Value> m_Metadata;
|
||||||
std::string* m_SavedState;
|
std::string* m_SavedState;
|
||||||
};
|
};
|
||||||
|
|
||||||
Status SavedGames::Load(const std::wstring& name, ScriptInterface& scriptInterface, JS::MutableHandleValue metadata, std::string& savedState)
|
Status SavedGames::Load(const std::wstring& name, const ScriptInterface& scriptInterface, JS::MutableHandleValue metadata, std::string& savedState)
|
||||||
{
|
{
|
||||||
// Determine the filename to load
|
// Determine the filename to load
|
||||||
const VfsPath basename(L"saves/" + name);
|
const VfsPath basename(L"saves/" + name);
|
||||||
@ -221,7 +221,7 @@ Status SavedGames::Load(const std::wstring& name, ScriptInterface& scriptInterfa
|
|||||||
return INFO::OK;
|
return INFO::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value SavedGames::GetSavedGames(ScriptInterface& scriptInterface)
|
JS::Value SavedGames::GetSavedGames(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
TIMER(L"GetSavedGames");
|
TIMER(L"GetSavedGames");
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
@ -294,7 +294,7 @@ bool SavedGames::DeleteSavedGame(const std::wstring& name)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value SavedGames::GetEngineInfo(ScriptInterface& scriptInterface)
|
JS::Value SavedGames::GetEngineInfo(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2016 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -70,7 +70,7 @@ Status SavePrefix(const CStrW& prefix, const CStrW& description, CSimulation2& s
|
|||||||
* loaded from simulation.dat inside the archive.
|
* loaded from simulation.dat inside the archive.
|
||||||
* @return INFO::OK if successfully loaded, else an error Status
|
* @return INFO::OK if successfully loaded, else an error Status
|
||||||
*/
|
*/
|
||||||
Status Load(const std::wstring& name, ScriptInterface& scriptInterface, JS::MutableHandleValue metadata, std::string& savedState);
|
Status Load(const std::wstring& name, const ScriptInterface& scriptInterface, JS::MutableHandleValue metadata, std::string& savedState);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of saved games for GUI script usage
|
* Get list of saved games for GUI script usage
|
||||||
@ -78,7 +78,7 @@ Status Load(const std::wstring& name, ScriptInterface& scriptInterface, JS::Muta
|
|||||||
* @param scriptInterface the ScriptInterface in which to create the return data.
|
* @param scriptInterface the ScriptInterface in which to create the return data.
|
||||||
* @return array of objects containing saved game data
|
* @return array of objects containing saved game data
|
||||||
*/
|
*/
|
||||||
JS::Value GetSavedGames(ScriptInterface& scriptInterface);
|
JS::Value GetSavedGames(const ScriptInterface& scriptInterface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permanently deletes the saved game archive with the given name
|
* Permanently deletes the saved game archive with the given name
|
||||||
@ -94,7 +94,7 @@ bool DeleteSavedGame(const std::wstring& name);
|
|||||||
* @param scriptInterface the ScriptInterface in which to create the return data.
|
* @param scriptInterface the ScriptInterface in which to create the return data.
|
||||||
* @return list of objects containing saved game data
|
* @return list of objects containing saved game data
|
||||||
*/
|
*/
|
||||||
JS::Value GetEngineInfo(ScriptInterface& scriptInterface);
|
JS::Value GetEngineInfo(const ScriptInterface& scriptInterface);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ bool VisualReplay::StartVisualReplay(const OsPath& directory)
|
|||||||
return g_Game->StartVisualReplay(replayFile);
|
return g_Game->StartVisualReplay(replayFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VisualReplay::ReadCacheFile(ScriptInterface& scriptInterface, JS::MutableHandleObject cachedReplaysObject)
|
bool VisualReplay::ReadCacheFile(const ScriptInterface& scriptInterface, JS::MutableHandleObject cachedReplaysObject)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
@ -89,7 +89,7 @@ bool VisualReplay::ReadCacheFile(ScriptInterface& scriptInterface, JS::MutableHa
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualReplay::StoreCacheFile(ScriptInterface& scriptInterface, JS::HandleObject replays)
|
void VisualReplay::StoreCacheFile(const ScriptInterface& scriptInterface, JS::HandleObject replays)
|
||||||
{
|
{
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
JSAutoRequest rq(cx);
|
JSAutoRequest rq(cx);
|
||||||
@ -104,7 +104,7 @@ void VisualReplay::StoreCacheFile(ScriptInterface& scriptInterface, JS::HandleOb
|
|||||||
LOGERROR("Could not store the replay cache");
|
LOGERROR("Could not store the replay cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::HandleObject VisualReplay::ReloadReplayCache(ScriptInterface& scriptInterface, bool compareFiles)
|
JS::HandleObject VisualReplay::ReloadReplayCache(const ScriptInterface& scriptInterface, bool compareFiles)
|
||||||
{
|
{
|
||||||
TIMER(L"ReloadReplayCache");
|
TIMER(L"ReloadReplayCache");
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
@ -217,7 +217,7 @@ JS::HandleObject VisualReplay::ReloadReplayCache(ScriptInterface& scriptInterfac
|
|||||||
return replays;
|
return replays;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value VisualReplay::GetReplays(ScriptInterface& scriptInterface, bool compareFiles)
|
JS::Value VisualReplay::GetReplays(const ScriptInterface& scriptInterface, bool compareFiles)
|
||||||
{
|
{
|
||||||
TIMER(L"GetReplays");
|
TIMER(L"GetReplays");
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
@ -320,7 +320,7 @@ inline int getReplayDuration(std::istream* replayStream, const OsPath& fileName,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value VisualReplay::LoadReplayData(ScriptInterface& scriptInterface, const OsPath& directory)
|
JS::Value VisualReplay::LoadReplayData(const ScriptInterface& scriptInterface, const OsPath& directory)
|
||||||
{
|
{
|
||||||
// The directory argument must not be constant, otherwise concatenating will fail
|
// The directory argument must not be constant, otherwise concatenating will fail
|
||||||
const OsPath replayFile = GetDirectoryName() / directory / L"commands.txt";
|
const OsPath replayFile = GetDirectoryName() / directory / L"commands.txt";
|
||||||
@ -434,7 +434,7 @@ JS::Value VisualReplay::GetReplayAttributes(ScriptInterface::CxPrivate* pCxPriva
|
|||||||
return attribs;
|
return attribs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualReplay::AddReplayToCache(ScriptInterface& scriptInterface, const CStrW& directoryName)
|
void VisualReplay::AddReplayToCache(const ScriptInterface& scriptInterface, const CStrW& directoryName)
|
||||||
{
|
{
|
||||||
TIMER(L"AddReplayToCache");
|
TIMER(L"AddReplayToCache");
|
||||||
JSContext* cx = scriptInterface.GetContext();
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
|
@ -48,7 +48,7 @@ bool StartVisualReplay(const OsPath& directory);
|
|||||||
* @param cachedReplaysObject - the cached replays.
|
* @param cachedReplaysObject - the cached replays.
|
||||||
* @return true on succes
|
* @return true on succes
|
||||||
*/
|
*/
|
||||||
bool ReadCacheFile(ScriptInterface& scriptInterface, JS::MutableHandleObject cachedReplaysObject);
|
bool ReadCacheFile(const ScriptInterface& scriptInterface, JS::MutableHandleObject cachedReplaysObject);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the replay list in the replay cache file
|
* Stores the replay list in the replay cache file
|
||||||
@ -56,7 +56,7 @@ bool ReadCacheFile(ScriptInterface& scriptInterface, JS::MutableHandleObject cac
|
|||||||
* @param scriptInterface - the ScriptInterface in which to create the return data.
|
* @param scriptInterface - the ScriptInterface in which to create the return data.
|
||||||
* @param replays - the replay list to store.
|
* @param replays - the replay list to store.
|
||||||
*/
|
*/
|
||||||
void StoreCacheFile(ScriptInterface& scriptInterface, JS::HandleObject replays);
|
void StoreCacheFile(const ScriptInterface& scriptInterface, JS::HandleObject replays);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the replay cache and check if there are new/deleted replays. If so, update the cache.
|
* Load the replay cache and check if there are new/deleted replays. If so, update the cache.
|
||||||
@ -65,7 +65,7 @@ void StoreCacheFile(ScriptInterface& scriptInterface, JS::HandleObject replays);
|
|||||||
* @param compareFiles - compare the directory name and the FileSize of the replays and the cache.
|
* @param compareFiles - compare the directory name and the FileSize of the replays and the cache.
|
||||||
* @return cache entries
|
* @return cache entries
|
||||||
*/
|
*/
|
||||||
JS::HandleObject ReloadReplayCache(ScriptInterface& scriptInterface, bool compareFiles);
|
JS::HandleObject ReloadReplayCache(const ScriptInterface& scriptInterface, bool compareFiles);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of replays to display in the GUI.
|
* Get a list of replays to display in the GUI.
|
||||||
@ -75,13 +75,13 @@ JS::HandleObject ReloadReplayCache(ScriptInterface& scriptInterface, bool compar
|
|||||||
* but nearly ensures, that no changed replay is missed.
|
* but nearly ensures, that no changed replay is missed.
|
||||||
* @return array of objects containing replay data
|
* @return array of objects containing replay data
|
||||||
*/
|
*/
|
||||||
JS::Value GetReplays(ScriptInterface& scriptInterface, bool compareFiles);
|
JS::Value GetReplays(const ScriptInterface& scriptInterface, bool compareFiles);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a commands.txt file and extracts metadata.
|
* Parses a commands.txt file and extracts metadata.
|
||||||
* Works similarly to CGame::LoadReplayData().
|
* Works similarly to CGame::LoadReplayData().
|
||||||
*/
|
*/
|
||||||
JS::Value LoadReplayData(ScriptInterface& scriptInterface, const OsPath& directory);
|
JS::Value LoadReplayData(const ScriptInterface& scriptInterface, const OsPath& directory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permanently deletes the visual replay (including the parent directory)
|
* Permanently deletes the visual replay (including the parent directory)
|
||||||
@ -114,7 +114,7 @@ void SaveReplayMetadata(ScriptInterface* scriptInterface);
|
|||||||
/**
|
/**
|
||||||
* Adds a replay to the replayCache.
|
* Adds a replay to the replayCache.
|
||||||
*/
|
*/
|
||||||
void AddReplayToCache(ScriptInterface& scriptInterface, const CStrW& directoryName);
|
void AddReplayToCache(const ScriptInterface& scriptInterface, const CStrW& directoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -133,7 +133,7 @@ bool JSI_ConfigDB::SetFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSI_ConfigDB::RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
void JSI_ConfigDB::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
scriptInterface.RegisterFunction<bool, std::wstring, &JSI_ConfigDB::HasChanges>("ConfigDB_HasChanges");
|
scriptInterface.RegisterFunction<bool, std::wstring, &JSI_ConfigDB::HasChanges>("ConfigDB_HasChanges");
|
||||||
scriptInterface.RegisterFunction<bool, std::wstring, bool, &JSI_ConfigDB::SetChanges>("ConfigDB_SetChanges");
|
scriptInterface.RegisterFunction<bool, std::wstring, bool, &JSI_ConfigDB::SetChanges>("ConfigDB_SetChanges");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -33,7 +33,7 @@ namespace JSI_ConfigDB
|
|||||||
bool WriteValueToFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path);
|
bool WriteValueToFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path);
|
||||||
bool Reload(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString);
|
bool Reload(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString);
|
||||||
bool SetFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const Path& path);
|
bool SetFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const Path& path);
|
||||||
void RegisterScriptFunctions(ScriptInterface& scriptInterface);
|
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -47,7 +47,7 @@ void JSI_Console::SetVisibleEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivat
|
|||||||
g_Console->SetVisible(Enabled);
|
g_Console->SetVisible(Enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSI_Console::RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
void JSI_Console::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
scriptInterface.RegisterFunction<bool, &JSI_Console::GetVisibleEnabled>("Console_GetVisibleEnabled");
|
scriptInterface.RegisterFunction<bool, &JSI_Console::GetVisibleEnabled>("Console_GetVisibleEnabled");
|
||||||
scriptInterface.RegisterFunction<void, bool, &JSI_Console::SetVisibleEnabled>("Console_SetVisibleEnabled");
|
scriptInterface.RegisterFunction<void, bool, &JSI_Console::SetVisibleEnabled>("Console_SetVisibleEnabled");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -26,7 +26,7 @@ namespace JSI_Console
|
|||||||
bool GetVisibleEnabled(ScriptInterface::CxPrivate* pCxPrivate);
|
bool GetVisibleEnabled(ScriptInterface::CxPrivate* pCxPrivate);
|
||||||
void SetVisibleEnabled(ScriptInterface::CxPrivate* pCxPrivate, bool Enabled);
|
void SetVisibleEnabled(ScriptInterface::CxPrivate* pCxPrivate, bool Enabled);
|
||||||
|
|
||||||
void RegisterScriptFunctions(ScriptInterface& scriptInterface);
|
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -123,7 +123,7 @@ void JSI_Mod::SetMods(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std:
|
|||||||
g_modsLoaded = mods;
|
g_modsLoaded = mods;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSI_Mod::RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
void JSI_Mod::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
scriptInterface.RegisterFunction<JS::Value, &JSI_Mod::GetAvailableMods>("GetAvailableMods");
|
scriptInterface.RegisterFunction<JS::Value, &JSI_Mod::GetAvailableMods>("GetAvailableMods");
|
||||||
scriptInterface.RegisterFunction<void, &JSI_Mod::RestartEngine>("RestartEngine");
|
scriptInterface.RegisterFunction<void, &JSI_Mod::RestartEngine>("RestartEngine");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -22,7 +22,7 @@ class ScriptInterface;
|
|||||||
|
|
||||||
namespace JSI_Mod
|
namespace JSI_Mod
|
||||||
{
|
{
|
||||||
void RegisterScriptFunctions(ScriptInterface& scriptInterface);
|
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
|
||||||
JS::Value GetAvailableMods(ScriptInterface::CxPrivate* pCxPrivate);
|
JS::Value GetAvailableMods(ScriptInterface::CxPrivate* pCxPrivate);
|
||||||
void RestartEngine(ScriptInterface::CxPrivate* pCxPrivate);
|
void RestartEngine(ScriptInterface::CxPrivate* pCxPrivate);
|
||||||
void SetMods(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStr>& mods);
|
void SetMods(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStr>& mods);
|
||||||
|
@ -63,7 +63,7 @@ CStrW JSI_VisualReplay::GetReplayDirectoryName(ScriptInterface::CxPrivate* UNUSE
|
|||||||
return wstring_from_utf8(OsPath(VisualReplay::GetDirectoryName() / directoryName).string8());
|
return wstring_from_utf8(OsPath(VisualReplay::GetDirectoryName() / directoryName).string8());
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSI_VisualReplay::RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
void JSI_VisualReplay::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
scriptInterface.RegisterFunction<JS::Value, bool, &GetReplays>("GetReplays");
|
scriptInterface.RegisterFunction<JS::Value, bool, &GetReplays>("GetReplays");
|
||||||
scriptInterface.RegisterFunction<bool, CStrW, &DeleteReplay>("DeleteReplay");
|
scriptInterface.RegisterFunction<bool, CStrW, &DeleteReplay>("DeleteReplay");
|
||||||
|
@ -30,7 +30,7 @@ namespace JSI_VisualReplay
|
|||||||
bool HasReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
|
bool HasReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
|
||||||
JS::Value GetReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
|
JS::Value GetReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
|
||||||
void AddReplayToCache(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
|
void AddReplayToCache(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
|
||||||
void RegisterScriptFunctions(ScriptInterface& scriptInterface);
|
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
|
||||||
CStrW GetReplayDirectoryName(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
|
CStrW GetReplayDirectoryName(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void JSI_Renderer::RecreateShadowMap(ScriptInterface::CxPrivate* UNUSED(pCxPriva
|
|||||||
scriptInterface.RegisterFunction<bool, &JSI_Renderer::Get##NAME##Enabled>("Renderer_Get" #NAME "Enabled"); \
|
scriptInterface.RegisterFunction<bool, &JSI_Renderer::Get##NAME##Enabled>("Renderer_Get" #NAME "Enabled"); \
|
||||||
scriptInterface.RegisterFunction<void, bool, &JSI_Renderer::Set##NAME##Enabled>("Renderer_Set" #NAME "Enabled");
|
scriptInterface.RegisterFunction<void, bool, &JSI_Renderer::Set##NAME##Enabled>("Renderer_Set" #NAME "Enabled");
|
||||||
|
|
||||||
void JSI_Renderer::RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
void JSI_Renderer::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
scriptInterface.RegisterFunction<std::string, &JSI_Renderer::GetRenderPath>("Renderer_GetRenderPath");
|
scriptInterface.RegisterFunction<std::string, &JSI_Renderer::GetRenderPath>("Renderer_GetRenderPath");
|
||||||
scriptInterface.RegisterFunction<void, std::string, &JSI_Renderer::SetRenderPath>("Renderer_SetRenderPath");
|
scriptInterface.RegisterFunction<void, std::string, &JSI_Renderer::SetRenderPath>("Renderer_SetRenderPath");
|
||||||
|
@ -47,7 +47,7 @@ namespace JSI_Renderer
|
|||||||
DECLARE_BOOLEAN_SCRIPT_SETTING(Postproc);
|
DECLARE_BOOLEAN_SCRIPT_SETTING(Postproc);
|
||||||
DECLARE_BOOLEAN_SCRIPT_SETTING(DisplayFrustum);
|
DECLARE_BOOLEAN_SCRIPT_SETTING(DisplayFrustum);
|
||||||
|
|
||||||
void RegisterScriptFunctions(ScriptInterface& scriptInterface);
|
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DECLARE_BOOLEAN_SCRIPT_SETTING
|
#undef DECLARE_BOOLEAN_SCRIPT_SETTING
|
||||||
|
@ -59,7 +59,8 @@ template <typename T> struct MaybeRef;
|
|||||||
// Define RegisterFunction<TR, T0..., f>
|
// Define RegisterFunction<TR, T0..., f>
|
||||||
#define OVERLOADS(z, i, data) \
|
#define OVERLOADS(z, i, data) \
|
||||||
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CxPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
|
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CxPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
|
||||||
void RegisterFunction(const char* name) { \
|
void RegisterFunction(const char* name) const \
|
||||||
|
{ \
|
||||||
Register(name, call<R T0_TAIL(z,i), fptr>, nargs<T0(z,i)>()); \
|
Register(name, call<R T0_TAIL(z,i), fptr>, nargs<T0(z,i)>()); \
|
||||||
}
|
}
|
||||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||||
|
@ -56,7 +56,7 @@ struct ScriptInterface_impl
|
|||||||
{
|
{
|
||||||
ScriptInterface_impl(const char* nativeScopeName, const shared_ptr<ScriptRuntime>& runtime);
|
ScriptInterface_impl(const char* nativeScopeName, const shared_ptr<ScriptRuntime>& runtime);
|
||||||
~ScriptInterface_impl();
|
~ScriptInterface_impl();
|
||||||
void Register(const char* name, JSNative fptr, uint nargs);
|
void Register(const char* name, JSNative fptr, uint nargs) const;
|
||||||
|
|
||||||
// Take care to keep this declaration before heap rooted members. Destructors of heap rooted
|
// Take care to keep this declaration before heap rooted members. Destructors of heap rooted
|
||||||
// members have to be called before the runtime destructor.
|
// members have to be called before the runtime destructor.
|
||||||
@ -393,7 +393,7 @@ ScriptInterface_impl::~ScriptInterface_impl()
|
|||||||
JS_DestroyContext(m_cx);
|
JS_DestroyContext(m_cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptInterface_impl::Register(const char* name, JSNative fptr, uint nargs)
|
void ScriptInterface_impl::Register(const char* name, JSNative fptr, uint nargs) const
|
||||||
{
|
{
|
||||||
JSAutoRequest rq(m_cx);
|
JSAutoRequest rq(m_cx);
|
||||||
JS::RootedObject nativeScope(m_cx, m_nativeScope);
|
JS::RootedObject nativeScope(m_cx, m_nativeScope);
|
||||||
@ -489,7 +489,7 @@ bool ScriptInterface::ReplaceNondeterministicRNG(boost::rand48& rng)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptInterface::Register(const char* name, JSNative fptr, size_t nargs)
|
void ScriptInterface::Register(const char* name, JSNative fptr, size_t nargs) const
|
||||||
{
|
{
|
||||||
m->Register(name, fptr, (uint)nargs);
|
m->Register(name, fptr, (uint)nargs);
|
||||||
}
|
}
|
||||||
@ -612,7 +612,7 @@ bool ScriptInterface::SetGlobal_(const char* name, JS::HandleValue value, bool r
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptInterface::SetProperty_(JS::HandleValue obj, const char* name, JS::HandleValue value, bool constant, bool enumerate)
|
bool ScriptInterface::SetProperty_(JS::HandleValue obj, const char* name, JS::HandleValue value, bool constant, bool enumerate) const
|
||||||
{
|
{
|
||||||
JSAutoRequest rq(m->m_cx);
|
JSAutoRequest rq(m->m_cx);
|
||||||
uint attrs = 0;
|
uint attrs = 0;
|
||||||
@ -630,7 +630,7 @@ bool ScriptInterface::SetProperty_(JS::HandleValue obj, const char* name, JS::Ha
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptInterface::SetProperty_(JS::HandleValue obj, const wchar_t* name, JS::HandleValue value, bool constant, bool enumerate)
|
bool ScriptInterface::SetProperty_(JS::HandleValue obj, const wchar_t* name, JS::HandleValue value, bool constant, bool enumerate) const
|
||||||
{
|
{
|
||||||
JSAutoRequest rq(m->m_cx);
|
JSAutoRequest rq(m->m_cx);
|
||||||
uint attrs = 0;
|
uint attrs = 0;
|
||||||
@ -649,7 +649,7 @@ bool ScriptInterface::SetProperty_(JS::HandleValue obj, const wchar_t* name, JS:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptInterface::SetPropertyInt_(JS::HandleValue obj, int name, JS::HandleValue value, bool constant, bool enumerate)
|
bool ScriptInterface::SetPropertyInt_(JS::HandleValue obj, int name, JS::HandleValue value, bool constant, bool enumerate) const
|
||||||
{
|
{
|
||||||
JSAutoRequest rq(m->m_cx);
|
JSAutoRequest rq(m->m_cx);
|
||||||
uint attrs = 0;
|
uint attrs = 0;
|
||||||
@ -1103,7 +1103,7 @@ void ScriptInterface::ForceGC()
|
|||||||
JS_GC(this->GetJSRuntime());
|
JS_GC(this->GetJSRuntime());
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value ScriptInterface::CloneValueFromOtherContext(ScriptInterface& otherContext, JS::HandleValue val)
|
JS::Value ScriptInterface::CloneValueFromOtherContext(const ScriptInterface& otherContext, JS::HandleValue val) const
|
||||||
{
|
{
|
||||||
PROFILE("CloneValueFromOtherContext");
|
PROFILE("CloneValueFromOtherContext");
|
||||||
JSAutoRequest rq(m->m_cx);
|
JSAutoRequest rq(m->m_cx);
|
||||||
@ -1124,7 +1124,7 @@ ScriptInterface::StructuredClone::~StructuredClone()
|
|||||||
JS_ClearStructuredClone(m_Data, m_Size, NULL, NULL);
|
JS_ClearStructuredClone(m_Data, m_Size, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ScriptInterface::StructuredClone> ScriptInterface::WriteStructuredClone(JS::HandleValue v)
|
shared_ptr<ScriptInterface::StructuredClone> ScriptInterface::WriteStructuredClone(JS::HandleValue v) const
|
||||||
{
|
{
|
||||||
JSAutoRequest rq(m->m_cx);
|
JSAutoRequest rq(m->m_cx);
|
||||||
u64* data = NULL;
|
u64* data = NULL;
|
||||||
@ -1141,7 +1141,7 @@ shared_ptr<ScriptInterface::StructuredClone> ScriptInterface::WriteStructuredClo
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptInterface::ReadStructuredClone(const shared_ptr<ScriptInterface::StructuredClone>& ptr, JS::MutableHandleValue ret)
|
void ScriptInterface::ReadStructuredClone(const shared_ptr<ScriptInterface::StructuredClone>& ptr, JS::MutableHandleValue ret) const
|
||||||
{
|
{
|
||||||
JSAutoRequest rq(m->m_cx);
|
JSAutoRequest rq(m->m_cx);
|
||||||
JS_ReadStructuredClone(m->m_cx, ptr->m_Data, ptr->m_Size, JS_STRUCTURED_CLONE_VERSION, ret, NULL, NULL);
|
JS_ReadStructuredClone(m->m_cx, ptr->m_Data, ptr->m_Size, JS_STRUCTURED_CLONE_VERSION, ret, NULL, NULL);
|
||||||
|
@ -151,21 +151,21 @@ public:
|
|||||||
* Optionally makes it {ReadOnly, DontDelete, DontEnum}.
|
* Optionally makes it {ReadOnly, DontDelete, DontEnum}.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool SetProperty(JS::HandleValue obj, const char* name, const T& value, bool constant = false, bool enumerate = true);
|
bool SetProperty(JS::HandleValue obj, const char* name, const T& value, bool constant = false, bool enumerate = true) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the named property on the given object.
|
* Set the named property on the given object.
|
||||||
* Optionally makes it {ReadOnly, DontDelete, DontEnum}.
|
* Optionally makes it {ReadOnly, DontDelete, DontEnum}.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool SetProperty(JS::HandleValue obj, const wchar_t* name, const T& value, bool constant = false, bool enumerate = true);
|
bool SetProperty(JS::HandleValue obj, const wchar_t* name, const T& value, bool constant = false, bool enumerate = true) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the integer-named property on the given object.
|
* Set the integer-named property on the given object.
|
||||||
* Optionally makes it {ReadOnly, DontDelete, DontEnum}.
|
* Optionally makes it {ReadOnly, DontDelete, DontEnum}.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool SetPropertyInt(JS::HandleValue obj, int name, const T& value, bool constant = false, bool enumerate = true);
|
bool SetPropertyInt(JS::HandleValue obj, int name, const T& value, bool constant = false, bool enumerate = true) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the named property on the given object.
|
* Get the named property on the given object.
|
||||||
@ -266,7 +266,7 @@ public:
|
|||||||
* Complex values (functions, XML, etc) won't be cloned correctly, but basic
|
* Complex values (functions, XML, etc) won't be cloned correctly, but basic
|
||||||
* types and cyclic references should be fine.
|
* types and cyclic references should be fine.
|
||||||
*/
|
*/
|
||||||
JS::Value CloneValueFromOtherContext(ScriptInterface& otherContext, JS::HandleValue val);
|
JS::Value CloneValueFromOtherContext(const ScriptInterface& otherContext, JS::HandleValue val) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a jsval to a C++ type. (This might trigger GC.)
|
* Convert a jsval to a C++ type. (This might trigger GC.)
|
||||||
@ -319,8 +319,8 @@ public:
|
|||||||
size_t m_Size;
|
size_t m_Size;
|
||||||
};
|
};
|
||||||
|
|
||||||
shared_ptr<StructuredClone> WriteStructuredClone(JS::HandleValue v);
|
shared_ptr<StructuredClone> WriteStructuredClone(JS::HandleValue v) const;
|
||||||
void ReadStructuredClone(const shared_ptr<StructuredClone>& ptr, JS::MutableHandleValue ret);
|
void ReadStructuredClone(const shared_ptr<StructuredClone>& ptr, JS::MutableHandleValue ret) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts |a| if needed and assigns it to |handle|.
|
* Converts |a| if needed and assigns it to |handle|.
|
||||||
@ -360,9 +360,9 @@ private:
|
|||||||
bool Eval_(const char* code, JS::MutableHandleValue ret) const;
|
bool Eval_(const char* code, JS::MutableHandleValue ret) const;
|
||||||
bool Eval_(const wchar_t* code, JS::MutableHandleValue ret) const;
|
bool Eval_(const wchar_t* code, JS::MutableHandleValue ret) const;
|
||||||
bool SetGlobal_(const char* name, JS::HandleValue value, bool replace);
|
bool SetGlobal_(const char* name, JS::HandleValue value, bool replace);
|
||||||
bool SetProperty_(JS::HandleValue obj, const char* name, JS::HandleValue value, bool readonly, bool enumerate);
|
bool SetProperty_(JS::HandleValue obj, const char* name, JS::HandleValue value, bool readonly, bool enumerate) const;
|
||||||
bool SetProperty_(JS::HandleValue obj, const wchar_t* name, JS::HandleValue value, bool readonly, bool enumerate);
|
bool SetProperty_(JS::HandleValue obj, const wchar_t* name, JS::HandleValue value, bool readonly, bool enumerate) const;
|
||||||
bool SetPropertyInt_(JS::HandleValue obj, int name, JS::HandleValue value, bool readonly, bool enumerate);
|
bool SetPropertyInt_(JS::HandleValue obj, int name, JS::HandleValue value, bool readonly, bool enumerate) const;
|
||||||
bool GetProperty_(JS::HandleValue obj, const char* name, JS::MutableHandleValue out) const;
|
bool GetProperty_(JS::HandleValue obj, const char* name, JS::MutableHandleValue out) const;
|
||||||
bool GetPropertyInt_(JS::HandleValue obj, int name, JS::MutableHandleValue value) const;
|
bool GetPropertyInt_(JS::HandleValue obj, int name, JS::MutableHandleValue value) const;
|
||||||
static bool IsExceptionPending(JSContext* cx);
|
static bool IsExceptionPending(JSContext* cx);
|
||||||
@ -394,7 +394,7 @@ private:
|
|||||||
JSClass* m_Class;
|
JSClass* m_Class;
|
||||||
JSNative m_Constructor;
|
JSNative m_Constructor;
|
||||||
};
|
};
|
||||||
void Register(const char* name, JSNative fptr, size_t nargs);
|
void Register(const char* name, JSNative fptr, size_t nargs) const;
|
||||||
|
|
||||||
// Take care to keep this declaration before heap rooted members. Destructors of heap rooted
|
// Take care to keep this declaration before heap rooted members. Destructors of heap rooted
|
||||||
// members have to be called before the runtime destructor.
|
// members have to be called before the runtime destructor.
|
||||||
@ -409,7 +409,7 @@ public:
|
|||||||
// This declares:
|
// This declares:
|
||||||
//
|
//
|
||||||
// template <R, T0..., TR (*fptr) (void* cbdata, T0...)>
|
// template <R, T0..., TR (*fptr) (void* cbdata, T0...)>
|
||||||
// void RegisterFunction(const char* functionName);
|
// void RegisterFunction(const char* functionName) const;
|
||||||
//
|
//
|
||||||
// template <R, T0..., TR (*fptr) (void* cbdata, T0...)>
|
// template <R, T0..., TR (*fptr) (void* cbdata, T0...)>
|
||||||
// static JSNative call;
|
// static JSNative call;
|
||||||
@ -494,7 +494,7 @@ bool ScriptInterface::SetGlobal(const char* name, const T& value, bool replace)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool ScriptInterface::SetProperty(JS::HandleValue obj, const char* name, const T& value, bool readonly, bool enumerate)
|
bool ScriptInterface::SetProperty(JS::HandleValue obj, const char* name, const T& value, bool readonly, bool enumerate) const
|
||||||
{
|
{
|
||||||
JSAutoRequest rq(GetContext());
|
JSAutoRequest rq(GetContext());
|
||||||
JS::RootedValue val(GetContext());
|
JS::RootedValue val(GetContext());
|
||||||
@ -503,7 +503,7 @@ bool ScriptInterface::SetProperty(JS::HandleValue obj, const char* name, const T
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool ScriptInterface::SetProperty(JS::HandleValue obj, const wchar_t* name, const T& value, bool readonly, bool enumerate)
|
bool ScriptInterface::SetProperty(JS::HandleValue obj, const wchar_t* name, const T& value, bool readonly, bool enumerate) const
|
||||||
{
|
{
|
||||||
JSAutoRequest rq(GetContext());
|
JSAutoRequest rq(GetContext());
|
||||||
JS::RootedValue val(GetContext());
|
JS::RootedValue val(GetContext());
|
||||||
@ -512,7 +512,7 @@ bool ScriptInterface::SetProperty(JS::HandleValue obj, const wchar_t* name, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool ScriptInterface::SetPropertyInt(JS::HandleValue obj, int name, const T& value, bool readonly, bool enumerate)
|
bool ScriptInterface::SetPropertyInt(JS::HandleValue obj, int name, const T& value, bool readonly, bool enumerate) const
|
||||||
{
|
{
|
||||||
JSAutoRequest rq(GetContext());
|
JSAutoRequest rq(GetContext());
|
||||||
JS::RootedValue val(GetContext());
|
JS::RootedValue val(GetContext());
|
||||||
|
@ -188,7 +188,7 @@ public:
|
|||||||
handle_templates_test(script, val, &out, nbrVal);
|
handle_templates_test(script, val, &out, nbrVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_templates_test(ScriptInterface& script, JS::HandleValue val, JS::MutableHandleValue out, JS::HandleValue nbrVal)
|
void handle_templates_test(const ScriptInterface& script, JS::HandleValue val, JS::MutableHandleValue out, JS::HandleValue nbrVal)
|
||||||
{
|
{
|
||||||
int nbr = 0;
|
int nbr = 0;
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
virtual int GetType() const { return MT_##name; } \
|
virtual int GetType() const { return MT_##name; } \
|
||||||
virtual const char* GetScriptHandlerName() const { return "On" #name; } \
|
virtual const char* GetScriptHandlerName() const { return "On" #name; } \
|
||||||
virtual const char* GetScriptGlobalHandlerName() const { return "OnGlobal" #name; } \
|
virtual const char* GetScriptGlobalHandlerName() const { return "OnGlobal" #name; } \
|
||||||
virtual JS::Value ToJSVal(ScriptInterface& scriptInterface) const; \
|
virtual JS::Value ToJSVal(const ScriptInterface& scriptInterface) const; \
|
||||||
static CMessage* FromJSVal(ScriptInterface&, JS::HandleValue val);
|
static CMessage* FromJSVal(const ScriptInterface&, JS::HandleValue val);
|
||||||
|
|
||||||
class SceneCollector;
|
class SceneCollector;
|
||||||
class CFrustum;
|
class CFrustum;
|
||||||
|
@ -161,7 +161,7 @@ public:
|
|||||||
SerializationTestState* primaryStateBefore, SerializationTestState* primaryStateAfter,
|
SerializationTestState* primaryStateBefore, SerializationTestState* primaryStateAfter,
|
||||||
SerializationTestState* secondaryStateBefore, SerializationTestState* secondaryStateAfter);
|
SerializationTestState* secondaryStateBefore, SerializationTestState* secondaryStateAfter);
|
||||||
|
|
||||||
static std::vector<SimulationCommand> CloneCommandsFromOtherContext(ScriptInterface& oldScript, ScriptInterface& newScript,
|
static std::vector<SimulationCommand> CloneCommandsFromOtherContext(const ScriptInterface& oldScript, const ScriptInterface& newScript,
|
||||||
const std::vector<SimulationCommand>& commands)
|
const std::vector<SimulationCommand>& commands)
|
||||||
{
|
{
|
||||||
JSContext* cxOld = oldScript.GetContext();
|
JSContext* cxOld = oldScript.GetContext();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -38,7 +38,7 @@ struct GetAIsHelper
|
|||||||
{
|
{
|
||||||
NONCOPYABLE(GetAIsHelper);
|
NONCOPYABLE(GetAIsHelper);
|
||||||
public:
|
public:
|
||||||
GetAIsHelper(ScriptInterface& scriptInterface) :
|
GetAIsHelper(const ScriptInterface& scriptInterface) :
|
||||||
m_ScriptInterface(scriptInterface),
|
m_ScriptInterface(scriptInterface),
|
||||||
m_AIs(scriptInterface.GetJSRuntime())
|
m_AIs(scriptInterface.GetJSRuntime())
|
||||||
{
|
{
|
||||||
@ -78,10 +78,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
JS::PersistentRootedObject m_AIs;
|
JS::PersistentRootedObject m_AIs;
|
||||||
ScriptInterface& m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
JS::Value ICmpAIManager::GetAIs(ScriptInterface& scriptInterface)
|
JS::Value ICmpAIManager::GetAIs(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
GetAIsHelper helper(scriptInterface);
|
GetAIsHelper helper(scriptInterface);
|
||||||
helper.Run();
|
helper.Run();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2011 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -51,7 +51,7 @@ public:
|
|||||||
* Returns a vector of {"id":"value-for-AddPlayer", "name":"Human readable name"}
|
* Returns a vector of {"id":"value-for-AddPlayer", "name":"Human readable name"}
|
||||||
* objects, based on all the available AI scripts.
|
* objects, based on all the available AI scripts.
|
||||||
*/
|
*/
|
||||||
static JS::Value GetAIs(ScriptInterface& scriptInterface);
|
static JS::Value GetAIs(const ScriptInterface& scriptInterface);
|
||||||
|
|
||||||
DECLARE_INTERFACE_TYPE(AIManager)
|
DECLARE_INTERFACE_TYPE(AIManager)
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -36,7 +36,7 @@ public:
|
|||||||
g_VFS.reset();
|
g_VFS.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load_script(ScriptInterface& scriptInterface, const VfsPath& pathname)
|
static void load_script(const ScriptInterface& scriptInterface, const VfsPath& pathname)
|
||||||
{
|
{
|
||||||
CVFSFile file;
|
CVFSFile file;
|
||||||
TS_ASSERT_EQUALS(file.Load(g_VFS, pathname), PSRETURN_OK);
|
TS_ASSERT_EQUALS(file.Load(g_VFS, pathname), PSRETURN_OK);
|
||||||
|
@ -505,7 +505,7 @@ But for now everything is put in there.)
|
|||||||
Now you have to add C++/JS conversions into MessageTypeConversions.cpp, so scripts can send and receive messages:
|
Now you have to add C++/JS conversions into MessageTypeConversions.cpp, so scripts can send and receive messages:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
JS::Value CMessageExample::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageExample::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(x);
|
SET_MSG_PROPERTY(x);
|
||||||
@ -513,7 +513,7 @@ JS::Value CMessageExample::ToJSVal(ScriptInterface& scriptInterface) const
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageExample::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageExample::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(int, x);
|
GET_MSG_PROPERTY(int, x);
|
||||||
@ -528,12 +528,12 @@ with a set of scalar fields.)
|
|||||||
If you don't want to support scripts sending/receiving the message, you can implement stub functions instead:
|
If you don't want to support scripts sending/receiving the message, you can implement stub functions instead:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
JS::Value CMessageExample::ToJSVal(ScriptInterface& UNUSED(scriptInterface)) const
|
JS::Value CMessageExample::ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const
|
||||||
{
|
{
|
||||||
return JS::UndefinedValue();
|
return JS::UndefinedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageExample::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageExample::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value CMessage::ToJSValCached(ScriptInterface& scriptInterface) const
|
JS::Value CMessage::ToJSValCached(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
if (!m_Cached)
|
if (!m_Cached)
|
||||||
m_Cached.reset(new JS::PersistentRootedValue(scriptInterface.GetJSRuntime(), ToJSVal(scriptInterface)));
|
m_Cached.reset(new JS::PersistentRootedValue(scriptInterface.GetJSRuntime(), ToJSVal(scriptInterface)));
|
||||||
@ -62,13 +62,13 @@ JS::Value CMessage::ToJSValCached(ScriptInterface& scriptInterface) const
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageTurnStart::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageTurnStart::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageTurnStart::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageTurnStart::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
return new CMessageTurnStart();
|
return new CMessageTurnStart();
|
||||||
}
|
}
|
||||||
@ -76,13 +76,13 @@ CMessage* CMessageTurnStart::FromJSVal(ScriptInterface& UNUSED(scriptInterface),
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
#define MESSAGE_1(name, t0, a0) \
|
#define MESSAGE_1(name, t0, a0) \
|
||||||
JS::Value CMessage##name::ToJSVal(ScriptInterface& scriptInterface) const \
|
JS::Value CMessage##name::ToJSVal(const ScriptInterface& scriptInterface) const \
|
||||||
{ \
|
{ \
|
||||||
TOJSVAL_SETUP(); \
|
TOJSVAL_SETUP(); \
|
||||||
SET_MSG_PROPERTY(a0); \
|
SET_MSG_PROPERTY(a0); \
|
||||||
return JS::ObjectValue(*obj); \
|
return JS::ObjectValue(*obj); \
|
||||||
} \
|
} \
|
||||||
CMessage* CMessage##name::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val) \
|
CMessage* CMessage##name::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val) \
|
||||||
{ \
|
{ \
|
||||||
FROMJSVAL_SETUP(); \
|
FROMJSVAL_SETUP(); \
|
||||||
GET_MSG_PROPERTY(t0, a0); \
|
GET_MSG_PROPERTY(t0, a0); \
|
||||||
@ -96,7 +96,7 @@ MESSAGE_1(Update_Final, fixed, turnLength)
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageInterpolate::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageInterpolate::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(deltaSimTime);
|
SET_MSG_PROPERTY(deltaSimTime);
|
||||||
@ -105,7 +105,7 @@ JS::Value CMessageInterpolate::ToJSVal(ScriptInterface& scriptInterface) const
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageInterpolate::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageInterpolate::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(float, deltaSimTime);
|
GET_MSG_PROPERTY(float, deltaSimTime);
|
||||||
@ -116,13 +116,13 @@ CMessage* CMessageInterpolate::FromJSVal(ScriptInterface& scriptInterface, JS::H
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageRenderSubmit::ToJSVal(ScriptInterface& UNUSED(scriptInterface)) const
|
JS::Value CMessageRenderSubmit::ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const
|
||||||
{
|
{
|
||||||
LOGWARNING("CMessageRenderSubmit::ToJSVal not implemented");
|
LOGWARNING("CMessageRenderSubmit::ToJSVal not implemented");
|
||||||
return JS::UndefinedValue();
|
return JS::UndefinedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageRenderSubmit::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageRenderSubmit::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
LOGWARNING("CMessageRenderSubmit::FromJSVal not implemented");
|
LOGWARNING("CMessageRenderSubmit::FromJSVal not implemented");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -130,13 +130,13 @@ CMessage* CMessageRenderSubmit::FromJSVal(ScriptInterface& UNUSED(scriptInterfac
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageProgressiveLoad::ToJSVal(ScriptInterface& UNUSED(scriptInterface)) const
|
JS::Value CMessageProgressiveLoad::ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const
|
||||||
{
|
{
|
||||||
LOGWARNING("CMessageProgressiveLoad::ToJSVal not implemented");
|
LOGWARNING("CMessageProgressiveLoad::ToJSVal not implemented");
|
||||||
return JS::UndefinedValue();
|
return JS::UndefinedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageProgressiveLoad::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageProgressiveLoad::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
LOGWARNING("CMessageProgressiveLoad::FromJSVal not implemented");
|
LOGWARNING("CMessageProgressiveLoad::FromJSVal not implemented");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -144,13 +144,13 @@ CMessage* CMessageProgressiveLoad::FromJSVal(ScriptInterface& UNUSED(scriptInter
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageDeserialized::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageDeserialized::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageDeserialized::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageDeserialized::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
return new CMessageDeserialized();
|
return new CMessageDeserialized();
|
||||||
@ -158,14 +158,14 @@ CMessage* CMessageDeserialized::FromJSVal(ScriptInterface& scriptInterface, JS::
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageCreate::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageCreate::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(entity);
|
SET_MSG_PROPERTY(entity);
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageCreate::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageCreate::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(entity_id_t, entity);
|
GET_MSG_PROPERTY(entity_id_t, entity);
|
||||||
@ -174,14 +174,14 @@ CMessage* CMessageCreate::FromJSVal(ScriptInterface& scriptInterface, JS::Handle
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageDestroy::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageDestroy::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(entity);
|
SET_MSG_PROPERTY(entity);
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageDestroy::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageDestroy::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(entity_id_t, entity);
|
GET_MSG_PROPERTY(entity_id_t, entity);
|
||||||
@ -190,7 +190,7 @@ CMessage* CMessageDestroy::FromJSVal(ScriptInterface& scriptInterface, JS::Handl
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageOwnershipChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageOwnershipChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(entity);
|
SET_MSG_PROPERTY(entity);
|
||||||
@ -199,7 +199,7 @@ JS::Value CMessageOwnershipChanged::ToJSVal(ScriptInterface& scriptInterface) co
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageOwnershipChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageOwnershipChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(entity_id_t, entity);
|
GET_MSG_PROPERTY(entity_id_t, entity);
|
||||||
@ -210,7 +210,7 @@ CMessage* CMessageOwnershipChanged::FromJSVal(ScriptInterface& scriptInterface,
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessagePositionChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessagePositionChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(entity);
|
SET_MSG_PROPERTY(entity);
|
||||||
@ -221,7 +221,7 @@ JS::Value CMessagePositionChanged::ToJSVal(ScriptInterface& scriptInterface) con
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessagePositionChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessagePositionChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(entity_id_t, entity);
|
GET_MSG_PROPERTY(entity_id_t, entity);
|
||||||
@ -234,13 +234,13 @@ CMessage* CMessagePositionChanged::FromJSVal(ScriptInterface& scriptInterface, J
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageInterpolatedPositionChanged::ToJSVal(ScriptInterface& UNUSED(scriptInterface)) const
|
JS::Value CMessageInterpolatedPositionChanged::ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const
|
||||||
{
|
{
|
||||||
LOGWARNING("CMessageInterpolatedPositionChanged::ToJSVal not implemented");
|
LOGWARNING("CMessageInterpolatedPositionChanged::ToJSVal not implemented");
|
||||||
return JS::UndefinedValue();
|
return JS::UndefinedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageInterpolatedPositionChanged::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageInterpolatedPositionChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
LOGWARNING("CMessageInterpolatedPositionChanged::FromJSVal not implemented");
|
LOGWARNING("CMessageInterpolatedPositionChanged::FromJSVal not implemented");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -248,7 +248,7 @@ CMessage* CMessageInterpolatedPositionChanged::FromJSVal(ScriptInterface& UNUSED
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageTerritoryPositionChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageTerritoryPositionChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(entity);
|
SET_MSG_PROPERTY(entity);
|
||||||
@ -256,7 +256,7 @@ JS::Value CMessageTerritoryPositionChanged::ToJSVal(ScriptInterface& scriptInter
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageTerritoryPositionChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageTerritoryPositionChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(entity_id_t, entity);
|
GET_MSG_PROPERTY(entity_id_t, entity);
|
||||||
@ -266,7 +266,7 @@ CMessage* CMessageTerritoryPositionChanged::FromJSVal(ScriptInterface& scriptInt
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageMotionChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageMotionChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(starting);
|
SET_MSG_PROPERTY(starting);
|
||||||
@ -274,7 +274,7 @@ JS::Value CMessageMotionChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageMotionChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageMotionChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(bool, starting);
|
GET_MSG_PROPERTY(bool, starting);
|
||||||
@ -284,7 +284,7 @@ CMessage* CMessageMotionChanged::FromJSVal(ScriptInterface& scriptInterface, JS:
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageTerrainChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageTerrainChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(i0);
|
SET_MSG_PROPERTY(i0);
|
||||||
@ -294,7 +294,7 @@ JS::Value CMessageTerrainChanged::ToJSVal(ScriptInterface& scriptInterface) cons
|
|||||||
return OBJECT_TO_JSVAL(obj);
|
return OBJECT_TO_JSVAL(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageTerrainChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageTerrainChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(int32_t, i0);
|
GET_MSG_PROPERTY(int32_t, i0);
|
||||||
@ -306,7 +306,7 @@ CMessage* CMessageTerrainChanged::FromJSVal(ScriptInterface& scriptInterface, JS
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageVisibilityChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageVisibilityChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(player);
|
SET_MSG_PROPERTY(player);
|
||||||
@ -316,7 +316,7 @@ JS::Value CMessageVisibilityChanged::ToJSVal(ScriptInterface& scriptInterface) c
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageVisibilityChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageVisibilityChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(player_id_t, player);
|
GET_MSG_PROPERTY(player_id_t, player);
|
||||||
@ -328,46 +328,46 @@ CMessage* CMessageVisibilityChanged::FromJSVal(ScriptInterface& scriptInterface,
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageWaterChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageWaterChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
return OBJECT_TO_JSVAL(obj);
|
return OBJECT_TO_JSVAL(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageWaterChanged::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageWaterChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
return new CMessageWaterChanged();
|
return new CMessageWaterChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageObstructionMapShapeChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageObstructionMapShapeChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageObstructionMapShapeChanged::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageObstructionMapShapeChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
return new CMessageObstructionMapShapeChanged();
|
return new CMessageObstructionMapShapeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageTerritoriesChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageTerritoriesChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageTerritoriesChanged::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageTerritoriesChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
return new CMessageTerritoriesChanged();
|
return new CMessageTerritoriesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageRangeUpdate::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageRangeUpdate::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(tag);
|
SET_MSG_PROPERTY(tag);
|
||||||
@ -376,7 +376,7 @@ JS::Value CMessageRangeUpdate::ToJSVal(ScriptInterface& scriptInterface) const
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageRangeUpdate::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageRangeUpdate::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
LOGWARNING("CMessageRangeUpdate::FromJSVal not implemented");
|
LOGWARNING("CMessageRangeUpdate::FromJSVal not implemented");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -384,13 +384,13 @@ CMessage* CMessageRangeUpdate::FromJSVal(ScriptInterface& UNUSED(scriptInterface
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessagePathResult::ToJSVal(ScriptInterface& UNUSED(scriptInterface)) const
|
JS::Value CMessagePathResult::ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const
|
||||||
{
|
{
|
||||||
LOGWARNING("CMessagePathResult::ToJSVal not implemented");
|
LOGWARNING("CMessagePathResult::ToJSVal not implemented");
|
||||||
return JS::UndefinedValue();
|
return JS::UndefinedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessagePathResult::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessagePathResult::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
LOGWARNING("CMessagePathResult::FromJSVal not implemented");
|
LOGWARNING("CMessagePathResult::FromJSVal not implemented");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -398,7 +398,7 @@ CMessage* CMessagePathResult::FromJSVal(ScriptInterface& UNUSED(scriptInterface)
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageValueModification::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageValueModification::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(entities);
|
SET_MSG_PROPERTY(entities);
|
||||||
@ -407,7 +407,7 @@ JS::Value CMessageValueModification::ToJSVal(ScriptInterface& scriptInterface) c
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageValueModification::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageValueModification::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(std::vector<entity_id_t>, entities);
|
GET_MSG_PROPERTY(std::vector<entity_id_t>, entities);
|
||||||
@ -418,7 +418,7 @@ CMessage* CMessageValueModification::FromJSVal(ScriptInterface& scriptInterface,
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageTemplateModification::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageTemplateModification::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(player);
|
SET_MSG_PROPERTY(player);
|
||||||
@ -427,7 +427,7 @@ JS::Value CMessageTemplateModification::ToJSVal(ScriptInterface& scriptInterface
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageTemplateModification::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageTemplateModification::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(player_id_t, player);
|
GET_MSG_PROPERTY(player_id_t, player);
|
||||||
@ -438,7 +438,7 @@ CMessage* CMessageTemplateModification::FromJSVal(ScriptInterface& scriptInterfa
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageVisionRangeChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageVisionRangeChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(entity);
|
SET_MSG_PROPERTY(entity);
|
||||||
@ -447,7 +447,7 @@ JS::Value CMessageVisionRangeChanged::ToJSVal(ScriptInterface& scriptInterface)
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageVisionRangeChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageVisionRangeChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(entity_id_t, entity);
|
GET_MSG_PROPERTY(entity_id_t, entity);
|
||||||
@ -456,7 +456,7 @@ CMessage* CMessageVisionRangeChanged::FromJSVal(ScriptInterface& scriptInterface
|
|||||||
return new CMessageVisionRangeChanged(entity, oldRange, newRange);
|
return new CMessageVisionRangeChanged(entity, oldRange, newRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value CMessageVisionSharingChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageVisionSharingChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(entity);
|
SET_MSG_PROPERTY(entity);
|
||||||
@ -465,7 +465,7 @@ JS::Value CMessageVisionSharingChanged::ToJSVal(ScriptInterface& scriptInterface
|
|||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageVisionSharingChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageVisionSharingChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(entity_id_t, entity);
|
GET_MSG_PROPERTY(entity_id_t, entity);
|
||||||
@ -476,27 +476,27 @@ CMessage* CMessageVisionSharingChanged::FromJSVal(ScriptInterface& scriptInterfa
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageMinimapPing::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageMinimapPing::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageMinimapPing::FromJSVal(ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
CMessage* CMessageMinimapPing::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
|
||||||
{
|
{
|
||||||
return new CMessageMinimapPing();
|
return new CMessageMinimapPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageCinemaPathEnded::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageCinemaPathEnded::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(name);
|
SET_MSG_PROPERTY(name);
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageCinemaPathEnded::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageCinemaPathEnded::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(CStrW, name);
|
GET_MSG_PROPERTY(CStrW, name);
|
||||||
@ -505,13 +505,13 @@ CMessage* CMessageCinemaPathEnded::FromJSVal(ScriptInterface& scriptInterface, J
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessageCinemaQueueEnded::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessageCinemaQueueEnded::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessageCinemaQueueEnded::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessageCinemaQueueEnded::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
return new CMessageCinemaQueueEnded();
|
return new CMessageCinemaQueueEnded();
|
||||||
@ -519,14 +519,14 @@ CMessage* CMessageCinemaQueueEnded::FromJSVal(ScriptInterface& scriptInterface,
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
JS::Value CMessagePlayerColorChanged::ToJSVal(ScriptInterface& scriptInterface) const
|
JS::Value CMessagePlayerColorChanged::ToJSVal(const ScriptInterface& scriptInterface) const
|
||||||
{
|
{
|
||||||
TOJSVAL_SETUP();
|
TOJSVAL_SETUP();
|
||||||
SET_MSG_PROPERTY(player);
|
SET_MSG_PROPERTY(player);
|
||||||
return JS::ObjectValue(*obj);
|
return JS::ObjectValue(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMessage* CMessagePlayerColorChanged::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
|
CMessage* CMessagePlayerColorChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
FROMJSVAL_SETUP();
|
FROMJSVAL_SETUP();
|
||||||
GET_MSG_PROPERTY(player_id_t, player);
|
GET_MSG_PROPERTY(player_id_t, player);
|
||||||
@ -535,7 +535,7 @@ CMessage* CMessagePlayerColorChanged::FromJSVal(ScriptInterface& scriptInterface
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CMessage* CMessageFromJSVal(int mtid, ScriptInterface& scriptingInterface, JS::HandleValue val)
|
CMessage* CMessageFromJSVal(int mtid, const ScriptInterface& scriptingInterface, JS::HandleValue val)
|
||||||
{
|
{
|
||||||
switch (mtid)
|
switch (mtid)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -22,7 +22,7 @@
|
|||||||
#include "simulation2/serialization/ISerializer.h"
|
#include "simulation2/serialization/ISerializer.h"
|
||||||
#include "simulation2/serialization/IDeserializer.h"
|
#include "simulation2/serialization/IDeserializer.h"
|
||||||
|
|
||||||
CComponentTypeScript::CComponentTypeScript(ScriptInterface& scriptInterface, JS::HandleValue instance) :
|
CComponentTypeScript::CComponentTypeScript(const ScriptInterface& scriptInterface, JS::HandleValue instance) :
|
||||||
m_ScriptInterface(scriptInterface), m_Instance(scriptInterface.GetJSRuntime(), instance)
|
m_ScriptInterface(scriptInterface), m_Instance(scriptInterface.GetJSRuntime(), instance)
|
||||||
{
|
{
|
||||||
// Cache the property detection for efficiency
|
// Cache the property detection for efficiency
|
||||||
|
@ -31,7 +31,7 @@ class CComponentTypeScript
|
|||||||
{
|
{
|
||||||
NONCOPYABLE(CComponentTypeScript);
|
NONCOPYABLE(CComponentTypeScript);
|
||||||
public:
|
public:
|
||||||
CComponentTypeScript(ScriptInterface& scriptInterface, JS::HandleValue instance);
|
CComponentTypeScript(const ScriptInterface& scriptInterface, JS::HandleValue instance);
|
||||||
|
|
||||||
JS::Value GetInstance() const { return m_Instance.get(); }
|
JS::Value GetInstance() const { return m_Instance.get(); }
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScriptInterface& m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
JS::PersistentRootedValue m_Instance;
|
JS::PersistentRootedValue m_Instance;
|
||||||
bool m_HasCustomSerialize;
|
bool m_HasCustomSerialize;
|
||||||
bool m_HasCustomDeserialize;
|
bool m_HasCustomDeserialize;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2016 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -54,7 +54,7 @@ static u8 GetArrayType(js::Scalar::Type arrayType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CBinarySerializerScriptImpl::CBinarySerializerScriptImpl(ScriptInterface& scriptInterface, ISerializer& serializer) :
|
CBinarySerializerScriptImpl::CBinarySerializerScriptImpl(const ScriptInterface& scriptInterface, ISerializer& serializer) :
|
||||||
m_ScriptInterface(scriptInterface), m_Serializer(serializer), m_ScriptBackrefs(scriptInterface.GetRuntime()),
|
m_ScriptInterface(scriptInterface), m_Serializer(serializer), m_ScriptBackrefs(scriptInterface.GetRuntime()),
|
||||||
m_SerializablePrototypes(new ObjectIdCache<std::wstring>(scriptInterface.GetRuntime())), m_ScriptBackrefsNext(1)
|
m_SerializablePrototypes(new ObjectIdCache<std::wstring>(scriptInterface.GetRuntime())), m_ScriptBackrefsNext(1)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -83,13 +83,13 @@ protected:
|
|||||||
class CBinarySerializerScriptImpl
|
class CBinarySerializerScriptImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBinarySerializerScriptImpl(ScriptInterface& scriptInterface, ISerializer& serializer);
|
CBinarySerializerScriptImpl(const ScriptInterface& scriptInterface, ISerializer& serializer);
|
||||||
|
|
||||||
void ScriptString(const char* name, JS::HandleString string);
|
void ScriptString(const char* name, JS::HandleString string);
|
||||||
void HandleScriptVal(JS::HandleValue val);
|
void HandleScriptVal(JS::HandleValue val);
|
||||||
void SetSerializablePrototypes(shared_ptr<ObjectIdCache<std::wstring> > prototypes);
|
void SetSerializablePrototypes(shared_ptr<ObjectIdCache<std::wstring> > prototypes);
|
||||||
private:
|
private:
|
||||||
ScriptInterface& m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
ISerializer& m_Serializer;
|
ISerializer& m_Serializer;
|
||||||
|
|
||||||
ObjectIdCache<u32> m_ScriptBackrefs;
|
ObjectIdCache<u32> m_ScriptBackrefs;
|
||||||
@ -111,7 +111,7 @@ class CBinarySerializer : public ISerializer
|
|||||||
{
|
{
|
||||||
NONCOPYABLE(CBinarySerializer);
|
NONCOPYABLE(CBinarySerializer);
|
||||||
public:
|
public:
|
||||||
CBinarySerializer(ScriptInterface& scriptInterface) :
|
CBinarySerializer(const ScriptInterface& scriptInterface) :
|
||||||
m_ScriptImpl(new CBinarySerializerScriptImpl(scriptInterface, *this)),
|
m_ScriptImpl(new CBinarySerializerScriptImpl(scriptInterface, *this)),
|
||||||
m_RawStreamBuf(m_Impl),
|
m_RawStreamBuf(m_Impl),
|
||||||
m_RawStream(&m_RawStreamBuf)
|
m_RawStream(&m_RawStreamBuf)
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename A>
|
template <typename A>
|
||||||
CBinarySerializer(ScriptInterface& scriptInterface, A& a) :
|
CBinarySerializer(const ScriptInterface& scriptInterface, A& a) :
|
||||||
m_ScriptImpl(new CBinarySerializerScriptImpl(scriptInterface, *this)),
|
m_ScriptImpl(new CBinarySerializerScriptImpl(scriptInterface, *this)),
|
||||||
m_Impl(a),
|
m_Impl(a),
|
||||||
m_RawStreamBuf(m_Impl),
|
m_RawStreamBuf(m_Impl),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2011 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -52,7 +52,7 @@ std::string canonfloat(T value, int prec)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
CDebugSerializer::CDebugSerializer(ScriptInterface& scriptInterface, std::ostream& stream, bool includeDebugInfo) :
|
CDebugSerializer::CDebugSerializer(const ScriptInterface& scriptInterface, std::ostream& stream, bool includeDebugInfo) :
|
||||||
m_ScriptInterface(scriptInterface), m_Stream(stream), m_IsDebug(includeDebugInfo), m_Indent(0)
|
m_ScriptInterface(scriptInterface), m_Stream(stream), m_IsDebug(includeDebugInfo), m_Indent(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2011 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -32,7 +32,7 @@ public:
|
|||||||
* @param stream Stream to receive UTF-8 encoded output
|
* @param stream Stream to receive UTF-8 encoded output
|
||||||
* @param includeDebugInfo If true then additional non-deterministic data will be included in the output
|
* @param includeDebugInfo If true then additional non-deterministic data will be included in the output
|
||||||
*/
|
*/
|
||||||
CDebugSerializer(ScriptInterface& scriptInterface, std::ostream& stream, bool includeDebugInfo = true);
|
CDebugSerializer(const ScriptInterface& scriptInterface, std::ostream& stream, bool includeDebugInfo = true);
|
||||||
|
|
||||||
void Comment(const std::string& comment);
|
void Comment(const std::string& comment);
|
||||||
void TextLine(const std::string& text);
|
void TextLine(const std::string& text);
|
||||||
@ -58,7 +58,7 @@ protected:
|
|||||||
virtual void PutRaw(const char* name, const u8* data, size_t len);
|
virtual void PutRaw(const char* name, const u8* data, size_t len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScriptInterface& m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
std::ostream& m_Stream;
|
std::ostream& m_Stream;
|
||||||
bool m_IsDebug;
|
bool m_IsDebug;
|
||||||
int m_Indent;
|
int m_Indent;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2010 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "HashSerializer.h"
|
#include "HashSerializer.h"
|
||||||
|
|
||||||
CHashSerializer::CHashSerializer(ScriptInterface& scriptInterface) :
|
CHashSerializer::CHashSerializer(const ScriptInterface& scriptInterface) :
|
||||||
CBinarySerializer<CHashSerializerImpl>(scriptInterface)
|
CBinarySerializer<CHashSerializerImpl>(scriptInterface)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2010 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -45,7 +45,7 @@ private:
|
|||||||
class CHashSerializer : public CBinarySerializer<CHashSerializerImpl>
|
class CHashSerializer : public CBinarySerializer<CHashSerializerImpl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CHashSerializer(ScriptInterface& scriptInterface);
|
CHashSerializer(const ScriptInterface& scriptInterface);
|
||||||
|
|
||||||
size_t GetHashLength();
|
size_t GetHashLength();
|
||||||
const u8* ComputeHash();
|
const u8* ComputeHash();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2016 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include "lib/byte_order.h"
|
#include "lib/byte_order.h"
|
||||||
|
|
||||||
CStdDeserializer::CStdDeserializer(ScriptInterface& scriptInterface, std::istream& stream) :
|
CStdDeserializer::CStdDeserializer(const ScriptInterface& scriptInterface, std::istream& stream) :
|
||||||
m_ScriptInterface(scriptInterface), m_Stream(stream),
|
m_ScriptInterface(scriptInterface), m_Stream(stream),
|
||||||
m_dummyObject(scriptInterface.GetJSRuntime())
|
m_dummyObject(scriptInterface.GetJSRuntime())
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2016 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -28,7 +28,7 @@ class CStdDeserializer : public IDeserializer
|
|||||||
{
|
{
|
||||||
NONCOPYABLE(CStdDeserializer);
|
NONCOPYABLE(CStdDeserializer);
|
||||||
public:
|
public:
|
||||||
CStdDeserializer(ScriptInterface& scriptInterface, std::istream& stream);
|
CStdDeserializer(const ScriptInterface& scriptInterface, std::istream& stream);
|
||||||
virtual ~CStdDeserializer();
|
virtual ~CStdDeserializer();
|
||||||
|
|
||||||
virtual void ScriptVal(const char* name, JS::MutableHandleValue out);
|
virtual void ScriptVal(const char* name, JS::MutableHandleValue out);
|
||||||
@ -57,7 +57,7 @@ private:
|
|||||||
std::vector<JS::Heap<JSObject*> > m_ScriptBackrefs;
|
std::vector<JS::Heap<JSObject*> > m_ScriptBackrefs;
|
||||||
JS::PersistentRooted<JSObject*> m_dummyObject;
|
JS::PersistentRooted<JSObject*> m_dummyObject;
|
||||||
|
|
||||||
ScriptInterface& m_ScriptInterface;
|
const ScriptInterface& m_ScriptInterface;
|
||||||
|
|
||||||
std::istream& m_Stream;
|
std::istream& m_Stream;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2011 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -24,7 +24,7 @@ CStdSerializerImpl::CStdSerializerImpl(std::ostream& stream) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CStdSerializer::CStdSerializer(ScriptInterface& scriptInterface, std::ostream& stream) :
|
CStdSerializer::CStdSerializer(const ScriptInterface& scriptInterface, std::ostream& stream) :
|
||||||
CBinarySerializer<CStdSerializerImpl>(scriptInterface, stream)
|
CBinarySerializer<CStdSerializerImpl>(scriptInterface, stream)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2015 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -59,7 +59,7 @@ private:
|
|||||||
class CStdSerializer : public CBinarySerializer<CStdSerializerImpl>
|
class CStdSerializer : public CBinarySerializer<CStdSerializerImpl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CStdSerializer(ScriptInterface& scriptInterface, std::ostream& stream);
|
CStdSerializer(const ScriptInterface& scriptInterface, std::ostream& stream);
|
||||||
|
|
||||||
virtual std::ostream& GetStream();
|
virtual std::ostream& GetStream();
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2010 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -42,7 +42,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define DEFAULT_COMPONENT_ALLOCATOR(cname) \
|
#define DEFAULT_COMPONENT_ALLOCATOR(cname) \
|
||||||
static IComponent* Allocate(ScriptInterface&, JS::HandleValue) { return new CCmp##cname(); } \
|
static IComponent* Allocate(const ScriptInterface&, JS::HandleValue) { return new CCmp##cname(); } \
|
||||||
static void Deallocate(IComponent* cmp) { delete static_cast<CCmp##cname*> (cmp); } \
|
static void Deallocate(IComponent* cmp) { delete static_cast<CCmp##cname*> (cmp); } \
|
||||||
virtual int GetComponentTypeId() const \
|
virtual int GetComponentTypeId() const \
|
||||||
{ \
|
{ \
|
||||||
@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
#define DEFAULT_SCRIPT_WRAPPER(cname) \
|
#define DEFAULT_SCRIPT_WRAPPER(cname) \
|
||||||
static void ClassInit(CComponentManager& UNUSED(componentManager)) { } \
|
static void ClassInit(CComponentManager& UNUSED(componentManager)) { } \
|
||||||
static IComponent* Allocate(ScriptInterface& scriptInterface, JS::HandleValue instance) \
|
static IComponent* Allocate(const ScriptInterface& scriptInterface, JS::HandleValue instance) \
|
||||||
{ \
|
{ \
|
||||||
return new CCmp##cname(scriptInterface, instance); \
|
return new CCmp##cname(scriptInterface, instance); \
|
||||||
} \
|
} \
|
||||||
@ -59,7 +59,7 @@
|
|||||||
{ \
|
{ \
|
||||||
delete static_cast<CCmp##cname*> (cmp); \
|
delete static_cast<CCmp##cname*> (cmp); \
|
||||||
} \
|
} \
|
||||||
CCmp##cname(ScriptInterface& scriptInterface, JS::HandleValue instance) : m_Script(scriptInterface, instance) { } \
|
CCmp##cname(const ScriptInterface& scriptInterface, JS::HandleValue instance) : m_Script(scriptInterface, instance) { } \
|
||||||
static std::string GetSchema() \
|
static std::string GetSchema() \
|
||||||
{ \
|
{ \
|
||||||
return "<a:component type='script-wrapper'/><empty/>"; \
|
return "<a:component type='script-wrapper'/><empty/>"; \
|
||||||
|
@ -40,9 +40,9 @@ public:
|
|||||||
virtual int GetType() const { return mtid; }
|
virtual int GetType() const { return mtid; }
|
||||||
virtual const char* GetScriptHandlerName() const { return handlerName.c_str(); }
|
virtual const char* GetScriptHandlerName() const { return handlerName.c_str(); }
|
||||||
virtual const char* GetScriptGlobalHandlerName() const { return globalHandlerName.c_str(); }
|
virtual const char* GetScriptGlobalHandlerName() const { return globalHandlerName.c_str(); }
|
||||||
virtual JS::Value ToJSVal(ScriptInterface& UNUSED(scriptInterface)) const { return msg.get(); }
|
virtual JS::Value ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const { return msg.get(); }
|
||||||
|
|
||||||
CMessageScripted(ScriptInterface& scriptInterface, int mtid, const std::string& name, JS::HandleValue msg) :
|
CMessageScripted(const ScriptInterface& scriptInterface, int mtid, const std::string& name, JS::HandleValue msg) :
|
||||||
mtid(mtid), handlerName("On" + name), globalHandlerName("OnGlobal" + name), msg(scriptInterface.GetJSRuntime(), msg)
|
mtid(mtid), handlerName("On" + name), globalHandlerName("OnGlobal" + name), msg(scriptInterface.GetJSRuntime(), msg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Component allocation types
|
// Component allocation types
|
||||||
typedef IComponent* (*AllocFunc)(ScriptInterface& scriptInterface, JS::HandleValue ctor);
|
typedef IComponent* (*AllocFunc)(const ScriptInterface& scriptInterface, JS::HandleValue ctor);
|
||||||
typedef void (*DeallocFunc)(IComponent*);
|
typedef void (*DeallocFunc)(IComponent*);
|
||||||
|
|
||||||
// ComponentTypes come in three types:
|
// ComponentTypes come in three types:
|
||||||
@ -303,11 +303,11 @@ public:
|
|||||||
void SetRNGSeed(u32 seed);
|
void SetRNGSeed(u32 seed);
|
||||||
|
|
||||||
// Various state serialization functions:
|
// Various state serialization functions:
|
||||||
bool ComputeStateHash(std::string& outHash, bool quick);
|
bool ComputeStateHash(std::string& outHash, bool quick) const;
|
||||||
bool DumpDebugState(std::ostream& stream, bool includeDebugInfo);
|
bool DumpDebugState(std::ostream& stream, bool includeDebugInfo) const;
|
||||||
// FlushDestroyedComponents must be called before SerializeState (since the destruction queue
|
// FlushDestroyedComponents must be called before SerializeState (since the destruction queue
|
||||||
// won't get serialized)
|
// won't get serialized)
|
||||||
bool SerializeState(std::ostream& stream);
|
bool SerializeState(std::ostream& stream) const;
|
||||||
bool DeserializeState(std::istream& stream);
|
bool DeserializeState(std::istream& stream);
|
||||||
|
|
||||||
std::string GenerateSchema() const;
|
std::string GenerateSchema() const;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -46,7 +46,7 @@ void DeserializeRNG(const std::string& str, boost::rand48& rng)
|
|||||||
s >> rng;
|
s >> rng;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CComponentManager::DumpDebugState(std::ostream& stream, bool includeDebugInfo)
|
bool CComponentManager::DumpDebugState(std::ostream& stream, bool includeDebugInfo) const
|
||||||
{
|
{
|
||||||
CDebugSerializer serializer(m_ScriptInterface, stream, includeDebugInfo);
|
CDebugSerializer serializer(m_ScriptInterface, stream, includeDebugInfo);
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ bool CComponentManager::DumpDebugState(std::ostream& stream, bool includeDebugIn
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CComponentManager::ComputeStateHash(std::string& outHash, bool quick)
|
bool CComponentManager::ComputeStateHash(std::string& outHash, bool quick) const
|
||||||
{
|
{
|
||||||
// Hash serialization: this includes the minimal data necessary to detect
|
// Hash serialization: this includes the minimal data necessary to detect
|
||||||
// differences in the state, and ignores things like counts and names
|
// differences in the state, and ignores things like counts and names
|
||||||
@ -177,7 +177,7 @@ bool CComponentManager::ComputeStateHash(std::string& outHash, bool quick)
|
|||||||
* version), but it doesn't seem worth having a separate codepath for that.)
|
* version), but it doesn't seem worth having a separate codepath for that.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool CComponentManager::SerializeState(std::ostream& stream)
|
bool CComponentManager::SerializeState(std::ostream& stream) const
|
||||||
{
|
{
|
||||||
CStdSerializer serializer(m_ScriptInterface, stream);
|
CStdSerializer serializer(m_ScriptInterface, stream);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2010 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -33,7 +33,7 @@ void IComponent::HandleMessage(const CMessage& UNUSED(msg), bool UNUSED(global))
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IComponent::NewJSObject(ScriptInterface& UNUSED(scriptInterface), JS::MutableHandleObject UNUSED(out)) const
|
bool IComponent::NewJSObject(const ScriptInterface& UNUSED(scriptInterface), JS::MutableHandleObject UNUSED(out)) const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
* Returns false by default, indicating that a scripted wrapper of this IComponent is not supported.
|
* Returns false by default, indicating that a scripted wrapper of this IComponent is not supported.
|
||||||
* Derrived classes should return true if they implement such a wrapper.
|
* Derrived classes should return true if they implement such a wrapper.
|
||||||
*/
|
*/
|
||||||
virtual bool NewJSObject(ScriptInterface& scriptInterface, JS::MutableHandleObject out) const;
|
virtual bool NewJSObject(const ScriptInterface& scriptInterface, JS::MutableHandleObject out) const;
|
||||||
virtual JS::Value GetJSInstance() const;
|
virtual JS::Value GetJSInstance() const;
|
||||||
virtual int GetComponentTypeId() const = 0;
|
virtual int GetComponentTypeId() const = 0;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2010 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -21,7 +21,7 @@
|
|||||||
#include "simulation2/system/IComponent.h"
|
#include "simulation2/system/IComponent.h"
|
||||||
|
|
||||||
#define DECLARE_INTERFACE_TYPE(iname) \
|
#define DECLARE_INTERFACE_TYPE(iname) \
|
||||||
virtual bool NewJSObject(ScriptInterface& scriptInterface, JS::MutableHandleObject out) const; \
|
virtual bool NewJSObject(const ScriptInterface& scriptInterface, JS::MutableHandleObject out) const; \
|
||||||
static void InterfaceInit(ScriptInterface& scriptInterface); \
|
static void InterfaceInit(ScriptInterface& scriptInterface); \
|
||||||
static int GetInterfaceId() { return IID_##iname; }
|
static int GetInterfaceId() { return IID_##iname; }
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
void ICmp##iname::InterfaceInit(ScriptInterface& scriptInterface) { \
|
void ICmp##iname::InterfaceInit(ScriptInterface& scriptInterface) { \
|
||||||
scriptInterface.DefineCustomObjectType(&class_ICmp##iname, NULL, 0, NULL, methods_ICmp##iname, NULL, NULL); \
|
scriptInterface.DefineCustomObjectType(&class_ICmp##iname, NULL, 0, NULL, methods_ICmp##iname, NULL, NULL); \
|
||||||
} \
|
} \
|
||||||
bool ICmp##iname::NewJSObject(ScriptInterface& scriptInterface, JS::MutableHandleObject out) const\
|
bool ICmp##iname::NewJSObject(const ScriptInterface& scriptInterface, JS::MutableHandleObject out) const\
|
||||||
{ \
|
{ \
|
||||||
out.set(scriptInterface.CreateCustomObject("ICmp" #iname)); \
|
out.set(scriptInterface.CreateCustomObject("ICmp" #iname)); \
|
||||||
return true; \
|
return true; \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2010 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -31,14 +31,14 @@ public:
|
|||||||
virtual int GetType() const = 0;
|
virtual int GetType() const = 0;
|
||||||
virtual const char* GetScriptHandlerName() const = 0;
|
virtual const char* GetScriptHandlerName() const = 0;
|
||||||
virtual const char* GetScriptGlobalHandlerName() const = 0;
|
virtual const char* GetScriptGlobalHandlerName() const = 0;
|
||||||
virtual JS::Value ToJSVal(ScriptInterface&) const = 0;
|
virtual JS::Value ToJSVal(const ScriptInterface&) const = 0;
|
||||||
JS::Value ToJSValCached(ScriptInterface&) const;
|
JS::Value ToJSValCached(const ScriptInterface&) const;
|
||||||
private:
|
private:
|
||||||
mutable std::unique_ptr<JS::PersistentRootedValue> m_Cached;
|
mutable std::unique_ptr<JS::PersistentRootedValue> m_Cached;
|
||||||
};
|
};
|
||||||
// TODO: GetType could be replaced with a plain member variable to avoid some
|
// TODO: GetType could be replaced with a plain member variable to avoid some
|
||||||
// virtual calls, if that turns out to be worthwhile
|
// virtual calls, if that turns out to be worthwhile
|
||||||
|
|
||||||
CMessage* CMessageFromJSVal(int mtid, ScriptInterface&, JS::HandleValue);
|
CMessage* CMessageFromJSVal(int mtid, const ScriptInterface&, JS::HandleValue);
|
||||||
|
|
||||||
#endif // INCLUDED_MESSAGE
|
#endif // INCLUDED_MESSAGE
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -135,7 +135,7 @@ namespace JSI_Sound
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void RegisterScriptFunctions(ScriptInterface& scriptInterface)
|
void RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||||
{
|
{
|
||||||
scriptInterface.RegisterFunction<void, &StartMusic>("StartMusic");
|
scriptInterface.RegisterFunction<void, &StartMusic>("StartMusic");
|
||||||
scriptInterface.RegisterFunction<void, &StopMusic>("StopMusic");
|
scriptInterface.RegisterFunction<void, &StopMusic>("StopMusic");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2012 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -23,7 +23,7 @@ class ScriptInterface;
|
|||||||
|
|
||||||
namespace JSI_Sound
|
namespace JSI_Sound
|
||||||
{
|
{
|
||||||
void RegisterScriptFunctions(ScriptInterface& scriptInterface);
|
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifndef INCLUDED_SOUNDSCRIPTINTERFACE
|
#endif // #ifndef INCLUDED_SOUNDSCRIPTINTERFACE
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2016 Wildfire Games.
|
/* Copyright (C) 2017 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -135,9 +135,9 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptTestSetup(ScriptInterface& ifc)
|
void ScriptTestSetup(const ScriptInterface& scriptinterface)
|
||||||
{
|
{
|
||||||
ifc.RegisterFunction<void, std::wstring, script_TS_FAIL>("TS_FAIL");
|
scriptinterface.RegisterFunction<void, std::wstring, script_TS_FAIL>("TS_FAIL");
|
||||||
|
|
||||||
// Load the TS_* function definitions
|
// Load the TS_* function definitions
|
||||||
// (We don't use VFS because tests might not have the normal VFS paths loaded)
|
// (We don't use VFS because tests might not have the normal VFS paths loaded)
|
||||||
@ -145,6 +145,6 @@ void ScriptTestSetup(ScriptInterface& ifc)
|
|||||||
std::ifstream ifs(OsString(path).c_str());
|
std::ifstream ifs(OsString(path).c_str());
|
||||||
ENSURE(ifs.good());
|
ENSURE(ifs.good());
|
||||||
std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
||||||
bool ok = ifc.LoadScript(L"test_setup.js", content);
|
bool ok = scriptinterface.LoadScript(L"test_setup.js", content);
|
||||||
ENSURE(ok);
|
ENSURE(ok);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user