Kotlin: 1.6.10 and 1.6.20 MM enabled I have a cal...
# kotlin-native
j
Kotlin: 1.6.10 and 1.6.20 MM enabled I have a callback in c looking this:
int (*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)
This has since been resolved, turns out the library used did not really have pointed checks in place, and a
.reinterpret()
was needed for the calling method