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 { AnnotatedExpression } from "./AnnotatedExpression" 33import { Expression } from "./Expression" 34import { Decorator } from "./Decorator" 35import { ValidationInfo } from "./ValidationInfo" 36import { TypeNode } from "./TypeNode" 37import { Es2pandaObjectTypeKind } from "../Es2pandaEnums" 38import { Property } from "./Property" 39export class ObjectExpression extends AnnotatedExpression { 40 constructor(pointer: KNativePointer) { 41 super(pointer) 42 43 } 44 get properties(): readonly Expression[] { 45 return unpackNodeArray(global.generatedEs2panda._ObjectExpressionPropertiesConst(global.context, this.peer)) 46 } 47 get isDeclaration(): boolean { 48 return global.generatedEs2panda._ObjectExpressionIsDeclarationConst(global.context, this.peer) 49 } 50 get isOptional(): boolean { 51 return global.generatedEs2panda._ObjectExpressionIsOptionalConst(global.context, this.peer) 52 } 53 get decorators(): readonly Decorator[] { 54 return unpackNodeArray(global.generatedEs2panda._ObjectExpressionDecoratorsConst(global.context, this.peer)) 55 } 56 /** @deprecated */ 57 setDeclaration(): this { 58 global.generatedEs2panda._ObjectExpressionSetDeclaration(global.context, this.peer) 59 return this 60 } 61 /** @deprecated */ 62 setOptional(optional_arg: boolean): this { 63 global.generatedEs2panda._ObjectExpressionSetOptional(global.context, this.peer, optional_arg) 64 return this 65 } 66 get typeAnnotation(): TypeNode | undefined { 67 return unpackNode(global.generatedEs2panda._ObjectExpressionTypeAnnotationConst(global.context, this.peer)) 68 } 69 /** @deprecated */ 70 setTsTypeAnnotation(typeAnnotation: TypeNode): this { 71 global.generatedEs2panda._ObjectExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) 72 return this 73 } 74 static createObjectExpression(nodeType: Es2pandaAstNodeType, properties: Property[], trailingComma: boolean): ObjectExpression { 75 return new ObjectExpression(global.generatedEs2panda._CreateObjectExpression(global.context, nodeType, passNodeArray(properties), properties.length, trailingComma)) 76 } 77 static updateObjectExpression(original: ObjectExpression, nodeType: Es2pandaAstNodeType, properties: Property[], trailingComma: boolean): ObjectExpression { 78 return new ObjectExpression(global.generatedEs2panda._UpdateObjectExpression(global.context, passNode(original), nodeType, passNodeArray(properties), properties.length, trailingComma)) 79 } 80} 81export function isObjectExpression(node: AstNode): node is ObjectExpression { 82 return node instanceof ObjectExpression 83}