@gtkx/codegen 1.0.0-rc.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/analysis/descriptor-render.d.ts +8 -1
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +37 -24
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +1 -1
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/inheritance.d.ts +1 -2
- package/dist/analysis/inheritance.d.ts.map +1 -1
- package/dist/analysis/inheritance.js +25 -22
- package/dist/analysis/inheritance.js.map +1 -1
- package/dist/analysis/nul-terminated-bytes.d.ts +5 -0
- package/dist/analysis/nul-terminated-bytes.d.ts.map +1 -0
- package/dist/analysis/nul-terminated-bytes.js +18 -0
- package/dist/analysis/nul-terminated-bytes.js.map +1 -0
- package/dist/analysis/param-capability.d.ts +5 -0
- package/dist/analysis/param-capability.d.ts.map +1 -0
- package/dist/analysis/param-capability.js +130 -0
- package/dist/analysis/param-capability.js.map +1 -0
- package/dist/analysis/param-structure.d.ts +11 -4
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +40 -14
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/type-shape.d.ts +8 -0
- package/dist/analysis/type-shape.d.ts.map +1 -0
- package/dist/analysis/type-shape.js +12 -0
- package/dist/analysis/type-shape.js.map +1 -0
- package/dist/compile.d.ts +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js.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 +7 -14
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/element-page.d.ts +4 -4
- package/dist/docs/element-page.d.ts.map +1 -1
- package/dist/docs/element-page.js +32 -20
- package/dist/docs/element-page.js.map +1 -1
- package/dist/docs/handwritten-props.d.ts +9 -0
- package/dist/docs/handwritten-props.d.ts.map +1 -0
- package/dist/docs/handwritten-props.js +149 -0
- package/dist/docs/handwritten-props.js.map +1 -0
- package/dist/docs/pipeline.js +2 -2
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.d.ts +25 -5
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +84 -22
- 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 +128 -43
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +1 -1
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js.map +1 -1
- package/dist/gir/ancestry.d.ts +2 -2
- package/dist/gir/ancestry.d.ts.map +1 -1
- package/dist/gir/ancestry.js +11 -1
- package/dist/gir/ancestry.js.map +1 -1
- package/dist/gir/annotations.d.ts +22 -0
- package/dist/gir/annotations.d.ts.map +1 -0
- package/dist/gir/annotations.js +15 -0
- package/dist/gir/annotations.js.map +1 -0
- package/dist/gir/callback.d.ts +1 -0
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +1 -0
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +32 -1
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +8 -3
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +21 -1
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +9 -9
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +19 -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.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 +34 -0
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/namespace.d.ts +38 -0
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +4 -5
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/parameter.d.ts +39 -0
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +7 -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 +6 -3
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +1 -0
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +16 -0
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +3 -3
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +22 -0
- package/dist/gir/record.d.ts.map +1 -1
- package/dist/gir/record.js +3 -2
- package/dist/gir/record.js.map +1 -1
- package/dist/gir/size.d.ts +5 -4
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js.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/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 +96 -26
- package/dist/khronos/modules.js.map +1 -1
- package/dist/khronos/notes.d.ts +19 -0
- package/dist/khronos/notes.d.ts.map +1 -0
- package/dist/khronos/notes.js +35 -0
- package/dist/khronos/notes.js.map +1 -0
- package/dist/khronos/param-pair.d.ts +1 -1
- package/dist/khronos/param-pair.d.ts.map +1 -1
- package/dist/khronos/param-pair.js.map +1 -1
- package/dist/khronos/pipeline.d.ts +3 -1
- package/dist/khronos/pipeline.d.ts.map +1 -1
- package/dist/khronos/pipeline.js +58 -27
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +3 -3
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +2 -2
- 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 +1 -7
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js.map +1 -1
- 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.map +1 -1
- package/dist/store/gi/callable-doc.d.ts +11 -0
- package/dist/store/gi/callable-doc.d.ts.map +1 -0
- package/dist/store/gi/callable-doc.js +62 -0
- package/dist/store/gi/callable-doc.js.map +1 -0
- package/dist/store/gi/callables.d.ts +3 -1
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +12 -12
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/callback.d.ts.map +1 -1
- package/dist/store/gi/callback.js +2 -2
- package/dist/store/gi/callback.js.map +1 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +5 -3
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/closure-invocation.d.ts +4 -0
- package/dist/store/gi/closure-invocation.d.ts.map +1 -0
- package/dist/store/gi/closure-invocation.js +22 -0
- package/dist/store/gi/closure-invocation.js.map +1 -0
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +3 -2
- package/dist/store/gi/constant.js.map +1 -1
- package/dist/store/gi/constructor-props.d.ts.map +1 -1
- package/dist/store/gi/constructor-props.js +18 -20
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/doc-spec.d.ts +14 -0
- package/dist/store/gi/doc-spec.d.ts.map +1 -0
- package/dist/store/gi/doc-spec.js +23 -0
- package/dist/store/gi/doc-spec.js.map +1 -0
- package/dist/store/gi/enum.d.ts.map +1 -1
- package/dist/store/gi/enum.js +29 -16
- package/dist/store/gi/enum.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +27 -12
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/interface.d.ts.map +1 -1
- package/dist/store/gi/interface.js +130 -16
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/item-comparators.d.ts.map +1 -1
- package/dist/store/gi/item-comparators.js +3 -5
- package/dist/store/gi/item-comparators.js.map +1 -1
- package/dist/store/gi/method.d.ts +9 -1
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +69 -26
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +4 -1
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +5 -1
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/pipeline.d.ts.map +1 -1
- package/dist/store/gi/pipeline.js +3 -2
- package/dist/store/gi/pipeline.js.map +1 -1
- package/dist/store/gi/properties.d.ts.map +1 -1
- package/dist/store/gi/properties.js +2 -2
- package/dist/store/gi/properties.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +3 -1
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +6 -5
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +3 -1
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +3 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +3 -2
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.js +1 -1
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +3 -2
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/registration.d.ts +1 -1
- package/dist/store/gi/registration.js +2 -2
- package/dist/store/gi/registration.js.map +1 -1
- package/dist/store/gi/runtime-override.d.ts +2 -1
- package/dist/store/gi/runtime-override.d.ts.map +1 -1
- package/dist/store/gi/runtime-override.js +8 -5
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +14 -15
- 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 +1 -1
- package/dist/store/gi/value-marshalable.js.map +1 -1
- package/dist/store/gi/vtable.d.ts +16 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +214 -51
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/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/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 +7 -6
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx/metadata.js +2 -2
- 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/writer/context.d.ts +2 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +3 -0
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/doc-tags.d.ts +21 -0
- package/dist/writer/doc-tags.d.ts.map +1 -0
- package/dist/writer/doc-tags.js +38 -0
- package/dist/writer/doc-tags.js.map +1 -0
- package/dist/writer/doc.d.ts +3 -1
- package/dist/writer/doc.d.ts.map +1 -1
- package/dist/writer/doc.js +19 -6
- package/dist/writer/doc.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts +1 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +64 -15
- package/dist/writer/gtk-doc.js.map +1 -1
- package/dist/writer/module.d.ts +8 -2
- package/dist/writer/module.d.ts.map +1 -1
- package/dist/writer/module.js +13 -1
- package/dist/writer/module.js.map +1 -1
- package/overrides/gdk/rgba.ts.ejs +26 -0
- package/overrides/gobject/object.ts.ejs +48 -3
- package/overrides/gobject/value.ts.ejs +7 -0
- package/overrides/graphene/structs.ts.ejs +55 -0
- package/package.json +4 -4
- package/src/analysis/descriptor-render.ts +47 -28
- package/src/analysis/descriptor.ts +0 -3
- package/src/analysis/inheritance.ts +35 -34
- package/src/analysis/nul-terminated-bytes.ts +31 -0
- package/src/analysis/param-capability.ts +172 -0
- package/src/analysis/param-structure.ts +83 -23
- package/src/analysis/type-shape.ts +24 -0
- package/src/compile.ts +1 -1
- package/src/docs/api-reference.ts +36 -25
- package/src/docs/element-page.ts +53 -47
- package/src/docs/handwritten-props.ts +230 -0
- package/src/docs/pipeline.ts +2 -2
- package/src/docs/render.ts +146 -32
- package/src/docs/symbol-page.ts +224 -79
- package/src/fingerprint.ts +0 -1
- package/src/gir/ancestry.ts +15 -1
- package/src/gir/annotations.ts +37 -0
- package/src/gir/callback.ts +2 -0
- package/src/gir/class.ts +42 -4
- package/src/gir/enum.ts +30 -10
- package/src/gir/field.ts +24 -9
- package/src/gir/function.ts +15 -0
- package/src/gir/libraries.ts +11 -3
- package/src/gir/library.ts +51 -2
- package/src/gir/namespace.ts +41 -5
- package/src/gir/parameter.ts +47 -3
- package/src/gir/parse.ts +8 -2
- package/src/gir/primitives.ts +1 -0
- package/src/gir/property.ts +18 -3
- package/src/gir/record.ts +24 -2
- package/src/gir/size.ts +8 -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/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 +134 -40
- package/src/khronos/notes.ts +74 -0
- package/src/khronos/param-pair.ts +1 -1
- package/src/khronos/pipeline.ts +94 -41
- package/src/khronos/plan.ts +4 -5
- 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 +1 -8
- package/src/store/compile-store.ts +1 -1
- package/src/store/gi/callable-doc.ts +102 -0
- package/src/store/gi/callables.ts +18 -12
- package/src/store/gi/callback.ts +3 -2
- package/src/store/gi/class.ts +6 -3
- package/src/store/gi/closure-invocation.ts +26 -0
- package/src/store/gi/constant.ts +3 -4
- package/src/store/gi/constructor-props.ts +19 -23
- package/src/store/gi/doc-spec.ts +38 -0
- package/src/store/gi/enum.ts +55 -20
- package/src/store/gi/function.ts +43 -21
- package/src/store/gi/interface.ts +214 -26
- package/src/store/gi/item-comparators.ts +3 -5
- package/src/store/gi/method.ts +98 -42
- package/src/store/gi/param-marshal.ts +15 -1
- package/src/store/gi/pipeline.ts +7 -2
- package/src/store/gi/properties.ts +3 -2
- package/src/store/gi/property-accessor.ts +9 -4
- package/src/store/gi/record-constructor.ts +6 -1
- package/src/store/gi/record-field-accessor.ts +5 -3
- package/src/store/gi/record-layout.ts +1 -1
- package/src/store/gi/record.ts +8 -2
- package/src/store/gi/registration.ts +3 -3
- package/src/store/gi/runtime-override.ts +13 -6
- package/src/store/gi/signal.ts +19 -20
- package/src/store/gi/value-marshalable.ts +1 -1
- package/src/store/gi/vtable.ts +361 -60
- 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/intrinsic-elements.ts +4 -0
- package/src/store/jsx/jsx.ts +8 -6
- package/src/store/jsx/metadata.ts +2 -2
- package/src/store/jsx/pipeline.ts +1 -1
- package/src/store/jsx/props.ts +20 -7
- package/src/writer/context.ts +5 -1
- package/src/writer/doc-tags.ts +70 -0
- package/src/writer/doc.ts +29 -6
- package/src/writer/gtk-doc.ts +82 -15
- package/src/writer/module.ts +25 -2
package/src/gir/parse.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { createXmlParser } from "../xml.js";
|
|
3
3
|
|
|
4
|
+
/** An element of the parsed GIR XML: attributes under `@_`-prefixed keys, children under their tag names. */
|
|
4
5
|
type RawNode = Record<string, unknown>;
|
|
5
6
|
|
|
6
7
|
const MULTI_TAGS: Set<string> = new Set([
|
|
@@ -16,6 +17,7 @@ const MULTI_TAGS: Set<string> = new Set([
|
|
|
16
17
|
"alias",
|
|
17
18
|
"union",
|
|
18
19
|
"method",
|
|
20
|
+
"virtual-method",
|
|
19
21
|
"constructor",
|
|
20
22
|
"property",
|
|
21
23
|
"field",
|
|
@@ -141,12 +143,12 @@ const docTextFromObject = (value: object): string | undefined => {
|
|
|
141
143
|
return typeof text === "string" ? normalizeDoc(text) : undefined;
|
|
142
144
|
};
|
|
143
145
|
|
|
144
|
-
const
|
|
146
|
+
const docElementText = (node: RawNode | undefined, tag: string): string | undefined => {
|
|
145
147
|
if (node === undefined) {
|
|
146
148
|
return undefined;
|
|
147
149
|
}
|
|
148
150
|
|
|
149
|
-
const value = firstDocValue(node
|
|
151
|
+
const value = firstDocValue(node[tag]);
|
|
150
152
|
|
|
151
153
|
if (typeof value === "string") {
|
|
152
154
|
return normalizeDoc(value);
|
|
@@ -159,6 +161,9 @@ const getDoc = (node: RawNode | undefined): string | undefined => {
|
|
|
159
161
|
return docTextFromObject(value);
|
|
160
162
|
};
|
|
161
163
|
|
|
164
|
+
const getDoc = (node: RawNode | undefined): string | undefined => docElementText(node, "doc");
|
|
165
|
+
const getDocDeprecated = (node: RawNode | undefined): string | undefined => docElementText(node, "doc-deprecated");
|
|
166
|
+
|
|
162
167
|
export {
|
|
163
168
|
GIR_CONSTRUCTOR_TAG,
|
|
164
169
|
parseGirFile,
|
|
@@ -170,5 +175,6 @@ export {
|
|
|
170
175
|
getChildren,
|
|
171
176
|
getChild,
|
|
172
177
|
getDoc,
|
|
178
|
+
getDocDeprecated,
|
|
173
179
|
type RawNode,
|
|
174
180
|
};
|
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 };
|
package/src/gir/type-id.ts
CHANGED
|
@@ -1,43 +1,89 @@
|
|
|
1
1
|
import type { RawNode } from "./parse.js";
|
|
2
2
|
import type { PrimitiveCategory } from "./primitives.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/** A reference to a parsed type: the type table holding it, and its slot in that table. */
|
|
5
|
+
type TypeId = {
|
|
6
|
+
/** Id of the table holding the type: a namespace's, or the internal one primitives and varargs intern into. */
|
|
7
|
+
nsId: number;
|
|
8
|
+
/** Slot the type occupies in that table. */
|
|
9
|
+
id: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/** Which GLib container a {@link ListType} is. */
|
|
5
13
|
type ListFlavor = (typeof LIST_FLAVOR_BY_NAME)[keyof typeof LIST_FLAVOR_BY_NAME];
|
|
6
|
-
type PrimitiveType = { kind: "primitive"; category: PrimitiveCategory };
|
|
7
|
-
type VarargsType = { kind: "varargs" };
|
|
8
14
|
|
|
15
|
+
/** A type that marshals directly as a value, such as `gint` or `utf8`. */
|
|
16
|
+
type PrimitiveType = {
|
|
17
|
+
/** Discriminates {@link StructuralType}. */
|
|
18
|
+
kind: "primitive";
|
|
19
|
+
/** The scalar the type marshals as. */
|
|
20
|
+
category: PrimitiveCategory;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** The trailing `...` argument list of a variadic C function. */
|
|
24
|
+
type VarargsType = {
|
|
25
|
+
/** Discriminates {@link StructuralType}. */
|
|
26
|
+
kind: "varargs";
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** A C array, along with whatever the GIR says about how its length is determined. */
|
|
9
30
|
type CArrayType = {
|
|
31
|
+
/** Discriminates {@link StructuralType}. */
|
|
10
32
|
kind: "carray";
|
|
33
|
+
/** Type of the array's elements, paired with `elementCType` to build the element descriptor. */
|
|
11
34
|
element: TypeId;
|
|
35
|
+
/** C declaration of an element, which tells an inline struct apart from a pointer to one. */
|
|
12
36
|
elementCType: string | undefined;
|
|
37
|
+
/** C declaration of the array itself. */
|
|
38
|
+
arrayCType: string | undefined;
|
|
39
|
+
/** Index of the parameter, or of the sibling record field, carrying the length. */
|
|
13
40
|
lengthParameterIndex: number | undefined;
|
|
41
|
+
/** Element count when the array has a fixed size. */
|
|
14
42
|
fixedSize: number | undefined;
|
|
43
|
+
/** Whether the array ends at a null element. */
|
|
15
44
|
isZeroTerminated: boolean;
|
|
16
45
|
};
|
|
17
46
|
|
|
47
|
+
/** A GLib list or array container over a single element type. */
|
|
18
48
|
type ListType = {
|
|
49
|
+
/** Discriminates {@link StructuralType}. */
|
|
19
50
|
kind: "list";
|
|
51
|
+
/** Which container the type is. */
|
|
20
52
|
flavor: ListFlavor;
|
|
53
|
+
/** Type the container's elements marshal as, which the list descriptor wraps. */
|
|
21
54
|
element: TypeId;
|
|
22
55
|
};
|
|
23
56
|
|
|
57
|
+
/** A `GLib.HashTable`. */
|
|
24
58
|
type HashTableType = {
|
|
59
|
+
/** Discriminates {@link StructuralType}. */
|
|
25
60
|
kind: "hashtable";
|
|
61
|
+
/** Type the keys marshal as, rendered as the key half of a `Record` or `Map`. */
|
|
26
62
|
key: TypeId;
|
|
63
|
+
/** Type the values marshal as, rendered as the value half of a `Record` or `Map`. */
|
|
27
64
|
value: TypeId;
|
|
28
65
|
};
|
|
29
66
|
|
|
67
|
+
/** A type the GIR describes by its structure rather than by a name it declares. */
|
|
30
68
|
type StructuralType = PrimitiveType | VarargsType | CArrayType | ListType | HashTableType;
|
|
31
69
|
|
|
70
|
+
/** The hooks the GIR parsers use to reference and register types while walking one namespace. */
|
|
32
71
|
type ParseContext = {
|
|
72
|
+
/** Id of the namespace being parsed. */
|
|
33
73
|
nsId: number;
|
|
74
|
+
/** Resolves a GIR type name, optionally namespace-qualified, reserving a slot when it is not parsed yet. */
|
|
34
75
|
findType(name: string): TypeId;
|
|
76
|
+
/** Interns a primitive type and returns its id. */
|
|
35
77
|
addPrimitive(category: PrimitiveCategory): TypeId;
|
|
78
|
+
/** Interns the varargs type and returns its id. */
|
|
36
79
|
addVarargs(): TypeId;
|
|
80
|
+
/** Registers an unnamed container type in the namespace and returns its id. */
|
|
37
81
|
addContainer(type: CArrayType | ListType | HashTableType): TypeId;
|
|
82
|
+
/** Parses an inline `<callback>` node, registers it as an unnamed type, and returns its id. */
|
|
38
83
|
addAnonymousCallback(node: RawNode): TypeId;
|
|
39
84
|
};
|
|
40
85
|
|
|
86
|
+
/** GIR type names of the GLib containers, mapped to the {@link ListFlavor} each one parses to. */
|
|
41
87
|
const LIST_FLAVOR_BY_NAME = {
|
|
42
88
|
"GLib.List": "glist",
|
|
43
89
|
"GLib.SList": "gslist",
|
package/src/gir/type-ref.ts
CHANGED
|
@@ -88,6 +88,7 @@ const arrayTypeRefFromNode = (arrayNode: RawNode, context: ParseContext): TypeId
|
|
|
88
88
|
kind: "carray",
|
|
89
89
|
element,
|
|
90
90
|
elementCType: elementNode === undefined ? undefined : attr(elementNode, "c:type"),
|
|
91
|
+
arrayCType: attr(arrayNode, "c:type"),
|
|
91
92
|
lengthParameterIndex: intAttr(arrayNode, "length"),
|
|
92
93
|
fixedSize: intAttr(arrayNode, "fixed-size"),
|
|
93
94
|
isZeroTerminated: isAttrTrue(arrayNode, "zero-terminated", true),
|
package/src/gir/type.ts
CHANGED
|
@@ -5,14 +5,58 @@ import type { GirAlias, GirNamespace } from "./namespace.js";
|
|
|
5
5
|
import type { GirRecord } from "./record.js";
|
|
6
6
|
import type { StructuralType } from "./type-id.js";
|
|
7
7
|
|
|
8
|
+
/** A named entity a GIR namespace declares, discriminated by `kind` and carrying the parsed node. */
|
|
8
9
|
type EntityType =
|
|
9
|
-
| {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
| {
|
|
11
|
+
/** Discriminates {@link EntityType}. */
|
|
12
|
+
kind: "class";
|
|
13
|
+
/** Namespace declaring the class. */
|
|
14
|
+
namespace: GirNamespace;
|
|
15
|
+
/** Parsed class, carrying its GType metadata and the members it declares. */
|
|
16
|
+
value: GirClass;
|
|
17
|
+
} |
|
|
18
|
+
{
|
|
19
|
+
/** Discriminates {@link EntityType}. */
|
|
20
|
+
kind: "interface";
|
|
21
|
+
/** Namespace declaring the interface. */
|
|
22
|
+
namespace: GirNamespace;
|
|
23
|
+
/** Parsed interface, modeled the same way as a class. */
|
|
24
|
+
value: GirClass;
|
|
25
|
+
} |
|
|
26
|
+
{
|
|
27
|
+
/** Discriminates {@link EntityType}. */
|
|
28
|
+
kind: "record";
|
|
29
|
+
/** Namespace declaring the record. */
|
|
30
|
+
namespace: GirNamespace;
|
|
31
|
+
/** Parsed record, either a struct or a union. */
|
|
32
|
+
value: GirRecord;
|
|
33
|
+
} |
|
|
34
|
+
{
|
|
35
|
+
/** Discriminates {@link EntityType}. */
|
|
36
|
+
kind: "enum";
|
|
37
|
+
/** Namespace declaring the enumeration. */
|
|
38
|
+
namespace: GirNamespace;
|
|
39
|
+
/** Parsed enumeration or bitfield. */
|
|
40
|
+
value: GirEnum;
|
|
41
|
+
} |
|
|
42
|
+
{
|
|
43
|
+
/** Discriminates {@link EntityType}. */
|
|
44
|
+
kind: "callback";
|
|
45
|
+
/** Namespace declaring the callback. */
|
|
46
|
+
namespace: GirNamespace;
|
|
47
|
+
/** Parsed callback signature. */
|
|
48
|
+
value: GirCallback;
|
|
49
|
+
} |
|
|
50
|
+
{
|
|
51
|
+
/** Discriminates {@link EntityType}. */
|
|
52
|
+
kind: "alias";
|
|
53
|
+
/** Namespace declaring the alias. */
|
|
54
|
+
namespace: GirNamespace;
|
|
55
|
+
/** Parsed alias, holding the type it stands for. */
|
|
56
|
+
value: GirAlias;
|
|
57
|
+
};
|
|
15
58
|
|
|
59
|
+
/** What a GIR type reference resolves to: a structural type, or an entity a namespace declares. */
|
|
16
60
|
type GirType = StructuralType | EntityType;
|
|
17
61
|
|
|
18
62
|
export { type EntityType, type GirType };
|
package/src/khronos/args.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toCamelIdentifier } from "@gtkx/utils";
|
|
2
2
|
import type { GlCommand, GlParam } from "./model.js";
|
|
3
|
-
import type { CommandPlan, GlScalar, ParamPlan } from "./plan.js";
|
|
3
|
+
import type { CommandPlan, GlScalar, ParamPlan, ReturnPlan } from "./plan.js";
|
|
4
4
|
import {
|
|
5
5
|
tArray,
|
|
6
6
|
tBoolean,
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
import { paramPairAt } from "./param-pair.js";
|
|
16
16
|
|
|
17
17
|
type InArg = {
|
|
18
|
-
|
|
18
|
+
isOut: false;
|
|
19
19
|
name: string;
|
|
20
20
|
tsType: string;
|
|
21
21
|
descriptor: string;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
type OutArg = {
|
|
25
|
-
|
|
25
|
+
isOut: true;
|
|
26
26
|
cellName: string;
|
|
27
27
|
seed: string;
|
|
28
28
|
tsType: string;
|
|
@@ -31,7 +31,7 @@ type OutArg = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
type PlannedArg = InArg | OutArg;
|
|
34
|
-
type OutArgCell = Pick<OutArg, "
|
|
34
|
+
type OutArgCell = Pick<OutArg, "isOut" | "cellName" | "paramIndex">;
|
|
35
35
|
type OutArgFields = Pick<OutArg, "seed" | "tsType" | "descriptor">;
|
|
36
36
|
|
|
37
37
|
type OutArgFieldsOptions = {
|
|
@@ -54,6 +54,29 @@ const OUT_PLAN_KINDS: Set<string> = new Set(["ref-out", "ref-array-out", "ref-fi
|
|
|
54
54
|
const scalarAliasOrGroup = (scalar: GlScalar, group: string | undefined): string =>
|
|
55
55
|
group !== undefined && scalar.isGroupBearing === true ? group : scalar.tsAlias;
|
|
56
56
|
|
|
57
|
+
const returnPlanTsType = (plan: ReturnPlan, group: string | undefined): string => {
|
|
58
|
+
switch (plan.kind) {
|
|
59
|
+
case "void": {
|
|
60
|
+
return "void";
|
|
61
|
+
}
|
|
62
|
+
case "scalar": {
|
|
63
|
+
return scalarAliasOrGroup(plan.scalar, group);
|
|
64
|
+
}
|
|
65
|
+
case "boolean": {
|
|
66
|
+
return "boolean";
|
|
67
|
+
}
|
|
68
|
+
case "string": {
|
|
69
|
+
return "string";
|
|
70
|
+
}
|
|
71
|
+
case "sync": {
|
|
72
|
+
return "GLsync";
|
|
73
|
+
}
|
|
74
|
+
case "opaque-pointer": {
|
|
75
|
+
return "GLpointer";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
57
80
|
const paramIndexByName = (command: GlCommand, name: string): number => {
|
|
58
81
|
const index = command.params.findIndex((param) => param.name === name);
|
|
59
82
|
|
|
@@ -71,7 +94,7 @@ const arrayInTsType = (scalar: GlScalar, group: string | undefined): string => {
|
|
|
71
94
|
};
|
|
72
95
|
|
|
73
96
|
const inArg = (name: string, tsType: string, descriptor: string): InArg => ({
|
|
74
|
-
|
|
97
|
+
isOut: false,
|
|
75
98
|
name,
|
|
76
99
|
tsType,
|
|
77
100
|
descriptor,
|
|
@@ -141,7 +164,7 @@ const outArgFields = (options: OutArgFieldsOptions): OutArgFields => {
|
|
|
141
164
|
|
|
142
165
|
return {
|
|
143
166
|
seed: `const ${cellName} = { value: new Array<number>(${lenIdentifier}).fill(0) };`,
|
|
144
|
-
tsType: `${track(plan.scalar.
|
|
167
|
+
tsType: `${track(scalarAliasOrGroup(plan.scalar, param.group))}[]`,
|
|
145
168
|
descriptor: tRef(tSizedArray(plan.scalar.descriptor, sizeIndex)),
|
|
146
169
|
};
|
|
147
170
|
}
|
|
@@ -182,14 +205,14 @@ const buildOutArg = (options: BuildArgOptions, track: (alias: string) => string)
|
|
|
182
205
|
}
|
|
183
206
|
|
|
184
207
|
const cellName = `out${String(outIndex)}`;
|
|
185
|
-
const cell: OutArgCell = {
|
|
208
|
+
const cell: OutArgCell = { isOut: true, cellName, paramIndex: index };
|
|
186
209
|
|
|
187
210
|
return { ...cell, ...outArgFields({ command, plan, param, cellName, track }) };
|
|
188
211
|
};
|
|
189
212
|
|
|
190
213
|
const isOutPlan = (plan: ParamPlan): boolean => OUT_PLAN_KINDS.has(plan.kind);
|
|
191
|
-
const isInArg = (arg: PlannedArg): arg is InArg => !arg.
|
|
192
|
-
const isOutArg = (arg: PlannedArg): arg is OutArg => arg.
|
|
214
|
+
const isInArg = (arg: PlannedArg): arg is InArg => !arg.isOut;
|
|
215
|
+
const isOutArg = (arg: PlannedArg): arg is OutArg => arg.isOut;
|
|
193
216
|
|
|
194
217
|
const buildArg = (options: BuildArgOptions, name: string, track: (alias: string) => string): PlannedArg =>
|
|
195
218
|
isOutPlan(options.plan) ? buildOutArg(options, track) : buildInArg(options, name, track);
|
|
@@ -203,7 +226,7 @@ const trackInto =
|
|
|
203
226
|
};
|
|
204
227
|
|
|
205
228
|
const planArgs = (
|
|
206
|
-
plan: CommandPlan & {
|
|
229
|
+
plan: CommandPlan & { isOk: true },
|
|
207
230
|
usedTypes: Set<string>,
|
|
208
231
|
): { args: PlannedArg[]; ins: InArg[]; outs: OutArg[] } => {
|
|
209
232
|
const track = trackInto(usedTypes);
|
|
@@ -230,7 +253,7 @@ const planArgs = (
|
|
|
230
253
|
};
|
|
231
254
|
|
|
232
255
|
const scalarPrefixArg = (
|
|
233
|
-
plan: CommandPlan & {
|
|
256
|
+
plan: CommandPlan & { isOk: true },
|
|
234
257
|
index: number,
|
|
235
258
|
track: (alias: string) => string,
|
|
236
259
|
): InArg | undefined => {
|
|
@@ -251,7 +274,7 @@ const scalarPrefixArg = (
|
|
|
251
274
|
);
|
|
252
275
|
};
|
|
253
276
|
|
|
254
|
-
const scalarPrefixArgs = (plan: CommandPlan & {
|
|
277
|
+
const scalarPrefixArgs = (plan: CommandPlan & { isOk: true }, usedTypes: Set<string>): InArg[] | undefined => {
|
|
255
278
|
const track = trackInto(usedTypes);
|
|
256
279
|
const prefix: InArg[] = [];
|
|
257
280
|
|
|
@@ -268,4 +291,4 @@ const scalarPrefixArgs = (plan: CommandPlan & { ok: true }, usedTypes: Set<strin
|
|
|
268
291
|
return prefix;
|
|
269
292
|
};
|
|
270
293
|
|
|
271
|
-
export { scalarAliasOrGroup, trackInto, planArgs, scalarPrefixArgs, type InArg, type OutArg };
|
|
294
|
+
export { returnPlanTsType, scalarAliasOrGroup, trackInto, planArgs, scalarPrefixArgs, type InArg, type OutArg };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { sortStrings } from "@gtkx/utils";
|
|
2
|
+
import type { GlExtensionAttribution, GlExtensionIndex } from "./extensions.js";
|
|
3
|
+
import type { GlEnum, GlRegistry, GlType } from "./model.js";
|
|
4
|
+
import type { CommandPlan } from "./plan.js";
|
|
5
|
+
|
|
6
|
+
type GlDocEnumRow = {
|
|
7
|
+
token: GlEnum;
|
|
8
|
+
exportName: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type GlDocContext = {
|
|
12
|
+
registryComment?: string;
|
|
13
|
+
kinds: Map<string, string>;
|
|
14
|
+
types: Map<string, GlType>;
|
|
15
|
+
aliasTargets: Map<string, string[]>;
|
|
16
|
+
extensionCommands: Map<string, GlExtensionAttribution[]>;
|
|
17
|
+
extensionEnums: Map<string, GlExtensionAttribution[]>;
|
|
18
|
+
bitmaskGroups: Set<string>;
|
|
19
|
+
emittedCommands: Set<string>;
|
|
20
|
+
groupMembers: Map<string, string[]>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type BuildDocContextOptions = {
|
|
24
|
+
registry: GlRegistry;
|
|
25
|
+
extensions: GlExtensionIndex;
|
|
26
|
+
plans: (CommandPlan & { isOk: true })[];
|
|
27
|
+
enumRows: GlDocEnumRow[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const buildGroupMembers = (rows: GlDocEnumRow[]): Map<string, string[]> => {
|
|
31
|
+
const members: Map<string, string[]> = new Map();
|
|
32
|
+
|
|
33
|
+
for (const row of rows) {
|
|
34
|
+
for (const group of row.token.groups) {
|
|
35
|
+
members.set(group, [...(members.get(group) ?? []), row.exportName]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const [group, names] of members) {
|
|
40
|
+
members.set(group, sortStrings(names));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return members;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const buildDocContext = (options: BuildDocContextOptions): GlDocContext => {
|
|
47
|
+
const { registry, extensions, plans, enumRows } = options;
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
...(registry.comment !== undefined && { registryComment: registry.comment }),
|
|
51
|
+
kinds: registry.kinds,
|
|
52
|
+
types: registry.types,
|
|
53
|
+
aliasTargets: registry.aliasTargets,
|
|
54
|
+
extensionCommands: extensions.commands,
|
|
55
|
+
extensionEnums: extensions.enums,
|
|
56
|
+
bitmaskGroups: registry.bitmaskGroups,
|
|
57
|
+
emittedCommands: new Set(plans.map((plan) => plan.command.name)),
|
|
58
|
+
groupMembers: buildGroupMembers(enumRows),
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { buildDocContext, type GlDocContext };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { sortStrings } from "@gtkx/utils";
|
|
2
|
+
import type { GlExtension, GlInterfaceBlock, GlRegistry } from "./model.js";
|
|
3
|
+
import type { GlSelection } from "./select.js";
|
|
4
|
+
|
|
5
|
+
type GlExtensionAttribution = {
|
|
6
|
+
name: string;
|
|
7
|
+
notes: string[];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type GlExtensionIndex = {
|
|
11
|
+
commands: Map<string, GlExtensionAttribution[]>;
|
|
12
|
+
enums: Map<string, GlExtensionAttribution[]>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type PendingIndex = Map<string, Map<string, string[]>>;
|
|
16
|
+
|
|
17
|
+
type PendingExtensionIndex = {
|
|
18
|
+
commands: PendingIndex;
|
|
19
|
+
enums: PendingIndex;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const SUPPORTED_APIS: Set<string> = new Set(["gl", "glcore"]);
|
|
23
|
+
|
|
24
|
+
const isExtensionSupported = (extension: GlExtension): boolean =>
|
|
25
|
+
extension.supported.some((api) => SUPPORTED_APIS.has(api));
|
|
26
|
+
|
|
27
|
+
const isBlockIncluded = (block: GlInterfaceBlock, selection: GlSelection): boolean =>
|
|
28
|
+
block.kind === "require" &&
|
|
29
|
+
(block.api === undefined || block.api === selection.api) &&
|
|
30
|
+
(block.profile === undefined || block.profile === selection.profile);
|
|
31
|
+
|
|
32
|
+
const blockNotes = (extension: GlExtension, block: GlInterfaceBlock): string[] => [
|
|
33
|
+
...(extension.comment === undefined ? [] : [extension.comment]),
|
|
34
|
+
...(block.comment === undefined ? [] : [block.comment]),
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const appendMembers = (index: PendingIndex, names: string[], extension: string, notes: string[]): void => {
|
|
38
|
+
for (const name of names) {
|
|
39
|
+
const byExtension = index.get(name) ?? new Map<string, string[]>();
|
|
40
|
+
byExtension.set(extension, [...(byExtension.get(extension) ?? []), ...notes]);
|
|
41
|
+
index.set(name, byExtension);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const indexExtension = (index: PendingExtensionIndex, extension: GlExtension, selection: GlSelection): void => {
|
|
46
|
+
for (const block of extension.blocks) {
|
|
47
|
+
if (!isBlockIncluded(block, selection)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const notes = blockNotes(extension, block);
|
|
52
|
+
appendMembers(index.commands, block.commands, extension.name, notes);
|
|
53
|
+
appendMembers(index.enums, block.enums, extension.name, notes);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const attributionsFor = (byExtension: Map<string, string[]>): GlExtensionAttribution[] =>
|
|
58
|
+
sortStrings(byExtension.keys()).map((name) => ({
|
|
59
|
+
name,
|
|
60
|
+
notes: [...new Set(byExtension.get(name))],
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
const finalizeIndex = (pending: PendingIndex): Map<string, GlExtensionAttribution[]> => {
|
|
64
|
+
const index: Map<string, GlExtensionAttribution[]> = new Map();
|
|
65
|
+
|
|
66
|
+
for (const [name, byExtension] of pending) {
|
|
67
|
+
index.set(name, attributionsFor(byExtension));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return index;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const buildExtensionIndex = (registry: GlRegistry, selection: GlSelection): GlExtensionIndex => {
|
|
74
|
+
const pending: PendingExtensionIndex = { commands: new Map(), enums: new Map() };
|
|
75
|
+
|
|
76
|
+
for (const extension of registry.extensions) {
|
|
77
|
+
if (isExtensionSupported(extension)) {
|
|
78
|
+
indexExtension(pending, extension, selection);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return { commands: finalizeIndex(pending.commands), enums: finalizeIndex(pending.enums) };
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { buildExtensionIndex, type GlExtensionAttribution, type GlExtensionIndex };
|