Skip to content

Commit

Permalink
add more api
Browse files Browse the repository at this point in the history
  • Loading branch information
xfqwdsj committed Apr 24, 2024
1 parent 7b5ac6e commit f72ce36
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions client-py/src/nativeMain/kotlin/ByteArray.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package xyz.xfqlittlefan.fhraise.py

import kotlinx.cinterop.*

@ExperimentalForeignApi
typealias OnData = CPointer<CFunction<(data: CArrayPointer<ByteVar>, size: Int) -> Unit>>

@Deprecated("This function is for calling from C code only.", level = DeprecationLevel.HIDDEN)
@ExperimentalForeignApi
fun byteArrayToPointer(byteArray: ByteArray, onData: OnData) { memScoped { onData(allocArrayOf(byteArray), byteArray.size) } }
8 changes: 7 additions & 1 deletion py/src/commonMain/kotlin/Message.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ sealed class Message {
@Serializable
sealed class Register : Message() {
@Serializable
data class Frame(val callId: String, val content: ByteArray) : Register() {
data class Frame(val callId: String, val format: FrameFormat, val content: ByteArray) : Register() {
@Deprecated("This function is for calling from C code only.", level = DeprecationLevel.HIDDEN)
fun getFormatString() = format.toString()

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false
Expand Down Expand Up @@ -55,6 +58,9 @@ sealed class Message {
}
}

@Serializable
enum class FrameFormat { AndroidRgba8888 }

@Serializable
sealed class Ping : Message() {
@Serializable
Expand Down

0 comments on commit f72ce36

Please sign in to comment.