Trying to use cinterop and most of the generated ...
# kotlin-native
h
Trying to use cinterop and most of the generated bindings come out with
@Deprecated("Unable to import this declaration"
. Is there any way to generate "unsafe" bindings or something like that? The header in question is
sqlite3ext.h
and targets are Android NDK
y
h
In your
sqlite.def
you are using
sqlite3.h
, it works for me also. I'm talking about
sqlite3ext.h
, which is used for creating SQLite3 dynamic loadable extensions. It does some wierd redefenitions, which I'm not able to make sense of, because I have almose no experience with C/C++.
Got it working. Better that writing
.c
files without autocompletion I guess...
Copy code
import kotlinx.cinterop.*
import kotlinx.cinterop.invoke
import platform.android.ANDROID_LOG_ERROR
import platform.android.__android_log_print
import sqlite3.*

/**SQLITE_EXTENSION_INIT1*/
private lateinit var sqlite3: sqlite3_api_routines

private fun custom_testt(context: CPointer<sqlite3_context>, argc: Int, argv: CPointer<CPointerVar<sqlite3_value>>) {
  memScoped {
    sqlite3.result_text!!(context, "Hello World!".cstr.ptr, -1, SQLITE_TRANSIENT)
  }
}

@CName("sqlite3_customtestt_init")
fun init(
  db: CPointer<sqlite3>,
  pzErrMsg: CPointer<CPointerVar<ByteVar>>,
  pApi: CPointer<sqlite3_api_routines>
): Int = memScoped {

  /**SQLITE_EXTENSION_INIT2(pApi)*/
  sqlite3 = pApi.pointed

  __android_log_print(ANDROID_LOG_ERROR.toInt(), "sqlite", "loading extension")

  return sqlite3.create_function!!(db, "custom_testt".cstr.ptr, 0, SQLITE_UTF8, null, staticCFunction(::custom_testt).reinterpret(), null, null)
}