diff --git a/arkui-plugins/ui-plugins/interop/legacy-transformer.ts b/arkui-plugins/ui-plugins/interop/legacy-transformer.ts index 366678e19cbfc237fbe16c1b30076df1975bba9b..1b831a9b00f81120621115d64aa85b81b2f64145 100644 --- a/arkui-plugins/ui-plugins/interop/legacy-transformer.ts +++ b/arkui-plugins/ui-plugins/interop/legacy-transformer.ts @@ -158,7 +158,8 @@ export class LegacyTransformer extends AbstractVisitor { definition.super, [...definition.body, instantiate_Interop], definition.modifiers, - arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + arkts.Es2pandaLanguage.JS ); if (arkts.isStructDeclaration(node)) { diff --git a/koala-wrapper/native/src/bridges.cc b/koala-wrapper/native/src/bridges.cc index 68e48f828fc9aa74856d4c2876e2398bc02ecf44..e137d9e8d4734063eaf0ac6b608ef00cee3f616e 100644 --- a/koala-wrapper/native/src/bridges.cc +++ b/koala-wrapper/native/src/bridges.cc @@ -20,6 +20,56 @@ #include #include "memoryTracker.h" +KInt impl_ClassDefinitionLanguageConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionLanguageConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionLanguageConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateClassDefinition3(KNativePointer context, KNativePointer ident, KNativePointer typeParams, KNativePointer superTypeParams, KNativePointerArray _implements, KUInt _implementsSequenceLength, KNativePointer ctor, KNativePointer superClass, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags, KInt lang) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _superTypeParams = reinterpret_cast(superTypeParams); + const auto __implements = reinterpret_cast(_implements); + const auto __implementsSequenceLength = static_cast(_implementsSequenceLength); + const auto _ctor = reinterpret_cast(ctor); + const auto _superClass = reinterpret_cast(superClass); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + const auto _lang = static_cast(lang); + auto result = GetImpl()->CreateClassDefinition3(_context, _ident, _typeParams, _superTypeParams, __implements, __implementsSequenceLength, _ctor, _superClass, _body, _bodySequenceLength, _modifiers, _flags, _lang); + return result; +} +KOALA_INTEROP_13(CreateClassDefinition3, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt, KInt); + +KNativePointer impl_UpdateClassDefinition3(KNativePointer context, KNativePointer original, KNativePointer ident, KNativePointer typeParams, KNativePointer superTypeParams, KNativePointerArray _implements, KUInt _implementsSequenceLength, KNativePointer ctor, KNativePointer superClass, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags, KInt lang) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _superTypeParams = reinterpret_cast(superTypeParams); + const auto __implements = reinterpret_cast(_implements); + const auto __implementsSequenceLength = static_cast(_implementsSequenceLength); + const auto _ctor = reinterpret_cast(ctor); + const auto _superClass = reinterpret_cast(superClass); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + const auto _lang = static_cast(lang); + auto result = GetImpl()->UpdateClassDefinition3(_context, _original, _ident, _typeParams, _superTypeParams, __implements, __implementsSequenceLength, _ctor, _superClass, _body, _bodySequenceLength, _modifiers, _flags, _lang); + return result; +} +KOALA_INTEROP_14(UpdateClassDefinition3, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt, KInt); + KBoolean impl_ClassDefinitionIsFromStructConst(KNativePointer contextPtr, KNativePointer instancePtr) { auto context = reinterpret_cast(contextPtr); diff --git a/koala-wrapper/src/Es2pandaEnums.ts b/koala-wrapper/src/Es2pandaEnums.ts index 9bb06c7d6109ad32fa7b369f52a043114292b7f5..4aa8f8c2d2bfda260a40c929543aefaf22033812 100644 --- a/koala-wrapper/src/Es2pandaEnums.ts +++ b/koala-wrapper/src/Es2pandaEnums.ts @@ -190,3 +190,11 @@ export enum Es2pandaImportFlags { IMPORT_FLAGS_DEFAULT_IMPORT, IMPORT_FLAGS_IMPLICIT_PACKAGE_IMPORT, } + +export enum Es2pandaLanguage { + AS = 0, + JS = 1, + TS = 2, + ETS = 3, + COUNT = 4 +} \ No newline at end of file diff --git a/koala-wrapper/src/Es2pandaNativeModule.ts b/koala-wrapper/src/Es2pandaNativeModule.ts index cf005c190b278837fcc22ecc97c1b240ecc02338..fe9ce5ca324b0c84ec282d93d1d8ba36577143fa 100644 --- a/koala-wrapper/src/Es2pandaNativeModule.ts +++ b/koala-wrapper/src/Es2pandaNativeModule.ts @@ -23,6 +23,7 @@ import { loadNativeModuleLibrary, KDouble, KStringArrayPtr, + KUInt, } from '@koalaui/interop'; import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from './generated/Es2pandaNativeModule'; import * as path from 'path'; @@ -818,6 +819,17 @@ export class Es2pandaNativeModule { _ClassDefinitionSetFromStructModifier(context: KNativePointer, instance: KNativePointer): void { throw new Error('Not implemented'); } + + _CreateClassDefinition3(context: KNativePointer, ident: KNativePointer, typeParams: KNativePointer, superTypeParams: KNativePointer, _implements: BigUint64Array, _implementsSequenceLength: KUInt, ctor: KNativePointer, superClass: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt, lang: KInt): KNativePointer { + throw new Error("'CreateClassDefinition was not overloaded by native module initialization") + } + _UpdateClassDefinition3(context: KNativePointer, original: KNativePointer, ident: KNativePointer, typeParams: KNativePointer, superTypeParams: KNativePointer, _implements: BigUint64Array, _implementsSequenceLength: KUInt, ctor: KNativePointer, superClass: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt, lang: KInt): KNativePointer { + throw new Error("'UpdateClassDefinition was not overloaded by native module initialization") + } + + _ClassDefinitionLanguageConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'ClassDefinitionLanguageConst was not overloaded by native module initialization") + } _ProgramFileNameConst(context: KPtr, program: KPtr): KNativePointer { throw new Error('Not implemented'); diff --git a/koala-wrapper/src/arkts-api/node-utilities/ClassDefinition.ts b/koala-wrapper/src/arkts-api/node-utilities/ClassDefinition.ts index feeac630221456f06585187ee9cef3b4e87e0e9c..793c00935a0982a76273a1e348f91f55ddd80f99 100644 --- a/koala-wrapper/src/arkts-api/node-utilities/ClassDefinition.ts +++ b/koala-wrapper/src/arkts-api/node-utilities/ClassDefinition.ts @@ -27,6 +27,7 @@ import { MethodDefinition } from '../types'; import { updateThenAttach } from '../utilities/private'; import { Es2pandaClassDefinitionModifiers, Es2pandaModifierFlags } from '../../generated/Es2pandaEnums'; import { classDefinitionFlags } from '../utilities/public'; +import { Es2pandaLanguage } from '..'; export function updateClassDefinition( original: ClassDefinition, @@ -38,7 +39,8 @@ export function updateClassDefinition( superClass: Expression | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, - flags: Es2pandaModifierFlags + flags: Es2pandaModifierFlags, + lang?: Es2pandaLanguage ): ClassDefinition { if ( isSameNativeObject(ident, original.ident) && @@ -48,14 +50,15 @@ export function updateClassDefinition( isSameNativeObject(superClass, original.super) && isSameNativeObject(body, original.body) && isSameNativeObject(modifiers, original.modifiers) && - isSameNativeObject(flags, classDefinitionFlags(original)) + isSameNativeObject(flags, classDefinitionFlags(original)) && + (!lang || isSameNativeObject(lang, original.lang)) /* TODO: no getter for ctor */ ) { return original; } const update = updateThenAttach( - ClassDefinition.updateClassDefinition, + ClassDefinition.update3ClassDefinition, (node: ClassDefinition, original: ClassDefinition) => node.setAnnotations(original.annotations) ); return update( @@ -68,6 +71,8 @@ export function updateClassDefinition( superClass, body, modifiers, - flags + flags, + lang ?? original.lang ); } + \ No newline at end of file diff --git a/koala-wrapper/src/generated/Es2pandaEnums.ts b/koala-wrapper/src/generated/Es2pandaEnums.ts index c69ad468ea67c9df733091e5769d7894063e4ee2..249570dde713bc41e5c4f5b713fcddfb072058a4 100644 --- a/koala-wrapper/src/generated/Es2pandaEnums.ts +++ b/koala-wrapper/src/generated/Es2pandaEnums.ts @@ -1094,4 +1094,4 @@ export enum Es2pandaCheckDecision { export enum Es2pandaCheckAction { CHECK_ACTION_CONTINUE = 0, CHECK_ACTION_SKIP_SUBTREE = 1 -} +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ClassDefinition.ts b/koala-wrapper/src/generated/peers/ClassDefinition.ts index fe51f912be9594aa2f104ce7e9172eaedd3c7141..2da37bb63be51a2acdcae6602d829f1bd109f27e 100644 --- a/koala-wrapper/src/generated/peers/ClassDefinition.ts +++ b/koala-wrapper/src/generated/peers/ClassDefinition.ts @@ -42,6 +42,7 @@ import { TSEnumDeclaration } from "./TSEnumDeclaration" import { ClassDeclaration } from "./ClassDeclaration" import { FunctionExpression } from "./FunctionExpression" import { AnnotationUsage } from "./AnnotationUsage" +import { Es2pandaLanguage } from "../../Es2pandaEnums" export class ClassDefinition extends TypedAstNode { constructor(pointer: KNativePointer) { assertValidPeer(pointer, Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DEFINITION) @@ -66,6 +67,12 @@ export class ClassDefinition extends TypedAstNode { static update2ClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition2(global.context, passNode(original), passNode(ident), modifiers, flags)) } + static create3ClassDefinition(ident: Identifier | undefined, typeParams: TSTypeParameterDeclaration | undefined, superTypeParams: TSTypeParameterInstantiation | undefined, _implements: readonly TSClassImplements[], ctor: MethodDefinition | undefined, superClass: Expression | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags, lang: Es2pandaLanguage): ClassDefinition { + return new ClassDefinition(global.es2panda._CreateClassDefinition3(global.context, passNode(ident), passNode(typeParams), passNode(superTypeParams), passNodeArray(_implements), _implements.length, passNode(ctor), passNode(superClass), passNodeArray(body), body.length, modifiers, flags, lang)) + } + static update3ClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, typeParams: TSTypeParameterDeclaration | undefined, superTypeParams: TSTypeParameterInstantiation | undefined, _implements: readonly TSClassImplements[], ctor: MethodDefinition | undefined, superClass: Expression | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags, lang: Es2pandaLanguage): ClassDefinition { + return new ClassDefinition(global.es2panda._UpdateClassDefinition3(global.context, passNode(original), passNode(ident), passNode(typeParams), passNode(superTypeParams), passNodeArray(_implements), _implements.length, passNode(ctor), passNode(superClass), passNodeArray(body), body.length, modifiers, flags, lang)) + } get ident(): Identifier | undefined { return unpackNode(global.generatedEs2panda._ClassDefinitionIdentConst(global.context, this.peer)) } @@ -213,6 +220,9 @@ export class ClassDefinition extends TypedAstNode { global.generatedEs2panda._ClassDefinitionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) return this } + get lang(): Es2pandaLanguage { + return global.es2panda._ClassDefinitionLanguageConst(global.context, this.peer); + } } export function isClassDefinition(node: AstNode): node is ClassDefinition { return node instanceof ClassDefinition