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