mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-08-28 13:55:26 -05:00
Make PluginLinkInformation not optional anymore in PluginContainer, add stub link data if missing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "PluginContainer.h"
|
||||
#include "utils/storage/StorageUtils.h"
|
||||
|
||||
PluginContainer::PluginContainer(PluginMetaInformation metaInformation, std::optional<PluginLinkInformation> pluginLinkInformation, std::shared_ptr<PluginData> pluginData)
|
||||
PluginContainer::PluginContainer(PluginMetaInformation metaInformation, PluginLinkInformation pluginLinkInformation, std::shared_ptr<PluginData> pluginData)
|
||||
: mMetaInformation(std::move(metaInformation)),
|
||||
mPluginLinkInformation(std::move(pluginLinkInformation)),
|
||||
mPluginData(std::move(pluginData)) {
|
||||
@@ -39,22 +39,13 @@ const PluginMetaInformation &PluginContainer::getMetaInformation() const {
|
||||
return this->mMetaInformation;
|
||||
}
|
||||
|
||||
bool PluginContainer::isPluginLinkedAndLoaded() const {
|
||||
return this->mPluginLinkInformation.has_value();
|
||||
|
||||
const PluginLinkInformation &PluginContainer::getPluginLinkInformation() const {
|
||||
return this->mPluginLinkInformation;
|
||||
}
|
||||
|
||||
const PluginLinkInformation *PluginContainer::getPluginLinkInformation() const {
|
||||
if (this->mPluginLinkInformation.has_value()) {
|
||||
return this->mPluginLinkInformation.operator->();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PluginLinkInformation *PluginContainer::getPluginLinkInformation() {
|
||||
if (this->mPluginLinkInformation.has_value()) {
|
||||
return this->mPluginLinkInformation.operator->();
|
||||
}
|
||||
return nullptr;
|
||||
PluginLinkInformation &PluginContainer::getPluginLinkInformation() {
|
||||
return this->mPluginLinkInformation;
|
||||
}
|
||||
|
||||
std::shared_ptr<PluginData> PluginContainer::getPluginDataCopy() const {
|
||||
@@ -73,6 +64,10 @@ void PluginContainer::setConfigData(const PluginConfigData &pluginConfigData) {
|
||||
mPluginConfigData = pluginConfigData;
|
||||
}
|
||||
|
||||
bool PluginContainer::isLinkedAndLoaded() const {
|
||||
return mPluginLinkInformation.hasValidData();
|
||||
}
|
||||
|
||||
WUPSStorageError PluginContainer::OpenStorage() {
|
||||
if (getMetaInformation().getWUPSVersion() < WUPSVersion(0, 8, 0)) {
|
||||
return WUPS_STORAGE_ERROR_SUCCESS;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
class PluginContainer {
|
||||
public:
|
||||
PluginContainer(PluginMetaInformation metaInformation, std::optional<PluginLinkInformation> pluginLinkInformation, std::shared_ptr<PluginData> pluginData);
|
||||
PluginContainer(PluginMetaInformation metaInformation, PluginLinkInformation pluginLinkInformation, std::shared_ptr<PluginData> pluginData);
|
||||
|
||||
PluginContainer(const PluginContainer &) = delete;
|
||||
|
||||
@@ -38,18 +38,18 @@ public:
|
||||
|
||||
[[nodiscard]] const PluginMetaInformation &getMetaInformation() const;
|
||||
|
||||
[[nodiscard]] const PluginLinkInformation *getPluginLinkInformation() const;
|
||||
[[nodiscard]] const PluginLinkInformation &getPluginLinkInformation() const;
|
||||
|
||||
[[nodiscard]] PluginLinkInformation *getPluginLinkInformation();
|
||||
[[nodiscard]] PluginLinkInformation &getPluginLinkInformation();
|
||||
|
||||
[[nodiscard]] std::shared_ptr<PluginData> getPluginDataCopy() const;
|
||||
|
||||
[[nodiscard]] bool isPluginLinkedAndLoaded() const;
|
||||
|
||||
[[nodiscard]] uint32_t getHandle() const;
|
||||
|
||||
[[nodiscard]] const std::optional<PluginConfigData> &getConfigData() const;
|
||||
|
||||
[[nodiscard]] bool isLinkedAndLoaded() const;
|
||||
|
||||
void setConfigData(const PluginConfigData &pluginConfigData);
|
||||
|
||||
WUPSStorageError OpenStorage();
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
private:
|
||||
PluginMetaInformation mMetaInformation;
|
||||
std::optional<PluginLinkInformation> mPluginLinkInformation;
|
||||
PluginLinkInformation mPluginLinkInformation;
|
||||
std::shared_ptr<PluginData> mPluginData;
|
||||
|
||||
std::optional<PluginConfigData> mPluginConfigData = std::nullopt;
|
||||
|
||||
@@ -111,3 +111,11 @@ const HeapMemoryFixedSize &PluginLinkInformation::getTextMemory() const {
|
||||
const HeapMemoryFixedSize &PluginLinkInformation::getDataMemory() const {
|
||||
return mAllocatedDataMemoryAddress;
|
||||
}
|
||||
|
||||
PluginLinkInformation PluginLinkInformation::CreateStub() {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool PluginLinkInformation::hasValidData() const {
|
||||
return mAllocatedDataMemoryAddress.size() > 0 && mAllocatedTextMemoryAddress.size() > 0;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ struct FunctionSymbolDataComparator {
|
||||
|
||||
class PluginLinkInformation {
|
||||
public:
|
||||
static PluginLinkInformation CreateStub();
|
||||
|
||||
PluginLinkInformation(const PluginLinkInformation &) = delete;
|
||||
|
||||
PluginLinkInformation(PluginLinkInformation &&src) noexcept;
|
||||
@@ -65,6 +67,8 @@ public:
|
||||
|
||||
[[nodiscard]] const HeapMemoryFixedSize &getDataMemory() const;
|
||||
|
||||
[[nodiscard]] bool hasValidData() const;
|
||||
|
||||
private:
|
||||
PluginLinkInformation() = default;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user