mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-28 23:49:26 +00:00
.
This commit is contained in:
parent
5a723e4fee
commit
5b0d9e7d07
@ -106,17 +106,7 @@ namespace
|
|||||||
namespace MM
|
namespace MM
|
||||||
{
|
{
|
||||||
|
|
||||||
|
using MacOS::tool_return_type;
|
||||||
template<class T>
|
|
||||||
struct tool_return_type { typedef tool_return<T> type; };
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct tool_return_type<MacOS::macos_error> { typedef tool_return<void> type; };
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct tool_return_type<tool_return<T>> { typedef tool_return<T> type; };
|
|
||||||
|
|
||||||
|
|
||||||
template<class T, class FRT, class F>
|
template<class T, class FRT, class F>
|
||||||
T with_handle_helper(F &&f, HandleInfo &info, typename std::enable_if<!std::is_void<FRT>::value>::type* = 0) {
|
T with_handle_helper(F &&f, HandleInfo &info, typename std::enable_if<!std::is_void<FRT>::value>::type* = 0) {
|
||||||
@ -137,12 +127,11 @@ namespace MM
|
|||||||
typename TRT = typename tool_return_type<FRT>::type> // tool return type.
|
typename TRT = typename tool_return_type<FRT>::type> // tool return type.
|
||||||
TRT __with_handle(uint32_t handle, F &&f)
|
TRT __with_handle(uint32_t handle, F &&f)
|
||||||
{
|
{
|
||||||
|
if (handle == 0) return SetMemError(MacOS::nilHandleErr);
|
||||||
|
|
||||||
const auto iter = HandleMap.find(handle);
|
const auto iter = HandleMap.find(handle);
|
||||||
|
|
||||||
if (iter == HandleMap.end()) {
|
if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr);
|
||||||
TRT rv = SetMemError(MacOS::memWZErr);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto &info = iter->second;
|
auto &info = iter->second;
|
||||||
TRT rv = with_handle_helper<TRT, FRT>(std::forward<F>(f), info);
|
TRT rv = with_handle_helper<TRT, FRT>(std::forward<F>(f), info);
|
||||||
|
Loading…
Reference in New Issue
Block a user