Vadim
07/26/2021, 11:01 PMerror
variable on the Kotlin side to call this C function?
int analyze(char **error);
Vadim
07/26/2021, 11:02 PMactual class Analysis {
actual fun perform(): Int {
val errorPointer = ???
// type of `error` parameter is decompiled as `CValuesRef<CPointerVar<ByteVar>>?`
val result = analyze(errorPointer)
return result
}
}
hfhbd
07/26/2021, 11:08 PMfun <R> withErrorPointer(block: (CPointer<ObjCObjectVar<NSError?>>) -> R): Result<R> = memScoped {
val errorPointer: ObjCObjectVar<NSError?> = alloc()
val pointer = errorPointer.ptr
val result = block(pointer)
val error = pointer.pointed.value
return if (error != null) {
Result.failure(CoreDataError(error))
} else {
Result.success(result)
}
}