Simplify working with values in interop
* Access primitive interop array elements and struct fields without `.value` * Simplify C*Var* interop types names
This commit is contained in:
committed by
SvyatoslavScherbina
parent
f94a47518a
commit
50c3be3fc2
@@ -40,13 +40,13 @@ class CUrl(val url: String) {
|
||||
}
|
||||
}
|
||||
|
||||
fun CPointer<CInt8Var>.toKString(length: Int): String {
|
||||
fun CPointer<ByteVar>.toKString(length: Int): String {
|
||||
val bytes = ByteArray(length)
|
||||
nativeMemUtils.getByteArray(pointed, bytes, length)
|
||||
return kotlin.text.fromUtf8Array(bytes, 0, bytes.size)
|
||||
}
|
||||
|
||||
fun header_callback(buffer: CPointer<CInt8Var>?, size: size_t, nitems: size_t, userdata: COpaquePointer?): size_t {
|
||||
fun header_callback(buffer: CPointer<ByteVar>?, size: size_t, nitems: size_t, userdata: COpaquePointer?): size_t {
|
||||
if (buffer == null) return 0
|
||||
val header = buffer.toKString((size * nitems).toInt()).trim()
|
||||
if (userdata != null) {
|
||||
|
||||
Reference in New Issue
Block a user