Scoop API

scoop:scoop.core:0.1.0

src/string_copies.scoop

Selected production source · src/string_copies.scoop

1// Construction-only storage operations. The caller establishes byte bounds;
2// writes are confined to an unpublished result until valid UTF-8 is complete.
3@Intrinsic("string_allocate_zeroed")
4internal fun coreStringAllocateZeroed(length: Long): String
6@Unsafe @Intrinsic("string_byte_at_unchecked")
7internal fun coreStringByteAtUnchecked(value: String, index: Long): Byte
9@Unsafe @Intrinsic("string_set_byte_unchecked")
10internal fun coreStringSetByteUnchecked(value: String, index: Long, byte: Byte)
12@Unsafe
13@Intrinsic("string_copy_utf8_unchecked")
14internal fun coreStringCopyUtf8Unchecked(bytes: Ptr<Byte>, length: Long): String
16@Intrinsic("string_to_bytes")
17internal fun coreStringToBytes(value: String): Array<Byte>
19@Intrinsic("string_to_mutable_bytes")
20internal fun coreStringToMutableBytes(value: String): MutableArray<Byte>
22// The Char caller supplies one valid scalar. Encode it once into a GC-free
23// local place, then copy exactly the initialized bytes.
24internal fun coreCharToString(code: UInt): String {
25 var storage = coreUtf8Word(code)
26 @Unsafe {
27 return coreStringCopyUtf8Unchecked(addressOf(storage).cast<Byte>(), coreUtf8Width(code))
28 }