Skip to content

Commit

Permalink
Reformat Code
Browse files Browse the repository at this point in the history
  • Loading branch information
crazytuzi committed Nov 25, 2024
1 parent 18ef14b commit a434c54
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 57 deletions.
16 changes: 8 additions & 8 deletions Source/ScriptCodeGenerator/Public/FGeneratorCore.inl
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ auto FGeneratorCore::GetFileName(const T* InField)
auto DirectoryName = FPaths::Combine(
FUnrealCSharpFunctionLibrary::GetGenerationPath(SignatureFunction), ModuleName);

auto ModuleRelativePath = FPaths::Combine(
FUnrealCSharpFunctionLibrary::GetModuleRelativePath(InField),
FUnrealCSharpFunctionLibrary::GetFullClass(InField));
auto ModuleRelativePath = FUnrealCSharpFunctionLibrary::GetModuleRelativePath(InField);

return FPaths::Combine(DirectoryName, ModuleRelativePath) + CSHARP_SUFFIX;
auto FileName = FUnrealCSharpFunctionLibrary::GetFullClass(InField) + CSHARP_SUFFIX;

return FPaths::Combine(DirectoryName, ModuleRelativePath, FileName);
}
else
{
Expand All @@ -34,10 +34,10 @@ auto FGeneratorCore::GetFileName(const T* InField)
auto DirectoryName = FPaths::Combine(
FUnrealCSharpFunctionLibrary::GetGenerationPath(InField), ModuleName);

auto ModuleRelativePath = FPaths::Combine(
FUnrealCSharpFunctionLibrary::GetModuleRelativePath(InField),
InField->GetName());
auto ModuleRelativePath = FUnrealCSharpFunctionLibrary::GetModuleRelativePath(InField);

auto FileName = InField->GetName() + CSHARP_SUFFIX;

return FPaths::Combine(DirectoryName, ModuleRelativePath) + CSHARP_SUFFIX;
return FPaths::Combine(DirectoryName, ModuleRelativePath, FileName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,12 @@ FString FUnrealCSharpFunctionLibrary::GetDotNet()
}
#endif

#if WITH_EDITOR
FString FUnrealCSharpFunctionLibrary::GetModuleName(const UField* InField)
{
if (InField == nullptr)
{
return FString();
}

return GetModuleName(InField->GetPackage());
return InField ? GetModuleName(InField->GetPackage()) : FString();
}

#if WITH_EDITOR
FString FUnrealCSharpFunctionLibrary::GetModuleRelativePath(const UField* InField)
{
if (InField == nullptr)
Expand All @@ -67,7 +62,7 @@ FString FUnrealCSharpFunctionLibrary::GetModuleRelativePath(const UField* InFiel

if (!InField->IsNative())
{
ModuleRelativePath = GetModuleRelativePath(ModuleRelativePath);
ProcessModuleRelativePath(ModuleRelativePath);
}

return ModuleRelativePath;
Expand All @@ -84,9 +79,11 @@ FString FUnrealCSharpFunctionLibrary::GetModuleRelativePathMetaData(const UField

ModuleRelativePathMetaData = FPaths::GetPath(InField->GetMetaData(TEXT("ModuleRelativePath")));

return GetModuleRelativePathMetaData(ModuleRelativePathMetaData);
return ProcessModuleRelativePathMetaData(ModuleRelativePathMetaData);
}
#endif

#if WITH_EDITOR
FString FUnrealCSharpFunctionLibrary::GetModuleName(
#if UE_F_DELEGATE_PROPERTY_SIGNATURE_FUNCTION_T_OBJECT_PTR
const TObjectPtr<UFunction>& InSignatureFunction)
Expand All @@ -96,7 +93,7 @@ FString FUnrealCSharpFunctionLibrary::GetModuleName(
{
FString ModuleName;

if (InSignatureFunction == nullptr)
if (InSignatureFunction == nullptr || InSignatureFunction->GetOuter() == nullptr)
{
return ModuleName;
}
Expand All @@ -112,6 +109,7 @@ FString FUnrealCSharpFunctionLibrary::GetModuleName(

return ModuleName;
}
#endif

FString FUnrealCSharpFunctionLibrary::GetModuleName(const UPackage* InPackage)
{
Expand Down Expand Up @@ -157,6 +155,7 @@ FString FUnrealCSharpFunctionLibrary::GetModuleName(const FString& InName)
return ModuleName;
}

#if WITH_EDITOR
FString FUnrealCSharpFunctionLibrary::GetModuleRelativePath(
const FDelegateProperty* InDelegateProperty)
{
Expand All @@ -177,7 +176,7 @@ FString FUnrealCSharpFunctionLibrary::GetModuleRelativePath(

if (!InDelegateProperty->IsNative())
{
ModuleRelativePath = GetModuleRelativePath(ModuleRelativePath);
ProcessModuleRelativePath(ModuleRelativePath);
}

return ModuleRelativePath;
Expand All @@ -195,7 +194,7 @@ FString FUnrealCSharpFunctionLibrary::GetModuleRelativePathMetaData(

ModuleRelativePathMetaData = FPaths::GetPath(InDelegateProperty->GetMetaData(TEXT("ModuleRelativePath")));

return GetModuleRelativePathMetaData(ModuleRelativePathMetaData);
return ProcessModuleRelativePathMetaData(ModuleRelativePathMetaData);
}

FString FUnrealCSharpFunctionLibrary::GetModuleRelativePath(
Expand All @@ -218,7 +217,7 @@ FString FUnrealCSharpFunctionLibrary::GetModuleRelativePath(

if (!InMulticastDelegateProperty->IsNative())
{
ModuleRelativePath = GetModuleRelativePath(ModuleRelativePath);
ProcessModuleRelativePath(ModuleRelativePath);
}

return ModuleRelativePath;
Expand All @@ -236,41 +235,32 @@ FString FUnrealCSharpFunctionLibrary::GetModuleRelativePathMetaData(

ModuleRelativePathMetaData = FPaths::GetPath(InMulticastDelegateProperty->GetMetaData(TEXT("ModuleRelativePath")));

return GetModuleRelativePathMetaData(ModuleRelativePathMetaData);
return ProcessModuleRelativePathMetaData(ModuleRelativePathMetaData);
}

FString FUnrealCSharpFunctionLibrary::GetModuleRelativePath(const FString& InRelativePath)
void FUnrealCSharpFunctionLibrary::ProcessModuleRelativePath(FString& OutModuleRelativePath)
{
auto ModuleRelativePath = InRelativePath;

if (ModuleRelativePath.IsEmpty())
if (!OutModuleRelativePath.IsEmpty())
{
return ModuleRelativePath;
}
OutModuleRelativePath.RemoveFromEnd(TEXT("/"));

ModuleRelativePath.RemoveFromEnd(TEXT("/"));

if (auto Index = 0; ModuleRelativePath.FindLastChar(TEXT('/'), Index))
{
ModuleRelativePath.LeftInline(Index);
if (auto Index = 0; OutModuleRelativePath.FindLastChar(TEXT('/'), Index))
{
OutModuleRelativePath.LeftInline(Index);
}
}

return ModuleRelativePath;
}
#endif

#if WITH_EDITOR
FString FUnrealCSharpFunctionLibrary::GetOuterRelativePath(
#if UE_F_DELEGATE_PROPERTY_SIGNATURE_FUNCTION_T_OBJECT_PTR
const TObjectPtr<UFunction>& InSignatureFunction)
#else
const UFunction* InSignatureFunction)
#endif
{
if (InSignatureFunction == nullptr)
{
return FString();
}

return GetOuterRelativePath(GetOuterName(InSignatureFunction));
return InSignatureFunction ? GetOuterRelativePath(GetOuterName(InSignatureFunction)) : FString();
}

FString FUnrealCSharpFunctionLibrary::GetOuterRelativePath(const FString& InRelativePath)
Expand Down Expand Up @@ -310,33 +300,28 @@ FString FUnrealCSharpFunctionLibrary::GetOuterName(
const UFunction* InSignatureFunction)
#endif
{
FString ModuleRelativePath;
FString OuterName;

if (InSignatureFunction == nullptr)
{
return ModuleRelativePath;
return OuterName;
}

if (const auto Class = Cast<UClass>(InSignatureFunction->GetOuter()))
{
ModuleRelativePath = GetOuterName(Class);
OuterName = GetOuterName(Class);
}
else if (const auto Package = Cast<UPackage>(InSignatureFunction->GetOuter()))
{
ModuleRelativePath = GetOuterName(Package);
OuterName = GetOuterName(Package);
}

return ModuleRelativePath;
return OuterName;
}

FString FUnrealCSharpFunctionLibrary::GetOuterName(const UPackage* InPackage)
{
if (InPackage == nullptr)
{
return FString();
}

return InPackage->GetName();
return InPackage ? InPackage->GetName() : FString();
}

FString FUnrealCSharpFunctionLibrary::GetOuterName(const UClass* InClass)
Expand Down Expand Up @@ -364,11 +349,11 @@ FString FUnrealCSharpFunctionLibrary::GetOuterName(const UClass* InClass)
return OuterName;
}

FString FUnrealCSharpFunctionLibrary::GetModuleRelativePathMetaData(const FString& InMetaData)
FString FUnrealCSharpFunctionLibrary::ProcessModuleRelativePathMetaData(const FString& InModuleRelativePathMetaData)
{
TArray<FString> OutArray;

InMetaData.ParseIntoArray(OutArray, TEXT("/"));
InModuleRelativePathMetaData.ParseIntoArray(OutArray, TEXT("/"));

OutArray.RemoveAll([](const FString& Element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@ class UNREALCSHARPCORE_API FUnrealCSharpFunctionLibrary
#endif

public:
#if WITH_EDITOR
static FString GetModuleName(const UField* InField);

#if WITH_EDITOR
static FString GetModuleRelativePath(const UField* InField);

static FString GetModuleRelativePathMetaData(const UField* InField);
#endif

#if WITH_EDITOR
#if UE_F_DELEGATE_PROPERTY_SIGNATURE_FUNCTION_T_OBJECT_PTR
static FString GetModuleName(const TObjectPtr<UFunction>& InSignatureFunction);
#else
static FString GetModuleName(const UFunction* InSignatureFunction);
#endif
#endif

static FString GetModuleName(const UPackage* InPackage);

static FString GetModuleName(const FString& InName);

#if WITH_EDITOR
static FString GetModuleRelativePath(const FDelegateProperty* InDelegateProperty);

static FString GetModuleRelativePathMetaData(const FDelegateProperty* InDelegateProperty);
Expand All @@ -36,8 +40,10 @@ class UNREALCSHARPCORE_API FUnrealCSharpFunctionLibrary

static FString GetModuleRelativePathMetaData(const FMulticastDelegateProperty* InMulticastDelegateProperty);

static FString GetModuleRelativePath(const FString& InRelativePath);
static void ProcessModuleRelativePath(FString& OutModuleRelativePath);
#endif

#if WITH_EDITOR
#if UE_F_DELEGATE_PROPERTY_SIGNATURE_FUNCTION_T_OBJECT_PTR
static FString GetOuterRelativePath(const TObjectPtr<UFunction>& InSignatureFunction);
#else
Expand All @@ -56,7 +62,7 @@ class UNREALCSHARPCORE_API FUnrealCSharpFunctionLibrary

static FString GetOuterName(const UClass* InClass);

static FString GetModuleRelativePathMetaData(const FString& InMetaData);
static FString ProcessModuleRelativePathMetaData(const FString& InModuleRelativePathMetaData);
#endif

static FString GetFullClass(const UStruct* InStruct);
Expand Down

0 comments on commit a434c54

Please sign in to comment.