mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-24 11:53:36 +00:00
Refactor all usage of RegisterFunction to ScriptFunction::Register
- Replace ScriptInterface::RegisterFunction with
ScriptFunction::Register
- Mostly removing unused cmpPrivate*
- Some usage introduces specific getters (mapgenerator, AIWorker,
XmppClient,...)
- Several passthrough functions are simply removed in favour of calling
the original, reducing duplication
- Make use of ScriptRequest/ScriptInterface capabilities where
relevant.
- Make JSI_* headers only expose necessary functions, lightening them
considerably and reducing duplication
- Reuse namespaces in JSI_* implementations directly, reducing visual
noise there
Follows f3aedf88a6
Differential Revision: https://code.wildfiregames.com/D3626
This was SVN commit r24983.
This commit is contained in:
@@ -22,42 +22,46 @@
|
||||
#include "ps/Filesystem.h"
|
||||
#include "ps/Pyrogenesis.h"
|
||||
#include "ps/UserReport.h"
|
||||
#include "scriptinterface/FunctionWrapper.h"
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
bool JSI_UserReport::IsUserReportEnabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
|
||||
namespace JSI_UserReport
|
||||
{
|
||||
bool IsUserReportEnabled()
|
||||
{
|
||||
return g_UserReporter.IsReportingEnabled();
|
||||
}
|
||||
|
||||
void JSI_UserReport::SetUserReportEnabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool enabled)
|
||||
void SetUserReportEnabled(bool enabled)
|
||||
{
|
||||
g_UserReporter.SetReportingEnabled(enabled);
|
||||
}
|
||||
|
||||
std::string JSI_UserReport::GetUserReportStatus(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
|
||||
std::string GetUserReportStatus()
|
||||
{
|
||||
return g_UserReporter.GetStatus();
|
||||
}
|
||||
|
||||
std::string JSI_UserReport::GetUserReportLogPath(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
|
||||
std::string GetUserReportLogPath()
|
||||
{
|
||||
return psLogDir().string8();
|
||||
}
|
||||
|
||||
std::string JSI_UserReport::GetUserReportConfigPath(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
|
||||
std::string GetUserReportConfigPath()
|
||||
{
|
||||
OsPath configPath;
|
||||
WARN_IF_ERR(g_VFS->GetDirectoryRealPath("config/", configPath));
|
||||
return configPath.string8();
|
||||
}
|
||||
|
||||
void JSI_UserReport::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||
void RegisterScriptFunctions(const ScriptRequest& rq)
|
||||
{
|
||||
scriptInterface.RegisterFunction<bool, &IsUserReportEnabled>("IsUserReportEnabled");
|
||||
scriptInterface.RegisterFunction<void, bool, &SetUserReportEnabled>("SetUserReportEnabled");
|
||||
scriptInterface.RegisterFunction<std::string, &GetUserReportStatus>("GetUserReportStatus");
|
||||
scriptInterface.RegisterFunction<std::string, &GetUserReportLogPath>("GetUserReportLogPath");
|
||||
scriptInterface.RegisterFunction<std::string, &GetUserReportConfigPath>("GetUserReportConfigPath");
|
||||
ScriptFunction::Register<&IsUserReportEnabled>(rq, "IsUserReportEnabled");
|
||||
ScriptFunction::Register<&SetUserReportEnabled>(rq, "SetUserReportEnabled");
|
||||
ScriptFunction::Register<&GetUserReportStatus>(rq, "GetUserReportStatus");
|
||||
ScriptFunction::Register<&GetUserReportLogPath>(rq, "GetUserReportLogPath");
|
||||
ScriptFunction::Register<&GetUserReportConfigPath>(rq, "GetUserReportConfigPath");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user