• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 { TypedAstNode } from "./TypedAstNode"
33import { Identifier } from "./Identifier"
34import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration"
35import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation"
36import { TSClassImplements } from "./TSClassImplements"
37import { MethodDefinition } from "./MethodDefinition"
38import { Expression } from "./Expression"
39import { Es2pandaClassDefinitionModifiers } from "./../Es2pandaEnums"
40import { Es2pandaModifierFlags } from "./../Es2pandaEnums"
41import { TSEnumDeclaration } from "./TSEnumDeclaration"
42import { ClassDeclaration } from "./ClassDeclaration"
43import { FunctionExpression } from "./FunctionExpression"
44import { AnnotationUsage } from "./AnnotationUsage"
45export class ClassDefinition extends TypedAstNode {
46     constructor(pointer: KNativePointer) {
47        assertValidPeer(pointer, Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DEFINITION)
48        super(pointer)
49
50    }
51    static createClassDefinition(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): ClassDefinition {
52        return new ClassDefinition(global.generatedEs2panda._CreateClassDefinition(global.context, passNode(ident), passNode(typeParams), passNode(superTypeParams), passNodeArray(_implements), _implements.length, passNode(ctor), passNode(superClass), passNodeArray(body), body.length, modifiers, flags))
53    }
54    static updateClassDefinition(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): ClassDefinition {
55        return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition(global.context, passNode(original), passNode(ident), passNode(typeParams), passNode(superTypeParams), passNodeArray(_implements), _implements.length, passNode(ctor), passNode(superClass), passNodeArray(body), body.length, modifiers, flags))
56    }
57    static create1ClassDefinition(ident: Identifier | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition {
58        return new ClassDefinition(global.generatedEs2panda._CreateClassDefinition1(global.context, passNode(ident), passNodeArray(body), body.length, modifiers, flags))
59    }
60    static update1ClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition {
61        return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition1(global.context, passNode(original), passNode(ident), passNodeArray(body), body.length, modifiers, flags))
62    }
63    static create2ClassDefinition(ident: Identifier | undefined, modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition {
64        return new ClassDefinition(global.generatedEs2panda._CreateClassDefinition2(global.context, passNode(ident), modifiers, flags))
65    }
66    static update2ClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition {
67        return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition2(global.context, passNode(original), passNode(ident), modifiers, flags))
68    }
69    get ident(): Identifier | undefined {
70        return unpackNode(global.generatedEs2panda._ClassDefinitionIdentConst(global.context, this.peer))
71    }
72    /** @deprecated */
73    setIdent(ident: Identifier): this {
74        global.generatedEs2panda._ClassDefinitionSetIdent(global.context, this.peer, passNode(ident))
75        return this
76    }
77    get internalName(): string {
78        return unpackString(global.generatedEs2panda._ClassDefinitionInternalNameConst(global.context, this.peer))
79    }
80    /** @deprecated */
81    setInternalName(internalName: string): this {
82        global.generatedEs2panda._ClassDefinitionSetInternalName(global.context, this.peer, internalName)
83        return this
84    }
85    get super(): Expression | undefined {
86        return unpackNode(global.generatedEs2panda._ClassDefinitionSuperConst(global.context, this.peer))
87    }
88    /** @deprecated */
89    setSuper(superClass: Expression): this {
90        global.generatedEs2panda._ClassDefinitionSetSuper(global.context, this.peer, passNode(superClass))
91        return this
92    }
93    get isGlobal(): boolean {
94        return global.generatedEs2panda._ClassDefinitionIsGlobalConst(global.context, this.peer)
95    }
96    get isLocal(): boolean {
97        return global.generatedEs2panda._ClassDefinitionIsLocalConst(global.context, this.peer)
98    }
99    get isExtern(): boolean {
100        return global.generatedEs2panda._ClassDefinitionIsExternConst(global.context, this.peer)
101    }
102    get isFromExternal(): boolean {
103        return global.generatedEs2panda._ClassDefinitionIsFromExternalConst(global.context, this.peer)
104    }
105    get isInner(): boolean {
106        return global.generatedEs2panda._ClassDefinitionIsInnerConst(global.context, this.peer)
107    }
108    get isGlobalInitialized(): boolean {
109        return global.generatedEs2panda._ClassDefinitionIsGlobalInitializedConst(global.context, this.peer)
110    }
111    get isClassDefinitionChecked(): boolean {
112        return global.generatedEs2panda._ClassDefinitionIsClassDefinitionCheckedConst(global.context, this.peer)
113    }
114    get isAnonymous(): boolean {
115        return global.generatedEs2panda._ClassDefinitionIsAnonymousConst(global.context, this.peer)
116    }
117    get isNamespaceTransformed(): boolean {
118        return global.generatedEs2panda._ClassDefinitionIsNamespaceTransformedConst(global.context, this.peer)
119    }
120    get isModule(): boolean {
121        return global.generatedEs2panda._ClassDefinitionIsModuleConst(global.context, this.peer)
122    }
123    /** @deprecated */
124    setGlobalInitialized(): this {
125        global.generatedEs2panda._ClassDefinitionSetGlobalInitialized(global.context, this.peer)
126        return this
127    }
128    /** @deprecated */
129    setInnerModifier(): this {
130        global.generatedEs2panda._ClassDefinitionSetInnerModifier(global.context, this.peer)
131        return this
132    }
133    /** @deprecated */
134    setClassDefinitionChecked(): this {
135        global.generatedEs2panda._ClassDefinitionSetClassDefinitionChecked(global.context, this.peer)
136        return this
137    }
138    /** @deprecated */
139    setAnonymousModifier(): this {
140        global.generatedEs2panda._ClassDefinitionSetAnonymousModifier(global.context, this.peer)
141        return this
142    }
143    /** @deprecated */
144    setNamespaceTransformed(): this {
145        global.generatedEs2panda._ClassDefinitionSetNamespaceTransformed(global.context, this.peer)
146        return this
147    }
148    get modifiers(): Es2pandaClassDefinitionModifiers {
149        return global.generatedEs2panda._ClassDefinitionModifiersConst(global.context, this.peer)
150    }
151    /** @deprecated */
152    setModifiers(modifiers: Es2pandaClassDefinitionModifiers): this {
153        global.generatedEs2panda._ClassDefinitionSetModifiers(global.context, this.peer, modifiers)
154        return this
155    }
156    /** @deprecated */
157    addProperties(body: readonly AstNode[]): this {
158        global.generatedEs2panda._ClassDefinitionAddProperties(global.context, this.peer, passNodeArray(body), body.length)
159        return this
160    }
161    get body(): readonly AstNode[] {
162        return unpackNodeArray(global.generatedEs2panda._ClassDefinitionBodyConst(global.context, this.peer))
163    }
164    /** @deprecated */
165    setCtor(ctor: MethodDefinition): this {
166        global.generatedEs2panda._ClassDefinitionSetCtor(global.context, this.peer, passNode(ctor))
167        return this
168    }
169    get implements(): readonly TSClassImplements[] {
170        return unpackNodeArray(global.generatedEs2panda._ClassDefinitionImplementsConst(global.context, this.peer))
171    }
172    get typeParams(): TSTypeParameterDeclaration | undefined {
173        return unpackNode(global.generatedEs2panda._ClassDefinitionTypeParamsConst(global.context, this.peer))
174    }
175    /** @deprecated */
176    setTypeParams(typeParams: TSTypeParameterDeclaration): this {
177        global.generatedEs2panda._ClassDefinitionSetTypeParams(global.context, this.peer, passNode(typeParams))
178        return this
179    }
180    get superTypeParams(): TSTypeParameterInstantiation | undefined {
181        return unpackNode(global.generatedEs2panda._ClassDefinitionSuperTypeParamsConst(global.context, this.peer))
182    }
183    get localTypeCounter(): number {
184        return global.generatedEs2panda._ClassDefinitionLocalTypeCounter(global.context, this.peer)
185    }
186    get localIndex(): number {
187        return global.generatedEs2panda._ClassDefinitionLocalIndexConst(global.context, this.peer)
188    }
189    get localPrefix(): string {
190        return unpackString(global.generatedEs2panda._ClassDefinitionLocalPrefixConst(global.context, this.peer))
191    }
192    /** @deprecated */
193    setOrigEnumDecl(enumDecl: TSEnumDeclaration): this {
194        global.generatedEs2panda._ClassDefinitionSetOrigEnumDecl(global.context, this.peer, passNode(enumDecl))
195        return this
196    }
197    get origEnumDecl(): TSEnumDeclaration | undefined {
198        return unpackNode(global.generatedEs2panda._ClassDefinitionOrigEnumDeclConst(global.context, this.peer))
199    }
200    get getAnonClass(): ClassDeclaration | undefined {
201        return unpackNode(global.generatedEs2panda._ClassDefinitionGetAnonClass(global.context, this.peer))
202    }
203    /** @deprecated */
204    setAnonClass(anonClass: ClassDeclaration): this {
205        global.generatedEs2panda._ClassDefinitionSetAnonClass(global.context, this.peer, passNode(anonClass))
206        return this
207    }
208    get annotations(): readonly AnnotationUsage[] {
209        return unpackNodeArray(global.generatedEs2panda._ClassDefinitionAnnotationsConst(global.context, this.peer))
210    }
211    /** @deprecated */
212    setAnnotations(annotations: readonly AnnotationUsage[]): this {
213        global.generatedEs2panda._ClassDefinitionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length)
214        return this
215    }
216}
217export function isClassDefinition(node: AstNode): node is ClassDefinition {
218    return node instanceof ClassDefinition
219}
220if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DEFINITION)) {
221    nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DEFINITION, ClassDefinition)
222}
223