#include #include "refl/refl.h" using namespace std; using namespace refl; struct vec3_parent { virtual int norm(int x1, int& x2) { x2 = x1 * x2; return x2; //cout << x2 << "vec3_parent::norm" << endl; } }; struct vec4 { string name{ "hello" }; }; struct vec3_Meta; struct vec3 : public vec3_parent { using MyMeta = vec3_Meta; __cppast(Meta = { 0.f}) float x = 1; __cppast(Meta = { 0.f}) float y = 2; __cppast(Meta = { 0.f}) float z = 3; string name{ "hellohellohellohellohellohello" }; __cppast(Meta = { {3,4} }) int norm(int x1, int& x2)override { int tmp = x1 * 2 + 1; x1 = x2; x2 = tmp; return x2; //cout << x2 << "vec3::norm" << endl; } virtual float norm1(int& x1) { x1 = x1 * x * y * z; //x = x1; //y = x1 - 1; //z = x1 - 10; //cout << x1 << "::norm1" << endl; return x1; } static void norm2(int x1 = 10) { cout << x1 << "::norm2" << endl; } static void norm3(int x1 = 10) { x1 = x1 * 10; cout << x1 << "::norm3" << endl; } }; struct vec3_Static_Meta { //这里好像不需要 consteval static auto __StaticFields() { return std::make_tuple(&vec3::x, &vec3::y, &vec3::z, &vec3::norm, &vec3::norm1, &vec3::norm2); }; consteval static auto __MakeStaticFields() { return std::array{ StaticMemberField(&vec3::x, "x", {0.f,vec4{}}), StaticMemberField(&vec3::y, "y", {0.f,{}}), StaticMemberField(&vec3::z, "z", {0.f,{}}), StaticMethodField(&vec3::norm, "norm", {{10,9},{}}), StaticMethodField(&vec3::norm1, "norm1", {{10},{}}), StaticMethodField(&vec3::norm2, "norm2", {{10},{}}), }; } consteval static int Size() { return fetch_meta_size(); } }; constexpr int size = vec3_Static_Meta::Size(); struct vec3_Meta : public Meta{ using MyStatic = vec3_Static_Meta; using MyUClass = UClass_Meta; inline static char s_data[MyStatic::Size()]{}; static auto __MakeFields() { char* memory = &s_data[0]; return std::array{ MemberField(&vec3::x, "x",memory, {0.f,vec4{}}), MemberField(&vec3::y, "y",memory, {0.f,{}}), MemberField(&vec3::z, "z",memory, {0.f,{}}), MethodField(&vec3::norm, "norm", memory, {{10,9},{}}), MethodField(&vec3::norm1, "norm1",memory, {{10},{}}), MethodField(&vec3::norm2, "norm2",memory, {{10},{}}), }; }; };