Skip to content

Commit

Permalink
RMG-Core: export symbols (TODO)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Feb 27, 2025
1 parent acc2c80 commit 1a97b4c
Show file tree
Hide file tree
Showing 32 changed files with 212 additions and 189 deletions.
9 changes: 5 additions & 4 deletions Source/RMG-Core/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "Archive.hpp"
#include "Library.hpp" // TODO: move?
#include "String.hpp"
#include "Error.hpp"

Expand Down Expand Up @@ -107,7 +108,7 @@ static int zlib_filefunc_testerror(voidpf opaque, voidpf stream)
// Exported Functions
//

bool CoreReadZipFile(std::filesystem::path file, std::filesystem::path& extractedFileName, bool& isDisk, std::vector<char>& outBuffer)
CORE_EXPORT bool CoreReadZipFile(std::filesystem::path file, std::filesystem::path& extractedFileName, bool& isDisk, std::vector<char>& outBuffer)
{
std::string error;
std::fstream fileStream;
Expand Down Expand Up @@ -245,7 +246,7 @@ bool CoreReadZipFile(std::filesystem::path file, std::filesystem::path& extracte
return false;
}

bool CoreRead7zipFile(std::filesystem::path file, std::filesystem::path& extractedFileName, bool& isDisk, std::vector<char>& outBuffer)
CORE_EXPORT bool CoreRead7zipFile(std::filesystem::path file, std::filesystem::path& extractedFileName, bool& isDisk, std::vector<char>& outBuffer)
{
std::string error;

Expand Down Expand Up @@ -401,7 +402,7 @@ bool CoreRead7zipFile(std::filesystem::path file, std::filesystem::path& extract
return false;
}

bool CoreReadArchiveFile(std::filesystem::path file, std::filesystem::path& extractedFileName, bool& isDisk, std::vector<char>& outBuffer)
CORE_EXPORT bool CoreReadArchiveFile(std::filesystem::path file, std::filesystem::path& extractedFileName, bool& isDisk, std::vector<char>& outBuffer)
{
std::string file_extension;

Expand Down Expand Up @@ -431,7 +432,7 @@ bool CoreReadArchiveFile(std::filesystem::path file, std::filesystem::path& extr
return true;
}

bool CoreUnzip(std::filesystem::path file, std::filesystem::path path)
CORE_EXPORT bool CoreUnzip(std::filesystem::path file, std::filesystem::path path)
{
std::string error;
std::filesystem::path targetPath;
Expand Down
6 changes: 0 additions & 6 deletions Source/RMG-Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ project(RMG-Core)

set(CMAKE_CXX_STANDARD 20)

# RMG-Core needs LTO disabled for windows
# else linking fails
if (WIN32)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
endif(WIN32)

find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2)
pkg_check_modules(MINIZIP REQUIRED minizip)
Expand Down
15 changes: 8 additions & 7 deletions Source/RMG-Core/CachedRomHeaderAndSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Directories.hpp"
#include "RomSettings.hpp"
#include "RomHeader.hpp"
#include "Library.hpp" // TODO: move?
#include "File.hpp"

#include <algorithm>
Expand Down Expand Up @@ -90,7 +91,7 @@ static std::vector<l_CacheEntry>::iterator get_cache_entry_iter(std::filesystem:
// Exported Functions
//

void CoreReadRomHeaderAndSettingsCache(void)
CORE_EXPORT void CoreReadRomHeaderAndSettingsCache(void)
{
std::ifstream inputStream;
char magicBuf[sizeof(CACHE_FILE_MAGIC)];
Expand Down Expand Up @@ -183,7 +184,7 @@ void CoreReadRomHeaderAndSettingsCache(void)
inputStream.close();
}

bool CoreSaveRomHeaderAndSettingsCache(void)
CORE_EXPORT bool CoreSaveRomHeaderAndSettingsCache(void)
{
std::ofstream outputStream;
wchar_t fileNameBuf[MAX_FILENAME_LEN];
Expand Down Expand Up @@ -282,7 +283,7 @@ bool CoreSaveRomHeaderAndSettingsCache(void)
return true;
}

bool CoreGetCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomType* type, CoreRomHeader* header, CoreRomSettings* defaultSettings, CoreRomSettings* settings)
CORE_EXPORT bool CoreGetCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomType* type, CoreRomHeader* header, CoreRomSettings* defaultSettings, CoreRomSettings* settings)
{
bool ret = false;
auto iter = get_cache_entry_iter(file);
Expand Down Expand Up @@ -355,7 +356,7 @@ bool CoreGetCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomType*
return true;
}

bool CoreAddCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomType type, CoreRomHeader header, CoreRomSettings defaultSettings, CoreRomSettings settings)
CORE_EXPORT bool CoreAddCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomType type, CoreRomHeader header, CoreRomSettings defaultSettings, CoreRomSettings settings)
{
l_CacheEntry cacheEntry;

Expand Down Expand Up @@ -383,7 +384,7 @@ bool CoreAddCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomType t
return true;
}

bool CoreUpdateCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomType type, CoreRomHeader header, CoreRomSettings defaultSettings, CoreRomSettings settings)
CORE_EXPORT bool CoreUpdateCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomType type, CoreRomHeader header, CoreRomSettings defaultSettings, CoreRomSettings settings)
{
l_CacheEntry cachedEntry;

Expand Down Expand Up @@ -414,7 +415,7 @@ bool CoreUpdateCachedRomHeaderAndSettings(std::filesystem::path file, CoreRomTyp
return true;
}

bool CoreUpdateCachedRomHeaderAndSettings(std::filesystem::path file)
CORE_EXPORT bool CoreUpdateCachedRomHeaderAndSettings(std::filesystem::path file)
{
CoreRomType type;
CoreRomHeader header;
Expand All @@ -441,7 +442,7 @@ bool CoreUpdateCachedRomHeaderAndSettings(std::filesystem::path file)
return CoreUpdateCachedRomHeaderAndSettings(file, type, header, defaultSettings, settings);
}

bool CoreClearRomHeaderAndSettingsCache(void)
CORE_EXPORT bool CoreClearRomHeaderAndSettingsCache(void)
{
l_CacheEntries.clear();
l_CacheEntriesChanged = true;
Expand Down
7 changes: 4 additions & 3 deletions Source/RMG-Core/Callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
#define CORE_INTERNAL
#include "ConvertStringEncoding.hpp"
#include "Library.hpp" // TODO: move?
#include "Callback.hpp"

#include <iostream>
Expand Down Expand Up @@ -82,7 +83,7 @@ void CoreStateCallback(void* context, m64p_core_param param, int value)
// Exported Functions
//

bool CoreSetupCallbacks(std::function<void(enum CoreDebugMessageType, std::string, std::string)> debugCallbackFunc,
CORE_EXPORT bool CoreSetupCallbacks(std::function<void(enum CoreDebugMessageType, std::string, std::string)> debugCallbackFunc,
std::function<void(enum CoreStateCallbackType, int)> stateCallbackFunc)
{
l_DebugCallbackFunc = debugCallbackFunc;
Expand All @@ -99,12 +100,12 @@ bool CoreSetupCallbacks(std::function<void(enum CoreDebugMessageType, std::strin
return true;
}

void CoreSetPrintDebugCallback(bool enabled)
CORE_EXPORT void CoreSetPrintDebugCallback(bool enabled)
{
l_PrintCallbacks = enabled;
}

void CoreAddCallbackMessage(CoreDebugMessageType type, std::string message)
CORE_EXPORT void CoreAddCallbackMessage(CoreDebugMessageType type, std::string message)
{
CoreDebugCallback((void*)"[GUI] ", (int)type, message.c_str());
}
37 changes: 19 additions & 18 deletions Source/RMG-Core/Cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "RomSettings.hpp"
#include "RomHeader.hpp"
#include "Settings.hpp"
#include "Library.hpp" // TODO: move?
#include "Cheats.hpp"
#include "Error.hpp"

Expand Down Expand Up @@ -568,7 +569,7 @@ static bool get_romheader_and_romsettings(const std::filesystem::path& file, Cor
// Exported Functions
//

bool CoreGetCurrentCheats(std::filesystem::path file, std::vector<CoreCheat>& cheats)
CORE_EXPORT bool CoreGetCurrentCheats(std::filesystem::path file, std::vector<CoreCheat>& cheats)
{
CoreRomHeader romHeader;
CoreRomSettings romSettings;
Expand Down Expand Up @@ -639,13 +640,13 @@ bool CoreGetCurrentCheats(std::filesystem::path file, std::vector<CoreCheat>& ch
return true;
}

bool CoreParseCheat(const std::vector<std::string>& lines, CoreCheat& cheat)
CORE_EXPORT bool CoreParseCheat(const std::vector<std::string>& lines, CoreCheat& cheat)
{
int endIndex = 0;
return parse_cheat(lines, 0, cheat, endIndex);
}

bool CoreGetCheatLines(CoreCheat cheat, std::vector<std::string>& codeLines, std::vector<std::string>& optionLines)
CORE_EXPORT bool CoreGetCheatLines(CoreCheat cheat, std::vector<std::string>& codeLines, std::vector<std::string>& optionLines)
{
for (const CoreCheatCode& code : cheat.CheatCodes)
{
Expand Down Expand Up @@ -675,7 +676,7 @@ bool CoreGetCheatLines(CoreCheat cheat, std::vector<std::string>& codeLines, std
return true;
}

bool CoreAddCheat(std::filesystem::path file, CoreCheat cheat)
CORE_EXPORT bool CoreAddCheat(std::filesystem::path file, CoreCheat cheat)
{
std::string error;
CoreRomHeader romHeader;
Expand Down Expand Up @@ -711,7 +712,7 @@ bool CoreAddCheat(std::filesystem::path file, CoreCheat cheat)
return write_cheat_file(l_UserCheatFile, cheatFilePath);
}

bool CoreUpdateCheat(std::filesystem::path file, CoreCheat oldCheat, CoreCheat newCheat)
CORE_EXPORT bool CoreUpdateCheat(std::filesystem::path file, CoreCheat oldCheat, CoreCheat newCheat)
{
CoreRomHeader romHeader;
CoreRomSettings romSettings;
Expand Down Expand Up @@ -760,12 +761,12 @@ bool CoreUpdateCheat(std::filesystem::path file, CoreCheat oldCheat, CoreCheat n
return write_cheat_file(l_UserCheatFile, cheatFilePath);
}

bool CoreCanRemoveCheat(CoreCheat cheat)
CORE_EXPORT bool CoreCanRemoveCheat(CoreCheat cheat)
{
return std::find(l_UserCheatFile.Cheats.begin(), l_UserCheatFile.Cheats.end(), cheat) != l_UserCheatFile.Cheats.end();
}

bool CoreRemoveCheat(std::filesystem::path file, CoreCheat cheat)
CORE_EXPORT bool CoreRemoveCheat(std::filesystem::path file, CoreCheat cheat)
{
CoreRomHeader romHeader;
CoreRomSettings romSettings;
Expand Down Expand Up @@ -793,7 +794,7 @@ bool CoreRemoveCheat(std::filesystem::path file, CoreCheat cheat)
return write_cheat_file(l_UserCheatFile, cheatFilePath);
}

bool CoreEnableCheat(std::filesystem::path file, CoreCheat cheat, bool enabled)
CORE_EXPORT bool CoreEnableCheat(std::filesystem::path file, CoreCheat cheat, bool enabled)
{
CoreRomHeader romHeader;
CoreRomSettings romSettings;
Expand All @@ -817,7 +818,7 @@ bool CoreEnableCheat(std::filesystem::path file, CoreCheat cheat, bool enabled)
return CoreSettingsSetValue(settingSection, settingKey, enabled);
}

bool CoreIsCheatEnabled(std::filesystem::path file, CoreCheat cheat)
CORE_EXPORT bool CoreIsCheatEnabled(std::filesystem::path file, CoreCheat cheat)
{
CoreRomHeader romHeader;
CoreRomSettings romSettings;
Expand All @@ -835,7 +836,7 @@ bool CoreIsCheatEnabled(std::filesystem::path file, CoreCheat cheat)
return CoreSettingsGetBoolValue(settingSection, settingKey, false);
}

bool CoreHasCheatOptionSet(std::filesystem::path file, CoreCheat cheat)
CORE_EXPORT bool CoreHasCheatOptionSet(std::filesystem::path file, CoreCheat cheat)
{
CoreRomHeader romHeader;
CoreRomSettings romSettings;
Expand All @@ -853,7 +854,7 @@ bool CoreHasCheatOptionSet(std::filesystem::path file, CoreCheat cheat)
return CoreSettingsGetIntValue(settingSection, settingKey, -1) != -1;
}

bool CoreSetCheatOption(std::filesystem::path file, CoreCheat cheat, CoreCheatOption option)
CORE_EXPORT bool CoreSetCheatOption(std::filesystem::path file, CoreCheat cheat, CoreCheatOption option)
{
CoreRomHeader romHeader;
CoreRomSettings romSettings;
Expand All @@ -871,7 +872,7 @@ bool CoreSetCheatOption(std::filesystem::path file, CoreCheat cheat, CoreCheatOp
return CoreSettingsSetValue(settingSection, settingKey, (int)option.Value);
}

bool CoreGetCheatOption(std::filesystem::path file, CoreCheat cheat, CoreCheatOption& option)
CORE_EXPORT bool CoreGetCheatOption(std::filesystem::path file, CoreCheat cheat, CoreCheatOption& option)
{
CoreRomHeader romHeader;
CoreRomSettings romSettings;
Expand Down Expand Up @@ -912,7 +913,7 @@ bool CoreGetCheatOption(std::filesystem::path file, CoreCheat cheat, CoreCheatOp
return false;
}

bool CoreResetCheatOption(std::filesystem::path file, CoreCheat cheat)
CORE_EXPORT bool CoreResetCheatOption(std::filesystem::path file, CoreCheat cheat)
{
CoreRomHeader romHeader;
CoreRomSettings romSettings;
Expand All @@ -936,7 +937,7 @@ bool CoreResetCheatOption(std::filesystem::path file, CoreCheat cheat)
return true;
}

bool CoreApplyCheats(void)
CORE_EXPORT bool CoreApplyCheats(void)
{
std::string error;
m64p_error ret;
Expand Down Expand Up @@ -1028,7 +1029,7 @@ bool CoreApplyCheats(void)
return true;
}

bool CoreClearCheats(void)
CORE_EXPORT bool CoreClearCheats(void)
{
std::string error;
m64p_error ret;
Expand Down Expand Up @@ -1059,13 +1060,13 @@ bool CoreClearCheats(void)
return true;
}

bool CoreSetNetplayCheats(const std::vector<CoreCheat>& cheats)
CORE_EXPORT bool CoreSetNetplayCheats(const std::vector<CoreCheat>& cheats)
{
l_NetplayCheats = cheats;
return true;
}

bool CoreApplyNetplayCheats(void)
CORE_EXPORT bool CoreApplyNetplayCheats(void)
{
std::string error;
m64p_error ret;
Expand Down Expand Up @@ -1136,7 +1137,7 @@ bool CoreApplyNetplayCheats(void)
return true;
}

bool CorePressGamesharkButton(bool enabled)
CORE_EXPORT bool CorePressGamesharkButton(bool enabled)
{
std::string error;
m64p_error ret;
Expand Down
3 changes: 2 additions & 1 deletion Source/RMG-Core/ConvertStringEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
#define CORE_INTERNAL
#include "ConvertStringEncoding.hpp"
#include "Library.hpp" // TODO: move?
#include "Error.hpp"

#include <string.h>
Expand All @@ -19,7 +20,7 @@
// Exported Functions
//

std::string CoreConvertStringEncoding(std::string str, CoreStringEncoding encoding)
CORE_EXPORT std::string CoreConvertStringEncoding(std::string str, CoreStringEncoding encoding)
{
std::string error;
std::string encodingString;
Expand Down
4 changes: 2 additions & 2 deletions Source/RMG-Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static bool config_override_user_dirs(void)
// Exported Functions
//

bool CoreInit(void)
CORE_EXPORT bool CoreInit(void)
{
std::string error;
std::filesystem::path core_file;
Expand Down Expand Up @@ -180,7 +180,7 @@ bool CoreInit(void)
return true;
}

void CoreShutdown(void)
CORE_EXPORT void CoreShutdown(void)
{
CorePluginsShutdown();

Expand Down
Loading

0 comments on commit 1a97b4c

Please sign in to comment.