Implement copy for DataViewMemory #106
@ -18,10 +18,9 @@ class DataViewMemory(val view: DataView) : Memory {
|
|||||||
return DataViewMemory(DataView(view.buffer, view.byteOffset + offset, length))
|
return DataViewMemory(DataView(view.buffer, view.byteOffset + offset, length))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun copy(): Memory = DataViewMemory(DataView(view.buffer.slice(0)))
|
override fun copy(): Memory = DataViewMemory(DataView(view.buffer.slice(0)))
|
||||||
|
|
||||||
private val reader = object : MemoryReader {
|
private val reader: MemoryReader = object : MemoryReader {
|
||||||
override val memory: Memory get() = this@DataViewMemory
|
override val memory: Memory get() = this@DataViewMemory
|
||||||
|
|
||||||
override fun readDouble(offset: Int): Double = view.getFloat64(offset, false)
|
override fun readDouble(offset: Int): Double = view.getFloat64(offset, false)
|
||||||
@ -44,7 +43,7 @@ class DataViewMemory(val view: DataView) : Memory {
|
|||||||
|
|
||||||
override fun reader(): MemoryReader = reader
|
override fun reader(): MemoryReader = reader
|
||||||
|
|
||||||
private val writer = object : MemoryWriter {
|
private val writer: MemoryWriter = object : MemoryWriter {
|
||||||
override val memory: Memory get() = this@DataViewMemory
|
override val memory: Memory get() = this@DataViewMemory
|
||||||
|
|
||||||
override fun writeDouble(offset: Int, value: Double) {
|
override fun writeDouble(offset: Int, value: Double) {
|
||||||
@ -75,7 +74,6 @@ class DataViewMemory(val view: DataView) : Memory {
|
|||||||
override fun release() {
|
override fun release() {
|
||||||
//does nothing on JS
|
//does nothing on JS
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun writer(): MemoryWriter = writer
|
override fun writer(): MemoryWriter = writer
|
||||||
|
Loading…
Reference in New Issue
Block a user