@gtkx/codegen 1.0.0-rc.1 → 1.0.0-rc.2
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/dist/analysis/descriptor-render.d.ts +18 -11
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +275 -152
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +37 -34
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +34 -30
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/inheritance.d.ts +16 -16
- package/dist/analysis/inheritance.d.ts.map +1 -1
- package/dist/analysis/inheritance.js +139 -84
- package/dist/analysis/inheritance.js.map +1 -1
- package/dist/analysis/param-structure.d.ts +14 -13
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +104 -53
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +6 -5
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +69 -23
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/compile.d.ts +5 -5
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +70 -63
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +12 -11
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +194 -121
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/element-page.d.ts +6 -9
- package/dist/docs/element-page.d.ts.map +1 -1
- package/dist/docs/element-page.js +68 -133
- package/dist/docs/element-page.js.map +1 -1
- package/dist/docs/pipeline.d.ts +8 -7
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +79 -53
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.d.ts +21 -19
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +80 -71
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts +6 -6
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +126 -84
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +28 -5
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +66 -13
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +13 -0
- package/dist/gi.d.ts.map +1 -0
- package/dist/gi.js +21 -0
- package/dist/gi.js.map +1 -0
- package/dist/gir/ancestry.d.ts +4 -3
- package/dist/gir/ancestry.d.ts.map +1 -1
- package/dist/gir/ancestry.js +12 -15
- package/dist/gir/ancestry.js.map +1 -1
- package/dist/gir/callback.d.ts +6 -11
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +6 -7
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +7 -5
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +14 -12
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +3 -3
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +7 -6
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +8 -3
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +30 -7
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/function.d.ts +6 -3
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +23 -7
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/gir-path.d.ts +2 -1
- package/dist/gir/gir-path.d.ts.map +1 -1
- package/dist/gir/gir-path.js +26 -10
- package/dist/gir/gir-path.js.map +1 -1
- package/dist/gir/libraries.d.ts +3 -2
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +39 -27
- package/dist/gir/libraries.js.map +1 -1
- package/dist/gir/library.d.ts +17 -11
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +116 -92
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/namespace.d.ts +10 -10
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +21 -20
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/nullable-overrides.d.ts +3 -0
- package/dist/gir/nullable-overrides.d.ts.map +1 -0
- package/dist/gir/nullable-overrides.js +5 -0
- package/dist/gir/nullable-overrides.js.map +1 -0
- package/dist/gir/parameter.d.ts +14 -12
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +27 -18
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts +12 -13
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +50 -40
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +5 -4
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js +4 -3
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +5 -4
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +10 -9
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +5 -4
- package/dist/gir/record.d.ts.map +1 -1
- package/dist/gir/record.js +13 -12
- package/dist/gir/record.js.map +1 -1
- package/dist/gir/size.d.ts +6 -5
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +49 -47
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +17 -15
- package/dist/gir/type-id.d.ts.map +1 -1
- package/dist/gir/type-id.js +5 -1
- package/dist/gir/type-id.js.map +1 -1
- package/dist/gir/type-ref.d.ts +3 -2
- package/dist/gir/type-ref.d.ts.map +1 -1
- package/dist/gir/type-ref.js +36 -25
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/gir/type.d.ts +3 -2
- package/dist/gir/type.d.ts.map +1 -1
- package/dist/gir/type.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx.d.ts +26 -0
- package/dist/jsx.d.ts.map +1 -0
- package/dist/jsx.js +40 -0
- package/dist/jsx.js.map +1 -0
- package/dist/khronos/args.d.ts +7 -7
- package/dist/khronos/args.d.ts.map +1 -1
- package/dist/khronos/args.js +88 -67
- package/dist/khronos/args.js.map +1 -1
- package/dist/khronos/jsdoc.d.ts +4 -4
- package/dist/khronos/jsdoc.d.ts.map +1 -1
- package/dist/khronos/jsdoc.js +29 -16
- package/dist/khronos/jsdoc.js.map +1 -1
- package/dist/khronos/model.d.ts +8 -7
- package/dist/khronos/model.d.ts.map +1 -1
- package/dist/khronos/model.js +94 -59
- package/dist/khronos/model.js.map +1 -1
- package/dist/khronos/modules.d.ts +4 -3
- package/dist/khronos/modules.d.ts.map +1 -1
- package/dist/khronos/modules.js +40 -25
- package/dist/khronos/modules.js.map +1 -1
- package/dist/khronos/param-pair.d.ts +11 -0
- package/dist/khronos/param-pair.d.ts.map +1 -0
- package/dist/khronos/param-pair.js +6 -0
- package/dist/khronos/param-pair.js.map +1 -0
- package/dist/khronos/parse.d.ts +7 -8
- package/dist/khronos/parse.d.ts.map +1 -1
- package/dist/khronos/parse.js +17 -16
- package/dist/khronos/parse.js.map +1 -1
- package/dist/khronos/pipeline.d.ts +4 -4
- package/dist/khronos/pipeline.d.ts.map +1 -1
- package/dist/khronos/pipeline.js +97 -56
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +11 -10
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +109 -45
- package/dist/khronos/plan.js.map +1 -1
- package/dist/khronos/render.d.ts +5 -4
- package/dist/khronos/render.d.ts.map +1 -1
- package/dist/khronos/render.js +106 -59
- package/dist/khronos/render.js.map +1 -1
- package/dist/khronos/select.d.ts +4 -4
- package/dist/khronos/select.d.ts.map +1 -1
- package/dist/khronos/select.js +30 -19
- package/dist/khronos/select.js.map +1 -1
- package/dist/react/element-config.d.ts +17 -0
- package/dist/react/element-config.d.ts.map +1 -0
- package/dist/react/element-config.js +61 -0
- package/dist/react/element-config.js.map +1 -0
- package/dist/runner.d.ts +17 -10
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +45 -43
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +5 -3
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +24 -22
- package/dist/store/compile-store.js.map +1 -1
- package/dist/store/gi/async.d.ts +2 -1
- package/dist/store/gi/async.d.ts.map +1 -1
- package/dist/store/gi/async.js +28 -24
- package/dist/store/gi/async.js.map +1 -1
- package/dist/store/gi/callables.d.ts +26 -20
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +162 -100
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/callback.d.ts +3 -2
- package/dist/store/gi/callback.d.ts.map +1 -1
- package/dist/store/gi/callback.js +6 -3
- package/dist/store/gi/callback.js.map +1 -1
- package/dist/store/gi/class-struct-record.d.ts +4 -3
- package/dist/store/gi/class-struct-record.d.ts.map +1 -1
- package/dist/store/gi/class-struct-record.js +33 -15
- package/dist/store/gi/class-struct-record.js.map +1 -1
- package/dist/store/gi/class.d.ts +2 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +86 -47
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/companion.d.ts +2 -1
- package/dist/store/gi/companion.d.ts.map +1 -1
- package/dist/store/gi/companion.js +8 -5
- package/dist/store/gi/companion.js.map +1 -1
- package/dist/store/gi/constant.d.ts +3 -2
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +25 -8
- package/dist/store/gi/constant.js.map +1 -1
- package/dist/store/gi/constructor-props.d.ts +3 -2
- package/dist/store/gi/constructor-props.d.ts.map +1 -1
- package/dist/store/gi/constructor-props.js +17 -10
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/enum.d.ts +3 -2
- package/dist/store/gi/enum.d.ts.map +1 -1
- package/dist/store/gi/enum.js +14 -11
- package/dist/store/gi/enum.js.map +1 -1
- package/dist/store/gi/function.d.ts +5 -4
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +50 -23
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/gtype-binding.d.ts +4 -4
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +15 -11
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/interface.d.ts +2 -1
- package/dist/store/gi/interface.d.ts.map +1 -1
- package/dist/store/gi/interface.js +36 -18
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/item-comparators.d.ts +3 -2
- package/dist/store/gi/item-comparators.d.ts.map +1 -1
- package/dist/store/gi/item-comparators.js +33 -21
- package/dist/store/gi/item-comparators.js.map +1 -1
- package/dist/store/gi/method.d.ts +13 -13
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +187 -130
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +7 -6
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +26 -13
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/pipeline.d.ts +2 -1
- package/dist/store/gi/pipeline.d.ts.map +1 -1
- package/dist/store/gi/pipeline.js +38 -23
- package/dist/store/gi/pipeline.js.map +1 -1
- package/dist/store/gi/properties.d.ts +2 -1
- package/dist/store/gi/properties.d.ts.map +1 -1
- package/dist/store/gi/properties.js +6 -4
- package/dist/store/gi/properties.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +11 -10
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +86 -60
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts +3 -2
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +36 -25
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +8 -8
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +171 -99
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +6 -5
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +75 -39
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/record.d.ts +2 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +19 -13
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/registration.d.ts +3 -3
- package/dist/store/gi/registration.d.ts.map +1 -1
- package/dist/store/gi/registration.js +3 -2
- package/dist/store/gi/registration.js.map +1 -1
- package/dist/store/gi/return-wrap.d.ts +2 -2
- package/dist/store/gi/return-wrap.d.ts.map +1 -1
- package/dist/store/gi/return-wrap.js +43 -22
- package/dist/store/gi/return-wrap.js.map +1 -1
- package/dist/store/gi/runtime-override.d.ts +2 -1
- package/dist/store/gi/runtime-override.d.ts.map +1 -1
- package/dist/store/gi/runtime-override.js +6 -3
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.d.ts +3 -2
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +113 -66
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/vtable.d.ts +2 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +60 -30
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +5 -4
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +4 -2
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/element-components.d.ts +23 -0
- package/dist/store/jsx/element-components.d.ts.map +1 -0
- package/dist/store/jsx/element-components.js +86 -0
- package/dist/store/jsx/element-components.js.map +1 -0
- package/dist/store/jsx/element-prop-imports.d.ts +17 -0
- package/dist/store/jsx/element-prop-imports.d.ts.map +1 -0
- package/dist/store/jsx/element-prop-imports.js +15 -0
- package/dist/store/jsx/element-prop-imports.js.map +1 -0
- package/dist/store/jsx/element-prop-types.d.ts +10 -0
- package/dist/store/jsx/element-prop-types.d.ts.map +1 -0
- package/dist/store/jsx/element-prop-types.js +41 -0
- package/dist/store/jsx/element-prop-types.js.map +1 -0
- package/dist/store/jsx/gir-index.d.ts +16 -0
- package/dist/store/jsx/gir-index.d.ts.map +1 -0
- package/dist/store/jsx/gir-index.js +33 -0
- package/dist/store/jsx/gir-index.js.map +1 -0
- package/dist/store/jsx/intrinsic-elements.d.ts +27 -0
- package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -0
- package/dist/store/jsx/intrinsic-elements.js +128 -0
- package/dist/store/jsx/intrinsic-elements.js.map +1 -0
- package/dist/store/{react → jsx}/jsx.d.ts +2 -4
- package/dist/store/jsx/jsx.d.ts.map +1 -0
- package/dist/store/{react → jsx}/jsx.js +110 -71
- package/dist/store/jsx/jsx.js.map +1 -0
- package/dist/store/jsx/metadata.d.ts +4 -0
- package/dist/store/jsx/metadata.d.ts.map +1 -0
- package/dist/store/{react → jsx}/metadata.js +148 -69
- package/dist/store/jsx/metadata.js.map +1 -0
- package/dist/store/jsx/pipeline.d.ts +21 -0
- package/dist/store/jsx/pipeline.d.ts.map +1 -0
- package/dist/store/{react → jsx}/pipeline.js +36 -15
- package/dist/store/jsx/pipeline.js.map +1 -0
- package/dist/store/{react → jsx}/props.d.ts +9 -12
- package/dist/store/jsx/props.d.ts.map +1 -0
- package/dist/store/jsx/props.js +158 -0
- package/dist/store/jsx/props.js.map +1 -0
- package/dist/store/jsx-store.d.ts +5 -3
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +4 -1
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +14 -12
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +9 -7
- package/dist/store/store-fs.js.map +1 -1
- package/dist/writer/context.d.ts +2 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +12 -6
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/doc.d.ts +2 -1
- package/dist/writer/doc.d.ts.map +1 -1
- package/dist/writer/doc.js +13 -7
- package/dist/writer/doc.js.map +1 -1
- package/dist/writer/emit.d.ts +8 -7
- package/dist/writer/emit.d.ts.map +1 -1
- package/dist/writer/emit.js +13 -10
- package/dist/writer/emit.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts +2 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +29 -18
- package/dist/writer/gtk-doc.js.map +1 -1
- package/dist/writer/imports.d.ts +4 -2
- package/dist/writer/imports.d.ts.map +1 -1
- package/dist/writer/imports.js +35 -24
- package/dist/writer/imports.js.map +1 -1
- package/dist/writer/module.d.ts +3 -2
- package/dist/writer/module.d.ts.map +1 -1
- package/dist/writer/module.js +16 -9
- package/dist/writer/module.js.map +1 -1
- package/dist/xml.d.ts +4 -0
- package/dist/xml.d.ts.map +1 -0
- package/dist/xml.js +10 -0
- package/dist/xml.js.map +1 -0
- package/overrides/cairo/context.ts.ejs +7 -7
- package/overrides/cairo/matrix.ts.ejs +2 -2
- package/overrides/cairo/recording-surface.ts.ejs +2 -2
- package/overrides/cairo/region.ts.ejs +1 -1
- package/overrides/cairo/scaled-font.ts.ejs +3 -3
- package/package.json +15 -9
- package/src/analysis/descriptor-render.ts +484 -168
- package/src/analysis/descriptor.ts +162 -125
- package/src/analysis/inheritance.ts +286 -98
- package/src/analysis/param-structure.ts +188 -57
- package/src/analysis/ts-type.ts +112 -26
- package/src/compile.ts +103 -76
- package/src/docs/api-reference.ts +340 -144
- package/src/docs/element-page.ts +137 -146
- package/src/docs/pipeline.ts +132 -73
- package/src/docs/render.ts +151 -87
- package/src/docs/symbol-page.ts +268 -123
- package/src/fingerprint.ts +127 -29
- package/src/gi.ts +26 -0
- package/src/gir/ancestry.ts +26 -14
- package/src/gir/callback.ts +10 -15
- package/src/gir/class.ts +20 -16
- package/src/gir/enum.ts +9 -7
- package/src/gir/field.ts +37 -8
- package/src/gir/function.ts +33 -9
- package/src/gir/gir-path.ts +36 -12
- package/src/gir/libraries.ts +56 -31
- package/src/gir/library.ts +200 -97
- package/src/gir/namespace.ts +42 -26
- package/src/gir/nullable-overrides.ts +5 -0
- package/src/gir/parameter.ts +80 -42
- package/src/gir/parse.ts +102 -47
- package/src/gir/primitives.ts +25 -23
- package/src/gir/property.ts +13 -11
- package/src/gir/record.ts +16 -14
- package/src/gir/size.ts +91 -58
- package/src/gir/type-id.ts +33 -18
- package/src/gir/type-ref.ts +62 -26
- package/src/gir/type.ts +10 -8
- package/src/index.ts +7 -0
- package/src/jsx.ts +70 -0
- package/src/khronos/args.ts +158 -89
- package/src/khronos/jsdoc.ts +67 -29
- package/src/khronos/model.ts +154 -53
- package/src/khronos/modules.ts +67 -27
- package/src/khronos/param-pair.ts +14 -0
- package/src/khronos/parse.ts +37 -17
- package/src/khronos/pipeline.ts +193 -90
- package/src/khronos/plan.ts +235 -86
- package/src/khronos/render.ts +208 -71
- package/src/khronos/select.ts +48 -18
- package/src/react/element-config.ts +91 -0
- package/src/runner.ts +93 -57
- package/src/store/compile-store.ts +32 -26
- package/src/store/gi/async.ts +48 -21
- package/src/store/gi/callables.ts +345 -136
- package/src/store/gi/callback.ts +13 -4
- package/src/store/gi/class-struct-record.ts +49 -17
- package/src/store/gi/class.ts +186 -64
- package/src/store/gi/companion.ts +15 -6
- package/src/store/gi/constant.ts +42 -8
- package/src/store/gi/constructor-props.ts +42 -16
- package/src/store/gi/enum.ts +28 -13
- package/src/store/gi/function.ts +90 -24
- package/src/store/gi/gtype-binding.ts +31 -18
- package/src/store/gi/interface.ts +101 -36
- package/src/store/gi/item-comparators.ts +74 -26
- package/src/store/gi/method.ts +376 -159
- package/src/store/gi/param-marshal.ts +38 -15
- package/src/store/gi/pipeline.ts +72 -22
- package/src/store/gi/properties.ts +16 -5
- package/src/store/gi/property-accessor.ts +192 -84
- package/src/store/gi/record-constructor.ts +62 -30
- package/src/store/gi/record-field-accessor.ts +380 -167
- package/src/store/gi/record-layout.ts +130 -43
- package/src/store/gi/record.ts +37 -14
- package/src/store/gi/registration.ts +15 -9
- package/src/store/gi/return-wrap.ts +71 -23
- package/src/store/gi/runtime-override.ts +13 -3
- package/src/store/gi/signal.ts +244 -104
- package/src/store/gi/vtable.ts +117 -41
- package/src/store/gi-store.ts +26 -13
- package/src/store/jsx/element-components.ts +152 -0
- package/src/store/jsx/element-prop-imports.ts +24 -0
- package/src/store/jsx/element-prop-types.ts +59 -0
- package/src/store/jsx/gir-index.ts +62 -0
- package/src/store/jsx/intrinsic-elements.ts +262 -0
- package/src/store/{react → jsx}/jsx.ts +213 -99
- package/src/store/jsx/metadata.ts +385 -0
- package/src/store/jsx/pipeline.ts +145 -0
- package/src/store/jsx/props.ts +274 -0
- package/src/store/jsx-store.ts +15 -3
- package/src/store/store-fs.ts +36 -20
- package/src/writer/context.ts +25 -6
- package/src/writer/doc.ts +19 -5
- package/src/writer/emit.ts +20 -11
- package/src/writer/gtk-doc.ts +48 -21
- package/src/writer/imports.ts +63 -28
- package/src/writer/module.ts +35 -11
- package/src/xml.ts +12 -0
- package/dist/store/react/built-ins.d.ts +0 -9
- package/dist/store/react/built-ins.d.ts.map +0 -1
- package/dist/store/react/built-ins.js +0 -226
- package/dist/store/react/built-ins.js.map +0 -1
- package/dist/store/react/element-components.d.ts +0 -15
- package/dist/store/react/element-components.d.ts.map +0 -1
- package/dist/store/react/element-components.js +0 -92
- package/dist/store/react/element-components.js.map +0 -1
- package/dist/store/react/element-prop-types.d.ts +0 -19
- package/dist/store/react/element-prop-types.d.ts.map +0 -1
- package/dist/store/react/element-prop-types.js +0 -244
- package/dist/store/react/element-prop-types.js.map +0 -1
- package/dist/store/react/element-props.d.ts +0 -4
- package/dist/store/react/element-props.d.ts.map +0 -1
- package/dist/store/react/element-props.js +0 -178
- package/dist/store/react/element-props.js.map +0 -1
- package/dist/store/react/gir-index.d.ts +0 -25
- package/dist/store/react/gir-index.d.ts.map +0 -1
- package/dist/store/react/gir-index.js +0 -55
- package/dist/store/react/gir-index.js.map +0 -1
- package/dist/store/react/intrinsic-elements.d.ts +0 -26
- package/dist/store/react/intrinsic-elements.d.ts.map +0 -1
- package/dist/store/react/intrinsic-elements.js +0 -107
- package/dist/store/react/intrinsic-elements.js.map +0 -1
- package/dist/store/react/jsx.d.ts.map +0 -1
- package/dist/store/react/jsx.js.map +0 -1
- package/dist/store/react/metadata.d.ts +0 -4
- package/dist/store/react/metadata.d.ts.map +0 -1
- package/dist/store/react/metadata.js.map +0 -1
- package/dist/store/react/pipeline.d.ts +0 -14
- package/dist/store/react/pipeline.d.ts.map +0 -1
- package/dist/store/react/pipeline.js.map +0 -1
- package/dist/store/react/props.d.ts.map +0 -1
- package/dist/store/react/props.js +0 -133
- package/dist/store/react/props.js.map +0 -1
- package/overrides/gtk/constants.ts.ejs +0 -3
- package/overrides/gtk/index.ts.ejs +0 -2
- package/src/store/react/built-ins.ts +0 -260
- package/src/store/react/element-components.ts +0 -138
- package/src/store/react/element-prop-types.ts +0 -280
- package/src/store/react/element-props.ts +0 -204
- package/src/store/react/gir-index.ts +0 -85
- package/src/store/react/intrinsic-elements.ts +0 -161
- package/src/store/react/metadata.ts +0 -197
- package/src/store/react/pipeline.ts +0 -90
- package/src/store/react/props.ts +0 -197
package/dist/store/gi/method.js
CHANGED
|
@@ -1,112 +1,134 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { arrayLengthSources, closureAndDestroyIndices, foldedLengthIndices, foldOutParamShape, inputParameters, parameterIdentifier, } from "../../analysis/param-structure.js";
|
|
1
|
+
import { camelCase, sourceStringLiteral } from "@gtkx/utils";
|
|
2
|
+
import { renderCallbackType, renderDescriptor, renderSelfDescriptor, shouldOmitPrimaryReturn, } from "../../analysis/descriptor-render.js";
|
|
3
|
+
import { arrayLengthSources, closureAndDestroyIndices, emittedArgIndices, foldedLengthIndices, foldOutParamShape, inputParameters, parameterIdentifier, } from "../../analysis/param-structure.js";
|
|
4
4
|
import { renderTsType } from "../../analysis/ts-type.js";
|
|
5
5
|
import { isCallerAllocatedOut, isInoutParameter, isOutParameter } from "../../gir/parameter.js";
|
|
6
|
+
import { hasUnknownArrayLength } from "../../gir/type-id.js";
|
|
6
7
|
import { itemComparatorArgDescriptors, itemComparatorTsType } from "./item-comparators.js";
|
|
7
|
-
import { isCollectibleCallerOut,
|
|
8
|
-
|
|
8
|
+
import { isCollectibleCallerOut, isHandlePassedInPlace, isHandlePassing } from "./param-marshal.js";
|
|
9
|
+
const methodExportName = (fn) => camelCase(fn.name);
|
|
9
10
|
const arrayLengthArgument = (source, sourceIndex) => {
|
|
10
11
|
const identifier = parameterIdentifier(source, sourceIndex);
|
|
11
12
|
return source.nullable || source.optional ? `(${identifier}?.length ?? 0)` : `${identifier}.length`;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
const
|
|
14
|
+
const renderMethodSignature = (context, fn) => renderInputParameters(context, fn, () => false, () => false);
|
|
15
|
+
const parameterAnnotation = (context, fn, parameter) => itemComparatorTsType(context, fn, parameter) ?? renderTsType(context, parameter.type, parameter.nullable);
|
|
16
|
+
const isParameterOptional = (parameter, isOptionalExtra) => parameter.optional || isOptionalExtra(parameter);
|
|
17
|
+
const formatParameterPart = (name, annotation, isOptional) => isOptional ? `${name}?: ${annotation}` : `${name}: ${annotation}`;
|
|
18
|
+
const renderInputParameters = (context, fn, shouldSkip, isOptionalExtra) => {
|
|
15
19
|
const parts = [];
|
|
16
|
-
let
|
|
20
|
+
let isSawOptional = false;
|
|
17
21
|
for (const { parameter, index } of inputParameters(context.library, fn)) {
|
|
18
|
-
if (
|
|
22
|
+
if (shouldSkip(parameter)) {
|
|
19
23
|
continue;
|
|
24
|
+
}
|
|
20
25
|
const name = parameterIdentifier(parameter, index);
|
|
21
|
-
if (parameter
|
|
22
|
-
|
|
26
|
+
if (isParameterOptional(parameter, isOptionalExtra)) {
|
|
27
|
+
isSawOptional = true;
|
|
23
28
|
}
|
|
24
|
-
|
|
25
|
-
parts.push(sawOptional ? `${name}?: ${annotation}` : `${name}: ${annotation}`);
|
|
29
|
+
parts.push(formatParameterPart(name, parameterAnnotation(context, fn, parameter), isSawOptional));
|
|
26
30
|
}
|
|
27
31
|
return parts.join(", ");
|
|
28
32
|
};
|
|
29
|
-
|
|
33
|
+
const isReturnedOutParameter = (context, parameter) => isOutParameter(parameter) ||
|
|
34
|
+
(isCallerAllocatedOut(parameter) && isCollectibleCallerOut(context, parameter)) ||
|
|
35
|
+
isInoutParameter(parameter);
|
|
36
|
+
const renderMethodReturnType = (context, fn) => {
|
|
30
37
|
const folded = foldedLengthIndices(context.library, fn);
|
|
31
|
-
const outs = fn.parameters.filter((p, index) => (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const primaryReturnsValue = !omitsPrimaryReturn(context.library, fn.returnValue);
|
|
38
|
+
const outs = fn.parameters.filter((p, index) => isReturnedOutParameter(context, p) && !folded.has(index));
|
|
39
|
+
const primary = shouldOmitPrimaryReturn(context.library, fn.returnValue)
|
|
40
|
+
? undefined
|
|
41
|
+
: renderTsType(context, fn.returnValue.type, fn.returnValue.nullable);
|
|
36
42
|
if (outs.length === 0) {
|
|
37
|
-
return
|
|
43
|
+
return primary ?? "void";
|
|
38
44
|
}
|
|
39
|
-
const outTypes = outs.map((parameter) => renderTsType(context, parameter.type,
|
|
40
|
-
const primary = primaryReturnsValue
|
|
41
|
-
? renderTsType(context, fn.returnValue.type, fn.returnValue.nullable)
|
|
42
|
-
: undefined;
|
|
45
|
+
const outTypes = outs.map((parameter) => renderTsType(context, parameter.type, parameter.nullable));
|
|
43
46
|
return foldOutParamShape(primary, outTypes);
|
|
44
47
|
};
|
|
45
|
-
|
|
48
|
+
const classifyPromisifiedParameter = (promisify, parameter, index, state) => {
|
|
49
|
+
if (parameter.isVarargs) {
|
|
50
|
+
return { sawOptional: state.sawOptional, expression: undefined };
|
|
51
|
+
}
|
|
52
|
+
if (index === state.cancellableIndex) {
|
|
53
|
+
return { sawOptional: true, expression: undefined };
|
|
54
|
+
}
|
|
55
|
+
if (shouldSkipPromisifiedParameter(promisify, parameter, index)) {
|
|
56
|
+
return { sawOptional: state.sawOptional, expression: undefined };
|
|
57
|
+
}
|
|
58
|
+
const isSawOptional = state.sawOptional || parameter.optional;
|
|
59
|
+
return { sawOptional: isSawOptional, expression: promisifiedArgument(promisify, parameter, index, isSawOptional) };
|
|
60
|
+
};
|
|
61
|
+
const collectPromisifiedArguments = (promisify, cancellableIndex) => {
|
|
62
|
+
const expressions = [];
|
|
63
|
+
let isSawOptional = false;
|
|
64
|
+
for (const [index, parameter] of promisify.asyncFn.parameters.entries()) {
|
|
65
|
+
const step = classifyPromisifiedParameter(promisify, parameter, index, {
|
|
66
|
+
cancellableIndex,
|
|
67
|
+
sawOptional: isSawOptional,
|
|
68
|
+
});
|
|
69
|
+
isSawOptional = step.sawOptional;
|
|
70
|
+
if (step.expression !== undefined) {
|
|
71
|
+
expressions.push(step.expression);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return expressions;
|
|
75
|
+
};
|
|
76
|
+
const renderCancellableExpression = (parameters, cancellableIndex) => {
|
|
77
|
+
if (cancellableIndex < 0) {
|
|
78
|
+
return "null";
|
|
79
|
+
}
|
|
80
|
+
const parameter = parameters[cancellableIndex];
|
|
81
|
+
return parameter === undefined ? "null" : parameterIdentifier(parameter, cancellableIndex);
|
|
82
|
+
};
|
|
83
|
+
const renderPromisifiedBody = (context, asyncFn, finishExpression, bindingExpression) => {
|
|
46
84
|
context.addRuntimeImport("promisify");
|
|
47
85
|
const cancellableIndex = findCancellableIndex(context, asyncFn.parameters);
|
|
48
|
-
const
|
|
49
|
-
|
|
86
|
+
const promisifyContext = {
|
|
87
|
+
context,
|
|
88
|
+
asyncFn,
|
|
89
|
+
closureIndices: closureAndDestroyIndices(asyncFn),
|
|
90
|
+
lengthSources: arrayLengthSources(context.library, asyncFn),
|
|
91
|
+
};
|
|
50
92
|
const leadingExpressions = [];
|
|
51
93
|
if (asyncFn.instance !== undefined) {
|
|
52
94
|
context.addRuntimeImport("getHandle");
|
|
53
95
|
leadingExpressions.push("getHandle(this)");
|
|
54
96
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let sawOptional = false;
|
|
58
|
-
asyncFn.parameters.forEach((parameter, index) => {
|
|
59
|
-
if (parameter.isVarargs)
|
|
60
|
-
return;
|
|
61
|
-
if (index === cancellableIndex) {
|
|
62
|
-
cancellableExpression = parameterIdentifier(parameter, index);
|
|
63
|
-
sawOptional = true;
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (skipPromisifiedParameter(promisifyContext, parameter, index))
|
|
67
|
-
return;
|
|
68
|
-
if (parameter.optional)
|
|
69
|
-
sawOptional = true;
|
|
70
|
-
leadingExpressions.push(promisifiedArgument(promisifyContext, parameter, index, sawOptional));
|
|
71
|
-
});
|
|
97
|
+
leadingExpressions.push(...collectPromisifiedArguments(promisifyContext, cancellableIndex));
|
|
98
|
+
const cancellableExpression = renderCancellableExpression(asyncFn.parameters, cancellableIndex);
|
|
72
99
|
const leadingArguments = leadingExpressions.length > 0 ? `, ${leadingExpressions.join(", ")}` : "";
|
|
73
100
|
return `return promisify(${bindingExpression}, ${finishExpression}, ${cancellableExpression}${leadingArguments});`;
|
|
74
101
|
};
|
|
75
|
-
|
|
76
|
-
|
|
102
|
+
const finishCallExpression = (asyncFn, finishFn, ownerName) => asyncFn.instance !== undefined && finishFn.instance === undefined
|
|
103
|
+
? `${ownerName}.${methodExportName(finishFn)}.bind(${ownerName})`
|
|
104
|
+
: `this.${methodExportName(finishFn)}.bind(this)`;
|
|
105
|
+
const shouldSkipPromisifiedParameter = (promisify, parameter, index) => isCallbackParameter(promisify.context, parameter) ||
|
|
77
106
|
promisify.closureIndices.has(index) ||
|
|
78
107
|
(isOutParameter(parameter) && !isCallerAllocatedOut(parameter));
|
|
79
|
-
const promisifiedArgument = (promisify, parameter, index,
|
|
80
|
-
const { context, asyncFn,
|
|
81
|
-
const sourceIndex =
|
|
108
|
+
const promisifiedArgument = (promisify, parameter, index, hasSeenOptional) => {
|
|
109
|
+
const { context, asyncFn, lengthSources } = promisify;
|
|
110
|
+
const sourceIndex = lengthSources.get(index);
|
|
82
111
|
const source = sourceIndex === undefined ? undefined : asyncFn.parameters[sourceIndex];
|
|
83
|
-
if (sourceIndex !== undefined && source !== undefined)
|
|
112
|
+
if (sourceIndex !== undefined && source !== undefined) {
|
|
84
113
|
return arrayLengthArgument(source, sourceIndex);
|
|
85
|
-
return parameterCallExpression(context, parameter, index, sawOptional);
|
|
86
|
-
};
|
|
87
|
-
const findCancellableIndex = (context, parameters) => {
|
|
88
|
-
for (let index = 0; index < parameters.length; index += 1) {
|
|
89
|
-
const parameter = parameters[index];
|
|
90
|
-
if (parameter === undefined)
|
|
91
|
-
continue;
|
|
92
|
-
if (isCancellable(context, parameter))
|
|
93
|
-
return index;
|
|
94
114
|
}
|
|
95
|
-
return
|
|
115
|
+
return parameterCallExpression(context, parameter, index, hasSeenOptional);
|
|
96
116
|
};
|
|
97
|
-
|
|
117
|
+
const findCancellableIndex = (context, parameters) => parameters.findIndex((parameter) => isCancellable(context, parameter));
|
|
118
|
+
const renderPromisifiedSignature = (context, asyncFn, finishFn) => {
|
|
98
119
|
const signature = renderInputParameters(context, asyncFn, (parameter) => isCallbackParameter(context, parameter), (parameter) => isCancellable(context, parameter));
|
|
99
120
|
const finishReturn = renderMethodReturnType(context, finishFn);
|
|
100
121
|
return { signature, returnType: `Promise<${finishReturn}>` };
|
|
101
122
|
};
|
|
102
|
-
const isCancellable = (context, parameter) => parameter.type !== undefined && context.library.
|
|
123
|
+
const isCancellable = (context, parameter) => parameter.type !== undefined && context.library.nameFor(parameter.type)?.typeName === "Cancellable";
|
|
103
124
|
const isCallbackParameter = (context, parameter) => {
|
|
104
125
|
const ref = parameter.type;
|
|
105
|
-
if (ref === undefined)
|
|
126
|
+
if (ref === undefined) {
|
|
106
127
|
return false;
|
|
107
|
-
|
|
128
|
+
}
|
|
129
|
+
return context.library.typeFor(ref)?.kind === "callback";
|
|
108
130
|
};
|
|
109
|
-
|
|
131
|
+
const renderMethodBody = (context, fn, options) => {
|
|
110
132
|
const { bindingExpression, returnTypeOverride } = options;
|
|
111
133
|
const inputs = planCallArgs(context, fn)
|
|
112
134
|
.map((arg) => arg.inputExpr)
|
|
@@ -117,21 +139,25 @@ export const renderMethodBody = (context, fn, options) => {
|
|
|
117
139
|
};
|
|
118
140
|
const paramDescriptorLiteral = (descriptor, options) => {
|
|
119
141
|
const parts = [`type: ${descriptor}`];
|
|
120
|
-
if (options.direction !== undefined)
|
|
142
|
+
if (options.direction !== undefined) {
|
|
121
143
|
parts.push(`direction: ${sourceStringLiteral(options.direction)}`);
|
|
122
|
-
|
|
144
|
+
}
|
|
145
|
+
if (options.callerAllocated === true) {
|
|
123
146
|
parts.push("callerAllocated: true");
|
|
124
|
-
|
|
147
|
+
}
|
|
148
|
+
if (options.consumed === true) {
|
|
125
149
|
parts.push("consumed: true");
|
|
150
|
+
}
|
|
126
151
|
return `{ ${parts.join(", ")} }`;
|
|
127
152
|
};
|
|
128
|
-
|
|
153
|
+
const renderReturnDescriptor = (context, fn) => {
|
|
129
154
|
const instanceOffset = fn.instance === undefined ? 0 : 1;
|
|
130
155
|
return renderDescriptor(context, fn.returnValue.type, fn.returnValue.transferOwnership, {
|
|
131
156
|
argIndexOffset: instanceOffset,
|
|
157
|
+
argIndexMap: emittedArgIndices(fn, instanceOffset),
|
|
132
158
|
});
|
|
133
159
|
};
|
|
134
|
-
|
|
160
|
+
const planCallArgs = (context, fn) => {
|
|
135
161
|
const plan = [];
|
|
136
162
|
if (fn.instance !== undefined) {
|
|
137
163
|
context.addRuntimeImport("getHandle");
|
|
@@ -140,74 +166,87 @@ export const planCallArgs = (context, fn) => {
|
|
|
140
166
|
inputExpr: "getHandle(this)",
|
|
141
167
|
});
|
|
142
168
|
}
|
|
169
|
+
const instanceOffset = fn.instance === undefined ? 0 : 1;
|
|
143
170
|
const planContext = {
|
|
144
171
|
fn,
|
|
145
|
-
instanceOffset
|
|
146
|
-
|
|
172
|
+
instanceOffset,
|
|
173
|
+
argIndex: { argIndexOffset: instanceOffset, argIndexMap: emittedArgIndices(fn, instanceOffset) },
|
|
174
|
+
lengthSources: arrayLengthSources(context.library, fn),
|
|
147
175
|
closureIndices: closureAndDestroyIndices(fn),
|
|
148
176
|
folded: foldedLengthIndices(context.library, fn),
|
|
149
177
|
};
|
|
150
178
|
for (const [index, parameter] of fn.parameters.entries()) {
|
|
151
179
|
const entry = planParameter(context, parameter, index, planContext);
|
|
152
|
-
if (entry !== undefined)
|
|
180
|
+
if (entry !== undefined) {
|
|
153
181
|
plan.push(entry);
|
|
182
|
+
}
|
|
154
183
|
}
|
|
155
184
|
return plan;
|
|
156
185
|
};
|
|
186
|
+
const isSkippedPlanParameter = (parameter, index, closureIndices) => parameter.isVarargs || closureIndices.has(index);
|
|
157
187
|
const planParameter = (context, parameter, index, planContext) => {
|
|
158
|
-
const {
|
|
159
|
-
if (parameter
|
|
188
|
+
const { folded, closureIndices, lengthSources } = planContext;
|
|
189
|
+
if (isSkippedPlanParameter(parameter, index, closureIndices)) {
|
|
160
190
|
return undefined;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (
|
|
191
|
+
}
|
|
192
|
+
if (isOutParameter(parameter)) {
|
|
193
|
+
return planOutParam(context, parameter, planContext.argIndex, folded.has(index));
|
|
194
|
+
}
|
|
195
|
+
if (isCallerAllocatedOut(parameter)) {
|
|
196
|
+
return planCallerOut(context, parameter, planContext.argIndex);
|
|
197
|
+
}
|
|
198
|
+
if (isInoutParameter(parameter)) {
|
|
166
199
|
return planInoutArgument(context, parameter, index, planContext);
|
|
167
|
-
|
|
168
|
-
|
|
200
|
+
}
|
|
201
|
+
const sourceIndex = lengthSources.get(index);
|
|
202
|
+
if (sourceIndex !== undefined) {
|
|
169
203
|
return planLengthArgument(context, parameter, sourceIndex, planContext);
|
|
204
|
+
}
|
|
170
205
|
return planInParam(context, parameter, index, planContext);
|
|
171
206
|
};
|
|
172
207
|
const planInoutArgument = (context, parameter, index, planContext) => {
|
|
173
|
-
const { fn,
|
|
174
|
-
const lengthSourceIndex =
|
|
208
|
+
const { fn, folded, lengthSources } = planContext;
|
|
209
|
+
const lengthSourceIndex = lengthSources.get(index);
|
|
175
210
|
const lengthSourceParam = lengthSourceIndex === undefined ? undefined : fn.parameters[lengthSourceIndex];
|
|
176
211
|
const lengthSource = lengthSourceIndex !== undefined && lengthSourceParam !== undefined
|
|
177
212
|
? { source: lengthSourceParam, index: lengthSourceIndex }
|
|
178
213
|
: undefined;
|
|
179
|
-
return planInoutParam(context, parameter, {
|
|
214
|
+
return planInoutParam(context, parameter, {
|
|
215
|
+
index,
|
|
216
|
+
argIndex: planContext.argIndex,
|
|
217
|
+
consumed: folded.has(index),
|
|
218
|
+
lengthSource,
|
|
219
|
+
});
|
|
180
220
|
};
|
|
181
221
|
const planLengthArgument = (context, parameter, sourceIndex, planContext) => {
|
|
182
222
|
const source = planContext.fn.parameters[sourceIndex];
|
|
183
|
-
const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership,
|
|
184
|
-
argIndexOffset: planContext.instanceOffset,
|
|
185
|
-
});
|
|
223
|
+
const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, planContext.argIndex);
|
|
186
224
|
return {
|
|
187
225
|
paramLiteral: paramDescriptorLiteral(descriptor, {}),
|
|
188
226
|
inputExpr: source === undefined ? "0" : arrayLengthArgument(source, sourceIndex),
|
|
189
227
|
};
|
|
190
228
|
};
|
|
191
|
-
const planOutParam = (context, parameter,
|
|
192
|
-
const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
229
|
+
const planOutParam = (context, parameter, argIndex, isConsumed) => {
|
|
230
|
+
const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, argIndex);
|
|
231
|
+
return {
|
|
232
|
+
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "out", consumed: isConsumed }),
|
|
233
|
+
inputExpr: undefined,
|
|
234
|
+
};
|
|
196
235
|
};
|
|
197
236
|
const constructibleName = (context, ref) => {
|
|
198
237
|
let current = ref;
|
|
199
238
|
while (current !== undefined) {
|
|
200
|
-
const resolved = context.library.
|
|
239
|
+
const resolved = context.library.typeFor(current);
|
|
201
240
|
if (resolved?.kind === "alias" && resolved.value.target !== undefined) {
|
|
202
241
|
current = resolved.value.target;
|
|
203
242
|
continue;
|
|
204
243
|
}
|
|
205
|
-
return context.library.
|
|
244
|
+
return context.library.nameFor(current);
|
|
206
245
|
}
|
|
207
246
|
return undefined;
|
|
208
247
|
};
|
|
209
|
-
const planCallerOut = (context, parameter,
|
|
210
|
-
const descriptor = renderDescriptor(context, parameter.type, "none",
|
|
248
|
+
const planCallerOut = (context, parameter, argIndex) => {
|
|
249
|
+
const descriptor = renderDescriptor(context, parameter.type, "none", argIndex);
|
|
211
250
|
const name = constructibleName(context, parameter.type);
|
|
212
251
|
if (name !== undefined && isCollectibleCallerOut(context, parameter)) {
|
|
213
252
|
context.addRuntimeImport("getHandle");
|
|
@@ -220,60 +259,78 @@ const planCallerOut = (context, parameter, instanceOffset) => {
|
|
|
220
259
|
return { paramLiteral: paramDescriptorLiteral(descriptor, {}), inputExpr: "undefined" };
|
|
221
260
|
};
|
|
222
261
|
const planInoutParam = (context, parameter, options) => {
|
|
223
|
-
const { index,
|
|
224
|
-
if (
|
|
225
|
-
const descriptor = renderDescriptor(context, parameter.type, "none",
|
|
262
|
+
const { index, argIndex, consumed, lengthSource } = options;
|
|
263
|
+
if (isHandlePassedInPlace(context, parameter)) {
|
|
264
|
+
const descriptor = renderDescriptor(context, parameter.type, "none", argIndex);
|
|
226
265
|
return {
|
|
227
266
|
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "inout", callerAllocated: true, consumed }),
|
|
228
267
|
inputExpr: parameterIdentifier(parameter, index),
|
|
229
268
|
};
|
|
230
269
|
}
|
|
231
|
-
const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership,
|
|
232
|
-
argIndexOffset: instanceOffset,
|
|
233
|
-
});
|
|
270
|
+
const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, argIndex);
|
|
234
271
|
return {
|
|
235
272
|
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "inout", consumed }),
|
|
236
|
-
inputExpr: lengthSource
|
|
237
|
-
?
|
|
238
|
-
:
|
|
273
|
+
inputExpr: lengthSource === undefined
|
|
274
|
+
? parameterCallExpression(context, parameter, index)
|
|
275
|
+
: arrayLengthArgument(lengthSource.source, lengthSource.index),
|
|
239
276
|
};
|
|
240
277
|
};
|
|
241
278
|
const planInParam = (context, parameter, index, planContext) => {
|
|
242
|
-
const { fn
|
|
279
|
+
const { fn } = planContext;
|
|
243
280
|
const callback = renderCallbackType(context, parameter.type, parameter, itemComparatorArgDescriptors(context, fn, parameter));
|
|
244
281
|
const descriptor = callback ??
|
|
245
|
-
renderDescriptor(context, parameter.type, parameter.transferOwnership,
|
|
282
|
+
renderDescriptor(context, parameter.type, parameter.transferOwnership, planContext.argIndex);
|
|
246
283
|
return {
|
|
247
284
|
paramLiteral: paramDescriptorLiteral(descriptor, {}),
|
|
248
285
|
inputExpr: parameterCallExpression(context, parameter, index),
|
|
249
286
|
};
|
|
250
287
|
};
|
|
251
|
-
const
|
|
288
|
+
const handleArgument = (context, name, isNullable) => {
|
|
289
|
+
if (isNullable) {
|
|
290
|
+
context.addRuntimeImport("tryGetHandle");
|
|
291
|
+
return `tryGetHandle(${name})`;
|
|
292
|
+
}
|
|
293
|
+
context.addRuntimeImport("getHandle");
|
|
294
|
+
return `getHandle(${name})`;
|
|
295
|
+
};
|
|
296
|
+
const hashtableArgument = (context, valueRef, name) => {
|
|
297
|
+
if (isHandlePassing(context, valueRef)) {
|
|
298
|
+
context.addRuntimeImport("tryGetHandle");
|
|
299
|
+
return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, tryGetHandle(v)]) : null`;
|
|
300
|
+
}
|
|
301
|
+
return `${name} ? globalThis.Array.from(${name}) : null`;
|
|
302
|
+
};
|
|
303
|
+
const mapHandleExpression = (name, isNullable) => isNullable ? `${name}?.map((item) => getHandle(item))` : `${name}.map((item) => getHandle(item))`;
|
|
304
|
+
const collectionArgument = (context, type, name, isNullable) => {
|
|
305
|
+
if (type?.kind === "hashtable") {
|
|
306
|
+
return hashtableArgument(context, type.value, name);
|
|
307
|
+
}
|
|
308
|
+
if (!isMappableSequence(context, type)) {
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
context.addRuntimeImport("getHandle");
|
|
312
|
+
return mapHandleExpression(name, isNullable);
|
|
313
|
+
};
|
|
314
|
+
// An array whose length nothing states is marshalled as the bare pointer it is, so there is nothing
|
|
315
|
+
// to map over.
|
|
316
|
+
const isMappableSequence = (context, type) => {
|
|
317
|
+
if (type?.kind === "carray") {
|
|
318
|
+
return !hasUnknownArrayLength(type) && isHandlePassing(context, type.element);
|
|
319
|
+
}
|
|
320
|
+
return type?.kind === "list" && isHandlePassing(context, type.element);
|
|
321
|
+
};
|
|
322
|
+
const parameterCallExpression = (context, parameter, index, isForcedNullable = false) => {
|
|
252
323
|
const name = parameterIdentifier(parameter, index);
|
|
253
324
|
const ref = parameter.type;
|
|
254
|
-
if (ref === undefined)
|
|
325
|
+
if (ref === undefined) {
|
|
255
326
|
return name;
|
|
256
|
-
const nullable = parameter.nullable || parameter.optional || forceNullable;
|
|
257
|
-
if (isHandlePassing(context, ref)) {
|
|
258
|
-
if (nullable) {
|
|
259
|
-
context.addRuntimeImport("tryGetHandle");
|
|
260
|
-
return `tryGetHandle(${name})`;
|
|
261
|
-
}
|
|
262
|
-
context.addRuntimeImport("getHandle");
|
|
263
|
-
return `getHandle(${name})`;
|
|
264
|
-
}
|
|
265
|
-
const type = context.library.typeOf(ref);
|
|
266
|
-
if ((type?.kind === "carray" || type?.kind === "list") && isHandlePassing(context, type.element)) {
|
|
267
|
-
context.addRuntimeImport("getHandle");
|
|
268
|
-
return nullable ? `${name}?.map((item) => getHandle(item))` : `${name}.map((item) => getHandle(item))`;
|
|
269
327
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, tryGetHandle(v)]) : null`;
|
|
274
|
-
}
|
|
275
|
-
return `${name} ? globalThis.Array.from(${name}) : null`;
|
|
328
|
+
const isNullable = parameter.nullable || parameter.optional || isForcedNullable;
|
|
329
|
+
if (isHandlePassing(context, ref)) {
|
|
330
|
+
return handleArgument(context, name, isNullable);
|
|
276
331
|
}
|
|
277
|
-
|
|
332
|
+
const type = context.library.typeFor(ref);
|
|
333
|
+
return collectionArgument(context, type, name, isNullable) ?? name;
|
|
278
334
|
};
|
|
335
|
+
export { methodExportName, renderMethodSignature, renderMethodReturnType, renderPromisifiedBody, finishCallExpression, renderPromisifiedSignature, renderMethodBody, renderReturnDescriptor, planCallArgs, };
|
|
279
336
|
//# sourceMappingURL=method.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/store/gi/method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EACH,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf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C,CAAC,GAAG,IAAI,kCAAkC,CAAC,CAAC,CAAC,GAAG,IAAI,iCAAiC,CAAC;IAC3G,CAAC;IACD,IAAI,IAAI,EAAE,IAAI,KAAK,WAAW,EAAE,CAAC;QAC7B,IAAI,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACvC,OAAO,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;YACzC,OAAO,GAAG,IAAI,4BAA4B,IAAI,gDAAgD,CAAC;QACnG,CAAC;QACD,OAAO,GAAG,IAAI,4BAA4B,IAAI,UAAU,CAAC;IAC7D,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { sourceStringLiteral, toCamelCase } from \"@gtkx/utils\";\nimport {\n omitsPrimaryReturn,\n renderCallbackType,\n renderDescriptor,\n renderSelfDescriptor,\n} from \"../../analysis/descriptor-render.js\";\nimport {\n arrayLengthSources,\n closureAndDestroyIndices,\n foldedLengthIndices,\n foldOutParamShape,\n inputParameters,\n parameterIdentifier,\n} from \"../../analysis/param-structure.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport { type GirParameter, isCallerAllocatedOut, isInoutParameter, isOutParameter } from \"../../gir/parameter.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { itemComparatorArgDescriptors, itemComparatorTsType } from \"./item-comparators.js\";\nimport { isCollectibleCallerOut, isHandlePassing, passesHandleInPlace } from \"./param-marshal.js\";\n\nexport const methodExportName = (fn: GirFunction): string => toCamelCase(fn.name);\n\nconst arrayLengthArgument = (source: GirParameter, sourceIndex: number): string => {\n const identifier = parameterIdentifier(source, sourceIndex);\n return source.nullable || source.optional ? `(${identifier}?.length ?? 0)` : `${identifier}.length`;\n};\n\nexport const renderMethodSignature = (context: ModuleContext, fn: GirFunction): string =>\n renderInputParameters(\n context,\n fn,\n () => false,\n () => false,\n );\n\nconst renderInputParameters = (\n context: ModuleContext,\n fn: GirFunction,\n skip: (parameter: GirParameter) => boolean,\n isOptionalExtra: (parameter: GirParameter) => boolean,\n): string => {\n const parts: string[] = [];\n let sawOptional = false;\n for (const { parameter, index } of inputParameters(context.library, fn)) {\n if (skip(parameter)) continue;\n const name = parameterIdentifier(parameter, index);\n if (parameter.optional || isOptionalExtra(parameter)) {\n sawOptional = true;\n }\n const annotation =\n itemComparatorTsType(context, fn, parameter) ?? renderTsType(context, parameter.type, parameter.nullable);\n parts.push(sawOptional ? `${name}?: ${annotation}` : `${name}: ${annotation}`);\n }\n return parts.join(\", \");\n};\n\nexport const renderMethodReturnType = (context: ModuleContext, fn: GirFunction): string => {\n const folded = foldedLengthIndices(context.library, fn);\n const outs = fn.parameters.filter(\n (p, index) =>\n (isOutParameter(p) ||\n (isCallerAllocatedOut(p) && isCollectibleCallerOut(context, p)) ||\n isInoutParameter(p)) &&\n !folded.has(index),\n );\n const primaryReturnsValue = !omitsPrimaryReturn(context.library, fn.returnValue);\n if (outs.length === 0) {\n return primaryReturnsValue ? renderTsType(context, fn.returnValue.type, fn.returnValue.nullable) : \"void\";\n }\n const outTypes = outs.map((parameter) => renderTsType(context, parameter.type, false));\n const primary = primaryReturnsValue\n ? renderTsType(context, fn.returnValue.type, fn.returnValue.nullable)\n : undefined;\n return foldOutParamShape(primary, outTypes);\n};\n\nexport const renderPromisifiedBody = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishExpression: string,\n bindingExpression: string,\n): string => {\n context.addRuntimeImport(\"promisify\");\n const cancellableIndex = findCancellableIndex(context, asyncFn.parameters);\n const closureIndices = closureAndDestroyIndices(asyncFn);\n const lengthFor = arrayLengthSources(context.library, asyncFn);\n const leadingExpressions: string[] = [];\n if (asyncFn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n leadingExpressions.push(\"getHandle(this)\");\n }\n const promisifyContext: PromisifyContext = { context, asyncFn, closureIndices, lengthFor };\n let cancellableExpression = \"null\";\n let sawOptional = false;\n asyncFn.parameters.forEach((parameter, index) => {\n if (parameter.isVarargs) return;\n if (index === cancellableIndex) {\n cancellableExpression = parameterIdentifier(parameter, index);\n sawOptional = true;\n return;\n }\n if (skipPromisifiedParameter(promisifyContext, parameter, index)) return;\n if (parameter.optional) sawOptional = true;\n leadingExpressions.push(promisifiedArgument(promisifyContext, parameter, index, sawOptional));\n });\n const leadingArguments = leadingExpressions.length > 0 ? `, ${leadingExpressions.join(\", \")}` : \"\";\n return `return promisify(${bindingExpression}, ${finishExpression}, ${cancellableExpression}${leadingArguments});`;\n};\n\nexport const boundFinishExpression = (finishFn: GirFunction): string => `this.${methodExportName(finishFn)}.bind(this)`;\n\ntype PromisifyContext = {\n context: ModuleContext;\n asyncFn: GirFunction;\n closureIndices: Set<number>;\n lengthFor: Map<number, number>;\n};\n\nconst skipPromisifiedParameter = (promisify: PromisifyContext, parameter: GirParameter, index: number): boolean =>\n isCallbackParameter(promisify.context, parameter) ||\n promisify.closureIndices.has(index) ||\n (isOutParameter(parameter) && !isCallerAllocatedOut(parameter));\n\nconst promisifiedArgument = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n sawOptional: boolean,\n): string => {\n const { context, asyncFn, lengthFor } = promisify;\n const sourceIndex = lengthFor.get(index);\n const source = sourceIndex === undefined ? undefined : asyncFn.parameters[sourceIndex];\n if (sourceIndex !== undefined && source !== undefined) return arrayLengthArgument(source, sourceIndex);\n return parameterCallExpression(context, parameter, index, sawOptional);\n};\n\nconst findCancellableIndex = (context: ModuleContext, parameters: GirParameter[]): number => {\n for (let index = 0; index < parameters.length; index += 1) {\n const parameter = parameters[index];\n if (parameter === undefined) continue;\n if (isCancellable(context, parameter)) return index;\n }\n return -1;\n};\n\nexport const renderPromisifiedSignature = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishFn: GirFunction,\n): { signature: string; returnType: string } => {\n const signature = renderInputParameters(\n context,\n asyncFn,\n (parameter) => isCallbackParameter(context, parameter),\n (parameter) => isCancellable(context, parameter),\n );\n const finishReturn = renderMethodReturnType(context, finishFn);\n return { signature, returnType: `Promise<${finishReturn}>` };\n};\n\nconst isCancellable = (context: ModuleContext, parameter: GirParameter): boolean =>\n parameter.type !== undefined && context.library.nameOf(parameter.type)?.typeName === \"Cancellable\";\n\nconst isCallbackParameter = (context: ModuleContext, parameter: GirParameter): boolean => {\n const ref = parameter.type;\n if (ref === undefined) return false;\n return context.library.typeOf(ref)?.kind === \"callback\";\n};\n\ntype WriteMethodBodyOptions = {\n bindingExpression: string;\n returnTypeOverride?: string | undefined;\n};\n\nexport const renderMethodBody = (context: ModuleContext, fn: GirFunction, options: WriteMethodBodyOptions): string => {\n const { bindingExpression, returnTypeOverride } = options;\n const inputs = planCallArgs(context, fn)\n .map((arg) => arg.inputExpr)\n .filter((expression): expression is string => expression !== undefined);\n const callExpression = `${bindingExpression}(${inputs.join(\", \")})`;\n const annotation = returnTypeOverride ?? renderMethodReturnType(context, fn);\n return annotation === \"void\" ? `${callExpression};` : `return ${callExpression} as ${annotation};`;\n};\n\ntype CallArgPlan = {\n paramLiteral: string;\n inputExpr: string | undefined;\n};\n\ntype ParamDescriptorOptions = {\n direction?: \"out\" | \"inout\";\n callerAllocated?: boolean;\n consumed?: boolean;\n};\n\nconst paramDescriptorLiteral = (descriptor: string, options: ParamDescriptorOptions): string => {\n const parts = [`type: ${descriptor}`];\n if (options.direction !== undefined) parts.push(`direction: ${sourceStringLiteral(options.direction)}`);\n if (options.callerAllocated === true) parts.push(\"callerAllocated: true\");\n if (options.consumed === true) parts.push(\"consumed: true\");\n return `{ ${parts.join(\", \")} }`;\n};\n\nexport const renderReturnDescriptor = (context: ModuleContext, fn: GirFunction): string => {\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n return renderDescriptor(context, fn.returnValue.type, fn.returnValue.transferOwnership, {\n argIndexOffset: instanceOffset,\n });\n};\n\nexport const planCallArgs = (context: ModuleContext, fn: GirFunction): CallArgPlan[] => {\n const plan: CallArgPlan[] = [];\n if (fn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n plan.push({\n paramLiteral: `{ type: ${renderSelfDescriptor(context, fn.instance)} }`,\n inputExpr: \"getHandle(this)\",\n });\n }\n const planContext: PlanArgsContext = {\n fn,\n instanceOffset: fn.instance === undefined ? 0 : 1,\n lengthFor: arrayLengthSources(context.library, fn),\n closureIndices: closureAndDestroyIndices(fn),\n folded: foldedLengthIndices(context.library, fn),\n };\n for (const [index, parameter] of fn.parameters.entries()) {\n const entry = planParameter(context, parameter, index, planContext);\n if (entry !== undefined) plan.push(entry);\n }\n return plan;\n};\n\ntype PlanArgsContext = {\n fn: GirFunction;\n instanceOffset: number;\n lengthFor: Map<number, number>;\n closureIndices: Set<number>;\n folded: Set<number>;\n};\n\nconst planParameter = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan | undefined => {\n const { instanceOffset, folded, closureIndices, lengthFor } = planContext;\n if (parameter.isVarargs || closureIndices.has(index)) return undefined;\n if (isOutParameter(parameter)) return planOutParam(context, parameter, instanceOffset, folded.has(index));\n if (isCallerAllocatedOut(parameter)) return planCallerOut(context, parameter, instanceOffset);\n if (isInoutParameter(parameter)) return planInoutArgument(context, parameter, index, planContext);\n const sourceIndex = lengthFor.get(index);\n if (sourceIndex !== undefined) return planLengthArgument(context, parameter, sourceIndex, planContext);\n return planInParam(context, parameter, index, planContext);\n};\n\nconst planInoutArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn, instanceOffset, folded, lengthFor } = planContext;\n const lengthSourceIndex = lengthFor.get(index);\n const lengthSourceParam = lengthSourceIndex === undefined ? undefined : fn.parameters[lengthSourceIndex];\n const lengthSource =\n lengthSourceIndex !== undefined && lengthSourceParam !== undefined\n ? { source: lengthSourceParam, index: lengthSourceIndex }\n : undefined;\n return planInoutParam(context, parameter, { index, instanceOffset, consumed: folded.has(index), lengthSource });\n};\n\nconst planLengthArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n sourceIndex: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const source = planContext.fn.parameters[sourceIndex];\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n argIndexOffset: planContext.instanceOffset,\n });\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: source === undefined ? \"0\" : arrayLengthArgument(source, sourceIndex),\n };\n};\n\nconst planOutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n instanceOffset: number,\n consumed: boolean,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n argIndexOffset: instanceOffset,\n });\n return { paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", consumed }), inputExpr: undefined };\n};\n\nconst constructibleName = (\n context: ModuleContext,\n ref: GirParameter[\"type\"],\n): { namespaceName: string; typeName: string } | undefined => {\n let current = ref;\n while (current !== undefined) {\n const resolved = context.library.typeOf(current);\n if (resolved?.kind === \"alias\" && resolved.value.target !== undefined) {\n current = resolved.value.target;\n continue;\n }\n return context.library.nameOf(current);\n }\n return undefined;\n};\n\nconst planCallerOut = (context: ModuleContext, parameter: GirParameter, instanceOffset: number): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", { argIndexOffset: instanceOffset });\n const name = constructibleName(context, parameter.type);\n if (name !== undefined && isCollectibleCallerOut(context, parameter)) {\n context.addRuntimeImport(\"getHandle\");\n const classExpression = context.qualify(name.namespaceName, name.typeName);\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", callerAllocated: true }),\n inputExpr: `new ${classExpression}()`,\n };\n }\n return { paramLiteral: paramDescriptorLiteral(descriptor, {}), inputExpr: \"undefined\" };\n};\n\nconst planInoutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n options: {\n index: number;\n instanceOffset: number;\n consumed: boolean;\n lengthSource?: { source: GirParameter; index: number } | undefined;\n },\n): CallArgPlan => {\n const { index, instanceOffset, consumed, lengthSource } = options;\n if (passesHandleInPlace(context, parameter)) {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", { argIndexOffset: instanceOffset });\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"inout\", callerAllocated: true, consumed }),\n inputExpr: parameterIdentifier(parameter, index),\n };\n }\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n argIndexOffset: instanceOffset,\n });\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"inout\", consumed }),\n inputExpr:\n lengthSource !== undefined\n ? arrayLengthArgument(lengthSource.source, lengthSource.index)\n : parameterCallExpression(context, parameter, index),\n };\n};\n\nconst planInParam = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn, instanceOffset } = planContext;\n const callback = renderCallbackType(\n context,\n parameter.type,\n parameter,\n itemComparatorArgDescriptors(context, fn, parameter),\n );\n const descriptor =\n callback ??\n renderDescriptor(context, parameter.type, parameter.transferOwnership, { argIndexOffset: instanceOffset });\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: parameterCallExpression(context, parameter, index),\n };\n};\n\nconst parameterCallExpression = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n forceNullable = false,\n): string => {\n const name = parameterIdentifier(parameter, index);\n const ref = parameter.type;\n if (ref === undefined) return name;\n const nullable = parameter.nullable || parameter.optional || forceNullable;\n if (isHandlePassing(context, ref)) {\n if (nullable) {\n context.addRuntimeImport(\"tryGetHandle\");\n return `tryGetHandle(${name})`;\n }\n context.addRuntimeImport(\"getHandle\");\n return `getHandle(${name})`;\n }\n const type = context.library.typeOf(ref);\n if ((type?.kind === \"carray\" || type?.kind === \"list\") && isHandlePassing(context, type.element)) {\n context.addRuntimeImport(\"getHandle\");\n return nullable ? `${name}?.map((item) => getHandle(item))` : `${name}.map((item) => getHandle(item))`;\n }\n if (type?.kind === \"hashtable\") {\n if (isHandlePassing(context, type.value)) {\n context.addRuntimeImport(\"tryGetHandle\");\n return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, tryGetHandle(v)]) : null`;\n }\n return `${name} ? globalThis.Array.from(${name}) : null`;\n }\n return name;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/store/gi/method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAI7D,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,GAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAqB,oBAAoB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACnH,OAAO,EAAE,qBAAqB,EAAe,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAyCpG,MAAM,gBAAgB,GAAG,CAAC,EAAe,EAAU,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAEzE,MAAM,mBAAmB,GAAG,CAAC,MAAoB,EAAE,WAAmB,EAAU,EAAE;IAC9E,MAAM,UAAU,GAAG,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAE5D,OAAO,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,UAAU,gBAAgB,CAAC,CAAC,CAAC,GAAG,UAAU,S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,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC;AACvE,CAAC,CAAC;AAEF,OAAO,EACH,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,GACf,CAAC","sourcesContent":["import { camelCase, sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { GirType } from \"../../gir/type.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport {\n renderCallbackType,\n renderDescriptor,\n renderSelfDescriptor,\n shouldOmitPrimaryReturn,\n} from \"../../analysis/descriptor-render.js\";\nimport {\n arrayLengthSources,\n closureAndDestroyIndices,\n emittedArgIndices,\n foldedLengthIndices,\n foldOutParamShape,\n inputParameters,\n parameterIdentifier,\n} from \"../../analysis/param-structure.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { type GirParameter, isCallerAllocatedOut, isInoutParameter, isOutParameter } from \"../../gir/parameter.js\";\nimport { hasUnknownArrayLength, type TypeId } from \"../../gir/type-id.js\";\nimport { itemComparatorArgDescriptors, itemComparatorTsType } from \"./item-comparators.js\";\nimport { isCollectibleCallerOut, isHandlePassedInPlace, isHandlePassing } from \"./param-marshal.js\";\n\ntype PromisifiedStep = { sawOptional: boolean; expression: string | undefined };\n\ntype PromisifyContext = {\n context: ModuleContext;\n asyncFn: GirFunction;\n closureIndices: Set<number>;\n lengthSources: Map<number, number>;\n};\n\ntype WriteMethodBodyOptions = {\n bindingExpression: string;\n returnTypeOverride?: string | undefined;\n};\n\ntype CallArgPlan = {\n paramLiteral: string;\n inputExpr: string | undefined;\n};\n\ntype ParamDescriptorOptions = {\n direction?: \"out\" | \"inout\";\n callerAllocated?: boolean;\n consumed?: boolean;\n};\n\ntype ArgIndexOptions = {\n argIndexOffset: number;\n argIndexMap: Map<number, number>;\n};\n\ntype PlanArgsContext = {\n fn: GirFunction;\n instanceOffset: number;\n argIndex: ArgIndexOptions;\n lengthSources: Map<number, number>;\n closureIndices: Set<number>;\n folded: Set<number>;\n};\n\nconst methodExportName = (fn: GirFunction): string => camelCase(fn.name);\n\nconst arrayLengthArgument = (source: GirParameter, sourceIndex: number): string => {\n const identifier = parameterIdentifier(source, sourceIndex);\n\n return source.nullable || source.optional ? `(${identifier}?.length ?? 0)` : `${identifier}.length`;\n};\n\nconst renderMethodSignature = (context: ModuleContext, fn: GirFunction): string =>\n renderInputParameters(\n context,\n fn,\n () => false,\n () => false,\n );\n\nconst parameterAnnotation = (context: ModuleContext, fn: GirFunction, parameter: GirParameter): string =>\n itemComparatorTsType(context, fn, parameter) ?? renderTsType(context, parameter.type, parameter.nullable);\n\nconst isParameterOptional = (parameter: GirParameter, isOptionalExtra: (parameter: GirParameter) => boolean): boolean =>\n parameter.optional || isOptionalExtra(parameter);\n\nconst formatParameterPart = (name: string, annotation: string, isOptional: boolean): string =>\n isOptional ? `${name}?: ${annotation}` : `${name}: ${annotation}`;\n\nconst renderInputParameters = (\n context: ModuleContext,\n fn: GirFunction,\n shouldSkip: (parameter: GirParameter) => boolean,\n isOptionalExtra: (parameter: GirParameter) => boolean,\n): string => {\n const parts: string[] = [];\n let isSawOptional = false;\n\n for (const { parameter, index } of inputParameters(context.library, fn)) {\n if (shouldSkip(parameter)) {\n continue;\n }\n\n const name = parameterIdentifier(parameter, index);\n\n if (isParameterOptional(parameter, isOptionalExtra)) {\n isSawOptional = true;\n }\n\n parts.push(formatParameterPart(name, parameterAnnotation(context, fn, parameter), isSawOptional));\n }\n\n return parts.join(\", \");\n};\n\nconst isReturnedOutParameter = (context: ModuleContext, parameter: GirParameter): boolean =>\n isOutParameter(parameter) ||\n (isCallerAllocatedOut(parameter) && isCollectibleCallerOut(context, parameter)) ||\n isInoutParameter(parameter);\n\nconst renderMethodReturnType = (context: ModuleContext, fn: GirFunction): string => {\n const folded = foldedLengthIndices(context.library, fn);\n const outs = fn.parameters.filter((p, index) => isReturnedOutParameter(context, p) && !folded.has(index));\n\n const primary = shouldOmitPrimaryReturn(context.library, fn.returnValue)\n ? undefined\n : renderTsType(context, fn.returnValue.type, fn.returnValue.nullable);\n\n if (outs.length === 0) {\n return primary ?? \"void\";\n }\n\n const outTypes = outs.map((parameter) => renderTsType(context, parameter.type, parameter.nullable));\n\n return foldOutParamShape(primary, outTypes);\n};\n\nconst classifyPromisifiedParameter = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n state: { cancellableIndex: number; sawOptional: boolean },\n): PromisifiedStep => {\n if (parameter.isVarargs) {\n return { sawOptional: state.sawOptional, expression: undefined };\n }\n\n if (index === state.cancellableIndex) {\n return { sawOptional: true, expression: undefined };\n }\n\n if (shouldSkipPromisifiedParameter(promisify, parameter, index)) {\n return { sawOptional: state.sawOptional, expression: undefined };\n }\n\n const isSawOptional = state.sawOptional || parameter.optional;\n\n return { sawOptional: isSawOptional, expression: promisifiedArgument(promisify, parameter, index, isSawOptional) };\n};\n\nconst collectPromisifiedArguments = (promisify: PromisifyContext, cancellableIndex: number): string[] => {\n const expressions: string[] = [];\n let isSawOptional = false;\n\n for (const [index, parameter] of promisify.asyncFn.parameters.entries()) {\n const step = classifyPromisifiedParameter(promisify, parameter, index, {\n cancellableIndex,\n sawOptional: isSawOptional,\n });\n\n isSawOptional = step.sawOptional;\n\n if (step.expression !== undefined) {\n expressions.push(step.expression);\n }\n }\n\n return expressions;\n};\n\nconst renderCancellableExpression = (parameters: GirParameter[], cancellableIndex: number): string => {\n if (cancellableIndex < 0) {\n return \"null\";\n }\n\n const parameter = parameters[cancellableIndex];\n\n return parameter === undefined ? \"null\" : parameterIdentifier(parameter, cancellableIndex);\n};\n\nconst renderPromisifiedBody = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishExpression: string,\n bindingExpression: string,\n): string => {\n context.addRuntimeImport(\"promisify\");\n const cancellableIndex = findCancellableIndex(context, asyncFn.parameters);\n\n const promisifyContext: PromisifyContext = {\n context,\n asyncFn,\n closureIndices: closureAndDestroyIndices(asyncFn),\n lengthSources: arrayLengthSources(context.library, asyncFn),\n };\n\n const leadingExpressions: string[] = [];\n\n if (asyncFn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n leadingExpressions.push(\"getHandle(this)\");\n }\n\n leadingExpressions.push(...collectPromisifiedArguments(promisifyContext, cancellableIndex));\n const cancellableExpression = renderCancellableExpression(asyncFn.parameters, cancellableIndex);\n const leadingArguments = leadingExpressions.length > 0 ? `, ${leadingExpressions.join(\", \")}` : \"\";\n\n return `return promisify(${bindingExpression}, ${finishExpression}, ${cancellableExpression}${leadingArguments});`;\n};\n\nconst finishCallExpression = (asyncFn: GirFunction, finishFn: GirFunction, ownerName: string): string =>\n asyncFn.instance !== undefined && finishFn.instance === undefined\n ? `${ownerName}.${methodExportName(finishFn)}.bind(${ownerName})`\n : `this.${methodExportName(finishFn)}.bind(this)`;\n\nconst shouldSkipPromisifiedParameter = (promisify: PromisifyContext, parameter: GirParameter, index: number): boolean =>\n isCallbackParameter(promisify.context, parameter) ||\n promisify.closureIndices.has(index) ||\n (isOutParameter(parameter) && !isCallerAllocatedOut(parameter));\n\nconst promisifiedArgument = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n hasSeenOptional: boolean,\n): string => {\n const { context, asyncFn, lengthSources } = promisify;\n const sourceIndex = lengthSources.get(index);\n const source = sourceIndex === undefined ? undefined : asyncFn.parameters[sourceIndex];\n\n if (sourceIndex !== undefined && source !== undefined) {\n return arrayLengthArgument(source, sourceIndex);\n }\n\n return parameterCallExpression(context, parameter, index, hasSeenOptional);\n};\n\nconst findCancellableIndex = (context: ModuleContext, parameters: GirParameter[]): number =>\n parameters.findIndex((parameter) => isCancellable(context, parameter));\n\nconst renderPromisifiedSignature = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishFn: GirFunction,\n): { signature: string; returnType: string } => {\n const signature = renderInputParameters(\n context,\n asyncFn,\n (parameter) => isCallbackParameter(context, parameter),\n (parameter) => isCancellable(context, parameter),\n );\n\n const finishReturn = renderMethodReturnType(context, finishFn);\n\n return { signature, returnType: `Promise<${finishReturn}>` };\n};\n\nconst isCancellable = (context: ModuleContext, parameter: GirParameter): boolean =>\n parameter.type !== undefined && context.library.nameFor(parameter.type)?.typeName === \"Cancellable\";\n\nconst isCallbackParameter = (context: ModuleContext, parameter: GirParameter): boolean => {\n const ref = parameter.type;\n\n if (ref === undefined) {\n return false;\n }\n\n return context.library.typeFor(ref)?.kind === \"callback\";\n};\n\nconst renderMethodBody = (context: ModuleContext, fn: GirFunction, options: WriteMethodBodyOptions): string => {\n const { bindingExpression, returnTypeOverride } = options;\n\n const inputs = planCallArgs(context, fn)\n .map((arg) => arg.inputExpr)\n .filter((expression): expression is string => expression !== undefined);\n\n const callExpression = `${bindingExpression}(${inputs.join(\", \")})`;\n const annotation = returnTypeOverride ?? renderMethodReturnType(context, fn);\n\n return annotation === \"void\" ? `${callExpression};` : `return ${callExpression} as ${annotation};`;\n};\n\nconst paramDescriptorLiteral = (descriptor: string, options: ParamDescriptorOptions): string => {\n const parts = [`type: ${descriptor}`];\n\n if (options.direction !== undefined) {\n parts.push(`direction: ${sourceStringLiteral(options.direction)}`);\n }\n\n if (options.callerAllocated === true) {\n parts.push(\"callerAllocated: true\");\n }\n\n if (options.consumed === true) {\n parts.push(\"consumed: true\");\n }\n\n return `{ ${parts.join(\", \")} }`;\n};\n\nconst renderReturnDescriptor = (context: ModuleContext, fn: GirFunction): string => {\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n return renderDescriptor(context, fn.returnValue.type, fn.returnValue.transferOwnership, {\n argIndexOffset: instanceOffset,\n argIndexMap: emittedArgIndices(fn, instanceOffset),\n });\n};\n\nconst planCallArgs = (context: ModuleContext, fn: GirFunction): CallArgPlan[] => {\n const plan: CallArgPlan[] = [];\n\n if (fn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n\n plan.push({\n paramLiteral: `{ type: ${renderSelfDescriptor(context, fn.instance)} }`,\n inputExpr: \"getHandle(this)\",\n });\n }\n\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n const planContext: PlanArgsContext = {\n fn,\n instanceOffset,\n argIndex: { argIndexOffset: instanceOffset, argIndexMap: emittedArgIndices(fn, instanceOffset) },\n lengthSources: arrayLengthSources(context.library, fn),\n closureIndices: closureAndDestroyIndices(fn),\n folded: foldedLengthIndices(context.library, fn),\n };\n\n for (const [index, parameter] of fn.parameters.entries()) {\n const entry = planParameter(context, parameter, index, planContext);\n\n if (entry !== undefined) {\n plan.push(entry);\n }\n }\n\n return plan;\n};\n\nconst isSkippedPlanParameter = (parameter: GirParameter, index: number, closureIndices: Set<number>): boolean =>\n parameter.isVarargs || closureIndices.has(index);\n\nconst planParameter = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan | undefined => {\n const { folded, closureIndices, lengthSources } = planContext;\n\n if (isSkippedPlanParameter(parameter, index, closureIndices)) {\n return undefined;\n }\n\n if (isOutParameter(parameter)) {\n return planOutParam(context, parameter, planContext.argIndex, folded.has(index));\n }\n\n if (isCallerAllocatedOut(parameter)) {\n return planCallerOut(context, parameter, planContext.argIndex);\n }\n\n if (isInoutParameter(parameter)) {\n return planInoutArgument(context, parameter, index, planContext);\n }\n\n const sourceIndex = lengthSources.get(index);\n\n if (sourceIndex !== undefined) {\n return planLengthArgument(context, parameter, sourceIndex, planContext);\n }\n\n return planInParam(context, parameter, index, planContext);\n};\n\nconst planInoutArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn, folded, lengthSources } = planContext;\n const lengthSourceIndex = lengthSources.get(index);\n const lengthSourceParam = lengthSourceIndex === undefined ? undefined : fn.parameters[lengthSourceIndex];\n\n const lengthSource =\n lengthSourceIndex !== undefined && lengthSourceParam !== undefined\n ? { source: lengthSourceParam, index: lengthSourceIndex }\n : undefined;\n\n return planInoutParam(context, parameter, {\n index,\n argIndex: planContext.argIndex,\n consumed: folded.has(index),\n lengthSource,\n });\n};\n\nconst planLengthArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n sourceIndex: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const source = planContext.fn.parameters[sourceIndex];\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, planContext.argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: source === undefined ? \"0\" : arrayLengthArgument(source, sourceIndex),\n };\n};\n\nconst planOutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n isConsumed: boolean,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", consumed: isConsumed }),\n inputExpr: undefined,\n };\n};\n\nconst constructibleName = (\n context: ModuleContext,\n ref: GirParameter[\"type\"],\n): { namespaceName: string; typeName: string } | undefined => {\n let current = ref;\n\n while (current !== undefined) {\n const resolved = context.library.typeFor(current);\n\n if (resolved?.kind === \"alias\" && resolved.value.target !== undefined) {\n current = resolved.value.target;\n continue;\n }\n\n return context.library.nameFor(current);\n }\n\n return undefined;\n};\n\nconst planCallerOut = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", argIndex);\n const name = constructibleName(context, parameter.type);\n\n if (name !== undefined && isCollectibleCallerOut(context, parameter)) {\n context.addRuntimeImport(\"getHandle\");\n const classExpression = context.qualify(name.namespaceName, name.typeName);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", callerAllocated: true }),\n inputExpr: `new ${classExpression}()`,\n };\n }\n\n return { paramLiteral: paramDescriptorLiteral(descriptor, {}), inputExpr: \"undefined\" };\n};\n\nconst planInoutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n options: {\n index: number;\n argIndex: ArgIndexOptions;\n consumed: boolean;\n lengthSource?: { source: GirParameter; index: number } | undefined;\n },\n): CallArgPlan => {\n const { index, argIndex, consumed, lengthSource } = options;\n\n if (isHandlePassedInPlace(context, parameter)) {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"inout\", callerAllocated: true, consumed }),\n inputExpr: parameterIdentifier(parameter, index),\n };\n }\n\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"inout\", consumed }),\n inputExpr:\n lengthSource === undefined\n ? parameterCallExpression(context, parameter, index)\n : arrayLengthArgument(lengthSource.source, lengthSource.index),\n };\n};\n\nconst planInParam = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn } = planContext;\n\n const callback = renderCallbackType(\n context,\n parameter.type,\n parameter,\n itemComparatorArgDescriptors(context, fn, parameter),\n );\n\n const descriptor =\n callback ??\n renderDescriptor(\n context,\n parameter.type,\n parameter.transferOwnership,\n planContext.argIndex,\n );\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: parameterCallExpression(context, parameter, index),\n };\n};\n\nconst handleArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n if (isNullable) {\n context.addRuntimeImport(\"tryGetHandle\");\n\n return `tryGetHandle(${name})`;\n }\n\n context.addRuntimeImport(\"getHandle\");\n\n return `getHandle(${name})`;\n};\n\nconst hashtableArgument = (context: ModuleContext, valueRef: TypeId, name: string): string => {\n if (isHandlePassing(context, valueRef)) {\n context.addRuntimeImport(\"tryGetHandle\");\n\n return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, tryGetHandle(v)]) : null`;\n }\n\n return `${name} ? globalThis.Array.from(${name}) : null`;\n};\n\nconst mapHandleExpression = (name: string, isNullable: boolean): string =>\n isNullable ? `${name}?.map((item) => getHandle(item))` : `${name}.map((item) => getHandle(item))`;\n\nconst collectionArgument = (\n context: ModuleContext,\n type: GirType | undefined,\n name: string,\n isNullable: boolean,\n): string | undefined => {\n if (type?.kind === \"hashtable\") {\n return hashtableArgument(context, type.value, name);\n }\n\n if (!isMappableSequence(context, type)) {\n return undefined;\n }\n\n context.addRuntimeImport(\"getHandle\");\n\n return mapHandleExpression(name, isNullable);\n};\n\n// An array whose length nothing states is marshalled as the bare pointer it is, so there is nothing\n// to map over.\nconst isMappableSequence = (context: ModuleContext, type: GirType | undefined): boolean => {\n if (type?.kind === \"carray\") {\n return !hasUnknownArrayLength(type) && isHandlePassing(context, type.element);\n }\n\n return type?.kind === \"list\" && isHandlePassing(context, type.element);\n};\n\nconst parameterCallExpression = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n isForcedNullable = false,\n): string => {\n const name = parameterIdentifier(parameter, index);\n const ref = parameter.type;\n\n if (ref === undefined) {\n return name;\n }\n\n const isNullable = parameter.nullable || parameter.optional || isForcedNullable;\n\n if (isHandlePassing(context, ref)) {\n return handleArgument(context, name, isNullable);\n }\n\n const type = context.library.typeFor(ref);\n\n return collectionArgument(context, type, name, isNullable) ?? name;\n};\n\nexport {\n methodExportName,\n renderMethodSignature,\n renderMethodReturnType,\n renderPromisifiedBody,\n finishCallExpression,\n renderPromisifiedSignature,\n renderMethodBody,\n renderReturnDescriptor,\n planCallArgs,\n};\n"]}
|