MixinSpec API
This commit is contained in:
10 files changed
+656
No files matched your search
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
namespace vl::reflect {
|
||||
|
||||
// Generator fills these specializations for every discoverable method pointer.
|
||||
template<auto MethodPtr>
|
||||
struct method_info {
|
||||
static_assert(sizeof(MethodPtr) == 0,
|
||||
"No reflection metadata found for this method pointer. "
|
||||
"Did you include the generated header for this class?");
|
||||
static constexpr std::string_view owner = ""; // "net/minecraft/.../LocalPlayer"
|
||||
static constexpr std::string_view name = ""; // "tick"
|
||||
static constexpr std::string_view desc = ""; // "()V"
|
||||
static constexpr bool is_static = false;
|
||||
};
|
||||
|
||||
template<auto MethodPtr>
|
||||
constexpr bool is_valid_method() {
|
||||
// If the primary template is instantiated, owner=="" and will trip this.
|
||||
return method_info<MethodPtr>::owner.size() > 0;
|
||||
}
|
||||
|
||||
template<auto MethodPtr>
|
||||
constexpr std::string_view method_owner() { return method_info<MethodPtr>::owner; }
|
||||
template<auto MethodPtr>
|
||||
constexpr std::string_view method_name() { return method_info<MethodPtr>::name; }
|
||||
template<auto MethodPtr>
|
||||
constexpr std::string_view method_desc() { return method_info<MethodPtr>::desc; }
|
||||
template<auto MethodPtr>
|
||||
constexpr bool method_is_static() { return method_info<MethodPtr>::is_static; }
|
||||
|
||||
} // namespace vl::reflect
|
||||
Reference in new issue
Block a user