Jeff Lockhart
09/21/2022, 1:26 AMCValuesRef<*>
)?
My API requires passing an arbitrary Kotlin lambda to a C library as a C function pointer. My understanding is that staticCFunction()
would not be able to capture the lambda to call inside it: staticCFunction { ~lambda()~ }
. I am able to have a context passed to the C Function as a COpaquePointer
though. I could have the lambda passed as this context parameter, if there would be a way to get a reference to it as a C pointer.msink
09/21/2022, 1:52 AMJeff Lockhart
09/21/2022, 2:22 AMJeff Lockhart
09/27/2022, 11:08 PMe: kotlinx.cinterop.staticCFunction must take an unbound, non-capturing function or lambda, but captures at: <this>
How is it you're avoiding this error? It would seem like you'd experience the same issue capturing this
for action
.Jeff Lockhart
09/27/2022, 11:11 PMthis
reference with ref.asCPointer()
, and that's what with(<http://ref.to|ref.to><Button>())
then resolves back to the kotlin instance?Jeff Lockhart
09/28/2022, 1:50 AMStableRef
is exactly what I need to get the C pointer reference I need.