Joakim Forslund
04/08/2022, 6:15 AMint (*messageClass)(struct UIElement *element, UIMessage message, int di /* data integer */, void *dp /* data pointer */);
I also have this c function:
UIElement *UIElementCreate(size_t bytes, UIElement *parent, uint32_t flags,
int (*messageClass)(UIElement *, UIMessage, int, void *), const char *cClassName);
That in kotlin interop becomes:
fun UIElementCreate(
bytes: size_t,
parent: CValuesRef<UIElement>?,
flags: uint32_t,
messageClass: CPointer<CFunction<(CPointer<UIElement>?, UIMessage, Int, COpaquePointer?) -> Int>>?, cClassName: kotlin.String?): CPointer<UIElement>? { }
I then try to call above method from kotlin with:
UIElementCreate(sizeOf<UIWindow>().toULong(),null,UI_ELEMENT_WINDOW,staticCFunction(::messageCallback),"Window")
fun messageCallback(element: CPointer<UIElement>?, message: UIMessage, di: Int, dp: COpaquePointer?): Int {
println("Inside weird ass callback")
return 0
}
This results in a crash, What am I doing wrong? As a side-note I also ran the staticCFunction as inline, had the same result (and the function is called just fine from pure c)Joakim Forslund
04/11/2022, 6:18 AM.reinterpret()
was needed for the calling method