Add .toCStringArray(AutofreeScope) to interop utils
This commit is contained in:
committed by
SvyatoslavScherbina
parent
62bee84a26
commit
0efa78d4a0
@@ -361,6 +361,20 @@ val String.cstr: CValues<ByteVar>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert this list of Kotlin strings to C array of C strings,
|
||||||
|
* allocating memory for the array and C strings with given [AutofreeScope].
|
||||||
|
*/
|
||||||
|
fun List<String>.toCStringArray(autofreeScope: AutofreeScope): CPointer<CPointerVar<ByteVar>> =
|
||||||
|
autofreeScope.allocArrayOf(this.map { it.cstr.getPointer(autofreeScope) })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert this array of Kotlin strings to C array of C strings,
|
||||||
|
* allocating memory for the array and C strings with given [AutofreeScope].
|
||||||
|
*/
|
||||||
|
fun Array<String>.toCStringArray(autofreeScope: AutofreeScope): CPointer<CPointerVar<ByteVar>> =
|
||||||
|
autofreeScope.allocArrayOf(this.map { it.cstr.getPointer(autofreeScope) })
|
||||||
|
|
||||||
val String.wcstr: CValues<ShortVar>
|
val String.wcstr: CValues<ShortVar>
|
||||||
get() {
|
get() {
|
||||||
val chars = CharArray(this.length, { i -> this.get(i)})
|
val chars = CharArray(this.length, { i -> this.get(i)})
|
||||||
|
|||||||
Reference in New Issue
Block a user