32 lines
738 B
C
32 lines
738 B
C
|
|
#pragma once
|
||
|
|
#include "type.h"
|
||
|
|
#include "field.h"
|
||
|
|
namespace refl {
|
||
|
|
class UClass{
|
||
|
|
public:
|
||
|
|
Name name;
|
||
|
|
uint32_t size;
|
||
|
|
public:
|
||
|
|
void Var() {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public:
|
||
|
|
template<typename T>
|
||
|
|
constexpr static UClass BuildClass() {
|
||
|
|
return {type_name<T>().View(), sizeof(T)};
|
||
|
|
}
|
||
|
|
protected:
|
||
|
|
template<uint32_t offset, typename T,typename U>
|
||
|
|
FieldPtr MakeMemberField(T U::* ptr, Name name) {
|
||
|
|
FieldPtr::Data member = { offset };
|
||
|
|
return { name, &TypeInfo<T>::StaticClass, {member} };
|
||
|
|
}
|
||
|
|
};
|
||
|
|
template<typename T, typename>
|
||
|
|
struct TypeInfo {
|
||
|
|
using UClass = UClass;
|
||
|
|
//这里的语法我也看不懂呀,防警告的,显示声明为模板调用
|
||
|
|
inline constexpr static UClass StaticClass = UClass::template BuildClass<T>();
|
||
|
|
};
|
||
|
|
}
|