feat(test): add real UE 5.8 RunLuaTests commandlet, Lua.RunTests command, and fix UnLua .d.ts math/UObject bugs

This commit is contained in:
szy73711 committed 2026-11-29 15:05:35 +08:00
1 parent 3dd61c32a9
commit 96e3f0d009
29 files changed
+1417 -134

No files matched your search

@@ -425,3 +425,5 @@ void FUnLuaIntelliSenseGenerator::OnAssetUpdated(const FAssetData& AssetData)
Export(Blueprint);
}
#undef LOCTEXT_NAMESPACE
@@ -1064,7 +1064,10 @@ namespace UnLuaTypeScriptGenInternal
*DataTableType));
}
AddStatic(TEXT("StaticClass"), TEXT("static StaticClass(this: void): UClass;"));
if (TypeName != TEXT("UObject") && TypeName != TEXT("UClass"))
{
AddStatic(TEXT("StaticClass"), TEXT("static StaticClass(this: void): UClass;"));
}
}
/**
@@ -1089,14 +1092,15 @@ namespace UnLuaTypeScriptGenInternal
}
};
// Note: In UnLua LuaLib_Math.h, Add/Sub/Mul/Div use bAssignment=true (mutate self in-place and return 0 values / void).
if (TypeName == TEXT("FVector"))
{
AddMethod(TEXT("Set"), TEXT("Set(X?: number, Y?: number, Z?: number): void;"));
AddMethod(TEXT("Normalize"), TEXT("Normalize(Tolerance?: number): boolean;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FVector | number): FVector;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FVector | number): FVector;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FVector | number): FVector;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FVector | number): FVector;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FVector | number): void;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FVector | number): void;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FVector | number): void;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FVector | number): void;"));
PostDecls += TEXT(" function FVector(this: void): FVector;\n");
PostDecls += TEXT(" function FVector(this: void, XYZ: number): FVector;\n");
PostDecls += TEXT(" function FVector(this: void, X: number, Y: number, Z: number): FVector;\n");
@@ -1106,10 +1110,10 @@ namespace UnLuaTypeScriptGenInternal
AddMethod(TEXT("Set"), TEXT("Set(X?: number, Y?: number): void;"));
AddMethod(TEXT("Normalize"), TEXT("Normalize(Tolerance?: number): void;"));
AddMethod(TEXT("IsNormalized"), TEXT("IsNormalized(): boolean;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FVector2D | number): FVector2D;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FVector2D | number): FVector2D;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FVector2D | number): FVector2D;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FVector2D | number): FVector2D;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FVector2D | number): void;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FVector2D | number): void;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FVector2D | number): void;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FVector2D | number): void;"));
PostDecls += TEXT(" function FVector2D(this: void): FVector2D;\n");
PostDecls += TEXT(" function FVector2D(this: void, XY: number): FVector2D;\n");
PostDecls += TEXT(" function FVector2D(this: void, X: number, Y: number): FVector2D;\n");
@@ -1117,10 +1121,10 @@ namespace UnLuaTypeScriptGenInternal
else if (TypeName == TEXT("FVector4"))
{
AddMethod(TEXT("Set"), TEXT("Set(X?: number, Y?: number, Z?: number, W?: number): void;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FVector4 | number): FVector4;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FVector4 | number): FVector4;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FVector4 | number): FVector4;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FVector4 | number): FVector4;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FVector4 | number): void;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FVector4 | number): void;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FVector4 | number): void;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FVector4 | number): void;"));
PostDecls += TEXT(" function FVector4(this: void, X?: number, Y?: number, Z?: number, W?: number): FVector4;\n");
}
else if (TypeName == TEXT("FRotator"))
@@ -1130,9 +1134,9 @@ namespace UnLuaTypeScriptGenInternal
AddMethod(TEXT("GetRightVector"), TEXT("GetRightVector(Out?: FVector): FVector;"));
AddMethod(TEXT("GetUpVector"), TEXT("GetUpVector(Out?: FVector): FVector;"));
AddMethod(TEXT("GetUnitAxis"), FString::Printf(TEXT("GetUnitAxis(Axis: %s, Out?: FVector): FVector;"), *AxisType));
AddMethod(TEXT("Add"), TEXT("Add(other: FRotator): FRotator;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FRotator): FRotator;"));
AddMethod(TEXT("Mul"), TEXT("Mul(scale: number): FRotator;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FRotator): void;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FRotator): void;"));
AddMethod(TEXT("Mul"), TEXT("Mul(scale: number): void;"));
PostDecls += TEXT(" function FRotator(this: void): FRotator;\n");
PostDecls += TEXT(" function FRotator(this: void, F: number): FRotator;\n");
PostDecls += TEXT(" function FRotator(this: void, Pitch: number, Yaw: number, Roll: number): FRotator;\n");
@@ -1140,10 +1144,10 @@ namespace UnLuaTypeScriptGenInternal
else if (TypeName == TEXT("FLinearColor"))
{
AddMethod(TEXT("Set"), TEXT("Set(R?: number, G?: number, B?: number, A?: number): void;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FLinearColor): FLinearColor;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FLinearColor): FLinearColor;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FLinearColor | number): FLinearColor;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FLinearColor | number): FLinearColor;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FLinearColor): void;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FLinearColor): void;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FLinearColor | number): void;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FLinearColor | number): void;"));
PostDecls += TEXT(" function FLinearColor(this: void): FLinearColor;\n");
PostDecls += TEXT(" function FLinearColor(this: void, R: number, G: number, B: number, A?: number): FLinearColor;\n");
}
@@ -1160,7 +1164,7 @@ namespace UnLuaTypeScriptGenInternal
AddMethod(TEXT("Set"), TEXT("Set(X?: number, Y?: number, Z?: number, W?: number): void;"));
AddMethod(TEXT("Normalize"), TEXT("Normalize(Tolerance?: number): void;"));
AddMethod(TEXT("GetNormalized"), TEXT("GetNormalized(Tolerance?: number): FQuat;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FQuat | number): FQuat;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FQuat | number): void;"));
AddStaticMethod(TEXT("FromAxisAndAngle"), TEXT("function FromAxisAndAngle(this: void, Axis: FVector, Angle: number, Out?: FQuat): FQuat;"));
PostDecls += TEXT(" function FQuat(this: void): FQuat;\n");
PostDecls += TEXT(" function FQuat(this: void, X: number, Y: number, Z: number, W: number): FQuat;\n");
@@ -1169,16 +1173,16 @@ namespace UnLuaTypeScriptGenInternal
{
AddMethod(TEXT("Blend"), TEXT("Blend(B: FTransform, C: FTransform, Alpha: number): void;"));
AddMethod(TEXT("BlendWith"), TEXT("BlendWith(B: FTransform, Alpha: number): void;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FTransform | number): FTransform;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FTransform | number): void;"));
PostDecls += TEXT(" function FTransform(this: void, Rotation?: FQuat, Translation?: FVector, Scale3D?: FVector): FTransform;\n");
}
else if (TypeName == TEXT("FIntPoint"))
{
AddMethod(TEXT("Set"), TEXT("Set(X?: number, Y?: number): void;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FIntPoint | number): FIntPoint;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FIntPoint | number): FIntPoint;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FIntPoint | number): FIntPoint;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FIntPoint | number): FIntPoint;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FIntPoint | number): void;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FIntPoint | number): void;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FIntPoint | number): void;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FIntPoint | number): void;"));
PostDecls += TEXT(" function FIntPoint(this: void): FIntPoint;\n");
PostDecls += TEXT(" function FIntPoint(this: void, XY: number): FIntPoint;\n");
PostDecls += TEXT(" function FIntPoint(this: void, X: number, Y: number): FIntPoint;\n");
@@ -1187,10 +1191,10 @@ namespace UnLuaTypeScriptGenInternal
{
AddMethod(TEXT("Set"), TEXT("Set(X?: number, Y?: number, Z?: number): void;"));
AddMethod(TEXT("SizeSquared"), TEXT("SizeSquared(): number;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FIntVector | number): FIntVector;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FIntVector | number): FIntVector;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FIntVector | number): FIntVector;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FIntVector | number): FIntVector;"));
AddMethod(TEXT("Add"), TEXT("Add(other: FIntVector | number): void;"));
AddMethod(TEXT("Sub"), TEXT("Sub(other: FIntVector | number): void;"));
AddMethod(TEXT("Mul"), TEXT("Mul(other: FIntVector | number): void;"));
AddMethod(TEXT("Div"), TEXT("Div(other: FIntVector | number): void;"));
PostDecls += TEXT(" function FIntVector(this: void): FIntVector;\n");
PostDecls += TEXT(" function FIntVector(this: void, XYZ: number): FIntVector;\n");
PostDecls += TEXT(" function FIntVector(this: void, X: number, Y: number, Z: number): FIntVector;\n");