VoidLoader/VoidLoaderApi/pipeline/head There was a failure building this commit
Signed-off-by: Faumaray <faumaray@gmail.com>
168 lines
12 KiB
C++
168 lines
12 KiB
C++
#pragma once
|
|
#include <Mixin/Mixin.hpp>
|
|
#include <Mixin/CallbackRegistry.hpp>
|
|
#include <Reflect/Method.hpp>
|
|
#include <Mixin/TypedAdapter.hpp>
|
|
|
|
|
|
#define MIXIN_INJECT(MethodPtr, AT_ENUM) \
|
|
static_assert(::vl::reflect::is_valid_method<MethodPtr>(), \
|
|
"MIXIN_INJECT: invalid method pointer — missing or wrong reflection"); \
|
|
struct _VL_INJECT_REG_##MethodPtr { \
|
|
_VL_INJECT_REG_##MethodPtr() { \
|
|
using _Target = typename std::remove_pointer_t<decltype(MethodPtr)>; \
|
|
::vl::mixin::InjectionSpec spec{ \
|
|
::vl::reflect::method_owner<MethodPtr>(), \
|
|
::vl::reflect::method_name<MethodPtr>(), \
|
|
::vl::reflect::method_desc<MethodPtr>(), \
|
|
AT_ENUM, ::vl::mixin::Side::Before, \
|
|
::vl::mixin::CallbackRegistry::add(_vl_make_callback_MethodPtr())\
|
|
}; \
|
|
::vl::mixin::Mixin<_Target>::add(spec); \
|
|
} \
|
|
} _vl_inject_reg_##MethodPtr; \
|
|
static ::vl::mixin::ErasedCallback _vl_make_callback_##MethodPtr()
|
|
|
|
#define MIXIN_REDIRECT(MethodPtr) \
|
|
static_assert(::vl::reflect::is_valid_method<MethodPtr>(), \
|
|
"MIXIN_REDIRECT: invalid method pointer — missing or wrong reflection"); \
|
|
struct _VL_REDIRECT_REG_##MethodPtr { \
|
|
_VL_REDIRECT_REG_##MethodPtr() { \
|
|
using _Target = typename std::remove_pointer_t<decltype(MethodPtr)>; \
|
|
::vl::mixin::RedirectSpec spec{ \
|
|
::vl::reflect::method_owner<MethodPtr>(), \
|
|
::vl::reflect::method_name<MethodPtr>(), \
|
|
::vl::reflect::method_desc<MethodPtr>(), \
|
|
::vl::mixin::CallbackRegistry::add(_vl_make_callback_MethodPtr())\
|
|
}; \
|
|
::vl::mixin::Mixin<_Target>::add(spec); \
|
|
} \
|
|
} _vl_redirect_reg_##MethodPtr; \
|
|
static ::vl::mixin::ErasedCallback _vl_make_callback_##MethodPtr()
|
|
|
|
#define MIXIN_MODIFY_CONST_INT(MethodPtr, VALUE_LITERAL) \
|
|
static_assert(::vl::reflect::is_valid_method<MethodPtr>(), \
|
|
"MIXIN_MODIFY_CONST_INT: invalid method pointer"); \
|
|
struct _VL_CONST_REG_##MethodPtr { \
|
|
_VL_CONST_REG_##MethodPtr() { \
|
|
using _Target = typename std::remove_pointer_t<decltype(MethodPtr)>; \
|
|
::vl::mixin::ModifyConstSpec spec{ \
|
|
::vl::reflect::method_owner<MethodPtr>(), \
|
|
::vl::reflect::method_name<MethodPtr>(), \
|
|
::vl::reflect::method_desc<MethodPtr>(), \
|
|
::vl::mixin::ModifyConstSpec::Int, (long long)(VALUE_LITERAL), 0.0, {}, \
|
|
0 /* static replacement by Core; no cb */ \
|
|
}; \
|
|
::vl::mixin::Mixin<_Target>::add(spec); \
|
|
} \
|
|
} _vl_const_reg_##MethodPtr;
|
|
|
|
|
|
// Inject with typed lambda: signature (Self[, Args...], CallbackInfo&)
|
|
#define MIXIN_INJECT_TYPED(MethodPtr, AT_ENUM, LAMBDA) \
|
|
struct _VL_INJECT_T_REG_##MethodPtr { \
|
|
_VL_INJECT_T_REG_##MethodPtr() { \
|
|
using _Target = typename std::remove_pointer_t<decltype(MethodPtr)>; \
|
|
::vl::mixin::InjectionSpec spec{ \
|
|
::vl::reflect::method_owner<MethodPtr>(), \
|
|
::vl::reflect::method_name<MethodPtr>(), \
|
|
::vl::reflect::method_desc<MethodPtr>(), \
|
|
AT_ENUM, ::vl::mixin::Side::Before, \
|
|
::vl::mixin::CallbackRegistry::add( \
|
|
::vl::mixin::make_typed_inject<MethodPtr>(LAMBDA) \
|
|
) \
|
|
}; \
|
|
::vl::mixin::Mixin<_Target>::add(spec); \
|
|
} \
|
|
} _vl_inject_typed_reg_##MethodPtr;
|
|
|
|
// Redirect with typed lambda: signature (Self[, Args...], CallbackInfoReturnable<Ret>&) -> Ret or void (set via ci)
|
|
#define MIXIN_REDIRECT_TYPED(MethodPtr, LAMBDA) \
|
|
struct _VL_REDIRECT_T_REG_##MethodPtr { \
|
|
_VL_REDIRECT_T_REG_##MethodPtr() { \
|
|
using _Target = typename std::remove_pointer_t<decltype(MethodPtr)>; \
|
|
::vl::mixin::RedirectSpec spec{ \
|
|
::vl::reflect::method_owner<MethodPtr>(), \
|
|
::vl::reflect::method_name<MethodPtr>(), \
|
|
::vl::reflect::method_desc<MethodPtr>(), \
|
|
::vl::mixin::CallbackRegistry::add( \
|
|
::vl::mixin::make_typed_redirect<MethodPtr>(LAMBDA) \
|
|
) \
|
|
}; \
|
|
::vl::mixin::Mixin<_Target>::add(spec); \
|
|
} \
|
|
} _vl_redirect_typed_reg_##MethodPtr;
|
|
|
|
|
|
#define MIXIN_FIELD_GET_TYPED(FieldPtr, LAMBDA, FieldT, SelfT) \
|
|
struct _VL_FIELD_GET_T_REG_##FieldPtr { \
|
|
_VL_FIELD_GET_T_REG_##FieldPtr() { \
|
|
using _Target = typename std::remove_pointer_t<decltype(FieldPtr)>; \
|
|
::vl::mixin::InjectionSpec spec{ \
|
|
::vl::reflect::method_owner<FieldPtr>(), \
|
|
::vl::reflect::method_name<FieldPtr>(), \
|
|
::vl::reflect::method_desc<FieldPtr>(), \
|
|
::vl::mixin::At::FIELD_GET, ::vl::mixin::Side::Before, \
|
|
::vl::mixin::CallbackRegistry::add( \
|
|
::vl::mixin::make_typed_field_get<FieldPtr,decltype(LAMBDA),FieldT,SelfT>(LAMBDA) \
|
|
) \
|
|
}; \
|
|
::vl::mixin::Mixin<_Target>::add(spec); \
|
|
} \
|
|
} _vl_field_get_typed_reg_##FieldPtr;
|
|
|
|
#define MIXIN_FIELD_PUT_TYPED(FieldPtr, LAMBDA, FieldT, SelfT) \
|
|
struct _VL_FIELD_PUT_T_REG_##FieldPtr { \
|
|
_VL_FIELD_PUT_T_REG_##FieldPtr() { \
|
|
using _Target = typename std::remove_pointer_t<decltype(FieldPtr)>; \
|
|
::vl::mixin::InjectionSpec spec{ \
|
|
::vl::reflect::method_owner<FieldPtr>(), \
|
|
::vl::reflect::method_name<FieldPtr>(), \
|
|
::vl::reflect::method_desc<FieldPtr>(), \
|
|
::vl::mixin::At::FIELD_PUT, ::vl::mixin::Side::Before, \
|
|
::vl::mixin::CallbackRegistry::add( \
|
|
::vl::mixin::make_typed_field_put<FieldPtr,decltype(LAMBDA),FieldT,SelfT>(LAMBDA) \
|
|
) \
|
|
}; \
|
|
::vl::mixin::Mixin<_Target>::add(spec); \
|
|
} \
|
|
} _vl_field_put_typed_reg_##FieldPtr;
|
|
|
|
#define MIXIN_INVOKE_BEFORE_TYPED(MethodPtr, InvokeTargetPtr, LAMBDA) \
|
|
struct _VL_INVOKE_B_T_REG_##MethodPtr##_##InvokeTargetPtr { \
|
|
_VL_INVOKE_B_T_REG_##MethodPtr##_##InvokeTargetPtr() { \
|
|
using _Target = typename std::remove_pointer_t<decltype(MethodPtr)>; \
|
|
::vl::mixin::InjectionSpec spec{}; \
|
|
spec.owner = ::vl::reflect::method_owner<MethodPtr>(); \
|
|
spec.methodName = ::vl::reflect::method_name<MethodPtr>(); \
|
|
spec.methodDesc = ::vl::reflect::method_desc<MethodPtr>(); \
|
|
spec.kind = ::vl::mixin::PointKind::Invoke; \
|
|
spec.when = ::vl::mixin::Side::Before; \
|
|
spec.cb = ::vl::mixin::CallbackRegistry::add( \
|
|
::vl::mixin::make_typed_invoke_before<InvokeTargetPtr>(LAMBDA)); \
|
|
spec.invoke.owner = ::vl::reflect::method_owner<InvokeTargetPtr>(); \
|
|
spec.invoke.name = ::vl::reflect::method_name<InvokeTargetPtr>(); \
|
|
spec.invoke.desc = ::vl::reflect::method_desc<InvokeTargetPtr>(); \
|
|
::vl::mixin::Mixin<_Target>::add(spec); \
|
|
} \
|
|
} _vl_invoke_before_typed_reg_##MethodPtr##_##InvokeTargetPtr;
|
|
|
|
// After a specific invoke inside a method
|
|
#define MIXIN_INVOKE_AFTER_TYPED(MethodPtr, InvokeTargetPtr, LAMBDA) \
|
|
struct _VL_INVOKE_A_T_REG_##MethodPtr##_##InvokeTargetPtr { \
|
|
_VL_INVOKE_A_T_REG_##MethodPtr##_##InvokeTargetPtr() { \
|
|
using _Target = typename std::remove_pointer_t<decltype(MethodPtr)>; \
|
|
::vl::mixin::InjectionSpec spec{}; \
|
|
spec.owner = ::vl::reflect::method_owner<MethodPtr>(); \
|
|
spec.methodName = ::vl::reflect::method_name<MethodPtr>(); \
|
|
spec.methodDesc = ::vl::reflect::method_desc<MethodPtr>(); \
|
|
spec.kind = ::vl::mixin::PointKind::Invoke; \
|
|
spec.when = ::vl::mixin::Side::After; \
|
|
spec.cb = ::vl::mixin::CallbackRegistry::add( \
|
|
::vl::mixin::make_typed_invoke_after<InvokeTargetPtr>(LAMBDA)); \
|
|
spec.invoke.owner = ::vl::reflect::method_owner<InvokeTargetPtr>(); \
|
|
spec.invoke.name = ::vl::reflect::method_name<InvokeTargetPtr>(); \
|
|
spec.invoke.desc = ::vl::reflect::method_desc<InvokeTargetPtr>(); \
|
|
::vl::mixin::Mixin<_Target>::add(spec); \
|
|
} \
|
|
} _vl_invoke_after_typed_reg_##MethodPtr##_##InvokeTargetPtr; |