vbsteven
04/22/2023, 3:07 PMKClass<SomeLibraryType>
? It looks like the companion objects are only initialized lazily when the first instance of that class is created.
For a custom typesystem in K/N I need to access the companion object of a given KClass<SomeLibraryType>
received through an inline reified fun so I can lookup some type information and casting functions.RyuNen344
04/23/2023, 1:50 AMgenerated interop symbol
@ExternalObjCClass public open class SomeObjCClass : NSObject {
@ObjCConstructor public constructor(arg: String, error: CPointer<ObjCObjectVar<NSError?>>?) { /* compiled code */ }
@ObjCConstructor public constructor() { /* compiled code */ }
@Deprecated @ObjCMethod @ConsumesReceiver @ReturnsRetained public open external fun init(): SomeObjCClass? { /* compiled code */ }
@Deprecated @ObjCMethod @ConsumesReceiver @ReturnsRetained public open external fun initArg(arg: String, error: CPointer<ObjCObjectVar<NSError?>>?): SomeObjCClass? { /* compiled code */ }
}
objc header
@interface SomeObjCClass : NSObject
- (instancetype)init NS_UNAVAILABLE;
- (nullable instancetype)initWithArg:(NSString *)arg error:(NSError **)error;
@end
Kolby Kunz
04/24/2023, 6:49 PMUndefined symbols for architecture x86_64 '_askar_version', referenced from _askar_askar_version_wrapper76 in result.o ld symbol(s) not found for archutecture x86_64
From what I understand the linker cannot find the definitions for the package for the target platform and is most likely looking in the standard include folders throughout the system but because it is a custom package they are not located there. Any advice on how to fix this would be greatly appreciated or if this is even something supported by cinterop.Reece H. Dunn
04/25/2023, 7:55 AMlinuxX64
, macosX64
, and mingwX64
figured out, and have a konan-target
and associated os
matrix parameter for those. Note: I just need the GitHub Action script settings, I know how to pass that to the build script.vbsteven
04/25/2023, 8:14 PMMAIN
dispatcher for kotlinx.coroutines on Kotlin Native?Kolby Kunz
04/26/2023, 8:03 PMAdam S
04/27/2023, 6:07 PMstaticCFunction()
to pass in a custom callback, but the callback requires some boilerplate to handle the C types. Is it possible to ‘wrap’ this callback with one of my own, without breaking the ‘no references’ rule for staticCFunction()
?
What I want is something like this, but this fails because “kotlinx.cinterop.staticCFunction must take an unbound, non-capturing function or lambda, but captures at (…) callback”
fun main() {
attachAudioMixedProcessor { samples, frames ->
for (frame in 0 until frames.convert()) {
val left = samples[frame * 2 + 0]
val right = samples[frame * 2 + 1]
// ...
}
}
}
fun attachAudioMixedProcessor(
callback: (samples: CPointer<FloatVar>, frames: Int) -> Unit
) {
// call the c-interop function
AttachAudioMixedProcessor(staticCFunction { buffer: COpaquePointer?, frames: UInt ->
val samples: CPointer<FloatVar> = buffer?.reinterpret() ?: return@staticCFunction
callback(samples, frames.toInt())
})
}
// generated C interop function
external fun AttachAudioMixedProcessor(processor: CPointer<CFunction<(COpaquePointer?, UInt) -> Unit>>?)
Shantanu Jaiswal
04/29/2023, 4:19 PMnatario1
05/01/2023, 11:18 AMexternal.so
shared library
• A base
kotlin module with cinterop bindings to baseHeader.h
(external.so)
• A derived
kotlin module with cinterop bindings to derivedHeader.h
(external.so). This module depends on the base
module.
What happens is that derived:commonizeCInterop
fails:
Unresolved classifier: some/symbol/from/baseHeader.h
zt
05/02/2023, 2:57 AMkatokay
05/03/2023, 10:21 PMimport kotlinx.cinterop.*
import lmdb.*
actual class Env : AutoCloseable {
private val envPtr: CPointerVar<MDB_env> = memScoped { allocPointerTo() }
internal val ptr: CPointer<MDB_env>
init {
check(mdb_env_create(envPtr.ptr))
ptr = envPtr.value!!
}
private var isOpened = false
actual var maxDatabases: UInt = 0u
set(value) {
check(mdb_env_set_maxdbs(ptr, value))
field = value
}
actual var mapSize: ULong = 1024UL * 1024UL * 50UL
set(value) {
check(mdb_env_set_mapsize(ptr, value))
field = value
}
actual var maxReaders: UInt = 0u
set(value) {
check(mdb_env_set_maxreaders(ptr, value))
field = value
}
actual val stat: Stat?
get() {
val statPtr: CValue<MDB_stat> = cValue<MDB_stat>()
check(mdb_env_stat(ptr, statPtr))
val pointed = memScoped {
statPtr.ptr.pointed
}
return Stat(
pointed.ms_branch_pages, pointed.ms_depth, pointed.ms_entries, pointed.ms_leaf_pages,
pointed.ms_overflow_pages, pointed.ms_psize
)
}
actual val info: EnvInfo?
get() {
val envInfo: CValue<MDB_envinfo> = cValue<MDB_envinfo>()
check(mdb_env_info(ptr, envInfo))
val pointed = memScoped {
envInfo.ptr.pointed
}
return EnvInfo(pointed.me_last_pgno, pointed.me_last_txnid,
pointed.me_mapaddr.toLong().toULong(), pointed.me_mapsize, pointed.me_maxreaders, pointed.me_numreaders)
}
actual fun open(path: String, vararg options: EnvOption, mode: UShort) {
check(mdb_env_open(ptr, path, options.asIterable().toFlags(), mode))
isOpened = true
}
actual fun beginTxn(vararg options: TxnOption) : Txn {
return Txn(this, *options)
}
actual fun copyTo(path: String, compact: Boolean) {
val flags = if (compact) {
0x01u
} else {
0u
}
check(mdb_env_copy2(ptr, path, flags))
}
actual fun sync(force: Boolean) {
val forceInt = if(force) 1 else 0
check(mdb_env_sync(ptr, forceInt))
}
actual override fun close() {
if (!isOpened)
return
mdb_env_close(ptr)
}
}
Tianyu Zhu
05/03/2023, 11:13 PMAdam S
05/05/2023, 12:36 PMJPC_BodyInterface_CreateBody
JPC_Body *floor = JPC_BodyInterface_CreateBody(body_interface, &floor_settings);
my Kotlin code is in the thread 🧵
I guess it’s a problem with passing in the floor_settings
pointer? Or maybe body_interface
isn’t stable? Do I need to pin it?Charlie Tapping
05/05/2023, 2:01 PMAdam Brown
05/05/2023, 11:16 PMmohamed rejeb
05/06/2023, 5:50 PMkotlinx.cinterop.staticCFunction must take an unbound, non-capturing function or lambda, but captures at:
Also using sel_registerName
the crashes when I click the button
button.addTarget(
target = _this_,
action = sel_registerName("action"),
forControlEvents = UIControlEventTouchUpInside
)
Charlie Tapping
05/07/2023, 6:27 PMhfhbd
05/09/2023, 2:11 PMkatokay
05/09/2023, 3:24 PMlouiscad
05/09/2023, 3:41 PMframe
property from UIView
in iOS is exposed as a val
, and not as a var
like in Swift and Objective-C?
This is a big blocker for something I want to achieve 😕Charlie Tapping
05/09/2023, 4:29 PMSrSouza
05/10/2023, 2:14 AMGiorgi
05/11/2023, 12:52 PMJeff Lockhart
05/11/2023, 6:32 PM@ExperimentalForeignApi
to Kotlin/Native kotlinx.cinterop APIs, like CPointer
, memScoped
, alloc
, convert
, as well as most C/ObjC interop generated APIs. Could someone please explain this change? Are apps that use C interop expected to opt in to this annotation globally?Charlie Tapping
05/11/2023, 7:19 PMmohamed rejeb
05/12/2023, 10:29 AMkang wang
05/13/2023, 8:55 AMalexandre mommers
05/13/2023, 10:45 PM