44 lines
1.3 KiB
Plaintext
44 lines
1.3 KiB
Plaintext
|
|
#include "uclass.h"
|
||
|
|
#include "name.h"
|
||
|
|
namespace refl{
|
||
|
|
namespace detail {
|
||
|
|
inline static pmr::FrameAllocatorPool MemPool{};
|
||
|
|
}
|
||
|
|
template <class T>
|
||
|
|
concept is_metas_v = false;//requires(const Name & name) { MetaImpl<T>::MyMetas::GetMeta(name); };
|
||
|
|
template<typename T>
|
||
|
|
class UClass_Auto : public UClass {
|
||
|
|
using UClass::UClass;
|
||
|
|
using MyUClass = UClass_Auto<T>;
|
||
|
|
public:
|
||
|
|
static MyUClass* BuildClass() {
|
||
|
|
MyUClass* cls = new(detail::MemPool)MyUClass(type_name<T>().View(), sizeof(T));
|
||
|
|
if constexpr (std::is_pointer_v<T>) {
|
||
|
|
using RT = std::remove_pointer_t<T>;
|
||
|
|
cls->flag |= CLASS_POINTER_FLAG;
|
||
|
|
if constexpr (!std::is_same_v<RT, void>) {
|
||
|
|
cls->parent = TypeInfo<RT>::StaticClass;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if constexpr (is_array_v<T>) {
|
||
|
|
using RT = is_array_t<T>;
|
||
|
|
cls->flag = CLASS_ARRAY_FLAG;
|
||
|
|
if constexpr (std::is_pointer_v<RT>) {
|
||
|
|
cls->flag |= CLASS_POINTER_FLAG;
|
||
|
|
}
|
||
|
|
cls->parent = TypeInfo<RT>::StaticClass;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
cls->vtable = new(detail::MemPool)vtable_uclass();
|
||
|
|
cls->vtable->Construct = &UClass::Construct<T>;
|
||
|
|
cls->vtable->Destruct = &UClass::Destruct<T>;
|
||
|
|
}
|
||
|
|
return cls;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
template<typename T>
|
||
|
|
struct TypeInfoImpl {
|
||
|
|
using MyUClass = UClass_Auto<T>;
|
||
|
|
inline static MyUClass* StaticClass = MyUClass::BuildClass();
|
||
|
|
};
|
||
|
|
}
|