Hey guys,
Just wanted to let you know that I released the foundations of a plugin that I have been working on.
Here is the repo in case someone is interested:
https://github.com/jmgomez/NimForUE
Thanks,
Juan
Hi Juan,
This is excellent work! I'm really excited to give this a spin!
Just did a repo template with instructions for windows in case someone here wants to try it out: https://github.com/jmgomez/NimTemplate
A video tutorial and instructions for Mac are coming soon.
There is also a Discord channel for NimForUE in case someone wants to join and get frequent updates: https://discord.gg/smD8vZxzHh
Hey guys,
here is a video on getting started on Windows.
https://www.youtube.com/watch?v=NuB_PjxVisw&ab_channel=JuanMG%C3%B3mez
Hopefully the audio is better than the NimConf recording
Let me know if you try it out and have any issues!
Just uploaded another short video going over uClasses and Hot reloading basics:
https://www.youtube.com/watch?v=j6N6WGt2lO0
On the plugin major updates were:
Long story short, editor builds uses dynlibs so we can hot reload non editor builds outputs the cpp code directly
Virtual functions implemented
Sweet. (Un)fortunately you got it to work without a Nim compiler codegen patch. ;-)
How did you do it?
I initially thought on just replacing the vtable pointer but seems like the user needs to know the fn index upfront which it isn’t very ergonomic so I end up just generating a class and importing it (I was already generating a class because the struct vs class conflict, i.e. ue forward declares a class in the headers and then the compiler found the definition as a struct).
So for the example above, a header with this is generated a compile time
DLLEXPORT class ANimCharacter : public ACharacter {
public:
ANimCharacter() = default;
ANimCharacter(FVTableHelper& Helper) : ACharacter(Helper) {}
public:
virtual void SetupPlayerInputComponent( UInputComponent* playerInputComponent) override;
void SetupPlayerInputComponentSuper( UInputComponent* playerInputComponent) { ACharacter::SetupPlayerInputComponent(playerInputComponent); }
};
Notice two things:
1. The actual virtual function is forward declared only. Then on the actual Nim codegen this is emitted:
void ANimCharacter::SetupPlayerInputComponent( UInputComponent* playerInputComponent) {
setupPlayerInputComponent_impl(this , playerInputComponent);
}
setupPlayerInputComponent_impl is the actual Nim implementation
2. It defines a wrapper around the overridden function, so we can access outside of to the super implementation in case it the vfunc is private/protected. Then on the Nim side, in the scope of the function implementation a super function is available so you can call the parent if you want see in the post above ` super(self, playerInputComponent)`
Here another example from (https://github.com/jmgomez/NimForUE/blob/master/src/nimforue/examples/examplevirtualfunc.nim) with const
proc canEditChange(inProperty {. constcpp .} : FPropertyPtr) : bool {. constcpp .} =
UE_Log "CanEditChange called in the child updated 1"
self.super(inProperty)
which generates:
bool ANimBeginPlayOverrideActor::CanEditChange(const FProperty* inProperty) const {
return canEditChange_impl(const_cast<ANimBeginPlayOverrideActor*>(this) , const_cast<FProperty*>(inProperty));
}
The bulk of the code is in (https://github.com/jmgomez/NimForUE/blob/master/src/nimforue/codegen/gencppclass.nim) in case someone is interested, it isn’t too coupled to NimForUE.
Another update, I have been working on automatizing, and enabling, ships builds.
I also worked on what I think it is one of the coolest feature that the plugin will have: NimVM integration + hooks to any ue function without recompiling. The final aim is to being able to copy -> paste code from the VM into the regular Nim code.
Here is a short video you can skip the first minutes as I go a little bit about what's the plugin is a about, it's an entry for the "notGDF" conf/thing.
Update:
Did a rework on how the cpp is generated on the automatics bindings and on the DSL:
- Now multipleinheritance is supported on uClasses.
- Got rid of my prev implementation of virtual at the macro level since it's natively supported by Nim
- virtual automatically generates a super function available inside the body
uClass ANimCharacter of ACharacter implements IAbilitySystemInterface:
proc getAbilitySystemComponent(): UAbilitySystemComponentPtr {.virtual, constcpp, override.} =
self.abilitySystemComponent
https://twitter.com/_jmgomez_/status/1667109236491407360 (video)
I will be focusing on the VM for a bit now until I get to: