#pragma once
#include "detail/uclass.inl"
#include "detail/container.inl"
#include "detail/view.inl"
#include "detail/field.inl"
#include "detail/convert.inl"
#include "detail/meta.inl"
#include "macro.h"
namespace refl {
	template<typename T, typename... Args>
	consteval FieldPtr StaticCtorField(T(*ptr)(Args...), const MethodData& data = {}) {
		uint32_t flag = FIELD_CTOR_FLAG;
		Offset offset = AnyArgs::GetArgsSize<void,void*, Args...>(data.value);
		if (data.meta) {
			offset += data.meta.Size();
		}
		FieldPtr::Data method(offset);
		return {FName("Ctor"), nullptr, method, flag};
	}
	template<typename T, typename Obj>
	consteval FieldPtr StaticMemberField(T Obj::* ptr, const Name& name, const MemberData& data = {}) {
		Offset offset = data.value ? sizeof(T) : 0;
		if (data.meta) {
			offset += data.meta.Size();
		}
		FieldPtr::Data member(offset);
		uint32_t flag = FIELD_MEMBER_FLAG | FIELD_ATTRIBUTE_FLAG;
		return { name, nullptr , member , flag};
	}
	template<typename R, typename ...Args>
	consteval FieldPtr StaticMethodField(R(*ptr)(Args...), const Name& name, const MethodData& data = {}) {
		uint32_t flag = FIELD_METHOD_FLAG;
		Offset offset = AnyArgs::GetArgsSize<R, Args...>(data.value);
		if (data.meta) {
			offset += data.meta.Size();
		}
		FieldPtr::Data method(offset);
		return { name,nullptr,method, flag };
	}
	template<typename T, typename R, typename ...Args>
	consteval FieldPtr StaticMethodField(R(T::* ptr)(Args...), const Name& name, const MethodData& data = {}) {
		uint32_t flag = FIELD_MEMBER_FLAG | FIELD_METHOD_FLAG;
		Offset offset = AnyArgs::GetArgsSize<R,void*, Args...>(data.value);
		if (data.meta) {
			offset += data.meta.Size();
		}
		FieldPtr::Data method(offset);
		return { name, nullptr,method,flag };
	}
	template<typename T, typename R, typename ...Args>
	consteval FieldPtr StaticMethodField(R(T::* ptr)(Args...)const, const Name& name, const MethodData& data = {}) {
		uint32_t flag = FIELD_MEMBER_FLAG | FIELD_METHOD_FLAG;
		Offset offset = AnyArgs::GetArgsSize<R, void*, Args...>(data.value);
		if (data.meta) {
			offset += data.meta.Size();
		}
		FieldPtr::Data method(offset);
		return { name, nullptr, method,flag };
	}
}