Added addressOf for Pinned<String> and Pinned<CharArray> (#3783)
This commit is contained in:
@@ -47,6 +47,12 @@ inline fun <T : Any, R> T.usePinned(block: (Pinned<T>) -> R): R {
|
|||||||
fun Pinned<ByteArray>.addressOf(index: Int): CPointer<ByteVar> = this.get().addressOfElement(index)
|
fun Pinned<ByteArray>.addressOf(index: Int): CPointer<ByteVar> = this.get().addressOfElement(index)
|
||||||
fun ByteArray.refTo(index: Int): CValuesRef<ByteVar> = this.usingPinned { addressOf(index) }
|
fun ByteArray.refTo(index: Int): CValuesRef<ByteVar> = this.usingPinned { addressOf(index) }
|
||||||
|
|
||||||
|
fun Pinned<String>.addressOf(index: Int): CPointer<COpaque> = this.get().addressOfElement(index)
|
||||||
|
fun String.refTo(index: Int): CValuesRef<COpaque> = this.usingPinned { addressOf(index) }
|
||||||
|
|
||||||
|
fun Pinned<CharArray>.addressOf(index: Int): CPointer<COpaque> = this.get().addressOfElement(index)
|
||||||
|
fun CharArray.refTo(index: Int): CValuesRef<COpaque> = this.usingPinned { addressOf(index) }
|
||||||
|
|
||||||
fun Pinned<ShortArray>.addressOf(index: Int): CPointer<ShortVar> = this.get().addressOfElement(index)
|
fun Pinned<ShortArray>.addressOf(index: Int): CPointer<ShortVar> = this.get().addressOfElement(index)
|
||||||
fun ShortArray.refTo(index: Int): CValuesRef<ShortVar> = this.usingPinned { addressOf(index) }
|
fun ShortArray.refTo(index: Int): CValuesRef<ShortVar> = this.usingPinned { addressOf(index) }
|
||||||
|
|
||||||
@@ -89,6 +95,12 @@ private inline fun <T : Any, P : CPointed> T.usingPinned(
|
|||||||
@SymbolName("Kotlin_Arrays_getByteArrayAddressOfElement")
|
@SymbolName("Kotlin_Arrays_getByteArrayAddressOfElement")
|
||||||
private external fun ByteArray.addressOfElement(index: Int): CPointer<ByteVar>
|
private external fun ByteArray.addressOfElement(index: Int): CPointer<ByteVar>
|
||||||
|
|
||||||
|
@SymbolName("Kotlin_Arrays_getStringAddressOfElement")
|
||||||
|
private external fun String.addressOfElement(index: Int): CPointer<COpaque>
|
||||||
|
|
||||||
|
@SymbolName("Kotlin_Arrays_getCharArrayAddressOfElement")
|
||||||
|
private external fun CharArray.addressOfElement(index: Int): CPointer<COpaque>
|
||||||
|
|
||||||
@SymbolName("Kotlin_Arrays_getShortArrayAddressOfElement")
|
@SymbolName("Kotlin_Arrays_getShortArrayAddressOfElement")
|
||||||
private external fun ShortArray.addressOfElement(index: Int): CPointer<ShortVar>
|
private external fun ShortArray.addressOfElement(index: Int): CPointer<ShortVar>
|
||||||
|
|
||||||
|
|||||||
@@ -661,6 +661,15 @@ KNativePtr Kotlin_Arrays_getByteArrayAddressOfElement(KRef thiz, KInt index) {
|
|||||||
return AddressOfElementAt<KByte>(array, index);
|
return AddressOfElementAt<KByte>(array, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KNativePtr Kotlin_Arrays_getCharArrayAddressOfElement (KRef thiz, KInt index) {
|
||||||
|
ArrayHeader* array = thiz->array();
|
||||||
|
return CharArrayAddressOfElementAt(array, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
KNativePtr Kotlin_Arrays_getStringAddressOfElement (KRef thiz, KInt index) {
|
||||||
|
return Kotlin_Arrays_getCharArrayAddressOfElement(thiz, index);
|
||||||
|
}
|
||||||
|
|
||||||
KNativePtr Kotlin_Arrays_getShortArrayAddressOfElement(KRef thiz, KInt index) {
|
KNativePtr Kotlin_Arrays_getShortArrayAddressOfElement(KRef thiz, KInt index) {
|
||||||
ArrayHeader* array = thiz->array();
|
ArrayHeader* array = thiz->array();
|
||||||
if (index < 0 || index >= array->count_) {
|
if (index < 0 || index >= array->count_) {
|
||||||
|
|||||||
Reference in New Issue
Block a user