1.3.4 release #9

Merged
Infendro merged 2 commits from develop into main 2026-02-03 22:06:18 +00:00
4 changed files with 74 additions and 16 deletions

View File

@@ -12,6 +12,6 @@ repositories {
}
commonMain.dependencies {
implementation("com.infendro:bytes:1.3.3")
implementation("com.infendro:bytes:1.3.4")
}
```

View File

@@ -5,7 +5,7 @@ import com.infendro.plugin.token
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
group = "com.infendro"
version = "1.3.3"
version = "1.3.4"
plugins {
alias(libs.plugins.infendro)

View File

@@ -49,15 +49,11 @@ private inline fun ByteArray.combine(that: ByteArray, combine: (Byte, Byte) -> B
return ByteArray(size).also { combineInto(that, it, combine = combine) }
}
private inline fun ByteArray.combine(that: Byte, combine: (Byte, Byte) -> Byte): ByteArray =
ByteArray(size).also { combineInto(that, it, combine = combine) }
private inline fun ByteArray.combine(that: Byte, combine: (Byte, Byte) -> Byte): ByteArray {
return ByteArray(size).also { combineInto(that, it, combine = combine) }
}
fun ByteArray.invInto(
destination: ByteArray,
destinationOffset: Int = 0,
startIndex: Int = 0,
endIndex: Int = size,
) {
fun ByteArray.invInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) {
val length = endIndex - startIndex
require(length >= 0)
require(startIndex in 0..(size - length))
@@ -68,6 +64,9 @@ fun ByteArray.invInto(
}
}
fun ByteArray.invInto(startIndex: Int = 0, endIndex: Int = size) =
invInto(this, startIndex, startIndex, endIndex)
fun ByteArray.inv(): ByteArray =
ByteArray(size).also { invInto(it) }
@@ -88,6 +87,16 @@ fun ByteArray.andInto(
endIndex: Int = size,
) = combineInto(that, destination, destinationOffset, startIndex, endIndex) { a, b -> a and b }
fun ByteArray.andInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
combineInto(
destination,
destination,
destinationOffset,
startIndex,
endIndex,
destinationOffset,
) { a, b -> a and b }
infix fun ByteArray.and(that: ByteArray): ByteArray =
combine(that) { a, b -> a and b }
@@ -111,6 +120,16 @@ fun ByteArray.orInto(
endIndex: Int = size,
) = combineInto(that, destination, destinationOffset, startIndex, endIndex) { a, b -> a or b }
fun ByteArray.orInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
combineInto(
destination,
destination,
destinationOffset,
startIndex,
endIndex,
destinationOffset,
) { a, b -> a or b }
infix fun ByteArray.or(that: ByteArray): ByteArray =
combine(that) { a, b -> a or b }
@@ -134,6 +153,16 @@ fun ByteArray.xorInto(
endIndex: Int = size,
) = combineInto(that, destination, destinationOffset, startIndex, endIndex) { a, b -> a xor b }
fun ByteArray.xorInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
combineInto(
destination,
destination,
destinationOffset,
startIndex,
endIndex,
destinationOffset,
) { a, b -> a xor b }
infix fun ByteArray.xor(that: ByteArray): ByteArray =
combine(that) { a, b -> a xor b }

View File

@@ -5,12 +5,11 @@ import com.infendro.bytes.bytearray.invInto
import com.infendro.bytes.bytearray.orInto
import com.infendro.bytes.bytearray.xorInto
fun UByteArray.invInto(
destination: UByteArray,
destinationOffset: Int = 0,
startIndex: Int = 0,
endIndex: Int = size,
) = asByteArray().invInto(destination.asByteArray(), destinationOffset, startIndex, endIndex)
fun UByteArray.invInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
asByteArray().invInto(destination.asByteArray(), destinationOffset, startIndex, endIndex)
fun UByteArray.invInto(startIndex: Int = 0, endIndex: Int = size) =
asByteArray().invInto(asByteArray(), startIndex, startIndex, endIndex)
fun UByteArray.inv(): UByteArray =
UByteArray(size).also { invInto(it) }
@@ -45,6 +44,16 @@ fun UByteArray.andInto(
endIndex,
)
fun UByteArray.andInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
asByteArray().andInto(
destination.asByteArray(),
destination.asByteArray(),
destinationOffset,
startIndex,
endIndex,
destinationOffset,
)
infix fun UByteArray.and(that: UByteArray): UByteArray =
UByteArray(size).also { andInto(that, it) }
@@ -81,6 +90,16 @@ fun UByteArray.orInto(
endIndex,
)
fun UByteArray.orInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
asByteArray().orInto(
destination.asByteArray(),
destination.asByteArray(),
destinationOffset,
startIndex,
endIndex,
destinationOffset,
)
infix fun UByteArray.or(that: UByteArray): UByteArray =
UByteArray(size).also { orInto(that, it) }
@@ -117,6 +136,16 @@ fun UByteArray.xorInto(
endIndex,
)
fun UByteArray.xorInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
asByteArray().xorInto(
destination.asByteArray(),
destination.asByteArray(),
destinationOffset,
startIndex,
endIndex,
destinationOffset,
)
infix fun UByteArray.xor(that: UByteArray): UByteArray =
UByteArray(size).also { xorInto(that, it) }