scoop:scoop.core:0.1.0
src/data_borrow.scoop
Selected production source · src/data_borrow.scoop
1
// Scoped native access. The compiler supplies layout and exception cleanup.3
@Unsafe4
@Intrinsic("array_with_data_pointer")5
internal fun <T : value, R> _withArrayDataPointer(array: Array<T>, block: (Ptr<T>, Long) -> R): R7
@Unsafe8
@Intrinsic("mutable_array_with_data_pointer")9
internal fun <T : value, R> _withMutableArrayDataPointer(array: MutableArray<T>, block: (Ptr<T>, Long) -> R): R11
@Unsafe12
@Intrinsic("string_with_utf8_bytes")13
internal fun <R> _withStringUtf8Bytes(value: String, block: (Ptr<UInt8>, Long) -> R): R15
/**16
* Borrows contiguous array element storage for the callback, passing its pointer and element17
* count. The pointer is valid only during the callback and must not escape.18
*/19
@Unsafe20
public fun <T : value, R> Array<T>.withDataPointer(block: (Ptr<T>, Long) -> R): R =21
_withArrayDataPointer<T, R>(this, block)23
/**24
* Borrows contiguous array element storage for the callback, passing its pointer and element25
* count. The pointer is valid only during the callback and must not escape.26
*/27
@Unsafe28
public fun <T : value, R> MutableArray<T>.withDataPointer(block: (Ptr<T>, Long) -> R): R =29
_withMutableArrayDataPointer<T, R>(this, block)31
/**32
* Borrows the string's UTF-8 bytes for the callback, without a terminating NUL. The pointer is33
* valid only during the callback.34
*/35
@Unsafe36
public fun <R> String.withUtf8Bytes(block: (Ptr<UInt8>, Long) -> R): R =37
_withStringUtf8Bytes<R>(this, block)