mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-26 11:49:19 +00:00
value_or_error()
This commit is contained in:
parent
a0768ec3c7
commit
71bbee0479
@ -3,6 +3,8 @@
|
||||
|
||||
#include "errors.h"
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
namespace MacOS {
|
||||
|
||||
@ -215,6 +217,11 @@ namespace MacOS {
|
||||
return f(std::move(_value));
|
||||
}
|
||||
|
||||
template<class TT=T>
|
||||
T value_or_error(typename std::enable_if<std::is_integral<TT>::value>::type * = 0) const {
|
||||
return _error ? _error : _value;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -936,10 +936,7 @@ namespace MM
|
||||
|
||||
Log("%04x DisposePtr(%08x)\n", trap, mcptr);
|
||||
|
||||
|
||||
auto rv = Native::DisposePtr(mcptr);
|
||||
|
||||
return rv.error(); //SetMemError(error);
|
||||
return Native::DisposePtr(mcptr).error();
|
||||
}
|
||||
|
||||
uint32_t GetPtrSize(uint16_t trap)
|
||||
@ -1093,7 +1090,6 @@ namespace MM
|
||||
Log("%04x ReallocHandle(%08x, %08x)\n", trap, hh, logicalSize);
|
||||
|
||||
return Native::ReallocHandle(hh, logicalSize).error();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1122,8 +1118,7 @@ namespace MM
|
||||
|
||||
Log("%04x GetHandleSize(%08x)\n", trap, hh);
|
||||
|
||||
auto rv = Native::GetHandleSize(hh);
|
||||
return rv ? rv.value() : rv.error();
|
||||
return Native::GetHandleSize(hh).value_or_error();
|
||||
}
|
||||
|
||||
uint16_t SetHandleSize(uint16_t trap)
|
||||
@ -1212,9 +1207,7 @@ namespace MM
|
||||
|
||||
Log("%04x HGetState(%08x)\n", trap, hh);
|
||||
|
||||
auto rv = Native::HGetState(hh);
|
||||
return rv ? rv.value() : rv.error();
|
||||
//return Native::HGetState(hh).then([](const tool_return<uint16_t> &rv){ return rv ? *rv : rv.error(); });
|
||||
return Native::HGetState(hh).value_or_error();
|
||||
}
|
||||
|
||||
uint16_t HSetState(uint16_t trap)
|
||||
|
Loading…
Reference in New Issue
Block a user