I’ve got C library converted with cinterop to be used with kotlin/native. It’s a GUI libraru and based on concept of callbacks.
In C I set callback using special function SetCallback passing reference to my callback function using
following type construction: (Icallback)exit_cb, where exit_cb function was defuned as int exit_cb(void).
While working in kotlin/native I can’t find the way how I could use same concept:
Icallback defined as:
typealias Icallback = CPointer<CFunction<(CPointer< Ihandle >?) -> Int >>
typealias Ihandle = Ihandle _
and for Ihandle_
Now coming back to my callback function. In C it was simple function returing type int value and getting
no parameters. But how I could use similar concept of type conversion i.e. (Icallback)exit_cb in C ?
I trien to force setting return type of my exit_cb() function definition in kotlin to Icallback? - but then I stuck how to convert integer return value to Icallback…
I am new to kotlin and would appreciate if you could guide me in right direction.