hmole
06/10/2020, 10:40 PM@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 NDKhmole
06/11/2020, 2:03 PMyigit
06/11/2020, 8:21 PMhmole
06/11/2020, 8:46 PMsqlite.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++.hmole
06/11/2020, 10:15 PM.c
files without autocompletion I guess...
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)
}