libER 0.1.4.2
ELDEN RING API library
Loading...
Searching...
No Matches
reflection.hpp
Go to the documentation of this file.
1
8#pragma once
9
11#include <detail/preprocessor.hpp>
12#include <detail/symbols.hpp>
15
16#include <algorithm>
17#include <string>
18
19namespace from {
20namespace DLRF {
21class DLRuntimeClass;
22class DLMethodInvoker;
23
29 LIBER_CLASS(DLRuntimeMethod);
30
36 const char* get_method_name() const noexcept {
37 return this->method_name;
38 }
39
45 const wchar_t* get_method_name_w() const noexcept {
46 return this->method_name_w;
47 }
48
56 return this->invokers;
57 }
58
59private:
60 friend class DLRuntimeClass;
61
62 DLRuntimeClass* owner;
63 const char* method_name;
64 const wchar_t* method_name_w;
66 from::vector<void*> liber_unknown;
67 void* liber_unknown;
69};
70
80public:
81 LIBER_CLASS(DLRuntimeClass);
82
83 virtual ~DLRuntimeClass() = default;
84
91 virtual const char* get_class_name() const noexcept = 0;
92
99 virtual const wchar_t* get_class_name_w() const noexcept = 0;
100
101private:
102 virtual void* liber_unknown() = 0;
103 virtual void* liber_unknown() = 0;
104 virtual void* liber_unknown() = 0;
105 virtual void* liber_unknown() = 0;
106 virtual bool liber_unknown() = 0;
107 virtual void liber_unknown() = 0;
108
109public:
116 virtual size_t get_class_size() const noexcept = 0;
117
118private:
119 virtual void liber_unknown() = 0;
120 virtual void liber_unknown() = 0;
121
122public:
129 const DLRuntimeClass* get_class_base() const noexcept {
130 return this->base_class;
131 }
132
133 template <typename T>
135 T* instance;
136 const char* name;
137 const wchar_t* name_w;
138 size_t name_length;
139 };
140
143
157 using pointer_type =
159 return liber::symbol<"GLOBAL_DLRuntimeClass_types">::as<pointer_type>()
160 .get();
161 }
162
163 static DLRuntimeClass* get_runtime_class(
164 std::string_view class_name) noexcept {
165 const auto* classes = get_registered_classes();
166 if (!classes)
167 return nullptr;
168 auto iter = std::lower_bound(classes->begin(), classes->end(),
169 class_name,
170 [](const DLRuntimeClassHolder& holder,
171 const std::string_view& rhs) {
172 return std::string_view(holder.name, holder.name_length) < rhs;
173 });
174 if (iter == classes->end()
175 || std::string_view(iter->name, iter->name_length) != class_name)
176 return nullptr;
177 return iter->instance;
178 }
179
187 return this->runtime_methods;
188 }
189
190private:
191 // A pointer to the base class, if the class is derived
192 DLRuntimeClass* base_class;
193 // A DLRuntimeMethod of the class's constructor
194 DLRuntimeMethod* runtime_constructor;
195 // A vector of DLRuntimeMethodHolders sorted by string length
197};
198} // namespace DLRF
199} // namespace from
A wrapper around a Windows kernel mutex.
Definition kernel_runtime.hpp:92
Abstract class used for type reflection.
Definition reflection.hpp:79
const from::vector< DLRuntimeMethodHolder > & get_methods() const noexcept
Get every bound method.
Definition reflection.hpp:186
static const from::vector< DLRuntimeClassHolder > * get_registered_classes() noexcept
Get a vector of all globally registered DLRuntimeClasses.
Definition reflection.hpp:156
virtual const wchar_t * get_class_name_w() const noexcept=0
Get the name of the type (wide).
virtual const char * get_class_name() const noexcept=0
Get the name of the type.
const DLRuntimeClass * get_class_base() const noexcept
Get a derived class's base class.
Definition reflection.hpp:129
virtual size_t get_class_size() const noexcept=0
Get the size of the type.
Definition from_memory.hpp:16
ELDEN RING memory utilities.
from::vector based on std::vector
std::vector< T, from::allocator< T > > vector
std::vector with from::allocator.
Definition from_vector.hpp:23
Dantelion2 kernel object management and synchronization.
A wrapper that represents a method with a vector of invoker objects.
Definition reflection.hpp:28
const char * get_method_name() const noexcept
Get the method name.
Definition reflection.hpp:36
const from::vector< DLMethodInvoker * > & get_invokers() const noexcept
Get all the invokers bound to this method.
Definition reflection.hpp:55
const wchar_t * get_method_name_w() const noexcept
Get the method name (wide).
Definition reflection.hpp:45