From 8723a2bf2cbba80da2fb643f45b6c7588e20f1f3 Mon Sep 17 00:00:00 2001 From: kolegovilya Date: Fri, 1 Aug 2025 14:49:46 +0300 Subject: [PATCH 1/5] Update interop for arkts --- interop/src/arkts/DeserializerBase.ts | 4 ++-- interop/src/arkts/InteropNativeModule.ts | 2 ++ interop/src/arkts/SerializerBase.ts | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/interop/src/arkts/DeserializerBase.ts b/interop/src/arkts/DeserializerBase.ts index 2f6d36a368..5388affb84 100644 --- a/interop/src/arkts/DeserializerBase.ts +++ b/interop/src/arkts/DeserializerBase.ts @@ -224,12 +224,12 @@ export class DeserializerBase implements Disposable { return ResourceHolder.instance().get(resource.resourceId) } - final readBuffer(): NativeBuffer { + final readBuffer(): ArrayBuffer { const resource = this.readCallbackResource() const data = this.readPointer() const length = this.readInt64() InteropNativeModule._CallCallbackResourceHolder(resource.hold, resource.resourceId) - return new NativeBuffer(data, length, resource.release) + return InteropNativeModule._MaterializeBuffer(data, length, resource.resourceId, resource.hold, resource.release) } } diff --git a/interop/src/arkts/InteropNativeModule.ts b/interop/src/arkts/InteropNativeModule.ts index 2c1edb7556..497095171c 100644 --- a/interop/src/arkts/InteropNativeModule.ts +++ b/interop/src/arkts/InteropNativeModule.ts @@ -75,5 +75,7 @@ export class InteropNativeModule { @ani.unsafe.Quick native static _CopyArray(data: KPointer, length: int64, args: KUint8ArrayPtr): void native static _ReportMemLeaks(): void + native static _MaterializeBuffer(data: KPointer, length: bigint, resourceId: int32, hold: KPointer, release: KPointer): ArrayBuffer + native static _GetNativeBufferPointer(data: ArrayBuffer): KPointer } diff --git a/interop/src/arkts/SerializerBase.ts b/interop/src/arkts/SerializerBase.ts index 033a2bf48a..992546fcf9 100644 --- a/interop/src/arkts/SerializerBase.ts +++ b/interop/src/arkts/SerializerBase.ts @@ -415,9 +415,10 @@ export class SerializerBase implements Disposable { unsafeMemory.writeInt32(pos, encodedLength + 1) this._position = pos + encodedLength + 4 + 1 } - final writeBuffer(value: NativeBuffer) { + final writeBuffer(value: ArrayBuffer) { this.holdAndWriteObject(value) - this.writePointer(value.data) - this.writeInt64(value.length) + const ptr = InteropNativeModule._GetNativeBufferPointer(value) + this.writePointer(ptr) + this.writeInt64(value.byteLength) } } -- Gitee From 70b9b728714035137d43c25019b0520aa0c2df11 Mon Sep 17 00:00:00 2001 From: kolegovilya Date: Fri, 1 Aug 2025 16:55:52 +0300 Subject: [PATCH 2/5] better interop process --- interop/src/arkts/InteropNativeModule.ts | 2 +- interop/src/cpp/ani/convertors-ani.h | 4 +++- interop/src/cpp/common-interop.cc | 2 +- interop/src/interop/DeserializerBase.ts | 5 ++--- interop/src/interop/SerializerBase.ts | 7 ++++--- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/interop/src/arkts/InteropNativeModule.ts b/interop/src/arkts/InteropNativeModule.ts index 497095171c..cee53ee034 100644 --- a/interop/src/arkts/InteropNativeModule.ts +++ b/interop/src/arkts/InteropNativeModule.ts @@ -75,7 +75,7 @@ export class InteropNativeModule { @ani.unsafe.Quick native static _CopyArray(data: KPointer, length: int64, args: KUint8ArrayPtr): void native static _ReportMemLeaks(): void - native static _MaterializeBuffer(data: KPointer, length: bigint, resourceId: int32, hold: KPointer, release: KPointer): ArrayBuffer + native static _MaterializeBuffer(data: KPointer, length: int64, resourceId: int32, hold: KPointer, release: KPointer): ArrayBuffer native static _GetNativeBufferPointer(data: ArrayBuffer): KPointer } diff --git a/interop/src/cpp/ani/convertors-ani.h b/interop/src/cpp/ani/convertors-ani.h index 8d50abcc89..39782c7378 100644 --- a/interop/src/cpp/ani/convertors-ani.h +++ b/interop/src/cpp/ani/convertors-ani.h @@ -175,7 +175,9 @@ struct InteropTypeConverter { return result; } static inline void release(ani_env* env, InteropType value, KInteropBuffer converted) { - delete [] (KByte*)converted.data; + if (converted.dispose) { + converted.dispose(converted.resourceId); + } } }; diff --git a/interop/src/cpp/common-interop.cc b/interop/src/cpp/common-interop.cc index 02025e4325..2eb8ffcd49 100644 --- a/interop/src/cpp/common-interop.cc +++ b/interop/src/cpp/common-interop.cc @@ -52,7 +52,7 @@ using std::string; static std::atomic mallocCounter{0}; #endif -#ifdef KOALA_NAPI +#if defined(KOALA_NAPI) || (KOALA_ANI) // Callback dispatcher MOVED to convertors-napi.cc. // Let's keep platform-specific parts of the code together diff --git a/interop/src/interop/DeserializerBase.ts b/interop/src/interop/DeserializerBase.ts index efac031a6c..675299b3b0 100644 --- a/interop/src/interop/DeserializerBase.ts +++ b/interop/src/interop/DeserializerBase.ts @@ -209,12 +209,11 @@ export class DeserializerBase { } return suffix } - readBuffer(): NativeBuffer { + readBuffer(): ArrayBuffer { const resource = this.readCallbackResource() const data = this.readPointer() const length = this.readInt64() - InteropNativeModule._CallCallbackResourceHolder(resource.hold, resource.resourceId) - return new NativeBuffer(data, length, resource.release) + return InteropNativeModule._MaterializeBuffer(data, BigInt(length), resource.resourceId, resource.hold, resource.release) } } diff --git a/interop/src/interop/SerializerBase.ts b/interop/src/interop/SerializerBase.ts index 3982565670..aa80556045 100644 --- a/interop/src/interop/SerializerBase.ts +++ b/interop/src/interop/SerializerBase.ts @@ -307,10 +307,11 @@ export class SerializerBase { this.view.setInt32(this.position, encodedLength, true) this.position += encodedLength + 4 } - writeBuffer(buffer: NativeBuffer) { + writeBuffer(buffer: ArrayBuffer) { this.holdAndWriteObject(buffer) - this.writePointer(buffer.data) - this.writeInt64(buffer.length) + const ptr = InteropNativeModule._GetNativeBufferPointer(buffer) + this.writePointer(ptr) + this.writeInt64(buffer.byteLength) } } -- Gitee From 5e406d5ef327c8a0845d6bc5c2c934ee3910fe0b Mon Sep 17 00:00:00 2001 From: kolegovilya Date: Fri, 1 Aug 2025 17:39:52 +0300 Subject: [PATCH 3/5] typo fix --- interop/src/cpp/common-interop.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interop/src/cpp/common-interop.cc b/interop/src/cpp/common-interop.cc index 2eb8ffcd49..f7b46b279f 100644 --- a/interop/src/cpp/common-interop.cc +++ b/interop/src/cpp/common-interop.cc @@ -52,7 +52,7 @@ using std::string; static std::atomic mallocCounter{0}; #endif -#if defined(KOALA_NAPI) || (KOALA_ANI) +#if defined(KOALA_NAPI) || defined(KOALA_ANI) // Callback dispatcher MOVED to convertors-napi.cc. // Let's keep platform-specific parts of the code together -- Gitee From cdd57e108a55b0fc2e5ec0f1787df76c21935ff5 Mon Sep 17 00:00:00 2001 From: kolegovilya Date: Fri, 1 Aug 2025 20:01:55 +0300 Subject: [PATCH 4/5] fix generation --- .../arkui/generated/component/canvas.ets | 18 +++++++------- .../arkui/generated/component/idlize.ets | 16 ++++++------- .../generated/component/styledString.ets | 24 +++++++++---------- .../framework/arkts/TestNativeModule.ets | 2 +- .../framework/ohos.multimedia.image.ets | 16 ++++++------- .../peers/CallbackDeserializeCall.ets | 8 +++---- arkoala-arkts/arkui/sdk/component/canvas.ets | 4 ++-- arkoala-arkts/arkui/sdk/component/idlize.ets | 4 ++-- .../arkui/sdk/component/styledString.ets | 8 +++---- .../sdk/framework/ohos.multimedia.image.ets | 4 ++-- 10 files changed, 52 insertions(+), 52 deletions(-) diff --git a/arkoala-arkts/arkui/generated/component/canvas.ets b/arkoala-arkts/arkui/generated/component/canvas.ets index 5e5a78ec41..d270a5a0f1 100644 --- a/arkoala-arkts/arkui/generated/component/canvas.ets +++ b/arkoala-arkts/arkui/generated/component/canvas.ets @@ -419,10 +419,10 @@ export class ImageData implements MaterializedBase { public getPeer(): Finalizable | undefined { return this.peer } - get data(): NativeBuffer { + get data(): ArrayBuffer { return this.getData() } - set data(data: NativeBuffer) { + set data(data: ArrayBuffer) { this.setData(data) } get height(): number { @@ -440,10 +440,10 @@ export class ImageData implements MaterializedBase { constructor(_0: boolean, _1: boolean, _2: boolean, _3: boolean, peerPtr: KPointer) { this.peer = new Finalizable(peerPtr, ImageData.getFinalizer()) } - constructor(width: number, height: number, data?: NativeBuffer, unit?: LengthMetricsUnit) { + constructor(width: number, height: number, data?: ArrayBuffer, unit?: LengthMetricsUnit) { this(false, false, false, false, ImageData.construct(width, height, data, unit)) } - static construct(width: number, height: number, data?: NativeBuffer, unit?: LengthMetricsUnit): KPointer { + static construct(width: number, height: number, data?: ArrayBuffer, unit?: LengthMetricsUnit): KPointer { const thisSerializer : SerializerBase = SerializerBase.hold() if (data !== undefined) { thisSerializer.writeInt8(RuntimeType.OBJECT) @@ -466,11 +466,11 @@ export class ImageData implements MaterializedBase { static getFinalizer(): KPointer { return ArkUIGeneratedNativeModule._ImageData_getFinalizer() } - private getData(): NativeBuffer { + private getData(): ArrayBuffer { return this.getData_serialize() } - private setData(data: NativeBuffer): void { - const data_casted = data as (NativeBuffer) + private setData(data: ArrayBuffer): void { + const data_casted = data as (ArrayBuffer) this.setData_serialize(data_casted) return } @@ -490,11 +490,11 @@ export class ImageData implements MaterializedBase { this.setWidth_serialize(width_casted) return } - private getData_serialize(): NativeBuffer { + private getData_serialize(): ArrayBuffer { const retval = ArkUIGeneratedNativeModule._ImageData_getData(this.peer!.ptr) return new DeserializerBase(retval, retval.length).readBuffer() } - private setData_serialize(data: NativeBuffer): void { + private setData_serialize(data: ArrayBuffer): void { const thisSerializer : SerializerBase = SerializerBase.hold() thisSerializer.writeBuffer(data) ArkUIGeneratedNativeModule._ImageData_setData(this.peer!.ptr, thisSerializer.asBuffer(), thisSerializer.length()) diff --git a/arkoala-arkts/arkui/generated/component/idlize.ets b/arkoala-arkts/arkui/generated/component/idlize.ets index 114ca2e82c..e6f2215801 100644 --- a/arkoala-arkts/arkui/generated/component/idlize.ets +++ b/arkoala-arkts/arkui/generated/component/idlize.ets @@ -937,9 +937,9 @@ export class RestrictedWorker implements MaterializedBase { static getFinalizer(): KPointer { return ArkUIGeneratedNativeModule._RestrictedWorker_getFinalizer() } - public postMessage(message: Object, transfer: Array): void { + public postMessage(message: Object, transfer: Array): void { const message_casted = message as (Object) - const transfer_casted = transfer as (Array) + const transfer_casted = transfer as (Array) this.postMessage0_serialize(message_casted, transfer_casted) return } @@ -949,9 +949,9 @@ export class RestrictedWorker implements MaterializedBase { this.postMessage1_serialize(message_casted, options_casted) return } - public postMessageWithSharedSendable(message: Object, transfer?: Array): void { + public postMessageWithSharedSendable(message: Object, transfer?: Array): void { const message_casted = message as (Object) - const transfer_casted = transfer as (Array | undefined) + const transfer_casted = transfer as (Array | undefined) this.postMessageWithSharedSendable_serialize(message_casted, transfer_casted) return } @@ -1040,12 +1040,12 @@ export class RestrictedWorker implements MaterializedBase { this.setOnmessageerror_serialize(onmessageerror_casted) return } - private postMessage0_serialize(message: Object, transfer: Array): void { + private postMessage0_serialize(message: Object, transfer: Array): void { const thisSerializer : SerializerBase = SerializerBase.hold() thisSerializer.holdAndWriteObject(message) thisSerializer.writeInt32((transfer.length).toInt()) for (let transferCounterI = 0; transferCounterI < transfer.length; transferCounterI++) { - const transferTmpElement : NativeBuffer = transfer[transferCounterI] + const transferTmpElement : ArrayBuffer = transfer[transferCounterI] thisSerializer.writeBuffer(transferTmpElement) } ArkUIGeneratedNativeModule._RestrictedWorker_postMessage0(this.peer!.ptr, thisSerializer.asBuffer(), thisSerializer.length()) @@ -1064,7 +1064,7 @@ export class RestrictedWorker implements MaterializedBase { ArkUIGeneratedNativeModule._RestrictedWorker_postMessage1(this.peer!.ptr, thisSerializer.asBuffer(), thisSerializer.length()) thisSerializer.release() } - private postMessageWithSharedSendable_serialize(message: Object, transfer?: Array): void { + private postMessageWithSharedSendable_serialize(message: Object, transfer?: Array): void { const thisSerializer : SerializerBase = SerializerBase.hold() thisSerializer.holdAndWriteObject(message) if (transfer !== undefined) { @@ -1072,7 +1072,7 @@ export class RestrictedWorker implements MaterializedBase { const transferTmpValue = transfer! thisSerializer.writeInt32((transferTmpValue.length).toInt()) for (let transferTmpValueCounterI = 0; transferTmpValueCounterI < transferTmpValue.length; transferTmpValueCounterI++) { - const transferTmpValueTmpElement : NativeBuffer = transferTmpValue[transferTmpValueCounterI] + const transferTmpValueTmpElement : ArrayBuffer = transferTmpValue[transferTmpValueCounterI] thisSerializer.writeBuffer(transferTmpValueTmpElement) } } else { diff --git a/arkoala-arkts/arkui/generated/component/styledString.ets b/arkoala-arkts/arkui/generated/component/styledString.ets index c908041ae9..846ec1c499 100644 --- a/arkoala-arkts/arkui/generated/component/styledString.ets +++ b/arkoala-arkts/arkui/generated/component/styledString.ets @@ -726,14 +726,14 @@ export class StyledString implements MaterializedBase { const retval = ArkUIGeneratedNativeModule._StyledString_toHtml(toPeerPtr(styledString)) return retval } - private static marshalling0_serialize(styledString: StyledString, callback_: StyledStringMarshallCallback): NativeBuffer { + private static marshalling0_serialize(styledString: StyledString, callback_: StyledStringMarshallCallback): ArrayBuffer { const thisSerializer : SerializerBase = SerializerBase.hold() thisSerializer.holdAndWriteCallback(callback_) const retval = ArkUIGeneratedNativeModule._StyledString_marshalling0(toPeerPtr(styledString), thisSerializer.asBuffer(), thisSerializer.length()) thisSerializer.release() return new DeserializerBase(retval, retval.length).readBuffer() } - private static unmarshalling0_serialize(buffer: NativeBuffer, callback_: StyledStringUnmarshallCallback): Promise { + private static unmarshalling0_serialize(buffer: ArrayBuffer, callback_: StyledStringUnmarshallCallback): Promise { const thisSerializer : SerializerBase = SerializerBase.hold() thisSerializer.writeBuffer(buffer) thisSerializer.holdAndWriteCallback(callback_) @@ -742,11 +742,11 @@ export class StyledString implements MaterializedBase { thisSerializer.release() return retval } - private static marshalling1_serialize(styledString: StyledString): NativeBuffer { + private static marshalling1_serialize(styledString: StyledString): ArrayBuffer { const retval = ArkUIGeneratedNativeModule._StyledString_marshalling1(toPeerPtr(styledString)) return new DeserializerBase(retval, retval.length).readBuffer() } - private static unmarshalling1_serialize(buffer: NativeBuffer): Promise { + private static unmarshalling1_serialize(buffer: ArrayBuffer): Promise { const thisSerializer : SerializerBase = SerializerBase.hold() thisSerializer.writeBuffer(buffer) const retval = thisSerializer.holdAndWriteCallbackForPromise()[0] @@ -780,22 +780,22 @@ export class StyledString implements MaterializedBase { const styledString_casted = styledString as (StyledString) return StyledString.toHtml_serialize(styledString_casted) } - public static marshalling(styledString: StyledString, callback_: StyledStringMarshallCallback): NativeBuffer { + public static marshalling(styledString: StyledString, callback_: StyledStringMarshallCallback): ArrayBuffer { const styledString_casted = styledString as (StyledString) const callback__casted = callback_ as (StyledStringMarshallCallback) return StyledString.marshalling0_serialize(styledString_casted, callback__casted) } - public static unmarshalling(buffer: NativeBuffer, callback_: StyledStringUnmarshallCallback): Promise { - const buffer_casted = buffer as (NativeBuffer) + public static unmarshalling(buffer: ArrayBuffer, callback_: StyledStringUnmarshallCallback): Promise { + const buffer_casted = buffer as (ArrayBuffer) const callback__casted = callback_ as (StyledStringUnmarshallCallback) return StyledString.unmarshalling0_serialize(buffer_casted, callback__casted) } - public static marshalling(styledString: StyledString): NativeBuffer { + public static marshalling(styledString: StyledString): ArrayBuffer { const styledString_casted = styledString as (StyledString) return StyledString.marshalling1_serialize(styledString_casted) } - public static unmarshalling(buffer: NativeBuffer): Promise { - const buffer_casted = buffer as (NativeBuffer) + public static unmarshalling(buffer: ArrayBuffer): Promise { + const buffer_casted = buffer as (ArrayBuffer) return StyledString.unmarshalling1_serialize(buffer_casted) } private getLength(): number { @@ -1087,8 +1087,8 @@ export class UserDataSpan implements MaterializedBase { } } export type StyledStringMarshallingValue = UserDataSpan; -export type StyledStringMarshallCallback = (marshallableVal: UserDataSpan) => NativeBuffer; -export type StyledStringUnmarshallCallback = (buf: NativeBuffer) => UserDataSpan; +export type StyledStringMarshallCallback = (marshallableVal: UserDataSpan) => ArrayBuffer; +export type StyledStringUnmarshallCallback = (buf: ArrayBuffer) => UserDataSpan; export interface StyleOptions { start?: number; length?: number; diff --git a/arkoala-arkts/arkui/generated/framework/arkts/TestNativeModule.ets b/arkoala-arkts/arkui/generated/framework/arkts/TestNativeModule.ets index 2d197d5794..a8cfaf973f 100644 --- a/arkoala-arkts/arkui/generated/framework/arkts/TestNativeModule.ets +++ b/arkoala-arkts/arkui/generated/framework/arkts/TestNativeModule.ets @@ -26,7 +26,7 @@ export class TestNativeModule { native static _TestCallIntRecursiveCallback(arg0: int32, arr: KSerializerBuffer, arg2: int32): int32 native static _TestCallIntMemory(arg0: int32, arg1: int32): int32 @ani.unsafe.Quick - native static _TestWithBuffer(buffer: NativeBuffer): void + native static _TestWithBuffer(buffer: ArrayBuffer): void @ani.unsafe.Direct native static _TestGetManagedCaller(kind: int32): KPointer @ani.unsafe.Direct diff --git a/arkoala-arkts/arkui/generated/framework/ohos.multimedia.image.ets b/arkoala-arkts/arkui/generated/framework/ohos.multimedia.image.ets index 3c168d7538..77ce5e78b0 100644 --- a/arkoala-arkts/arkui/generated/framework/ohos.multimedia.image.ets +++ b/arkoala-arkts/arkui/generated/framework/ohos.multimedia.image.ets @@ -37,8 +37,8 @@ export namespace image { export interface PixelMap { isEditable: boolean isStrideAlignment: boolean - readPixelsToBufferSync(dst: NativeBuffer): void - writeBufferToPixels(src: NativeBuffer): void + readPixelsToBufferSync(dst: ArrayBuffer): void + writeBufferToPixels(src: ArrayBuffer): void } export class PixelMapInternal implements MaterializedBase,PixelMap { peer?: Finalizable | undefined = undefined @@ -65,13 +65,13 @@ export namespace image { public static fromPtr(ptr: KPointer): PixelMapInternal { return new PixelMapInternal(ptr) } - public readPixelsToBufferSync(dst: NativeBuffer): void { - const dst_casted = dst as (NativeBuffer) + public readPixelsToBufferSync(dst: ArrayBuffer): void { + const dst_casted = dst as (ArrayBuffer) this.readPixelsToBufferSync_serialize(dst_casted) return } - public writeBufferToPixels(src: NativeBuffer): void { - const src_casted = src as (NativeBuffer) + public writeBufferToPixels(src: ArrayBuffer): void { + const src_casted = src as (ArrayBuffer) this.writeBufferToPixels_serialize(src_casted) return } @@ -81,13 +81,13 @@ export namespace image { private getIsStrideAlignment(): boolean { return this.getIsStrideAlignment_serialize() } - private readPixelsToBufferSync_serialize(dst: NativeBuffer): void { + private readPixelsToBufferSync_serialize(dst: ArrayBuffer): void { const thisSerializer : SerializerBase = SerializerBase.hold() thisSerializer.writeBuffer(dst) ArkUIGeneratedNativeModule._image_PixelMap_readPixelsToBufferSync(this.peer!.ptr, thisSerializer.asBuffer(), thisSerializer.length()) thisSerializer.release() } - private writeBufferToPixels_serialize(src: NativeBuffer): void { + private writeBufferToPixels_serialize(src: ArrayBuffer): void { const thisSerializer : SerializerBase = SerializerBase.hold() thisSerializer.writeBuffer(src) ArkUIGeneratedNativeModule._image_PixelMap_writeBufferToPixels(this.peer!.ptr, thisSerializer.asBuffer(), thisSerializer.length()) diff --git a/arkoala-arkts/arkui/generated/framework/peers/CallbackDeserializeCall.ets b/arkoala-arkts/arkui/generated/framework/peers/CallbackDeserializeCall.ets index 4b1e55c42b..13210f849c 100644 --- a/arkoala-arkts/arkui/generated/framework/peers/CallbackDeserializeCall.ets +++ b/arkoala-arkts/arkui/generated/framework/peers/CallbackDeserializeCall.ets @@ -236,8 +236,8 @@ export function deserializeAndCallCallback_Boolean_Void(thisDeserializer: Deseri } export function deserializeAndCallCallback_Buffer_Void(thisDeserializer: DeserializerBase): void { const _resourceId : int32 = thisDeserializer.readInt32() - const _call = (ResourceHolder.instance().get(_resourceId) as ((value: NativeBuffer) => void)) - let value : NativeBuffer = (thisDeserializer.readBuffer() as NativeBuffer) + const _call = (ResourceHolder.instance().get(_resourceId) as ((value: ArrayBuffer) => void)) + let value : ArrayBuffer = (thisDeserializer.readBuffer() as ArrayBuffer) _call(value) } export function deserializeAndCallCallback_ClickEvent_LocationButtonOnClickResult_Void(thisDeserializer: DeserializerBase): void { @@ -2707,7 +2707,7 @@ export function deserializeAndCallStyledStringMarshallCallback(thisDeserializer: const continuationBufferBufResource : CallbackResource = thisDeserializer.readCallbackResource() const continuationBufferBufCall : KPointer = thisDeserializer.readPointer() const continuationBufferBufCallSync : KPointer = thisDeserializer.readPointer() - let continuationResult : ((value: NativeBuffer) => void) = (value: NativeBuffer):void => { + let continuationResult : ((value: ArrayBuffer) => void) = (value: ArrayBuffer):void => { const continuationBufferBufArgsSerializer : SerializerBase = SerializerBase.hold(); continuationBufferBufArgsSerializer.writeInt32(continuationBufferBufResource.resourceId); continuationBufferBufArgsSerializer.writePointer(continuationBufferBufCall); @@ -2723,7 +2723,7 @@ export function deserializeAndCallStyledStringMarshallCallback(thisDeserializer: export function deserializeAndCallStyledStringUnmarshallCallback(thisDeserializer: DeserializerBase): void { const _resourceId : int32 = thisDeserializer.readInt32() const _call = (ResourceHolder.instance().get(_resourceId) as StyledStringUnmarshallCallback) - let buf : NativeBuffer = (thisDeserializer.readBuffer() as NativeBuffer) + let buf : ArrayBuffer = (thisDeserializer.readBuffer() as ArrayBuffer) const continuationBufferBufResource : CallbackResource = thisDeserializer.readCallbackResource() const continuationBufferBufCall : KPointer = thisDeserializer.readPointer() const continuationBufferBufCallSync : KPointer = thisDeserializer.readPointer() diff --git a/arkoala-arkts/arkui/sdk/component/canvas.ets b/arkoala-arkts/arkui/sdk/component/canvas.ets index 5d2d85ab2b..ae458fca5e 100644 --- a/arkoala-arkts/arkui/sdk/component/canvas.ets +++ b/arkoala-arkts/arkui/sdk/component/canvas.ets @@ -85,8 +85,8 @@ export declare class ImageBitmap { close(): void } export declare class ImageData { - constructor(width: number, height: number, data: NativeBuffer | undefined, unit: LengthMetricsUnit | undefined) - get data():NativeBuffer; + constructor(width: number, height: number, data: ArrayBuffer | undefined, unit: LengthMetricsUnit | undefined) + get data():ArrayBuffer; get height():number; get width():number; } diff --git a/arkoala-arkts/arkui/sdk/component/idlize.ets b/arkoala-arkts/arkui/sdk/component/idlize.ets index f94d930237..2553cc78e1 100644 --- a/arkoala-arkts/arkui/sdk/component/idlize.ets +++ b/arkoala-arkts/arkui/sdk/component/idlize.ets @@ -246,9 +246,9 @@ export declare class RestrictedWorker { onerror?: RestrictedWorker_onerror_Callback; onmessage?: RestrictedWorker_onmessage_Callback; onmessageerror?: RestrictedWorker_onmessage_Callback; - postMessage(message: Object, transfer: Array): void + postMessage(message: Object, transfer: Array): void postMessage(message: Object, options?: PostMessageOptions): void - postMessageWithSharedSendable(message: Object, transfer?: Array): void + postMessageWithSharedSendable(message: Object, transfer?: Array): void on(Type: string, listener: WorkerEventListener): void once(Type: string, listener: WorkerEventListener): void off(Type: string, listener?: WorkerEventListener): void diff --git a/arkoala-arkts/arkui/sdk/component/styledString.ets b/arkoala-arkts/arkui/sdk/component/styledString.ets index 23aad14e73..4114f3557c 100644 --- a/arkoala-arkts/arkui/sdk/component/styledString.ets +++ b/arkoala-arkts/arkui/sdk/component/styledString.ets @@ -31,8 +31,8 @@ import { LeadingMarginPlaceholder } from "./richEditor" import { image } from "./../framework/ohos.multimedia.image" import { drawing } from "./../framework/ohos.graphics.drawing" export type StyledStringMarshallingValue = UserDataSpan; -export type StyledStringMarshallCallback = (marshallableVal: UserDataSpan) => NativeBuffer; -export type StyledStringUnmarshallCallback = (buf: NativeBuffer) => UserDataSpan; +export type StyledStringMarshallCallback = (marshallableVal: UserDataSpan) => ArrayBuffer; +export type StyledStringUnmarshallCallback = (buf: ArrayBuffer) => UserDataSpan; export declare class StyledString { constructor(value: string | ImageAttachment | CustomSpan, styles: Array | undefined) readonly length: number; @@ -42,8 +42,8 @@ export declare class StyledString { subStyledString(start: number, length?: number): StyledString static fromHtml(html: string): Promise static toHtml(styledString: StyledString): string - static marshalling(styledString: StyledString, callback_?: StyledStringMarshallCallback): NativeBuffer - static unmarshalling(buffer: NativeBuffer, callback_?: StyledStringUnmarshallCallback): Promise + static marshalling(styledString: StyledString, callback_?: StyledStringMarshallCallback): ArrayBuffer + static unmarshalling(buffer: ArrayBuffer, callback_?: StyledStringUnmarshallCallback): Promise } export declare interface StyleOptions { start?: number; diff --git a/arkoala-arkts/arkui/sdk/framework/ohos.multimedia.image.ets b/arkoala-arkts/arkui/sdk/framework/ohos.multimedia.image.ets index 469c4863fd..3551b34b6b 100644 --- a/arkoala-arkts/arkui/sdk/framework/ohos.multimedia.image.ets +++ b/arkoala-arkts/arkui/sdk/framework/ohos.multimedia.image.ets @@ -24,8 +24,8 @@ export declare namespace image { export interface PixelMap { readonly isEditable: boolean; readonly isStrideAlignment: boolean; - readPixelsToBufferSync(dst: NativeBuffer): void - writeBufferToPixels(src: NativeBuffer): void + readPixelsToBufferSync(dst: ArrayBuffer): void + writeBufferToPixels(src: ArrayBuffer): void } export enum ResolutionQuality { LOW = 1, -- Gitee From cb03de6b08505ffa85cff9fbd6fc76b407365d43 Mon Sep 17 00:00:00 2001 From: kolegovilya Date: Mon, 4 Aug 2025 11:42:09 +0300 Subject: [PATCH 5/5] Fixes in idlize test --- subset/arkoala/arkui/src/main.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/subset/arkoala/arkui/src/main.ts b/subset/arkoala/arkui/src/main.ts index 068bafca8a..497c2ff58b 100644 --- a/subset/arkoala/arkui/src/main.ts +++ b/subset/arkoala/arkui/src/main.ts @@ -617,14 +617,12 @@ function checkReadAndMutateBuffer() { uint8array[i] = i + 1 } const serializer = SerializerBase.hold() - const nativeBuffer = new NativeBuffer(uint8array.length) - InteropNativeModule._CopyArray(nativeBuffer.data, nativeBuffer.length, uint8array) - serializer.writeBuffer(nativeBuffer) + serializer.writeBuffer(buffer) TestNativeModule._TestReadAndMutateManagedBuffer(serializer.toArray(), serializer.length()) let isSame = true for (let i = 0; i < bufferSize; ++i) { - isSame = isSame && (i + 1) * 2 === nativeBuffer.readByte(i) + isSame = isSame && (i + 1) * 2 === uint8array[i] } serializer.release() assertTrue("Buffer mutated correctly", isSame) -- Gitee