diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 4704b340b2..4024205672 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -534,6 +534,11 @@ add_library(core PowerPC/SignatureDB/MEGASignatureDB.h PowerPC/SignatureDB/SignatureDB.cpp PowerPC/SignatureDB/SignatureDB.h + Scripting/CoreScriptInterface/InternalAPIs/FileUtility_APIs.h + Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.cpp + Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.h + Scripting/ScriptUtilities.cpp + Scripting/ScriptUtilities.h State.cpp State.h SyncIdentifier.h diff --git a/Source/Core/Core/Scripting/CoreScriptInterface/InternalAPIs/FileUtility_APIs.h b/Source/Core/Core/Scripting/CoreScriptInterface/InternalAPIs/FileUtility_APIs.h new file mode 100644 index 0000000000..d9e9a6d03c --- /dev/null +++ b/Source/Core/Core/Scripting/CoreScriptInterface/InternalAPIs/FileUtility_APIs.h @@ -0,0 +1,18 @@ +#pragma once + +namespace Scripting +{ + +// FileUtility_APIs contains the APIs for getting the user directory path and the system directory +// path for Dolphin. +typedef struct FileUtility_APIs +{ + // Returns the user directory path for Dolphin. + const char* (*GetUserDirectoryPath)(); + + // Returns the system directory path for Dolphin. + const char* (*GetSystemDirectoryPath)(); + +} FileUtility_APIs; + +} // namespace Scripting diff --git a/Source/Core/Core/Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.cpp b/Source/Core/Core/Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.cpp new file mode 100644 index 0000000000..b0e50fd139 --- /dev/null +++ b/Source/Core/Core/Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.cpp @@ -0,0 +1,31 @@ +#include "Core/Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.h" + +#include +#include "Common/FileUtil.h" + +namespace Scripting::FileUtilityAPIsImpl +{ +FileUtility_APIs fileUtility_APIs = {}; + +std::string user_directory_path; +std::string system_directory_path; + +void Init() +{ + fileUtility_APIs.GetUserDirectoryPath = GetUserDirectoryPath_impl; + fileUtility_APIs.GetSystemDirectoryPath = GetSystemDirectoryPath_impl; + user_directory_path = File::GetUserPath(D_LOAD_IDX); + system_directory_path = File::GetSysDirectory(); +} + +const char* GetUserDirectoryPath_impl() +{ + return user_directory_path.c_str(); +} + +const char* GetSystemDirectoryPath_impl() +{ + return system_directory_path.c_str(); +} + +} // namespace Scripting::FileUtilityAPIsImpl diff --git a/Source/Core/Core/Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.h b/Source/Core/Core/Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.h new file mode 100644 index 0000000000..a6040c80d9 --- /dev/null +++ b/Source/Core/Core/Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.h @@ -0,0 +1,15 @@ +#pragma once + +#include "Core/Scripting/CoreScriptInterface/InternalAPIs/FileUtility_APIs.h" + +// This file contains the implementations for the APIs in FileUtility_APIs +namespace Scripting::FileUtilityAPIsImpl +{ +extern FileUtility_APIs fileUtility_APIs; + +void Init(); + +const char* GetUserDirectoryPath_impl(); +const char* GetSystemDirectoryPath_impl(); + +} // namespace Scripting::FileUtilityAPIsImpl diff --git a/Source/Core/Core/Scripting/ScriptUtilities.cpp b/Source/Core/Core/Scripting/ScriptUtilities.cpp new file mode 100644 index 0000000000..85e4d50647 --- /dev/null +++ b/Source/Core/Core/Scripting/ScriptUtilities.cpp @@ -0,0 +1,19 @@ +#include "Core/Scripting/ScriptUtilities.h" + +#include "Core/Scripting/HelperClasses/InternalAPIDefinitions/FileUtility_API_Implementations.h" + +namespace Scripting +{ + +static bool is_scripting_core_initialized = false; + +void InitScriptingCore() +{ + if (!is_scripting_core_initialized) + { + FileUtilityAPIsImpl::Init(); + is_scripting_core_initialized = true; + } +} + +} // namespace Scripting diff --git a/Source/Core/Core/Scripting/ScriptUtilities.h b/Source/Core/Core/Scripting/ScriptUtilities.h new file mode 100644 index 0000000000..0890945eff --- /dev/null +++ b/Source/Core/Core/Scripting/ScriptUtilities.h @@ -0,0 +1,8 @@ +#pragma once + +namespace Scripting +{ + +void InitScriptingCore(); + +} // namespace Scripting diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index a61f0d822a..3055b54123 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -454,6 +454,9 @@ + + + @@ -1121,6 +1124,8 @@ + +