Kotlin/Native/cinterop pointer to custom class
I've been playing with Kotlin/Native and cinterop, and I found myself needing to have a pointer to my own class, something like this:
class Point(rawPtr: NativePtr) : CPointed(rawPtr) {
var x = 0
var y = 0
}
...
memScoped {
val testPtr = allocPointerTo()
testPtr.pointed?.x = 123
testPtr.pointed?.y = 321
}
But when I try to build it, it fails with:
Subclasses of kotlinx.cinterop.NativePointed cannot have properties with backing fields
Why is that the case? And is there any way to get around this limitation?