This commit is contained in:
Jaby
2022-12-16 03:47:30 +01:00
parent 8a6293dc87
commit 04739004f5
5 changed files with 53 additions and 7 deletions

View File

@@ -4,20 +4,33 @@
namespace JabyEngine {
struct NextRoutine {
typedef NextRoutine (*ExecutionFunction)();
static constexpr uintptr_t OverlayBit = (1 << ((sizeof(uintptr_t)*8) - 2));
typedef NextRoutine (*MainRoutine)();
uintptr_t value;
static NextRoutine null() {
constexpr static NextRoutine null() {
return {.value = 0};
}
static NextRoutine from(ExecutionFunction function) {
static NextRoutine from(MainRoutine function) {
return {.value = reinterpret_cast<uintptr_t>(function)};
}
constexpr bool is_overlay() const {
return (this->value & OverlayBit);
}
constexpr bool is_absolute() const {
return !NextRoutine::is_overlay();
}
constexpr bool is_null() const {
return this->value == 0;
}
};
typedef NextRoutine::ExecutionFunction ExecutionFunction;
typedef NextRoutine::MainRoutine MainRoutine;
}
#endif //!__JABYENGINE__H__