// Copyright (c) 2024 Codemongous LLC. All Rights Reserved.

#include "SCW_UFunction.h"
#include "UObject/Class.h"
#include "SourcifyCoreUEWrapperModule.h"

using namespace Sourcify;

SCW_UFunction::SCW_UFunction(UFunction* InFunction) : SCW_UStruct(InFunction), Function(InFunction)
{

}

SCW_EFunctionFlags SCW_UFunction::GetFunctionFlags() const
{
	return static_cast<SCW_EFunctionFlags>(Function->FunctionFlags);
}

ISCW_UFunctionPtr SCW_UFunction::GetSuperFunction() const
{
	return Function->GetSuperFunction() ? FSourcifyCoreUEWrapper::Get().Wrap(*Function->GetSuperFunction()) : nullptr;
}

bool SCW_UFunction::HasAllFunctionFlags(SCW_EFunctionFlags FlagsToCheck) const
{
	return Function->HasAllFunctionFlags(static_cast<EFunctionFlags>(FlagsToCheck));
}

bool SCW_UFunction::HasAnyFunctionFlags(SCW_EFunctionFlags FlagsToCheck) const
{
	return Function->HasAnyFunctionFlags(static_cast<EFunctionFlags>(FlagsToCheck));
}

bool SCW_UFunction::IsSignatureCompatibleWith(ISCW_UFunctionConstPtr OtherFunction) const
{
	return Function->IsSignatureCompatibleWith(dynamic_cast<const SCW_UFunction*>(OtherFunction.get())->ToUFunction());
}

bool SCW_UFunction::IsSignatureCompatibleWith(ISCW_UFunctionConstPtr OtherFunction, uint64_t IgnoreFlags) const
{
	return Function->IsSignatureCompatibleWith(dynamic_cast<const SCW_UFunction*>(OtherFunction.get())->ToUFunction(), IgnoreFlags);
}

UFunction* SCW_UFunction::ToUFunction() const
{
	return Function;
}

ISCW_UFunctionPtr SCW_UFunction::ToUFunctionPtr()
{
	return GetSharedThisAs<SCW_UFunction>();
}

ISCW_UFunctionConstPtr SCW_UFunction::ToUFunctionPtr() const
{
	return GetSharedThisAs<SCW_UFunction>();
}