refl inl函数定义需要加inline,避免重定义报错

This commit is contained in:
ouczbs 2024-04-26 16:57:48 +08:00
parent ba8692659f
commit faed6a2228
3 changed files with 10 additions and 10 deletions

View File

@ -2,7 +2,7 @@
#include <string>
#include "convert.h"
namespace refl {
bool Convert::ToString(Any& dst, const Any& src)
inline bool Convert::ToString(Any& dst, const Any& src)
{
if (src.Parent() == &TypeInfo<char>::StaticClass) {
std::construct_at(dst.CastTo<std::string*>(), src.CastTo<const char*>());
@ -23,7 +23,7 @@ namespace refl {
}
return it->second(dst, src);
}
ConvertMap Convert::BuildClassMap()
inline ConvertMap Convert::BuildClassMap()
{
ConvertMap classMap;
classMap.emplace(&TypeInfo<std::string*>::StaticClass, &ToString);

View File

@ -8,14 +8,14 @@ namespace refl {
MemberFunc fptr = (MemberFunc)data.method.fptr;
return fptr(std::forward<Args>(args)...);
}
bool FieldPtr::Invoke(const sarray<Any>& ArgsList)const{
inline bool FieldPtr::Invoke(const sarray<Any>& ArgsList)const{
auto Call = type->vtable.Call;
if (Call) {
Call(this, ArgsList);
}
return Call;
}
bool FieldPtr::Invoke(svector<Any>& ArgsList)const {
inline bool FieldPtr::Invoke(svector<Any>& ArgsList)const {
auto Call = type->vtable.Call;
if (Call) {
sarray<const UClass*> params = GetParams();
@ -45,7 +45,7 @@ namespace refl {
}
return Call;
}
sarray<const UClass*> FieldPtr::GetParams() const {
inline sarray<const UClass*> FieldPtr::GetParams() const {
auto GetParams = type->vtable.GetParams;
if (GetParams) {
return GetParams(type);

View File

@ -4,7 +4,7 @@
#include "convert.h"
namespace refl {
using enum ClassFlag;
bool Any::Check(const UClass* toClass) const{
inline bool Any::Check(const UClass* toClass) const{
if (cls == toClass) {
return true;
}
@ -28,7 +28,7 @@ namespace refl {
{
return cls->parent;
}
AnyArgs::AnyArgs(const sarray<Any>& args, const sarray<const UClass*>& params, void* memory)
inline AnyArgs::AnyArgs(const sarray<Any>& args, const sarray<const UClass*>& params, void* memory)
: data(memory), num(args.size()), size(GetArgsSize(args, params))
{
assert(size > 0);
@ -124,7 +124,7 @@ namespace refl {
}
return false;
}
bool AnyView::Invoke(const Name& name,const sarray<Any>& ArgsList)
inline bool AnyView::Invoke(const Name& name,const sarray<Any>& ArgsList)
{
auto field = cls->GetField(name, 0);
if (!field) {
@ -135,7 +135,7 @@ namespace refl {
}
return field->Invoke(ArgsList);
}
bool AnyView::Invoke(const Name& name, svector<Any>& ArgsList)
inline bool AnyView::Invoke(const Name& name, svector<Any>& ArgsList)
{
auto field = cls->GetField(name, 0);
if (!field) {
@ -146,7 +146,7 @@ namespace refl {
}
return field->Invoke(ArgsList);
}
AnyView AnyView::Parent() {
inline AnyView AnyView::Parent() {
return { ptr, cls ? cls->parent : nullptr };
}
}