jmgomez / NimForUE

Nim plugin for UE5 with native performance, hot reloading and full interop that sits between C++ and Blueprints. This allows you to do common UE workflows like for example to extend any UE class in Nim and extending it again in Blueprint if you wish so without restarting the editor. The final aim is to be able to do in Nim what you can do in C++
MIT License
491 stars 30 forks source link

Unable to generate bindings/reflection data #23

Closed gushromp closed 1 year ago

gushromp commented 1 year ago

EDIT: Ok the second part seems to be some sort of a regression in current Nim-Devel writeFile. The file does get written out even with the index not in range exception. :) So just the first part of this issue is relevant.


Two issues I've found (current devel):

1) IsRunningCommandlet as defined in this commit

is always false, so genBindingsEntryPoint() doesn't do anything. I've changed it to

proc isRunningCommandlet*() : bool {.importcpp:"IsRunningCommandlet" .}

and all the relevant call sites and seems to work as expected.

2) generateProject() fails with the following error:

[2023.07.06-08.48.21:196][  1]NimForUEBindings: [genreflectiondatav2.nim:596]: All module names@["NimTemplate", "NimForUE", "NimForUEBindings", "NimForUETest", "NimForUEEditor", "ModelingToolsEditorMode", "Engine/Exporters", "Engine/EdGraph", "Engine/Atmosphere", "Engine/Sound", "Engine/AI", "Engine/Kismet", "Engine/Camera", "Engine/GameFramework", "Engine/Components", "Engine/Animation", "Engine/VT", "Engine/Elements", "Engine/Slate", "Engine/Instances", "Engine/ISMPartition", "Engine/SparseVolumeTexture", "Engine/Engine", "Engine/Materials", "Engine/Net", "Engine/Enums", "Engine/DataDrivenCVars", "Engine/Particles", "Engine/PhysicsEngine", "Engine/Haptics", "Engine/ActorPartition", "Engine/Delegates", "Engine/Commandlets", "Engine/PhysicalMaterials", "Engine/Lightmass", "Engine/EditorFramework", "Engine/Physics", "Engine/Distributions", "Engine/Curves", "Engine/WorldPartition", "Engine/VectorField", "Slate", "SlateCore", "PhysicsCore", "Chaos", "InputCore", "UMG/Slate", "UMG/FieldNotification", "UMG/UMG", "UMG/Components", "UMG/Animation", "UMG/Delegates", "UMG/Enums", "UMG/Blueprint", "GameplayAbilities/GameplayAbilities", "GameplayAbilities/Serialization", "GameplayAbilities/Abilities", "GameplayAbilities/Delegates", "GameplayAbilities/Enums", "GameplayAbilities/Sequencer", "EnhancedInput", "AssetRegistry", "Engine/Common"]
[2023.07.06-08.48.21:442][  1]NimForUEBindings: Error: [ffinimforue.nim:66]: Error in genBindingsEntryPoint: index -1 not in 0 .. 88
[2023.07.06-08.48.24:449][  1]LogCore: Engine exit requested (reason: Commandlet GenerateBindingsCommandlet_0 finished execution (result 0))
[2023.07.06-08.48.24:450][  1]LogInit: Display: 
[2023.07.06-08.48.24:450][  1]LogInit: Display: Warning/Error Summary (Unique only)
[2023.07.06-08.48.24:450][  1]LogInit: Display: -----------------------------------
[2023.07.06-08.48.24:450][  1]LogInit: Display: NimForUEBindings: Error: [genreflectiondatav2.nim:473]: CodeGenOnlyUEImportRule(affectedTypes: @["AActor", "AInfo", "UReflectionHelpers", "UObject", "UEngine", "APawn", "UField", "UStruct", "UScriptStruct", "UPackage", "UPackageMap", "UClass", "UFunction", "UDelegateFunction", "UEnum", "AVolume", "UInterface", "UActorComponent", "AController", "AGameMode", "AGameModeBase", "UBlueprint", "UBlueprintGeneratedClass", "APlayerController", "UAnimBlueprintGeneratedClass", "UEngineSubsystem", "USubsystem", "UDynamicSubsystem", "UWorldSubsystem", "USceneComponent", "UPrimitiveComponent", "UWorld", "UInputComponent", "UEnhancedInputComponent", "UInputAction", "UPlayerInput", "UEnhancedPlayerInput", "UPhysicalMaterial", "UTickableWorldSubsystem", "UGameViewportClient", "UNavigationSystemConfig", "UNavigationSystemModuleConfig", "UFunctionCaller", "FNativeFuncPtr", "UNimScriptStruct", "UNimScriptStructPtr", "UNimEnum", "UNimEnumPtr", "UNimFunction", "UNimFunctionPtr", "UReflectionHelpers", "UReflectionHelpersPtr", "FNimTestBase", "FNimHotReload", "FNimHotReloadPtr", "FField", "FFieldPtr", "FProperty", "FPropertyPtr", "FFieldClass", "FFieldClassPtr", "FFieldPath", "UObject", "UObjectPtr", "UField", "UFieldPtr", "UEnum", "UEnumPtr", "UStruct", "UStructPtr", "FObjectInitializer", "FReferenceCollector", "UClassConstructor", "VTableConstructor", "FOutParmRec", "FFrame", "UClassAddReferencedObjectsType", "UFunctionNativeSignature", "FImplementedInterface", "FUObjectCppClassStaticFunctions", "UClass", "UClassPtr", "UInterface", "UInterfacePtr", "UScriptStruct", "UScriptStructPtr", "ICppStructOps", "ICppStructOpsPtr", "UFunction", "UFunctionPtr", "UDelegateFunction", "UDelegateFunctionPtr", "TObjectPtr", "TLazyObjectPtr", "TEnumAsByte", "TWeakObjectPtr", "TScriptInterface", "UWorld", "UWorldPtr", "ConstructorHelpers", "FObjectFinder", "FClassFinder", "TSubclassOf", "TFieldPath", "FVTableHelper", "FPropertyChangedEvent", "FPropertyChangedChainEvent", "FObjectPostSaveRootContext", "FScriptArray", "FScriptArrayHelper", "FScriptMap", "FScriptMapHelper", "FScriptMapLayout", "FFieldVariant", "DelegateProp", "ERenameFlag", "TFieldIterator", "FRawObjectIterator", "ScriptContainer", "FAssetBundleData", "FAssetBundleEntry", "FSoftObjectPath", "FAssetData", "FAutomationEvent", "FGuid", "EAutomationEventType", "FAutomationExecutionEntry", "FDateTime", "FBox", "FBox2D", "FVector2D", "FBox2f", "FVector2f", "FBox3d", "FVector3d", "FBox3f", "FVector3f", "FBoxSphereBounds", "FBoxSphereBounds3d", "FBoxSphereBounds3f", "FColor", "FDirectoryPath", "FFallbackStruct", "FFilePath", "FFloatInterval", "FFloatRange", "FFloatRangeBound", "ERangeBoundTypes", "FFrameNumber", "FFrameNumberRange", "FFrameNumberRangeBound", "FFrameRate", "FFrameTime", "FInt32Interval", "FInt32Range", "FInt32RangeBound", "FInterpCurveFloat", "FInterpCurvePointFloat", "EInterpCurveMode", "FInterpCurveLinearColor", "FInterpCurvePointLinearColor", "FLinearColor", "FInterpCurvePointQuat", "FQuat", "FInterpCurvePointTwoVectors", "FTwoVectors", "FInterpCurvePointVector", "FInterpCurvePointVector2D", "FInterpCurveQuat", "FInterpCurveTwoVectors", "FInterpCurveVector", "FInterpCurveVector2D", "FIntPoint", "FIntVector", "FMatrix", "FPlane", "FMatrix44d", "FPlane4d", "FMatrix44f", "FPlane4f", "FOrientedBox", "FPackedNormal", "FPackedRGB10A2N", "FPackedRGBA16N", "FPolyglotTextData", "ELocalizedTextSourceCategory", "FPrimaryAssetId", "FPrimaryAssetType", "FQualifiedFrameTime", "FQuat4d", "FQuat4f", "FRandomStream", "FRotator", "FRotator3d", "FRotator3f", "FSoftClassPath", "FTestUninitializedScriptStructMembersTest", "FTimecode", "FTimespan", "FTransform", "FTransform3d", "FTransform3f", "FVector4", "FVector4d", "FVector4f", "ELifetimeCondition", "ELifetimeRepNotifyCondition", "ESearchCase", "ESearchDir", "ELogTimes", "EAxis", "EPixelFormat", "EMouseCursor", "EUnit", "EPropertyAccessChangeNotifyMode", "EAppReturnType", "EAppMsgType", "EDataValidationResult", "UPackage", "UPackagePtr", "TSoftObjectPtr", "TSoftClassPtr", "FName", "EName", "FMulticastScriptDelegate", "FScriptDelegate", "FStaticConstructObjectParameters", "UMetadata", "UMetadataPtr", "TChar", "FString", "TArray", "TPair", "TMap", "TSet", "ELogVerbosity", "FVector", "FVector_NetQuantize", "FVector_NetQuantizeNormal", "FVector_NetQuantize100", "FVector_NetQuantize10", "FText", "FWeakObjectPtr", "FDelegateHandle", "FDelegateHandlePtr", "TMulticastDelegateOneParam", "TDelegateRetOneParam", "IAssetRegistry", "UEngine", "UEnginePtr", "USubsystem", "USubsystemPtr", "UDynamicSubsystem", "UDynamicSubsystemPtr", "UEngineSubsystem", "UEngineSubsystemPtr", "FTickFunction", "FActorTickFunction", "AActor", "AActorPtr", "AController", "AControllerPtr", "APlayerController", "APlayerControllerPtr", "APawn", "APawnPtr", "AInfo", "AInfoPtr", "AGameModeBase", "AGameModeBasePtr", "AGameMode", "AGameModePtr", "UActorComponent", "UActorComponentPtr", "USceneComponent", "USceneComponentPtr", "UPrimitiveComponent", "UPrimitiveComponentPtr", "UBlueprint", "UBlueprintPtr", "UBlueprintGeneratedClass", "UBlueprintGeneratedClassPtr", "UAnimBlueprintGeneratedClass", "UAnimBlueprintGeneratedClassPtr", "UAsyncActionLoadPrimaryAssetBase", "UAsyncActionLoadPrimaryAssetBasePtr", "ASceneCapture", "ASceneCapturePtr", "AVolume", "AVolumePtr", "UWorldSubsystem", "UWorldSubsystemPtr", "UTickableWorldSubsystem", "UTickableWorldSubsystemPtr", "FWorldContext", "FWorldContextPtr", "FHitResult", "FLifetimeProperty", "FGameplayTag", "UPackageMap", "UPackageMapPtr", "FKey", "FPlatformUserId", "FTopLevelAssetPath", "FARFilter", "EInputDeviceConnectionState", "FTableRowBase", "FObjectPreSaveContext", "FViewport", "FViewportPtr", "UGameViewportClient", "UGameViewportClientPtr", "FActorInstanceHandle", "UPhysicalMaterial", "UPhysicalMaterialPtr", "UMaterialInterface", "UMaterialInterfacePtr", "UUserDefinedStruct", "UUserDefinedStructPtr", "UNavigationSystemModuleConfig", "UNavigationSystemModuleConfigPtr", "UNavigationSystemConfig", "UNavigationSystemConfigPtr", "FSlateBrush", "EGetWorldErrorMode", "ETriggerEvent", "UInputComponent", "UInputComponentPtr", "UEnhancedInputComponent", "UEnhancedInputComponentPtr", "UInputAction", "UInputActionPtr", "UPlayerInput", "UPlayerInputPtr", "UEnhancedPlayerInput", "UEnhancedPlayerInputPtr", "FEnhancedInputActionEventBinding", "FInputActionValue", "FKeyEvent", "FkeyEventPtr", "FInputKeyEventArgs", "FInputKeyEventArgsPtr", "FInputDeviceId", "EInputEvent", "FOnInputKeySignature", "OnInputKeyEventPressedNimSignature", "OnKeyPressedNimSignature", "EAxisList", "ECollisionChannel", "EObjectTypeQuery", "ETraceTypeQuery", "FActorSpawnParameters", "Criteria", "SomePointer", "SomeTable", "EPropertyFlags", "EObjectFlagsVal", "EObjectFlags", "EFunctionFlags", "EClassFlags", "EClassCastFlags", "EStructFlags", "EFieldIterationFlags"], target: uertType.UERuleTarget, rule: uerCodeGenOnlyFields)
[2023.07.06-08.48.24:450][  1]LogInit: Display: NimForUEBindings: Error: [ffinimforue.nim:66]: Error in genBindingsEntryPoint: index -1 not in 0 .. 88

I've added a bunch of logging to pinpoint the error and it seems to be this piece of code:

writeFile(config.reflectionDataFilePath, codeTemplate % [ueProjectAsStr])

or, rather, more specifically, the string interpolation part: codeTemplate % [ueProjectAsStr].

I could paste the contents of ueProjectAsStr (in a Gist since it is huge) if that would be helpful.

Additional info: Unreal Engine 5.2.1

jmgomez commented 1 year ago

@gushromp thanks. This was a regression that I introduced yesterday. Will try to stabilize the template so newcomers can start there and dont suffer that many regressions. Next time send a PR :)