zengine-old/engine/3rdparty/zlib/test/refl/vertex.h

84 lines
2.2 KiB
C
Raw Normal View History

2024-04-11 10:13:15 +08:00
#include <iostream>
#include "refl/refl.h"
2024-04-03 17:58:02 +08:00
using namespace std;
2024-04-11 10:13:15 +08:00
using namespace refl;
struct vec3_parent {
2024-04-16 16:17:13 +08:00
virtual int norm(int x1, int& x2) {
2024-04-11 10:13:15 +08:00
x2 = x1 * x2;
2024-04-16 16:17:13 +08:00
return x2;
2024-04-11 10:13:15 +08:00
//cout << x2 << "vec3_parent::norm" << endl;
}
2024-04-03 17:58:02 +08:00
};
2024-04-19 22:02:27 +08:00
struct vec4 {
string name{ "hello" };
};
struct vec3_Meta;
2024-04-11 10:13:15 +08:00
struct vec3 : public vec3_parent {
2024-04-19 22:02:27 +08:00
using MyMeta = vec3_Meta;
__cppast(Meta = { 0.f})
2024-04-11 10:13:15 +08:00
float x = 1;
2024-04-19 22:02:27 +08:00
__cppast(Meta = { 0.f})
2024-04-11 10:13:15 +08:00
float y = 2;
2024-04-19 22:02:27 +08:00
__cppast(Meta = { 0.f})
2024-04-11 10:13:15 +08:00
float z = 3;
string name{ "hellohellohellohellohellohello" };
2024-04-19 22:02:27 +08:00
__cppast(Meta = { {3,4} })
2024-04-16 16:17:13 +08:00
int norm(int x1, int& x2)override {
int tmp = x1 * 2 + 1;
x1 = x2;
x2 = tmp;
return x2;
//cout << x2 << "vec3::norm" << endl;
2024-04-11 10:13:15 +08:00
}
virtual float norm1(int& x1) {
2024-04-15 19:53:39 +08:00
x1 = x1 * x * y * z;
2024-04-11 10:13:15 +08:00
//x = x1;
//y = x1 - 1;
//z = x1 - 10;
//cout << x1 << "::norm1" << endl;
return x1;
}
static void norm2(int x1 = 10) {
2024-04-15 19:53:39 +08:00
cout << x1 << "::norm2" << endl;
2024-04-11 10:13:15 +08:00
}
static void norm3(int x1 = 10) {
x1 = x1 * 10;
2024-04-15 19:53:39 +08:00
cout << x1 << "::norm3" << endl;
2024-04-11 10:13:15 +08:00
}
2024-04-19 22:02:27 +08:00
};
struct vec3_Static_Meta {
2024-04-15 19:53:39 +08:00
//这里好像不需要
consteval static auto __StaticFields() {
return std::make_tuple(&vec3::x, &vec3::y, &vec3::z, &vec3::norm, &vec3::norm1, &vec3::norm2);
};
2024-04-14 22:45:08 +08:00
consteval static auto __MakeStaticFields() {
return std::array{
2024-04-19 22:02:27 +08:00
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},{}}),
2024-04-14 22:45:08 +08:00
};
}
2024-04-19 22:02:27 +08:00
consteval static int Size() {
return fetch_meta_size<vec3_Static_Meta>();
}
};
constexpr int size = vec3_Static_Meta::Size();
struct vec3_Meta : public Meta{
using MyStatic = vec3_Static_Meta;
using MyUClass = UClass_Meta<vec3, vec3_parent>;
inline static char s_data[MyStatic::Size()]{};
2024-04-14 22:45:08 +08:00
static auto __MakeFields() {
2024-04-19 22:02:27 +08:00
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},{}}),
2024-04-11 10:13:15 +08:00
};
2024-04-13 17:47:44 +08:00
};
2024-04-11 10:13:15 +08:00
};