UNPKG

@ts-for-gir/lib

Version:

Typescript .d.ts generator from GIR for gjs

43 lines 1.41 kB
import { IntrospectedNamespaceMember } from "./base.js"; import { getType, parseDoc, parseMetadata, sanitizeIdentifierName } from "./util.js"; export class IntrospectedConstant extends IntrospectedNamespaceMember { type; value; constructor({ name, type, namespace, value, ...options }) { super(name, namespace, options); this.type = type; this.value = value; } accept(visitor) { const node = this.copy({ type: visitor.visitType?.(this.type) }); return visitor.visitConst?.(node) ?? node; } copy(options = {}) { const { type, name, value } = this; return new IntrospectedConstant({ name, namespace: options.parent ?? this.namespace, type: options.type ?? type, value })._copyBaseProperties(this); } static fromXML(element, ns, options) { const c = new IntrospectedConstant({ name: sanitizeIdentifierName(ns.namespace, element.$.name), namespace: ns, type: getType(ns, element), value: element.$.value ?? null }); if (options.loadDocs) { c.doc = parseDoc(element); c.metadata = parseMetadata(element); } return c; } asString(generator) { return generator.generateConst(this); } } //# sourceMappingURL=const.js.map