Skip to content

Commit

Permalink
Remove stringToUTF8 from wasm/js
Browse files Browse the repository at this point in the history
  • Loading branch information
Schahen committed Aug 6, 2024
1 parent 9b3707d commit 00b11da
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 22 deletions.
2 changes: 0 additions & 2 deletions skiko/src/jsMain/kotlin/org/jetbrains/skia/impl/Native.js.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ internal actual fun fromWasm(src: NativePointer, result: DoubleArray) {
result.asDynamic().set(HEAPF64.subarray(startIndex, startIndex + result.size))
}

internal actual external fun stringToUTF8(str: String, outPtr: NativePointer, maxBytesToWrite: Int)

internal actual class InteropScope actual constructor() {
private val elements = mutableListOf<NativePointer>()
private var callbacksInitialized = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ internal external fun _malloc(size: Int): NativePointer
@ModuleImport("./skiko.mjs", "free")
internal external fun _free(ptr: NativePointer)

private external fun lengthBytesUTF8(str: String): Int

internal expect fun stringToUTF8(str: String, outPtr: NativePointer, maxBytesToWrite: Int)

private external fun UTF8ToString(ptr: NativePointer): String

// Data copying routines.
internal expect fun toWasm(dest: NativePointer, src: ByteArray)
internal expect fun toWasm(dest: NativePointer, src: ShortArray)
Expand Down
14 changes: 0 additions & 14 deletions skiko/src/wasmJsMain/kotlin/org/jetbrains/skia/impl/Native.wasm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,6 @@ internal actual fun fromWasm(src: NativePointer, result: DoubleArray) {
}
}

internal actual fun stringToUTF8(str: String, outPtr: NativePointer, maxBytesToWrite: Int) {
if (maxBytesToWrite <= 0) return

val utf8 = str.encodeToByteArray()
val lastIndex = minOf(maxBytesToWrite - 1, utf8.size)

var index = 0
while (index < lastIndex) {
skia_memSetByte(outPtr + index, utf8[index])
index++
}
skia_memSetByte(outPtr + index, 0)
}

internal actual class InteropScope actual constructor() {
private val elements = mutableListOf<NativePointer>()
private var callbacksInitialized = false
Expand Down

0 comments on commit 00b11da

Please sign in to comment.