Big Chungus
01/08/2020, 8:47 PMWe use the staticCFunction{..} helper function from Kotlin/Native to wrap a Kotlin lambda function into a C function pointer. It only allows having unbound and non-capturing lambda functions.
Could someone elaborate on what it means by unbound and non-capturing lambda functions
. Does it mean that for instance if you want to register callbacks from c they cannot be in a kotlin class, but rather only top-level function?Kris Wong
01/08/2020, 8:50 PMBig Chungus
01/08/2020, 8:58 PMBig Chungus
01/08/2020, 9:02 PM/** Function to be run when the user makes a change to the TextField.
* Only one function can be registered at a time. */
fun action(block: TextField.() -> Unit) {
action = block
uiEntryOnChanged(ptr, staticCFunction { _, ref ->
with(<http://ref.to|ref.to><TextField>()) {
action?.invoke(this)
}
}, ref.asCPointer())
}
internal var action: (TextField.() -> Unit)? = null
Can you explain why the compiler does not complain that action is outside the function?Kris Wong
01/08/2020, 9:02 PMBig Chungus
01/08/2020, 9:16 PMCOpaquePointer
as:
<http://ref.to|ref.to><TextField>()
Big Chungus
01/08/2020, 9:19 PMref.asStableRef<TextField>().get()