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

47 lines
1.0 KiB
C
Raw Normal View History

2024-04-03 17:58:02 +08:00
#pragma once
#include "UTemplate/Type.hpp"
#include <variant>
#include <functional>
using Ubpa::Name;
using Ubpa::type_name;
namespace refl {
class UClass;
2024-04-09 16:31:09 +08:00
class ArgsView;
2024-04-06 23:50:17 +08:00
using Offset = uint32_t;
2024-04-07 21:15:34 +08:00
using Method = void(*)(...);
2024-04-09 16:31:09 +08:00
using DefaultMember = const ArgsView (*)();
using DefaultMethod = std::pair<ArgsView*, int>(*)();
2024-04-05 16:03:58 +08:00
enum FieldFlag:uint32_t {
2024-04-09 16:31:09 +08:00
FIELD_NONE_FLAG = 0,
FIELD_MEMBER_FLAG = 1 << 0,
FIELD_ATTRIBUTE_FLAG = 1 << 1,
FIELD_METHOD_FLAG = 1 << 2,
FIELD_METHOD_VALUE_FLAG = 1 << 3
2024-04-05 16:03:58 +08:00
};
2024-04-03 17:58:02 +08:00
struct FieldPtr {
2024-04-09 16:31:09 +08:00
union Data
{
Offset offset;
Method method;
Data() : method(nullptr) {}
Data(Offset& offset) : offset(offset) {}
Data(Method& method) : method(method) {}
};
union Default {
DefaultMember member;
DefaultMethod method;
Default(): method(nullptr) {}
Default(DefaultMember& member) : member(member) {}
Default(DefaultMethod& method) : method(method) {}
};
2024-04-03 17:58:02 +08:00
Name name;
const UClass* type;
Data data;
2024-04-09 16:31:09 +08:00
Default value;
2024-04-05 16:03:58 +08:00
uint32_t flag;
2024-04-03 17:58:02 +08:00
};
2024-04-09 16:31:09 +08:00
2024-04-03 17:58:02 +08:00
}