#include #include #include "refl/refl.h" #include "vertex.h" #include "tstring.h" #include using namespace std; using namespace refl; struct vec3_parent { virtual void norm(int x1, int& x2) { x2 = x1 * x2; cout << x2 << "vec3_parent::norm" << endl; } }; struct vec3 : public vec3_parent { float x = 1; float y = 2; float z = 3; string name{ "hellohellohellohellohellohello" }; void norm(int x1, int& x2)override { x2 = x1 * x2; cout << x2 << "vec3::norm" << endl; } virtual float norm1(int x1 = 10) { cout << x1 << "::norm1" << endl; return x * y *z * x1; } static void norm2(int x1 = 10) { cout << x1 << "::norm2" << endl; } static void norm3(int x1 = 10) { x1 = x1 * 10; cout << x1 << "::norm3" << endl; } using MyUClass = UClass_Custom; static MyUClass BuildClass() { MyUClass cls(type_name().View(), sizeof(vec3), &TypeInfo::StaticClass); auto& FList = cls.FList; FList.reserve(6); FList.push_back(cls.MakeMemberField("x", &TypeInfo::StaticClass)); FList.push_back(cls.MakeMemberField("y", &TypeInfo::StaticClass)); FList.push_back(cls.MakeMemberField("z", &TypeInfo::StaticClass)); cls.AttrNum = FList.size(); FList.push_back(cls.MakeMethodField(&vec3::norm, "norm")); FList.push_back(cls.MakeMethodField(&vec3::norm, "norm1")); cls.vtable.InitObject = &UClass::InitObject; cls.BuildClass(); return cls; } }; int main() { auto cls = &TypeInfo::StaticClass; int x = 100, y = 2; auto ov = cls->New(); ov.Invoke("norm", x, y); vec3* v = (vec3*)ov.ptr; delete v; cout << "hello world\n"; }