mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 04:39:17 +01:00
Capture values by reference in lambdas
This commit is contained in:
parent
9e4930acec
commit
b8647b94fc
@ -28,7 +28,7 @@ namespace WUPSConfigAPIBackend {
|
|||||||
namespace Intern {
|
namespace Intern {
|
||||||
WUPSConfig *GetConfigByHandle(WUPSConfigHandle handle) {
|
WUPSConfig *GetConfigByHandle(WUPSConfigHandle handle) {
|
||||||
std::lock_guard lock(sConfigsMutex);
|
std::lock_guard lock(sConfigsMutex);
|
||||||
auto itr = std::find_if(sConfigs.begin(), sConfigs.end(), [handle](auto &cur) { return handle == cur.get(); });
|
auto itr = std::find_if(sConfigs.begin(), sConfigs.end(), [&handle](auto &cur) { return handle == cur.get(); });
|
||||||
if (itr == sConfigs.end()) {
|
if (itr == sConfigs.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ namespace WUPSConfigAPIBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<WUPSConfig> PopConfigByHandle(WUPSConfigHandle handle) {
|
std::unique_ptr<WUPSConfig> PopConfigByHandle(WUPSConfigHandle handle) {
|
||||||
return pop_locked_first_if(sConfigsMutex, sConfigs, [handle](auto &cur) { return handle == cur.get(); });
|
return pop_locked_first_if(sConfigsMutex, sConfigs, [&handle](auto &cur) { return handle == cur.get(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
static WUPSConfigCategory *GetCategoryByHandleRecursive(WUPSConfigCategory *category, WUPSConfigCategoryHandle handle) {
|
static WUPSConfigCategory *GetCategoryByHandleRecursive(WUPSConfigCategory *category, WUPSConfigCategoryHandle handle) {
|
||||||
@ -54,7 +54,7 @@ namespace WUPSConfigAPIBackend {
|
|||||||
|
|
||||||
WUPSConfigCategory *GetCategoryByHandle(WUPSConfigCategoryHandle handle, bool checkRecursive) {
|
WUPSConfigCategory *GetCategoryByHandle(WUPSConfigCategoryHandle handle, bool checkRecursive) {
|
||||||
std::lock_guard lock(sConfigCategoryMutex);
|
std::lock_guard lock(sConfigCategoryMutex);
|
||||||
auto itr = std::find_if(sConfigCategories.begin(), sConfigCategories.end(), [handle](auto &cur) { return handle == cur.get(); });
|
auto itr = std::find_if(sConfigCategories.begin(), sConfigCategories.end(), [&handle](auto &cur) { return handle == cur.get(); });
|
||||||
if (itr == sConfigCategories.end()) {
|
if (itr == sConfigCategories.end()) {
|
||||||
if (checkRecursive) {
|
if (checkRecursive) {
|
||||||
std::lock_guard config_lock(sConfigsMutex);
|
std::lock_guard config_lock(sConfigsMutex);
|
||||||
@ -72,12 +72,12 @@ namespace WUPSConfigAPIBackend {
|
|||||||
|
|
||||||
|
|
||||||
std::unique_ptr<WUPSConfigCategory> PopCategoryByHandle(WUPSConfigCategoryHandle handle) {
|
std::unique_ptr<WUPSConfigCategory> PopCategoryByHandle(WUPSConfigCategoryHandle handle) {
|
||||||
return pop_locked_first_if(sConfigCategoryMutex, sConfigCategories, [handle](auto &cur) { return handle == cur.get(); });
|
return pop_locked_first_if(sConfigCategoryMutex, sConfigCategories, [&handle](auto &cur) { return handle == cur.get(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPSConfigItem *GetItemByHandle(WUPSConfigItemHandle handle) {
|
WUPSConfigItem *GetItemByHandle(WUPSConfigItemHandle handle) {
|
||||||
std::lock_guard lock(sConfigItemsMutex);
|
std::lock_guard lock(sConfigItemsMutex);
|
||||||
auto itr = std::find_if(sConfigItems.begin(), sConfigItems.end(), [handle](auto &cur) { return handle == cur.get(); });
|
auto itr = std::find_if(sConfigItems.begin(), sConfigItems.end(), [&handle](auto &cur) { return handle == cur.get(); });
|
||||||
if (itr == sConfigItems.end()) {
|
if (itr == sConfigItems.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ namespace WUPSConfigAPIBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<WUPSConfigItem> PopItemByHandle(WUPSConfigItemHandle handle) {
|
std::unique_ptr<WUPSConfigItem> PopItemByHandle(WUPSConfigItemHandle handle) {
|
||||||
return pop_locked_first_if(sConfigItemsMutex, sConfigItems, [handle](auto &cur) { return handle == cur.get(); });
|
return pop_locked_first_if(sConfigItemsMutex, sConfigItems, [&handle](auto &cur) { return handle == cur.get(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPSConfigAPIStatus CreateConfig(const char *name, WUPSConfigHandle *out) {
|
WUPSConfigAPIStatus CreateConfig(const char *name, WUPSConfigHandle *out) {
|
||||||
@ -184,11 +184,11 @@ namespace WUPSConfigAPIBackend {
|
|||||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!remove_locked_first_if(sConfigCategoryMutex, sConfigCategories, [handle](auto &cur) { return handle == cur.get(); })) {
|
if (!remove_locked_first_if(sConfigCategoryMutex, sConfigCategories, [&handle](auto &cur) { return handle == cur.get(); })) {
|
||||||
{
|
{
|
||||||
// Ignore any attempts to destroy to create root item.
|
// Ignore any attempts to destroy to create root item.
|
||||||
std::lock_guard lock(sConfigsMutex);
|
std::lock_guard lock(sConfigsMutex);
|
||||||
if (std::any_of(sConfigs.begin(), sConfigs.end(), [handle](auto &cur) { return handle == cur.get(); })) {
|
if (std::any_of(sConfigs.begin(), sConfigs.end(), [&handle](auto &cur) { return handle == cur.get(); })) {
|
||||||
return WUPSCONFIG_API_RESULT_SUCCESS;
|
return WUPSCONFIG_API_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ namespace WUPSConfigAPIBackend {
|
|||||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!remove_locked_first_if(sConfigItemsMutex, sConfigItems, [handle](auto &cur) { return cur.get() == handle; })) {
|
if (!remove_locked_first_if(sConfigItemsMutex, sConfigItems, [&handle](auto &cur) { return cur.get() == handle; })) {
|
||||||
DEBUG_FUNCTION_LINE_WARN("Failed to destroy WUPSConfigItem (handle: \"%08X\")", handle);
|
DEBUG_FUNCTION_LINE_WARN("Failed to destroy WUPSConfigItem (handle: \"%08X\")", handle);
|
||||||
return WUPSCONFIG_API_RESULT_NOT_FOUND;
|
return WUPSCONFIG_API_RESULT_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ extern "C" PluginBackendApiErrorType WUPSLoadAndLinkByDataHandle(const wups_back
|
|||||||
extern "C" PluginBackendApiErrorType WUPSDeletePluginData(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) {
|
extern "C" PluginBackendApiErrorType WUPSDeletePluginData(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) {
|
||||||
if (plugin_data_handle_list != nullptr && plugin_data_handle_list_size != 0) {
|
if (plugin_data_handle_list != nullptr && plugin_data_handle_list_size != 0) {
|
||||||
for (auto &handle : std::span(plugin_data_handle_list, plugin_data_handle_list_size)) {
|
for (auto &handle : std::span(plugin_data_handle_list, plugin_data_handle_list_size)) {
|
||||||
if (!remove_locked_first_if(gLoadedDataMutex, gLoadedData, [handle](auto &cur) { return cur->getHandle() == handle; })) {
|
if (!remove_locked_first_if(gLoadedDataMutex, gLoadedData, [&handle](auto &cur) { return cur->getHandle() == handle; })) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to delete plugin data by handle %08X", handle);
|
DEBUG_FUNCTION_LINE_ERR("Failed to delete plugin data by handle %08X", handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ namespace StorageUtils {
|
|||||||
auto res = StorageUtils::Helper::WriteStorageToSD(root, false);
|
auto res = StorageUtils::Helper::WriteStorageToSD(root, false);
|
||||||
// TODO: handle write error?
|
// TODO: handle write error?
|
||||||
|
|
||||||
if (!remove_locked_first_if(gStorageMutex, gStorage, [root](auto &cur) { return cur.getHandle() == (uint32_t) root; })) {
|
if (!remove_locked_first_if(gStorageMutex, gStorage, [&root](auto &cur) { return cur.getHandle() == (uint32_t) root; })) {
|
||||||
DEBUG_FUNCTION_LINE_WARN("Failed to close storage: Not opened (\"%08X\")", root);
|
DEBUG_FUNCTION_LINE_WARN("Failed to close storage: Not opened (\"%08X\")", root);
|
||||||
return WUPS_STORAGE_ERROR_NOT_FOUND;
|
return WUPS_STORAGE_ERROR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user