diff --git a/arkoala/framework/src/NativePeerNode.ts b/arkoala/framework/src/NativePeerNode.ts index 7eba22ab472a6704d30c7b72196a756631658fa7..883d28349fec4a7abad3644be743564ffff6e485 100644 --- a/arkoala/framework/src/NativePeerNode.ts +++ b/arkoala/framework/src/NativePeerNode.ts @@ -13,10 +13,8 @@ * limitations under the License. */ import { int32 } from "@koalaui/common" -import { pointer, withString, KStringPtr, nullptr, withStringResult, KInt, wrapCallback, disposeCallback } from "@koalaui/interop" -import { Finalizable } from "./Finalizable" +import { pointer, KInt, wrapCallback, disposeCallback, Finalizable } from "@koalaui/interop" import { ArkUINativeModule } from "./generated/ArkUINativeModule" -import { NativeString } from "./NativeString" import { PeerNode } from "./PeerNode" export class NativePeerNode extends Finalizable { diff --git a/arkoala/framework/src/PeerEvents.ts b/arkoala/framework/src/PeerEvents.ts index e03db4bca29a403e4913df86ff0388499af14326..33ed863c58ca9914b4c68c083f4747f56885020c 100644 --- a/arkoala/framework/src/PeerEvents.ts +++ b/arkoala/framework/src/PeerEvents.ts @@ -13,8 +13,7 @@ * limitations under the License. */ import { int32 } from "@koalaui/common" -import { Access, KInt32ArrayPtr, bitsToPtr, ptrToBits, withInt32Array } from "@koalaui/interop" -import { NativeString } from "./NativeString" +import { bitsToPtr, ptrToBits, NativeString } from "@koalaui/interop" // Must match ArkUIAPIEventKind in api.h. export enum PeerEventKind { diff --git a/arkoala/framework/src/PeerNode.ts b/arkoala/framework/src/PeerNode.ts index fd45f58c59844a6dd79adcc8c593f9b7ee2bfa6a..38837be4a5a926e9f21f2756f09a7119e8d1f87a 100644 --- a/arkoala/framework/src/PeerNode.ts +++ b/arkoala/framework/src/PeerNode.ts @@ -15,7 +15,7 @@ import { float32, int32 } from "@koalaui/common" import { Access, ptrToBits, withFloat32Array, KFloat32ArrayPtr, Wrapper, pointer, bitsToPtr, KPointer, KInt, KFloat, wrapCallback, - nullptr} from "@koalaui/interop" + nullptr, Finalizable } from "@koalaui/interop" import { ArkUINativeModule } from "./generated/ArkUINativeModule" import { DataNode, IncrementalNode, contextNode } from "@koalaui/runtime" import { @@ -33,7 +33,6 @@ import { } from "./PeerEvents" import { NativePeerNode } from "./NativePeerNode" import { WebLoadInterceptDataType } from "./WebResourceRequest" -import { Finalizable } from "./Finalizable" import { Alignment } from "./PeerLayout" export function IntToFloatArray(array: Int32Array, offset: number = 0, length?: number): Float32Array { diff --git a/arkoala/framework/src/index.ts b/arkoala/framework/src/index.ts index 546510f305f55febabb9f07754f6870f540a7b49..af410312e2588185103cf6e4590bf3f84424fce4 100644 --- a/arkoala/framework/src/index.ts +++ b/arkoala/framework/src/index.ts @@ -15,7 +15,6 @@ export * from "./generated/ArkUINativeModule" export * from "./generated/TestNativeModule" -export * from "./NativeString" export * from "./PeerNode" export * from "./PeerEvents" export * from "./NativePeerNode" @@ -30,5 +29,4 @@ export * from "./PeerLayout" export * from "./utils" export * from "./LegacyWrapper" export * from "./ArkUINodeType" -export * from "./Finalizable" export { wrapCallback } from "@koalaui/interop" diff --git a/arkoala/framework/src/NativeString.ts b/interop/src/interop/NativeString.ts similarity index 57% rename from arkoala/framework/src/NativeString.ts rename to interop/src/interop/NativeString.ts index 274439f85a6886a569faa9430bc5de8551913fc4..3e7affc5638f3d9da1a4ccbe044c0b8482630d80 100644 --- a/arkoala/framework/src/NativeString.ts +++ b/interop/src/interop/NativeString.ts @@ -13,26 +13,18 @@ * limitations under the License. */ -import { Access, decodeToString, pointer, withByteArray, withString, KStringPtr, KUint8ArrayPtr, InteropNativeModule } from "@koalaui/interop" import { Finalizable } from "./Finalizable" +import { InteropNativeModule } from "./InteropNativeModule" +import { pointer } from "./InteropTypes" export class NativeString extends Finalizable { constructor(ptr: pointer) { super(ptr, InteropNativeModule._GetStringFinalizer()) } static Make(value: string): NativeString { - let nativePtr = withString(value, (valuePtr: KStringPtr) => { - return InteropNativeModule._StringMake(valuePtr) - }) - return new NativeString(nativePtr) + return new NativeString(InteropNativeModule._StringMake(value)) } toString(): string { - // TODO: optimize me! - let size = InteropNativeModule._StringLength(this.ptr) - let array = new Uint8Array(size) - withByteArray(array, Access.WRITE, (arrayPtr: KUint8ArrayPtr) => { - InteropNativeModule._StringData(this.ptr, arrayPtr, size) - }) - return decodeToString(array) + return InteropNativeModule._StdStringToString(this.ptr) } } diff --git a/interop/src/interop/index.ts b/interop/src/interop/index.ts index eea216b1458692d404f53f84b935e7cb65217665..5dcfa15a2226b631976d6f7c1ac5660d465d1691 100644 --- a/interop/src/interop/index.ts +++ b/interop/src/interop/index.ts @@ -63,6 +63,7 @@ export * from "./Platform" export * from "./InteropTypes" export * from "./InteropOps" +export * from "./NativeString" export * from "./buffer" export * from "../arkts/ResourceManager" export * from "./NativeBuffer"