Sync with libloot v0.26.0

This commit is contained in:
Oliver Hamlet
2025-04-20 15:58:13 +01:00
parent fc4b976bd6
commit fb1e1ad360
70 changed files with 737 additions and 349 deletions
Generated
+4 -4
View File
@@ -565,7 +565,7 @@ dependencies = [
[[package]]
name = "libloot"
version = "0.25.5"
version = "0.26.0"
dependencies = [
"crc32fast",
"esplugin",
@@ -587,7 +587,7 @@ dependencies = [
[[package]]
name = "libloot-cxx"
version = "0.25.5"
version = "0.26.0"
dependencies = [
"cxx",
"cxx-build",
@@ -599,7 +599,7 @@ dependencies = [
[[package]]
name = "libloot-ffi-errors"
version = "0.25.5"
version = "0.26.0"
dependencies = [
"esplugin",
"libloadorder",
@@ -609,7 +609,7 @@ dependencies = [
[[package]]
name = "libloot_pyo3"
version = "0.25.5"
version = "0.26.0"
dependencies = [
"libloot",
"libloot-ffi-errors",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "libloot"
version = "0.25.5"
version = "0.26.0"
edition = "2024"
license = "GPL-3.0"
+1 -1
View File
@@ -1,6 +1,6 @@
# libloot-rs
This is an **experimental** reimplementation of [libloot](https://github.com/loot/libloot) using Rust instead of C++, that should match libloot v0.25.5.
This is an **experimental** reimplementation of [libloot](https://github.com/loot/libloot) using Rust instead of C++, that should match libloot v0.26.0.
See the `cxx` and `pyo3` subdirectories for C++ and Python wrappers respectively.
+2 -1
View File
@@ -154,6 +154,7 @@ target_include_directories(loot SYSTEM PRIVATE
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_compile_definitions(loot PRIVATE UNICODE _UNICODE LOOT_EXPORT)
target_compile_options(loot PRIVATE "/Zc:__cplusplus")
set(LOOT_LIBS ntdll ws2_32 bcrypt)
@@ -224,7 +225,7 @@ endif()
# Install
########################################
set(LIBLOOT_VERSION "0.25.4")
set(LIBLOOT_VERSION "0.26.0")
set_property(TARGET loot PROPERTY VERSION ${LIBLOOT_VERSION})
set_property(TARGET loot PROPERTY SOVERSION 0)
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "libloot-cxx"
version = "0.25.5"
version = "0.26.0"
edition = "2024"
license = "GPL-3.0"
+2 -2
View File
@@ -1,6 +1,6 @@
# libloot-rs C++ wrapper
This is an **experimental** wrapper around the Rust reimplementation of libloot that provides a C++ interface that's ABI-compatible with libloot v0.25.5.
This is an **experimental** wrapper around the Rust reimplementation of libloot that provides a C++ interface that's ABI-compatible with libloot v0.26.0.
The wrapper has two layers:
@@ -47,7 +47,7 @@ cmake --build build --parallel
### Tests & Packaging
The build process also builds a copy of the public API tests from C++ libloot v0.25.5 by default. To skip building the tests, pass `-DLIBLOOT_BUILD_TESTS=OFF` when first running CMake.
The build process also builds a copy of the public API tests from C++ libloot v0.26.0 by default. To skip building the tests, pass `-DLIBLOOT_BUILD_TESTS=OFF` when first running CMake.
If built, the tests can be run using:
+2
View File
@@ -1,6 +1,8 @@
fn main() {
cxx_build::bridge("src/lib.rs")
.std("c++17")
.flag_if_supported("/Zc:__cplusplus")
.flag_if_supported("/permissive-")
.compile("libloot-cxx");
// From <https://github.com/dtolnay/cxx/issues/880#issuecomment-2521375384>
+3 -2
View File
@@ -133,13 +133,14 @@ endif()
if(MSVC)
# Turn off permissive mode to be more standards-compliant and avoid compiler errors.
target_compile_options(libloot_tests PRIVATE "/permissive-" "/W4")
target_compile_options(libloot_tests PRIVATE "/permissive-" "/W4" "/Zc:__cplusplus")
# Set /bigobj to allow building Debug and RelWithDebInfo tests
target_compile_options(libloot_internals_tests PRIVATE
"/permissive-"
"/W4"
"$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:RelWithDebInfo>>:/bigobj>")
"$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:RelWithDebInfo>>:/bigobj>"
"/Zc:__cplusplus")
endif()
+2 -3
View File
@@ -29,6 +29,7 @@
#include <functional>
#include <memory>
#include <string>
#include <string_view>
#include "loot/api_decorator.h"
#include "loot/enum/game_type.h"
@@ -50,14 +51,12 @@ namespace loot {
/**
* @brief Set the callback function that is called when logging.
* @details If this function is not called, the default behaviour is to
* print messages to the console.
* @param callback
* The function called when logging. The first parameter is the
* level of the message being logged, and the second is the message.
*/
LOOT_API void SetLoggingCallback(
std::function<void(LogLevel, const char*)> callback);
std::function<void(LogLevel, std::string_view)> callback);
/**
* @brief Set the log severity level.
+37 -15
View File
@@ -27,6 +27,7 @@
#include <filesystem>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
#include "loot/exception/cyclic_interaction_error.h"
@@ -46,26 +47,41 @@ public:
*/
/**
* @brief Loads the masterlist, userlist and masterlist prelude from the
* paths specified.
* @brief Loads the masterlist from the path specified.
* @details Can be called multiple times, each time replacing the
* previously-loaded data.
* @param masterlist_path
* The relative or absolute path to the masterlist file that should be
* loaded.
* @param userlist_path
* The relative or absolute path to the userlist file that should be
* loaded, or an empty path. If an empty path, no userlist will be
*/
virtual void LoadMasterlist(
const std::filesystem::path& masterlistPath) = 0;
/**
* @brief Loads the masterlist and masterlist prelude from the paths
specified.
* @details Can be called multiple times, each time replacing the
* previously-loaded data.
* @param masterlist_path
* The relative or absolute path to the masterlist file that should be
* loaded.
* @param masterlist_prelude_path
* The relative or absolute path to the masterlist prelude file that
* should be loaded. If an empty path, no masterlist prelude will be
* should be loaded.
*/
virtual void LoadMasterlistWithPrelude(
const std::filesystem::path& masterlistPath,
const std::filesystem::path& masterlistPreludePath) = 0;
/**
* @brief Loads the userlist from the path specified.
* @details Can be called multiple times, each time replacing the
* previously-loaded data.
* @param userlist_path
* The relative or absolute path to the userlist file that should be
* loaded.
*/
virtual void LoadLists(
const std::filesystem::path& masterlist_path,
const std::filesystem::path& userlist_path = "",
const std::filesystem::path& masterlist_prelude_path = "") = 0;
virtual void LoadUserlist(const std::filesystem::path& userlistPath) = 0;
/**
* Writes a metadata file containing all loaded user-added metadata.
@@ -91,6 +107,12 @@ public:
virtual void WriteMinimalList(const std::filesystem::path& outputFile,
const bool overwrite) const = 0;
/**
* @brief Evaluate the given condition string.
* @param condition A condition string.
*/
virtual bool Evaluate(const std::string& condition) const = 0;
/**
* @}
* @name Non-plugin Data Access
@@ -160,8 +182,8 @@ public:
* exists.
*/
virtual std::vector<Vertex> GetGroupsPath(
const std::string& fromGroupName,
const std::string& toGroupName) const = 0;
std::string_view fromGroupName,
std::string_view toGroupName) const = 0;
/**
* @}
@@ -185,7 +207,7 @@ public:
* otherwise an optional containing no value.
*/
virtual std::optional<PluginMetadata> GetPluginMetadata(
const std::string& plugin,
std::string_view plugin,
bool includeUserMetadata = true,
bool evaluateConditions = false) const = 0;
@@ -201,7 +223,7 @@ public:
* that metadata, otherwise an optional containing no value.
*/
virtual std::optional<PluginMetadata> GetPluginUserMetadata(
const std::string& plugin,
std::string_view plugin,
bool evaluateConditions = false) const = 0;
/**
@@ -220,7 +242,7 @@ public:
* The filename of the plugin for which all user-added metadata
* should be deleted.
*/
virtual void DiscardPluginUserMetadata(const std::string& plugin) = 0;
virtual void DiscardPluginUserMetadata(std::string_view plugin) = 0;
/**
* @brief Discards all loaded user metadata for all plugins, and any
@@ -26,6 +26,7 @@
#define LOOT_EXCEPTION_UNDEFINED_GROUP_ERROR
#include <stdexcept>
#include <string_view>
#include "loot/api_decorator.h"
@@ -39,7 +40,7 @@ public:
* @brief Construct an exception for an undefined group.
* @param groupName The name of the group that is undefined.
*/
LOOT_API UndefinedGroupError(const std::string& groupName);
LOOT_API UndefinedGroupError(std::string_view groupName);
/**
* Get the name of the undefined group.
+4 -3
View File
@@ -141,8 +141,8 @@ public:
* is called, this GameInterface is destroyed, or until a plugin with
* a case-insensitively equal filename is loaded.
*/
virtual const PluginInterface* GetPlugin(
const std::string& pluginName) const = 0;
virtual std::shared_ptr<const PluginInterface> GetPlugin(
std::string_view pluginName) const = 0;
/**
* @brief Get a set of const references to all loaded plugins' PluginInterface
@@ -152,7 +152,8 @@ public:
* this GameInterface is destroyed, or until a plugin with a
* case-insensitively equal filename is loaded.
*/
virtual std::vector<const PluginInterface*> GetLoadedPlugins() const = 0;
virtual std::vector<std::shared_ptr<const PluginInterface>> GetLoadedPlugins()
const = 0;
/**
* @}
+2 -2
View File
@@ -34,10 +34,10 @@ namespace loot {
inline constexpr unsigned int LIBLOOT_VERSION_MAJOR = 0;
/** @brief libloot's minor version number. */
inline constexpr unsigned int LIBLOOT_VERSION_MINOR = 25;
inline constexpr unsigned int LIBLOOT_VERSION_MINOR = 26;
/** @brief libloot's patch version number. */
inline constexpr unsigned int LIBLOOT_VERSION_PATCH = 5;
inline constexpr unsigned int LIBLOOT_VERSION_PATCH = 0;
/**
* @brief Get the library version.
@@ -25,6 +25,7 @@
#define LOOT_METADATA_CONDITIONAL_METADATA
#include <string>
#include <string_view>
#include "loot/api_decorator.h"
@@ -48,7 +49,7 @@ public:
* documentation.
* @return A ConditionalMetadata object.
*/
LOOT_API explicit ConditionalMetadata(const std::string& condition);
LOOT_API explicit ConditionalMetadata(std::string_view condition);
/**
* Check if the condition string is non-empty.
+12 -4
View File
@@ -25,6 +25,7 @@
#define LOOT_METADATA_FILE
#include <string>
#include <string_view>
#include "loot/api_decorator.h"
#include "loot/metadata/conditional_metadata.h"
@@ -56,12 +57,16 @@ public:
* The detail message content, which may be appended to any messages
* generated for this file. If multilingual, one language must be
* English.
* @param constraint
* A condition string that must evaluate to true for the file's existence
* to be recognised.
* @return A File object.
*/
LOOT_API explicit File(const std::string& name,
const std::string& display = "",
const std::string& condition = "",
const std::vector<MessageContent>& detail = {});
LOOT_API explicit File(std::string_view name,
std::string_view display = "",
std::string_view condition = "",
const std::vector<MessageContent>& detail = {},
std::string_view constraint = "");
/**
* Get the filename of the file.
@@ -84,10 +89,13 @@ public:
*/
LOOT_API std::vector<MessageContent> GetDetail() const;
LOOT_API std::string GetConstraint() const;
private:
Filename name_;
std::string display_;
std::vector<MessageContent> detail_;
std::string constraint_;
};
/**
+2 -1
View File
@@ -25,6 +25,7 @@
#define LOOT_METADATA_FILENAME
#include <string>
#include <string_view>
#include "loot/api_decorator.h"
@@ -44,7 +45,7 @@ public:
* Construct a Filename using the given string.
* @return A Filename object.
*/
LOOT_API explicit Filename(const std::string& filename);
LOOT_API explicit Filename(std::string_view filename);
/**
* Get this Filename as a string.
+4 -3
View File
@@ -25,6 +25,7 @@
#define LOOT_METADATA_GROUP
#include <string>
#include <string_view>
#include <vector>
#include "loot/api_decorator.h"
@@ -38,7 +39,7 @@ public:
/**
* The name of the group to which all plugins belong by default.
*/
static constexpr const char* DEFAULT_NAME = "default";
static constexpr std::string_view DEFAULT_NAME = "default";
/**
* Construct a Group with the name "default" and an empty set of groups to
@@ -58,9 +59,9 @@ public:
* A description of the group.
* @return A Group object.
*/
LOOT_API explicit Group(const std::string& name,
LOOT_API explicit Group(std::string_view name,
const std::vector<std::string>& afterGroups = {},
const std::string& description = "");
std::string_view description = "");
/**
* Get the name of the group.
+3 -2
View File
@@ -25,6 +25,7 @@
#define LOOT_METADATA_LOCATION
#include <string>
#include <string_view>
#include <vector>
#include "loot/api_decorator.h"
@@ -49,8 +50,8 @@ public:
* A name for the URL, eg. the page or site name.
* @return A Location object.
*/
LOOT_API explicit Location(const std::string& url,
const std::string& name = "");
LOOT_API explicit Location(std::string_view url,
std::string_view name = "");
/**
* Get the object's URL.
+4 -3
View File
@@ -25,6 +25,7 @@
#define LOOT_METADATA_MESSAGE
#include <string>
#include <string_view>
#include <vector>
#include "loot/api_decorator.h"
@@ -57,8 +58,8 @@ public:
* @return A Message object.
*/
LOOT_API explicit Message(const MessageType type,
const std::string& content,
const std::string& condition = "");
std::string_view content,
std::string_view condition = "");
/**
* Construct a Message object with the given type, content and condition
@@ -73,7 +74,7 @@ public:
*/
LOOT_API explicit Message(const MessageType type,
const std::vector<MessageContent>& content,
const std::string& condition = "");
std::string_view condition = "");
/**
* Get the message type.
+5 -4
View File
@@ -26,6 +26,7 @@
#include <optional>
#include <string>
#include <string_view>
#include <vector>
#include "loot/api_decorator.h"
@@ -40,7 +41,7 @@ public:
* The code for the default language assumed for message content, which is
* "en" (English).
*/
static constexpr const char* DEFAULT_LANGUAGE = "en";
static constexpr std::string_view DEFAULT_LANGUAGE = "en";
/**
* Construct a MessageContent object with an empty English message string.
@@ -57,8 +58,8 @@ public:
* @return A MessageContent object.
*/
LOOT_API explicit MessageContent(
const std::string& text,
const std::string& language = DEFAULT_LANGUAGE);
std::string_view text,
std::string_view language = DEFAULT_LANGUAGE);
/**
* Get the message text.
@@ -144,7 +145,7 @@ LOOT_API bool operator>=(const MessageContent& lhs, const MessageContent& rhs);
*/
LOOT_API std::optional<MessageContent> SelectMessageContent(
const std::vector<MessageContent> content,
const std::string& language);
std::string_view language);
}
#endif

Some files were not shown because too many files have changed in this diff Show More