@gtkx/codegen 1.0.0-rc.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -9
- package/dist/analysis/descriptor-render.d.ts +9 -4
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +51 -61
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +7 -7
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +7 -7
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/inheritance.d.ts +1 -2
- package/dist/analysis/inheritance.d.ts.map +1 -1
- package/dist/analysis/inheritance.js +25 -22
- package/dist/analysis/inheritance.js.map +1 -1
- package/dist/analysis/nul-terminated-bytes.d.ts +5 -0
- package/dist/analysis/nul-terminated-bytes.d.ts.map +1 -0
- package/dist/analysis/nul-terminated-bytes.js +18 -0
- package/dist/analysis/nul-terminated-bytes.js.map +1 -0
- package/dist/analysis/param-capability.d.ts +5 -0
- package/dist/analysis/param-capability.d.ts.map +1 -0
- package/dist/analysis/param-capability.js +130 -0
- package/dist/analysis/param-capability.js.map +1 -0
- package/dist/analysis/param-structure.d.ts +13 -6
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +44 -20
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +3 -5
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/analysis/type-shape.d.ts +8 -0
- package/dist/analysis/type-shape.d.ts.map +1 -0
- package/dist/analysis/type-shape.js +12 -0
- package/dist/analysis/type-shape.js.map +1 -0
- package/dist/compile.d.ts +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +2 -1
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +79 -3
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +68 -13
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/element-page.d.ts +4 -4
- package/dist/docs/element-page.d.ts.map +1 -1
- package/dist/docs/element-page.js +32 -20
- package/dist/docs/element-page.js.map +1 -1
- package/dist/docs/handwritten-props.d.ts +9 -0
- package/dist/docs/handwritten-props.d.ts.map +1 -0
- package/dist/docs/handwritten-props.js +149 -0
- package/dist/docs/handwritten-props.js.map +1 -0
- package/dist/docs/pipeline.d.ts +4 -4
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +6 -6
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.d.ts +25 -5
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +90 -28
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts +22 -0
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +129 -44
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +3 -6
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +6 -8
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +3 -11
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +0 -7
- package/dist/gi.js.map +1 -1
- package/dist/gir/ancestry.d.ts +2 -2
- package/dist/gir/ancestry.d.ts.map +1 -1
- package/dist/gir/ancestry.js +11 -1
- package/dist/gir/ancestry.js.map +1 -1
- package/dist/gir/annotations.d.ts +22 -0
- package/dist/gir/annotations.d.ts.map +1 -0
- package/dist/gir/annotations.js +15 -0
- package/dist/gir/annotations.js.map +1 -0
- package/dist/gir/callback.d.ts +1 -0
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +1 -0
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +32 -1
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +8 -3
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +21 -1
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +9 -9
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +19 -4
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +7 -11
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/function.d.ts +15 -0
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/gir-path.d.ts +7 -0
- package/dist/gir/gir-path.d.ts.map +1 -1
- package/dist/gir/gir-path.js +7 -0
- package/dist/gir/gir-path.js.map +1 -1
- package/dist/gir/libraries.d.ts +13 -2
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +11 -0
- package/dist/gir/libraries.js.map +1 -1
- package/dist/gir/library.d.ts +36 -0
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +34 -0
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/namespace.d.ts +38 -0
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +4 -5
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/parameter.d.ts +39 -0
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +7 -7
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts +3 -1
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +6 -3
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +1 -0
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +16 -0
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +3 -3
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +22 -0
- package/dist/gir/record.d.ts.map +1 -1
- package/dist/gir/record.js +3 -2
- package/dist/gir/record.js.map +1 -1
- package/dist/gir/size.d.ts +5 -4
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +0 -3
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +36 -1
- package/dist/gir/type-id.d.ts.map +1 -1
- package/dist/gir/type-id.js +2 -3
- package/dist/gir/type-id.js.map +1 -1
- package/dist/gir/type-ref.d.ts.map +1 -1
- package/dist/gir/type-ref.js +2 -1
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/gir/type.d.ts +20 -0
- package/dist/gir/type.d.ts.map +1 -1
- package/dist/gir/type.js.map +1 -1
- package/dist/index.d.ts +18 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -0
- package/dist/jsx.d.ts +7 -12
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +18 -19
- package/dist/jsx.js.map +1 -1
- package/dist/khronos/args.d.ts +7 -6
- package/dist/khronos/args.d.ts.map +1 -1
- package/dist/khronos/args.js +29 -7
- package/dist/khronos/args.js.map +1 -1
- package/dist/khronos/doc-context.d.ts +29 -0
- package/dist/khronos/doc-context.d.ts.map +1 -0
- package/dist/khronos/doc-context.js +29 -0
- package/dist/khronos/doc-context.js.map +1 -0
- package/dist/khronos/extensions.d.ts +13 -0
- package/dist/khronos/extensions.d.ts.map +1 -0
- package/dist/khronos/extensions.js +49 -0
- package/dist/khronos/extensions.js.map +1 -0
- package/dist/khronos/jsdoc.d.ts +17 -11
- package/dist/khronos/jsdoc.d.ts.map +1 -1
- package/dist/khronos/jsdoc.js +104 -46
- package/dist/khronos/jsdoc.js.map +1 -1
- package/dist/khronos/model.d.ts +42 -3
- package/dist/khronos/model.d.ts.map +1 -1
- package/dist/khronos/model.js +218 -63
- package/dist/khronos/model.js.map +1 -1
- package/dist/khronos/modules.d.ts +9 -6
- package/dist/khronos/modules.d.ts.map +1 -1
- package/dist/khronos/modules.js +96 -26
- package/dist/khronos/modules.js.map +1 -1
- package/dist/khronos/notes.d.ts +19 -0
- package/dist/khronos/notes.d.ts.map +1 -0
- package/dist/khronos/notes.js +35 -0
- package/dist/khronos/notes.js.map +1 -0
- package/dist/khronos/param-pair.d.ts +1 -1
- package/dist/khronos/param-pair.d.ts.map +1 -1
- package/dist/khronos/param-pair.js.map +1 -1
- package/dist/khronos/pipeline.d.ts +3 -1
- package/dist/khronos/pipeline.d.ts.map +1 -1
- package/dist/khronos/pipeline.js +59 -28
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +5 -5
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +8 -8
- package/dist/khronos/plan.js.map +1 -1
- package/dist/khronos/render.d.ts +8 -6
- package/dist/khronos/render.d.ts.map +1 -1
- package/dist/khronos/render.js +35 -26
- package/dist/khronos/render.js.map +1 -1
- package/dist/khronos/select.d.ts +21 -4
- package/dist/khronos/select.d.ts.map +1 -1
- package/dist/khronos/select.js +47 -34
- package/dist/khronos/select.js.map +1 -1
- package/dist/react/element-config.d.ts +16 -10
- package/dist/react/element-config.d.ts.map +1 -1
- package/dist/react/element-config.js +22 -15
- package/dist/react/element-config.js.map +1 -1
- package/dist/runner.d.ts +33 -21
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +19 -20
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +2 -3
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +2 -2
- package/dist/store/compile-store.js.map +1 -1
- package/dist/store/gi/callable-doc.d.ts +11 -0
- package/dist/store/gi/callable-doc.d.ts.map +1 -0
- package/dist/store/gi/callable-doc.js +62 -0
- package/dist/store/gi/callable-doc.js.map +1 -0
- package/dist/store/gi/callables.d.ts +3 -1
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +16 -16
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/callback.d.ts.map +1 -1
- package/dist/store/gi/callback.js +2 -2
- package/dist/store/gi/callback.js.map +1 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +5 -3
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/closure-invocation.d.ts +4 -0
- package/dist/store/gi/closure-invocation.d.ts.map +1 -0
- package/dist/store/gi/closure-invocation.js +22 -0
- package/dist/store/gi/closure-invocation.js.map +1 -0
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +3 -4
- package/dist/store/gi/constant.js.map +1 -1
- package/dist/store/gi/constructor-props.d.ts.map +1 -1
- package/dist/store/gi/constructor-props.js +18 -20
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/doc-spec.d.ts +14 -0
- package/dist/store/gi/doc-spec.d.ts.map +1 -0
- package/dist/store/gi/doc-spec.js +23 -0
- package/dist/store/gi/doc-spec.js.map +1 -0
- package/dist/store/gi/enum.d.ts.map +1 -1
- package/dist/store/gi/enum.js +29 -16
- package/dist/store/gi/enum.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +28 -17
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/interface.d.ts.map +1 -1
- package/dist/store/gi/interface.js +130 -16
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/item-comparators.d.ts.map +1 -1
- package/dist/store/gi/item-comparators.js +3 -5
- package/dist/store/gi/item-comparators.js.map +1 -1
- package/dist/store/gi/method.d.ts +9 -1
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +92 -47
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +4 -1
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +5 -1
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/pipeline.d.ts.map +1 -1
- package/dist/store/gi/pipeline.js +3 -2
- package/dist/store/gi/pipeline.js.map +1 -1
- package/dist/store/gi/properties.d.ts.map +1 -1
- package/dist/store/gi/properties.js +2 -2
- package/dist/store/gi/properties.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +4 -2
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +10 -11
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +3 -1
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +4 -2
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +6 -11
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +1 -5
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +3 -2
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/registration.d.ts +1 -1
- package/dist/store/gi/registration.js +2 -2
- package/dist/store/gi/registration.js.map +1 -1
- package/dist/store/gi/return-wrap.d.ts +1 -1
- package/dist/store/gi/return-wrap.d.ts.map +1 -1
- package/dist/store/gi/return-wrap.js +4 -4
- package/dist/store/gi/return-wrap.js.map +1 -1
- package/dist/store/gi/runtime-override.d.ts +2 -1
- package/dist/store/gi/runtime-override.d.ts.map +1 -1
- package/dist/store/gi/runtime-override.js +8 -5
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +27 -31
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/value-marshalable.d.ts +1 -10
- package/dist/store/gi/value-marshalable.d.ts.map +1 -1
- package/dist/store/gi/value-marshalable.js +1 -10
- package/dist/store/gi/value-marshalable.js.map +1 -1
- package/dist/store/gi/vtable.d.ts +16 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +214 -51
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +2 -3
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/element-components.d.ts +1 -3
- package/dist/store/jsx/element-components.d.ts.map +1 -1
- package/dist/store/jsx/element-components.js +6 -8
- package/dist/store/jsx/element-components.js.map +1 -1
- package/dist/store/jsx/element-prop-imports.d.ts +1 -4
- package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-imports.js +0 -2
- package/dist/store/jsx/element-prop-imports.js.map +1 -1
- package/dist/store/jsx/element-prop-types.d.ts +3 -1
- package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-types.js +7 -2
- package/dist/store/jsx/element-prop-types.js.map +1 -1
- package/dist/store/jsx/generated-elements.d.ts +29 -0
- package/dist/store/jsx/generated-elements.d.ts.map +1 -0
- package/dist/store/jsx/generated-elements.js +30 -0
- package/dist/store/jsx/generated-elements.js.map +1 -0
- package/dist/store/jsx/intrinsic-elements.d.ts +4 -0
- package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -1
- package/dist/store/jsx/intrinsic-elements.js.map +1 -1
- package/dist/store/jsx/jsx.d.ts.map +1 -1
- package/dist/store/jsx/jsx.js +13 -12
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx/metadata.js +9 -9
- package/dist/store/jsx/metadata.js.map +1 -1
- package/dist/store/jsx/omitted-props.d.ts +2 -4
- package/dist/store/jsx/omitted-props.d.ts.map +1 -1
- package/dist/store/jsx/omitted-props.js +2 -4
- package/dist/store/jsx/omitted-props.js.map +1 -1
- package/dist/store/jsx/pipeline.d.ts +4 -2
- package/dist/store/jsx/pipeline.d.ts.map +1 -1
- package/dist/store/jsx/pipeline.js +3 -2
- package/dist/store/jsx/pipeline.js.map +1 -1
- package/dist/store/jsx/props.d.ts +1 -7
- package/dist/store/jsx/props.d.ts.map +1 -1
- package/dist/store/jsx/props.js +16 -8
- package/dist/store/jsx/props.js.map +1 -1
- package/dist/store/jsx-store.d.ts +2 -3
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +3 -3
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/resolve-store.d.ts +28 -0
- package/dist/store/resolve-store.d.ts.map +1 -0
- package/dist/store/resolve-store.js +65 -0
- package/dist/store/resolve-store.js.map +1 -0
- package/dist/store/store-fs.d.ts +5 -1
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +6 -4
- package/dist/store/store-fs.js.map +1 -1
- package/dist/writer/context.d.ts +2 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +3 -0
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/doc-tags.d.ts +21 -0
- package/dist/writer/doc-tags.d.ts.map +1 -0
- package/dist/writer/doc-tags.js +38 -0
- package/dist/writer/doc-tags.js.map +1 -0
- package/dist/writer/doc.d.ts +3 -1
- package/dist/writer/doc.d.ts.map +1 -1
- package/dist/writer/doc.js +19 -6
- package/dist/writer/doc.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts +1 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +64 -15
- package/dist/writer/gtk-doc.js.map +1 -1
- package/dist/writer/module.d.ts +8 -2
- package/dist/writer/module.d.ts.map +1 -1
- package/dist/writer/module.js +13 -1
- package/dist/writer/module.js.map +1 -1
- package/overrides/gdk/rgba.ts.ejs +26 -0
- package/overrides/gobject/object.ts.ejs +56 -11
- package/overrides/gobject/value.ts.ejs +7 -0
- package/overrides/graphene/structs.ts.ejs +55 -0
- package/package.json +7 -11
- package/src/analysis/descriptor-render.ts +67 -73
- package/src/analysis/descriptor.ts +13 -16
- package/src/analysis/inheritance.ts +35 -34
- package/src/analysis/nul-terminated-bytes.ts +31 -0
- package/src/analysis/param-capability.ts +172 -0
- package/src/analysis/param-structure.ts +90 -32
- package/src/analysis/ts-type.ts +4 -6
- package/src/analysis/type-shape.ts +24 -0
- package/src/compile.ts +3 -2
- package/src/docs/api-reference.ts +162 -28
- package/src/docs/element-page.ts +53 -47
- package/src/docs/handwritten-props.ts +230 -0
- package/src/docs/pipeline.ts +10 -10
- package/src/docs/render.ts +153 -39
- package/src/docs/symbol-page.ts +230 -80
- package/src/fingerprint.ts +8 -14
- package/src/gi.ts +4 -11
- package/src/gir/ancestry.ts +15 -1
- package/src/gir/annotations.ts +37 -0
- package/src/gir/callback.ts +2 -0
- package/src/gir/class.ts +42 -4
- package/src/gir/enum.ts +30 -10
- package/src/gir/field.ts +24 -13
- package/src/gir/function.ts +15 -0
- package/src/gir/gir-path.ts +7 -0
- package/src/gir/libraries.ts +23 -2
- package/src/gir/library.ts +51 -2
- package/src/gir/namespace.ts +41 -5
- package/src/gir/parameter.ts +47 -7
- package/src/gir/parse.ts +8 -2
- package/src/gir/primitives.ts +1 -0
- package/src/gir/property.ts +18 -3
- package/src/gir/record.ts +24 -2
- package/src/gir/size.ts +8 -6
- package/src/gir/type-id.ts +51 -7
- package/src/gir/type-ref.ts +2 -1
- package/src/gir/type.ts +50 -6
- package/src/index.ts +18 -16
- package/src/internal.ts +2 -0
- package/src/jsx.ts +26 -26
- package/src/khronos/args.ts +37 -14
- package/src/khronos/doc-context.ts +62 -0
- package/src/khronos/extensions.ts +85 -0
- package/src/khronos/jsdoc.ts +152 -56
- package/src/khronos/model.ts +314 -69
- package/src/khronos/modules.ts +134 -40
- package/src/khronos/notes.ts +74 -0
- package/src/khronos/param-pair.ts +1 -1
- package/src/khronos/pipeline.ts +95 -42
- package/src/khronos/plan.ts +12 -13
- package/src/khronos/render.ts +62 -50
- package/src/khronos/select.ts +91 -50
- package/src/react/element-config.ts +21 -18
- package/src/runner.ts +51 -40
- package/src/store/compile-store.ts +4 -5
- package/src/store/gi/callable-doc.ts +102 -0
- package/src/store/gi/callables.ts +23 -17
- package/src/store/gi/callback.ts +3 -2
- package/src/store/gi/class.ts +6 -3
- package/src/store/gi/closure-invocation.ts +26 -0
- package/src/store/gi/constant.ts +3 -6
- package/src/store/gi/constructor-props.ts +19 -23
- package/src/store/gi/doc-spec.ts +38 -0
- package/src/store/gi/enum.ts +55 -20
- package/src/store/gi/function.ts +44 -26
- package/src/store/gi/interface.ts +214 -26
- package/src/store/gi/item-comparators.ts +3 -5
- package/src/store/gi/method.ts +126 -68
- package/src/store/gi/param-marshal.ts +15 -1
- package/src/store/gi/pipeline.ts +7 -2
- package/src/store/gi/properties.ts +3 -2
- package/src/store/gi/property-accessor.ts +14 -11
- package/src/store/gi/record-constructor.ts +6 -1
- package/src/store/gi/record-field-accessor.ts +9 -13
- package/src/store/gi/record-layout.ts +1 -5
- package/src/store/gi/record.ts +8 -2
- package/src/store/gi/registration.ts +3 -3
- package/src/store/gi/return-wrap.ts +5 -5
- package/src/store/gi/runtime-override.ts +13 -6
- package/src/store/gi/signal.ts +36 -37
- package/src/store/gi/value-marshalable.ts +1 -10
- package/src/store/gi/vtable.ts +361 -60
- package/src/store/gi-store.ts +2 -4
- package/src/store/jsx/element-components.ts +8 -11
- package/src/store/jsx/element-prop-imports.ts +6 -5
- package/src/store/jsx/element-prop-types.ts +10 -2
- package/src/store/jsx/generated-elements.ts +60 -0
- package/src/store/jsx/intrinsic-elements.ts +4 -0
- package/src/store/jsx/jsx.ts +15 -13
- package/src/store/jsx/metadata.ts +10 -10
- package/src/store/jsx/omitted-props.ts +2 -4
- package/src/store/jsx/pipeline.ts +6 -4
- package/src/store/jsx/props.ts +22 -9
- package/src/store/jsx-store.ts +5 -7
- package/src/store/resolve-store.ts +100 -0
- package/src/store/store-fs.ts +12 -5
- package/src/writer/context.ts +5 -1
- package/src/writer/doc-tags.ts +70 -0
- package/src/writer/doc.ts +29 -6
- package/src/writer/gtk-doc.ts +82 -15
- package/src/writer/module.ts +25 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { attr, getDoc, getDocDeprecated, isAttrTrue, nameAttr, type RawNode } from "./parse.js";
|
|
2
|
+
|
|
3
|
+
/** Release and deprecation annotations GIR carries on a documentable element. */
|
|
4
|
+
type GirAnnotations = {
|
|
5
|
+
/** Library release the symbol appeared in, from the `version` attribute. */
|
|
6
|
+
since: string | undefined;
|
|
7
|
+
/** Whether GIR marks the symbol deprecated. */
|
|
8
|
+
isDeprecated: boolean;
|
|
9
|
+
/** Release the symbol was deprecated in, from the `deprecated-version` attribute. */
|
|
10
|
+
deprecatedSince: string | undefined;
|
|
11
|
+
/** Prose from `<doc-deprecated>` naming what to use instead. */
|
|
12
|
+
deprecationDoc: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type DocumentedNode = {
|
|
16
|
+
name: string;
|
|
17
|
+
doc: string | undefined;
|
|
18
|
+
annotations: GirAnnotations;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const annotationsFromNode = (node: RawNode | undefined): GirAnnotations => ({
|
|
22
|
+
since: attr(node, "version"),
|
|
23
|
+
isDeprecated: isAttrTrue(node, "deprecated"),
|
|
24
|
+
deprecatedSince: attr(node, "deprecated-version"),
|
|
25
|
+
deprecationDoc: getDocDeprecated(node),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const documentedFromNode = (node: RawNode): DocumentedNode => ({
|
|
29
|
+
name: nameAttr(node),
|
|
30
|
+
doc: getDoc(node),
|
|
31
|
+
annotations: annotationsFromNode(node),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const hasAnnotations = (annotations: GirAnnotations): boolean =>
|
|
35
|
+
annotations.since !== undefined || annotations.isDeprecated || annotations.deprecatedSince !== undefined;
|
|
36
|
+
|
|
37
|
+
export { annotationsFromNode, documentedFromNode, hasAnnotations, type GirAnnotations };
|
package/src/gir/callback.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { RawNode } from "./parse.js";
|
|
|
3
3
|
import type { ParseContext } from "./type-id.js";
|
|
4
4
|
import { type GirCallable, parseCallable } from "./parameter.js";
|
|
5
5
|
|
|
6
|
+
/** The signature of a function pointer type GIR declares, whether named or anonymous. */
|
|
6
7
|
type GirCallback = GirCallable;
|
|
7
8
|
|
|
8
9
|
const callbackFromNode = (node: RawNode, context: ParseContext): GirCallback => parseCallable(node, context);
|
|
@@ -10,6 +11,7 @@ const callbackFromNode = (node: RawNode, context: ParseContext): GirCallback =>
|
|
|
10
11
|
const callbackAsFunction = (callback: GirCallback): GirFunction => ({
|
|
11
12
|
name: callback.name,
|
|
12
13
|
doc: callback.doc,
|
|
14
|
+
annotations: callback.annotations,
|
|
13
15
|
cIdentifier: undefined,
|
|
14
16
|
movedTo: undefined,
|
|
15
17
|
throws: callback.throws,
|
package/src/gir/class.ts
CHANGED
|
@@ -1,35 +1,72 @@
|
|
|
1
1
|
import type { ParseContext } from "./type-id.js";
|
|
2
|
+
import { documentedFromNode, type GirAnnotations } from "./annotations.js";
|
|
2
3
|
import { functionFromNode, type GirFunction } from "./function.js";
|
|
3
4
|
import { type GirCallable, parseCallable } from "./parameter.js";
|
|
4
|
-
import { attr, getChildren,
|
|
5
|
+
import { attr, getChildren, GIR_CONSTRUCTOR_TAG, isAttrTrue, type RawNode } from "./parse.js";
|
|
5
6
|
import { type GirProperty, propertyFromNode } from "./property.js";
|
|
6
7
|
|
|
8
|
+
/** A `<virtual-method>` on a class or interface: the vtable slot's own documentation and signature. */
|
|
9
|
+
type GirVirtualMethod = GirCallable & {
|
|
10
|
+
/** Method GIR names as invoking this slot, absent when the slot has no invoker. */
|
|
11
|
+
invoker: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** A `<class>` or `<interface>` declared by a GIR namespace. */
|
|
7
15
|
type GirClass = {
|
|
16
|
+
/** Name GIR gives the type, without its namespace prefix. */
|
|
8
17
|
name: string;
|
|
18
|
+
/** Documentation GIR carries for the type. */
|
|
9
19
|
doc: string | undefined;
|
|
20
|
+
/** Release and deprecation annotations GIR carries on the type. */
|
|
21
|
+
annotations: GirAnnotations;
|
|
22
|
+
/** C type of an instance, such as `GtkWidget`. */
|
|
10
23
|
cType: string | undefined;
|
|
24
|
+
/** The class it derives from, qualified when it lives in another namespace. */
|
|
11
25
|
parent: string | undefined;
|
|
26
|
+
/** GType name the type registers under, such as `GtkWidget`. */
|
|
12
27
|
glibTypeName: string | undefined;
|
|
28
|
+
/** C function returning the GType, such as `gtk_widget_get_type`. */
|
|
13
29
|
glibGetType: string | undefined;
|
|
30
|
+
/** Record holding the class or interface vtable, which virtual method bindings are laid out against. */
|
|
14
31
|
glibTypeStruct: string | undefined;
|
|
32
|
+
/** C function that takes a reference, on a type that manages its own refcount. */
|
|
15
33
|
glibRefFunc: string | undefined;
|
|
34
|
+
/** C function that drops a reference, on a type that manages its own refcount. */
|
|
16
35
|
glibUnrefFunc: string | undefined;
|
|
36
|
+
/** Whether the type is its own GType fundamental rather than a GObject descendant. */
|
|
17
37
|
fundamental: boolean;
|
|
38
|
+
/** Whether the class cannot be instantiated on its own. */
|
|
18
39
|
isAbstract: boolean;
|
|
40
|
+
/** Whether the type came from an `<interface>` rather than a `<class>`. */
|
|
19
41
|
isInterface: boolean;
|
|
42
|
+
/** Whether GIR exposes the type to bindings; codegen skips it when false. */
|
|
20
43
|
introspectable: boolean;
|
|
44
|
+
/** Interfaces the class implements. */
|
|
21
45
|
implements: string[];
|
|
46
|
+
/** Types an implementer of this interface must also provide. */
|
|
22
47
|
prerequisites: string[];
|
|
48
|
+
/** Methods taking an instance. */
|
|
23
49
|
methods: GirFunction[];
|
|
50
|
+
/** Functions returning a new instance. */
|
|
24
51
|
constructors: GirFunction[];
|
|
52
|
+
/** Functions namespaced under the type that take no instance. */
|
|
25
53
|
functions: GirFunction[];
|
|
54
|
+
/** GObject properties the type declares. */
|
|
26
55
|
properties: GirProperty[];
|
|
56
|
+
/** GObject signals the type declares. */
|
|
27
57
|
signals: GirCallable[];
|
|
58
|
+
/** Virtual methods the type declares, carrying the documentation their vtable slots are generated from. */
|
|
59
|
+
vfuncs: GirVirtualMethod[];
|
|
28
60
|
};
|
|
29
61
|
|
|
62
|
+
const virtualMethodsFromNode = (node: RawNode, context: ParseContext): GirVirtualMethod[] =>
|
|
63
|
+
getChildren(node, "virtual-method").map((vfunc) => ({
|
|
64
|
+
...parseCallable(vfunc, context),
|
|
65
|
+
invoker: attr(vfunc, "invoker"),
|
|
66
|
+
}));
|
|
67
|
+
|
|
30
68
|
const classFromNode = (node: RawNode, isInterface: boolean, context: ParseContext): GirClass => ({
|
|
31
|
-
|
|
32
|
-
doc: getDoc(node),
|
|
69
|
+
...documentedFromNode(node),
|
|
33
70
|
cType: attr(node, "c:type"),
|
|
34
71
|
parent: attr(node, "parent"),
|
|
35
72
|
glibTypeName: attr(node, "glib:type-name"),
|
|
@@ -52,6 +89,7 @@ const classFromNode = (node: RawNode, isInterface: boolean, context: ParseContex
|
|
|
52
89
|
functions: getChildren(node, "function").map((fn) => functionFromNode(fn, context)),
|
|
53
90
|
properties: getChildren(node, "property").map((property) => propertyFromNode(property, context)),
|
|
54
91
|
signals: getChildren(node, "glib:signal").map((signal) => parseCallable(signal, context)),
|
|
92
|
+
vfuncs: virtualMethodsFromNode(node, context),
|
|
55
93
|
});
|
|
56
94
|
|
|
57
|
-
export { classFromNode, type GirClass };
|
|
95
|
+
export { classFromNode, type GirClass, type GirVirtualMethod };
|
package/src/gir/enum.ts
CHANGED
|
@@ -1,39 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { documentedFromNode, type GirAnnotations } from "./annotations.js";
|
|
2
|
+
import { attr, getChildren, isAttrTrue, type RawNode } from "./parse.js";
|
|
2
3
|
|
|
4
|
+
/** One member of a {@link GirEnum}. */
|
|
3
5
|
type EnumMember = {
|
|
6
|
+
/** The member's GIR name, which the emitted key is derived from. */
|
|
4
7
|
name: string;
|
|
8
|
+
/** Documentation prose from GIR, emitted as the member's JSDoc. */
|
|
5
9
|
doc: string | undefined;
|
|
10
|
+
/** Release and deprecation annotations GIR carries on the member. */
|
|
11
|
+
annotations: GirAnnotations;
|
|
12
|
+
/** The member's numeric value, `0` when GIR declares none. */
|
|
6
13
|
value: string;
|
|
14
|
+
/** C constant the member is exposed as, such as `GTK_ORIENTATION_HORIZONTAL`. */
|
|
7
15
|
cIdentifier: string | undefined;
|
|
8
16
|
};
|
|
9
17
|
|
|
18
|
+
/** Whether an enum is a plain enumeration or a bitfield of flags. */
|
|
10
19
|
type EnumKind = "enumeration" | "bitfield";
|
|
11
20
|
|
|
21
|
+
/** An enumeration or bitfield declared by a GIR namespace. */
|
|
12
22
|
type GirEnum = {
|
|
23
|
+
/** Whether the declaration is a plain enumeration or a bitfield. */
|
|
13
24
|
kind: EnumKind;
|
|
25
|
+
/** Name the enum is exported under, without its namespace prefix. */
|
|
14
26
|
name: string;
|
|
27
|
+
/** Documentation prose from GIR, emitted as the enum's JSDoc. */
|
|
15
28
|
doc: string | undefined;
|
|
29
|
+
/** Release and deprecation annotations GIR carries on the enum. */
|
|
30
|
+
annotations: GirAnnotations;
|
|
31
|
+
/** GType name of the enum, absent when it is not registered with GLib. */
|
|
16
32
|
glibTypeName: string | undefined;
|
|
33
|
+
/** C function returning the enum's GType, absent when it is not registered with GLib. */
|
|
17
34
|
glibGetType: string | undefined;
|
|
35
|
+
/** Quark name of the GError domain the members are codes of, absent on enums that carry no domain. */
|
|
18
36
|
errorDomain: string | undefined;
|
|
37
|
+
/** Whether the enum is introspectable; code generation skips the ones that are not. */
|
|
19
38
|
introspectable: boolean;
|
|
39
|
+
/** The enum's members, in declaration order. */
|
|
20
40
|
members: EnumMember[];
|
|
21
41
|
};
|
|
22
42
|
|
|
43
|
+
const enumMemberFromNode = (node: RawNode): EnumMember => ({
|
|
44
|
+
...documentedFromNode(node),
|
|
45
|
+
value: attr(node, "value") ?? "0",
|
|
46
|
+
cIdentifier: attr(node, "c:identifier"),
|
|
47
|
+
});
|
|
48
|
+
|
|
23
49
|
const enumFromNode = (node: RawNode, kind: EnumKind): GirEnum => ({
|
|
24
50
|
kind,
|
|
25
|
-
|
|
26
|
-
doc: getDoc(node),
|
|
51
|
+
...documentedFromNode(node),
|
|
27
52
|
glibTypeName: attr(node, "glib:type-name"),
|
|
28
53
|
glibGetType: attr(node, "glib:get-type"),
|
|
29
54
|
errorDomain: attr(node, "glib:error-domain"),
|
|
30
55
|
introspectable: isAttrTrue(node, "introspectable", true),
|
|
31
|
-
members: getChildren(node, "member").map((member) => (
|
|
32
|
-
name: nameAttr(member),
|
|
33
|
-
doc: getDoc(member),
|
|
34
|
-
value: attr(member, "value") ?? "0",
|
|
35
|
-
cIdentifier: attr(member, "c:identifier"),
|
|
36
|
-
})),
|
|
56
|
+
members: getChildren(node, "member").map((member) => enumMemberFromNode(member)),
|
|
37
57
|
});
|
|
38
58
|
|
|
39
|
-
export { enumFromNode, type GirEnum };
|
|
59
|
+
export { enumFromNode, type EnumMember, type GirEnum };
|
package/src/gir/field.ts
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
import type { ParseContext, TypeId } from "./type-id.js";
|
|
2
|
-
import {
|
|
2
|
+
import { documentedFromNode, type GirAnnotations } from "./annotations.js";
|
|
3
|
+
import { attr, getChild, getChildren, intAttr, isAttrTrue, type RawNode } from "./parse.js";
|
|
3
4
|
import { typeRefFromNode } from "./type-ref.js";
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* One slot in a record or union layout: a named field, or a nested struct or union
|
|
8
|
+
* whose own members are laid out inline.
|
|
9
|
+
*/
|
|
5
10
|
type GirField = {
|
|
11
|
+
/** Field name as GIR spells it. */
|
|
6
12
|
name: string;
|
|
13
|
+
/** Documentation prose from GIR, emitted as the field accessor's JSDoc. */
|
|
7
14
|
doc: string | undefined;
|
|
15
|
+
/** Release and deprecation annotations GIR carries on the field. */
|
|
16
|
+
annotations: GirAnnotations;
|
|
17
|
+
/** The field's value type, absent for a nested struct or union and for one GIR leaves undeclared. */
|
|
8
18
|
type: TypeId | undefined;
|
|
19
|
+
/** The C type spelled on the field, which decides whether it is read through a pointer. */
|
|
9
20
|
cType: string | undefined;
|
|
21
|
+
/** Whether the field can be read; one that is neither readable nor writable gets no accessor at all. */
|
|
10
22
|
readable: boolean;
|
|
23
|
+
/** Whether the field can be written, which is what earns it a setter alongside its getter. */
|
|
11
24
|
writable: boolean;
|
|
25
|
+
/** Whether the field is private to the library, as every nested struct or union is. */
|
|
12
26
|
private: boolean;
|
|
27
|
+
/** Width in bits when the field is a C bitfield member. */
|
|
13
28
|
bits: number | undefined;
|
|
14
|
-
/** Members of
|
|
29
|
+
/** Members of a nested struct or union, absent for a named field. */
|
|
15
30
|
inlineMembers: GirField[] | undefined;
|
|
16
|
-
|
|
31
|
+
/** Whether {@link GirField.inlineMembers} overlap as a union rather than following one another as a struct. */
|
|
32
|
+
isInlineUnion: boolean;
|
|
17
33
|
};
|
|
18
34
|
|
|
19
35
|
const fieldFromNode = (node: RawNode, context: ParseContext): GirField => ({
|
|
20
|
-
|
|
21
|
-
doc: getDoc(node),
|
|
36
|
+
...documentedFromNode(node),
|
|
22
37
|
type: typeRefFromNode(node, context),
|
|
23
38
|
cType: attr(getChild(node, "type"), "c:type"),
|
|
24
39
|
readable: isAttrTrue(node, "readable", true),
|
|
@@ -26,15 +41,11 @@ const fieldFromNode = (node: RawNode, context: ParseContext): GirField => ({
|
|
|
26
41
|
private: isAttrTrue(node, "private", false),
|
|
27
42
|
bits: intAttr(node, "bits"),
|
|
28
43
|
inlineMembers: undefined,
|
|
29
|
-
|
|
44
|
+
isInlineUnion: false,
|
|
30
45
|
});
|
|
31
46
|
|
|
32
|
-
// A record may embed an anonymous `<union>` or `<record>` instead of naming a type for it. The
|
|
33
|
-
// member occupies a real slot and contributes its own size and alignment, but carries no `<type>`,
|
|
34
|
-
// so it has to be admitted as a field whose layout comes from its own children.
|
|
35
47
|
const anonymousMemberFromNode = (node: RawNode, isUnion: boolean, context: ParseContext): GirField => ({
|
|
36
|
-
|
|
37
|
-
doc: getDoc(node),
|
|
48
|
+
...documentedFromNode(node),
|
|
38
49
|
type: undefined,
|
|
39
50
|
cType: undefined,
|
|
40
51
|
readable: false,
|
|
@@ -42,7 +53,7 @@ const anonymousMemberFromNode = (node: RawNode, isUnion: boolean, context: Parse
|
|
|
42
53
|
private: true,
|
|
43
54
|
bits: undefined,
|
|
44
55
|
inlineMembers: collectFields(node, context),
|
|
45
|
-
|
|
56
|
+
isInlineUnion: isUnion,
|
|
46
57
|
});
|
|
47
58
|
|
|
48
59
|
const collectFields = (node: RawNode, context: ParseContext): GirField[] => [
|
|
@@ -51,4 +62,4 @@ const collectFields = (node: RawNode, context: ParseContext): GirField[] => [
|
|
|
51
62
|
...getChildren(node, "record").map((member) => anonymousMemberFromNode(member, false, context)),
|
|
52
63
|
];
|
|
53
64
|
|
|
54
|
-
export { collectFields,
|
|
65
|
+
export { collectFields, type GirField };
|
package/src/gir/function.ts
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
|
+
import type { GirAnnotations } from "./annotations.js";
|
|
1
2
|
import type { ParseContext } from "./type-id.js";
|
|
2
3
|
import { PARAMETERS_MISSING_NULLABLE_ANNOTATION } from "./nullable-overrides.js";
|
|
3
4
|
import { type GirParameter, type GirReturnValue, parameterFromNode, parseCallable } from "./parameter.js";
|
|
4
5
|
import { attr, getChild, type RawNode } from "./parse.js";
|
|
5
6
|
|
|
7
|
+
/** A callable declared by a GIR namespace, class, or record: a function, a method, or a constructor. */
|
|
6
8
|
type GirFunction = {
|
|
9
|
+
/** Local name within its owner, taken from the `shadows` annotation when the callable has one. */
|
|
7
10
|
name: string;
|
|
11
|
+
/** Documentation text carried by the GIR node. */
|
|
8
12
|
doc: string | undefined;
|
|
13
|
+
/** Release and deprecation annotations GIR carries on the callable. */
|
|
14
|
+
annotations: GirAnnotations;
|
|
15
|
+
/** C symbol the callable is invoked through. */
|
|
9
16
|
cIdentifier: string | undefined;
|
|
17
|
+
/** Whether the C function takes a trailing `GError` out parameter and can fail. */
|
|
10
18
|
throws: boolean;
|
|
19
|
+
/** Whether the GIR marks the callable as introspectable, and so bindable. */
|
|
11
20
|
introspectable: boolean;
|
|
21
|
+
/** Qualified `Type.member` the GIR redirects the callable to, from its `moved-to` annotation. */
|
|
12
22
|
movedTo: string | undefined;
|
|
23
|
+
/** Name of the callable that shadows this one, from the GIR's `shadowed-by` annotation. */
|
|
13
24
|
shadowedBy: string | undefined;
|
|
25
|
+
/** Name of the callable that completes this asynchronous one, from the GIR's `glib:finish-func`. */
|
|
14
26
|
finishFunc: string | undefined;
|
|
27
|
+
/** The instance the callable is invoked on, absent for constructors and namespace-level functions. */
|
|
15
28
|
instance: GirParameter | undefined;
|
|
29
|
+
/** Parameters other than the instance one, in declaration order. */
|
|
16
30
|
parameters: GirParameter[];
|
|
31
|
+
/** What the callable returns, with its transfer and nullability. */
|
|
17
32
|
returnValue: GirReturnValue;
|
|
18
33
|
};
|
|
19
34
|
|
package/src/gir/gir-path.ts
CHANGED
|
@@ -4,6 +4,13 @@ import { existsSync } from "node:fs";
|
|
|
4
4
|
|
|
5
5
|
const SYSTEM_GIR_PATH = "/usr/share/gir-1.0";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* The directories to search for `.gir` files, in precedence order: the config's own `girPath`, then
|
|
9
|
+
* `GTKX_GIR_PATH`, then `/usr/share/gir-1.0`, then the girdir pkg-config reports for
|
|
10
|
+
* gobject-introspection-1.0. Duplicates are dropped, and the last two are included only when they exist.
|
|
11
|
+
*
|
|
12
|
+
* @throws If pkg-config is installed but fails while being queried.
|
|
13
|
+
*/
|
|
7
14
|
const resolveGirPath = (configGirPath: string[] | undefined): string[] => {
|
|
8
15
|
const paths: string[] = [];
|
|
9
16
|
|
package/src/gir/libraries.ts
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
import { sortStrings } from "@gtkx/utils";
|
|
2
2
|
import { readdirSync } from "node:fs";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
type
|
|
4
|
+
/** A namespace found on the GIR path, taken from the name of its `.gir` file. */
|
|
5
|
+
type GirNamespace = {
|
|
6
|
+
/** Namespace the file describes, such as `Gtk`. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** API version the file describes, such as `4.0`. */
|
|
9
|
+
version: string;
|
|
10
|
+
/** Name and version joined the way a `libraries` entry spells them, such as `Gtk-4.0`. */
|
|
11
|
+
identifier: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** A `libraries` config value: an explicit list, `"*"` for everything installed, or absent for the default. */
|
|
15
|
+
type LibrarySelection = "*" | string[] | undefined;
|
|
6
16
|
|
|
7
17
|
const LIBRARIES_WILDCARD = "*";
|
|
8
18
|
const GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\d+(?:\.\d+)*$/;
|
|
9
19
|
const DEFAULT_LIBRARIES: string[] = ["Gtk-4.0"];
|
|
10
20
|
const GIR_FILE_SUFFIX = ".gir";
|
|
11
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Expands a `libraries` config value into the GIR identifiers to generate from: `"Gtk-4.0"` alone when
|
|
24
|
+
* nothing is configured, everything installed for `"*"`, and otherwise the given list with `"Gtk-4.0"`
|
|
25
|
+
* prepended unless it already names a Gtk version.
|
|
26
|
+
*
|
|
27
|
+
* @throws If `"*"` matched no `.gir` file anywhere on the GIR path.
|
|
28
|
+
*/
|
|
12
29
|
const resolveLibraries = (libraries: LibrarySelection, girPath: string[]): string[] => {
|
|
13
30
|
if (libraries === undefined) {
|
|
14
31
|
return [...DEFAULT_LIBRARIES];
|
|
@@ -74,6 +91,10 @@ const collectDirNamespaces = (highestByName: Map<string, GirNamespace>, dir: str
|
|
|
74
91
|
}
|
|
75
92
|
};
|
|
76
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Every GIR library installed on the search path, as sorted `Name-Version` identifiers. A namespace found
|
|
96
|
+
* in more than one version contributes only its highest, and unreadable directories are skipped.
|
|
97
|
+
*/
|
|
77
98
|
const discoverGirNamespaces = (girPath: string[]): string[] => {
|
|
78
99
|
const highestByName: Map<string, GirNamespace> = new Map();
|
|
79
100
|
|
package/src/gir/library.ts
CHANGED
|
@@ -14,13 +14,23 @@ import {
|
|
|
14
14
|
import { parseGirFile, type RawNode } from "./parse.js";
|
|
15
15
|
import { splitOptionalNamespace } from "./type-ref.js";
|
|
16
16
|
|
|
17
|
+
/** The types belonging to one namespace, addressed by the id half of a {@link TypeId}. */
|
|
17
18
|
type TypeTable = {
|
|
19
|
+
/** Parsed type in each slot, still `undefined` while only a forward reference to it has been seen. */
|
|
18
20
|
types: (GirType | undefined)[];
|
|
21
|
+
/** Declared name of each slot, `undefined` for anonymous types such as containers and inline callbacks. */
|
|
19
22
|
names: (string | undefined)[];
|
|
23
|
+
/** Slot id each named type occupies, so repeated references resolve to the same id. */
|
|
20
24
|
index: Map<string, number>;
|
|
21
25
|
};
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
/** A namespace whose header has been read and whose shell is registered, before its body is parsed. */
|
|
28
|
+
type DiscoveredNamespace = {
|
|
29
|
+
/** Attributes and includes read from the namespace's GIR file. */
|
|
30
|
+
header: NamespaceHeader;
|
|
31
|
+
/** Empty namespace registered for the header, populated once every header is known. */
|
|
32
|
+
shell: GirNamespace;
|
|
33
|
+
};
|
|
24
34
|
|
|
25
35
|
const INTERNAL_NS_ID = 0;
|
|
26
36
|
|
|
@@ -50,6 +60,10 @@ const locateGirFile = (identifier: string, girPath: string[]): string => {
|
|
|
50
60
|
throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);
|
|
51
61
|
};
|
|
52
62
|
|
|
63
|
+
/**
|
|
64
|
+
* The parsed GIR universe: every requested namespace plus everything those namespaces include,
|
|
65
|
+
* with types resolvable across namespace boundaries.
|
|
66
|
+
*/
|
|
53
67
|
class Library {
|
|
54
68
|
private static drive(library: Library, libraries: string[], girPath: string[]): void {
|
|
55
69
|
const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);
|
|
@@ -65,6 +79,13 @@ class Library {
|
|
|
65
79
|
library.girFilesValue = girFiles;
|
|
66
80
|
}
|
|
67
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Parses the named GIR libraries along with every namespace they transitively include.
|
|
84
|
+
*
|
|
85
|
+
* @param libraries GIR identifiers to load, such as `Gtk-4.0`.
|
|
86
|
+
* @param girPath Directories searched, in order, for each `.gir` file.
|
|
87
|
+
* @returns A library holding every namespace that was parsed.
|
|
88
|
+
*/
|
|
68
89
|
static load(libraries: string[], girPath: string[]): Library {
|
|
69
90
|
const library = new Library();
|
|
70
91
|
this.drive(library, libraries, girPath);
|
|
@@ -79,6 +100,7 @@ class Library {
|
|
|
79
100
|
private typeTables: TypeTable[] = [];
|
|
80
101
|
private girFilesValue: string[] = [];
|
|
81
102
|
|
|
103
|
+
/** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */
|
|
82
104
|
constructor() {
|
|
83
105
|
this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };
|
|
84
106
|
this.namespaceById[INTERNAL_NS_ID] = undefined;
|
|
@@ -301,19 +323,38 @@ class Library {
|
|
|
301
323
|
return { discovered, girFiles };
|
|
302
324
|
}
|
|
303
325
|
|
|
326
|
+
/** The loaded namespaces, keyed by their GIR name such as `Gtk`. */
|
|
304
327
|
public get namespaces(): Map<string, GirNamespace> {
|
|
305
328
|
return this.namespacesByName;
|
|
306
329
|
}
|
|
307
330
|
|
|
331
|
+
/** Paths of the `.gir` files that were read, in the order they were discovered. */
|
|
308
332
|
public get girFiles(): string[] {
|
|
309
333
|
return this.girFilesValue;
|
|
310
334
|
}
|
|
311
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Reads the type a {@link TypeId} points at.
|
|
338
|
+
*
|
|
339
|
+
* @param tid The type id to dereference.
|
|
340
|
+
* @returns The parsed type, or `undefined` when nothing has been parsed into that slot.
|
|
341
|
+
*/
|
|
312
342
|
typeFor(tid: TypeId): GirType | undefined {
|
|
313
343
|
return this.typeTables[tid.nsId]?.types[tid.id];
|
|
314
344
|
}
|
|
315
345
|
|
|
316
|
-
|
|
346
|
+
/**
|
|
347
|
+
* Reads the name a {@link TypeId} was registered under.
|
|
348
|
+
*
|
|
349
|
+
* @param tid The type id to name.
|
|
350
|
+
* @returns The namespace and type name, or `undefined` for an anonymous type.
|
|
351
|
+
*/
|
|
352
|
+
nameFor(tid: TypeId): {
|
|
353
|
+
/** GIR namespace to qualify the type with, such as `Gtk`. */
|
|
354
|
+
namespaceName: string;
|
|
355
|
+
/** Unqualified type name as GIR declares it, such as `Widget`. */
|
|
356
|
+
typeName: string;
|
|
357
|
+
} | undefined {
|
|
317
358
|
const typeName = this.typeTables[tid.nsId]?.names[tid.id];
|
|
318
359
|
const namespaceName = this.nsNameById[tid.nsId];
|
|
319
360
|
|
|
@@ -324,6 +365,14 @@ class Library {
|
|
|
324
365
|
return { namespaceName, typeName };
|
|
325
366
|
}
|
|
326
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Looks up a type by the name a GIR file writes, resolving an unqualified name against the
|
|
370
|
+
* namespace it appears in and a `Namespace.Type` name against the loaded namespaces.
|
|
371
|
+
*
|
|
372
|
+
* @param currentNamespaceName Namespace the name is written in.
|
|
373
|
+
* @param name Type name, optionally qualified with a namespace prefix.
|
|
374
|
+
* @returns The parsed type, or `undefined` when the name is unknown or only a forward reference to it exists.
|
|
375
|
+
*/
|
|
327
376
|
resolveType(currentNamespaceName: string, name: string): GirType | undefined {
|
|
328
377
|
const currentNsId = this.nsIdByName.get(currentNamespaceName);
|
|
329
378
|
|
package/src/gir/namespace.ts
CHANGED
|
@@ -1,52 +1,90 @@
|
|
|
1
1
|
import type { ParseContext, TypeId } from "./type-id.js";
|
|
2
|
+
import { documentedFromNode, type GirAnnotations } from "./annotations.js";
|
|
2
3
|
import { callbackFromNode, type GirCallback } from "./callback.js";
|
|
3
4
|
import { classFromNode, type GirClass } from "./class.js";
|
|
4
5
|
import { enumFromNode, type GirEnum } from "./enum.js";
|
|
5
6
|
import { functionFromNode, type GirFunction } from "./function.js";
|
|
6
|
-
import { attr, getChild, getChildren,
|
|
7
|
+
import { attr, getChild, getChildren, nameAttr, type RawNode } from "./parse.js";
|
|
7
8
|
import { type GirRecord, isVtableRecord, recordFromNode } from "./record.js";
|
|
8
9
|
import { typeRefFromNode } from "./type-ref.js";
|
|
9
10
|
|
|
11
|
+
/** A compile-time constant declared by a namespace. */
|
|
10
12
|
type GirConstant = {
|
|
13
|
+
/** Local name within the namespace. */
|
|
11
14
|
name: string;
|
|
15
|
+
/** Documentation text carried by the GIR node. */
|
|
12
16
|
doc: string | undefined;
|
|
17
|
+
/** Release and deprecation annotations GIR carries on the constant. */
|
|
18
|
+
annotations: GirAnnotations;
|
|
19
|
+
/** Literal as written in the GIR, still to be interpreted according to {@link GirConstant.type}. */
|
|
13
20
|
value: string;
|
|
21
|
+
/** Type of the constant, unresolved until looked up in the library's type tables. */
|
|
14
22
|
type: TypeId | undefined;
|
|
15
23
|
};
|
|
16
24
|
|
|
25
|
+
/** A named alias for another type. */
|
|
17
26
|
type GirAlias = {
|
|
27
|
+
/** Local name within the namespace. */
|
|
18
28
|
name: string;
|
|
29
|
+
/** Documentation text carried by the GIR node. */
|
|
19
30
|
doc: string | undefined;
|
|
31
|
+
/** Release and deprecation annotations GIR carries on the alias. */
|
|
32
|
+
annotations: GirAnnotations;
|
|
33
|
+
/** C typedef name introduced by the alias. */
|
|
20
34
|
cType: string | undefined;
|
|
35
|
+
/** Type the alias stands for, unresolved until looked up in the library's type tables. */
|
|
21
36
|
target: TypeId | undefined;
|
|
37
|
+
/** C type name of the target, which decides how the alias marshals. */
|
|
22
38
|
targetCType: string | undefined;
|
|
23
39
|
};
|
|
24
40
|
|
|
41
|
+
/** Everything one GIR namespace declares, keyed into the library that parsed it. */
|
|
25
42
|
type GirNamespace = {
|
|
43
|
+
/** Identifier of the namespace's type table within its library. */
|
|
26
44
|
id: number;
|
|
45
|
+
/** Namespace name as it appears in the GIR, such as `Gtk`. */
|
|
27
46
|
name: string;
|
|
47
|
+
/** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
|
|
28
48
|
sharedLibrary: string | undefined;
|
|
49
|
+
/** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
|
|
29
50
|
cSymbolPrefixes: string[];
|
|
51
|
+
/** GObject classes declared by the namespace. */
|
|
30
52
|
classes: GirClass[];
|
|
53
|
+
/** GObject interfaces declared by the namespace. */
|
|
31
54
|
interfaces: GirClass[];
|
|
55
|
+
/** Structs and unions declared by the namespace. */
|
|
32
56
|
records: GirRecord[];
|
|
57
|
+
/** Enumerations and bitfields declared by the namespace. */
|
|
33
58
|
enums: GirEnum[];
|
|
59
|
+
/** Callback types declared by the namespace. */
|
|
34
60
|
callbacks: GirCallback[];
|
|
61
|
+
/** Free functions declared by the namespace. */
|
|
35
62
|
functions: GirFunction[];
|
|
63
|
+
/** Compile-time values, emitted as module-level `const` bindings. */
|
|
36
64
|
constants: GirConstant[];
|
|
65
|
+
/** Typedefs, emitted as TypeScript type aliases and resolvable as types themselves. */
|
|
37
66
|
aliases: GirAlias[];
|
|
38
67
|
};
|
|
39
68
|
|
|
69
|
+
/** Another namespace a GIR repository depends on. */
|
|
40
70
|
type NamespaceInclude = {
|
|
71
|
+
/** Name of the included namespace, such as `Gio`. */
|
|
41
72
|
name: string;
|
|
73
|
+
/** Version of the included namespace, such as `2.0`. */
|
|
42
74
|
version: string;
|
|
43
75
|
};
|
|
44
76
|
|
|
77
|
+
/** A namespace's declaration and dependencies, read before its body is parsed. */
|
|
45
78
|
type NamespaceHeader = {
|
|
79
|
+
/** Namespace name as it appears in the GIR, such as `Gtk`. */
|
|
46
80
|
name: string;
|
|
81
|
+
/** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
|
|
47
82
|
sharedLibrary: string | undefined;
|
|
83
|
+
/** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
|
|
48
84
|
cSymbolPrefixes: string[];
|
|
85
|
+
/** Namespaces this repository includes, each of which is parsed in turn. */
|
|
49
86
|
includes: NamespaceInclude[];
|
|
87
|
+
/** The `<namespace>` node whose children hold the declarations. */
|
|
50
88
|
namespaceNode: RawNode;
|
|
51
89
|
};
|
|
52
90
|
|
|
@@ -97,15 +135,13 @@ const populateNamespaceBody = (shell: GirNamespace, namespaceNode: RawNode, cont
|
|
|
97
135
|
shell.functions = getChildren(namespaceNode, "function").map((fn) => functionFromNode(fn, context));
|
|
98
136
|
|
|
99
137
|
shell.constants = getChildren(namespaceNode, "constant").map((constant) => ({
|
|
100
|
-
|
|
101
|
-
doc: getDoc(constant),
|
|
138
|
+
...documentedFromNode(constant),
|
|
102
139
|
value: attr(constant, "value") ?? "",
|
|
103
140
|
type: typeRefFromNode(constant, context),
|
|
104
141
|
}));
|
|
105
142
|
|
|
106
143
|
shell.aliases = getChildren(namespaceNode, "alias").map((alias) => ({
|
|
107
|
-
|
|
108
|
-
doc: getDoc(alias),
|
|
144
|
+
...documentedFromNode(alias),
|
|
109
145
|
cType: attr(alias, "c:type"),
|
|
110
146
|
target: typeRefFromNode(alias, context),
|
|
111
147
|
targetCType: attr(getChild(alias, "type"), "c:type"),
|