when compiling the following K/N code: ``` fun foo...
# kotlin-native
j
when compiling the following K/N code:
Copy code
fun foo(bar: IntArray) {}
to a macOsX dynamic library, I “get” a compiled library with a generated header where kotlin IntArray type is mapped to
libtest_kref_kotlin_IntArray
, where
test
is the name of my library. There seems to be no good way of constructing this object though, or at least it’s not defined in this header. Is there a way of consuming this library in a C program and somehow providing an object of that type?
d
You would have to communicate with the kotlin vm somehow, since it's refcounted. Assuming that's how the GC works.
Sorry I cant answer the question
o
Just create in your Kotlin code constructor for an IntArray and setter for elements. We do not automatically reexport standard library.
d
If C code is using native ptrs, they can't be ref counted can they? So you would need to use StableRef somehow?
j
@olonho okay, so if I understand correctly, only primitive types are mapped and user defined constructs get bindings? I was also wondering why arrays aren’t mapped since C seems to have a good equivalent type
o
There’s no equivalent type in C
j
I meant, that instead of
libtest_kref_kotlin_IntArray
in my generated header, I would get
int[]
o
int[]
and
int*
are not equivalent types to
IntArray