1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { 17 global, 18 passNode, 19 passNodeArray, 20 unpackNonNullableNode, 21 unpackNode, 22 unpackNodeArray, 23 assertValidPeer, 24 AstNode, 25 Es2pandaAstNodeType, 26 KNativePointer, 27 nodeByType, 28 ArktsObject, 29 unpackString 30} from "../../reexport-for-generated" 31 32import { TypedStatement } from "./TypedStatement" 33import { TSInterfaceHeritage } from "./TSInterfaceHeritage" 34import { TSInterfaceBody } from "./TSInterfaceBody" 35import { Identifier } from "./Identifier" 36import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" 37import { Decorator } from "./Decorator" 38import { ClassDeclaration } from "./ClassDeclaration" 39import { AnnotationUsage } from "./AnnotationUsage" 40export class TSInterfaceDeclaration extends TypedStatement { 41 constructor(pointer: KNativePointer) { 42 assertValidPeer(pointer, Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERFACE_DECLARATION) 43 super(pointer) 44 45 } 46 static createTSInterfaceDeclaration(_extends: readonly TSInterfaceHeritage[], id: AstNode | undefined, typeParams: AstNode | undefined, body: AstNode | undefined, isStatic: boolean, isExternal: boolean): TSInterfaceDeclaration { 47 return new TSInterfaceDeclaration(global.generatedEs2panda._CreateTSInterfaceDeclaration(global.context, passNodeArray(_extends), _extends.length, passNode(id), passNode(typeParams), passNode(body), isStatic, isExternal)) 48 } 49 static updateTSInterfaceDeclaration(original: TSInterfaceDeclaration | undefined, _extends: readonly TSInterfaceHeritage[], id: AstNode | undefined, typeParams: AstNode | undefined, body: AstNode | undefined, isStatic: boolean, isExternal: boolean): TSInterfaceDeclaration { 50 return new TSInterfaceDeclaration(global.generatedEs2panda._UpdateTSInterfaceDeclaration(global.context, passNode(original), passNodeArray(_extends), _extends.length, passNode(id), passNode(typeParams), passNode(body), isStatic, isExternal)) 51 } 52 get body(): TSInterfaceBody | undefined { 53 return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationBodyConst(global.context, this.peer)) 54 } 55 get id(): Identifier | undefined { 56 return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationIdConst(global.context, this.peer)) 57 } 58 get internalName(): string { 59 return unpackString(global.generatedEs2panda._TSInterfaceDeclarationInternalNameConst(global.context, this.peer)) 60 } 61 /** @deprecated */ 62 setInternalName(internalName: string): this { 63 global.generatedEs2panda._TSInterfaceDeclarationSetInternalName(global.context, this.peer, internalName) 64 return this 65 } 66 get isStatic(): boolean { 67 return global.generatedEs2panda._TSInterfaceDeclarationIsStaticConst(global.context, this.peer) 68 } 69 get isFromExternal(): boolean { 70 return global.generatedEs2panda._TSInterfaceDeclarationIsFromExternalConst(global.context, this.peer) 71 } 72 get typeParams(): TSTypeParameterDeclaration | undefined { 73 return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationTypeParamsConst(global.context, this.peer)) 74 } 75 get extends(): readonly TSInterfaceHeritage[] { 76 return unpackNodeArray(global.generatedEs2panda._TSInterfaceDeclarationExtendsConst(global.context, this.peer)) 77 } 78 get decorators(): readonly Decorator[] { 79 return unpackNodeArray(global.generatedEs2panda._TSInterfaceDeclarationDecoratorsConst(global.context, this.peer)) 80 } 81 get getAnonClass(): ClassDeclaration | undefined { 82 return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationGetAnonClassConst(global.context, this.peer)) 83 } 84 /** @deprecated */ 85 setAnonClass(anonClass: ClassDeclaration): this { 86 global.generatedEs2panda._TSInterfaceDeclarationSetAnonClass(global.context, this.peer, passNode(anonClass)) 87 return this 88 } 89 get annotations(): readonly AnnotationUsage[] { 90 return unpackNodeArray(global.generatedEs2panda._TSInterfaceDeclarationAnnotationsConst(global.context, this.peer)) 91 } 92 /** @deprecated */ 93 setAnnotations(annotations: readonly AnnotationUsage[]): this { 94 global.generatedEs2panda._TSInterfaceDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) 95 return this 96 } 97} 98export function isTSInterfaceDeclaration(node: AstNode): node is TSInterfaceDeclaration { 99 return node instanceof TSInterfaceDeclaration 100} 101if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERFACE_DECLARATION)) { 102 nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERFACE_DECLARATION, TSInterfaceDeclaration) 103} 104