@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/dist/gir/namespace.d.ts
CHANGED
|
@@ -1,46 +1,84 @@
|
|
|
1
1
|
import type { ParseContext, TypeId } from "./type-id.js";
|
|
2
|
+
import { type GirAnnotations } from "./annotations.js";
|
|
2
3
|
import { type GirCallback } from "./callback.js";
|
|
3
4
|
import { type GirClass } from "./class.js";
|
|
4
5
|
import { type GirEnum } from "./enum.js";
|
|
5
6
|
import { type GirFunction } from "./function.js";
|
|
6
7
|
import { type RawNode } from "./parse.js";
|
|
7
8
|
import { type GirRecord } from "./record.js";
|
|
9
|
+
/** A compile-time constant declared by a namespace. */
|
|
8
10
|
type GirConstant = {
|
|
11
|
+
/** Local name within the namespace. */
|
|
9
12
|
name: string;
|
|
13
|
+
/** Documentation text carried by the GIR node. */
|
|
10
14
|
doc: string | undefined;
|
|
15
|
+
/** Release and deprecation annotations GIR carries on the constant. */
|
|
16
|
+
annotations: GirAnnotations;
|
|
17
|
+
/** Literal as written in the GIR, still to be interpreted according to {@link GirConstant.type}. */
|
|
11
18
|
value: string;
|
|
19
|
+
/** Type of the constant, unresolved until looked up in the library's type tables. */
|
|
12
20
|
type: TypeId | undefined;
|
|
13
21
|
};
|
|
22
|
+
/** A named alias for another type. */
|
|
14
23
|
type GirAlias = {
|
|
24
|
+
/** Local name within the namespace. */
|
|
15
25
|
name: string;
|
|
26
|
+
/** Documentation text carried by the GIR node. */
|
|
16
27
|
doc: string | undefined;
|
|
28
|
+
/** Release and deprecation annotations GIR carries on the alias. */
|
|
29
|
+
annotations: GirAnnotations;
|
|
30
|
+
/** C typedef name introduced by the alias. */
|
|
17
31
|
cType: string | undefined;
|
|
32
|
+
/** Type the alias stands for, unresolved until looked up in the library's type tables. */
|
|
18
33
|
target: TypeId | undefined;
|
|
34
|
+
/** C type name of the target, which decides how the alias marshals. */
|
|
19
35
|
targetCType: string | undefined;
|
|
20
36
|
};
|
|
37
|
+
/** Everything one GIR namespace declares, keyed into the library that parsed it. */
|
|
21
38
|
type GirNamespace = {
|
|
39
|
+
/** Identifier of the namespace's type table within its library. */
|
|
22
40
|
id: number;
|
|
41
|
+
/** Namespace name as it appears in the GIR, such as `Gtk`. */
|
|
23
42
|
name: string;
|
|
43
|
+
/** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
|
|
24
44
|
sharedLibrary: string | undefined;
|
|
45
|
+
/** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
|
|
25
46
|
cSymbolPrefixes: string[];
|
|
47
|
+
/** GObject classes declared by the namespace. */
|
|
26
48
|
classes: GirClass[];
|
|
49
|
+
/** GObject interfaces declared by the namespace. */
|
|
27
50
|
interfaces: GirClass[];
|
|
51
|
+
/** Structs and unions declared by the namespace. */
|
|
28
52
|
records: GirRecord[];
|
|
53
|
+
/** Enumerations and bitfields declared by the namespace. */
|
|
29
54
|
enums: GirEnum[];
|
|
55
|
+
/** Callback types declared by the namespace. */
|
|
30
56
|
callbacks: GirCallback[];
|
|
57
|
+
/** Free functions declared by the namespace. */
|
|
31
58
|
functions: GirFunction[];
|
|
59
|
+
/** Compile-time values, emitted as module-level `const` bindings. */
|
|
32
60
|
constants: GirConstant[];
|
|
61
|
+
/** Typedefs, emitted as TypeScript type aliases and resolvable as types themselves. */
|
|
33
62
|
aliases: GirAlias[];
|
|
34
63
|
};
|
|
64
|
+
/** Another namespace a GIR repository depends on. */
|
|
35
65
|
type NamespaceInclude = {
|
|
66
|
+
/** Name of the included namespace, such as `Gio`. */
|
|
36
67
|
name: string;
|
|
68
|
+
/** Version of the included namespace, such as `2.0`. */
|
|
37
69
|
version: string;
|
|
38
70
|
};
|
|
71
|
+
/** A namespace's declaration and dependencies, read before its body is parsed. */
|
|
39
72
|
type NamespaceHeader = {
|
|
73
|
+
/** Namespace name as it appears in the GIR, such as `Gtk`. */
|
|
40
74
|
name: string;
|
|
75
|
+
/** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
|
|
41
76
|
sharedLibrary: string | undefined;
|
|
77
|
+
/** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
|
|
42
78
|
cSymbolPrefixes: string[];
|
|
79
|
+
/** Namespaces this repository includes, each of which is parsed in turn. */
|
|
43
80
|
includes: NamespaceInclude[];
|
|
81
|
+
/** The `<namespace>` node whose children hold the declarations. */
|
|
44
82
|
namespaceNode: RawNode;
|
|
45
83
|
};
|
|
46
84
|
declare const namespaceDirectory: (namespace: Pick<GirNamespace, "name">) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../src/gir/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../src/gir/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,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,YAAY,EAAE,eAAe,OAAO,EAAE,SAAS,YAAY,KAAG,IAoBnG,CAAC;AAiBF,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,eAAe,GACvB,CAAC"}
|
package/dist/gir/namespace.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { documentedFromNode } from "./annotations.js";
|
|
1
2
|
import { callbackFromNode } from "./callback.js";
|
|
2
3
|
import { classFromNode } from "./class.js";
|
|
3
4
|
import { enumFromNode } from "./enum.js";
|
|
4
5
|
import { functionFromNode } from "./function.js";
|
|
5
|
-
import { attr, getChild, getChildren,
|
|
6
|
+
import { attr, getChild, getChildren, nameAttr } from "./parse.js";
|
|
6
7
|
import { isVtableRecord, recordFromNode } from "./record.js";
|
|
7
8
|
import { typeRefFromNode } from "./type-ref.js";
|
|
8
9
|
const namespaceDirectory = (namespace) => namespace.name.toLowerCase();
|
|
@@ -45,14 +46,12 @@ const populateNamespaceBody = (shell, namespaceNode, context) => {
|
|
|
45
46
|
shell.callbacks = getChildren(namespaceNode, "callback").map((callback) => callbackFromNode(callback, context));
|
|
46
47
|
shell.functions = getChildren(namespaceNode, "function").map((fn) => functionFromNode(fn, context));
|
|
47
48
|
shell.constants = getChildren(namespaceNode, "constant").map((constant) => ({
|
|
48
|
-
|
|
49
|
-
doc: getDoc(constant),
|
|
49
|
+
...documentedFromNode(constant),
|
|
50
50
|
value: attr(constant, "value") ?? "",
|
|
51
51
|
type: typeRefFromNode(constant, context),
|
|
52
52
|
}));
|
|
53
53
|
shell.aliases = getChildren(namespaceNode, "alias").map((alias) => ({
|
|
54
|
-
|
|
55
|
-
doc: getDoc(alias),
|
|
54
|
+
...documentedFromNode(alias),
|
|
56
55
|
cType: attr(alias, "c:type"),
|
|
57
56
|
target: typeRefFromNode(alias, context),
|
|
58
57
|
targetCType: attr(getChild(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AAC,aAAsB,EAAE,OAAqB,EAAe,EAAE,CAAC;IACnF,GAAG,WAAW,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACnD,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CACjE;IACD,GAAG,WAAW,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;CACrH,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,aAAsB,EAAa,EAAE,CAAC;IACxD,GAAG,WAAW,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC3G,GAAG,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;CAClG,CAAC;AAEF,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GAKxB,CAAC","sourcesContent":["import type { ParseContext, TypeId } from \"./type-id.js\";\nimport { callbackFromNode, type GirCallback } from \"./callback.js\";\nimport { classFromNode, type GirClass } from \"./class.js\";\nimport { enumFromNode, type GirEnum } from \"./enum.js\";\nimport { functionFromNode, type GirFunction } from \"./function.js\";\nimport { attr, getChild, getChildren, getDoc, nameAttr, type RawNode } from \"./parse.js\";\nimport { type GirRecord, isVtableRecord, recordFromNode } from \"./record.js\";\nimport { typeRefFromNode } from \"./type-ref.js\";\n\ntype GirConstant = {\n name: string;\n doc: string | undefined;\n value: string;\n type: TypeId | undefined;\n};\n\ntype GirAlias = {\n name: string;\n doc: string | undefined;\n cType: string | undefined;\n target: TypeId | undefined;\n targetCType: string | undefined;\n};\n\ntype GirNamespace = {\n id: number;\n name: string;\n sharedLibrary: string | undefined;\n cSymbolPrefixes: string[];\n classes: GirClass[];\n interfaces: GirClass[];\n records: GirRecord[];\n enums: GirEnum[];\n callbacks: GirCallback[];\n functions: GirFunction[];\n constants: GirConstant[];\n aliases: GirAlias[];\n};\n\ntype NamespaceInclude = {\n name: string;\n version: string;\n};\n\ntype NamespaceHeader = {\n name: string;\n sharedLibrary: string | undefined;\n cSymbolPrefixes: string[];\n includes: NamespaceInclude[];\n namespaceNode: RawNode;\n};\n\nconst namespaceDirectory = (namespace: Pick<GirNamespace, \"name\">): string => namespace.name.toLowerCase();\n\nconst parseNamespaceHeader = (repositoryNode: RawNode): NamespaceHeader => {\n const includes = getChildren(repositoryNode, \"include\").map<NamespaceInclude>((include) => ({\n name: nameAttr(include),\n version: attr(include, \"version\") ?? \"\",\n }));\n\n const namespaceNode = getChildren(repositoryNode, \"namespace\")[0];\n\n if (namespaceNode === undefined) {\n throw new Error(\"GIR repository has no <namespace> child\");\n }\n\n return {\n name: nameAttr(namespaceNode),\n sharedLibrary: attr(namespaceNode, \"shared-library\"),\n cSymbolPrefixes: splitPrefixes(attr(namespaceNode, \"c:symbol-prefixes\")),\n includes,\n namespaceNode,\n };\n};\n\nconst createNamespaceShell = (header: NamespaceHeader, id: number): GirNamespace => ({\n id,\n name: header.name,\n sharedLibrary: header.sharedLibrary,\n cSymbolPrefixes: header.cSymbolPrefixes,\n classes: [],\n interfaces: [],\n records: [],\n enums: [],\n callbacks: [],\n functions: [],\n constants: [],\n aliases: [],\n});\n\nconst populateNamespaceBody = (shell: GirNamespace, namespaceNode: RawNode, context: ParseContext): void => {\n shell.classes = getChildren(namespaceNode, \"class\").map((klass) => classFromNode(klass, false, context));\n shell.interfaces = getChildren(namespaceNode, \"interface\").map((iface) => classFromNode(iface, true, context));\n shell.records = collectRecords(namespaceNode, context);\n shell.enums = collectEnums(namespaceNode);\n shell.callbacks = getChildren(namespaceNode, \"callback\").map((callback) => callbackFromNode(callback, context));\n shell.functions = getChildren(namespaceNode, \"function\").map((fn) => functionFromNode(fn, context));\n\n shell.constants = getChildren(namespaceNode, \"constant\").map((constant) => ({\n name: nameAttr(constant),\n doc: getDoc(constant),\n value: attr(constant, \"value\") ?? \"\",\n type: typeRefFromNode(constant, context),\n }));\n\n shell.aliases = getChildren(namespaceNode, \"alias\").map((alias) => ({\n name: nameAttr(alias),\n doc: getDoc(alias),\n cType: attr(alias, \"c:type\"),\n target: typeRefFromNode(alias, context),\n targetCType: attr(getChild(alias, \"type\"), \"c:type\"),\n }));\n};\n\nconst splitPrefixes = (raw: string | undefined): string[] =>\n (raw ?? \"\").split(\",\").filter((prefix) => prefix.length > 0);\n\nconst collectRecords = (namespaceNode: RawNode, context: ParseContext): GirRecord[] => [\n ...getChildren(namespaceNode, \"record\").map((record) =>\n recordFromNode(record, isVtableRecord(record), false, context),\n ),\n ...getChildren(namespaceNode, \"union\").map((union) => recordFromNode(union, isVtableRecord(union), true, context)),\n];\n\nconst collectEnums = (namespaceNode: RawNode): GirEnum[] => [\n ...getChildren(namespaceNode, \"enumeration\").map((enumeration) => enumFromNode(enumeration, \"enumeration\")),\n ...getChildren(namespaceNode, \"bitfield\").map((bitfield) => enumFromNode(bitfield, \"bitfield\")),\n];\n\nexport {\n namespaceDirectory,\n parseNamespaceHeader,\n createNamespaceShell,\n populateNamespaceBody,\n type GirConstant,\n type GirAlias,\n type GirNamespace,\n type NamespaceHeader,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../src/gir/namespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAoB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,YA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,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;CACrH,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,aAAsB,EAAa,EAAE,CAAC;IACxD,GAAG,WAAW,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC3G,GAAG,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;CAClG,CAAC;AAEF,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GAKxB,CAAC","sourcesContent":["import type { ParseContext, TypeId } from \"./type-id.js\";\nimport { documentedFromNode, type GirAnnotations } from \"./annotations.js\";\nimport { callbackFromNode, type GirCallback } from \"./callback.js\";\nimport { classFromNode, type GirClass } from \"./class.js\";\nimport { enumFromNode, type GirEnum } from \"./enum.js\";\nimport { functionFromNode, type GirFunction } from \"./function.js\";\nimport { attr, getChild, getChildren, nameAttr, type RawNode } from \"./parse.js\";\nimport { type GirRecord, isVtableRecord, recordFromNode } from \"./record.js\";\nimport { typeRefFromNode } from \"./type-ref.js\";\n\n/** A compile-time constant declared by a namespace. */\ntype GirConstant = {\n /** Local name within the namespace. */\n name: string;\n /** Documentation text carried by the GIR node. */\n doc: string | undefined;\n /** Release and deprecation annotations GIR carries on the constant. */\n annotations: GirAnnotations;\n /** Literal as written in the GIR, still to be interpreted according to {@link GirConstant.type}. */\n value: string;\n /** Type of the constant, unresolved until looked up in the library's type tables. */\n type: TypeId | undefined;\n};\n\n/** A named alias for another type. */\ntype GirAlias = {\n /** Local name within the namespace. */\n name: string;\n /** Documentation text carried by the GIR node. */\n doc: string | undefined;\n /** Release and deprecation annotations GIR carries on the alias. */\n annotations: GirAnnotations;\n /** C typedef name introduced by the alias. */\n cType: string | undefined;\n /** Type the alias stands for, unresolved until looked up in the library's type tables. */\n target: TypeId | undefined;\n /** C type name of the target, which decides how the alias marshals. */\n targetCType: string | undefined;\n};\n\n/** Everything one GIR namespace declares, keyed into the library that parsed it. */\ntype GirNamespace = {\n /** Identifier of the namespace's type table within its library. */\n id: number;\n /** Namespace name as it appears in the GIR, such as `Gtk`. */\n name: string;\n /** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */\n sharedLibrary: string | undefined;\n /** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */\n cSymbolPrefixes: string[];\n /** GObject classes declared by the namespace. */\n classes: GirClass[];\n /** GObject interfaces declared by the namespace. */\n interfaces: GirClass[];\n /** Structs and unions declared by the namespace. */\n records: GirRecord[];\n /** Enumerations and bitfields declared by the namespace. */\n enums: GirEnum[];\n /** Callback types declared by the namespace. */\n callbacks: GirCallback[];\n /** Free functions declared by the namespace. */\n functions: GirFunction[];\n /** Compile-time values, emitted as module-level `const` bindings. */\n constants: GirConstant[];\n /** Typedefs, emitted as TypeScript type aliases and resolvable as types themselves. */\n aliases: GirAlias[];\n};\n\n/** Another namespace a GIR repository depends on. */\ntype NamespaceInclude = {\n /** Name of the included namespace, such as `Gio`. */\n name: string;\n /** Version of the included namespace, such as `2.0`. */\n version: string;\n};\n\n/** A namespace's declaration and dependencies, read before its body is parsed. */\ntype NamespaceHeader = {\n /** Namespace name as it appears in the GIR, such as `Gtk`. */\n name: string;\n /** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */\n sharedLibrary: string | undefined;\n /** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */\n cSymbolPrefixes: string[];\n /** Namespaces this repository includes, each of which is parsed in turn. */\n includes: NamespaceInclude[];\n /** The `<namespace>` node whose children hold the declarations. */\n namespaceNode: RawNode;\n};\n\nconst namespaceDirectory = (namespace: Pick<GirNamespace, \"name\">): string => namespace.name.toLowerCase();\n\nconst parseNamespaceHeader = (repositoryNode: RawNode): NamespaceHeader => {\n const includes = getChildren(repositoryNode, \"include\").map<NamespaceInclude>((include) => ({\n name: nameAttr(include),\n version: attr(include, \"version\") ?? \"\",\n }));\n\n const namespaceNode = getChildren(repositoryNode, \"namespace\")[0];\n\n if (namespaceNode === undefined) {\n throw new Error(\"GIR repository has no <namespace> child\");\n }\n\n return {\n name: nameAttr(namespaceNode),\n sharedLibrary: attr(namespaceNode, \"shared-library\"),\n cSymbolPrefixes: splitPrefixes(attr(namespaceNode, \"c:symbol-prefixes\")),\n includes,\n namespaceNode,\n };\n};\n\nconst createNamespaceShell = (header: NamespaceHeader, id: number): GirNamespace => ({\n id,\n name: header.name,\n sharedLibrary: header.sharedLibrary,\n cSymbolPrefixes: header.cSymbolPrefixes,\n classes: [],\n interfaces: [],\n records: [],\n enums: [],\n callbacks: [],\n functions: [],\n constants: [],\n aliases: [],\n});\n\nconst populateNamespaceBody = (shell: GirNamespace, namespaceNode: RawNode, context: ParseContext): void => {\n shell.classes = getChildren(namespaceNode, \"class\").map((klass) => classFromNode(klass, false, context));\n shell.interfaces = getChildren(namespaceNode, \"interface\").map((iface) => classFromNode(iface, true, context));\n shell.records = collectRecords(namespaceNode, context);\n shell.enums = collectEnums(namespaceNode);\n shell.callbacks = getChildren(namespaceNode, \"callback\").map((callback) => callbackFromNode(callback, context));\n shell.functions = getChildren(namespaceNode, \"function\").map((fn) => functionFromNode(fn, context));\n\n shell.constants = getChildren(namespaceNode, \"constant\").map((constant) => ({\n ...documentedFromNode(constant),\n value: attr(constant, \"value\") ?? \"\",\n type: typeRefFromNode(constant, context),\n }));\n\n shell.aliases = getChildren(namespaceNode, \"alias\").map((alias) => ({\n ...documentedFromNode(alias),\n cType: attr(alias, \"c:type\"),\n target: typeRefFromNode(alias, context),\n targetCType: attr(getChild(alias, \"type\"), \"c:type\"),\n }));\n};\n\nconst splitPrefixes = (raw: string | undefined): string[] =>\n (raw ?? \"\").split(\",\").filter((prefix) => prefix.length > 0);\n\nconst collectRecords = (namespaceNode: RawNode, context: ParseContext): GirRecord[] => [\n ...getChildren(namespaceNode, \"record\").map((record) =>\n recordFromNode(record, isVtableRecord(record), false, context),\n ),\n ...getChildren(namespaceNode, \"union\").map((union) => recordFromNode(union, isVtableRecord(union), true, context)),\n];\n\nconst collectEnums = (namespaceNode: RawNode): GirEnum[] => [\n ...getChildren(namespaceNode, \"enumeration\").map((enumeration) => enumFromNode(enumeration, \"enumeration\")),\n ...getChildren(namespaceNode, \"bitfield\").map((bitfield) => enumFromNode(bitfield, \"bitfield\")),\n];\n\nexport {\n namespaceDirectory,\n parseNamespaceHeader,\n createNamespaceShell,\n populateNamespaceBody,\n type GirConstant,\n type GirAlias,\n type GirNamespace,\n type NamespaceHeader,\n};\n"]}
|
package/dist/gir/parameter.d.ts
CHANGED
|
@@ -1,33 +1,72 @@
|
|
|
1
1
|
import type { ParseContext, TypeId } from "./type-id.js";
|
|
2
|
+
import { type GirAnnotations } from "./annotations.js";
|
|
2
3
|
import { type RawNode } from "./parse.js";
|
|
4
|
+
/** Which way a parameter's value travels: into the call, back out of it, or both. */
|
|
3
5
|
type ParameterDirection = "in" | "out" | "inout";
|
|
6
|
+
/** How much of a value the receiver takes ownership of: none, the whole value, or only its container. */
|
|
4
7
|
type ParameterTransfer = "none" | "full" | "container";
|
|
8
|
+
/**
|
|
9
|
+
* How long a callback parameter stays valid: for the duration of the call, until its destroy notify runs,
|
|
10
|
+
* until the asynchronous operation invokes it, or forever.
|
|
11
|
+
*/
|
|
5
12
|
type CallbackScope = "call" | "notified" | "async" | "forever";
|
|
13
|
+
/** A parameter of a {@link GirCallable}, with the annotations that decide how it is marshalled. */
|
|
6
14
|
type GirParameter = {
|
|
15
|
+
/** The name GIR gives the parameter. */
|
|
7
16
|
name: string;
|
|
17
|
+
/** What the parameter holds, absent when the GIR node declares no type. */
|
|
8
18
|
type: TypeId | undefined;
|
|
19
|
+
/** The C spelling of the parameter's type, taken from its `type` or `array` child. */
|
|
20
|
+
cType: string | undefined;
|
|
21
|
+
/** Documentation prose from GIR, emitted as the parameter's `@param` text. */
|
|
22
|
+
doc: string | undefined;
|
|
23
|
+
/** Decides whether the parameter is an argument, part of the returned tuple, or both. */
|
|
9
24
|
direction: ParameterDirection;
|
|
25
|
+
/** Ownership the marshalling descriptor is generated with, deciding whether the receiver frees the value. */
|
|
10
26
|
transferOwnership: ParameterTransfer;
|
|
27
|
+
/** Whether the value may be null. */
|
|
11
28
|
nullable: boolean;
|
|
29
|
+
/** Whether the caller may leave the parameter out entirely. */
|
|
12
30
|
optional: boolean;
|
|
31
|
+
/** Whether the caller supplies the storage an out parameter writes into. */
|
|
13
32
|
callerAllocates: boolean;
|
|
33
|
+
/** How long a callback parameter stays valid, absent when GIR carries no scope annotation. */
|
|
14
34
|
scope: CallbackScope | undefined;
|
|
35
|
+
/** Position of the parameter carrying the callback's user data. */
|
|
15
36
|
closureIndex: number | undefined;
|
|
37
|
+
/** Position of the parameter carrying the callback's destroy notify. */
|
|
16
38
|
destroyIndex: number | undefined;
|
|
39
|
+
/** Whether the parameter is the `...` varargs marker. */
|
|
17
40
|
isVarargs: boolean;
|
|
18
41
|
};
|
|
42
|
+
/** What a {@link GirCallable} hands back, with the annotations that decide how it is marshalled. */
|
|
19
43
|
type GirReturnValue = {
|
|
44
|
+
/** What the callable returns, absent when the GIR node declares no type. */
|
|
20
45
|
type: TypeId | undefined;
|
|
46
|
+
/** Documentation prose from GIR, emitted as the callable's `@returns` text. */
|
|
47
|
+
doc: string | undefined;
|
|
48
|
+
/** How much ownership the caller takes of the returned value. */
|
|
21
49
|
transferOwnership: ParameterTransfer;
|
|
50
|
+
/** Whether the returned value may be null. */
|
|
22
51
|
nullable: boolean;
|
|
52
|
+
/** Whether GIR marks the value as skipped, keeping it out of the generated signature. */
|
|
23
53
|
skip: boolean;
|
|
24
54
|
};
|
|
55
|
+
/** Anything GIR describes with parameters and a return value: functions, methods, signals, and callbacks. */
|
|
25
56
|
type GirCallable = {
|
|
57
|
+
/** The name GIR gives the callable. */
|
|
26
58
|
name: string;
|
|
59
|
+
/** The callable's documentation text, absent when GIR carries none. */
|
|
27
60
|
doc: string | undefined;
|
|
61
|
+
/** Release and deprecation annotations GIR carries on the callable. */
|
|
62
|
+
annotations: GirAnnotations;
|
|
63
|
+
/** The parameters the callable takes, in declaration order. */
|
|
28
64
|
parameters: GirParameter[];
|
|
65
|
+
/** What the callable hands back. */
|
|
29
66
|
returnValue: GirReturnValue;
|
|
67
|
+
/** Whether the callable reports failure through a trailing `GError`. */
|
|
30
68
|
throws: boolean;
|
|
69
|
+
/** Whether GIR exposes the callable to bindings. */
|
|
31
70
|
introspectable: boolean;
|
|
32
71
|
};
|
|
33
72
|
declare const transferOwnership: (node: RawNode) => ParameterTransfer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter.d.ts","sourceRoot":"","sources":["../../src/gir/parameter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EASH,KAAK,OAAO,EACf,MAAM,YAAY,CAAC;AAGpB,KAAK,kBAAkB,GAAG,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC;AACjD,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;AACvD,KAAK,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAE/D,KAAK,YAAY,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC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C;AAMF,QAAA,MAAM,iBAAiB,GAAI,MAAM,OAAO,KAAG,iBACiD,CAAC;AAc7F,QAAA,MAAM,iBAAiB,GAAI,MAAM,OAAO,EAAE,SAAS,YAAY,KAAG,YAchE,CAAC;AAEH,QAAA,MAAM,cAAc,GAAI,WAAW,YAAY,KAAG,OACa,CAAC;AAEhE,QAAA,MAAM,oBAAoB,GAAI,WAAW,YAAY,KAAG,OACM,CAAC;AAE/D,QAAA,MAAM,gBAAgB,GAAI,WAAW,YAAY,KAAG,OAA0C,CAAC;AAgB/F,QAAA,MAAM,aAAa,GAAI,MAAM,OAAO,EAAE,SAAS,YAAY,KAAG,WAW7D,CAAC;AAEF,OAAO,EACH,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,WAAW,GACnB,CAAC"}
|
package/dist/gir/parameter.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { documentedFromNode } from "./annotations.js";
|
|
1
2
|
import { attr, getChild, getChildren, getDoc, intAttr, isAttrTrue, nameAttr, parseEnumAttr, } from "./parse.js";
|
|
2
3
|
import { typeRefFromNode } from "./type-ref.js";
|
|
3
4
|
const DIRECTIONS = new Set(["in", "out", "inout"]);
|
|
@@ -7,9 +8,12 @@ const transferOwnership = (node) => parseEnumAttr(attr(node, "transfer-ownership
|
|
|
7
8
|
const isInDirection = (node) => parseEnumAttr(attr(node, "direction"), DIRECTIONS, "in", "direction") === "in";
|
|
8
9
|
const hasNullableAttr = (node) => isAttrTrue(node, "nullable") || (isInDirection(node) && isAttrTrue(node, "allow-none"));
|
|
9
10
|
const hasOptionalAttr = (node) => isAttrTrue(node, "optional") || (!isInDirection(node) && isAttrTrue(node, "allow-none"));
|
|
11
|
+
const parameterCType = (node) => attr(getChild(node, "type"), "c:type") ?? attr(getChild(node, "array"), "c:type");
|
|
10
12
|
const parameterFromNode = (node, context) => ({
|
|
11
13
|
name: nameAttr(node),
|
|
12
14
|
type: typeRefFromNode(node, context),
|
|
15
|
+
cType: parameterCType(node),
|
|
16
|
+
doc: getDoc(node),
|
|
13
17
|
direction: parseEnumAttr(attr(node, "direction"), DIRECTIONS, "in", "direction"),
|
|
14
18
|
transferOwnership: transferOwnership(node),
|
|
15
19
|
nullable: hasNullableAttr(node),
|
|
@@ -25,10 +29,11 @@ const isCallerAllocatedOut = (parameter) => parameter.direction === "out" && par
|
|
|
25
29
|
const isInoutParameter = (parameter) => parameter.direction === "inout";
|
|
26
30
|
const returnValueFromNode = (node, context) => {
|
|
27
31
|
if (node === undefined) {
|
|
28
|
-
return { type: undefined, transferOwnership: "none", nullable: false, skip: false };
|
|
32
|
+
return { type: undefined, doc: undefined, transferOwnership: "none", nullable: false, skip: false };
|
|
29
33
|
}
|
|
30
34
|
return {
|
|
31
35
|
type: typeRefFromNode(node, context),
|
|
36
|
+
doc: getDoc(node),
|
|
32
37
|
transferOwnership: transferOwnership(node),
|
|
33
38
|
nullable: hasNullableAttr(node),
|
|
34
39
|
skip: isAttrTrue(node, "skip"),
|
|
@@ -38,8 +43,7 @@ const parseCallable = (node, context) => {
|
|
|
38
43
|
const parametersNode = getChild(node, "parameters");
|
|
39
44
|
const parameterNodes = getChildren(parametersNode, "parameter");
|
|
40
45
|
return {
|
|
41
|
-
|
|
42
|
-
doc: getDoc(node),
|
|
46
|
+
...documentedFromNode(node),
|
|
43
47
|
parameters: parameterNodes.map((parameter) => parameterFromNode(parameter, context)),
|
|
44
48
|
returnValue: returnValueFromNode(getChild(node, "return-value"), context),
|
|
45
49
|
throws: isAttrTrue(node, "throws"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../src/gir/parameter.ts"],"names":[],"mappings":"AACA,OAAO,EACH,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,MAAM,EACN,OAAO,EACP,UAAU,E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AED,OAAO;QACH,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC;QACpC,iBAAiB,EAAE,iBAAiB,CAAC,IAAI,CAAC;QAC1C,QAAQ,EAAE,eAAe,CAAC,IAAI,CAAC;QAC/B,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC;KACjC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,IAAa,EAAE,OAAqB,EAAe,EAAE;IACxE,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,WAAW,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAEhE,OAAO;QACH,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC;QACjB,UAAU,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACpF,WAAW,EAAE,mBAAmB,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC;QACzE,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC;QAClC,cAAc,EAAE,UAAU,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC;KAC3D,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EACH,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,GAKhB,CAAC","sourcesContent":["import type { ParseContext, TypeId } from \"./type-id.js\";\nimport {\n attr,\n getChild,\n getChildren,\n getDoc,\n intAttr,\n isAttrTrue,\n nameAttr,\n parseEnumAttr,\n type RawNode,\n} from \"./parse.js\";\nimport { typeRefFromNode } from \"./type-ref.js\";\n\ntype ParameterDirection = \"in\" | \"out\" | \"inout\";\ntype ParameterTransfer = \"none\" | \"full\" | \"container\";\ntype CallbackScope = \"call\" | \"notified\" | \"async\" | \"forever\";\n\ntype GirParameter = {\n name: string;\n type: TypeId | undefined;\n direction: ParameterDirection;\n transferOwnership: ParameterTransfer;\n nullable: boolean;\n optional: boolean;\n callerAllocates: boolean;\n scope: CallbackScope | undefined;\n closureIndex: number | undefined;\n destroyIndex: number | undefined;\n isVarargs: boolean;\n};\n\ntype GirReturnValue = {\n type: TypeId | undefined;\n transferOwnership: ParameterTransfer;\n nullable: boolean;\n skip: boolean;\n};\n\ntype GirCallable = {\n name: string;\n doc: string | undefined;\n parameters: GirParameter[];\n returnValue: GirReturnValue;\n throws: boolean;\n introspectable: boolean;\n};\n\nconst DIRECTIONS: Set<ParameterDirection> = new Set([\"in\", \"out\", \"inout\"]);\nconst TRANSFERS: Set<ParameterTransfer> = new Set([\"none\", \"full\", \"container\"]);\nconst SCOPES: Set<CallbackScope> = new Set([\"call\", \"notified\", \"async\", \"forever\"]);\n\nconst transferOwnership = (node: RawNode): ParameterTransfer =>\n parseEnumAttr(attr(node, \"transfer-ownership\"), TRANSFERS, \"none\", \"transfer-ownership\");\n\nconst isInDirection = (node: RawNode): boolean =>\n parseEnumAttr(attr(node, \"direction\"), DIRECTIONS, \"in\", \"direction\") === \"in\";\n\nconst hasNullableAttr = (node: RawNode): boolean =>\n isAttrTrue(node, \"nullable\") || (isInDirection(node) && isAttrTrue(node, \"allow-none\"));\n\nconst hasOptionalAttr = (node: RawNode): boolean =>\n isAttrTrue(node, \"optional\") || (!isInDirection(node) && isAttrTrue(node, \"allow-none\"));\n\nconst parameterFromNode = (node: RawNode, context: ParseContext): GirParameter => ({\n name: nameAttr(node),\n type: typeRefFromNode(node, context),\n direction: parseEnumAttr(attr(node, \"direction\"), DIRECTIONS, \"in\", \"direction\"),\n transferOwnership: transferOwnership(node),\n nullable: hasNullableAttr(node),\n optional: hasOptionalAttr(node),\n callerAllocates: isAttrTrue(node, \"caller-allocates\"),\n scope: parseEnumAttr(attr(node, \"scope\"), SCOPES, undefined, \"scope\"),\n closureIndex: intAttr(node, \"closure\"),\n destroyIndex: intAttr(node, \"destroy\"),\n isVarargs: getChild(node, \"varargs\") !== undefined,\n});\n\nconst isOutParameter = (parameter: GirParameter): boolean =>\n parameter.direction === \"out\" && !parameter.callerAllocates;\n\nconst isCallerAllocatedOut = (parameter: GirParameter): boolean =>\n parameter.direction === \"out\" && parameter.callerAllocates;\n\nconst isInoutParameter = (parameter: GirParameter): boolean => parameter.direction === \"inout\";\n\nconst returnValueFromNode = (node: RawNode | undefined, context: ParseContext): GirReturnValue => {\n if (node === undefined) {\n return { type: undefined, transferOwnership: \"none\", nullable: false, skip: false };\n }\n\n return {\n type: typeRefFromNode(node, context),\n transferOwnership: transferOwnership(node),\n nullable: hasNullableAttr(node),\n skip: isAttrTrue(node, \"skip\"),\n };\n};\n\nconst parseCallable = (node: RawNode, context: ParseContext): GirCallable => {\n const parametersNode = getChild(node, \"parameters\");\n const parameterNodes = getChildren(parametersNode, \"parameter\");\n\n return {\n name: nameAttr(node),\n doc: getDoc(node),\n parameters: parameterNodes.map((parameter) => parameterFromNode(parameter, context)),\n returnValue: returnValueFromNode(getChild(node, \"return-value\"), context),\n throws: isAttrTrue(node, \"throws\"),\n introspectable: isAttrTrue(node, \"introspectable\", true),\n };\n};\n\nexport {\n transferOwnership,\n parameterFromNode,\n isOutParameter,\n isCallerAllocatedOut,\n isInoutParameter,\n parseCallable,\n type ParameterTransfer,\n type GirParameter,\n type GirReturnValue,\n type GirCallable,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../src/gir/parameter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EACH,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,MAAM,EACN,OAAO,EACP,UAAU,EACV,QAAQ,EACR,aAAa,GAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EA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","sourcesContent":["import type { ParseContext, TypeId } from \"./type-id.js\";\nimport { documentedFromNode, type GirAnnotations } from \"./annotations.js\";\nimport {\n attr,\n getChild,\n getChildren,\n getDoc,\n intAttr,\n isAttrTrue,\n nameAttr,\n parseEnumAttr,\n type RawNode,\n} from \"./parse.js\";\nimport { typeRefFromNode } from \"./type-ref.js\";\n\n/** Which way a parameter's value travels: into the call, back out of it, or both. */\ntype ParameterDirection = \"in\" | \"out\" | \"inout\";\n/** How much of a value the receiver takes ownership of: none, the whole value, or only its container. */\ntype ParameterTransfer = \"none\" | \"full\" | \"container\";\n/**\n * How long a callback parameter stays valid: for the duration of the call, until its destroy notify runs,\n * until the asynchronous operation invokes it, or forever.\n */\ntype CallbackScope = \"call\" | \"notified\" | \"async\" | \"forever\";\n\n/** A parameter of a {@link GirCallable}, with the annotations that decide how it is marshalled. */\ntype GirParameter = {\n /** The name GIR gives the parameter. */\n name: string;\n /** What the parameter holds, absent when the GIR node declares no type. */\n type: TypeId | undefined;\n /** The C spelling of the parameter's type, taken from its `type` or `array` child. */\n cType: string | undefined;\n /** Documentation prose from GIR, emitted as the parameter's `@param` text. */\n doc: string | undefined;\n /** Decides whether the parameter is an argument, part of the returned tuple, or both. */\n direction: ParameterDirection;\n /** Ownership the marshalling descriptor is generated with, deciding whether the receiver frees the value. */\n transferOwnership: ParameterTransfer;\n /** Whether the value may be null. */\n nullable: boolean;\n /** Whether the caller may leave the parameter out entirely. */\n optional: boolean;\n /** Whether the caller supplies the storage an out parameter writes into. */\n callerAllocates: boolean;\n /** How long a callback parameter stays valid, absent when GIR carries no scope annotation. */\n scope: CallbackScope | undefined;\n /** Position of the parameter carrying the callback's user data. */\n closureIndex: number | undefined;\n /** Position of the parameter carrying the callback's destroy notify. */\n destroyIndex: number | undefined;\n /** Whether the parameter is the `...` varargs marker. */\n isVarargs: boolean;\n};\n\n/** What a {@link GirCallable} hands back, with the annotations that decide how it is marshalled. */\ntype GirReturnValue = {\n /** What the callable returns, absent when the GIR node declares no type. */\n type: TypeId | undefined;\n /** Documentation prose from GIR, emitted as the callable's `@returns` text. */\n doc: string | undefined;\n /** How much ownership the caller takes of the returned value. */\n transferOwnership: ParameterTransfer;\n /** Whether the returned value may be null. */\n nullable: boolean;\n /** Whether GIR marks the value as skipped, keeping it out of the generated signature. */\n skip: boolean;\n};\n\n/** Anything GIR describes with parameters and a return value: functions, methods, signals, and callbacks. */\ntype GirCallable = {\n /** The name GIR gives the callable. */\n name: string;\n /** The callable's documentation text, absent when GIR carries none. */\n doc: string | undefined;\n /** Release and deprecation annotations GIR carries on the callable. */\n annotations: GirAnnotations;\n /** The parameters the callable takes, in declaration order. */\n parameters: GirParameter[];\n /** What the callable hands back. */\n returnValue: GirReturnValue;\n /** Whether the callable reports failure through a trailing `GError`. */\n throws: boolean;\n /** Whether GIR exposes the callable to bindings. */\n introspectable: boolean;\n};\n\nconst DIRECTIONS: Set<ParameterDirection> = new Set([\"in\", \"out\", \"inout\"]);\nconst TRANSFERS: Set<ParameterTransfer> = new Set([\"none\", \"full\", \"container\"]);\nconst SCOPES: Set<CallbackScope> = new Set([\"call\", \"notified\", \"async\", \"forever\"]);\n\nconst transferOwnership = (node: RawNode): ParameterTransfer =>\n parseEnumAttr(attr(node, \"transfer-ownership\"), TRANSFERS, \"none\", \"transfer-ownership\");\n\nconst isInDirection = (node: RawNode): boolean =>\n parseEnumAttr(attr(node, \"direction\"), DIRECTIONS, \"in\", \"direction\") === \"in\";\n\nconst hasNullableAttr = (node: RawNode): boolean =>\n isAttrTrue(node, \"nullable\") || (isInDirection(node) && isAttrTrue(node, \"allow-none\"));\n\nconst hasOptionalAttr = (node: RawNode): boolean =>\n isAttrTrue(node, \"optional\") || (!isInDirection(node) && isAttrTrue(node, \"allow-none\"));\n\nconst parameterCType = (node: RawNode): string | undefined =>\n attr(getChild(node, \"type\"), \"c:type\") ?? attr(getChild(node, \"array\"), \"c:type\");\n\nconst parameterFromNode = (node: RawNode, context: ParseContext): GirParameter => ({\n name: nameAttr(node),\n type: typeRefFromNode(node, context),\n cType: parameterCType(node),\n doc: getDoc(node),\n direction: parseEnumAttr(attr(node, \"direction\"), DIRECTIONS, \"in\", \"direction\"),\n transferOwnership: transferOwnership(node),\n nullable: hasNullableAttr(node),\n optional: hasOptionalAttr(node),\n callerAllocates: isAttrTrue(node, \"caller-allocates\"),\n scope: parseEnumAttr(attr(node, \"scope\"), SCOPES, undefined, \"scope\"),\n closureIndex: intAttr(node, \"closure\"),\n destroyIndex: intAttr(node, \"destroy\"),\n isVarargs: getChild(node, \"varargs\") !== undefined,\n});\n\nconst isOutParameter = (parameter: GirParameter): boolean =>\n parameter.direction === \"out\" && !parameter.callerAllocates;\n\nconst isCallerAllocatedOut = (parameter: GirParameter): boolean =>\n parameter.direction === \"out\" && parameter.callerAllocates;\n\nconst isInoutParameter = (parameter: GirParameter): boolean => parameter.direction === \"inout\";\n\nconst returnValueFromNode = (node: RawNode | undefined, context: ParseContext): GirReturnValue => {\n if (node === undefined) {\n return { type: undefined, doc: undefined, transferOwnership: \"none\", nullable: false, skip: false };\n }\n\n return {\n type: typeRefFromNode(node, context),\n doc: getDoc(node),\n transferOwnership: transferOwnership(node),\n nullable: hasNullableAttr(node),\n skip: isAttrTrue(node, \"skip\"),\n };\n};\n\nconst parseCallable = (node: RawNode, context: ParseContext): GirCallable => {\n const parametersNode = getChild(node, \"parameters\");\n const parameterNodes = getChildren(parametersNode, \"parameter\");\n\n return {\n ...documentedFromNode(node),\n parameters: parameterNodes.map((parameter) => parameterFromNode(parameter, context)),\n returnValue: returnValueFromNode(getChild(node, \"return-value\"), context),\n throws: isAttrTrue(node, \"throws\"),\n introspectable: isAttrTrue(node, \"introspectable\", true),\n };\n};\n\nexport {\n transferOwnership,\n parameterFromNode,\n isOutParameter,\n isCallerAllocatedOut,\n isInoutParameter,\n parseCallable,\n type ParameterTransfer,\n type GirParameter,\n type GirReturnValue,\n type GirCallable,\n};\n"]}
|
package/dist/gir/parse.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** An element of the parsed GIR XML: attributes under `@_`-prefixed keys, children under their tag names. */
|
|
1
2
|
type RawNode = Record<string, unknown>;
|
|
2
3
|
declare const GIR_CONSTRUCTOR_TAG = "gir-constructor";
|
|
3
4
|
declare const parseGirFile: (path: string) => RawNode;
|
|
@@ -9,5 +10,6 @@ declare const parseEnumAttr: <T extends string, F extends T | undefined>(raw: st
|
|
|
9
10
|
declare const getChildren: (node: RawNode | undefined, tag: string) => RawNode[];
|
|
10
11
|
declare const getChild: (node: RawNode | undefined, tag: string) => RawNode | undefined;
|
|
11
12
|
declare const getDoc: (node: RawNode | undefined) => string | undefined;
|
|
12
|
-
|
|
13
|
+
declare const getDocDeprecated: (node: RawNode | undefined) => string | undefined;
|
|
14
|
+
export { GIR_CONSTRUCTOR_TAG, parseGirFile, attr, isAttrTrue, nameAttr, intAttr, parseEnumAttr, getChildren, getChild, getDoc, getDocDeprecated, type RawNode, };
|
|
13
15
|
//# sourceMappingURL=parse.d.ts.map
|
package/dist/gir/parse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/gir/parse.ts"],"names":[],"mappings":"AAGA,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/gir/parse.ts"],"names":[],"mappings":"AAGA,6GAA6G;AAC7G,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA0BvC,QAAA,MAAM,mBAAmB,oBAAoB,CAAC;AAc9C,QAAA,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAIpC,CAAC;AAEF,QAAA,MAAM,IAAI,GAAI,MAAM,OAAO,GAAG,SAAS,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAQhE,CAAC;AAEF,QAAA,MAAM,UAAU,GAAI,MAAM,OAAO,GAAG,SAAS,EAAE,MAAM,MAAM,EAAE,yBAAuB,KAAG,OAQtF,CAAC;AAEF,QAAA,MAAM,QAAQ,GAAI,MAAM,OAAO,KAAG,MAAkC,CAAC;AAErE,QAAA,MAAM,OAAO,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAIvD,CAAC;AAYF,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,SAAS,EAC5D,KAAK,MAAM,GAAG,SAAS,EACvB,SAAS,GAAG,CAAC,CAAC,CAAC,EACf,UAAU,CAAC,EACX,OAAO,MAAM,KACd,CAAC,GAAG,CAAqE,CAAC;AAE7E,QAAA,MAAM,WAAW,GAAI,MAAM,OAAO,GAAG,SAAS,EAAE,KAAK,MAAM,KAAG,OAAO,EAgBpE,CAAC;AAEF,QAAA,MAAM,QAAQ,GAAI,MAAM,OAAO,GAAG,SAAS,EAAE,KAAK,MAAM,KAAG,OAAO,GAAG,SAgBpE,CAAC;AAkCF,QAAA,MAAM,MAAM,GAAI,MAAM,OAAO,GAAG,SAAS,KAAG,MAAM,GAAG,SAAwC,CAAC;AAC9F,QAAA,MAAM,gBAAgB,GAAI,MAAM,OAAO,GAAG,SAAS,KAAG,MAAM,GAAG,SAAmD,CAAC;AAEnH,OAAO,EACH,mBAAmB,EACnB,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,OAAO,EACP,aAAa,EACb,WAAW,EACX,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,KAAK,OAAO,GACf,CAAC"}
|
package/dist/gir/parse.js
CHANGED
|
@@ -13,6 +13,7 @@ const MULTI_TAGS = new Set([
|
|
|
13
13
|
"alias",
|
|
14
14
|
"union",
|
|
15
15
|
"method",
|
|
16
|
+
"virtual-method",
|
|
16
17
|
"constructor",
|
|
17
18
|
"property",
|
|
18
19
|
"field",
|
|
@@ -100,11 +101,11 @@ const docTextFromObject = (value) => {
|
|
|
100
101
|
const text = value["#text"];
|
|
101
102
|
return typeof text === "string" ? normalizeDoc(text) : undefined;
|
|
102
103
|
};
|
|
103
|
-
const
|
|
104
|
+
const docElementText = (node, tag) => {
|
|
104
105
|
if (node === undefined) {
|
|
105
106
|
return undefined;
|
|
106
107
|
}
|
|
107
|
-
const value = firstDocValue(node
|
|
108
|
+
const value = firstDocValue(node[tag]);
|
|
108
109
|
if (typeof value === "string") {
|
|
109
110
|
return normalizeDoc(value);
|
|
110
111
|
}
|
|
@@ -113,5 +114,7 @@ const getDoc = (node) => {
|
|
|
113
114
|
}
|
|
114
115
|
return docTextFromObject(value);
|
|
115
116
|
};
|
|
116
|
-
|
|
117
|
+
const getDoc = (node) => docElementText(node, "doc");
|
|
118
|
+
const getDocDeprecated = (node) => docElementText(node, "doc-deprecated");
|
|
119
|
+
export { GIR_CONSTRUCTOR_TAG, parseGirFile, attr, isAttrTrue, nameAttr, intAttr, parseEnumAttr, getChildren, getChild, getDoc, getDocDeprecated, };
|
|
117
120
|
//# sourceMappingURL=parse.js.map
|
package/dist/gir/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/gir/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/gir/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAK5C,MAAM,UAAU,GAAgB,IAAI,GAAG,CAAC;IACpC,SAAS;IACT,OAAO;IACP,WAAW;IACX,QAAQ;IACR,aAAa;IACb,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,OAAO;IACP,OAAO;IACP,QAA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AC,CAAC,GAAG,CAAC,CAAC;AAErF,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAsB,EAAE;IAC5D,MAAM,IAAI,GAAI,KAAiB,CAAC,OAAO,CAAC,CAAC;IAEzC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAyB,EAAE,GAAW,EAAsB,EAAE;IAClF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9C,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,IAAyB,EAAsB,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC9F,MAAM,gBAAgB,GAAG,CAAC,IAAyB,EAAsB,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;AAEnH,OAAO,EACH,mBAAmB,EACnB,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,OAAO,EACP,aAAa,EACb,WAAW,EACX,QAAQ,EACR,MAAM,EACN,gBAAgB,GAEnB,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { createXmlParser } from \"../xml.js\";\n\n/** An element of the parsed GIR XML: attributes under `@_`-prefixed keys, children under their tag names. */\ntype RawNode = Record<string, unknown>;\n\nconst MULTI_TAGS: Set<string> = new Set([\n \"include\",\n \"class\",\n \"interface\",\n \"record\",\n \"enumeration\",\n \"bitfield\",\n \"callback\",\n \"function\",\n \"constant\",\n \"alias\",\n \"union\",\n \"method\",\n \"virtual-method\",\n \"constructor\",\n \"property\",\n \"field\",\n \"glib:signal\",\n \"implements\",\n \"prerequisite\",\n \"member\",\n \"parameter\",\n]);\n\nconst GIR_CONSTRUCTOR_TAG = \"gir-constructor\";\nconst RESERVED_TAG_RENAMES: Map<string, string> = new Map([[\"constructor\", GIR_CONSTRUCTOR_TAG]]);\nconst RENAMED_MULTI_TAGS: Set<string> = new Set([...MULTI_TAGS].map((tag) => renameReservedTag(tag)));\n\nconst PARSER = createXmlParser({\n trimValues: true,\n transformTagName: renameReservedTag,\n isArray: (name) => RENAMED_MULTI_TAGS.has(name),\n});\n\nfunction renameReservedTag(tag: string): string {\n return RESERVED_TAG_RENAMES.get(tag) ?? tag;\n}\n\nconst parseGirFile = (path: string): RawNode => {\n const xml = readFileSync(path, \"utf8\");\n\n return PARSER.parse(xml) as RawNode;\n};\n\nconst attr = (node: RawNode | undefined, name: string): string | undefined => {\n if (node === undefined) {\n return undefined;\n }\n\n const value = node[`@_${name}`];\n\n return typeof value === \"string\" ? value : undefined;\n};\n\nconst isAttrTrue = (node: RawNode | undefined, name: string, isTrueByDefault = false): boolean => {\n const value = attr(node, name);\n\n if (value === undefined) {\n return isTrueByDefault;\n }\n\n return value === \"1\";\n};\n\nconst nameAttr = (node: RawNode): string => attr(node, \"name\") ?? \"\";\n\nconst intAttr = (node: RawNode, name: string): number | undefined => {\n const raw = attr(node, name);\n\n return raw === undefined ? undefined : Number(raw);\n};\n\nconst enumMember = <T extends string>(raw: string, members: Set<T>, label: string): T => {\n for (const member of members) {\n if (member === raw) {\n return member;\n }\n }\n\n throw new Error(`Unknown ${label} value \"${raw}\"`);\n};\n\nconst parseEnumAttr = <T extends string, F extends T | undefined>(\n raw: string | undefined,\n members: Set<T>,\n fallback: F,\n label: string,\n): T | F => (raw === undefined ? fallback : enumMember(raw, members, label));\n\nconst getChildren = (node: RawNode | undefined, tag: string): RawNode[] => {\n if (node === undefined) {\n return [];\n }\n\n const value = node[tag];\n\n if (value === undefined) {\n return [];\n }\n\n if (Array.isArray(value)) {\n return value as RawNode[];\n }\n\n return [value as RawNode];\n};\n\nconst getChild = (node: RawNode | undefined, tag: string): RawNode | undefined => {\n if (node === undefined) {\n return undefined;\n }\n\n const value = node[tag];\n\n if (value === undefined) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n return value.length === 0 ? undefined : (value[0] as RawNode);\n }\n\n return value as RawNode;\n};\n\nconst normalizeDoc = (text: string): string | undefined => {\n const trimmed = text.trim();\n\n return trimmed.length === 0 ? undefined : trimmed;\n};\n\nconst firstDocValue = (raw: unknown): unknown => (Array.isArray(raw) ? raw[0] : raw);\n\nconst docTextFromObject = (value: object): string | undefined => {\n const text = (value as RawNode)[\"#text\"];\n\n return typeof text === \"string\" ? normalizeDoc(text) : undefined;\n};\n\nconst docElementText = (node: RawNode | undefined, tag: string): string | undefined => {\n if (node === undefined) {\n return undefined;\n }\n\n const value = firstDocValue(node[tag]);\n\n if (typeof value === \"string\") {\n return normalizeDoc(value);\n }\n\n if (value === null || typeof value !== \"object\") {\n return undefined;\n }\n\n return docTextFromObject(value);\n};\n\nconst getDoc = (node: RawNode | undefined): string | undefined => docElementText(node, \"doc\");\nconst getDocDeprecated = (node: RawNode | undefined): string | undefined => docElementText(node, \"doc-deprecated\");\n\nexport {\n GIR_CONSTRUCTOR_TAG,\n parseGirFile,\n attr,\n isAttrTrue,\n nameAttr,\n intAttr,\n parseEnumAttr,\n getChildren,\n getChild,\n getDoc,\n getDocDeprecated,\n type RawNode,\n};\n"]}
|
package/dist/gir/primitives.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** A fundamental C type GIR can name, collapsed to the marshalling category GTKX treats it as. */
|
|
1
2
|
type PrimitiveCategory = "void" | "boolean" | "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32" | "int64" | "uint64" | "bigint64" | "biguint64" | "gtype" | "float32" | "float64" | "string" | "unichar" | "pointer";
|
|
2
3
|
declare const PRIMITIVE_SIZE: Record<PrimitiveCategory, number>;
|
|
3
4
|
declare const PRIMITIVE_TS_TYPE: Record<PrimitiveCategory, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/gir/primitives.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAChB,MAAM,GACR,SAAS,GACT,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,UAAU,GACV,WAAW,GACX,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,CAAC;AAEd,QAAA,MAAM,cAAc,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAmBrD,CAAC;AAsDF,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAmBxD,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,iBAAiB,GAAG,SAAwC,CAAC;AAEvG,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/gir/primitives.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,KAAK,iBAAiB,GAChB,MAAM,GACR,SAAS,GACT,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,UAAU,GACV,WAAW,GACX,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,CAAC;AAEd,QAAA,MAAM,cAAc,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAmBrD,CAAC;AAsDF,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAmBxD,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,iBAAiB,GAAG,SAAwC,CAAC;AAEvG,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/gir/primitives.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/gir/primitives.ts"],"names":[],"mappings":"AAqBA,MAAM,cAAc,GAAsC;IACtD,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,CAAC;IACZ,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;CACb,CAAC;AAEF,MAAM,iBAAiB,GAAmC,IAAI,GAAG,CAAC;IAC9D,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,OAAO,EAAE,MAAM,CAAC;IACjB,CAAC,OAAO,EAAE,MAAM,CAAC;IACjB,CAAC,QAAQ,EAAE,OAAO,CAAC;IACnB,CAAC,QAAQ,EAAE,OAA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AAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,QAAQ,EAAE,SAAS,CAAC;IACrB,CAAC,aAAa,EAAE,SAAS,CAAC;IAC1B,CAAC,MAAM,EAAE,QAAQ,CAAC;IAClB,CAAC,UAAU,EAAE,QAAQ,CAAC;IACtB,CAAC,YAAY,EAAE,QAAQ,CAAC;IACxB,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,eAAe,EAAE,SAAS,CAAC;CACtB,CAAC,CAAC;AAEZ,MAAM,iBAAiB,GAAsC;IACzD,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,QAAQ;IACnB,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,QAAQ;IACjB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,QAAQ;CACpB,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAiC,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAEvG,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAA0B,CAAC","sourcesContent":["/** A fundamental C type GIR can name, collapsed to the marshalling category GTKX treats it as. */\ntype PrimitiveCategory =\n | \"void\" |\n \"boolean\" |\n \"int8\" |\n \"uint8\" |\n \"int16\" |\n \"uint16\" |\n \"int32\" |\n \"uint32\" |\n \"int64\" |\n \"uint64\" |\n \"bigint64\" |\n \"biguint64\" |\n \"gtype\" |\n \"float32\" |\n \"float64\" |\n \"string\" |\n \"unichar\" |\n \"pointer\";\n\nconst PRIMITIVE_SIZE: Record<PrimitiveCategory, number> = {\n void: 0,\n boolean: 4,\n int8: 1,\n uint8: 1,\n int16: 2,\n uint16: 2,\n int32: 4,\n uint32: 4,\n int64: 8,\n uint64: 8,\n bigint64: 8,\n biguint64: 8,\n gtype: 8,\n float32: 4,\n float64: 8,\n string: 8,\n unichar: 4,\n pointer: 8,\n};\n\nconst PRIMITIVE_BY_NAME: Map<string, PrimitiveCategory> = new Map([\n [\"none\", \"void\"],\n [\"void\", \"void\"],\n [\"gboolean\", \"boolean\"],\n [\"gchar\", \"int8\"],\n [\"gint8\", \"int8\"],\n [\"guchar\", \"uint8\"],\n [\"guint8\", \"uint8\"],\n [\"gshort\", \"int16\"],\n [\"gint16\", \"int16\"],\n [\"gushort\", \"uint16\"],\n [\"guint16\", \"uint16\"],\n [\"gint\", \"int32\"],\n [\"gint32\", \"int32\"],\n [\"int\", \"int32\"],\n [\"int8\", \"int8\"],\n [\"uint8\", \"uint8\"],\n [\"int16\", \"int16\"],\n [\"uint16\", \"uint16\"],\n [\"int32\", \"int32\"],\n [\"uint32\", \"uint32\"],\n [\"int64\", \"bigint64\"],\n [\"uint64\", \"biguint64\"],\n [\"guint\", \"uint32\"],\n [\"guint32\", \"uint32\"],\n [\"glong\", \"bigint64\"],\n [\"gint64\", \"bigint64\"],\n [\"long\", \"bigint64\"],\n [\"gssize\", \"int64\"],\n [\"gintptr\", \"int64\"],\n [\"gulong\", \"biguint64\"],\n [\"guint64\", \"biguint64\"],\n [\"gsize\", \"uint64\"],\n [\"guintptr\", \"uint64\"],\n [\"GType\", \"gtype\"],\n [\"time_t\", \"bigint64\"],\n [\"pid_t\", \"int32\"],\n [\"uid_t\", \"uint32\"],\n [\"gid_t\", \"uint32\"],\n [\"gfloat\", \"float32\"],\n [\"float\", \"float32\"],\n [\"gdouble\", \"float64\"],\n [\"double\", \"float64\"],\n [\"long double\", \"float64\"],\n [\"utf8\", \"string\"],\n [\"filename\", \"string\"],\n [\"gchararray\", \"string\"],\n [\"gunichar\", \"unichar\"],\n [\"gpointer\", \"pointer\"],\n [\"gconstpointer\", \"pointer\"],\n] as const);\n\nconst PRIMITIVE_TS_TYPE: Record<PrimitiveCategory, string> = {\n void: \"void\",\n boolean: \"boolean\",\n int8: \"number\",\n uint8: \"number\",\n int16: \"number\",\n uint16: \"number\",\n int32: \"number\",\n uint32: \"number\",\n int64: \"number\",\n uint64: \"number\",\n bigint64: \"bigint\",\n biguint64: \"bigint\",\n gtype: \"bigint\",\n float32: \"number\",\n float64: \"number\",\n string: \"string\",\n unichar: \"string\",\n pointer: \"number\",\n};\n\nconst primitiveCategory = (name: string): PrimitiveCategory | undefined => PRIMITIVE_BY_NAME.get(name);\n\nexport { PRIMITIVE_SIZE, PRIMITIVE_TS_TYPE, primitiveCategory, type PrimitiveCategory };\n"]}
|
package/dist/gir/property.d.ts
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
import type { ParseContext, TypeId } from "./type-id.js";
|
|
2
|
+
import { type GirAnnotations } from "./annotations.js";
|
|
2
3
|
import { type ParameterTransfer } from "./parameter.js";
|
|
3
4
|
import { type RawNode } from "./parse.js";
|
|
5
|
+
/** A GObject property declared on a class or interface, with the annotations its accessors are generated from. */
|
|
4
6
|
type GirProperty = {
|
|
7
|
+
/** Canonical property name, dashed the way GObject registers it. */
|
|
5
8
|
name: string;
|
|
9
|
+
/** Documentation prose from GIR, emitted as the accessor's JSDoc. */
|
|
6
10
|
doc: string | undefined;
|
|
11
|
+
/** Release and deprecation annotations GIR carries on the property. */
|
|
12
|
+
annotations: GirAnnotations;
|
|
13
|
+
/** The property's value type, absent when GIR declares none. */
|
|
7
14
|
type: TypeId | undefined;
|
|
15
|
+
/** Whether GObject exposes the value for reading, which admits a generated getter. */
|
|
8
16
|
readable: boolean;
|
|
17
|
+
/** Whether GObject accepts a value for the property, which admits a generated setter. */
|
|
9
18
|
writable: boolean;
|
|
19
|
+
/** Whether GObject sets the property during construction, using its default when none is supplied. */
|
|
10
20
|
construct: boolean;
|
|
21
|
+
/** Whether the property can only be set at construction. */
|
|
11
22
|
constructOnly: boolean;
|
|
23
|
+
/** Whether GIR exposes the property to bindings. */
|
|
12
24
|
introspectable: boolean;
|
|
25
|
+
/** How ownership of the value transfers, which decides the descriptor the accessors marshal through. */
|
|
13
26
|
transferOwnership: ParameterTransfer;
|
|
27
|
+
/** Method GIR names as reading the property, which the generated getter delegates to. */
|
|
14
28
|
getter: string | undefined;
|
|
29
|
+
/** Method GIR names as writing the property, which the generated setter delegates to. */
|
|
15
30
|
setter: string | undefined;
|
|
31
|
+
/** The property's default, as GIR spells it. */
|
|
16
32
|
defaultValue: string | undefined;
|
|
17
33
|
};
|
|
18
34
|
declare const isConstructableProperty: (property: GirProperty) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../src/gir/property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../src/gir/property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5D,kHAAkH;AAClH,KAAK,WAAW,GAAG;IACf,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,uEAAuE;IACvE,WAAW,EAAE,cAAc,CAAC;IAC5B,gEAAgE;IAChE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,sFAAsF;IACtF,QAAQ,EAAE,OAAO,CAAC;IAClB,yFAAyF;IACzF,QAAQ,EAAE,OAAO,CAAC;IAClB,sGAAsG;IACtG,SAAS,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,aAAa,EAAE,OAAO,CAAC;IACvB,oDAAoD;IACpD,cAAc,EAAE,OAAO,CAAC;IACxB,wGAAwG;IACxG,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,yFAAyF;IACzF,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,yFAAyF;IACzF,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,gDAAgD;IAChD,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAEF,QAAA,MAAM,uBAAuB,GAAI,UAAU,WAAW,KAAG,OACY,CAAC;AAEtE,QAAA,MAAM,gBAAgB,GAAI,MAAM,OAAO,EAAE,SAAS,YAAY,KAAG,WAY/D,CAAC;AAEH,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,CAAC"}
|
package/dist/gir/property.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { documentedFromNode } from "./annotations.js";
|
|
1
2
|
import { transferOwnership } from "./parameter.js";
|
|
2
|
-
import { attr,
|
|
3
|
+
import { attr, isAttrTrue } from "./parse.js";
|
|
3
4
|
import { typeRefFromNode } from "./type-ref.js";
|
|
4
5
|
const isConstructableProperty = (property) => property.writable || property.construct || property.constructOnly;
|
|
5
6
|
const propertyFromNode = (node, context) => ({
|
|
6
|
-
|
|
7
|
-
doc: getDoc(node),
|
|
7
|
+
...documentedFromNode(node),
|
|
8
8
|
type: typeRefFromNode(node, context),
|
|
9
9
|
readable: isAttrTrue(node, "readable", true),
|
|
10
10
|
writable: isAttrTrue(node, "writable"),
|
package/dist/gir/property.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property.js","sourceRoot":"","sources":["../../src/gir/property.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"property.js","sourceRoot":"","sources":["../../src/gir/property.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAA0B,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAgChD,MAAM,uBAAuB,GAAG,CAAC,QAAqB,EAAW,EAAE,CAC/D,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,aAAa,CAAC;AAEtE,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAE,OAAqB,EAAe,EAAE,CAAC,CAAC;IAC7E,GAAG,kBAAkB,CAAC,IAAI,CAAC;IAC3B,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC;IACpC,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC;IAC5C,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC;IACtC,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC;IACxC,aAAa,EAAE,UAAU,CAAC,IAAI,EAAE,gBAAgB,CAAC;IACjD,cAAc,EAAE,UAAU,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC;IACxD,iBAAiB,EAAE,iBAAiB,CAAC,IAAI,CAAC;IAC1C,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;IAC5B,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;IAC5B,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC;CAC5C,CAAC,CAAC;AAEH,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAoB,CAAC","sourcesContent":["import type { ParseContext, TypeId } from \"./type-id.js\";\nimport { documentedFromNode, type GirAnnotations } from \"./annotations.js\";\nimport { type ParameterTransfer, transferOwnership } from \"./parameter.js\";\nimport { attr, isAttrTrue, type RawNode } from \"./parse.js\";\nimport { typeRefFromNode } from \"./type-ref.js\";\n\n/** A GObject property declared on a class or interface, with the annotations its accessors are generated from. */\ntype GirProperty = {\n /** Canonical property name, dashed the way GObject registers it. */\n name: string;\n /** Documentation prose from GIR, emitted as the accessor's JSDoc. */\n doc: string | undefined;\n /** Release and deprecation annotations GIR carries on the property. */\n annotations: GirAnnotations;\n /** The property's value type, absent when GIR declares none. */\n type: TypeId | undefined;\n /** Whether GObject exposes the value for reading, which admits a generated getter. */\n readable: boolean;\n /** Whether GObject accepts a value for the property, which admits a generated setter. */\n writable: boolean;\n /** Whether GObject sets the property during construction, using its default when none is supplied. */\n construct: boolean;\n /** Whether the property can only be set at construction. */\n constructOnly: boolean;\n /** Whether GIR exposes the property to bindings. */\n introspectable: boolean;\n /** How ownership of the value transfers, which decides the descriptor the accessors marshal through. */\n transferOwnership: ParameterTransfer;\n /** Method GIR names as reading the property, which the generated getter delegates to. */\n getter: string | undefined;\n /** Method GIR names as writing the property, which the generated setter delegates to. */\n setter: string | undefined;\n /** The property's default, as GIR spells it. */\n defaultValue: string | undefined;\n};\n\nconst isConstructableProperty = (property: GirProperty): boolean =>\n property.writable || property.construct || property.constructOnly;\n\nconst propertyFromNode = (node: RawNode, context: ParseContext): GirProperty => ({\n ...documentedFromNode(node),\n type: typeRefFromNode(node, context),\n readable: isAttrTrue(node, \"readable\", true),\n writable: isAttrTrue(node, \"writable\"),\n construct: isAttrTrue(node, \"construct\"),\n constructOnly: isAttrTrue(node, \"construct-only\"),\n introspectable: isAttrTrue(node, \"introspectable\", true),\n transferOwnership: transferOwnership(node),\n getter: attr(node, \"getter\"),\n setter: attr(node, \"setter\"),\n defaultValue: attr(node, \"default-value\"),\n});\n\nexport { isConstructableProperty, propertyFromNode, type GirProperty };\n"]}
|