mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-09-09 04:19:35 -05:00
Remove unnecessary std::unique_ptr usages
This commit is contained in:
@@ -72,16 +72,16 @@ void ConfigUtils::displayMenu() {
|
||||
renderBasicScreen("Loading configs...");
|
||||
|
||||
std::vector<ConfigDisplayItem> configs;
|
||||
for (auto &plugin : gLoadedPlugins) {
|
||||
for (const auto &plugin : gLoadedPlugins) {
|
||||
GeneralConfigInformation info;
|
||||
info.name = plugin->getMetaInformation().getName();
|
||||
info.author = plugin->getMetaInformation().getAuthor();
|
||||
info.version = plugin->getMetaInformation().getVersion();
|
||||
info.name = plugin.getMetaInformation().getName();
|
||||
info.author = plugin.getMetaInformation().getAuthor();
|
||||
info.version = plugin.getMetaInformation().getVersion();
|
||||
|
||||
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config;
|
||||
auto configData = plugin->getConfigData();
|
||||
const auto configData = plugin.getConfigData();
|
||||
if (configData) {
|
||||
auto configHandleOpt = configData->createConfig();
|
||||
const auto configHandleOpt = configData->createConfig();
|
||||
if (configHandleOpt) {
|
||||
WUPSConfigAPIStatus callbackResult = configData->CallMenuOpenendCallback(configHandleOpt.value());
|
||||
config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(configHandleOpt.value());
|
||||
@@ -97,13 +97,13 @@ void ConfigUtils::displayMenu() {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to create config for plugin: \"%s\"", info.name.c_str());
|
||||
}
|
||||
} else {
|
||||
for (const auto &hook : plugin->getPluginInformation().getHookDataList()) {
|
||||
if (hook->getType() == WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED) {
|
||||
if (hook->getFunctionPointer() == nullptr) {
|
||||
for (const auto &hook : plugin.getPluginInformation().getHookDataList()) {
|
||||
if (hook.getType() == WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED) {
|
||||
if (hook.getFunctionPointer() == nullptr) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Hook had invalid ptr");
|
||||
break;
|
||||
}
|
||||
auto cur_config_handle = ((void *(*) ())((uint32_t *) hook->getFunctionPointer()))();
|
||||
auto cur_config_handle = ((void *(*) ())((uint32_t *) hook.getFunctionPointer()))();
|
||||
if (cur_config_handle == nullptr) {
|
||||
DEBUG_FUNCTION_LINE_WARN("Hook returned empty handle");
|
||||
break;
|
||||
@@ -183,12 +183,14 @@ void ConfigUtils::displayMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &plugin : gLoadedPlugins) {
|
||||
auto configData = plugin->getConfigData();
|
||||
for (const auto &plugin : gLoadedPlugins) {
|
||||
const auto configData = plugin.getConfigData();
|
||||
if (configData) {
|
||||
configData->CallMenuClosedCallback();
|
||||
if (configData->CallMenuClosedCallback() == WUPSCONFIG_API_RESULT_MISSING_CALLBACK) {
|
||||
DEBUG_FUNCTION_LINE_WARN("CallMenuClosedCallback is missing for %s", plugin.getMetaInformation().getName().c_str());
|
||||
}
|
||||
} else {
|
||||
CallHook(*plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED);
|
||||
CallHook(plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformation(WUPSBackendGet
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
std::unique_ptr<PluginMetaInformation> pluginInfo;
|
||||
std::optional<PluginMetaInformation> pluginInfo;
|
||||
PluginParseErrors error = PLUGIN_PARSE_ERROR_UNKNOWN;
|
||||
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != nullptr) {
|
||||
pluginInfo = PluginMetaInformationFactory::loadPlugin(path, error);
|
||||
@@ -136,8 +136,8 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const
|
||||
auto handle = plugin_container_handle_list[i];
|
||||
bool found = false;
|
||||
for (const auto &curContainer : gLoadedPlugins) {
|
||||
if (curContainer->getHandle() == handle) {
|
||||
auto pluginData = curContainer->getPluginDataCopy();
|
||||
if (curContainer.getHandle() == handle) {
|
||||
auto pluginData = curContainer.getPluginDataCopy();
|
||||
plugin_data_list[i] = (uint32_t) pluginData->getHandle();
|
||||
gLoadedData.insert(std::move(pluginData));
|
||||
found = true;
|
||||
@@ -160,8 +160,8 @@ extern "C" PluginBackendApiErrorType WUPSGetMetaInformation(const wups_backend_p
|
||||
auto handle = plugin_container_handle_list[i];
|
||||
bool found = false;
|
||||
for (const auto &curContainer : gLoadedPlugins) {
|
||||
if (curContainer->getHandle() == handle) {
|
||||
const auto &metaInfo = curContainer->getMetaInformation();
|
||||
if (curContainer.getHandle() == handle) {
|
||||
const auto &metaInfo = curContainer.getMetaInformation();
|
||||
|
||||
plugin_information_list[i].plugin_information_version = WUPS_BACKEND_PLUGIN_INFORMATION_VERSION;
|
||||
strncpy(plugin_information_list[i].storageId, metaInfo.getStorageId().c_str(), sizeof(plugin_information_list[i].storageId) - 1);
|
||||
@@ -196,7 +196,7 @@ extern "C" PluginBackendApiErrorType WUPSGetLoadedPlugins(wups_backend_plugin_co
|
||||
uint32_t counter = 0;
|
||||
for (const auto &plugin : gLoadedPlugins) {
|
||||
if (counter < buffer_size) {
|
||||
io_handles[counter] = plugin->getHandle();
|
||||
io_handles[counter] = plugin.getHandle();
|
||||
counter++;
|
||||
} else {
|
||||
break;
|
||||
@@ -245,9 +245,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionInformationForPlugin(const wu
|
||||
if (handle != 0 && plugin_section_list != nullptr && buffer_size != 0) {
|
||||
bool found = false;
|
||||
for (const auto &curContainer : gLoadedPlugins) {
|
||||
if (curContainer->getHandle() == handle) {
|
||||
if (curContainer.getHandle() == handle) {
|
||||
found = true;
|
||||
const auto §ionInfoList = curContainer->getPluginInformation().getSectionInfoList();
|
||||
const auto §ionInfoList = curContainer.getPluginInformation().getSectionInfoList();
|
||||
|
||||
uint32_t offset = 0;
|
||||
for (auto const &[key, sectionInfo] : sectionInfoList) {
|
||||
@@ -255,9 +255,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionInformationForPlugin(const wu
|
||||
break;
|
||||
}
|
||||
plugin_section_list[offset].plugin_section_info_version = WUPS_BACKEND_PLUGIN_SECTION_INFORMATION_VERSION;
|
||||
strncpy(plugin_section_list[offset].name, sectionInfo->getName().c_str(), sizeof(plugin_section_list[offset].name) - 1);
|
||||
plugin_section_list[offset].address = (void *) sectionInfo->getAddress();
|
||||
plugin_section_list[offset].size = sectionInfo->getSize();
|
||||
strncpy(plugin_section_list[offset].name, sectionInfo.getName().c_str(), sizeof(plugin_section_list[offset].name) - 1);
|
||||
plugin_section_list[offset].address = (void *) sectionInfo.getAddress();
|
||||
plugin_section_list[offset].size = sectionInfo.getSize();
|
||||
offset++;
|
||||
}
|
||||
if (out_count != nullptr) {
|
||||
@@ -289,9 +289,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionMemoryAddresses(wups_backend_
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
for (const auto &curContainer : gLoadedPlugins) {
|
||||
if (curContainer->getHandle() == handle) {
|
||||
*textAddress = (void *) curContainer->getPluginInformation().getTextMemory().data();
|
||||
*dataAddress = (void *) curContainer->getPluginInformation().getDataMemory().data();
|
||||
if (curContainer.getHandle() == handle) {
|
||||
*textAddress = (void *) curContainer.getPluginInformation().getTextMemory().data();
|
||||
*dataAddress = (void *) curContainer.getPluginInformation().getDataMemory().data();
|
||||
return PLUGIN_BACKEND_API_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user