Lua向C#逻辑迁移 一期 #13

将整个插件代码上传
This commit is contained in:
2025-10-26 21:48:39 +08:00
parent 56994b3927
commit 648386cd73
785 changed files with 53683 additions and 2 deletions

View File

@ -0,0 +1,23 @@
#include "AsyncExporter.h"
#include "CSManagedDelegate.h"
void UAsyncExporter::RunOnThread(TWeakObjectPtr<UObject> WorldContextObject, ENamedThreads::Type Thread, FGCHandleIntPtr DelegateHandle)
{
AsyncTask(Thread, [WorldContextObject, DelegateHandle]()
{
FCSManagedDelegate ManagedDelegate = FGCHandle(DelegateHandle, GCHandleType::StrongHandle);
if (!WorldContextObject.IsValid())
{
ManagedDelegate.Dispose();
return;
}
ManagedDelegate.Invoke(WorldContextObject.Get());
});
}
int UAsyncExporter::GetCurrentNamedThread()
{
return FTaskGraphInterface::Get().GetCurrentThreadIfKnown();
}

View File

@ -0,0 +1,22 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "Async/Async.h"
#include "CSManagedGCHandle.h"
#include "AsyncExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UAsyncExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void RunOnThread(TWeakObjectPtr<UObject> WorldContextObject, ENamedThreads::Type Thread, FGCHandleIntPtr DelegateHandle);
UNREALSHARP_FUNCTION()
static int GetCurrentNamedThread();
};

View File

@ -0,0 +1,11 @@
#include "CSTimerExtensions.h"
void UCSTimerExtensions::SetTimerForNextTick(FNextTickEvent NextTickEvent)
{
#if WITH_EDITOR
FFunctionGraphTask::CreateAndDispatchWhenReady([NextTickEvent]
{
GEditor->GetTimerManager()->SetTimerForNextTick(FTimerDelegate::CreateLambda(NextTickEvent));
}, TStatId(), nullptr, ENamedThreads::GameThread);
#endif
}

View File

@ -0,0 +1,18 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "CSTimerExtensions.generated.h"
using FNextTickEvent = void(*)();
UCLASS()
class UNREALSHARPCORE_API UCSTimerExtensions : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void SetTimerForNextTick(FNextTickEvent NextTickEvent);
};

View File

@ -0,0 +1,43 @@
#include "FArrayPropertyExporter.h"
void UFArrayPropertyExporter::InitializeArray(FArrayProperty* ArrayProperty, const void* ScriptArray, int Length)
{
FScriptArrayHelper Helper(ArrayProperty, ScriptArray);
Helper.EmptyAndAddValues(Length);
}
void UFArrayPropertyExporter::EmptyArray(FArrayProperty* ArrayProperty, const void* ScriptArray)
{
FScriptArrayHelper Helper(ArrayProperty, ScriptArray);
Helper.EmptyValues();
}
void UFArrayPropertyExporter::AddToArray(FArrayProperty* ArrayProperty, const void* ScriptArray)
{
FScriptArrayHelper Helper(ArrayProperty, ScriptArray);
Helper.AddValue();
}
void UFArrayPropertyExporter::InsertInArray(FArrayProperty* ArrayProperty, const void* ScriptArray, int index)
{
FScriptArrayHelper Helper(ArrayProperty, ScriptArray);
Helper.InsertValues(index);
}
void UFArrayPropertyExporter::RemoveFromArray(FArrayProperty* ArrayProperty, const void* ScriptArray, int index)
{
FScriptArrayHelper Helper(ArrayProperty, ScriptArray);
Helper.RemoveValues(index);
}
void UFArrayPropertyExporter::ResizeArray(FArrayProperty* ArrayProperty, const void* ScriptArray, int Length)
{
FScriptArrayHelper Helper(ArrayProperty, ScriptArray);
Helper.Resize(Length);
}
void UFArrayPropertyExporter::SwapValues(FArrayProperty* ArrayProperty, const void* ScriptArray, int indexA, int indexB)
{
FScriptArrayHelper Helper(ArrayProperty, ScriptArray);
Helper.SwapValues(indexA, indexB);
}

View File

@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FArrayPropertyExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFArrayPropertyExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void InitializeArray(FArrayProperty* ArrayProperty, const void* ScriptArray, int Length);
UNREALSHARP_FUNCTION()
static void EmptyArray(FArrayProperty* ArrayProperty, const void* ScriptArray);
UNREALSHARP_FUNCTION()
static void AddToArray(FArrayProperty* ArrayProperty, const void* ScriptArray);
UNREALSHARP_FUNCTION()
static void InsertInArray(FArrayProperty* ArrayProperty, const void* ScriptArray, int index);
UNREALSHARP_FUNCTION()
static void RemoveFromArray(FArrayProperty* ArrayProperty, const void* ScriptArray, int index);
UNREALSHARP_FUNCTION()
static void ResizeArray(FArrayProperty* ArrayProperty, const void* ScriptArray, int Length);
UNREALSHARP_FUNCTION()
static void SwapValues(FArrayProperty* ArrayProperty, const void* ScriptArray, int indexA, int indexB);
};

View File

@ -0,0 +1,21 @@
#include "FBoolPropertyExporter.h"
bool UFBoolPropertyExporter::GetBitfieldValueFromProperty(uint8* NativeBuffer, FProperty* Property, int32 Offset)
{
// NativeBuffer won't necessarily correspond to a UObject. It might be the beginning of a native struct, for example.
check(NativeBuffer);
uint8* OffsetPointer = NativeBuffer + Offset;
check(OffsetPointer == Property->ContainerPtrToValuePtr<uint8>(NativeBuffer));
FBoolProperty* BoolProperty = CastFieldChecked<FBoolProperty>(Property);
return BoolProperty->GetPropertyValue(OffsetPointer);
}
void UFBoolPropertyExporter::SetBitfieldValueForProperty(uint8* NativeObject, FProperty* Property, int32 Offset, bool Value)
{
// NativeBuffer won't necessarily correspond to a UObject. It might be the beginning of a native struct, for example.
check(NativeObject);
uint8* OffsetPointer = NativeObject + Offset;
check(OffsetPointer == Property->ContainerPtrToValuePtr<uint8>(NativeObject));
const FBoolProperty* BoolProperty = CastFieldChecked<FBoolProperty>(Property);
BoolProperty->SetPropertyValue(OffsetPointer, Value);
}

View File

@ -0,0 +1,21 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FBoolPropertyExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFBoolPropertyExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static bool GetBitfieldValueFromProperty(uint8* NativeBuffer, FProperty* Property, int32 Offset);
UNREALSHARP_FUNCTION()
static void SetBitfieldValueForProperty(uint8* NativeObject, FProperty* Property, int32 Offset, bool Value);
};

View File

@ -0,0 +1,7 @@
#include "FCSManagedCallbacksExporter.h"
#include "CSManagedCallbacksCache.h"
FCSManagedCallbacks::FManagedCallbacks* UFCSManagedCallbacksExporter::GetManagedCallbacks()
{
return &FCSManagedCallbacks::ManagedCallbacks;
}

View File

@ -0,0 +1,18 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "CSManagedCallbacksCache.h"
#include "UObject/Object.h"
#include "FCSManagedCallbacksExporter.generated.h"
class FCSManagedCallbacks;
UCLASS()
class UNREALSHARPCORE_API UFCSManagedCallbacksExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static FCSManagedCallbacks::FManagedCallbacks* GetManagedCallbacks();
};

View File

@ -0,0 +1,23 @@
#include "FCSManagerExporter.h"
#include "UnrealSharpCore/CSManager.h"
void* UFCSManagerExporter::FindManagedObject(UObject* Object)
{
return UCSManager::Get().FindManagedObject(Object);
}
void* UFCSManagerExporter::FindOrCreateManagedInterfaceWrapper(UObject* Object, UClass* NativeClass)
{
return UCSManager::Get().FindOrCreateManagedInterfaceWrapper(Object, NativeClass);
}
void* UFCSManagerExporter::GetCurrentWorldContext()
{
return UCSManager::Get().GetCurrentWorldContext();
}
void* UFCSManagerExporter::GetCurrentWorldPtr()
{
UObject* WorldContext = UCSManager::Get().GetCurrentWorldContext();
return GEngine->GetWorldFromContextObject(WorldContext, EGetWorldErrorMode::ReturnNull);
}

View File

@ -0,0 +1,28 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FCSManagerExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFCSManagerExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* FindManagedObject(UObject* Object);
UNREALSHARP_FUNCTION()
static void* FindOrCreateManagedInterfaceWrapper(UObject* Object, UClass* NativeClass);
UNREALSHARP_FUNCTION()
static void* GetCurrentWorldContext();
UNREALSHARP_FUNCTION()
static void* GetCurrentWorldPtr();
};

View File

@ -0,0 +1,6 @@
#include "FCSTypeRegistryExporter.h"
void UFCSTypeRegistryExporter::RegisterClassToFilePath(const UTF16CHAR* ClassName, const UTF16CHAR* FilePath)
{
//FCSTypeRegistry::Get().RegisterClassToFilePath(ClassName, FilePath);
}

View File

@ -0,0 +1,19 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FCSTypeRegistryExporter.generated.h"
UCLASS()
class UFCSTypeRegistryExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void RegisterClassToFilePath(const UTF16CHAR* ClassName, const UTF16CHAR* FilePath);
};

View File

@ -0,0 +1,30 @@
#include "FEditorDelegatesExporter.h"
void UFEditorDelegatesExporter::BindEndPIE(FPIEEvent Delegate, FDelegateHandle* DelegateHandle)
{
#if WITH_EDITOR
*DelegateHandle = FEditorDelegates::EndPIE.AddLambda(Delegate);
#endif
}
void UFEditorDelegatesExporter::BindStartPIE(FPIEEvent Delegate, FDelegateHandle* DelegateHandle)
{
#if WITH_EDITOR
*DelegateHandle = FEditorDelegates::BeginPIE.AddLambda(Delegate);
#endif
}
void UFEditorDelegatesExporter::UnbindStartPIE(FDelegateHandle DelegateHandle)
{
#if WITH_EDITOR
FEditorDelegates::BeginPIE.Remove(DelegateHandle);
#endif
}
void UFEditorDelegatesExporter::UnbindEndPIE(FDelegateHandle DelegateHandle)
{
#if WITH_EDITOR
FEditorDelegates::EndPIE.Remove(DelegateHandle);
#endif
}

View File

@ -0,0 +1,27 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FEditorDelegatesExporter.generated.h"
using FPIEEvent = void(*)(bool);
UCLASS()
class UNREALSHARPCORE_API UFEditorDelegatesExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void BindEndPIE(FPIEEvent Delegate, FDelegateHandle* DelegateHandle);
UNREALSHARP_FUNCTION()
static void BindStartPIE(FPIEEvent Delegate, FDelegateHandle* DelegateHandle);
UNREALSHARP_FUNCTION()
static void UnbindEndPIE(FDelegateHandle DelegateHandle);
UNREALSHARP_FUNCTION()
static void UnbindStartPIE(FDelegateHandle DelegateHandle);
};

View File

@ -0,0 +1,31 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "FFieldPathExporter.h"
bool UFFieldPathExporter::IsValid(const TFieldPath<FField>& FieldPath)
{
return FieldPath != nullptr;
}
bool UFFieldPathExporter::IsStale(const FFieldPath& FieldPath)
{
return FieldPath.IsStale();
}
void UFFieldPathExporter::FieldPathToString(const FFieldPath& FieldPath, FString* OutString)
{
*OutString = FieldPath.ToString();
}
bool UFFieldPathExporter::FieldPathsEqual(const FFieldPath& A, const FFieldPath& B)
{
return A == B;
}
int32 UFFieldPathExporter::GetFieldPathHashCode(const FFieldPath& FieldPath)
{
// GetHashCode returns a signed integer in C#, but GetTypeHash returns an unsigned integer, thus
// the cast is necessary
return static_cast<int32>(GetTypeHash(FieldPath));
}

View File

@ -0,0 +1,30 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UObject/Object.h"
#include "FFieldPathExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFFieldPathExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static bool IsValid(const TFieldPath<FField>& FieldPath);
UNREALSHARP_FUNCTION()
static bool IsStale(const FFieldPath& FieldPath);
UNREALSHARP_FUNCTION()
static void FieldPathToString(const FFieldPath& FieldPath, FString* OutString);
UNREALSHARP_FUNCTION()
static bool FieldPathsEqual(const FFieldPath& A, const FFieldPath& B);
UNREALSHARP_FUNCTION()
static int32 GetFieldPathHashCode(const FFieldPath& FieldPath);
};

View File

@ -0,0 +1,38 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "FInstancedStructExporter.h"
#include "StructUtils/InstancedStruct.h"
const UScriptStruct* UFInstancedStructExporter::GetNativeStruct(const FInstancedStruct& Struct)
{
check(&Struct != nullptr);
return Struct.GetScriptStruct();
}
void UFInstancedStructExporter::NativeInit(FInstancedStruct& Struct)
{
std::construct_at(&Struct);
}
void UFInstancedStructExporter::NativeCopy(FInstancedStruct& Dest, const FInstancedStruct& Src)
{
std::construct_at(&Dest, Src);
}
void UFInstancedStructExporter::NativeDestroy(FInstancedStruct& Struct)
{
std::destroy_at(&Struct);
}
void UFInstancedStructExporter::InitializeAs(FInstancedStruct& Struct, const UScriptStruct* ScriptStruct, const uint8* StructData)
{
check(ScriptStruct != nullptr);
Struct.InitializeAs(ScriptStruct, StructData);
}
const uint8* UFInstancedStructExporter::GetMemory(const FInstancedStruct& Struct)
{
return Struct.GetMemory();
}

View File

@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UObject/Object.h"
#include "FInstancedStructExporter.generated.h"
struct FInstancedStruct;
/**
*
*/
UCLASS()
class UNREALSHARPCORE_API UFInstancedStructExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static const UScriptStruct* GetNativeStruct(const FInstancedStruct& Struct);
UNREALSHARP_FUNCTION()
static void NativeInit(FInstancedStruct& Struct);
UNREALSHARP_FUNCTION()
static void NativeCopy(FInstancedStruct& Dest, const FInstancedStruct& Src);
UNREALSHARP_FUNCTION()
static void NativeDestroy(FInstancedStruct& Struct);
UNREALSHARP_FUNCTION()
static void InitializeAs(FInstancedStruct& Struct, const UScriptStruct* ScriptStruct, const uint8* StructData);
UNREALSHARP_FUNCTION()
static const uint8* GetMemory(const FInstancedStruct& Struct);
};

View File

@ -0,0 +1,11 @@
#include "FMapPropertyExporter.h"
void* UFMapPropertyExporter::GetKey(FMapProperty* MapProperty)
{
return MapProperty->KeyProp;
}
void* UFMapPropertyExporter::GetValue(FMapProperty* MapProperty)
{
return MapProperty->ValueProp;
}

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UObject/Object.h"
#include "FMapPropertyExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFMapPropertyExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* GetKey(FMapProperty* MapProperty);
UNREALSHARP_FUNCTION()
static void* GetValue(FMapProperty* MapProperty);
};

View File

@ -0,0 +1,6 @@
#include "FMatrixExporter.h"
void UFMatrixExporter::FromRotator(FMatrix* Matrix, const FRotator Rotator)
{
*Matrix = Rotator.Quaternion().ToMatrix();
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FMatrixExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFMatrixExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void FromRotator(FMatrix* Matrix, const FRotator Rotator);
};

View File

@ -0,0 +1,9 @@
#include "FMsgExporter.h"
void UFMsgExporter::Log(const UTF16CHAR* ManagedCategoryName, ELogVerbosity::Type Verbosity, const UTF16CHAR* ManagedMessage)
{
FString Message = FString(ManagedMessage);
FName CategoryName = FName(ManagedCategoryName);
FMsg::Logf(nullptr, 0, CategoryName, Verbosity, TEXT("%s"), *Message);
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FMsgExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFMsgExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void Log(const UTF16CHAR* ManagedCategoryName, ELogVerbosity::Type Verbosity, const UTF16CHAR* ManagedMessage);
};

View File

@ -0,0 +1,64 @@
#include "FMulticastDelegatePropertyExporter.h"
void UFMulticastDelegatePropertyExporter::AddDelegate(FMulticastDelegateProperty* DelegateProperty, FMulticastScriptDelegate* Delegate, UObject* Target, const char* FunctionName)
{
FScriptDelegate NewScriptDelegate = MakeScriptDelegate(Target, FunctionName);
DelegateProperty->AddDelegate(NewScriptDelegate, nullptr, Delegate);
}
bool UFMulticastDelegatePropertyExporter::IsBound(FMulticastScriptDelegate* Delegate)
{
return Delegate->IsBound();
}
void UFMulticastDelegatePropertyExporter::ToString(FMulticastScriptDelegate* Delegate, FString* OutString)
{
*OutString = Delegate->ToString<UObject>();
}
void UFMulticastDelegatePropertyExporter::RemoveDelegate(FMulticastDelegateProperty* DelegateProperty, FMulticastScriptDelegate* Delegate, UObject* Target, const char* FunctionName)
{
FScriptDelegate NewScriptDelegate = MakeScriptDelegate(Target, FunctionName);
DelegateProperty->RemoveDelegate(NewScriptDelegate, nullptr, Delegate);
}
void UFMulticastDelegatePropertyExporter::ClearDelegate(FMulticastDelegateProperty* DelegateProperty, FMulticastScriptDelegate* Delegate)
{
DelegateProperty->ClearDelegate(nullptr, Delegate);
}
void UFMulticastDelegatePropertyExporter::BroadcastDelegate(FMulticastDelegateProperty* DelegateProperty, const FMulticastScriptDelegate* Delegate, void* Parameters)
{
Delegate = TryGetSparseMulticastDelegate(DelegateProperty, Delegate);
Delegate->ProcessMulticastDelegate<UObject>(Parameters);
}
bool UFMulticastDelegatePropertyExporter::ContainsDelegate(FMulticastDelegateProperty* DelegateProperty, const FMulticastScriptDelegate* Delegate, UObject* Target, const char* FunctionName)
{
FScriptDelegate NewScriptDelegate = MakeScriptDelegate(Target, FunctionName);
Delegate = TryGetSparseMulticastDelegate(DelegateProperty, Delegate);
return Delegate->Contains(NewScriptDelegate);
}
void* UFMulticastDelegatePropertyExporter::GetSignatureFunction(FMulticastDelegateProperty* DelegateProperty)
{
return DelegateProperty->SignatureFunction;
}
FScriptDelegate UFMulticastDelegatePropertyExporter::MakeScriptDelegate(UObject* Target, const char* FunctionName)
{
FScriptDelegate NewDelegate;
NewDelegate.BindUFunction(Target, FunctionName);
return NewDelegate;
}
const FMulticastScriptDelegate* UFMulticastDelegatePropertyExporter::TryGetSparseMulticastDelegate(FMulticastDelegateProperty* DelegateProperty, const FMulticastScriptDelegate* Delegate)
{
// If the delegate is a sparse delegate, we need to get the multicast delegate from FSparseDelegate wrapper.
if (DelegateProperty->IsA<FMulticastSparseDelegateProperty>())
{
Delegate = DelegateProperty->GetMulticastDelegate(Delegate);
}
return Delegate;
}

View File

@ -0,0 +1,58 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FMulticastDelegatePropertyExporter.generated.h"
struct Interop_FScriptDelegate
{
UObject* Object;
FName Name;
FScriptDelegate ToFScriptDelegate() const
{
FScriptDelegate NewScriptDelegate;
NewScriptDelegate.BindUFunction(Object, Name);
return NewScriptDelegate;
}
};
UCLASS()
class UNREALSHARPCORE_API UFMulticastDelegatePropertyExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void AddDelegate(FMulticastDelegateProperty* DelegateProperty, FMulticastScriptDelegate* Delegate, UObject* Target, const char* FunctionName);
UNREALSHARP_FUNCTION()
static bool IsBound(FMulticastScriptDelegate* Delegate);
UNREALSHARP_FUNCTION()
static void ToString(FMulticastScriptDelegate* Delegate, FString* OutString);
UNREALSHARP_FUNCTION()
static void RemoveDelegate(FMulticastDelegateProperty* DelegateProperty, FMulticastScriptDelegate* Delegate, UObject* Target, const char* FunctionName);
UNREALSHARP_FUNCTION()
static void ClearDelegate(FMulticastDelegateProperty* DelegateProperty, FMulticastScriptDelegate* Delegate);
UNREALSHARP_FUNCTION()
static void BroadcastDelegate(FMulticastDelegateProperty* DelegateProperty, const FMulticastScriptDelegate* Delegate, void* Parameters);
UNREALSHARP_FUNCTION()
static bool ContainsDelegate(FMulticastDelegateProperty* DelegateProperty, const FMulticastScriptDelegate* Delegate, UObject* Target, const char* FunctionName);
UNREALSHARP_FUNCTION()
static void* GetSignatureFunction(FMulticastDelegateProperty* DelegateProperty);
UNREALSHARP_FUNCTION()
static FScriptDelegate MakeScriptDelegate(UObject* Target, const char* FunctionName);
UNREALSHARP_FUNCTION()
static const FMulticastScriptDelegate* TryGetSparseMulticastDelegate(FMulticastDelegateProperty* DelegateProperty, const FMulticastScriptDelegate* Delegate);
};

View File

@ -0,0 +1,17 @@
#include "FNameExporter.h"
void UFNameExporter::NameToString(FName Name, FString* OutString)
{
Name.ToString(*OutString);
}
void UFNameExporter::StringToName(FName* Name, const UTF16CHAR* String, int32 Length)
{
*Name = FName(TStringView(String, Length));
}
bool UFNameExporter::IsValid(FName Name)
{
bool bIsValid = Name.IsValid();
return bIsValid;
}

View File

@ -0,0 +1,23 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FNameExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFNameExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void NameToString(FName Name, FString* OutString);
UNREALSHARP_FUNCTION()
static void StringToName(FName* Name, const UTF16CHAR* String, int32 Length);
UNREALSHARP_FUNCTION()
static bool IsValid(FName Name);
};

View File

@ -0,0 +1,62 @@
#include "FOptionalPropertyExporter.h"
#include "UObject/PropertyOptional.h"
bool UFOptionalPropertyExporter::IsSet(const FOptionalProperty* OptionalProperty, const void* ScriptValue)
{
return OptionalProperty->IsSet(ScriptValue);
}
void* UFOptionalPropertyExporter::MarkSetAndGetInitializedValuePointerToReplace(const FOptionalProperty* OptionalProperty, void* Data)
{
return OptionalProperty->MarkSetAndGetInitializedValuePointerToReplace(Data);
}
void UFOptionalPropertyExporter::MarkUnset(const FOptionalProperty* OptionalProperty, void* Data)
{
return OptionalProperty->MarkUnset(Data);
}
const void* UFOptionalPropertyExporter::GetValuePointerForRead(const FOptionalProperty* OptionalProperty, const void* Data)
{
return OptionalProperty->GetValuePointerForRead(Data);
}
void* UFOptionalPropertyExporter::GetValuePointerForReplace(const FOptionalProperty* OptionalProperty, void* Data)
{
return OptionalProperty->GetValuePointerForReplace(Data);
}
const void* UFOptionalPropertyExporter::GetValuePointerForReadIfSet(const FOptionalProperty* OptionalProperty, const void* Data)
{
return OptionalProperty->GetValuePointerForReadIfSet(Data);
}
void* UFOptionalPropertyExporter::GetValuePointerForReplaceIfSet(const FOptionalProperty* OptionalProperty, void* Data)
{
return OptionalProperty->GetValuePointerForReplaceIfSet(Data);
}
void* UFOptionalPropertyExporter::GetValuePointerForReadOrReplace(const FOptionalProperty* OptionalProperty, void* Data)
{
return OptionalProperty->GetValuePointerForReadOrReplace(Data);
}
void* UFOptionalPropertyExporter::GetValuePointerForReadOrReplaceIfSet(const FOptionalProperty* OptionalProperty, void* Data)
{
return OptionalProperty->GetValuePointerForReadOrReplaceIfSet(Data);
}
int32 UFOptionalPropertyExporter::CalcSize(const FOptionalProperty* OptionalProperty)
{
#if ENGINE_MINOR_VERSION >= 5
// Do we really need this? StaticLink should do this.
return OptionalProperty->CalcSize();
#else
return OptionalProperty->GetSize();
#endif
}
void UFOptionalPropertyExporter::DestructInstance(const FOptionalProperty* OptionalProperty, void* Data)
{
OptionalProperty->DestroyValueInternal(Data);
}

View File

@ -0,0 +1,47 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UObject/Object.h"
#include "FOptionalPropertyExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFOptionalPropertyExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static bool IsSet(const FOptionalProperty* OptionalProperty, const void* ScriptValue);
UNREALSHARP_FUNCTION()
static void* MarkSetAndGetInitializedValuePointerToReplace(const FOptionalProperty* OptionalProperty, void* Data);
UNREALSHARP_FUNCTION()
static void MarkUnset(const FOptionalProperty* OptionalProperty, void* Data);
UNREALSHARP_FUNCTION()
static const void* GetValuePointerForRead(const FOptionalProperty* OptionalProperty, const void* Data);
UNREALSHARP_FUNCTION()
static void* GetValuePointerForReplace(const FOptionalProperty* OptionalProperty, void* Data);
UNREALSHARP_FUNCTION()
static const void* GetValuePointerForReadIfSet(const FOptionalProperty* OptionalProperty, const void* Data);
UNREALSHARP_FUNCTION()
static void* GetValuePointerForReplaceIfSet(const FOptionalProperty* OptionalProperty, void* Data);
UNREALSHARP_FUNCTION()
static void* GetValuePointerForReadOrReplace(const FOptionalProperty* OptionalProperty, void* Data);
UNREALSHARP_FUNCTION()
static void* GetValuePointerForReadOrReplaceIfSet(const FOptionalProperty* OptionalProperty, void* Data);
UNREALSHARP_FUNCTION()
static int32 CalcSize(const FOptionalProperty* OptionalProperty);
UNREALSHARP_FUNCTION()
static void DestructInstance(const FOptionalProperty* OptionalProperty, void* Data);
};

View File

@ -0,0 +1,106 @@
#include "FPropertyExporter.h"
FProperty* UFPropertyExporter::GetNativePropertyFromName(UStruct* Struct, const char* PropertyName)
{
FProperty* Property = FindFProperty<FProperty>(Struct, PropertyName);
return Property;
}
int32 UFPropertyExporter::GetPropertyOffset(FProperty* Property)
{
return Property->GetOffset_ForInternal();
}
int32 UFPropertyExporter::GetSize(FProperty* Property)
{
return Property->GetSize();
}
int32 UFPropertyExporter::GetArrayDim(FProperty* Property)
{
return Property->ArrayDim;
}
void UFPropertyExporter::DestroyValue(FProperty* Property, void* Value)
{
Property->DestroyValue(Value);
}
void UFPropertyExporter::DestroyValue_InContainer(FProperty* Property, void* Value)
{
Property->DestroyValue_InContainer(Value);
}
void UFPropertyExporter::InitializeValue(FProperty* Property, void* Value)
{
Property->InitializeValue(Value);
}
bool UFPropertyExporter::Identical(const FProperty* Property, void* ValueA, void* ValueB)
{
bool bIsIdentical = Property->Identical(ValueA, ValueB);
return bIsIdentical;
}
void UFPropertyExporter::GetInnerFields(FProperty* SetProperty, TArray<FField*>* OutFields)
{
SetProperty->GetInnerFields(*OutFields);
}
uint32 UFPropertyExporter::GetValueTypeHash(FProperty* Property, void* Source)
{
return Property->GetValueTypeHash(Source);
}
bool UFPropertyExporter::HasAnyPropertyFlags(FProperty* Property, EPropertyFlags FlagsToCheck)
{
return Property->HasAnyPropertyFlags(FlagsToCheck);
}
bool UFPropertyExporter::HasAllPropertyFlags(FProperty* Property, EPropertyFlags FlagsToCheck)
{
return Property->HasAllPropertyFlags(FlagsToCheck);
}
void UFPropertyExporter::CopySingleValue(FProperty* Property, void* Dest, void* Src)
{
Property->CopySingleValue(Dest, Src);
}
void UFPropertyExporter::GetValue_InContainer(FProperty* Property, void* Container, void* OutValue)
{
Property->GetValue_InContainer(Container, OutValue);
}
void UFPropertyExporter::SetValue_InContainer(FProperty* Property, void* Container, void* Value)
{
Property->SetValue_InContainer(Container, Value);
}
uint8 UFPropertyExporter::GetBoolPropertyFieldMaskFromName(UStruct* InStruct, const char* InPropertyName)
{
FBoolProperty* Property = FindFProperty<FBoolProperty>(InStruct, InPropertyName);
if (!Property)
{
return 0;
}
return Property->GetFieldMask();
}
int32 UFPropertyExporter::GetPropertyOffsetFromName(UStruct* InStruct, const char* InPropertyName)
{
FProperty* FoundProperty = GetNativePropertyFromName(InStruct, InPropertyName);
if (!FoundProperty)
{
return -1;
}
return GetPropertyOffset(FoundProperty);
}
int32 UFPropertyExporter::GetPropertyArrayDimFromName(UStruct* InStruct, const char* PropertyName)
{
FProperty* Property = GetNativePropertyFromName(InStruct, PropertyName);
return GetArrayDim(Property);
}

View File

@ -0,0 +1,69 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FPropertyExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFPropertyExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static FProperty* GetNativePropertyFromName(UStruct* Struct, const char* PropertyName);
UNREALSHARP_FUNCTION()
static int32 GetPropertyOffsetFromName(UStruct* InStruct, const char* InPropertyName);
UNREALSHARP_FUNCTION()
static int32 GetPropertyArrayDimFromName(UStruct* InStruct, const char* PropertyName);
UNREALSHARP_FUNCTION()
static int32 GetPropertyOffset(FProperty* Property);
UNREALSHARP_FUNCTION()
static int32 GetSize(FProperty* Property);
UNREALSHARP_FUNCTION()
static int32 GetArrayDim(FProperty* Property);
UNREALSHARP_FUNCTION()
static void DestroyValue(FProperty* Property, void* Value);
UNREALSHARP_FUNCTION()
static void DestroyValue_InContainer(FProperty* Property, void* Value);
UNREALSHARP_FUNCTION()
static void InitializeValue(FProperty* Property, void* Value);
UNREALSHARP_FUNCTION()
static bool Identical(const FProperty* Property, void* ValueA, void* ValueB);
UNREALSHARP_FUNCTION()
static void GetInnerFields(FProperty* SetProperty, TArray<FField*>* OutFields);
UNREALSHARP_FUNCTION()
static uint32 GetValueTypeHash(FProperty* Property, void* Source);
UNREALSHARP_FUNCTION()
static bool HasAnyPropertyFlags(FProperty* Property, EPropertyFlags FlagsToCheck);
UNREALSHARP_FUNCTION()
static bool HasAllPropertyFlags(FProperty* Property, EPropertyFlags FlagsToCheck);
UNREALSHARP_FUNCTION()
static void CopySingleValue(FProperty* Property, void* Dest, void* Src);
UNREALSHARP_FUNCTION()
static void GetValue_InContainer(FProperty* Property, void* Container, void* OutValue);
UNREALSHARP_FUNCTION()
static void SetValue_InContainer(FProperty* Property, void* Container, void* Value);
UNREALSHARP_FUNCTION()
static uint8 GetBoolPropertyFieldMaskFromName(UStruct* InStruct, const char* InPropertyName);
};

View File

@ -0,0 +1,37 @@
#include "FRandomStreamExporter.h"
void UFRandomStreamExporter::GenerateNewSeed(FRandomStream* RandomStream)
{
RandomStream->GenerateNewSeed();
}
float UFRandomStreamExporter::GetFraction(FRandomStream* RandomStream)
{
return RandomStream->GetFraction();
}
uint32 UFRandomStreamExporter::GetUnsignedInt(FRandomStream* RandomStream)
{
return RandomStream->GetUnsignedInt();
}
FVector UFRandomStreamExporter::GetUnitVector(FRandomStream* RandomStream)
{
return RandomStream->GetUnitVector();
}
int UFRandomStreamExporter::RandRange(FRandomStream* RandomStream, int32 Min, int32 Max)
{
return RandomStream->RandRange(Min, Max);
}
FVector UFRandomStreamExporter::VRandCone(FRandomStream* RandomStream, FVector Dir, float ConeHalfAngleRad)
{
return RandomStream->VRandCone(Dir, ConeHalfAngleRad);
}
FVector UFRandomStreamExporter::VRandCone2(FRandomStream* RandomStream, FVector Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad)
{
return RandomStream->VRandCone(Dir, HorizontalConeHalfAngleRad, VerticalConeHalfAngleRad);
}

View File

@ -0,0 +1,35 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FRandomStreamExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFRandomStreamExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void GenerateNewSeed(FRandomStream* RandomStream);
UNREALSHARP_FUNCTION()
static float GetFraction(FRandomStream* RandomStream);
UNREALSHARP_FUNCTION()
static uint32 GetUnsignedInt(FRandomStream* RandomStream);
UNREALSHARP_FUNCTION()
static FVector GetUnitVector(FRandomStream* RandomStream);
UNREALSHARP_FUNCTION()
static int RandRange(FRandomStream* RandomStream, int32 Min, int32 Max);
UNREALSHARP_FUNCTION()
static FVector VRandCone(FRandomStream* RandomStream, FVector Dir, float ConeHalfAngleRad);
UNREALSHARP_FUNCTION()
static FVector VRandCone2(FRandomStream* RandomStream, FVector Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad);
};

View File

@ -0,0 +1,8 @@
#include "FRotatorExporter.h"
void UFRotatorExporter::FromMatrix(FRotator* Rotator, const FMatrix& Matrix)
{
*Rotator = Matrix.Rotator();
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FRotatorExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFRotatorExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void FromMatrix(FRotator* Rotator, const FMatrix& Matrix);
};

View File

@ -0,0 +1,21 @@
#include "FScriptArrayExporter.h"
void* UFScriptArrayExporter::GetData(FScriptArray* Instance)
{
return Instance->GetData();
}
bool UFScriptArrayExporter::IsValidIndex(FScriptArray* Instance, int32 i)
{
return Instance->IsValidIndex(i);
}
int UFScriptArrayExporter::Num(FScriptArray* Instance)
{
return Instance->Num();
}
void UFScriptArrayExporter::Destroy(FScriptArray* Instance)
{
Instance->~FScriptArray();
}

View File

@ -0,0 +1,26 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FScriptArrayExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFScriptArrayExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* GetData(FScriptArray* Instance);
UNREALSHARP_FUNCTION()
static bool IsValidIndex(FScriptArray* Instance, int32 i);
UNREALSHARP_FUNCTION()
static int Num(FScriptArray* Instance);
UNREALSHARP_FUNCTION()
static void Destroy(FScriptArray* Instance);
};

View File

@ -0,0 +1,11 @@
#include "FScriptDelegateExporter.h"
void UFScriptDelegateExporter::BroadcastDelegate(FScriptDelegate* Delegate, void* Params)
{
Delegate->ProcessDelegate<UObject>(Params);
}
bool UFScriptDelegateExporter::IsBound(FScriptDelegate* Delegate)
{
return Delegate->IsBound();
}

View File

@ -0,0 +1,20 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FScriptDelegateExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFScriptDelegateExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void BroadcastDelegate(FScriptDelegate* Delegate, void* Params);
UNREALSHARP_FUNCTION()
static bool IsBound(FScriptDelegate* Delegate);
};

View File

@ -0,0 +1,65 @@
#include "FScriptMapHelperExporter.h"
void UFScriptMapHelperExporter::AddPair(FMapProperty* MapProperty, const void* Address, const void* Key, const void* Value)
{
FScriptMapHelper Helper(MapProperty, Address);
Helper.AddPair(Key, Value);
}
void* UFScriptMapHelperExporter::FindOrAdd(FMapProperty* MapProperty, const void* Address, const void* Key)
{
FScriptMapHelper Helper(MapProperty, Address);
return Helper.FindOrAdd(Key);
}
int UFScriptMapHelperExporter::Num(FMapProperty* MapProperty, const void* Address)
{
FScriptMapHelper Helper(MapProperty, Address);
return Helper.Num();
}
int UFScriptMapHelperExporter::FindMapPairIndexFromHash(FMapProperty* MapProperty, const void* Address, const void* Key)
{
FScriptMapHelper Helper(MapProperty, Address);
#if ENGINE_MINOR_VERSION >= 4
return Helper.FindMapPairIndexFromHash(Key);
#else
return Helper.FindMapIndexWithKey(Key);
#endif
}
void UFScriptMapHelperExporter::RemoveIndex(FMapProperty* MapProperty, const void* Address, int Index)
{
FScriptMapHelper Helper(MapProperty, Address);
Helper.RemoveAt(Index);
}
void UFScriptMapHelperExporter::EmptyValues(FMapProperty* MapProperty, const void* Address)
{
FScriptMapHelper Helper(MapProperty, Address);
Helper.EmptyValues();
}
void UFScriptMapHelperExporter::Remove(FMapProperty* MapProperty, const void* Address, const void* Key)
{
FScriptMapHelper Helper(MapProperty, Address);
Helper.RemovePair(Key);
}
bool UFScriptMapHelperExporter::IsValidIndex(FMapProperty* MapProperty, const void* Address, int Index)
{
FScriptMapHelper Helper(MapProperty, Address);
return Helper.IsValidIndex(Index);
}
int UFScriptMapHelperExporter::GetMaxIndex(FMapProperty* MapProperty, const void* Address)
{
FScriptMapHelper Helper(MapProperty, Address);
return Helper.GetMaxIndex();
}
void* UFScriptMapHelperExporter::GetPairPtr(FMapProperty* MapProperty, const void* Address, int Index)
{
FScriptMapHelper Helper(MapProperty, Address);
return Helper.GetPairPtr(Index);
}

View File

@ -0,0 +1,44 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FScriptMapHelperExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFScriptMapHelperExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void AddPair(FMapProperty* MapProperty, const void* Address, const void* Key, const void* Value);
UNREALSHARP_FUNCTION()
static void* FindOrAdd(FMapProperty* MapProperty, const void* Address, const void* Key);
UNREALSHARP_FUNCTION()
static int Num(FMapProperty* MapProperty, const void* Address);
UNREALSHARP_FUNCTION()
static int FindMapPairIndexFromHash(FMapProperty* MapProperty, const void* Address, const void* Key);
UNREALSHARP_FUNCTION()
static void RemoveIndex(FMapProperty* MapProperty, const void* Address, int Index);
UNREALSHARP_FUNCTION()
static void EmptyValues(FMapProperty* MapProperty, const void* Address);
UNREALSHARP_FUNCTION()
static void Remove(FMapProperty* MapProperty, const void* Address, const void* Key);
UNREALSHARP_FUNCTION()
static bool IsValidIndex(FMapProperty* MapProperty, const void* Address, int Index);
UNREALSHARP_FUNCTION()
static int GetMaxIndex(FMapProperty* MapProperty, const void* Address);
UNREALSHARP_FUNCTION()
static void* GetPairPtr(FMapProperty* MapProperty, const void* Address, int Index);
};

View File

@ -0,0 +1,52 @@
#include "FScriptSetExporter.h"
bool UFScriptSetExporter::IsValidIndex(FScriptSet* ScriptSet, int32 Index)
{
return ScriptSet->IsValidIndex(Index);
}
int UFScriptSetExporter::Num(FScriptSet* ScriptSet)
{
int Num = ScriptSet->Num();
return Num;
}
int UFScriptSetExporter::GetMaxIndex(FScriptSet* ScriptSet)
{
return ScriptSet->GetMaxIndex();
}
void* UFScriptSetExporter::GetData(int Index, FScriptSet* ScriptSet, FSetProperty* Property)
{
return ScriptSet->GetData(Index, Property->SetLayout);
}
void UFScriptSetExporter::Empty(int Slack, FScriptSet* ScriptSet, FSetProperty* Property)
{
return ScriptSet->Empty(Slack, Property->SetLayout);
}
void UFScriptSetExporter::RemoveAt(int Index, FScriptSet* ScriptSet, FSetProperty* Property)
{
return ScriptSet->RemoveAt(Index, Property->SetLayout);
}
int UFScriptSetExporter::AddUninitialized(FScriptSet* ScriptSet, FSetProperty* Property)
{
return ScriptSet->AddUninitialized(Property->SetLayout);
}
void UFScriptSetExporter::Add(FScriptSet* ScriptSet, FSetProperty* Property, const void* Element,FGetKeyHash GetKeyHash, FEqualityFn EqualityFn, FConstructFn ConstructFn, FDestructFn DestructFn)
{
ScriptSet->Add(Element, Property->SetLayout, GetKeyHash, EqualityFn, ConstructFn, DestructFn);
}
int32 UFScriptSetExporter::FindOrAdd(FScriptSet* ScriptSet, FSetProperty* Property, const void* Element, FGetKeyHash GetKeyHash, FEqualityFn EqualityFn, FConstructFn ConstructFn)
{
return ScriptSet->FindOrAdd(Element, Property->SetLayout, GetKeyHash, EqualityFn, ConstructFn);
}
int UFScriptSetExporter::FindIndex(FScriptSet* ScriptSet, FSetProperty* Property, const void* Element, FGetKeyHash GetKeyHash, FEqualityFn EqualityFn)
{
return ScriptSet->FindIndex(Element, Property->SetLayout, GetKeyHash, EqualityFn);
}

View File

@ -0,0 +1,50 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FScriptSetExporter.generated.h"
using FGetKeyHash = uint32(*)(const void*);
using FEqualityFn = bool(*)(const void*, const void*);
using FConstructFn = void(*)(void*);
using FDestructFn = void(*)(void*);
UCLASS()
class UNREALSHARPCORE_API UFScriptSetExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static bool IsValidIndex(FScriptSet* ScriptSet, int32 Index);
UNREALSHARP_FUNCTION()
static int Num(FScriptSet* ScriptSet);
UNREALSHARP_FUNCTION()
static int GetMaxIndex(FScriptSet* ScriptSet);
UNREALSHARP_FUNCTION()
static void* GetData(int Index, FScriptSet* ScriptSet, FSetProperty* Property);
UNREALSHARP_FUNCTION()
static void Empty(int Slack, FScriptSet* ScriptSet, FSetProperty* Property);
UNREALSHARP_FUNCTION()
static void RemoveAt(int Index, FScriptSet* ScriptSet, FSetProperty* Property);
UNREALSHARP_FUNCTION()
static int AddUninitialized(FScriptSet* ScriptSet, FSetProperty* Property);
UNREALSHARP_FUNCTION()
static void Add(FScriptSet* ScriptSet, FSetProperty* Property, const void* Element, FGetKeyHash GetKeyHash, FEqualityFn EqualityFn, FConstructFn ConstructFn, FDestructFn DestructFn);
UNREALSHARP_FUNCTION()
static int32 FindOrAdd(FScriptSet* ScriptSet, FSetProperty* Property, const void* Element, FGetKeyHash GetKeyHash, FEqualityFn EqualityFn, FConstructFn ConstructFn);
UNREALSHARP_FUNCTION()
static int FindIndex(FScriptSet* ScriptSet, FSetProperty* Property, const void* Element, FGetKeyHash GetKeyHash, FEqualityFn EqualityFn);
};

View File

@ -0,0 +1,6 @@
#include "FSetPropertyExporter.h"
void* UFSetPropertyExporter::GetElement(FSetProperty* Property)
{
return Property->ElementProp;
}

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UObject/Object.h"
#include "FSetPropertyExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFSetPropertyExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* GetElement(FSetProperty* Property);
};

View File

@ -0,0 +1,13 @@
#include "FSoftObjectPtrExporter.h"
#include "UnrealSharpCore/CSManager.h"
void* UFSoftObjectPtrExporter::LoadSynchronous(const TSoftObjectPtr<UObject>* SoftObjectPtr)
{
if (SoftObjectPtr->IsNull())
{
return nullptr;
}
UObject* LoadedObject = SoftObjectPtr->LoadSynchronous();
return UCSManager::Get().FindManagedObject(LoadedObject);
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FSoftObjectPtrExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFSoftObjectPtrExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* LoadSynchronous(const TSoftObjectPtr<UObject>* SoftObjectPtr);
};

View File

@ -0,0 +1,6 @@
#include "FStringExporter.h"
void UFStringExporter::MarshalToNativeString(FString* String, TCHAR* ManagedString)
{
*String = ManagedString;
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FStringExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFStringExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void MarshalToNativeString(FString* String, TCHAR* ManagedString);
};

View File

@ -0,0 +1,9 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "FSubsystemCollectionBaseRefExporter.h"
USubsystem* UFSubsystemCollectionBaseRefExporter::InitializeDependency(FSubsystemCollectionBase* Collection, UClass* SubsystemClass)
{
return Collection->InitializeDependency(SubsystemClass);
}

View File

@ -0,0 +1,21 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UObject/Object.h"
#include "FSubsystemCollectionBaseRefExporter.generated.h"
/**
*
*/
UCLASS()
class UNREALSHARPCORE_API UFSubsystemCollectionBaseRefExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static USubsystem* InitializeDependency(FSubsystemCollectionBase* Collection, UClass* SubsystemClass);
};

View File

@ -0,0 +1,66 @@
#include "FTextExporter.h"
const TCHAR* UFTextExporter::ToString(FText* Text)
{
if (!Text)
{
return nullptr;
}
return *Text->ToString();
}
void UFTextExporter::ToStringView(FText* Text, const TCHAR*& OutString, int32& OutLength)
{
if (!Text)
{
OutString = nullptr;
OutLength = 0;
return;
}
const FString& AsString = Text->ToString();
OutString = *AsString;
OutLength = AsString.Len();
}
void UFTextExporter::FromString(FText* Text, const char* String)
{
if (!Text)
{
return;
}
*Text = Text->FromString(String);
}
void UFTextExporter::FromStringView(FText* Text, const TCHAR* String, int32 Length)
{
if (!Text)
{
return;
}
*Text = Text->FromStringView(FStringView(String, Length));
}
void UFTextExporter::FromName(FText* Text, FName Name)
{
if (!Text)
{
return;
}
*Text = Text->FromName(Name);
}
void UFTextExporter::CreateEmptyText(FText* Text)
{
if (!Text)
{
return;
}
*Text = FText::GetEmpty();
}

View File

@ -0,0 +1,29 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FTextExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFTextExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static const TCHAR* ToString(FText* Text);
UNREALSHARP_FUNCTION()
static void ToStringView(FText* Text, const TCHAR*& OutString, int32& OutLength);
UNREALSHARP_FUNCTION()
static void FromString(FText* Text, const char* String);
UNREALSHARP_FUNCTION()
static void FromStringView(FText* Text, const TCHAR* String, int32 Length);
UNREALSHARP_FUNCTION()
static void FromName(FText* Text, FName Name);
UNREALSHARP_FUNCTION()
static void CreateEmptyText(FText* Text);
};

View File

@ -0,0 +1,6 @@
#include "FVectorExporter.h"
FVector UFVectorExporter::FromRotator(const FRotator& Rotator)
{
return Rotator.Vector();
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FVectorExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFVectorExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static FVector FromRotator(const FRotator& Rotator);
};

View File

@ -0,0 +1,35 @@
#include "FWeakObjectPtrExporter.h"
#include "UnrealSharpCore/CSManager.h"
void UFWeakObjectPtrExporter::SetObject(TWeakObjectPtr<UObject>& WeakObject, UObject* Object)
{
WeakObject = Object;
}
void* UFWeakObjectPtrExporter::GetObject(TWeakObjectPtr<UObject> WeakObjectPtr)
{
if (!WeakObjectPtr.IsValid())
{
return nullptr;
}
UObject* Object = WeakObjectPtr.Get();
return UCSManager::Get().FindManagedObject(Object);
}
bool UFWeakObjectPtrExporter::IsValid(TWeakObjectPtr<UObject> WeakObjectPtr)
{
return WeakObjectPtr.IsValid();
}
bool UFWeakObjectPtrExporter::IsStale(TWeakObjectPtr<UObject> WeakObjectPtr)
{
return WeakObjectPtr.IsStale();
}
bool UFWeakObjectPtrExporter::NativeEquals(TWeakObjectPtr<UObject> A, TWeakObjectPtr<UObject> B)
{
return A == B;
}

View File

@ -0,0 +1,29 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FWeakObjectPtrExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UFWeakObjectPtrExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void SetObject(TWeakObjectPtr<UObject>& WeakObject, UObject* Object);
UNREALSHARP_FUNCTION()
static void* GetObject(TWeakObjectPtr<UObject> WeakObjectPtr);
UNREALSHARP_FUNCTION()
static bool IsValid(TWeakObjectPtr<UObject> WeakObjectPtr);
UNREALSHARP_FUNCTION()
static bool IsStale(TWeakObjectPtr<UObject> WeakObjectPtr);
UNREALSHARP_FUNCTION()
static bool NativeEquals(TWeakObjectPtr<UObject> A, TWeakObjectPtr<UObject> B);
};

View File

@ -0,0 +1,11 @@
#include "FWorldDelegatesExporter.h"
void UFWorldDelegatesExporter::BindOnWorldCleanup(FWorldCleanupEventDelegate Delegate, FDelegateHandle* Handle)
{
*Handle = FWorldDelegates::OnWorldCleanup.AddLambda(Delegate);
}
void UFWorldDelegatesExporter::UnbindOnWorldCleanup(const FDelegateHandle Handle)
{
FWorldDelegates::OnWorldCleanup.Remove(Handle);
}

View File

@ -0,0 +1,23 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "FWorldDelegatesExporter.generated.h"
using FWorldCleanupEventDelegate = void(*)(UWorld*, bool, bool);
UCLASS()
class UNREALSHARPCORE_API UFWorldDelegatesExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void BindOnWorldCleanup(FWorldCleanupEventDelegate Delegate, FDelegateHandle* Handle);
UNREALSHARP_FUNCTION()
static void UnbindOnWorldCleanup(FDelegateHandle Handle);
};

View File

@ -0,0 +1,18 @@
#include "GEditorExporter.h"
#include "CSManager.h"
#if WITH_EDITOR
#include "Editor.h"
#include "EditorSubsystem.h"
#endif
void* UGEditorExporter::GetEditorSubsystem(UClass* SubsystemClass)
{
#if WITH_EDITOR
const UEditorSubsystem* EditorSubsystem = GEditor->GetEditorSubsystemBase(SubsystemClass);
return UCSManager::Get().FindManagedObject(EditorSubsystem);
#else
return nullptr;
#endif
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "GEditorExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UGEditorExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* GetEditorSubsystem(UClass* SubsystemClass);
};

View File

@ -0,0 +1,9 @@
#include "GEngineExporter.h"
#include "Engine/Engine.h"
#include "UnrealSharpCore/CSManager.h"
void* UGEngineExporter::GetEngineSubsystem(UClass* SubsystemClass)
{
UEngineSubsystem* EngineSubsystem = GEngine->GetEngineSubsystemBase(SubsystemClass);
return UCSManager::Get().FindManagedObject(EngineSubsystem);
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "GEngineExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UGEngineExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* GetEngineSubsystem(UClass* SubsystemClass);
};

View File

@ -0,0 +1,34 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "IRefCountedObjectExporter.h"
uint32 UIRefCountedObjectExporter::GetRefCount(const IRefCountedObject* Object)
{
if (!Object || Object->GetRefCount() == 0)
{
return 0;
}
return Object->GetRefCount();
}
uint32 UIRefCountedObjectExporter::AddRef(const IRefCountedObject* Object)
{
if (!Object || Object->GetRefCount() == 0)
{
return 0;
}
return Object->AddRef();
}
uint32 UIRefCountedObjectExporter::Release(const IRefCountedObject* Object)
{
if (!Object || Object->GetRefCount() == 0)
{
return 0;
}
return Object->Release();
}

View File

@ -0,0 +1,23 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UObject/Object.h"
#include "IRefCountedObjectExporter.generated.h"
UCLASS()
class UIRefCountedObjectExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static uint32 GetRefCount(const IRefCountedObject* Object);
UNREALSHARP_FUNCTION()
static uint32 AddRef(const IRefCountedObject* Object);
UNREALSHARP_FUNCTION()
static uint32 Release(const IRefCountedObject* Object);
};

View File

@ -0,0 +1,26 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "ManagedHandleExporter.h"
void UManagedHandleExporter::StoreManagedHandle(const FGCHandleIntPtr Handle, FSharedGCHandle& Destination)
{
Destination = FSharedGCHandle(Handle);
}
FGCHandleIntPtr UManagedHandleExporter::LoadManagedHandle(const FSharedGCHandle& Source)
{
return Source.GetHandle();
}
void UManagedHandleExporter::StoreUnmanagedMemory(const void* Source, FUnmanagedDataStore& Destination, const int32 Size)
{
check(Size > 0)
Destination.CopyDataIn(Source, Size);
}
void UManagedHandleExporter::LoadUnmanagedMemory(const FUnmanagedDataStore& Source, void* Destination, const int32 Size)
{
check(Size > 0)
Source.CopyDataOut(Destination, Size);
}

View File

@ -0,0 +1,32 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "CSManagedGCHandle.h"
#include "CSUnmanagedDataStore.h"
#include "UObject/Object.h"
#include "ManagedHandleExporter.generated.h"
/**
*
*/
UCLASS()
class UNREALSHARPCORE_API UManagedHandleExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void StoreManagedHandle(FGCHandleIntPtr Handle, FSharedGCHandle& Destination);
UNREALSHARP_FUNCTION()
static FGCHandleIntPtr LoadManagedHandle(const FSharedGCHandle& Source);
UNREALSHARP_FUNCTION()
static void StoreUnmanagedMemory(const void* Source, FUnmanagedDataStore& Destination, const int32 Size);
UNREALSHARP_FUNCTION()
static void LoadUnmanagedMemory(const FUnmanagedDataStore& Source, void* Destination, const int32 Size);
};

View File

@ -0,0 +1,29 @@
#include "TPersistentObjectPtrExporter.h"
#include "UnrealSharpCore/CSManager.h"
void UTPersistentObjectPtrExporter::FromObject(TPersistentObjectPtr<FSoftObjectPath>* Path, UObject* InObject)
{
*Path = InObject;
}
void UTPersistentObjectPtrExporter::FromSoftObjectPath(TPersistentObjectPtr<FSoftObjectPath>* Path, const FSoftObjectPath* SoftObjectPath)
{
*Path = *SoftObjectPath;
}
void* UTPersistentObjectPtrExporter::Get(TPersistentObjectPtr<FSoftObjectPath>* Path)
{
UObject* Object = Path->Get();
return UCSManager::Get().FindManagedObject(Object);
}
void* UTPersistentObjectPtrExporter::GetNativePointer(TPersistentObjectPtr<FSoftObjectPath>* Path)
{
return Path->Get();
}
void* UTPersistentObjectPtrExporter::GetUniqueID(TPersistentObjectPtr<FSoftObjectPath>* Path)
{
return &Path->GetUniqueID();
}

View File

@ -0,0 +1,31 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "TPersistentObjectPtrExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UTPersistentObjectPtrExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void FromObject(TPersistentObjectPtr<FSoftObjectPath>* Path, UObject* Object);
UNREALSHARP_FUNCTION()
static void FromSoftObjectPath(TPersistentObjectPtr<FSoftObjectPath>* Path, const FSoftObjectPath* SoftObjectPath);
UNREALSHARP_FUNCTION()
static void* Get(TPersistentObjectPtr<FSoftObjectPath>* Path);
UNREALSHARP_FUNCTION()
static void* GetNativePointer(TPersistentObjectPtr<FSoftObjectPath>* Path);
UNREALSHARP_FUNCTION()
static void* GetUniqueID(TPersistentObjectPtr<FSoftObjectPath>* Path);
};

View File

@ -0,0 +1,21 @@
#include "TSharedPtrExporter.h"
void UTSharedPtrExporter::AddSharedReference(SharedPointerInternals::TReferenceControllerBase<ESPMode::ThreadSafe>* ReferenceController)
{
if (!ReferenceController)
{
return;
}
ReferenceController->AddSharedReference();
}
void UTSharedPtrExporter::ReleaseSharedReference(SharedPointerInternals::TReferenceControllerBase<ESPMode::ThreadSafe>* ReferenceController)
{
if (!ReferenceController)
{
return;
}
ReferenceController->ReleaseSharedReference();
}

View File

@ -0,0 +1,20 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "TSharedPtrExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UTSharedPtrExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void AddSharedReference(SharedPointerInternals::TReferenceControllerBase<ESPMode::ThreadSafe>* ReferenceController);
UNREALSHARP_FUNCTION()
static void ReleaseSharedReference(SharedPointerInternals::TReferenceControllerBase<ESPMode::ThreadSafe>* ReferenceController);
};

View File

@ -0,0 +1,18 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "TStrongObjectPtrExporter.h"
void UTStrongObjectPtrExporter::ConstructStrongObjectPtr(TStrongObjectPtr<UObject>* Ptr, UObject* Object)
{
static_assert(sizeof(TStrongObjectPtr<UObject>) == sizeof(UObject*), "TStrongObjectPtr<UObject> must be the same size as UObject*");
check(Ptr != nullptr);
std::construct_at(Ptr, Object);
}
void UTStrongObjectPtrExporter::DestroyStrongObjectPtr(TStrongObjectPtr<UObject>* Ptr)
{
static_assert(sizeof(TStrongObjectPtr<UObject>) == sizeof(UObject*), "TStrongObjectPtr<UObject> must be the same size as UObject*");
check(Ptr != nullptr);
std::destroy_at(Ptr);
}

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UObject/Object.h"
#include "TStrongObjectPtrExporter.generated.h"
/**
*
*/
UCLASS()
class UNREALSHARPCORE_API UTStrongObjectPtrExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void ConstructStrongObjectPtr(TStrongObjectPtr<UObject>* Ptr, UObject* Object);
UNREALSHARP_FUNCTION()
static void DestroyStrongObjectPtr(TStrongObjectPtr<UObject>* Ptr);
};

View File

@ -0,0 +1,9 @@
#include "UAssetManagerExporter.h"
#include "CSManager.h"
#include "Engine/AssetManager.h"
void* UUAssetManagerExporter::GetAssetManager()
{
UAssetManager& AssetManager = UAssetManager::Get();
return UCSManager::Get().FindManagedObject(&AssetManager);
}

View File

@ -0,0 +1,19 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UAssetManagerExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UUAssetManagerExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* GetAssetManager();
};

View File

@ -0,0 +1,64 @@
#include "UClassExporter.h"
#include "CSManager.h"
#include "UnrealSharpCore/TypeGenerator/Register/TypeInfo/CSClassInfo.h"
#include "UnrealSharpCore/UnrealSharpCore.h"
UFunction* UUClassExporter::GetNativeFunctionFromClassAndName(const UClass* Class, const char* FunctionName)
{
UFunction* Function = Class->FindFunctionByName(FunctionName);
if (!Function)
{
UE_LOG(LogUnrealSharp, Warning, TEXT("Failed to get NativeFunction. FunctionName: %hs"), FunctionName)
return nullptr;
}
return Function;
}
UFunction* UUClassExporter::GetNativeFunctionFromInstanceAndName(const UObject* NativeObject, const char* FunctionName)
{
if (!IsValid(NativeObject))
{
UE_LOG(LogUnrealSharp, Warning, TEXT("Failed to get NativeFunction. NativeObject is not valid."))
return nullptr;
}
return NativeObject->FindFunctionChecked(FunctionName);
}
void* UUClassExporter::GetDefaultFromName(const char* AssemblyName, const char* Namespace, const char* ClassName)
{
UCSAssembly* Assembly = UCSManager::Get().FindOrLoadAssembly(AssemblyName);
FCSFieldName FieldName(ClassName, Namespace);
UClass* Class = Assembly->FindType<UClass>(FieldName);
if (!IsValid(Class))
{
UE_LOGFMT(LogUnrealSharp, Warning, "Failed to get default object. ClassName: {0}", *FieldName.GetName());
return nullptr;
}
return UCSManager::Get().FindManagedObject(Class->GetDefaultObject());
}
void* UUClassExporter::GetDefaultFromInstance(UObject* Object)
{
if (!IsValid(Object))
{
return nullptr;
}
UObject* CDO;
if (UClass* Class = Cast<UClass>(Object))
{
CDO = Class->GetDefaultObject();
}
else
{
CDO = Object->GetClass()->GetDefaultObject();
}
return UCSManager::Get().FindManagedObject(CDO);
}

View File

@ -0,0 +1,26 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UClassExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UUClassExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static UFunction* GetNativeFunctionFromClassAndName(const UClass* Class, const char* FunctionName);
UNREALSHARP_FUNCTION()
static UFunction* GetNativeFunctionFromInstanceAndName(const UObject* NativeObject, const char* FunctionName);
UNREALSHARP_FUNCTION()
static void* GetDefaultFromName(const char* AssemblyName, const char* Namespace, const char* ClassName);
UNREALSHARP_FUNCTION()
static void* GetDefaultFromInstance(UObject* Object);
};

View File

@ -0,0 +1,29 @@
#include "UCoreUObjectExporter.h"
#include "CSAssembly.h"
#include "CSManager.h"
#include "TypeGenerator/Register/TypeInfo/CSClassInfo.h"
UClass* UUCoreUObjectExporter::GetNativeClassFromName(const char* InAssemblyName, const char* InNamespace, const char* InClassName)
{
// This gets called by the static constructor of the class, so we can cache the class info of native classes here.
UCSAssembly* Assembly = UCSManager::Get().FindOrLoadAssembly(InAssemblyName);
FCSFieldName FieldName(InClassName, InNamespace);
TSharedPtr<FCSClassInfo> ClassInfo = Assembly->FindOrAddTypeInfo<FCSClassInfo>(FieldName);
return ClassInfo->GetFieldChecked<UClass>();
}
UClass* UUCoreUObjectExporter::GetNativeInterfaceFromName(const char* InAssemblyName, const char* InNamespace, const char* InInterfaceName)
{
UCSAssembly* Assembly = UCSManager::Get().FindOrLoadAssembly(InAssemblyName);
FCSFieldName FieldName(InInterfaceName, InNamespace);
return Assembly->FindType<UClass>(FieldName);
}
UScriptStruct* UUCoreUObjectExporter::GetNativeStructFromName(const char* InAssemblyName, const char* InNamespace, const char* InStructName)
{
UCSAssembly* Assembly = UCSManager::Get().FindOrLoadAssembly(InAssemblyName);
FCSFieldName FieldName(InStructName, InNamespace);
UScriptStruct* ScriptStruct = Assembly->FindType<UScriptStruct>(FieldName);
return ScriptStruct;
}

View File

@ -0,0 +1,22 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UCoreUObjectExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UUCoreUObjectExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static UClass* GetNativeClassFromName(const char* InAssemblyName, const char* InNamespace, const char* InClassName);
UNREALSHARP_FUNCTION()
static UClass* GetNativeInterfaceFromName(const char* InAssemblyName, const char* InNamespace, const char* InInterfaceName);
UNREALSHARP_FUNCTION()
static UScriptStruct* GetNativeStructFromName(const char* InAssemblyName, const char* InNamespace, const char* InStructName);
};

View File

@ -0,0 +1,11 @@
#include "UDataTableExporter.h"
uint8* UUDataTableExporter::GetRow(const UDataTable* DataTable, FName RowName)
{
if (!IsValid(DataTable))
{
return nullptr;
}
return DataTable->FindRowUnchecked(RowName);
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UDataTableExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UUDataTableExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static uint8* GetRow(const UDataTable* DataTable, FName RowName);
};

View File

@ -0,0 +1,22 @@
#include "UEnhancedInputComponentExporter.h"
#include "EnhancedInputComponent.h"
bool UUEnhancedInputComponentExporter::BindAction(UEnhancedInputComponent* InputComponent, UInputAction* InputAction, ETriggerEvent TriggerEvent, UObject* Object, const FName FunctionName, uint32* OutHandle)
{
if (!IsValid(InputComponent) || !IsValid(InputAction))
{
return false;
}
*OutHandle = InputComponent->BindAction(InputAction, TriggerEvent, Object, FunctionName).GetHandle();
return true;
}
bool UUEnhancedInputComponentExporter::RemoveBindingByHandle(UEnhancedInputComponent* InputComponent, const uint32 Handle)
{
if (!IsValid(InputComponent))
{
return false;
}
return InputComponent->RemoveBindingByHandle(Handle);
}

View File

@ -0,0 +1,25 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UEnhancedInputComponentExporter.generated.h"
enum class ETriggerEvent : uint8;
class UInputAction;
class UEnhancedInputComponent;
UCLASS()
class UNREALSHARPCORE_API UUEnhancedInputComponentExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static bool BindAction(UEnhancedInputComponent* InputComponent, UInputAction* InputAction, ETriggerEvent TriggerEvent, UObject* Object, const FName FunctionName, uint32* OutHandle);
UNREALSHARP_FUNCTION()
static bool RemoveBindingByHandle(UEnhancedInputComponent* InputComponent, const uint32 Handle);
};

View File

@ -0,0 +1,30 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "UEnumExporter.h"
#include "CSManager.h"
#include "TypeGenerator/CSEnum.h"
FGCHandleIntPtr UUEnumExporter::GetManagedEnumType(UEnum* ScriptEnum)
{
if (const UCSEnum* CSEnum = Cast<UCSEnum>(ScriptEnum); CSEnum != nullptr)
{
return CSEnum->GetManagedTypeInfo<FCSManagedTypeInfo>()->GetManagedTypeHandle()->GetHandle();
}
const UCSAssembly* Assembly = UCSManager::Get().FindOwningAssembly(ScriptEnum);
if (Assembly == nullptr)
{
return FGCHandleIntPtr();
}
const FCSFieldName FieldName(ScriptEnum);
const TSharedPtr<FCSManagedTypeInfo> Info = Assembly->FindTypeInfo<FCSManagedTypeInfo>(FieldName);
if (!Info.IsValid())
{
return FGCHandleIntPtr();
}
return Info->GetManagedTypeHandle()->GetHandle();
}

View File

@ -0,0 +1,22 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "CSManagedGCHandle.h"
#include "UObject/Object.h"
#include "UEnumExporter.generated.h"
/**
*
*/
UCLASS()
class UNREALSHARPCORE_API UUEnumExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static FGCHandleIntPtr GetManagedEnumType(UEnum* ScriptEnum);
};

View File

@ -0,0 +1,102 @@
#include "UFunctionExporter.h"
#include "UnrealSharpCore.h"
#include "Utils/CSClassUtilities.h"
uint16 UUFunctionExporter::GetNativeFunctionParamsSize(const UFunction* NativeFunction)
{
check(NativeFunction);
return NativeFunction->ParmsSize;
}
UFunction* UUFunctionExporter::CreateNativeFunctionCustomStructSpecialization(UFunction* NativeFunction,
FProperty** CustomStructParams, UScriptStruct** CustomStructs)
{
UClass* Outer = NativeFunction->GetOuterUClass();
UFunction* Specialization = NewObject<UFunction>(Outer, UFunction::StaticClass());
Specialization->FunctionFlags = NativeFunction->FunctionFlags;
Specialization->SetSuperStruct(NativeFunction);
Specialization->SetNativeFunc(NativeFunction->GetNativeFunc());
TArray<FProperty*> FunctionProperties;
for (TFieldIterator<FProperty> PropIt(NativeFunction); PropIt && PropIt->PropertyFlags & CPF_Parm; ++PropIt)
{
FProperty* Property = *PropIt;
FProperty* OutProperty;
if(Property == *CustomStructParams)
{
FStructProperty* CustomStructParam = new FStructProperty(Specialization, Property->GetFName(), Property->GetFlags());
UScriptStruct* Struct = *CustomStructs++;
CustomStructParam->Struct = Struct;
EPropertyFlags Flags = Property->GetPropertyFlags() | CPF_BlueprintVisible | CPF_BlueprintReadOnly;
if (const auto CppStructOps = Struct->GetCppStructOps())
{
const auto Capabilities = CppStructOps->GetCapabilities();
if(Capabilities.HasZeroConstructor)
{
Flags |= CPF_ZeroConstructor;
}
else
{
Flags &= ~(CPF_ZeroConstructor);
}
if(Capabilities.IsPlainOldData)
{
Flags |= CPF_IsPlainOldData;
}
else
{
Flags &= ~(CPF_IsPlainOldData);
}
}
else
{
Flags &= ~(CPF_ZeroConstructor | CPF_IsPlainOldData);
}
CustomStructParam->PropertyFlags = Flags;
OutProperty = CastField<FProperty>(CustomStructParam);
CustomStructParams++;
}
else
{
OutProperty = CastField<FProperty>(FField::Duplicate(Property, Specialization, Property->GetFName(), RF_AllFlags, CS_EInternalObjectFlags_AllFlags & ~EInternalObjectFlags::Native));
OutProperty->PropertyFlags |= CPF_BlueprintVisible | CPF_BlueprintReadOnly;
OutProperty->Next = nullptr;
}
Specialization->Script.Add(OutProperty->PropertyFlags & CPF_OutParm ? EX_LocalOutVariable : EX_LocalVariable);
Specialization->Script.Append((uint8*)&OutProperty, sizeof(FProperty*));
FunctionProperties.Add(OutProperty);
}
for(int32 i = FunctionProperties.Num(); i-- > 0;)
{
Specialization->AddCppProperty(FunctionProperties[i]);
}
Specialization->Next = Outer->Children;
Outer->Children = Specialization;
Specialization->StaticLink(true);
return Specialization;
}
void UUFunctionExporter::InitializeFunctionParams(UFunction* NativeFunction, void* Params)
{
check(NativeFunction && Params)
for (TFieldIterator<FProperty> PropIt(NativeFunction); PropIt; ++PropIt)
{
PropIt->InitializeValue_InContainer(Params);
}
}
bool UUFunctionExporter::HasBlueprintEventBeenImplemented(const UFunction* NativeFunction)
{
if (!IsValid(NativeFunction))
{
return false;
}
UClass* FunctionOwner = NativeFunction->GetOwnerClass();
return !FCSClassUtilities::IsNativeClass(FunctionOwner);
}

View File

@ -0,0 +1,28 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UFunctionExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UUFunctionExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static uint16 GetNativeFunctionParamsSize(const UFunction* NativeFunction);
UNREALSHARP_FUNCTION()
static UFunction* CreateNativeFunctionCustomStructSpecialization(UFunction* NativeFunction, FProperty** CustomStructParams, UScriptStruct** CustomStructs);
UNREALSHARP_FUNCTION()
static void InitializeFunctionParams(UFunction* NativeFunction, void* Params);
UNREALSHARP_FUNCTION()
static bool HasBlueprintEventBeenImplemented(const UFunction* NativeFunction);
};

View File

@ -0,0 +1,13 @@
#include "UGameInstanceExporter.h"
#include "UnrealSharpCore/CSManager.h"
void* UUGameInstanceExporter::GetGameInstanceSubsystem(UClass* SubsystemClass, UObject* WorldContextObject)
{
if (!IsValid(WorldContextObject))
{
return nullptr;
}
UGameInstanceSubsystem* GameInstanceSubsystem = WorldContextObject->GetWorld()->GetGameInstance()->GetSubsystemBase(SubsystemClass);
return UCSManager::Get().FindManagedObject(GameInstanceSubsystem);
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UGameInstanceExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UUGameInstanceExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* GetGameInstanceSubsystem(UClass* SubsystemClass, UObject* WorldContextObject);
};

View File

@ -0,0 +1,50 @@
#include "UInputComponentExporter.h"
void UUInputComponentExporter::BindAction(UInputComponent* InputComponent, const FName ActionName, const EInputEvent KeyEvent, UObject* Object, const FName FunctionName, bool bConsumeInput, bool bExecuteWhenPaused)
{
if (!IsValid(InputComponent))
{
return;
}
FInputActionHandlerSignature Handler;
Handler.BindUFunction(Object, FunctionName);
FInputActionBinding Binding(ActionName, KeyEvent);
Binding.ActionDelegate = Handler;
Binding.bConsumeInput = bConsumeInput;
Binding.bExecuteWhenPaused = bExecuteWhenPaused;
InputComponent->AddActionBinding(Binding);
}
void UUInputComponentExporter::BindActionKeySignature(UInputComponent* InputComponent, const FName ActionName, const EInputEvent KeyEvent, UObject* Object, const FName FunctionName, bool bConsumeInput, bool bExecuteWhenPaused)
{
if (!IsValid(InputComponent))
{
return;
}
FInputActionHandlerDynamicSignature Handler;
Handler.BindUFunction(Object, FunctionName);
FInputActionBinding Binding(ActionName, KeyEvent);
Binding.ActionDelegate = Handler;
Binding.bConsumeInput = bConsumeInput;
Binding.bExecuteWhenPaused = bExecuteWhenPaused;
InputComponent->AddActionBinding(Binding);
}
void UUInputComponentExporter::BindAxis(UInputComponent* InputComponent, const FName AxisName, UObject* Object, const FName FunctionName, bool bConsumeInput, bool bExecuteWhenPaused)
{
if (!IsValid(InputComponent))
{
return;
}
FInputAxisBinding NewAxisBinding(AxisName);
NewAxisBinding.bConsumeInput = bConsumeInput;
NewAxisBinding.bExecuteWhenPaused = bExecuteWhenPaused;
NewAxisBinding.AxisDelegate.BindDelegate(Object, FunctionName);
InputComponent->AxisBindings.Add(NewAxisBinding);
}

View File

@ -0,0 +1,25 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UInputComponentExporter.generated.h"
class UInputAction;
UCLASS()
class UNREALSHARPCORE_API UUInputComponentExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void BindAction(UInputComponent* InputComponent, const FName ActionName, const EInputEvent KeyEvent, UObject* Object, const FName FunctionName, bool bConsumeInput, bool bExecuteWhenPaused);
UNREALSHARP_FUNCTION()
static void BindActionKeySignature(UInputComponent* InputComponent, const FName ActionName, const EInputEvent KeyEvent, UObject* Object, const FName FunctionName, bool bConsumeInput, bool bExecuteWhenPaused);
UNREALSHARP_FUNCTION()
static void BindAxis(UInputComponent* InputComponent, const FName AxisName, UObject* Object, const FName FunctionName, bool bConsumeInput, bool bExecuteWhenPaused);
};

View File

@ -0,0 +1,13 @@
#include "ULocalPlayerExporter.h"
#include "UnrealSharpCore/CSManager.h"
void* UULocalPlayerExporter::GetLocalPlayerSubsystem(UClass* SubsystemClass, APlayerController* PlayerController)
{
if (!IsValid(PlayerController) || !IsValid(SubsystemClass))
{
return nullptr;
}
ULocalPlayerSubsystem* LocalPlayerSubsystem = PlayerController->GetLocalPlayer()->GetSubsystemBase(SubsystemClass);
return UCSManager::Get().FindManagedObject(LocalPlayerSubsystem);
}

View File

@ -0,0 +1,16 @@
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "ULocalPlayerExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UULocalPlayerExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* GetLocalPlayerSubsystem(UClass* SubsystemClass, APlayerController* PlayerController);
};

View File

@ -0,0 +1,172 @@
#include "UObjectExporter.h"
#include "UnrealSharpCore/CSManager.h"
#include "UObject/UObjectGlobals.h"
void* UUObjectExporter::CreateNewObject(UObject* Outer, UClass* Class, UObject* Template)
{
if (!IsValid(Outer))
{
return nullptr;
}
UObject* NewCSharpObject = NewObject<UObject>(Outer, Class, NAME_None, RF_NoFlags, Template);
return UCSManager::Get().FindManagedObject(NewCSharpObject);
}
void* UUObjectExporter::GetTransientPackage()
{
UPackage* TransientPackage = ::GetTransientPackage();
if (!IsValid(TransientPackage))
{
return nullptr;
}
return UCSManager::Get().FindManagedObject(TransientPackage);
}
void UUObjectExporter::NativeGetName(UObject* Object, FName* OutName)
{
*OutName = !IsValid(Object) ? NAME_None : Object->GetFName();
}
void UUObjectExporter::InvokeNativeFunction(UObject* NativeObject, UFunction* NativeFunction, uint8* Params, uint8* ReturnValueAddress)
{
TRACE_CPUPROFILER_EVENT_SCOPE(UUObjectExporter::InvokeNativeFunction);
FFrame NewStack(NativeObject, NativeFunction, Params, nullptr, NativeFunction->ChildProperties);
NativeFunction->Invoke(NativeObject, NewStack, ReturnValueAddress);
}
void UUObjectExporter::InvokeNativeStaticFunction(UClass* NativeClass, UFunction* NativeFunction, uint8* Params, uint8* ReturnValueAddress)
{
TRACE_CPUPROFILER_EVENT_SCOPE(UUObjectExporter::InvokeNativeStaticFunction);
UObject* ClassDefaultObject = NativeClass->GetDefaultObject();
if (NativeFunction->HasAllFunctionFlags(FUNC_HasOutParms))
{
InvokeNativeFunctionOutParms(ClassDefaultObject, NativeFunction, Params, ReturnValueAddress);
}
else
{
FFrame NewStack(ClassDefaultObject, NativeFunction, Params, nullptr, NativeFunction->ChildProperties);
NativeFunction->GetNativeFunc()(ClassDefaultObject, NewStack, ReturnValueAddress);
}
}
void UUObjectExporter::InvokeNativeNetFunction(UObject* NativeObject, UFunction* NativeFunction, uint8* Params, uint8* ReturnValueAddress)
{
TRACE_CPUPROFILER_EVENT_SCOPE(UUObjectExporter::InvokeNativeNetFunction);
int32 FunctionCallspace = NativeObject->GetFunctionCallspace(NativeFunction, nullptr);
if (FunctionCallspace & FunctionCallspace::Remote)
{
NativeObject->CallRemoteFunction(NativeFunction, Params, nullptr, nullptr);
return;
}
if (FunctionCallspace & FunctionCallspace::Absorbed)
{
return;
}
FFrame NewStack(NativeObject, NativeFunction, Params, nullptr, NativeFunction->ChildProperties);
NativeFunction->Invoke(NativeObject, NewStack, ReturnValueAddress);
}
void UUObjectExporter::InvokeNativeFunctionOutParms(UObject* NativeObject, UFunction* NativeFunction, uint8* Params, uint8* ReturnValueAddress)
{
TRACE_CPUPROFILER_EVENT_SCOPE(UUObjectExporter::InvokeNativeFunctionOutParms);
FFrame NewStack(NativeObject, NativeFunction, Params, nullptr, NativeFunction->ChildProperties);
FOutParmRec** LastOut = &NewStack.OutParms;
for (TFieldIterator<FProperty> PropIt(NativeFunction); PropIt; ++PropIt)
{
FProperty* Property = *PropIt;
if (!Property->HasAllPropertyFlags(CPF_OutParm))
{
continue;
}
FOutParmRec* Out = static_cast<FOutParmRec*>(UE_VSTACK_ALLOC(VirtualStackAllocator, sizeof(FOutParmRec)));
Out->PropAddr = Property->ContainerPtrToValuePtr<uint8>(Params);
Out->Property = Property;
if (*LastOut)
{
(*LastOut)->NextOutParm = Out;
LastOut = &(*LastOut)->NextOutParm;
}
else
{
*LastOut = Out;
}
}
if (*LastOut)
{
(*LastOut)->NextOutParm = nullptr;
}
NativeFunction->Invoke(NativeObject, NewStack, ReturnValueAddress);
}
bool UUObjectExporter::NativeIsValid(UObject* Object)
{
return IsValid(Object);
}
void* UUObjectExporter::GetWorld_Internal(UObject* Object)
{
if (!IsValid(Object))
{
return nullptr;
}
UWorld* World = Object->GetWorld();
return UCSManager::Get().FindManagedObject(World);
}
bool UUObjectExporter::IsA(const UObject* Object, UClass* Class)
{
return Object->IsA(Class);
}
uint32 UUObjectExporter::GetUniqueID(UObject* Object)
{
return Object->GetUniqueID();
}
void* UUObjectExporter::StaticLoadClass(UClass* BaseClass, UObject* InOuter, const char* Name)
{
if (Name == nullptr)
{
return nullptr;
}
UClass* Loaded = ::StaticLoadClass(BaseClass, InOuter, UTF8_TO_TCHAR(Name));
if (!IsValid(Loaded))
{
return nullptr;
}
return UCSManager::Get().FindManagedObject(Loaded);
}
void* UUObjectExporter::StaticLoadObject(UClass* BaseClass, UObject* InOuter, const char* Name)
{
if (Name == nullptr)
{
return nullptr;
}
UObject* LoadedObj = ::StaticLoadObject(BaseClass, InOuter, UTF8_TO_TCHAR(Name));
if (!IsValid(LoadedObj))
{
return nullptr;
}
return UCSManager::Get().FindManagedObject(LoadedObj);
}

View File

@ -0,0 +1,55 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "UObjectExporter.generated.h"
UCLASS()
class UNREALSHARPCORE_API UUObjectExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static void* CreateNewObject(UObject* Outer, UClass* Class, UObject* Template);
UNREALSHARP_FUNCTION()
static void* GetTransientPackage();
UNREALSHARP_FUNCTION()
static void NativeGetName(UObject* Object, FName* OutName);
UNREALSHARP_FUNCTION()
static void InvokeNativeFunction(UObject* NativeObject, UFunction* NativeFunction, uint8* Params, uint8* ReturnValueAddress);
UNREALSHARP_FUNCTION()
static void InvokeNativeStaticFunction(UClass* NativeClass, UFunction* NativeFunction, uint8* Params, uint8* ReturnValueAddress);
UNREALSHARP_FUNCTION()
static void InvokeNativeNetFunction(UObject* NativeObject, UFunction* NativeFunction, uint8* Params, uint8* ReturnValueAddress);
UNREALSHARP_FUNCTION()
static void InvokeNativeFunctionOutParms(UObject* NativeObject, UFunction* NativeFunction, uint8* Params, uint8* ReturnValueAddress);
UNREALSHARP_FUNCTION()
static bool NativeIsValid(UObject* Object);
UNREALSHARP_FUNCTION()
static void* GetWorld_Internal(UObject* Object);
UNREALSHARP_FUNCTION()
static bool IsA(const UObject* Object, UClass* Class);
UNREALSHARP_FUNCTION()
static uint32 GetUniqueID(UObject* Object);
UNREALSHARP_FUNCTION()
static void* StaticLoadClass(UClass* BaseClass, UObject* InOuter, const char* Name);
UNREALSHARP_FUNCTION()
static void* StaticLoadObject(UClass* BaseClass, UObject* InOuter, const char* Name);
};

View File

@ -0,0 +1,104 @@
#include "UScriptStructExporter.h"
#include "CSManager.h"
#include "TypeGenerator/CSScriptStruct.h"
int UUScriptStructExporter::GetNativeStructSize(const UScriptStruct* ScriptStruct)
{
if (const UScriptStruct::ICppStructOps* CppStructOps = ScriptStruct->GetCppStructOps(); CppStructOps != nullptr)
{
return CppStructOps->GetSize();
}
return ScriptStruct->GetStructureSize();
}
bool UUScriptStructExporter::NativeCopy(const UScriptStruct* ScriptStruct, void* Src, void* Dest)
{
if (UScriptStruct::ICppStructOps* CppStructOps = ScriptStruct->GetCppStructOps(); CppStructOps != nullptr)
{
if (CppStructOps->HasCopy())
{
return CppStructOps->Copy(Dest, Src, 1);
}
FMemory::Memcpy(Dest, Src, CppStructOps->GetSize());
return true;
}
return false;
}
bool UUScriptStructExporter::NativeDestroy(const UScriptStruct* ScriptStruct, void* Struct)
{
if (UScriptStruct::ICppStructOps* CppStructOps = ScriptStruct->GetCppStructOps(); CppStructOps != nullptr)
{
if (CppStructOps->HasDestructor())
{
CppStructOps->Destruct(Struct);
}
return true;
}
return false;
}
void UUScriptStructExporter::AllocateNativeStruct(FNativeStructData& Data, const UScriptStruct* ScriptStruct)
{
if (const int32 NativeSize = GetNativeStructSize(ScriptStruct); NativeSize <= sizeof(FNativeStructData))
{
ScriptStruct->InitializeStruct(std::addressof(Data.SmallStorage));
}
else
{
Data.LargeStorage = FMemory::Malloc(NativeSize);
ScriptStruct->InitializeStruct(Data.LargeStorage);
}
}
void UUScriptStructExporter::DeallocateNativeStruct(FNativeStructData& Data, const UScriptStruct* ScriptStruct)
{
if (const int32 NativeSize = GetNativeStructSize(ScriptStruct); NativeSize <= sizeof(FNativeStructData))
{
ScriptStruct->DestroyStruct(std::addressof(Data.SmallStorage));
}
else
{
ScriptStruct->DestroyStruct(Data.LargeStorage);
FMemory::Free(Data.LargeStorage);
}
}
void* UUScriptStructExporter::GetStructLocation(FNativeStructData& Data, const UScriptStruct* ScriptStruct)
{
if (const int32 NativeSize = GetNativeStructSize(ScriptStruct); NativeSize <= sizeof(FNativeStructData))
{
return std::addressof(Data.SmallStorage);
}
return Data.LargeStorage;
}
FGCHandleIntPtr UUScriptStructExporter::GetManagedStructType(UScriptStruct *ScriptStruct)
{
if (const UCSScriptStruct* CSStruct = Cast<UCSScriptStruct>(ScriptStruct); CSStruct != nullptr)
{
return CSStruct->GetManagedTypeInfo<FCSManagedTypeInfo>()->GetManagedTypeHandle()->GetHandle();
}
const UCSAssembly* Assembly = UCSManager::Get().FindOwningAssembly(ScriptStruct);
if (Assembly == nullptr)
{
return FGCHandleIntPtr();
}
const FCSFieldName FieldName(ScriptStruct);
const TSharedPtr<FCSManagedTypeInfo> Info = Assembly->FindTypeInfo<FCSManagedTypeInfo>(FieldName);
if (!Info.IsValid())
{
return FGCHandleIntPtr();
}
return Info->GetManagedTypeHandle()->GetHandle();
}

View File

@ -0,0 +1,42 @@
#pragma once
#include <array>
#include "CoreMinimal.h"
#include "CSBindsManager.h"
#include "CSManagedGCHandle.h"
#include "UScriptStructExporter.generated.h"
union FNativeStructData
{
std::array<std::byte, 64> SmallStorage;
void* LargeStorage;
};
UCLASS()
class UNREALSHARPCORE_API UUScriptStructExporter : public UObject
{
GENERATED_BODY()
public:
UNREALSHARP_FUNCTION()
static int GetNativeStructSize(const UScriptStruct* ScriptStruct);
UNREALSHARP_FUNCTION()
static bool NativeCopy(const UScriptStruct* ScriptStruct, void* Src, void* Dest);
UNREALSHARP_FUNCTION()
static bool NativeDestroy(const UScriptStruct* ScriptStruct, void* Struct);
UNREALSHARP_FUNCTION()
static void AllocateNativeStruct(FNativeStructData& Data, const UScriptStruct* ScriptStruct);
UNREALSHARP_FUNCTION()
static void DeallocateNativeStruct(FNativeStructData& Data, const UScriptStruct* ScriptStruct);
UNREALSHARP_FUNCTION()
static void* GetStructLocation(FNativeStructData& Data, const UScriptStruct* ScriptStruct);
UNREALSHARP_FUNCTION()
static FGCHandleIntPtr GetManagedStructType(UScriptStruct* ScriptStruct);
};

Some files were not shown because too many files have changed in this diff Show More