diff --git a/interop/src/cangjie/DeserializerBase.cj b/interop/src/cangjie/DeserializerBase.cj index 7e73e01bf7b33f6f4627eb1c9e23f7d3dbcf4c69..2ae92c8769bec6ffe11a5abd7988419c50731024 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 95b7d7414b10bac87222c69bf58ec62ec5174a22..5d46174980a2e358fc17807baa9a034b0c9fed53 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 882405ac7a4cf414d7c15022109d4edb1a9d3a1b..cf83974d6bbdda26e13d38dcf56587b64adf11b8 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) \