40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
#include <iostream>
|
|
#include <array>
|
|
#include "refl/uclass.h"
|
|
#include "vertex.h"
|
|
using namespace std;
|
|
using namespace refl;
|
|
struct vec3 {
|
|
using UClass = class vec3_UClass;
|
|
float x;
|
|
float y;
|
|
float z;
|
|
float norm() {
|
|
return x * y * z;
|
|
}
|
|
};
|
|
struct vec3_UClass : public UClass {
|
|
array<FieldPtr,3> FList;
|
|
constexpr static vec3_UClass BuildClass() {
|
|
vec3_UClass cls{};
|
|
cls.name = type_name<vec3>().View();
|
|
cls.size = sizeof(vec3);
|
|
//offsetof(vec3, x) 很坑,相当坑
|
|
cls.FList[0] = cls.MakeMemberField<offsetof(vec3, x)>(&vec3::x, "x");
|
|
cls.FList[1] = cls.MakeMemberField<offsetof(vec3, y)>(&vec3::y, "y");
|
|
cls.FList[2] = cls.MakeMemberField<offsetof(vec3, z)>(&vec3::z, "z");
|
|
return cls;
|
|
}
|
|
};
|
|
int main() {
|
|
|
|
using uclass = TypeInfo<vec3>::UClass;
|
|
auto& res = TypeInfo<int>::StaticClass;
|
|
auto& res2 = TypeInfo<float>::StaticClass;
|
|
|
|
auto& res3 = TypeInfo<vec3>::StaticClass;
|
|
auto t1 = res3.FList[0];
|
|
//using t2 = t1::UClass;
|
|
std::cout << sizeof(Name) << "Type2: " << typeid(vec3).name() << std::endl;
|
|
cout << "hello world\n";
|
|
} |