How do you map in Nim a function with this signature:
void FunctionName(UObject* Context, FFrame& Stack, void*const Result) {..}
And then cast the type so it can be accepted as one argument only of FNativeFuncPtr which comes defined as:
typedef void (*FNativeFuncPtr)(UObject* Context, FFrame& TheStack, RESULT_DECL);
So I can create a Function in nim like so
proc SetNativeFunc*(ufunc: UFunction, funcPtr: FNativeFuncPtr) : void {.importcpp: "#->SetNativeFunc(#)", header: "UObject/Class.h" .}
proc NimFunctionToReplace*(context:ptr UObject, stack:ptr FFrame, result:ptr void) = ....
SetNativeFunc(NimFunctionToReplace)
Thanks,
Juan
Got it working until here
cannot convert argument 1 from 'void (__cdecl *)(UObject *,FFrame *,void *)' to 'void (__cdecl *)(UObject *,FFrame &,void *)'
I imported it like that:
type FFrame* {.importcpp: "FFrame", inheritable, pure, byref, header: "UObject/Stack.h".} = object
Code : ptr uint8
proc MakeFNativeFuncPtr*(fun:proc (context:ptr UObject, stack: FFrame, result: pointer):void {. cdecl .}) : FNativeFuncPtr {.importcpp: "UReflectionHelpers::MakeFNativeFuncPtr(@)", header: "NimObjectBindTest.h" .}
This is the Cpp definition:
static FNativeFuncPtr MakeFNativeFuncPtr(void (FnPtr)(UObject* Context, FFrame& TheStack, void* Result));
If I change the ref in Cpp I can do a reinterpret_cast but I got a crash and not sure if it's because of it or something else. Is there a way to tell nim to export an argument as a C++ ref (&)? Any direction will be appreciated. Thanks, Juan