@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/store/gi/vtable.ts
CHANGED
|
@@ -1,46 +1,116 @@
|
|
|
1
|
-
import { pascalCase,
|
|
2
|
-
import type {
|
|
3
|
-
import type { GirClass } from "../../gir/class.js";
|
|
1
|
+
import { pascalCase, sanitizeTypeIdentifier, sourceStringLiteral } from "@gtkx/utils";
|
|
2
|
+
import type { GirClass, GirVirtualMethod } from "../../gir/class.js";
|
|
4
3
|
import type { GirField } from "../../gir/field.js";
|
|
4
|
+
import type { GirFunction } from "../../gir/function.js";
|
|
5
|
+
import type { Library } from "../../gir/library.js";
|
|
5
6
|
import type { GirParameter } from "../../gir/parameter.js";
|
|
7
|
+
import type { GirRecord } from "../../gir/record.js";
|
|
8
|
+
import type { TypeId } from "../../gir/type-id.js";
|
|
6
9
|
import type { ModuleContext } from "../../writer/context.js";
|
|
10
|
+
import type { JsDocSpec } from "../../writer/doc.js";
|
|
7
11
|
import {
|
|
8
12
|
isInlineCallbackRef,
|
|
9
13
|
isScalarRef,
|
|
10
14
|
renderDescriptor,
|
|
11
15
|
renderParamDescriptor,
|
|
12
16
|
} from "../../analysis/descriptor-render.js";
|
|
13
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
foldedLengthParameters,
|
|
19
|
+
handlerParameters,
|
|
20
|
+
parameterIdentifier,
|
|
21
|
+
renamesWithInstance,
|
|
22
|
+
renderHandlerParameters,
|
|
23
|
+
renderHandlerResultType,
|
|
24
|
+
} from "../../analysis/param-structure.js";
|
|
25
|
+
import { renderTsType } from "../../analysis/ts-type.js";
|
|
26
|
+
import { typeKey } from "../../analysis/type-key.js";
|
|
27
|
+
import { ancestorChain, type ResolvedAncestor, resolveInterfaces } from "../../gir/ancestry.js";
|
|
28
|
+
import { callbackAsFunction, type GirCallback } from "../../gir/callback.js";
|
|
29
|
+
import { renderJsDoc } from "../../writer/doc.js";
|
|
30
|
+
import { renderBlock, renderBraced } from "../../writer/emit.js";
|
|
31
|
+
import { handlerSpec, THROWS_TEXT } from "./doc-spec.js";
|
|
14
32
|
import { computeRecordFieldSlots } from "./record-layout.js";
|
|
15
33
|
|
|
16
34
|
type VtableKind = "class" | "interface";
|
|
35
|
+
type VfuncMemberMode = "implementation" | "requirement" | "signature";
|
|
17
36
|
|
|
18
|
-
type
|
|
37
|
+
type VtableSlot = {
|
|
19
38
|
key: string;
|
|
20
|
-
structName: string;
|
|
21
|
-
kind: VtableKind;
|
|
22
39
|
field: GirField;
|
|
23
40
|
callback: GirCallback;
|
|
41
|
+
vfunc: GirVirtualMethod | undefined;
|
|
24
42
|
byteOffset: number;
|
|
25
|
-
vtableSize: number;
|
|
26
43
|
};
|
|
27
44
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
type VfuncMemberOptions = {
|
|
46
|
+
context: ModuleContext;
|
|
47
|
+
ownerRef: string;
|
|
48
|
+
slot: VtableSlot;
|
|
49
|
+
mode: VfuncMemberMode;
|
|
50
|
+
isProtected: boolean;
|
|
51
|
+
};
|
|
32
52
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
type VfuncMembersOptions = {
|
|
54
|
+
context: ModuleContext;
|
|
55
|
+
klass: GirClass;
|
|
56
|
+
mode: VfuncMemberMode;
|
|
57
|
+
};
|
|
36
58
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
type VfuncSignature = {
|
|
60
|
+
header: string;
|
|
61
|
+
returnType: string;
|
|
62
|
+
};
|
|
40
63
|
|
|
41
|
-
|
|
64
|
+
type VfuncEntry = {
|
|
65
|
+
name: string;
|
|
66
|
+
signature: string;
|
|
67
|
+
doc: string | undefined;
|
|
42
68
|
};
|
|
43
69
|
|
|
70
|
+
type Vtable = {
|
|
71
|
+
structName: string;
|
|
72
|
+
kind: VtableKind;
|
|
73
|
+
vtableSize: number;
|
|
74
|
+
slots: VtableSlot[];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const PADDING_FIELD_NAME = /^(?:reserved|padding)\d*$/i;
|
|
78
|
+
|
|
79
|
+
const UNCALLABLE_SLOT_KEYS: Set<string> = new Set([
|
|
80
|
+
"vfuncDispose",
|
|
81
|
+
"vfuncFinalize",
|
|
82
|
+
"vfuncGetProperty",
|
|
83
|
+
"vfuncSetProperty",
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
const VTABLE_CACHE: WeakMap<GirClass, Vtable> = new WeakMap();
|
|
87
|
+
const PROTECTED_SLOT_NOTE = "It is `protected`, so only a subclass chaining up reaches it.";
|
|
88
|
+
const PUBLIC_SLOT_NOTE = "Calling it from anywhere else re-enters the slot on a live instance.";
|
|
89
|
+
|
|
90
|
+
const vfuncMemberName = (fieldName: string): string => `vfunc${pascalCase(fieldName)}`;
|
|
91
|
+
|
|
92
|
+
const vfuncOverrideNote = (slot: VtableSlot, isProtected: boolean): string =>
|
|
93
|
+
[
|
|
94
|
+
`Invokes the \`${slot.field.name}\` vtable slot. Override it on a class passed to \`registerClass\``,
|
|
95
|
+
`and chain up with \`super.${slot.key}()\`.`,
|
|
96
|
+
isProtected ? PROTECTED_SLOT_NOTE : PUBLIC_SLOT_NOTE,
|
|
97
|
+
].join("\n");
|
|
98
|
+
|
|
99
|
+
const vfuncRequirementNote = (slot: VtableSlot, ownerRef: string): string =>
|
|
100
|
+
[
|
|
101
|
+
`Fills the \`${slot.field.name}\` vtable slot. Declare it on a class passed to \`registerClass\``,
|
|
102
|
+
`with \`${ownerRef}\` in \`implements\`, which installs it in the interface vtable. Leaving it out`,
|
|
103
|
+
"keeps whatever the interface installs by default, the way it does for a C implementer.",
|
|
104
|
+
].join("\n");
|
|
105
|
+
|
|
106
|
+
const vfuncMemberNote = (options: VfuncMemberOptions): string =>
|
|
107
|
+
options.mode === "requirement"
|
|
108
|
+
? vfuncRequirementNote(options.slot, options.ownerRef)
|
|
109
|
+
: vfuncOverrideNote(options.slot, options.isProtected);
|
|
110
|
+
|
|
111
|
+
const isPaddingField = (field: GirField): boolean =>
|
|
112
|
+
field.name.startsWith("_") || PADDING_FIELD_NAME.test(field.name);
|
|
113
|
+
|
|
44
114
|
const vtableCallbackType = (context: ModuleContext, field: GirField): GirCallback | undefined => {
|
|
45
115
|
if (field.type === undefined) {
|
|
46
116
|
return undefined;
|
|
@@ -60,15 +130,19 @@ const vtableSlotEntry = (
|
|
|
60
130
|
field: GirField,
|
|
61
131
|
claimedNames: Set<string>,
|
|
62
132
|
): { key: string; callback: GirCallback } | undefined => {
|
|
133
|
+
if (field.name === "constructor" || isPaddingField(field)) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
|
|
63
137
|
const callback = vtableCallbackType(context, field);
|
|
64
138
|
|
|
65
139
|
if (callback === undefined) {
|
|
66
140
|
return undefined;
|
|
67
141
|
}
|
|
68
142
|
|
|
69
|
-
const key =
|
|
143
|
+
const key = vfuncMemberName(field.name);
|
|
70
144
|
|
|
71
|
-
if (
|
|
145
|
+
if (claimedNames.has(key)) {
|
|
72
146
|
return undefined;
|
|
73
147
|
}
|
|
74
148
|
|
|
@@ -79,53 +153,342 @@ const vtableSlotEntry = (
|
|
|
79
153
|
return { key, callback };
|
|
80
154
|
};
|
|
81
155
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const { slots, size } = computeRecordFieldSlots(context, resolved.value.fields, resolved.value.isUnion);
|
|
90
|
-
const entries: string[] = [];
|
|
156
|
+
const collectVtableSlots = (
|
|
157
|
+
context: ModuleContext,
|
|
158
|
+
fields: GirField[],
|
|
159
|
+
isUnion: boolean,
|
|
160
|
+
): { slots: VtableSlot[]; vtableSize: number } => {
|
|
161
|
+
const { slots, size } = computeRecordFieldSlots(context, fields, isUnion);
|
|
162
|
+
const entries: VtableSlot[] = [];
|
|
91
163
|
const claimedNames: Set<string> = new Set();
|
|
92
164
|
|
|
93
165
|
for (const { field, slot } of slots) {
|
|
94
166
|
const entry = vtableSlotEntry(context, field, claimedNames);
|
|
95
167
|
|
|
96
|
-
if (entry
|
|
97
|
-
|
|
168
|
+
if (entry !== undefined) {
|
|
169
|
+
claimedNames.add(entry.key);
|
|
170
|
+
entries.push({ ...entry, field, vfunc: undefined, byteOffset: slot.byteOffset });
|
|
98
171
|
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return { slots: entries, vtableSize: size };
|
|
175
|
+
};
|
|
99
176
|
|
|
100
|
-
|
|
177
|
+
const resolveVtableRecord = (
|
|
178
|
+
context: ModuleContext,
|
|
179
|
+
namespaceName: string,
|
|
180
|
+
klass: GirClass,
|
|
181
|
+
): { typeStruct: string; record: GirRecord } | undefined => {
|
|
182
|
+
const typeStruct = klass.glibTypeStruct;
|
|
183
|
+
const resolved = typeStruct === undefined ? undefined : context.library.resolveType(namespaceName, typeStruct);
|
|
101
184
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
key: entry.key,
|
|
105
|
-
structName,
|
|
106
|
-
kind,
|
|
107
|
-
field,
|
|
108
|
-
callback: entry.callback,
|
|
109
|
-
byteOffset: slot.byteOffset,
|
|
110
|
-
vtableSize: size,
|
|
111
|
-
}),
|
|
112
|
-
);
|
|
185
|
+
if (typeStruct === undefined || resolved?.kind !== "record" || resolved.value.fields.length === 0) {
|
|
186
|
+
return undefined;
|
|
113
187
|
}
|
|
114
188
|
|
|
115
|
-
return
|
|
189
|
+
return { typeStruct, record: resolved.value };
|
|
116
190
|
};
|
|
117
191
|
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
192
|
+
const attachVirtualMethods = (slots: VtableSlot[], klass: GirClass): VtableSlot[] => {
|
|
193
|
+
const byKey: Map<string, GirVirtualMethod> = new Map(
|
|
194
|
+
klass.vfuncs.map((vfunc) => [vfuncMemberName(vfunc.name), vfunc]),
|
|
195
|
+
);
|
|
122
196
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
197
|
+
return slots.map((slot) => ({ ...slot, vfunc: byKey.get(slot.key) }));
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const buildVtable = (context: ModuleContext, namespaceName: string, klass: GirClass): Vtable | undefined => {
|
|
201
|
+
const resolved = resolveVtableRecord(context, namespaceName, klass);
|
|
202
|
+
|
|
203
|
+
if (resolved === undefined) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const { slots, vtableSize } = collectVtableSlots(context, resolved.record.fields, resolved.record.isUnion);
|
|
208
|
+
|
|
209
|
+
if (slots.length === 0) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
structName: pascalCase(resolved.typeStruct),
|
|
215
|
+
kind: klass.isInterface ? "interface" : "class",
|
|
216
|
+
vtableSize,
|
|
217
|
+
slots: disambiguateSlots(context, namespaceName, klass, attachVirtualMethods(slots, klass)),
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const collectVtable = (context: ModuleContext, namespaceName: string, klass: GirClass): Vtable | undefined => {
|
|
222
|
+
const cached = VTABLE_CACHE.get(klass);
|
|
223
|
+
|
|
224
|
+
if (cached !== undefined) {
|
|
225
|
+
return cached;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const vtable = buildVtable(context, namespaceName, klass);
|
|
229
|
+
|
|
230
|
+
if (vtable !== undefined) {
|
|
231
|
+
VTABLE_CACHE.set(klass, vtable);
|
|
126
232
|
}
|
|
127
233
|
|
|
128
|
-
|
|
234
|
+
return vtable;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const shadowedSlotKey = (klass: GirClass, slot: VtableSlot): string =>
|
|
238
|
+
`vfunc${sanitizeTypeIdentifier(klass.name)}${pascalCase(slot.field.name)}`;
|
|
239
|
+
|
|
240
|
+
const slotSignatureKey = (library: Library, slot: VtableSlot): string => {
|
|
241
|
+
const [, ...parameters] = slot.callback.parameters;
|
|
242
|
+
|
|
243
|
+
const parts = parameters.map(
|
|
244
|
+
(parameter) => `${typeKey(library, parameter.type)}/${parameter.direction}/${String(parameter.nullable)}`);
|
|
245
|
+
|
|
246
|
+
return `${parts.join(",")}->${typeKey(library, slot.callback.returnValue.type)}`;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const isShadowingSlot = (library: Library, slot: VtableSlot, inherited: VtableSlot[]): boolean =>
|
|
250
|
+
inherited.some(
|
|
251
|
+
(other) =>
|
|
252
|
+
other.key === slot.key &&
|
|
253
|
+
slotIdentity(other) !== slotIdentity(slot) &&
|
|
254
|
+
slotSignatureKey(library, other) !== slotSignatureKey(library, slot));
|
|
255
|
+
|
|
256
|
+
const disambiguateSlots = (
|
|
257
|
+
context: ModuleContext,
|
|
258
|
+
namespaceName: string,
|
|
259
|
+
klass: GirClass,
|
|
260
|
+
slots: VtableSlot[],
|
|
261
|
+
): VtableSlot[] => {
|
|
262
|
+
const inherited = ancestorSlots(context, namespaceName, klass);
|
|
263
|
+
|
|
264
|
+
return slots.map((slot) =>
|
|
265
|
+
isShadowingSlot(context.library, slot, inherited) ? { ...slot, key: shadowedSlotKey(klass, slot) } : slot);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const ancestorSlots = (context: ModuleContext, namespaceName: string, klass: GirClass): VtableSlot[] => {
|
|
269
|
+
const [, ...ancestors] = [...ancestorChain(context.library, klass, namespaceName)];
|
|
270
|
+
|
|
271
|
+
return ancestors.flatMap((ancestor) => collectVtable(context, ancestor.namespaceName, ancestor.klass)?.slots ?? []);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const vfuncMemberNames = (context: ModuleContext, namespaceName: string, klass: GirClass): string[] =>
|
|
275
|
+
collectVtable(context, namespaceName, klass)?.slots.map((slot) => slot.key) ?? [];
|
|
276
|
+
|
|
277
|
+
const renderVfuncMetadata = (context: ModuleContext, klass: GirClass): string | undefined => {
|
|
278
|
+
const vtable = collectVtable(context, context.namespace.name, klass);
|
|
279
|
+
|
|
280
|
+
if (vtable === undefined) {
|
|
281
|
+
return undefined;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const entries = vtable.slots.map((slot) => renderVtableSlotDescriptor(context, vtable, slot));
|
|
285
|
+
|
|
286
|
+
return renderBraced(entries.join("\n"));
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const slotIdentity = (slot: VtableSlot): string => `${slot.key}:${String(slot.byteOffset)}`;
|
|
290
|
+
|
|
291
|
+
const inheritedSlotIdentities = (context: ModuleContext, namespaceName: string, klass: GirClass): Set<string> =>
|
|
292
|
+
new Set(ancestorSlots(context, namespaceName, klass).map((slot) => slotIdentity(slot)));
|
|
293
|
+
|
|
294
|
+
const addInterfaceSlotKeys = (
|
|
295
|
+
context: ModuleContext,
|
|
296
|
+
iface: ResolvedAncestor,
|
|
297
|
+
keys: Set<string>,
|
|
298
|
+
seen: Set<string>,
|
|
299
|
+
): void => {
|
|
300
|
+
const identity = `${iface.namespaceName}.${iface.klass.name}`;
|
|
301
|
+
|
|
302
|
+
if (seen.has(identity)) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
seen.add(identity);
|
|
307
|
+
|
|
308
|
+
for (const key of vfuncMemberNames(context, iface.namespaceName, iface.klass)) {
|
|
309
|
+
keys.add(key);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
for (const ref of resolveInterfaces(context.library, iface.namespaceName, iface.klass.prerequisites)) {
|
|
313
|
+
addInterfaceSlotKeys(context, ref, keys, seen);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const implementedSlotKeys = (context: ModuleContext, namespaceName: string, klass: GirClass): Set<string> => {
|
|
318
|
+
const keys: Set<string> = new Set();
|
|
319
|
+
const seen: Set<string> = new Set();
|
|
320
|
+
|
|
321
|
+
for (const ancestor of ancestorChain(context.library, klass, namespaceName)) {
|
|
322
|
+
for (const ref of resolveInterfaces(context.library, ancestor.namespaceName, ancestor.klass.implements)) {
|
|
323
|
+
addInterfaceSlotKeys(context, ref, keys, seen);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return keys;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
const protectedSlotKeys = (options: VfuncMembersOptions, slots: VtableSlot[]): Set<string> => {
|
|
331
|
+
const { context, klass } = options;
|
|
332
|
+
|
|
333
|
+
if (klass.isInterface) {
|
|
334
|
+
return new Set();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const shared = implementedSlotKeys(context, context.namespace.name, klass);
|
|
338
|
+
|
|
339
|
+
return new Set(slots.map((slot) => slot.key).filter((key) => !shared.has(key)));
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const vfuncCallables = (context: ModuleContext, namespaceName: string, klass: GirClass): Map<string, GirFunction> => {
|
|
343
|
+
const members: Map<string, GirFunction> = new Map();
|
|
344
|
+
|
|
345
|
+
for (const slot of callableVfuncSlots(context, namespaceName, klass)) {
|
|
346
|
+
const [, ...parameters] = slot.callback.parameters;
|
|
347
|
+
members.set(slot.key, { ...callbackAsFunction(slot.callback), parameters });
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return members;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
const addProtectedSlotKeys = (context: ModuleContext, ancestor: ResolvedAncestor, keys: Set<string>): void => {
|
|
354
|
+
const shared = implementedSlotKeys(context, ancestor.namespaceName, ancestor.klass);
|
|
355
|
+
|
|
356
|
+
for (const slot of callableVfuncSlots(context, ancestor.namespaceName, ancestor.klass)) {
|
|
357
|
+
if (!shared.has(slot.key)) {
|
|
358
|
+
keys.add(slot.key);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const protectedChainSlotKeys = (context: ModuleContext, klass: GirClass): Set<string> => {
|
|
364
|
+
const keys: Set<string> = new Set();
|
|
365
|
+
|
|
366
|
+
for (const ancestor of ancestorChain(context.library, klass, context.namespace.name)) {
|
|
367
|
+
addProtectedSlotKeys(context, ancestor, keys);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return keys;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
const callableVfuncSlots = (context: ModuleContext, namespaceName: string, klass: GirClass): VtableSlot[] => {
|
|
374
|
+
const vtable = collectVtable(context, namespaceName, klass);
|
|
375
|
+
|
|
376
|
+
if (vtable === undefined) {
|
|
377
|
+
return [];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const inherited = inheritedSlotIdentities(context, namespaceName, klass);
|
|
381
|
+
|
|
382
|
+
return vtable.slots.filter((slot) => isCallableSlot(context, slot) && !inherited.has(slotIdentity(slot)));
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const hasCallableVfuncSlots = (context: ModuleContext, namespaceName: string, klass: GirClass): boolean =>
|
|
386
|
+
callableVfuncSlots(context, namespaceName, klass).length > 0;
|
|
387
|
+
|
|
388
|
+
const slotDoc = (slot: VtableSlot): string | undefined => slot.vfunc?.doc ?? slot.field.doc ?? slot.callback.doc;
|
|
389
|
+
|
|
390
|
+
const slotDocParameters = (slot: VtableSlot): GirParameter[] => {
|
|
391
|
+
const [, ...parameters] = slot.callback.parameters;
|
|
392
|
+
const vfuncParameters = slot.vfunc?.parameters ?? [];
|
|
393
|
+
|
|
394
|
+
return parameters.map((parameter, index) => ({ ...parameter, doc: vfuncParameters[index]?.doc ?? parameter.doc }));
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
const slotDocSpec = (slot: VtableSlot): JsDocSpec => {
|
|
398
|
+
const parameters = slotDocParameters(slot);
|
|
399
|
+
const source = slot.vfunc ?? slot.callback;
|
|
400
|
+
|
|
401
|
+
return {
|
|
402
|
+
...handlerSpec(source, parameters, renamesWithInstance(parameters, slot.callback.parameters[0])),
|
|
403
|
+
returns: slot.vfunc?.returnValue.doc ?? slot.callback.returnValue.doc,
|
|
404
|
+
throws: slot.callback.throws ? THROWS_TEXT : undefined,
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
const vfuncEntries = (context: ModuleContext, namespaceName: string, klass: GirClass): VfuncEntry[] =>
|
|
409
|
+
callableVfuncSlots(context, namespaceName, klass).map((slot) => ({
|
|
410
|
+
name: slot.key,
|
|
411
|
+
signature: vfuncSlotSignature(context, slot).header,
|
|
412
|
+
doc: slotDoc(slot),
|
|
413
|
+
}));
|
|
414
|
+
|
|
415
|
+
const renderVfuncMembers = (options: VfuncMembersOptions): string[] => {
|
|
416
|
+
const { context, klass, mode } = options;
|
|
417
|
+
const ownerRef = sanitizeTypeIdentifier(klass.name);
|
|
418
|
+
const slots = callableVfuncSlots(context, context.namespace.name, klass);
|
|
419
|
+
|
|
420
|
+
if (slots.length === 0) {
|
|
421
|
+
return [];
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (mode === "implementation") {
|
|
425
|
+
context.addRuntimeImport("callVfunc");
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const protectedKeys = protectedSlotKeys(options, slots);
|
|
429
|
+
|
|
430
|
+
return slots.map((slot) =>
|
|
431
|
+
renderVfuncMember({ context, ownerRef, slot, mode, isProtected: protectedKeys.has(slot.key) }));
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
const hasUnannotatedPointerParam = (context: ModuleContext, slot: VtableSlot): boolean => {
|
|
435
|
+
const [, ...parameters] = slot.callback.parameters;
|
|
436
|
+
|
|
437
|
+
return parameters.some(
|
|
438
|
+
(parameter) =>
|
|
439
|
+
parameter.direction === "in" &&
|
|
440
|
+
parameter.cType?.endsWith("*") === true &&
|
|
441
|
+
isScalarRef(context.library, parameter.type),
|
|
442
|
+
);
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
const isCallableSlot = (context: ModuleContext, slot: VtableSlot): boolean =>
|
|
446
|
+
!UNCALLABLE_SLOT_KEYS.has(slot.key) && !hasUnannotatedPointerParam(context, slot);
|
|
447
|
+
|
|
448
|
+
const vfuncSlotSignature = (context: ModuleContext, slot: VtableSlot, isOptional = false): VfuncSignature => {
|
|
449
|
+
const [, ...parameters] = slot.callback.parameters;
|
|
450
|
+
|
|
451
|
+
const renderType = (ref: TypeId | undefined, isNullable: boolean): string =>
|
|
452
|
+
renderTsType(context, ref, isNullable);
|
|
453
|
+
|
|
454
|
+
const signature = renderHandlerParameters(parameters, renderType).join(", ");
|
|
455
|
+
const folded = foldedLengthParameters(context.library, slot.callback);
|
|
456
|
+
|
|
457
|
+
const returnType = renderHandlerResultType({
|
|
458
|
+
library: context.library,
|
|
459
|
+
signal: { ...slot.callback, parameters },
|
|
460
|
+
renderType,
|
|
461
|
+
shouldIncludeCallerAllocated: true,
|
|
462
|
+
isOptOut: false,
|
|
463
|
+
shouldExcludeOut: (parameter) => folded.has(parameter),
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
return { header: `${slot.key}${isOptional ? "?" : ""}(${signature}): ${returnType}`, returnType };
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
const renderVfuncMember = (options: VfuncMemberOptions): string => {
|
|
470
|
+
const { context, ownerRef, slot, mode, isProtected } = options;
|
|
471
|
+
const { header, returnType } = vfuncSlotSignature(context, slot, mode === "requirement");
|
|
472
|
+
const declaration = `${isProtected ? "protected " : ""}${header}`;
|
|
473
|
+
const doc = renderJsDoc(slotDoc(slot), vfuncMemberNote(options), slotDocSpec(slot));
|
|
474
|
+
|
|
475
|
+
if (mode !== "implementation") {
|
|
476
|
+
return `${doc}${declaration};`;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const [, ...parameters] = slot.callback.parameters;
|
|
480
|
+
|
|
481
|
+
const inputs = handlerParameters(parameters).map((parameter, index) =>
|
|
482
|
+
parameterIdentifier(parameter, index));
|
|
483
|
+
|
|
484
|
+
const call = `callVfunc(${ownerRef}, ${sourceStringLiteral(slot.key)}, this, [${inputs.join(", ")}])`;
|
|
485
|
+
const body = returnType === "void" ? `${call};` : `return ${call} as ${returnType};`;
|
|
486
|
+
|
|
487
|
+
return `${doc}${renderBlock(declaration, body)}`;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
const isEligibleVtableParam = (context: ModuleContext, param: GirParameter): boolean => {
|
|
491
|
+
if (param.isVarargs) {
|
|
129
492
|
return false;
|
|
130
493
|
}
|
|
131
494
|
|
|
@@ -146,8 +509,8 @@ const isVtableSlotEligible = (context: ModuleContext, callback: GirCallback): bo
|
|
|
146
509
|
return !isInlineCallbackRef(context.library, callback.returnValue.type);
|
|
147
510
|
};
|
|
148
511
|
|
|
149
|
-
const renderVtableSlotDescriptor = (context: ModuleContext,
|
|
150
|
-
const { key,
|
|
512
|
+
const renderVtableSlotDescriptor = (context: ModuleContext, vtable: Vtable, slot: VtableSlot): string => {
|
|
513
|
+
const { key, field, callback, byteOffset } = slot;
|
|
151
514
|
|
|
152
515
|
const argDescriptors = callback.parameters
|
|
153
516
|
.map((param) => renderParamDescriptor(context, param, param.type))
|
|
@@ -160,16 +523,31 @@ const renderVtableSlotDescriptor = (context: ModuleContext, options: RenderVtabl
|
|
|
160
523
|
);
|
|
161
524
|
|
|
162
525
|
const lines = [
|
|
163
|
-
`
|
|
164
|
-
`className: ${sourceStringLiteral(structName)},`,
|
|
526
|
+
`className: ${sourceStringLiteral(vtable.structName)},`,
|
|
165
527
|
`vfuncName: ${sourceStringLiteral(field.name)},`,
|
|
166
528
|
`byteOffset: ${String(byteOffset)},`,
|
|
167
|
-
`vtableSize: ${String(vtableSize)},`,
|
|
168
|
-
`argDescriptors: [${argDescriptors}],`,
|
|
169
|
-
`returnDescriptor: ${returnDescriptor},`,
|
|
170
529
|
];
|
|
171
530
|
|
|
531
|
+
if (vtable.kind === "interface") {
|
|
532
|
+
lines.push(`vtableSize: ${String(vtable.vtableSize)},`);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
lines.push(`argDescriptors: [${argDescriptors}],`, `returnDescriptor: ${returnDescriptor},`);
|
|
536
|
+
|
|
537
|
+
if (callback.throws) {
|
|
538
|
+
lines.push("canThrow: true,");
|
|
539
|
+
}
|
|
540
|
+
|
|
172
541
|
return `${key}: ${renderBraced(lines.join("\n"))},`;
|
|
173
542
|
};
|
|
174
543
|
|
|
175
|
-
export {
|
|
544
|
+
export {
|
|
545
|
+
hasCallableVfuncSlots,
|
|
546
|
+
protectedChainSlotKeys,
|
|
547
|
+
renderVfuncMembers,
|
|
548
|
+
vfuncCallables,
|
|
549
|
+
renderVfuncMetadata,
|
|
550
|
+
vfuncEntries,
|
|
551
|
+
vfuncMemberNames,
|
|
552
|
+
type VfuncMemberMode,
|
|
553
|
+
};
|
package/src/store/gi-store.ts
CHANGED
|
@@ -1,64 +1,59 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import type { SourceModule } from "../compile.js";
|
|
4
5
|
import { FINGERPRINT_FILENAME, type GiFingerprint } from "../fingerprint.js";
|
|
5
|
-
import { buildManifest, type StoreOptions, subpathExport, writeStore } from "./store-fs.js";
|
|
6
|
+
import { buildManifest, namespaceBarrel, type StoreOptions, subpathExport, writeStore } from "./store-fs.js";
|
|
6
7
|
|
|
7
8
|
type GiNamespaceInput = {
|
|
8
9
|
directory: string;
|
|
9
10
|
rawSource: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type CollectedFile = {
|
|
13
|
-
fileName: string;
|
|
14
|
-
source: string;
|
|
11
|
+
girFile: string;
|
|
15
12
|
};
|
|
16
13
|
|
|
17
14
|
const OVERRIDES_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "overrides");
|
|
18
15
|
|
|
19
|
-
const overrideFiles = (directory: string):
|
|
16
|
+
const overrideFiles = (directory: string): SourceModule[] => {
|
|
20
17
|
const dir = join(OVERRIDES_ROOT, directory);
|
|
21
18
|
|
|
22
19
|
if (!existsSync(dir)) {
|
|
23
20
|
return [];
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
return readdirSync(dir)
|
|
23
|
+
return readdirSync(dir)
|
|
24
|
+
.filter((name) => name.endsWith(".ejs") && name !== "index.ts.ejs")
|
|
25
|
+
.map((name) => overrideModule(`${directory}/overrides/${name.replace(/\.ejs$/, "")}`, join(dir, name)));
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
const
|
|
28
|
+
const overrideModule = (fileName: string, overridePath: string): SourceModule => ({
|
|
29
|
+
fileName,
|
|
30
|
+
source: readFileSync(overridePath, "utf8"),
|
|
31
|
+
origin: overridePath,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const barrelFile = (directory: string, girFile: string): SourceModule => {
|
|
35
|
+
const barrel = namespaceBarrel(directory);
|
|
30
36
|
const overrideIndex = join(OVERRIDES_ROOT, directory, "index.ts.ejs");
|
|
31
37
|
|
|
32
38
|
if (!existsSync(overrideIndex)) {
|
|
33
|
-
return
|
|
39
|
+
return { ...barrel, origin: girFile };
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
return
|
|
42
|
+
return overrideModule(barrel.fileName, overrideIndex);
|
|
37
43
|
};
|
|
38
44
|
|
|
39
45
|
const collectStoreSources = (
|
|
40
46
|
namespaces: GiNamespaceInput[],
|
|
41
|
-
): { collected:
|
|
47
|
+
): { collected: SourceModule[]; exportsMap: Record<string, unknown> } => {
|
|
42
48
|
const exportsMap: Record<string, unknown> = {};
|
|
43
|
-
const collected:
|
|
44
|
-
|
|
45
|
-
for (const { directory, rawSource } of namespaces) {
|
|
46
|
-
collected.push(
|
|
47
|
-
fileName: `${directory}/${directory}.ts`,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
for (const file of overrideFiles(directory)) {
|
|
52
|
-
collected.push({
|
|
53
|
-
fileName: `${directory}/overrides/${file.replace(/\.ejs$/, "")}`,
|
|
54
|
-
source: readFileSync(join(OVERRIDES_ROOT, directory, file), "utf8"),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
collected.push({
|
|
59
|
-
fileName: `${directory}/index.ts`,
|
|
60
|
-
source: barrelSource(directory),
|
|
61
|
-
});
|
|
49
|
+
const collected: SourceModule[] = [];
|
|
50
|
+
|
|
51
|
+
for (const { directory, rawSource, girFile } of namespaces) {
|
|
52
|
+
collected.push(
|
|
53
|
+
{ fileName: `${directory}/${directory}.ts`, source: rawSource, origin: girFile },
|
|
54
|
+
...overrideFiles(directory),
|
|
55
|
+
barrelFile(directory, girFile),
|
|
56
|
+
);
|
|
62
57
|
|
|
63
58
|
exportsMap[`./${directory}`] = subpathExport(`${directory}/index`);
|
|
64
59
|
}
|