From 32140b54fde5235b2342713e0668c88013254f93 Mon Sep 17 00:00:00 2001 From: Igor Loginov Date: Fri, 15 Aug 2025 10:46:28 +0300 Subject: [PATCH] CAPI setters usage --- ui2abc/libarkts/generator/options.json5 | 4 --- ui2abc/libarkts/native/src/common.cc | 12 ------- .../libarkts/native/src/generated/bridges.cc | 35 ++++++++++++++++++- .../src/generated/Es2pandaNativeModule.ts | 9 +++++ .../src/generated/peers/CallExpression.ts | 5 +++ .../src/generated/peers/ETSFunctionType.ts | 5 +++ .../src/generated/peers/ScriptFunction.ts | 7 ++-- .../src/transform/FunctionTransformer.ts | 11 ++---- .../src/transform/SignatureTransformer.ts | 11 ++---- 9 files changed, 63 insertions(+), 36 deletions(-) diff --git a/ui2abc/libarkts/generator/options.json5 b/ui2abc/libarkts/generator/options.json5 index c2e749380..e8c217097 100644 --- a/ui2abc/libarkts/generator/options.json5 +++ b/ui2abc/libarkts/generator/options.json5 @@ -366,10 +366,6 @@ name: "setPreferredReturnTypePointer", definition: "extension_ScriptFunctionSetPreferredReturnTypePointer", }, - { - name: "setParams", - definition: "extension_ScriptFunctionSetParams", - }, ] }, { diff --git a/ui2abc/libarkts/native/src/common.cc b/ui2abc/libarkts/native/src/common.cc index 8aa244116..6fea396a6 100644 --- a/ui2abc/libarkts/native/src/common.cc +++ b/ui2abc/libarkts/native/src/common.cc @@ -268,18 +268,6 @@ KInt impl_IdentifierIdentifierFlags(KNativePointer contextPtr, KNativePointer no } KOALA_INTEROP_2(IdentifierIdentifierFlags, KInt, KNativePointer, KNativePointer) -void impl_ScriptFunctionSetParams(KNativePointer context, KNativePointer receiver, KNativePointerArray paramsList, KUInt paramsListLength) { - const auto _context = reinterpret_cast(context); - const auto _receiver = reinterpret_cast(receiver); - const auto _paramsList = reinterpret_cast(paramsList); - const auto _paramsListLength = static_cast(paramsListLength); - GetImpl()->ScriptFunctionClearParams(_context, _receiver); - for (size_t i = 0; i < _paramsListLength; i++) { - GetImpl()->ScriptFunctionEmplaceParams(_context, _receiver, _paramsList[i]); - } -} -KOALA_INTEROP_V4(ScriptFunctionSetParams, KNativePointer, KNativePointer, KNativePointerArray, KUInt) - void impl_ClassDefinitionSetBody(KNativePointer context, KNativePointer receiver, KNativePointerArray body, KUInt bodyLength) { const auto _context = reinterpret_cast(context); const auto _receiver = reinterpret_cast(receiver); diff --git a/ui2abc/libarkts/native/src/generated/bridges.cc b/ui2abc/libarkts/native/src/generated/bridges.cc index 13c2f8f47..e6fc4f480 100644 --- a/ui2abc/libarkts/native/src/generated/bridges.cc +++ b/ui2abc/libarkts/native/src/generated/bridges.cc @@ -17,7 +17,7 @@ /* * THIS FILE IS AUTOGENERATED BY arktscgen v2.1.10-arktscgen-2. DO NOT EDIT MANUALLY! - * es2panda 8950988a4162d5cf0fe7f8adc92c0ac5cb6852d7(2025-08-15) sdk v1.5.0-dev.41863 + * es2panda 45c3ccb2d02bd4cc1357a5dc4d17bf1c9f3de542(2025-08-15) sdk vlocal */ KNativePointer impl_GetAllErrorMessages(KNativePointer context) @@ -2057,6 +2057,17 @@ KNativePointer impl_ETSFunctionTypeParamsConst(KNativePointer context, KNativePo } KOALA_INTEROP_2(ETSFunctionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); +void impl_ETSFunctionTypeSetParams(KNativePointer context, KNativePointer receiver, KNativePointerArray paramsList, KUInt paramsListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _paramsList = reinterpret_cast(paramsList); + const auto _paramsListSequenceLength = static_cast(paramsListSequenceLength); + GetImpl()->ETSFunctionTypeIrSetParams(_context, _receiver, _paramsList, _paramsListSequenceLength); + return ; +} +KOALA_INTEROP_V4(ETSFunctionTypeSetParams, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + KNativePointer impl_ETSFunctionTypeReturnTypeConst(KNativePointer context, KNativePointer receiver) { const auto _context = reinterpret_cast(context); @@ -3017,6 +3028,17 @@ KNativePointer impl_CallExpressionArguments(KNativePointer context, KNativePoint } KOALA_INTEROP_2(CallExpressionArguments, KNativePointer, KNativePointer, KNativePointer); +void impl_CallExpressionSetArguments(KNativePointer context, KNativePointer receiver, KNativePointerArray argumentsList, KUInt argumentsListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _argumentsList = reinterpret_cast(argumentsList); + const auto _argumentsListSequenceLength = static_cast(argumentsListSequenceLength); + GetImpl()->CallExpressionSetArguments(_context, _receiver, _argumentsList, _argumentsListSequenceLength); + return ; +} +KOALA_INTEROP_V4(CallExpressionSetArguments, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + KBoolean impl_CallExpressionHasTrailingCommaConst(KNativePointer context, KNativePointer receiver) { const auto _context = reinterpret_cast(context); @@ -5676,6 +5698,17 @@ void impl_ScriptFunctionEmplaceParams(KNativePointer context, KNativePointer rec } KOALA_INTEROP_V3(ScriptFunctionEmplaceParams, KNativePointer, KNativePointer, KNativePointer); +void impl_ScriptFunctionSetParams(KNativePointer context, KNativePointer receiver, KNativePointerArray paramsList, KUInt paramsListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _paramsList = reinterpret_cast(paramsList); + const auto _paramsListSequenceLength = static_cast(paramsListSequenceLength); + GetImpl()->ScriptFunctionSetParams(_context, _receiver, _paramsList, _paramsListSequenceLength); + return ; +} +KOALA_INTEROP_V4(ScriptFunctionSetParams, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + void impl_ScriptFunctionClearParams(KNativePointer context, KNativePointer receiver) { const auto _context = reinterpret_cast(context); diff --git a/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts b/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts index f51850acc..82737e0a0 100644 --- a/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts +++ b/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts @@ -755,6 +755,9 @@ export class Es2pandaNativeModule { _ETSFunctionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } + _ETSFunctionTypeSetParams(context: KNativePointer, receiver: KNativePointer, paramsList: BigUint64Array, paramsListSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } _ETSFunctionTypeReturnTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } @@ -1049,6 +1052,9 @@ export class Es2pandaNativeModule { _CallExpressionArguments(context: KNativePointer, receiver: KNativePointer): KNativePointer { throw new Error("This methods was not overloaded by native module initialization") } + _CallExpressionSetArguments(context: KNativePointer, receiver: KNativePointer, argumentsList: BigUint64Array, argumentsListSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } _CallExpressionHasTrailingCommaConst(context: KNativePointer, receiver: KNativePointer): KBoolean { throw new Error("This methods was not overloaded by native module initialization") } @@ -1871,6 +1877,9 @@ export class Es2pandaNativeModule { _ScriptFunctionEmplaceParams(context: KNativePointer, receiver: KNativePointer, params: KNativePointer): void { throw new Error("This methods was not overloaded by native module initialization") } + _ScriptFunctionSetParams(context: KNativePointer, receiver: KNativePointer, paramsList: BigUint64Array, paramsListSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } _ScriptFunctionClearParams(context: KNativePointer, receiver: KNativePointer): void { throw new Error("This methods was not overloaded by native module initialization") } diff --git a/ui2abc/libarkts/src/generated/peers/CallExpression.ts b/ui2abc/libarkts/src/generated/peers/CallExpression.ts index 9173a4927..34bc1619a 100644 --- a/ui2abc/libarkts/src/generated/peers/CallExpression.ts +++ b/ui2abc/libarkts/src/generated/peers/CallExpression.ts @@ -74,6 +74,11 @@ export class CallExpression extends MaybeOptionalExpression { get arguments(): readonly Expression[] { return unpackNodeArray(global.generatedEs2panda._CallExpressionArguments(global.context, this.peer)) } + /** @deprecated */ + setArguments(argumentsList: readonly Expression[]): this { + global.generatedEs2panda._CallExpressionSetArguments(global.context, this.peer, passNodeArray(argumentsList), argumentsList.length) + return this + } get hasTrailingComma(): boolean { return global.generatedEs2panda._CallExpressionHasTrailingCommaConst(global.context, this.peer) } diff --git a/ui2abc/libarkts/src/generated/peers/ETSFunctionType.ts b/ui2abc/libarkts/src/generated/peers/ETSFunctionType.ts index 9298f1bf6..2ad4075e6 100644 --- a/ui2abc/libarkts/src/generated/peers/ETSFunctionType.ts +++ b/ui2abc/libarkts/src/generated/peers/ETSFunctionType.ts @@ -69,6 +69,11 @@ export class ETSFunctionType extends TypeNode { get params(): readonly Expression[] { return unpackNodeArray(global.generatedEs2panda._ETSFunctionTypeParamsConst(global.context, this.peer)) } + /** @deprecated */ + setParams(paramsList: readonly Expression[]): this { + global.generatedEs2panda._ETSFunctionTypeSetParams(global.context, this.peer, passNodeArray(paramsList), paramsList.length) + return this + } get returnType(): TypeNode | undefined { return unpackNode(global.generatedEs2panda._ETSFunctionTypeReturnType(global.context, this.peer)) } diff --git a/ui2abc/libarkts/src/generated/peers/ScriptFunction.ts b/ui2abc/libarkts/src/generated/peers/ScriptFunction.ts index fc7b2bd3b..6ca2070b5 100644 --- a/ui2abc/libarkts/src/generated/peers/ScriptFunction.ts +++ b/ui2abc/libarkts/src/generated/peers/ScriptFunction.ts @@ -43,7 +43,6 @@ import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" import { TypeNode } from "./TypeNode" import { extension_ScriptFunctionGetPreferredReturnTypePointer } from "./../../reexport-for-generated" import { extension_ScriptFunctionGetSignaturePointer } from "./../../reexport-for-generated" -import { extension_ScriptFunctionSetParams } from "./../../reexport-for-generated" import { extension_ScriptFunctionSetPreferredReturnTypePointer } from "./../../reexport-for-generated" import { extension_ScriptFunctionSetSignaturePointer } from "./../../reexport-for-generated" @@ -244,6 +243,11 @@ export class ScriptFunction extends AstNode { return this } /** @deprecated */ + setParams(paramsList: readonly Expression[]): this { + global.generatedEs2panda._ScriptFunctionSetParams(global.context, this.peer, passNodeArray(paramsList), paramsList.length) + return this + } + /** @deprecated */ clearParams(): this { global.generatedEs2panda._ScriptFunctionClearParams(global.context, this.peer) return this @@ -296,7 +300,6 @@ export class ScriptFunction extends AstNode { setSignaturePointer = extension_ScriptFunctionSetSignaturePointer getPreferredReturnTypePointer = extension_ScriptFunctionGetPreferredReturnTypePointer setPreferredReturnTypePointer = extension_ScriptFunctionSetPreferredReturnTypePointer - setParams = extension_ScriptFunctionSetParams protected readonly brandScriptFunction: undefined } export function isScriptFunction(node: object | undefined): node is ScriptFunction { diff --git a/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts b/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts index 648991f3b..67f6675ba 100644 --- a/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/FunctionTransformer.ts @@ -239,15 +239,8 @@ export class FunctionTransformer extends arkts.AbstractVisitor { if (callsiteHasReceiver(kind)) { newArgs = moveToFront(newArgs, 2) } - return arkts.factory.updateCallExpression( - node, - node.callee, - newArgs, - node.typeParams, - node.isOptional, - node.hasTrailingComma, - node.trailingBlock, - ) + node.setArguments(newArgs) + return node } transformETSFunctionType(node: arkts.ETSFunctionType): arkts.ETSFunctionType { diff --git a/ui2abc/memo-plugin/src/transform/SignatureTransformer.ts b/ui2abc/memo-plugin/src/transform/SignatureTransformer.ts index 9ac921491..7d8b6ebdd 100644 --- a/ui2abc/memo-plugin/src/transform/SignatureTransformer.ts +++ b/ui2abc/memo-plugin/src/transform/SignatureTransformer.ts @@ -62,18 +62,13 @@ export class SignatureTransformer extends arkts.AbstractVisitor { if (!shouldTransform) { return node } - return arkts.factory.updateETSFunctionType( - node, - node.typeParams, + node.setParams( extendParameters( castParameters(node.params), kind == MemoFunctionKind.MEMO_WITH_RECEIVER || kind == MemoFunctionKind.INTRINSIC_WITH_RECEIVER - ), - node.returnType, - node.isExtensionFunction, - node.flags, - node.annotations, + ) ) + return node } return this.visitEachChild(node) -- Gitee