Changeset View
Changeset View
Standalone View
Standalone View
source/scriptinterface/ScriptInterface.h
/* Copyright (C) 2023 Wildfire Games. | /* Copyright (C) 2023 Wildfire Games. | ||||
Lint: Inaccurate Copyright Year: Inaccurate Copyright Year | |||||
* 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 | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 9 Lines | |||||
#define INCLUDED_SCRIPTINTERFACE | #define INCLUDED_SCRIPTINTERFACE | ||||
#include "ps/Errors.h" | #include "ps/Errors.h" | ||||
#include "scriptinterface/ScriptConversions.h" | #include "scriptinterface/ScriptConversions.h" | ||||
#include "scriptinterface/ScriptExceptions.h" | #include "scriptinterface/ScriptExceptions.h" | ||||
#include "scriptinterface/ScriptRequest.h" | #include "scriptinterface/ScriptRequest.h" | ||||
#include "scriptinterface/ScriptTypes.h" | #include "scriptinterface/ScriptTypes.h" | ||||
#include <map> | #include <unordered_map> | ||||
ERROR_GROUP(Scripting); | ERROR_GROUP(Scripting); | ||||
ERROR_TYPE(Scripting, SetupFailed); | ERROR_TYPE(Scripting, SetupFailed); | ||||
ERROR_SUBGROUP(Scripting, LoadFile); | ERROR_SUBGROUP(Scripting, LoadFile); | ||||
ERROR_TYPE(Scripting_LoadFile, OpenFailed); | ERROR_TYPE(Scripting_LoadFile, OpenFailed); | ||||
ERROR_TYPE(Scripting_LoadFile, EvalErrors); | ERROR_TYPE(Scripting_LoadFile, EvalErrors); | ||||
▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | private: | ||||
}; | }; | ||||
CmptPrivate m_CmptPrivate; | CmptPrivate m_CmptPrivate; | ||||
// 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 custom destructor of ScriptInterface_impl. | // members have to be called before the custom destructor of ScriptInterface_impl. | ||||
std::unique_ptr<ScriptInterface_impl> m; | std::unique_ptr<ScriptInterface_impl> m; | ||||
std::map<std::string, CustomType> m_CustomObjectTypes; | std::unordered_map<std::string, CustomType> m_CustomObjectTypes; | ||||
}; | }; | ||||
// Explicitly instantiate void* as that is used for the generic template, | // Explicitly instantiate void* as that is used for the generic template, | ||||
// and we want to define it in the .cpp file. | // and we want to define it in the .cpp file. | ||||
template <> void* ScriptInterface::ObjectFromCBData(const ScriptRequest& rq); | template <> void* ScriptInterface::ObjectFromCBData(const ScriptRequest& rq); | ||||
template<typename T> | template<typename T> | ||||
bool ScriptInterface::SetGlobal(const char* name, const T& value, bool replace, bool constant, bool enumerate) | bool ScriptInterface::SetGlobal(const char* name, const T& value, bool replace, bool constant, bool enumerate) | ||||
Show All 18 Lines |
Wildfire Games · Phabricator
Inaccurate Copyright Year