From c49dec775edb4a3270eb12289e2c51fc3bedc4c4 Mon Sep 17 00:00:00 2001 From: pavelpozdeev Date: Fri, 7 Feb 2025 18:49:14 +0300 Subject: [PATCH] initial --- interop/src/cangjie/DeserializerBase.cj | 12 ++++++------ interop/src/cangjie/InteropNativeModule.cj | 4 ++-- interop/src/cpp/cangjie/convertors-cj.h | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/interop/src/cangjie/DeserializerBase.cj b/interop/src/cangjie/DeserializerBase.cj index 7e73e01bf..2ae92c876 100644 --- a/interop/src/cangjie/DeserializerBase.cj +++ b/interop/src/cangjie/DeserializerBase.cj @@ -103,12 +103,12 @@ public open class DeserializerBase { // } public func readString(): String { - return "readString" - // let length = Int64(this.readInt32()) - // this.checkCapacity(length) - // // read without null-terminated byte - // let value = InteropNativeModule._Utf8ToString(this.buffer, Int32(this.position), Int32(length)) - // this.position += length + let length = Int64(this.readInt32()) + this.checkCapacity(length) + // read without null-terminated byte + let value = InteropNativeModule._Utf8ToString(this.buffer.toArray(), Int32(this.position), Int32(length)) + this.position += length + return value } public func readCustomObject(kind: String): Object{ diff --git a/interop/src/cangjie/InteropNativeModule.cj b/interop/src/cangjie/InteropNativeModule.cj index 95b7d7414..5d4617498 100644 --- a/interop/src/cangjie/InteropNativeModule.cj +++ b/interop/src/cangjie/InteropNativeModule.cj @@ -144,9 +144,9 @@ public open class InteropNativeModule { LibC.free(str1) } } - public static func _Utf8ToString(data: ArrayList, offset: Int32, length: Int32): String { + public static func _Utf8ToString(data: Array, offset: Int32, length: Int32): String { unsafe { - let handle_0 = acquireArrayRawData(data.toArray()) + let handle_0 = acquireArrayRawData(data) let result = Utf8ToString(handle_0.pointer, offset, length) releaseArrayRawData(handle_0) return result.toString() diff --git a/interop/src/cpp/cangjie/convertors-cj.h b/interop/src/cpp/cangjie/convertors-cj.h index 882405ac7..cf83974d6 100644 --- a/interop/src/cpp/cangjie/convertors-cj.h +++ b/interop/src/cpp/cangjie/convertors-cj.h @@ -765,7 +765,8 @@ KOALA_INTEROP_EXPORT Ret name(InteropTypeConverter::InteropType _p0, \ #define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ -KOALA_INTEROP_EXPORT Ret name(InteropTypeConverter::InteropType _p0, \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ InteropTypeConverter::InteropType _p1, \ InteropTypeConverter::InteropType _p2) { \ KOALA_MAYBE_LOG(name) \ -- Gitee