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

#include "SCW_FArrayProperty.h"
#include "UObject/UnrealType.h"
#include "SourcifyCoreUEWrapperModule.h"

using namespace Sourcify;

SCW_FArrayProperty::SCW_FArrayProperty(FArrayProperty* InArrayProperty) : SCW_FProperty(InArrayProperty), ArrayProperty(InArrayProperty)
{

}

wstring SCW_FArrayProperty::GetCPPTypeCustom(wstring* ExtendedTypeText, SCW_EPropertyExportCPPFlags CPPExportFlags, const wstring& InnerTypeText, const wstring& InInnerExtendedTypeText) const
{
	if (ExtendedTypeText == nullptr)
	{
		return TCHAR_TO_WCHAR(*ArrayProperty->GetCPPTypeCustom(nullptr, static_cast<uint32>(CPPExportFlags), InnerTypeText.c_str(), InInnerExtendedTypeText.c_str()));
	}

	FString ExtendedTypeTextFString = ExtendedTypeText->c_str();
	FString CPPTypeCustomFString = ArrayProperty->GetCPPTypeCustom(&ExtendedTypeTextFString, static_cast<uint32>(CPPExportFlags), InnerTypeText.c_str(), InInnerExtendedTypeText.c_str());
	*ExtendedTypeText = TCHAR_TO_WCHAR(*ExtendedTypeTextFString);
	
	return TCHAR_TO_WCHAR(*CPPTypeCustomFString);
}

ISCW_FPropertyPtr SCW_FArrayProperty::GetInner() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(*ArrayProperty->Inner);
}

FArrayProperty* SCW_FArrayProperty::ToFArrayProperty() const
{
	return ArrayProperty;
}
