refl bugfix

This commit is contained in:
ouczbs 2024-04-26 15:26:38 +08:00
parent 0828271799
commit ba8692659f
5 changed files with 11 additions and 7 deletions

View File

@ -13,8 +13,8 @@ namespace refl {
inline bool Convert::Construct(Any& dst, const Any& src) inline bool Convert::Construct(Any& dst, const Any& src)
{ {
if (dst.Check(src.cls)) { if (dst.Check(src.cls)) {
dst.cls->InitObject((void*)dst.ptr); dst.cls->parent->InitObject((void*)dst.ptr);
dst.cls->CopyObject((void*)dst.ptr, src.ptr); dst.cls->parent->CopyObject((void*)dst.ptr, src.ptr);
return true; return true;
} }
auto it = ClassMap.find(dst.cls); auto it = ClassMap.find(dst.cls);

View File

@ -1,3 +1,4 @@
#pragma once
#include "uclass.h" #include "uclass.h"
namespace refl { namespace refl {
template<typename Func, typename... Args> template<typename Func, typename... Args>

View File

@ -18,6 +18,9 @@ namespace refl {
for (auto& field : fields) { for (auto& field : fields) {
size += field.data.member.offset; size += field.data.member.offset;
} }
if (size == 0) {
size = 1;
}
return size; return size;
} }
enum MetaFlag :uint32_t { enum MetaFlag :uint32_t {

View File

@ -1,3 +1,4 @@
#pragma once
#if !defined(__cppast) #if !defined(__cppast)
#define __cppast(...) #define __cppast(...)
#endif #endif

View File

@ -12,14 +12,14 @@ struct vec3_parent {
struct vec4 { struct vec4 {
string name{ "hello" }; string name{ "hello" };
}; };
struct vec3_Meta; class vec3_Meta;
struct vec3 : public vec3_parent { struct vec3 : public vec3_parent {
using MyMeta = vec3_Meta; using MyMeta = vec3_Meta;
__cppast(Meta = { 0.f}) __cppast(Meta = { 1.f})
float x = 1; float x = 1;
__cppast(Meta = { 0.f}) __cppast(Meta = { 2.f})
float y = 2; float y = 2;
__cppast(Meta = { 0.f}) __cppast(Meta = { 5.f})
float z = 3; float z = 3;
__cppast(Meta = { "hello meta"}) __cppast(Meta = { "hello meta"})
string name = "???"; string name = "???";
@ -50,5 +50,4 @@ struct vec3 : public vec3_parent {
cout << x1 << "::norm3" << endl; cout << x1 << "::norm3" << endl;
} }
}; };
#include "meta_vertex_gen.inl" #include "meta_vertex_gen.inl"