#pragma once
#include "UTemplate/Type.hpp"
#include <variant>
#include <functional>
using Ubpa::Name;
using Ubpa::type_name;
namespace refl {
	class UClass;
	class ArgsView;

	using Offset = uint32_t;
	using Method = void(*)(...);

	using DefaultMember = const ArgsView (*)();
	using DefaultMethod = std::pair<ArgsView*, int>(*)();

	enum FieldFlag:uint32_t {
		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
	};
	struct FieldPtr {
		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) {}
		};
		Name name;
		const UClass* type;
		Data data;
		Default value;
		uint32_t flag;
	};

}