zengine-old/engine/3rdparty/zlib/include/refl/detail/view.h

54 lines
1.5 KiB
C
Raw Normal View History

2024-04-07 21:15:34 +08:00
#pragma once
2024-04-06 23:50:17 +08:00
#include <string>
2024-04-16 16:17:13 +08:00
#include "field.h"
2024-04-06 23:50:17 +08:00
namespace refl {
2024-04-09 16:31:09 +08:00
//存入的是真实的数据类型,type用于拷贝数据
2024-04-19 22:02:27 +08:00
struct AnyValue : public Any {
2024-04-09 16:31:09 +08:00
const UClass* type;
2024-04-19 22:02:27 +08:00
constexpr AnyValue() :Any(), type(nullptr) {}
2024-04-09 16:31:09 +08:00
template<typename T>
2024-04-19 22:02:27 +08:00
constexpr AnyValue(T&& t) : Any(t), type(&TypeInfo<args_type_t<T>>::StaticClass){}
};
struct MemberDataValue {
Offset offset{0};
AnyValue value;
AnyValue meta;
constexpr MemberDataValue() :value(), meta() {}
constexpr MemberDataValue(const AnyValue& value, const AnyValue& meta = {}) : value(value), meta(meta) {}
};
struct MethodDataValue {
Method fptr{nullptr};
sarray<AnyValue> value;
AnyValue meta;
constexpr MethodDataValue() :value(), meta() {}
constexpr MethodDataValue(const sarray<AnyValue>& value, const AnyValue& meta = {}) : value(value), meta(meta) {}
2024-04-09 16:31:09 +08:00
};
2024-04-19 22:02:27 +08:00
struct AnyValueList{
2024-04-14 22:45:08 +08:00
void* data;
2024-04-15 19:53:39 +08:00
int num;
2024-04-14 22:45:08 +08:00
bool isMemoryOwner{false};
2024-04-19 22:02:27 +08:00
AnyValueList(const sarray<AnyValue>& args,void* memory = nullptr);
~AnyValueList();
void ConvertArgs(sarray<const UClass*> params);
const sarray<Any> ToSArray();
constexpr static int GetArgsSize(const sarray<AnyValue>& args);
2024-04-09 16:31:09 +08:00
};
2024-04-19 22:02:27 +08:00
class AnyView : public Any{
2024-04-11 10:13:15 +08:00
public:
const FieldPtr* cache{ nullptr };
2024-04-19 22:02:27 +08:00
AnyView(const void* ptr, const UClass* cls) : Any(ptr,cls) {}
2024-04-11 10:13:15 +08:00
public:
template<typename T>
bool Get(const Name& name, T& t);
template<typename T>
bool Set(const Name& name, const T& t);
2024-04-19 22:02:27 +08:00
bool Invoke(const Name& name,const sarray<Any>& ArgsList);
2024-04-11 10:13:15 +08:00
2024-04-19 22:02:27 +08:00
bool Invoke(const Name& name,svector<Any>& ArgsList);
2024-04-11 10:13:15 +08:00
2024-04-19 22:02:27 +08:00
AnyView Parent();
2024-04-11 10:13:15 +08:00
};
2024-04-06 23:50:17 +08:00
}