@gtkx/codegen 1.0.0-rc.4 → 1.1.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 +5 -5
- package/dist/analysis/descriptor-render.d.ts +13 -9
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +80 -50
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +16 -7
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +15 -3
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/inheritance.d.ts +4 -3
- package/dist/analysis/inheritance.d.ts.map +1 -1
- package/dist/analysis/inheritance.js +103 -58
- package/dist/analysis/inheritance.js.map +1 -1
- package/dist/analysis/interface-conflicts.d.ts +23 -0
- package/dist/analysis/interface-conflicts.d.ts.map +1 -0
- package/dist/analysis/interface-conflicts.js +144 -0
- package/dist/analysis/interface-conflicts.js.map +1 -0
- 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 +129 -0
- package/dist/analysis/param-capability.js.map +1 -0
- package/dist/analysis/param-structure.d.ts +11 -4
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +42 -16
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +10 -17
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/analysis/type-key.d.ts +5 -0
- package/dist/analysis/type-key.d.ts.map +1 -0
- package/dist/analysis/type-key.js +9 -0
- package/dist/analysis/type-key.js.map +1 -0
- 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 +12 -3
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +73 -24
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +2 -2
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +17 -23
- 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 +36 -22
- 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.map +1 -1
- package/dist/docs/pipeline.js +87 -20
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.d.ts +26 -5
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +88 -25
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts +17 -0
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +132 -44
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +12 -1
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +44 -28
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +1 -0
- package/dist/gi.js.map +1 -1
- package/dist/gir/ancestry.d.ts +8 -2
- package/dist/gir/ancestry.d.ts.map +1 -1
- package/dist/gir/ancestry.js +19 -1
- package/dist/gir/ancestry.js.map +1 -1
- package/dist/gir/annotations.d.ts +21 -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/cursor-overrides.d.ts +8 -0
- package/dist/gir/cursor-overrides.d.ts.map +1 -0
- package/dist/gir/cursor-overrides.js +6 -0
- package/dist/gir/cursor-overrides.js.map +1 -0
- package/dist/gir/emittable.d.ts +7 -0
- package/dist/gir/emittable.d.ts.map +1 -0
- package/dist/gir/emittable.js +3 -0
- package/dist/gir/emittable.js.map +1 -0
- 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 -3
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +7 -8
- 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 +28 -2
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/libraries.d.ts +1 -3
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +0 -1
- 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 +35 -1
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/namespace.d.ts +43 -1
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +8 -7
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/parameter.d.ts +52 -1
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +8 -3
- 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 +9 -9
- 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.map +1 -1
- package/dist/gir/type-id.d.ts +35 -0
- package/dist/gir/type-id.d.ts.map +1 -1
- package/dist/gir/type-id.js +1 -0
- 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 +1 -0
- 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/guards.d.ts +16 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +11 -0
- package/dist/guards.js.map +1 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -0
- package/dist/internal.js.map +1 -1
- package/dist/json.d.ts +3 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +11 -0
- package/dist/json.js.map +1 -0
- package/dist/khronos/args.d.ts +7 -6
- package/dist/khronos/args.d.ts.map +1 -1
- package/dist/khronos/args.js +28 -6
- 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 +112 -27
- 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/parse.d.ts.map +1 -1
- package/dist/khronos/parse.js +3 -4
- package/dist/khronos/parse.js.map +1 -1
- package/dist/khronos/pipeline.d.ts +4 -2
- package/dist/khronos/pipeline.d.ts.map +1 -1
- package/dist/khronos/pipeline.js +58 -27
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +3 -9
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +3 -3
- 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 +2 -2
- package/dist/react/element-config.d.ts.map +1 -1
- package/dist/react/element-config.js.map +1 -1
- package/dist/runner.d.ts +6 -8
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +16 -0
- package/dist/runner.js.map +1 -1
- package/dist/staging.d.ts +5 -0
- package/dist/staging.d.ts.map +1 -0
- package/dist/staging.js +57 -0
- package/dist/staging.js.map +1 -0
- package/dist/store/compile-store.d.ts +1 -1
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +4 -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 +9 -2
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +35 -40
- 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 +10 -6
- 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 +63 -40
- 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/companion.d.ts.map +1 -1
- package/dist/store/gi/companion.js +6 -6
- package/dist/store/gi/companion.js.map +1 -1
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +12 -3
- 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 +52 -19
- package/dist/store/gi/enum.js.map +1 -1
- package/dist/store/gi/function.d.ts +1 -3
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +50 -29
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +4 -1
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/interface.d.ts.map +1 -1
- package/dist/store/gi/interface.js +155 -26
- 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 +11 -2
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +80 -45
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +6 -2
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +54 -5
- 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 +23 -11
- package/dist/store/gi/pipeline.js.map +1 -1
- package/dist/store/gi/properties.d.ts +2 -1
- package/dist/store/gi/properties.d.ts.map +1 -1
- package/dist/store/gi/properties.js +7 -4
- package/dist/store/gi/properties.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +12 -5
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +98 -46
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts +8 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +34 -11
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +3 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +8 -3
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +6 -1
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +9 -2
- 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 +21 -9
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/registration.d.ts +1 -1
- package/dist/store/gi/registration.js +4 -4
- package/dist/store/gi/registration.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 +2 -1
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +42 -37
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/value-marshalable.d.ts +1 -2
- package/dist/store/gi/value-marshalable.d.ts.map +1 -1
- package/dist/store/gi/value-marshalable.js +3 -2
- package/dist/store/gi/value-marshalable.js.map +1 -1
- package/dist/store/gi/vtable.d.ts +19 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +257 -51
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +1 -0
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +15 -20
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/element-components.d.ts +1 -1
- package/dist/store/jsx/element-components.d.ts.map +1 -1
- package/dist/store/jsx/element-components.js +6 -4
- package/dist/store/jsx/element-components.js.map +1 -1
- package/dist/store/jsx/element-prop-imports.d.ts +1 -3
- package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-imports.js.map +1 -1
- package/dist/store/jsx/element-prop-types.d.ts +3 -0
- package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-types.js +7 -1
- package/dist/store/jsx/element-prop-types.js.map +1 -1
- package/dist/store/jsx/generated-elements.d.ts +2 -1
- package/dist/store/jsx/generated-elements.d.ts.map +1 -1
- package/dist/store/jsx/generated-elements.js +13 -7
- package/dist/store/jsx/generated-elements.js.map +1 -1
- 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 +10 -9
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx/metadata.d.ts.map +1 -1
- package/dist/store/jsx/metadata.js +5 -3
- package/dist/store/jsx/metadata.js.map +1 -1
- package/dist/store/jsx/pipeline.d.ts +1 -1
- package/dist/store/jsx/pipeline.d.ts.map +1 -1
- 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 +14 -6
- package/dist/store/jsx/props.js.map +1 -1
- 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 +14 -3
- package/dist/store/resolve-store.d.ts.map +1 -1
- package/dist/store/resolve-store.js +98 -15
- package/dist/store/resolve-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +9 -6
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +59 -25
- package/dist/store/store-fs.js.map +1 -1
- package/dist/store/store-links.d.ts +3 -0
- package/dist/store/store-links.d.ts.map +1 -0
- package/dist/store/store-links.js +39 -0
- package/dist/store/store-links.js.map +1 -0
- package/dist/writer/comparison-context.d.ts +4 -0
- package/dist/writer/comparison-context.d.ts.map +1 -0
- package/dist/writer/comparison-context.js +13 -0
- package/dist/writer/comparison-context.js.map +1 -0
- package/dist/writer/context.d.ts +3 -2
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +11 -3
- 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 +17 -3
- package/dist/writer/module.d.ts.map +1 -1
- package/dist/writer/module.js +72 -3
- package/dist/writer/module.js.map +1 -1
- package/dist/xml.d.ts +7 -1
- package/dist/xml.d.ts.map +1 -1
- package/dist/xml.js +43 -1
- package/dist/xml.js.map +1 -1
- package/overrides/gdk/rgba.ts.ejs +26 -0
- package/overrides/gobject/object.ts.ejs +48 -3
- package/overrides/gobject/value.ts.ejs +7 -0
- package/overrides/graphene/structs.ts.ejs +55 -0
- package/package.json +15 -4
- package/src/analysis/descriptor-render.ts +130 -66
- package/src/analysis/descriptor.ts +35 -11
- package/src/analysis/inheritance.ts +166 -75
- package/src/analysis/interface-conflicts.ts +237 -0
- package/src/analysis/nul-terminated-bytes.ts +31 -0
- package/src/analysis/param-capability.ts +169 -0
- package/src/analysis/param-structure.ts +85 -25
- package/src/analysis/ts-type.ts +13 -17
- package/src/analysis/type-key.ts +14 -0
- package/src/analysis/type-shape.ts +24 -0
- package/src/compile.ts +110 -26
- package/src/docs/api-reference.ts +46 -34
- package/src/docs/element-page.ts +58 -49
- package/src/docs/handwritten-props.ts +230 -0
- package/src/docs/pipeline.ts +131 -21
- package/src/docs/render.ts +153 -35
- package/src/docs/symbol-page.ts +230 -80
- package/src/fingerprint.ts +86 -32
- package/src/gi.ts +1 -0
- package/src/gir/ancestry.ts +31 -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/cursor-overrides.ts +12 -0
- package/src/gir/emittable.ts +8 -0
- package/src/gir/enum.ts +30 -10
- package/src/gir/field.ts +24 -9
- package/src/gir/function.ts +60 -9
- package/src/gir/libraries.ts +11 -3
- package/src/gir/library.ts +52 -3
- package/src/gir/namespace.ts +49 -7
- package/src/gir/parameter.ts +62 -3
- package/src/gir/parse.ts +13 -9
- 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 -3
- package/src/gir/type-id.ts +49 -3
- package/src/gir/type-ref.ts +1 -0
- package/src/gir/type.ts +50 -6
- package/src/guards.ts +23 -0
- package/src/internal.ts +2 -0
- package/src/json.ts +11 -0
- package/src/khronos/args.ts +36 -13
- 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 +150 -40
- package/src/khronos/notes.ts +74 -0
- package/src/khronos/param-pair.ts +1 -1
- package/src/khronos/parse.ts +3 -4
- package/src/khronos/pipeline.ts +95 -42
- package/src/khronos/plan.ts +4 -6
- package/src/khronos/render.ts +62 -50
- package/src/khronos/select.ts +91 -50
- package/src/react/element-config.ts +2 -2
- package/src/runner.ts +20 -9
- package/src/staging.ts +69 -0
- package/src/store/compile-store.ts +7 -5
- package/src/store/gi/callable-doc.ts +102 -0
- package/src/store/gi/callables.ts +58 -44
- package/src/store/gi/callback.ts +10 -9
- package/src/store/gi/class.ts +83 -49
- package/src/store/gi/closure-invocation.ts +26 -0
- package/src/store/gi/companion.ts +7 -6
- package/src/store/gi/constant.ts +14 -5
- package/src/store/gi/constructor-props.ts +19 -23
- package/src/store/gi/doc-spec.ts +38 -0
- package/src/store/gi/enum.ts +75 -26
- package/src/store/gi/function.ts +72 -44
- package/src/store/gi/gtype-binding.ts +7 -2
- package/src/store/gi/interface.ts +244 -37
- package/src/store/gi/item-comparators.ts +3 -5
- package/src/store/gi/method.ts +124 -69
- package/src/store/gi/param-marshal.ts +91 -6
- package/src/store/gi/pipeline.ts +28 -13
- package/src/store/gi/properties.ts +10 -5
- package/src/store/gi/property-accessor.ts +163 -75
- package/src/store/gi/record-constructor.ts +56 -19
- package/src/store/gi/record-field-accessor.ts +13 -4
- package/src/store/gi/record-layout.ts +12 -2
- package/src/store/gi/record.ts +24 -10
- package/src/store/gi/registration.ts +5 -5
- package/src/store/gi/runtime-override.ts +13 -6
- package/src/store/gi/signal.ts +54 -57
- package/src/store/gi/value-marshalable.ts +4 -2
- package/src/store/gi/vtable.ts +439 -61
- package/src/store/gi-store.ts +26 -31
- package/src/store/jsx/element-components.ts +8 -5
- package/src/store/jsx/element-prop-imports.ts +1 -3
- package/src/store/jsx/element-prop-types.ts +10 -1
- package/src/store/jsx/generated-elements.ts +17 -8
- package/src/store/jsx/intrinsic-elements.ts +4 -0
- package/src/store/jsx/jsx.ts +11 -9
- package/src/store/jsx/metadata.ts +6 -3
- package/src/store/jsx/pipeline.ts +1 -1
- package/src/store/jsx/props.ts +20 -7
- package/src/store/jsx-store.ts +3 -3
- package/src/store/resolve-store.ts +133 -18
- package/src/store/store-fs.ts +87 -34
- package/src/store/store-links.ts +49 -0
- package/src/writer/comparison-context.ts +18 -0
- package/src/writer/context.ts +14 -4
- 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 +114 -4
- package/src/xml.ts +61 -1
package/src/gir/libraries.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { sortStrings } from "@gtkx/utils";
|
|
2
2
|
import { readdirSync } from "node:fs";
|
|
3
3
|
|
|
4
|
-
|
|
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
|
+
|
|
5
14
|
/** A `libraries` config value: an explicit list, `"*"` for everything installed, or absent for the default. */
|
|
6
|
-
type LibrarySelection =
|
|
15
|
+
type LibrarySelection = "*" | string[] | undefined;
|
|
7
16
|
|
|
8
|
-
/** The `libraries` value that stands for every GIR library installed on the search path. */
|
|
9
17
|
const LIBRARIES_WILDCARD = "*";
|
|
10
18
|
const GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\d+(?:\.\d+)*$/;
|
|
11
19
|
const DEFAULT_LIBRARIES: string[] = ["Gtk-4.0"];
|
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;
|
|
@@ -272,7 +294,7 @@ class Library {
|
|
|
272
294
|
seen.add(namespaceName);
|
|
273
295
|
const path = locateGirFile(identifier, girPath);
|
|
274
296
|
girFiles.push(path);
|
|
275
|
-
const header = parseNamespaceHeader(readRepositoryNode(path));
|
|
297
|
+
const header = parseNamespaceHeader(readRepositoryNode(path), path);
|
|
276
298
|
const shell = this.registerNamespace(header);
|
|
277
299
|
discovered.push({ header, shell });
|
|
278
300
|
|
|
@@ -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,58 +1,100 @@
|
|
|
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
|
+
/** Path of the `.gir` file the namespace was parsed from, named by every diagnostic the namespace causes. */
|
|
48
|
+
girFile: string;
|
|
49
|
+
/** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
|
|
28
50
|
sharedLibrary: string | undefined;
|
|
51
|
+
/** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
|
|
29
52
|
cSymbolPrefixes: string[];
|
|
53
|
+
/** GObject classes declared by the namespace. */
|
|
30
54
|
classes: GirClass[];
|
|
55
|
+
/** GObject interfaces declared by the namespace. */
|
|
31
56
|
interfaces: GirClass[];
|
|
57
|
+
/** Structs and unions declared by the namespace. */
|
|
32
58
|
records: GirRecord[];
|
|
59
|
+
/** Enumerations and bitfields declared by the namespace. */
|
|
33
60
|
enums: GirEnum[];
|
|
61
|
+
/** Callback types declared by the namespace. */
|
|
34
62
|
callbacks: GirCallback[];
|
|
63
|
+
/** Free functions declared by the namespace. */
|
|
35
64
|
functions: GirFunction[];
|
|
65
|
+
/** Compile-time values, emitted as module-level `const` bindings. */
|
|
36
66
|
constants: GirConstant[];
|
|
67
|
+
/** Typedefs, emitted as TypeScript type aliases and resolvable as types themselves. */
|
|
37
68
|
aliases: GirAlias[];
|
|
38
69
|
};
|
|
39
70
|
|
|
71
|
+
/** Another namespace a GIR repository depends on. */
|
|
40
72
|
type NamespaceInclude = {
|
|
73
|
+
/** Name of the included namespace, such as `Gio`. */
|
|
41
74
|
name: string;
|
|
75
|
+
/** Version of the included namespace, such as `2.0`. */
|
|
42
76
|
version: string;
|
|
43
77
|
};
|
|
44
78
|
|
|
79
|
+
/** A namespace's declaration and dependencies, read before its body is parsed. */
|
|
45
80
|
type NamespaceHeader = {
|
|
81
|
+
/** Namespace name as it appears in the GIR, such as `Gtk`. */
|
|
46
82
|
name: string;
|
|
83
|
+
/** Path of the `.gir` file the header was read from. */
|
|
84
|
+
girFile: string;
|
|
85
|
+
/** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
|
|
47
86
|
sharedLibrary: string | undefined;
|
|
87
|
+
/** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
|
|
48
88
|
cSymbolPrefixes: string[];
|
|
89
|
+
/** Namespaces this repository includes, each of which is parsed in turn. */
|
|
49
90
|
includes: NamespaceInclude[];
|
|
91
|
+
/** The `<namespace>` node whose children hold the declarations. */
|
|
50
92
|
namespaceNode: RawNode;
|
|
51
93
|
};
|
|
52
94
|
|
|
53
95
|
const namespaceDirectory = (namespace: Pick<GirNamespace, "name">): string => namespace.name.toLowerCase();
|
|
54
96
|
|
|
55
|
-
const parseNamespaceHeader = (repositoryNode: RawNode): NamespaceHeader => {
|
|
97
|
+
const parseNamespaceHeader = (repositoryNode: RawNode, path: string): NamespaceHeader => {
|
|
56
98
|
const includes = getChildren(repositoryNode, "include").map<NamespaceInclude>((include) => ({
|
|
57
99
|
name: nameAttr(include),
|
|
58
100
|
version: attr(include, "version") ?? "",
|
|
@@ -61,11 +103,12 @@ const parseNamespaceHeader = (repositoryNode: RawNode): NamespaceHeader => {
|
|
|
61
103
|
const namespaceNode = getChildren(repositoryNode, "namespace")[0];
|
|
62
104
|
|
|
63
105
|
if (namespaceNode === undefined) {
|
|
64
|
-
throw new Error(
|
|
106
|
+
throw new Error(`GIR file at ${path} has no <namespace> child in its <repository>`);
|
|
65
107
|
}
|
|
66
108
|
|
|
67
109
|
return {
|
|
68
110
|
name: nameAttr(namespaceNode),
|
|
111
|
+
girFile: path,
|
|
69
112
|
sharedLibrary: attr(namespaceNode, "shared-library"),
|
|
70
113
|
cSymbolPrefixes: splitPrefixes(attr(namespaceNode, "c:symbol-prefixes")),
|
|
71
114
|
includes,
|
|
@@ -76,6 +119,7 @@ const parseNamespaceHeader = (repositoryNode: RawNode): NamespaceHeader => {
|
|
|
76
119
|
const createNamespaceShell = (header: NamespaceHeader, id: number): GirNamespace => ({
|
|
77
120
|
id,
|
|
78
121
|
name: header.name,
|
|
122
|
+
girFile: header.girFile,
|
|
79
123
|
sharedLibrary: header.sharedLibrary,
|
|
80
124
|
cSymbolPrefixes: header.cSymbolPrefixes,
|
|
81
125
|
classes: [],
|
|
@@ -97,15 +141,13 @@ const populateNamespaceBody = (shell: GirNamespace, namespaceNode: RawNode, cont
|
|
|
97
141
|
shell.functions = getChildren(namespaceNode, "function").map((fn) => functionFromNode(fn, context));
|
|
98
142
|
|
|
99
143
|
shell.constants = getChildren(namespaceNode, "constant").map((constant) => ({
|
|
100
|
-
|
|
101
|
-
doc: getDoc(constant),
|
|
144
|
+
...documentedFromNode(constant),
|
|
102
145
|
value: attr(constant, "value") ?? "",
|
|
103
146
|
type: typeRefFromNode(constant, context),
|
|
104
147
|
}));
|
|
105
148
|
|
|
106
149
|
shell.aliases = getChildren(namespaceNode, "alias").map((alias) => ({
|
|
107
|
-
|
|
108
|
-
doc: getDoc(alias),
|
|
150
|
+
...documentedFromNode(alias),
|
|
109
151
|
cType: attr(alias, "c:type"),
|
|
110
152
|
target: typeRefFromNode(alias, context),
|
|
111
153
|
targetCType: attr(getChild(alias, "type"), "c:type"),
|
package/src/gir/parameter.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ParseContext, TypeId } from "./type-id.js";
|
|
2
|
+
import { documentedFromNode, type GirAnnotations } from "./annotations.js";
|
|
2
3
|
import {
|
|
3
4
|
attr,
|
|
4
5
|
getChild,
|
|
@@ -12,37 +13,88 @@ import {
|
|
|
12
13
|
} from "./parse.js";
|
|
13
14
|
import { typeRefFromNode } from "./type-ref.js";
|
|
14
15
|
|
|
16
|
+
/** Which way a parameter's value travels: into the call, back out of it, or both. */
|
|
15
17
|
type ParameterDirection = "in" | "out" | "inout";
|
|
18
|
+
/** How much of a value the receiver takes ownership of: none, the whole value, or only its container. */
|
|
16
19
|
type ParameterTransfer = "none" | "full" | "container";
|
|
20
|
+
/**
|
|
21
|
+
* How long a callback parameter stays valid: for the duration of the call, until its destroy notify runs,
|
|
22
|
+
* until the asynchronous operation invokes it, or forever.
|
|
23
|
+
*/
|
|
17
24
|
type CallbackScope = "call" | "notified" | "async" | "forever";
|
|
18
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Bounds of an out parameter that points into the buffer of a sibling parameter instead of to an
|
|
28
|
+
* array of its own, which GIR describes as an array with no extent of any kind.
|
|
29
|
+
*/
|
|
30
|
+
type GirCursorBounds = {
|
|
31
|
+
/** Position of the parameter holding the buffer the pointer points into. */
|
|
32
|
+
baseIndex: number;
|
|
33
|
+
/** Position of the parameter carrying that buffer's element count. */
|
|
34
|
+
lengthIndex: number;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** A parameter of a {@link GirCallable}, with the annotations that decide how it is marshalled. */
|
|
19
38
|
type GirParameter = {
|
|
39
|
+
/** The name GIR gives the parameter. */
|
|
20
40
|
name: string;
|
|
41
|
+
/** What the parameter holds, absent when the GIR node declares no type. */
|
|
21
42
|
type: TypeId | undefined;
|
|
43
|
+
/** The C spelling of the parameter's type, taken from its `type` or `array` child. */
|
|
44
|
+
cType: string | undefined;
|
|
45
|
+
/** Documentation prose from GIR, emitted as the parameter's `@param` text. */
|
|
46
|
+
doc: string | undefined;
|
|
47
|
+
/** Decides whether the parameter is an argument, part of the returned tuple, or both. */
|
|
22
48
|
direction: ParameterDirection;
|
|
49
|
+
/** Ownership the marshalling descriptor is generated with, deciding whether the receiver frees the value. */
|
|
23
50
|
transferOwnership: ParameterTransfer;
|
|
51
|
+
/** Whether the value may be null. */
|
|
24
52
|
nullable: boolean;
|
|
53
|
+
/** Whether the caller may leave the parameter out entirely. */
|
|
25
54
|
optional: boolean;
|
|
55
|
+
/** Whether the caller supplies the storage an out parameter writes into. */
|
|
26
56
|
callerAllocates: boolean;
|
|
57
|
+
/** How long a callback parameter stays valid, absent when GIR carries no scope annotation. */
|
|
27
58
|
scope: CallbackScope | undefined;
|
|
59
|
+
/** Position of the parameter carrying the callback's user data. */
|
|
28
60
|
closureIndex: number | undefined;
|
|
61
|
+
/** Position of the parameter carrying the callback's destroy notify. */
|
|
29
62
|
destroyIndex: number | undefined;
|
|
63
|
+
/** Whether the parameter is the `...` varargs marker. */
|
|
30
64
|
isVarargs: boolean;
|
|
65
|
+
/** Where the buffer is that the parameter points into, when it carries a cursor rather than an array. */
|
|
66
|
+
cursor: GirCursorBounds | undefined;
|
|
31
67
|
};
|
|
32
68
|
|
|
69
|
+
/** What a {@link GirCallable} hands back, with the annotations that decide how it is marshalled. */
|
|
33
70
|
type GirReturnValue = {
|
|
71
|
+
/** What the callable returns, absent when the GIR node declares no type. */
|
|
34
72
|
type: TypeId | undefined;
|
|
73
|
+
/** Documentation prose from GIR, emitted as the callable's `@returns` text. */
|
|
74
|
+
doc: string | undefined;
|
|
75
|
+
/** How much ownership the caller takes of the returned value. */
|
|
35
76
|
transferOwnership: ParameterTransfer;
|
|
77
|
+
/** Whether the returned value may be null. */
|
|
36
78
|
nullable: boolean;
|
|
79
|
+
/** Whether GIR marks the value as skipped, keeping it out of the generated signature. */
|
|
37
80
|
skip: boolean;
|
|
38
81
|
};
|
|
39
82
|
|
|
83
|
+
/** Anything GIR describes with parameters and a return value: functions, methods, signals, and callbacks. */
|
|
40
84
|
type GirCallable = {
|
|
85
|
+
/** The name GIR gives the callable. */
|
|
41
86
|
name: string;
|
|
87
|
+
/** The callable's documentation text, absent when GIR carries none. */
|
|
42
88
|
doc: string | undefined;
|
|
89
|
+
/** Release and deprecation annotations GIR carries on the callable. */
|
|
90
|
+
annotations: GirAnnotations;
|
|
91
|
+
/** The parameters the callable takes, in declaration order. */
|
|
43
92
|
parameters: GirParameter[];
|
|
93
|
+
/** What the callable hands back. */
|
|
44
94
|
returnValue: GirReturnValue;
|
|
95
|
+
/** Whether the callable reports failure through a trailing `GError`. */
|
|
45
96
|
throws: boolean;
|
|
97
|
+
/** Whether GIR exposes the callable to bindings. */
|
|
46
98
|
introspectable: boolean;
|
|
47
99
|
};
|
|
48
100
|
|
|
@@ -62,9 +114,14 @@ const hasNullableAttr = (node: RawNode): boolean =>
|
|
|
62
114
|
const hasOptionalAttr = (node: RawNode): boolean =>
|
|
63
115
|
isAttrTrue(node, "optional") || (!isInDirection(node) && isAttrTrue(node, "allow-none"));
|
|
64
116
|
|
|
117
|
+
const parameterCType = (node: RawNode): string | undefined =>
|
|
118
|
+
attr(getChild(node, "type"), "c:type") ?? attr(getChild(node, "array"), "c:type");
|
|
119
|
+
|
|
65
120
|
const parameterFromNode = (node: RawNode, context: ParseContext): GirParameter => ({
|
|
66
121
|
name: nameAttr(node),
|
|
67
122
|
type: typeRefFromNode(node, context),
|
|
123
|
+
cType: parameterCType(node),
|
|
124
|
+
doc: getDoc(node),
|
|
68
125
|
direction: parseEnumAttr(attr(node, "direction"), DIRECTIONS, "in", "direction"),
|
|
69
126
|
transferOwnership: transferOwnership(node),
|
|
70
127
|
nullable: hasNullableAttr(node),
|
|
@@ -74,6 +131,7 @@ const parameterFromNode = (node: RawNode, context: ParseContext): GirParameter =
|
|
|
74
131
|
closureIndex: intAttr(node, "closure"),
|
|
75
132
|
destroyIndex: intAttr(node, "destroy"),
|
|
76
133
|
isVarargs: getChild(node, "varargs") !== undefined,
|
|
134
|
+
cursor: undefined,
|
|
77
135
|
});
|
|
78
136
|
|
|
79
137
|
const isOutParameter = (parameter: GirParameter): boolean =>
|
|
@@ -86,11 +144,12 @@ const isInoutParameter = (parameter: GirParameter): boolean => parameter.directi
|
|
|
86
144
|
|
|
87
145
|
const returnValueFromNode = (node: RawNode | undefined, context: ParseContext): GirReturnValue => {
|
|
88
146
|
if (node === undefined) {
|
|
89
|
-
return { type: undefined, transferOwnership: "none", nullable: false, skip: false };
|
|
147
|
+
return { type: undefined, doc: undefined, transferOwnership: "none", nullable: false, skip: false };
|
|
90
148
|
}
|
|
91
149
|
|
|
92
150
|
return {
|
|
93
151
|
type: typeRefFromNode(node, context),
|
|
152
|
+
doc: getDoc(node),
|
|
94
153
|
transferOwnership: transferOwnership(node),
|
|
95
154
|
nullable: hasNullableAttr(node),
|
|
96
155
|
skip: isAttrTrue(node, "skip"),
|
|
@@ -102,8 +161,7 @@ const parseCallable = (node: RawNode, context: ParseContext): GirCallable => {
|
|
|
102
161
|
const parameterNodes = getChildren(parametersNode, "parameter");
|
|
103
162
|
|
|
104
163
|
return {
|
|
105
|
-
|
|
106
|
-
doc: getDoc(node),
|
|
164
|
+
...documentedFromNode(node),
|
|
107
165
|
parameters: parameterNodes.map((parameter) => parameterFromNode(parameter, context)),
|
|
108
166
|
returnValue: returnValueFromNode(getChild(node, "return-value"), context),
|
|
109
167
|
throws: isAttrTrue(node, "throws"),
|
|
@@ -119,6 +177,7 @@ export {
|
|
|
119
177
|
isInoutParameter,
|
|
120
178
|
parseCallable,
|
|
121
179
|
type ParameterTransfer,
|
|
180
|
+
type GirCursorBounds,
|
|
122
181
|
type GirParameter,
|
|
123
182
|
type GirReturnValue,
|
|
124
183
|
type GirCallable,
|
package/src/gir/parse.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createXmlParser } from "../xml.js";
|
|
1
|
+
import { createXmlParser, parseXmlFile } from "../xml.js";
|
|
3
2
|
|
|
3
|
+
/** An element of the parsed GIR XML: attributes under `@_`-prefixed keys, children under their tag names. */
|
|
4
4
|
type RawNode = Record<string, unknown>;
|
|
5
5
|
|
|
6
|
+
const GIR_LABEL = "GIR file";
|
|
7
|
+
|
|
6
8
|
const MULTI_TAGS: Set<string> = new Set([
|
|
7
9
|
"include",
|
|
8
10
|
"class",
|
|
@@ -16,6 +18,7 @@ const MULTI_TAGS: Set<string> = new Set([
|
|
|
16
18
|
"alias",
|
|
17
19
|
"union",
|
|
18
20
|
"method",
|
|
21
|
+
"virtual-method",
|
|
19
22
|
"constructor",
|
|
20
23
|
"property",
|
|
21
24
|
"field",
|
|
@@ -40,11 +43,8 @@ function renameReservedTag(tag: string): string {
|
|
|
40
43
|
return RESERVED_TAG_RENAMES.get(tag) ?? tag;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
const parseGirFile = (path: string): RawNode =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return PARSER.parse(xml) as RawNode;
|
|
47
|
-
};
|
|
46
|
+
const parseGirFile = (path: string): RawNode =>
|
|
47
|
+
parseXmlFile({ parser: PARSER, label: GIR_LABEL, path }) as RawNode;
|
|
48
48
|
|
|
49
49
|
const attr = (node: RawNode | undefined, name: string): string | undefined => {
|
|
50
50
|
if (node === undefined) {
|
|
@@ -141,12 +141,12 @@ const docTextFromObject = (value: object): string | undefined => {
|
|
|
141
141
|
return typeof text === "string" ? normalizeDoc(text) : undefined;
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
const
|
|
144
|
+
const docElementText = (node: RawNode | undefined, tag: string): string | undefined => {
|
|
145
145
|
if (node === undefined) {
|
|
146
146
|
return undefined;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
const value = firstDocValue(node
|
|
149
|
+
const value = firstDocValue(node[tag]);
|
|
150
150
|
|
|
151
151
|
if (typeof value === "string") {
|
|
152
152
|
return normalizeDoc(value);
|
|
@@ -159,6 +159,9 @@ const getDoc = (node: RawNode | undefined): string | undefined => {
|
|
|
159
159
|
return docTextFromObject(value);
|
|
160
160
|
};
|
|
161
161
|
|
|
162
|
+
const getDoc = (node: RawNode | undefined): string | undefined => docElementText(node, "doc");
|
|
163
|
+
const getDocDeprecated = (node: RawNode | undefined): string | undefined => docElementText(node, "doc-deprecated");
|
|
164
|
+
|
|
162
165
|
export {
|
|
163
166
|
GIR_CONSTRUCTOR_TAG,
|
|
164
167
|
parseGirFile,
|
|
@@ -170,5 +173,6 @@ export {
|
|
|
170
173
|
getChildren,
|
|
171
174
|
getChild,
|
|
172
175
|
getDoc,
|
|
176
|
+
getDocDeprecated,
|
|
173
177
|
type RawNode,
|
|
174
178
|
};
|
package/src/gir/primitives.ts
CHANGED
package/src/gir/property.ts
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
import type { ParseContext, TypeId } from "./type-id.js";
|
|
2
|
+
import { documentedFromNode, type GirAnnotations } from "./annotations.js";
|
|
2
3
|
import { type ParameterTransfer, transferOwnership } from "./parameter.js";
|
|
3
|
-
import { attr,
|
|
4
|
+
import { attr, isAttrTrue, type RawNode } from "./parse.js";
|
|
4
5
|
import { typeRefFromNode } from "./type-ref.js";
|
|
5
6
|
|
|
7
|
+
/** A GObject property declared on a class or interface, with the annotations its accessors are generated from. */
|
|
6
8
|
type GirProperty = {
|
|
9
|
+
/** Canonical property name, dashed the way GObject registers it. */
|
|
7
10
|
name: string;
|
|
11
|
+
/** Documentation prose from GIR, emitted as the accessor's JSDoc. */
|
|
8
12
|
doc: string | undefined;
|
|
13
|
+
/** Release and deprecation annotations GIR carries on the property. */
|
|
14
|
+
annotations: GirAnnotations;
|
|
15
|
+
/** The property's value type, absent when GIR declares none. */
|
|
9
16
|
type: TypeId | undefined;
|
|
17
|
+
/** Whether GObject exposes the value for reading, which admits a generated getter. */
|
|
10
18
|
readable: boolean;
|
|
19
|
+
/** Whether GObject accepts a value for the property, which admits a generated setter. */
|
|
11
20
|
writable: boolean;
|
|
21
|
+
/** Whether GObject sets the property during construction, using its default when none is supplied. */
|
|
12
22
|
construct: boolean;
|
|
23
|
+
/** Whether the property can only be set at construction. */
|
|
13
24
|
constructOnly: boolean;
|
|
25
|
+
/** Whether GIR exposes the property to bindings. */
|
|
14
26
|
introspectable: boolean;
|
|
27
|
+
/** How ownership of the value transfers, which decides the descriptor the accessors marshal through. */
|
|
15
28
|
transferOwnership: ParameterTransfer;
|
|
29
|
+
/** Method GIR names as reading the property, which the generated getter delegates to. */
|
|
16
30
|
getter: string | undefined;
|
|
31
|
+
/** Method GIR names as writing the property, which the generated setter delegates to. */
|
|
17
32
|
setter: string | undefined;
|
|
33
|
+
/** The property's default, as GIR spells it. */
|
|
18
34
|
defaultValue: string | undefined;
|
|
19
35
|
};
|
|
20
36
|
|
|
@@ -22,8 +38,7 @@ const isConstructableProperty = (property: GirProperty): boolean =>
|
|
|
22
38
|
property.writable || property.construct || property.constructOnly;
|
|
23
39
|
|
|
24
40
|
const propertyFromNode = (node: RawNode, context: ParseContext): GirProperty => ({
|
|
25
|
-
|
|
26
|
-
doc: getDoc(node),
|
|
41
|
+
...documentedFromNode(node),
|
|
27
42
|
type: typeRefFromNode(node, context),
|
|
28
43
|
readable: isAttrTrue(node, "readable", true),
|
|
29
44
|
writable: isAttrTrue(node, "writable"),
|
package/src/gir/record.ts
CHANGED
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
import type { ParseContext } from "./type-id.js";
|
|
2
|
+
import { documentedFromNode, type GirAnnotations } from "./annotations.js";
|
|
2
3
|
import { collectFields, type GirField } from "./field.js";
|
|
3
4
|
import { functionFromNode, type GirFunction } from "./function.js";
|
|
4
|
-
import { attr, getChildren,
|
|
5
|
+
import { attr, getChildren, GIR_CONSTRUCTOR_TAG, isAttrTrue, type RawNode } from "./parse.js";
|
|
5
6
|
|
|
7
|
+
/** A C struct or union declared by a GIR namespace: a plain record, a boxed type, or a GObject vtable. */
|
|
6
8
|
type GirRecord = {
|
|
9
|
+
/** Whether the record is the class or interface struct holding another type's virtual methods. */
|
|
7
10
|
isVtable: boolean;
|
|
11
|
+
/** Name within the declaring namespace, such as `"TextIter"`. */
|
|
8
12
|
name: string;
|
|
13
|
+
/** Raw gtk-doc text from the GIR, undefined when the record is undocumented. */
|
|
9
14
|
doc: string | undefined;
|
|
15
|
+
/** Release and deprecation annotations GIR carries on the record. */
|
|
16
|
+
annotations: GirAnnotations;
|
|
17
|
+
/** C struct name, such as `"GtkTextIter"`. */
|
|
10
18
|
cType: string | undefined;
|
|
19
|
+
/** GLib type name the record is registered under, present when it is a boxed type. */
|
|
11
20
|
glibTypeName: string | undefined;
|
|
21
|
+
/** Name of the function registering the record's GType, such as `"gtk_text_iter_get_type"`. */
|
|
12
22
|
glibGetType: string | undefined;
|
|
23
|
+
/** Name of the function taking a reference, for reference-counted records. */
|
|
13
24
|
glibRefFunc: string | undefined;
|
|
25
|
+
/** Name of the function dropping a reference, for reference-counted records. */
|
|
14
26
|
glibUnrefFunc: string | undefined;
|
|
27
|
+
/** Name of the function duplicating an instance, used when the record has no ref function. */
|
|
15
28
|
copyFunc: string | undefined;
|
|
29
|
+
/** Name of the function releasing an instance, used when the record has no unref function. */
|
|
16
30
|
freeFunc: string | undefined;
|
|
31
|
+
/** Whether the struct is only ever handled behind a pointer, so its layout stays hidden. */
|
|
17
32
|
disguised: boolean;
|
|
33
|
+
/** Whether the struct's fields are private, so instances cannot be allocated or read directly. */
|
|
18
34
|
opaque: boolean;
|
|
35
|
+
/** Whether the record is exposed to language bindings. */
|
|
19
36
|
introspectable: boolean;
|
|
37
|
+
/** Struct members: the named fields first, then the anonymous inline unions, then the inline records. */
|
|
20
38
|
fields: GirField[];
|
|
39
|
+
/** Functions taking an instance of the record as their first argument. */
|
|
21
40
|
methods: GirFunction[];
|
|
41
|
+
/** Functions returning a new instance of the record. */
|
|
22
42
|
constructors: GirFunction[];
|
|
43
|
+
/** Functions scoped to the record but taking no instance. */
|
|
23
44
|
functions: GirFunction[];
|
|
45
|
+
/** Whether the record is a union, so its fields overlap instead of following one another. */
|
|
24
46
|
isUnion: boolean;
|
|
25
47
|
};
|
|
26
48
|
|
|
@@ -31,8 +53,8 @@ const recordFromNode = (
|
|
|
31
53
|
context: ParseContext,
|
|
32
54
|
): GirRecord => ({
|
|
33
55
|
isVtable,
|
|
56
|
+
...documentedFromNode(node),
|
|
34
57
|
name: attr(node, "name") ?? attr(node, "glib:name") ?? "",
|
|
35
|
-
doc: getDoc(node),
|
|
36
58
|
cType: attr(node, "c:type"),
|
|
37
59
|
glibTypeName: attr(node, "glib:type-name"),
|
|
38
60
|
glibGetType: attr(node, "glib:get-type"),
|
package/src/gir/size.ts
CHANGED
|
@@ -11,6 +11,11 @@ type FieldSlot = {
|
|
|
11
11
|
bitWidth: number | undefined;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
type FieldSlots = {
|
|
15
|
+
slots: FieldSlot[];
|
|
16
|
+
size: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
14
19
|
type FieldLayoutInput = {
|
|
15
20
|
layout: FieldLayout;
|
|
16
21
|
bits: number | undefined;
|
|
@@ -39,7 +44,7 @@ const roundUp = (value: number, multiple: number): number => {
|
|
|
39
44
|
return remainder === 0 ? value : value + (multiple - remainder);
|
|
40
45
|
};
|
|
41
46
|
|
|
42
|
-
const computeUnionSlots = (fields: FieldLayoutInput[]):
|
|
47
|
+
const computeUnionSlots = (fields: FieldLayoutInput[]): FieldSlots => {
|
|
43
48
|
let maxSize = 0;
|
|
44
49
|
let maxAlign = 1;
|
|
45
50
|
|
|
@@ -95,7 +100,7 @@ const processStructField = (state: StructLayoutState, slots: FieldSlot[], field:
|
|
|
95
100
|
pushBitfield({ state, slots, field, align, bits: field.bits });
|
|
96
101
|
};
|
|
97
102
|
|
|
98
|
-
const computeStructSlots = (fields: FieldLayoutInput[]):
|
|
103
|
+
const computeStructSlots = (fields: FieldLayoutInput[]): FieldSlots => {
|
|
99
104
|
const slots: FieldSlot[] = [];
|
|
100
105
|
const state: StructLayoutState = { bitCursor: 0, maxAlign: 1 };
|
|
101
106
|
|
|
@@ -106,7 +111,7 @@ const computeStructSlots = (fields: FieldLayoutInput[]): { slots: FieldSlot[]; s
|
|
|
106
111
|
return { slots, size: roundUp(roundUp(state.bitCursor, 8) / 8, state.maxAlign) };
|
|
107
112
|
};
|
|
108
113
|
|
|
109
|
-
const computeFieldSlots = (fields: FieldLayoutInput[], isUnion = false):
|
|
114
|
+
const computeFieldSlots = (fields: FieldLayoutInput[], isUnion = false): FieldSlots =>
|
|
110
115
|
isUnion ? computeUnionSlots(fields) : computeStructSlots(fields);
|
|
111
116
|
|
|
112
117
|
export { layoutOfPrimitive, computeFieldSlots, type FieldLayout, type FieldSlot, type FieldLayoutInput };
|