@gtkx/codegen 0.21.0 → 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/README.md +173 -0
- package/dist/analysis/descriptor-render.d.ts +25 -0
- package/dist/analysis/descriptor-render.d.ts.map +1 -0
- package/dist/analysis/descriptor-render.js +420 -0
- package/dist/analysis/descriptor-render.js.map +1 -0
- package/dist/analysis/descriptor.d.ts +62 -0
- package/dist/analysis/descriptor.d.ts.map +1 -0
- package/dist/analysis/descriptor.js +127 -0
- package/dist/analysis/descriptor.js.map +1 -0
- package/dist/analysis/inheritance.d.ts +38 -0
- package/dist/analysis/inheritance.d.ts.map +1 -0
- package/dist/analysis/inheritance.js +248 -0
- package/dist/analysis/inheritance.js.map +1 -0
- package/dist/analysis/param-structure.d.ts +27 -0
- package/dist/analysis/param-structure.d.ts.map +1 -0
- package/dist/analysis/param-structure.js +158 -0
- package/dist/analysis/param-structure.js.map +1 -0
- package/dist/analysis/ts-type.d.ts +20 -0
- package/dist/analysis/ts-type.d.ts.map +1 -0
- package/dist/analysis/ts-type.js +111 -0
- package/dist/analysis/ts-type.js.map +1 -0
- package/dist/compile.d.ts +18 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +130 -0
- package/dist/compile.js.map +1 -0
- package/dist/docs/api-reference.d.ts +67 -0
- package/dist/docs/api-reference.d.ts.map +1 -0
- package/dist/docs/api-reference.js +372 -0
- package/dist/docs/api-reference.js.map +1 -0
- package/dist/docs/element-page.d.ts +12 -0
- package/dist/docs/element-page.d.ts.map +1 -0
- package/dist/docs/element-page.js +156 -0
- package/dist/docs/element-page.js.map +1 -0
- package/dist/docs/pipeline.d.ts +26 -0
- package/dist/docs/pipeline.d.ts.map +1 -0
- package/dist/docs/pipeline.js +156 -0
- package/dist/docs/pipeline.js.map +1 -0
- package/dist/docs/render.d.ts +34 -0
- package/dist/docs/render.d.ts.map +1 -0
- package/dist/docs/render.js +143 -0
- package/dist/docs/render.js.map +1 -0
- package/dist/docs/symbol-page.d.ts +41 -0
- package/dist/docs/symbol-page.d.ts.map +1 -0
- package/dist/docs/symbol-page.js +380 -0
- package/dist/docs/symbol-page.js.map +1 -0
- package/dist/fingerprint.d.ts +31 -28
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +84 -19
- 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 +10 -0
- package/dist/gir/ancestry.d.ts.map +1 -0
- package/dist/gir/ancestry.js +26 -0
- package/dist/gir/ancestry.js.map +1 -0
- package/dist/gir/callback.d.ts +8 -14
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +16 -16
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +25 -44
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +16 -26
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +16 -34
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +10 -16
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +16 -24
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +35 -18
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/function.d.ts +15 -43
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +26 -23
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/gir-path.d.ts +3 -0
- package/dist/gir/gir-path.d.ts.map +1 -0
- package/dist/gir/gir-path.js +57 -0
- package/dist/gir/gir-path.js.map +1 -0
- package/dist/gir/libraries.d.ts +5 -0
- package/dist/gir/libraries.d.ts.map +1 -0
- package/dist/gir/libraries.js +74 -0
- package/dist/gir/libraries.js.map +1 -0
- package/dist/gir/library.d.ts +43 -0
- package/dist/gir/library.d.ts.map +1 -0
- package/dist/gir/library.js +242 -0
- package/dist/gir/library.js.map +1 -0
- package/dist/gir/namespace.d.ts +40 -54
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +51 -40
- 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 +34 -76
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +47 -59
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts +12 -77
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +65 -103
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +5 -35
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js +21 -36
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +18 -26
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +16 -12
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +28 -0
- package/dist/gir/record.d.ts.map +1 -0
- package/dist/gir/record.js +26 -0
- package/dist/gir/record.js.map +1 -0
- package/dist/gir/size.d.ts +15 -61
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +49 -72
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +51 -0
- package/dist/gir/type-id.d.ts.map +1 -0
- package/dist/gir/type-id.js +12 -0
- package/dist/gir/type-id.js.map +1 -0
- package/dist/gir/type-ref.d.ts +4 -77
- package/dist/gir/type-ref.d.ts.map +1 -1
- package/dist/gir/type-ref.js +58 -77
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/gir/type.d.ts +34 -0
- package/dist/gir/type.d.ts.map +1 -0
- package/dist/gir/type.js +2 -0
- package/dist/gir/type.js.map +1 -0
- package/dist/index.d.ts +7 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -11
- 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 +30 -0
- package/dist/khronos/args.d.ts.map +1 -0
- package/dist/khronos/args.js +171 -0
- package/dist/khronos/args.js.map +1 -0
- package/dist/khronos/jsdoc.d.ts +21 -0
- package/dist/khronos/jsdoc.d.ts.map +1 -0
- package/dist/khronos/jsdoc.js +72 -0
- package/dist/khronos/jsdoc.js.map +1 -0
- package/dist/khronos/model.d.ts +38 -0
- package/dist/khronos/model.d.ts.map +1 -0
- package/dist/khronos/model.js +167 -0
- package/dist/khronos/model.js.map +1 -0
- package/dist/khronos/modules.d.ts +12 -0
- package/dist/khronos/modules.d.ts.map +1 -0
- package/dist/khronos/modules.js +73 -0
- package/dist/khronos/modules.js.map +1 -0
- 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 +8 -0
- package/dist/khronos/parse.d.ts.map +1 -0
- package/dist/khronos/parse.js +62 -0
- package/dist/khronos/parse.js.map +1 -0
- package/dist/khronos/pipeline.d.ts +24 -0
- package/dist/khronos/pipeline.d.ts.map +1 -0
- package/dist/khronos/pipeline.js +223 -0
- package/dist/khronos/pipeline.js.map +1 -0
- package/dist/khronos/plan.d.ts +81 -0
- package/dist/khronos/plan.d.ts.map +1 -0
- package/dist/khronos/plan.js +200 -0
- package/dist/khronos/plan.js.map +1 -0
- package/dist/khronos/render.d.ts +17 -0
- package/dist/khronos/render.d.ts.map +1 -0
- package/dist/khronos/render.js +205 -0
- package/dist/khronos/render.js.map +1 -0
- package/dist/khronos/select.d.ts +15 -0
- package/dist/khronos/select.d.ts.map +1 -0
- package/dist/khronos/select.js +56 -0
- package/dist/khronos/select.js.map +1 -0
- 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 +38 -49
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +81 -54
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +11 -0
- package/dist/store/compile-store.d.ts.map +1 -0
- package/dist/store/compile-store.js +40 -0
- package/dist/store/compile-store.js.map +1 -0
- package/dist/store/gi/async.d.ts +5 -0
- package/dist/store/gi/async.d.ts.map +1 -0
- package/dist/store/gi/async.js +45 -0
- package/dist/store/gi/async.js.map +1 -0
- package/dist/store/gi/callables.d.ts +42 -0
- package/dist/store/gi/callables.d.ts.map +1 -0
- package/dist/store/gi/callables.js +264 -0
- package/dist/store/gi/callables.js.map +1 -0
- package/dist/store/gi/callback.d.ts +5 -0
- package/dist/store/gi/callback.d.ts.map +1 -0
- package/dist/store/gi/callback.js +17 -0
- package/dist/store/gi/callback.js.map +1 -0
- package/dist/store/gi/class-struct-record.d.ts +10 -0
- package/dist/store/gi/class-struct-record.d.ts.map +1 -0
- package/dist/store/gi/class-struct-record.js +52 -0
- package/dist/store/gi/class-struct-record.js.map +1 -0
- package/dist/store/gi/class.d.ts +5 -0
- package/dist/store/gi/class.d.ts.map +1 -0
- package/dist/store/gi/class.js +208 -0
- package/dist/store/gi/class.js.map +1 -0
- package/dist/store/gi/companion.d.ts +5 -0
- package/dist/store/gi/companion.d.ts.map +1 -0
- package/dist/store/gi/companion.js +16 -0
- package/dist/store/gi/companion.js.map +1 -0
- package/dist/store/gi/constant.d.ts +6 -0
- package/dist/store/gi/constant.d.ts.map +1 -0
- package/dist/store/gi/constant.js +35 -0
- package/dist/store/gi/constant.js.map +1 -0
- package/dist/store/gi/constructor-props.d.ts +6 -0
- package/dist/store/gi/constructor-props.d.ts.map +1 -0
- package/dist/store/gi/constructor-props.js +71 -0
- package/dist/store/gi/constructor-props.js.map +1 -0
- package/dist/store/gi/enum.d.ts +6 -0
- package/dist/store/gi/enum.d.ts.map +1 -0
- package/dist/store/gi/enum.js +41 -0
- package/dist/store/gi/enum.js.map +1 -0
- package/dist/store/gi/function.d.ts +9 -0
- package/dist/store/gi/function.d.ts.map +1 -0
- package/dist/store/gi/function.js +114 -0
- package/dist/store/gi/function.js.map +1 -0
- package/dist/store/gi/gtype-binding.d.ts +10 -0
- package/dist/store/gi/gtype-binding.d.ts.map +1 -0
- package/dist/store/gi/gtype-binding.js +24 -0
- package/dist/store/gi/gtype-binding.js.map +1 -0
- package/dist/store/gi/interface.d.ts +5 -0
- package/dist/store/gi/interface.d.ts.map +1 -0
- package/dist/store/gi/interface.js +117 -0
- package/dist/store/gi/interface.js.map +1 -0
- package/dist/store/gi/item-comparators.d.ts +7 -0
- package/dist/store/gi/item-comparators.d.ts.map +1 -0
- package/dist/store/gi/item-comparators.js +88 -0
- package/dist/store/gi/item-comparators.js.map +1 -0
- package/dist/store/gi/method.d.ts +24 -0
- package/dist/store/gi/method.d.ts.map +1 -0
- package/dist/store/gi/method.js +336 -0
- package/dist/store/gi/method.js.map +1 -0
- package/dist/store/gi/param-marshal.d.ts +10 -0
- package/dist/store/gi/param-marshal.d.ts.map +1 -0
- package/dist/store/gi/param-marshal.js +50 -0
- package/dist/store/gi/param-marshal.js.map +1 -0
- package/dist/store/gi/pipeline.d.ts +5 -0
- package/dist/store/gi/pipeline.d.ts.map +1 -0
- package/dist/store/gi/pipeline.js +95 -0
- package/dist/store/gi/pipeline.js.map +1 -0
- package/dist/store/gi/properties.d.ts +6 -0
- package/dist/store/gi/properties.d.ts.map +1 -0
- package/dist/store/gi/properties.js +32 -0
- package/dist/store/gi/properties.js.map +1 -0
- package/dist/store/gi/property-accessor.d.ts +27 -0
- package/dist/store/gi/property-accessor.d.ts.map +1 -0
- package/dist/store/gi/property-accessor.js +158 -0
- package/dist/store/gi/property-accessor.js.map +1 -0
- package/dist/store/gi/record-constructor.d.ts +6 -0
- package/dist/store/gi/record-constructor.d.ts.map +1 -0
- package/dist/store/gi/record-constructor.js +76 -0
- package/dist/store/gi/record-constructor.js.map +1 -0
- package/dist/store/gi/record-field-accessor.d.ts +25 -0
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -0
- package/dist/store/gi/record-field-accessor.js +360 -0
- package/dist/store/gi/record-field-accessor.js.map +1 -0
- package/dist/store/gi/record-layout.d.ts +15 -0
- package/dist/store/gi/record-layout.d.ts.map +1 -0
- package/dist/store/gi/record-layout.js +132 -0
- package/dist/store/gi/record-layout.js.map +1 -0
- package/dist/store/gi/record.d.ts +5 -0
- package/dist/store/gi/record.d.ts.map +1 -0
- package/dist/store/gi/record.js +65 -0
- package/dist/store/gi/record.js.map +1 -0
- package/dist/store/gi/registration.d.ts +16 -0
- package/dist/store/gi/registration.d.ts.map +1 -0
- package/dist/store/gi/registration.js +21 -0
- package/dist/store/gi/registration.js.map +1 -0
- package/dist/store/gi/return-wrap.d.ts +10 -0
- package/dist/store/gi/return-wrap.d.ts.map +1 -0
- package/dist/store/gi/return-wrap.js +67 -0
- package/dist/store/gi/return-wrap.js.map +1 -0
- package/dist/store/gi/runtime-override.d.ts +4 -0
- package/dist/store/gi/runtime-override.d.ts.map +1 -0
- package/dist/store/gi/runtime-override.js +32 -0
- package/dist/store/gi/runtime-override.js.map +1 -0
- package/dist/store/gi/signal.d.ts +6 -0
- package/dist/store/gi/signal.d.ts.map +1 -0
- package/dist/store/gi/signal.js +280 -0
- package/dist/store/gi/signal.js.map +1 -0
- package/dist/store/gi/vtable.d.ts +5 -0
- package/dist/store/gi/vtable.d.ts.map +1 -0
- package/dist/store/gi/vtable.js +108 -0
- package/dist/store/gi/vtable.js.map +1 -0
- package/dist/store/gi-store.d.ts +10 -0
- package/dist/store/gi-store.d.ts.map +1 -0
- package/dist/store/gi-store.js +59 -0
- package/dist/store/gi-store.js.map +1 -0
- 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/jsx/jsx.d.ts +16 -0
- package/dist/store/jsx/jsx.d.ts.map +1 -0
- package/dist/store/jsx/jsx.js +242 -0
- 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/jsx/metadata.js +253 -0
- 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/jsx/pipeline.js +81 -0
- package/dist/store/jsx/pipeline.js.map +1 -0
- package/dist/store/jsx/props.d.ts +33 -0
- 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 +7 -0
- package/dist/store/jsx-store.d.ts.map +1 -0
- package/dist/store/jsx-store.js +26 -0
- package/dist/store/jsx-store.js.map +1 -0
- package/dist/store/store-fs.d.ts +43 -0
- package/dist/store/store-fs.d.ts.map +1 -0
- package/dist/store/store-fs.js +73 -0
- package/dist/store/store-fs.js.map +1 -0
- package/dist/writer/context.d.ts +17 -0
- package/dist/writer/context.d.ts.map +1 -0
- package/dist/writer/context.js +50 -0
- package/dist/writer/context.js.map +1 -0
- package/dist/writer/doc.d.ts +3 -0
- package/dist/writer/doc.d.ts.map +1 -0
- package/dist/writer/doc.js +18 -0
- package/dist/writer/doc.js.map +1 -0
- package/dist/writer/emit.d.ts +9 -0
- package/dist/writer/emit.d.ts.map +1 -0
- package/dist/writer/emit.js +24 -0
- package/dist/writer/emit.js.map +1 -0
- package/dist/writer/gtk-doc.d.ts +3 -0
- package/dist/writer/gtk-doc.d.ts.map +1 -0
- package/dist/writer/gtk-doc.js +78 -0
- package/dist/writer/gtk-doc.js.map +1 -0
- package/dist/writer/imports.d.ts +12 -0
- package/dist/writer/imports.d.ts.map +1 -0
- package/dist/writer/imports.js +61 -0
- package/dist/writer/imports.js.map +1 -0
- package/dist/writer/module.d.ts +16 -0
- package/dist/writer/module.d.ts.map +1 -0
- package/dist/writer/module.js +53 -0
- package/dist/writer/module.js.map +1 -0
- 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 +1269 -0
- package/overrides/cairo/font-face.ts.ejs +151 -0
- package/overrides/cairo/font-options.ts.ejs +199 -0
- package/overrides/cairo/image-surface.ts.ejs +132 -0
- package/overrides/cairo/index.ts.ejs +22 -0
- package/overrides/cairo/matrix.ts.ejs +171 -0
- package/overrides/cairo/pattern.ts.ejs +476 -0
- package/overrides/cairo/recording-surface.ts.ejs +102 -0
- package/overrides/cairo/region.ts.ejs +237 -0
- package/overrides/cairo/scaled-font.ts.ejs +330 -0
- package/overrides/cairo/surface.ts.ejs +296 -0
- package/overrides/gdk/index.ts.ejs +2 -0
- package/overrides/gdk/rgba.ts.ejs +11 -0
- package/overrides/gobject/index.ts.ejs +29 -0
- package/overrides/gobject/object.ts.ejs +51 -0
- package/overrides/gobject/value.ts.ejs +17 -0
- package/overrides/graphene/index.ts.ejs +2 -0
- package/overrides/graphene/structs.ts.ejs +37 -0
- package/package.json +21 -15
- package/src/analysis/descriptor-render.ts +723 -0
- package/src/analysis/descriptor.ts +300 -0
- package/src/analysis/inheritance.ts +430 -0
- package/src/analysis/param-structure.ts +258 -0
- package/src/analysis/ts-type.ts +174 -0
- package/src/compile.ts +179 -0
- package/src/docs/api-reference.ts +557 -0
- package/src/docs/element-page.ts +281 -0
- package/src/docs/pipeline.ts +241 -0
- package/src/docs/render.ts +255 -0
- package/src/docs/symbol-page.ts +589 -0
- package/src/fingerprint.ts +144 -35
- package/src/gi.ts +26 -0
- package/src/gir/ancestry.ts +53 -0
- package/src/gir/callback.ts +22 -24
- package/src/gir/class.ts +39 -61
- package/src/gir/enum.ts +25 -41
- package/src/gir/field.ts +51 -37
- package/src/gir/function.ts +44 -59
- package/src/gir/gir-path.ts +73 -0
- package/src/gir/libraries.ts +102 -0
- package/src/gir/library.ts +351 -0
- package/src/gir/namespace.ts +109 -88
- package/src/gir/nullable-overrides.ts +5 -0
- package/src/gir/parameter.ts +111 -102
- package/src/gir/parse.ts +124 -121
- package/src/gir/primitives.ts +43 -63
- package/src/gir/property.ts +33 -33
- package/src/gir/record.ts +55 -0
- package/src/gir/size.ts +93 -107
- package/src/gir/type-id.ts +64 -0
- package/src/gir/type-ref.ts +77 -146
- package/src/gir/type.ts +18 -0
- package/src/index.ts +27 -15
- package/src/jsx.ts +70 -0
- package/src/khronos/args.ts +271 -0
- package/src/khronos/jsdoc.ts +114 -0
- package/src/khronos/model.ts +267 -0
- package/src/khronos/modules.ts +115 -0
- package/src/khronos/param-pair.ts +14 -0
- package/src/khronos/parse.ts +86 -0
- package/src/khronos/pipeline.ts +337 -0
- package/src/khronos/plan.ts +340 -0
- package/src/khronos/registry/LICENSE +202 -0
- package/src/khronos/registry/gl.xml +47748 -0
- package/src/khronos/render.ts +330 -0
- package/src/khronos/select.ts +97 -0
- package/src/react/element-config.ts +91 -0
- package/src/runner.ts +153 -80
- package/src/store/compile-store.ts +55 -0
- package/src/store/gi/async.ts +69 -0
- package/src/store/gi/callables.ts +518 -0
- package/src/store/gi/callback.ts +24 -0
- package/src/store/gi/class-struct-record.ts +72 -0
- package/src/store/gi/class.ts +334 -0
- package/src/store/gi/companion.ts +22 -0
- package/src/store/gi/constant.ts +58 -0
- package/src/store/gi/constructor-props.ts +108 -0
- package/src/store/gi/enum.ts +64 -0
- package/src/store/gi/function.ts +173 -0
- package/src/store/gi/gtype-binding.ts +46 -0
- package/src/store/gi/interface.ts +222 -0
- package/src/store/gi/item-comparators.ts +138 -0
- package/src/store/gi/method.ts +634 -0
- package/src/store/gi/param-marshal.ts +71 -0
- package/src/store/gi/pipeline.ts +135 -0
- package/src/store/gi/properties.ts +50 -0
- package/src/store/gi/property-accessor.ts +302 -0
- package/src/store/gi/record-constructor.ts +119 -0
- package/src/store/gi/record-field-accessor.ts +607 -0
- package/src/store/gi/record-layout.ts +221 -0
- package/src/store/gi/record.ts +89 -0
- package/src/store/gi/registration.ts +44 -0
- package/src/store/gi/return-wrap.ts +100 -0
- package/src/store/gi/runtime-override.ts +46 -0
- package/src/store/gi/signal.ts +450 -0
- package/src/store/gi/vtable.ts +175 -0
- package/src/store/gi-store.ts +92 -0
- 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/jsx/jsx.ts +408 -0
- 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 +39 -0
- package/src/store/store-fs.ts +128 -0
- package/src/writer/context.ts +67 -0
- package/src/writer/doc.ts +25 -0
- package/src/writer/emit.ts +35 -0
- package/src/writer/gtk-doc.ts +101 -0
- package/src/writer/imports.ts +94 -0
- package/src/writer/module.ts +69 -0
- package/src/xml.ts +12 -0
- package/LICENSE +0 -373
- package/dist/dsl/context.d.ts +0 -104
- package/dist/dsl/context.d.ts.map +0 -1
- package/dist/dsl/context.js +0 -140
- package/dist/dsl/context.js.map +0 -1
- package/dist/dsl/emit.d.ts +0 -28
- package/dist/dsl/emit.d.ts.map +0 -1
- package/dist/dsl/emit.js +0 -41
- package/dist/dsl/emit.js.map +0 -1
- package/dist/dsl/identifier.d.ts +0 -28
- package/dist/dsl/identifier.d.ts.map +0 -1
- package/dist/dsl/identifier.js +0 -45
- package/dist/dsl/identifier.js.map +0 -1
- package/dist/dsl/imports.d.ts +0 -58
- package/dist/dsl/imports.d.ts.map +0 -1
- package/dist/dsl/imports.js +0 -107
- package/dist/dsl/imports.js.map +0 -1
- package/dist/dsl/module.d.ts +0 -53
- package/dist/dsl/module.d.ts.map +0 -1
- package/dist/dsl/module.js +0 -76
- package/dist/dsl/module.js.map +0 -1
- package/dist/ffi/pipeline.d.ts +0 -19
- package/dist/ffi/pipeline.d.ts.map +0 -1
- package/dist/ffi/pipeline.js +0 -107
- package/dist/ffi/pipeline.js.map +0 -1
- package/dist/gi-store.d.ts +0 -34
- package/dist/gi-store.d.ts.map +0 -1
- package/dist/gi-store.js +0 -154
- package/dist/gi-store.js.map +0 -1
- package/dist/gir/boxed.d.ts +0 -66
- package/dist/gir/boxed.d.ts.map +0 -1
- package/dist/gir/boxed.js +0 -49
- package/dist/gir/boxed.js.map +0 -1
- package/dist/gir/qualified-name.d.ts +0 -37
- package/dist/gir/qualified-name.d.ts.map +0 -1
- package/dist/gir/qualified-name.js +0 -39
- package/dist/gir/qualified-name.js.map +0 -1
- package/dist/gir/qualify.d.ts +0 -32
- package/dist/gir/qualify.d.ts.map +0 -1
- package/dist/gir/qualify.js +0 -60
- package/dist/gir/qualify.js.map +0 -1
- package/dist/gir/repository.d.ts +0 -82
- package/dist/gir/repository.d.ts.map +0 -1
- package/dist/gir/repository.js +0 -122
- package/dist/gir/repository.js.map +0 -1
- package/dist/gir/signal.d.ts +0 -22
- package/dist/gir/signal.d.ts.map +0 -1
- package/dist/gir/signal.js +0 -20
- package/dist/gir/signal.js.map +0 -1
- package/dist/jsx-store.d.ts +0 -22
- package/dist/jsx-store.d.ts.map +0 -1
- package/dist/jsx-store.js +0 -40
- package/dist/jsx-store.js.map +0 -1
- package/dist/react/compounds-meta.d.ts +0 -18
- package/dist/react/compounds-meta.d.ts.map +0 -1
- package/dist/react/compounds-meta.js +0 -93
- package/dist/react/compounds-meta.js.map +0 -1
- package/dist/react/compounds.d.ts +0 -27
- package/dist/react/compounds.d.ts.map +0 -1
- package/dist/react/compounds.js +0 -164
- package/dist/react/compounds.js.map +0 -1
- package/dist/react/internal.d.ts +0 -14
- package/dist/react/internal.d.ts.map +0 -1
- package/dist/react/internal.js +0 -79
- package/dist/react/internal.js.map +0 -1
- package/dist/react/jsx.d.ts +0 -22
- package/dist/react/jsx.d.ts.map +0 -1
- package/dist/react/jsx.js +0 -134
- package/dist/react/jsx.js.map +0 -1
- package/dist/react/pipeline.d.ts +0 -13
- package/dist/react/pipeline.d.ts.map +0 -1
- package/dist/react/pipeline.js +0 -25
- package/dist/react/pipeline.js.map +0 -1
- package/dist/react/props.d.ts +0 -38
- package/dist/react/props.d.ts.map +0 -1
- package/dist/react/props.js +0 -231
- package/dist/react/props.js.map +0 -1
- package/dist/react/slot-props.d.ts +0 -10
- package/dist/react/slot-props.d.ts.map +0 -1
- package/dist/react/slot-props.js +0 -56
- package/dist/react/slot-props.js.map +0 -1
- package/dist/react/widgets.d.ts +0 -83
- package/dist/react/widgets.d.ts.map +0 -1
- package/dist/react/widgets.js +0 -152
- package/dist/react/widgets.js.map +0 -1
- package/dist/store-fs.d.ts +0 -109
- package/dist/store-fs.d.ts.map +0 -1
- package/dist/store-fs.js +0 -98
- package/dist/store-fs.js.map +0 -1
- package/dist/transpile.d.ts +0 -32
- package/dist/transpile.d.ts.map +0 -1
- package/dist/transpile.js +0 -63
- package/dist/transpile.js.map +0 -1
- package/dist/typecheck-store.d.ts +0 -41
- package/dist/typecheck-store.d.ts.map +0 -1
- package/dist/typecheck-store.js +0 -102
- package/dist/typecheck-store.js.map +0 -1
- package/dist/writers/alias.d.ts +0 -13
- package/dist/writers/alias.d.ts.map +0 -1
- package/dist/writers/alias.js +0 -17
- package/dist/writers/alias.js.map +0 -1
- package/dist/writers/async.d.ts +0 -22
- package/dist/writers/async.d.ts.map +0 -1
- package/dist/writers/async.js +0 -48
- package/dist/writers/async.js.map +0 -1
- package/dist/writers/boxed-constructor.d.ts +0 -26
- package/dist/writers/boxed-constructor.d.ts.map +0 -1
- package/dist/writers/boxed-constructor.js +0 -85
- package/dist/writers/boxed-constructor.js.map +0 -1
- package/dist/writers/boxed-field-accessor.d.ts +0 -18
- package/dist/writers/boxed-field-accessor.d.ts.map +0 -1
- package/dist/writers/boxed-field-accessor.js +0 -260
- package/dist/writers/boxed-field-accessor.js.map +0 -1
- package/dist/writers/boxed-layout.d.ts +0 -27
- package/dist/writers/boxed-layout.d.ts.map +0 -1
- package/dist/writers/boxed-layout.js +0 -128
- package/dist/writers/boxed-layout.js.map +0 -1
- package/dist/writers/boxed.d.ts +0 -20
- package/dist/writers/boxed.d.ts.map +0 -1
- package/dist/writers/boxed.js +0 -71
- package/dist/writers/boxed.js.map +0 -1
- package/dist/writers/callables.d.ts +0 -124
- package/dist/writers/callables.d.ts.map +0 -1
- package/dist/writers/callables.js +0 -283
- package/dist/writers/callables.js.map +0 -1
- package/dist/writers/callback.d.ts +0 -16
- package/dist/writers/callback.d.ts.map +0 -1
- package/dist/writers/callback.js +0 -38
- package/dist/writers/callback.js.map +0 -1
- package/dist/writers/class-struct-record.d.ts +0 -31
- package/dist/writers/class-struct-record.d.ts.map +0 -1
- package/dist/writers/class-struct-record.js +0 -67
- package/dist/writers/class-struct-record.js.map +0 -1
- package/dist/writers/class-struct.d.ts +0 -22
- package/dist/writers/class-struct.d.ts.map +0 -1
- package/dist/writers/class-struct.js +0 -85
- package/dist/writers/class-struct.js.map +0 -1
- package/dist/writers/class.d.ts +0 -16
- package/dist/writers/class.d.ts.map +0 -1
- package/dist/writers/class.js +0 -307
- package/dist/writers/class.js.map +0 -1
- package/dist/writers/constant.d.ts +0 -15
- package/dist/writers/constant.d.ts.map +0 -1
- package/dist/writers/constant.js +0 -23
- package/dist/writers/constant.js.map +0 -1
- package/dist/writers/constants.d.ts +0 -15
- package/dist/writers/constants.d.ts.map +0 -1
- package/dist/writers/constants.js +0 -23
- package/dist/writers/constants.js.map +0 -1
- package/dist/writers/constructor-props.d.ts +0 -32
- package/dist/writers/constructor-props.d.ts.map +0 -1
- package/dist/writers/constructor-props.js +0 -110
- package/dist/writers/constructor-props.js.map +0 -1
- package/dist/writers/enum.d.ts +0 -21
- package/dist/writers/enum.d.ts.map +0 -1
- package/dist/writers/enum.js +0 -48
- package/dist/writers/enum.js.map +0 -1
- package/dist/writers/function.d.ts +0 -40
- package/dist/writers/function.d.ts.map +0 -1
- package/dist/writers/function.js +0 -127
- package/dist/writers/function.js.map +0 -1
- package/dist/writers/gtype-binding.d.ts +0 -19
- package/dist/writers/gtype-binding.d.ts.map +0 -1
- package/dist/writers/gtype-binding.js +0 -40
- package/dist/writers/gtype-binding.js.map +0 -1
- package/dist/writers/inheritance.d.ts +0 -48
- package/dist/writers/inheritance.d.ts.map +0 -1
- package/dist/writers/inheritance.js +0 -90
- package/dist/writers/inheritance.js.map +0 -1
- package/dist/writers/interface.d.ts +0 -16
- package/dist/writers/interface.d.ts.map +0 -1
- package/dist/writers/interface.js +0 -155
- package/dist/writers/interface.js.map +0 -1
- package/dist/writers/method.d.ts +0 -150
- package/dist/writers/method.d.ts.map +0 -1
- package/dist/writers/method.js +0 -510
- package/dist/writers/method.js.map +0 -1
- package/dist/writers/param-classify.d.ts +0 -93
- package/dist/writers/param-classify.d.ts.map +0 -1
- package/dist/writers/param-classify.js +0 -163
- package/dist/writers/param-classify.js.map +0 -1
- package/dist/writers/property-accessor.d.ts +0 -19
- package/dist/writers/property-accessor.d.ts.map +0 -1
- package/dist/writers/property-accessor.js +0 -117
- package/dist/writers/property-accessor.js.map +0 -1
- package/dist/writers/registration.d.ts +0 -27
- package/dist/writers/registration.d.ts.map +0 -1
- package/dist/writers/registration.js +0 -30
- package/dist/writers/registration.js.map +0 -1
- package/dist/writers/return-wrap.d.ts +0 -39
- package/dist/writers/return-wrap.d.ts.map +0 -1
- package/dist/writers/return-wrap.js +0 -152
- package/dist/writers/return-wrap.js.map +0 -1
- package/dist/writers/runtime-override.d.ts +0 -18
- package/dist/writers/runtime-override.d.ts.map +0 -1
- package/dist/writers/runtime-override.js +0 -44
- package/dist/writers/runtime-override.js.map +0 -1
- package/dist/writers/signal.d.ts +0 -21
- package/dist/writers/signal.d.ts.map +0 -1
- package/dist/writers/signal.js +0 -260
- package/dist/writers/signal.js.map +0 -1
- package/dist/writers/ts-type.d.ts +0 -50
- package/dist/writers/ts-type.d.ts.map +0 -1
- package/dist/writers/ts-type.js +0 -75
- package/dist/writers/ts-type.js.map +0 -1
- package/dist/writers/types-ts.d.ts +0 -27
- package/dist/writers/types-ts.d.ts.map +0 -1
- package/dist/writers/types-ts.js +0 -97
- package/dist/writers/types-ts.js.map +0 -1
- package/dist/writers/value.d.ts +0 -89
- package/dist/writers/value.d.ts.map +0 -1
- package/dist/writers/value.js +0 -402
- package/dist/writers/value.js.map +0 -1
- package/src/dsl/context.ts +0 -146
- package/src/dsl/emit.ts +0 -42
- package/src/dsl/identifier.ts +0 -52
- package/src/dsl/imports.ts +0 -109
- package/src/dsl/module.ts +0 -75
- package/src/ffi/pipeline.ts +0 -113
- package/src/gi-store.ts +0 -199
- package/src/gir/boxed.ts +0 -94
- package/src/gir/qualified-name.ts +0 -55
- package/src/gir/qualify.ts +0 -64
- package/src/gir/repository.ts +0 -149
- package/src/gir/signal.ts +0 -36
- package/src/jsx-store.ts +0 -53
- package/src/react/compounds-meta.ts +0 -99
- package/src/react/compounds.ts +0 -204
- package/src/react/internal.ts +0 -91
- package/src/react/jsx.ts +0 -155
- package/src/react/pipeline.ts +0 -29
- package/src/react/props.ts +0 -307
- package/src/react/slot-props.ts +0 -57
- package/src/react/widgets.ts +0 -185
- package/src/store-fs.ts +0 -157
- package/src/transpile.ts +0 -80
- package/src/typecheck-store.ts +0 -136
- package/src/writers/alias.ts +0 -19
- package/src/writers/async.ts +0 -44
- package/src/writers/boxed-constructor.ts +0 -105
- package/src/writers/boxed-field-accessor.ts +0 -306
- package/src/writers/boxed-layout.ts +0 -166
- package/src/writers/boxed.ts +0 -77
- package/src/writers/callables.ts +0 -339
- package/src/writers/callback.ts +0 -40
- package/src/writers/class-struct-record.ts +0 -75
- package/src/writers/class-struct.ts +0 -96
- package/src/writers/class.ts +0 -384
- package/src/writers/constant.ts +0 -29
- package/src/writers/constructor-props.ts +0 -130
- package/src/writers/enum.ts +0 -53
- package/src/writers/function.ts +0 -136
- package/src/writers/gtype-binding.ts +0 -48
- package/src/writers/inheritance.ts +0 -104
- package/src/writers/interface.ts +0 -168
- package/src/writers/method.ts +0 -678
- package/src/writers/param-classify.ts +0 -178
- package/src/writers/property-accessor.ts +0 -139
- package/src/writers/registration.ts +0 -42
- package/src/writers/return-wrap.ts +0 -180
- package/src/writers/runtime-override.ts +0 -59
- package/src/writers/signal.ts +0 -318
- package/src/writers/ts-type.ts +0 -115
- package/src/writers/value.ts +0 -485
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { callbackFromNode } from "./callback.js";
|
|
4
|
+
import { createNamespaceShell, parseNamespaceHeader, populateNamespaceBody, } from "./namespace.js";
|
|
5
|
+
import { parseGirFile } from "./parse.js";
|
|
6
|
+
import { splitOptionalNamespace } from "./type-ref.js";
|
|
7
|
+
const INTERNAL_NS_ID = 0;
|
|
8
|
+
const readRepositoryNode = (path) => {
|
|
9
|
+
const root = parseGirFile(path);
|
|
10
|
+
const repository = root.repository;
|
|
11
|
+
if (typeof repository !== "object" || repository === null) {
|
|
12
|
+
throw new Error(`GIR file at ${path} has no <repository> root`);
|
|
13
|
+
}
|
|
14
|
+
return repository;
|
|
15
|
+
};
|
|
16
|
+
const locateGirFile = (identifier, girPath) => {
|
|
17
|
+
const filename = `${identifier}.gir`;
|
|
18
|
+
for (const directory of girPath) {
|
|
19
|
+
const candidate = join(directory, filename);
|
|
20
|
+
if (existsSync(candidate)) {
|
|
21
|
+
return candidate;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const tried = girPath.map((directory) => join(directory, filename)).join(", ");
|
|
25
|
+
throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);
|
|
26
|
+
};
|
|
27
|
+
class Library {
|
|
28
|
+
static drive(library, libraries, girPath) {
|
|
29
|
+
const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);
|
|
30
|
+
for (const { header, shell } of discovered) {
|
|
31
|
+
populateNamespaceBody(shell, header.namespaceNode, library.parseContext(shell.id));
|
|
32
|
+
}
|
|
33
|
+
for (const { shell } of discovered) {
|
|
34
|
+
library.addDeclarations(shell);
|
|
35
|
+
}
|
|
36
|
+
library.girFilesValue = girFiles;
|
|
37
|
+
}
|
|
38
|
+
static load(libraries, girPath) {
|
|
39
|
+
const library = new Library();
|
|
40
|
+
this.drive(library, libraries, girPath);
|
|
41
|
+
return library;
|
|
42
|
+
}
|
|
43
|
+
namespacesByName = new Map();
|
|
44
|
+
namespaceById = [];
|
|
45
|
+
nsNameById = [];
|
|
46
|
+
nsIdByName = new Map();
|
|
47
|
+
typeTables = [];
|
|
48
|
+
girFilesValue = [];
|
|
49
|
+
constructor() {
|
|
50
|
+
this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };
|
|
51
|
+
this.namespaceById[INTERNAL_NS_ID] = undefined;
|
|
52
|
+
this.nsNameById[INTERNAL_NS_ID] = "$internal";
|
|
53
|
+
}
|
|
54
|
+
ensureNsId(name) {
|
|
55
|
+
const existing = this.nsIdByName.get(name);
|
|
56
|
+
if (existing !== undefined) {
|
|
57
|
+
return existing;
|
|
58
|
+
}
|
|
59
|
+
const nsId = this.typeTables.length;
|
|
60
|
+
this.typeTables[nsId] = { types: [], names: [], index: new Map() };
|
|
61
|
+
this.namespaceById[nsId] = undefined;
|
|
62
|
+
this.nsNameById[nsId] = name;
|
|
63
|
+
this.nsIdByName.set(name, nsId);
|
|
64
|
+
return nsId;
|
|
65
|
+
}
|
|
66
|
+
registerNamespace(header) {
|
|
67
|
+
const nsId = this.ensureNsId(header.name);
|
|
68
|
+
const shell = createNamespaceShell(header, nsId);
|
|
69
|
+
this.namespaceById[nsId] = shell;
|
|
70
|
+
this.namespacesByName.set(header.name, shell);
|
|
71
|
+
return shell;
|
|
72
|
+
}
|
|
73
|
+
namespaceFor(nsId) {
|
|
74
|
+
const namespace = this.namespaceById[nsId];
|
|
75
|
+
if (namespace === undefined) {
|
|
76
|
+
throw new Error(`No namespace registered for type table id ${String(nsId)}`);
|
|
77
|
+
}
|
|
78
|
+
return namespace;
|
|
79
|
+
}
|
|
80
|
+
typeTableFor(nsId) {
|
|
81
|
+
const typeTable = this.typeTables[nsId];
|
|
82
|
+
if (typeTable === undefined) {
|
|
83
|
+
throw new Error(`No type table for namespace id ${String(nsId)}`);
|
|
84
|
+
}
|
|
85
|
+
return typeTable;
|
|
86
|
+
}
|
|
87
|
+
insertIntoTypeTable(typeTable, slot) {
|
|
88
|
+
const id = typeTable.types.length;
|
|
89
|
+
typeTable.types.push(slot.type);
|
|
90
|
+
typeTable.names.push(slot.displayName);
|
|
91
|
+
if (slot.indexKey !== undefined) {
|
|
92
|
+
typeTable.index.set(slot.indexKey, id);
|
|
93
|
+
}
|
|
94
|
+
return id;
|
|
95
|
+
}
|
|
96
|
+
resolveTypeId(nsId, name, type) {
|
|
97
|
+
const typeTable = this.typeTableFor(nsId);
|
|
98
|
+
const existing = typeTable.index.get(name);
|
|
99
|
+
if (existing !== undefined) {
|
|
100
|
+
return existing;
|
|
101
|
+
}
|
|
102
|
+
return this.insertIntoTypeTable(typeTable, { type, indexKey: name, displayName: name });
|
|
103
|
+
}
|
|
104
|
+
addType(nsId, name, type) {
|
|
105
|
+
this.typeTableFor(nsId).types[this.resolveTypeId(nsId, name, type)] = type;
|
|
106
|
+
}
|
|
107
|
+
findType(nsId, name) {
|
|
108
|
+
return { nsId, id: this.resolveTypeId(nsId, name, undefined) };
|
|
109
|
+
}
|
|
110
|
+
addAnonymousType(nsId, type) {
|
|
111
|
+
const typeTable = this.typeTableFor(nsId);
|
|
112
|
+
const id = this.insertIntoTypeTable(typeTable, { type });
|
|
113
|
+
return { nsId, id };
|
|
114
|
+
}
|
|
115
|
+
findTypeByName(currentNsId, name) {
|
|
116
|
+
const [namespaceName, localName] = splitOptionalNamespace(name);
|
|
117
|
+
const targetNsId = namespaceName === undefined ? currentNsId : this.ensureNsId(namespaceName);
|
|
118
|
+
return this.findType(targetNsId, localName);
|
|
119
|
+
}
|
|
120
|
+
parseContext(nsId) {
|
|
121
|
+
const context = {
|
|
122
|
+
nsId,
|
|
123
|
+
findType: (name) => this.findTypeByName(nsId, name),
|
|
124
|
+
addPrimitive: (category) => this.addPrimitive(category),
|
|
125
|
+
addVarargs: () => this.addVarargs(),
|
|
126
|
+
addContainer: (type) => this.addAnonymousType(nsId, type),
|
|
127
|
+
addAnonymousCallback: (node) => this.addAnonymousType(nsId, {
|
|
128
|
+
kind: "callback",
|
|
129
|
+
namespace: this.namespaceFor(nsId),
|
|
130
|
+
value: callbackFromNode(node, context),
|
|
131
|
+
}),
|
|
132
|
+
};
|
|
133
|
+
return context;
|
|
134
|
+
}
|
|
135
|
+
addPrimitive(category) {
|
|
136
|
+
return this.findOrAddContainer(`primitive:${category}`, { kind: "primitive", category });
|
|
137
|
+
}
|
|
138
|
+
addVarargs() {
|
|
139
|
+
return this.findOrAddContainer("varargs", { kind: "varargs" });
|
|
140
|
+
}
|
|
141
|
+
findOrAddContainer(key, type) {
|
|
142
|
+
const typeTable = this.typeTableFor(INTERNAL_NS_ID);
|
|
143
|
+
const existing = typeTable.index.get(key);
|
|
144
|
+
if (existing !== undefined) {
|
|
145
|
+
return { nsId: INTERNAL_NS_ID, id: existing };
|
|
146
|
+
}
|
|
147
|
+
const id = this.insertIntoTypeTable(typeTable, { type, indexKey: key });
|
|
148
|
+
return { nsId: INTERNAL_NS_ID, id };
|
|
149
|
+
}
|
|
150
|
+
addDeclarations(shell) {
|
|
151
|
+
this.addClassDeclarations(shell);
|
|
152
|
+
this.addValueDeclarations(shell);
|
|
153
|
+
}
|
|
154
|
+
addClassDeclarations(shell) {
|
|
155
|
+
const nsId = shell.id;
|
|
156
|
+
for (const value of shell.classes) {
|
|
157
|
+
this.addType(nsId, value.name, { kind: "class", namespace: shell, value });
|
|
158
|
+
}
|
|
159
|
+
for (const value of shell.interfaces) {
|
|
160
|
+
this.addType(nsId, value.name, { kind: "interface", namespace: shell, value });
|
|
161
|
+
}
|
|
162
|
+
for (const value of shell.records) {
|
|
163
|
+
this.addType(nsId, value.name, { kind: "record", namespace: shell, value });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
addValueDeclarations(shell) {
|
|
167
|
+
const nsId = shell.id;
|
|
168
|
+
for (const value of shell.enums) {
|
|
169
|
+
this.addType(nsId, value.name, { kind: "enum", namespace: shell, value });
|
|
170
|
+
}
|
|
171
|
+
for (const value of shell.callbacks) {
|
|
172
|
+
this.addType(nsId, value.name, { kind: "callback", namespace: shell, value });
|
|
173
|
+
}
|
|
174
|
+
for (const alias of shell.aliases) {
|
|
175
|
+
this.addType(nsId, alias.name, { kind: "alias", namespace: shell, value: alias });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
processIdentifier(input) {
|
|
179
|
+
const { identifier, girPath, seen, queue, girFiles, discovered } = input;
|
|
180
|
+
const namespaceName = identifier.split("-", 1)[0] ?? identifier;
|
|
181
|
+
if (seen.has(namespaceName)) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
seen.add(namespaceName);
|
|
185
|
+
const path = locateGirFile(identifier, girPath);
|
|
186
|
+
girFiles.push(path);
|
|
187
|
+
const header = parseNamespaceHeader(readRepositoryNode(path));
|
|
188
|
+
const shell = this.registerNamespace(header);
|
|
189
|
+
discovered.push({ header, shell });
|
|
190
|
+
for (const include of header.includes) {
|
|
191
|
+
queue.push(`${include.name}-${include.version}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
discoverNamespaces(libraries, girPath) {
|
|
195
|
+
const queue = [...libraries];
|
|
196
|
+
const seen = new Set();
|
|
197
|
+
const discovered = [];
|
|
198
|
+
const girFiles = [];
|
|
199
|
+
while (queue.length > 0) {
|
|
200
|
+
const identifier = queue.shift();
|
|
201
|
+
if (identifier !== undefined) {
|
|
202
|
+
this.processIdentifier({ identifier, girPath, seen, queue, girFiles, discovered });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return { discovered, girFiles };
|
|
206
|
+
}
|
|
207
|
+
get namespaces() {
|
|
208
|
+
return this.namespacesByName;
|
|
209
|
+
}
|
|
210
|
+
get girFiles() {
|
|
211
|
+
return this.girFilesValue;
|
|
212
|
+
}
|
|
213
|
+
typeFor(tid) {
|
|
214
|
+
return this.typeTables[tid.nsId]?.types[tid.id];
|
|
215
|
+
}
|
|
216
|
+
nameFor(tid) {
|
|
217
|
+
const typeName = this.typeTables[tid.nsId]?.names[tid.id];
|
|
218
|
+
const namespaceName = this.nsNameById[tid.nsId];
|
|
219
|
+
if (typeName === undefined || namespaceName === undefined) {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
return { namespaceName, typeName };
|
|
223
|
+
}
|
|
224
|
+
resolveType(currentNamespaceName, name) {
|
|
225
|
+
const currentNsId = this.nsIdByName.get(currentNamespaceName);
|
|
226
|
+
if (currentNsId === undefined) {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
const [namespaceName, localName] = splitOptionalNamespace(name);
|
|
230
|
+
const targetNsId = namespaceName === undefined ? currentNsId : this.nsIdByName.get(namespaceName);
|
|
231
|
+
if (targetNsId === undefined) {
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
const id = this.typeTableFor(targetNsId).index.get(localName);
|
|
235
|
+
if (id === undefined) {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
return this.typeTableFor(targetNsId).types[id];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
export { Library };
|
|
242
|
+
//# sourceMappingURL=library.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library.js","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACH,oBAAoB,EAGpB,oBAAoB,EACpB,qBAAqB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAUvD,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAW,EAAE;IACjD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IAEnC,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,2BAA2B,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,UAAqB,CAAC;AACjC,CAAC,CAAC;AAEF,M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O,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACJ;AAED,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { PrimitiveCategory } from \"./primitives.js\";\nimport type { CArrayType, HashTableType, ListType, ParseContext, TypeId } from \"./type-id.js\";\nimport type { GirType } from \"./type.js\";\nimport { callbackFromNode } from \"./callback.js\";\nimport {\n createNamespaceShell,\n type GirNamespace,\n type NamespaceHeader,\n parseNamespaceHeader,\n populateNamespaceBody,\n} from \"./namespace.js\";\nimport { parseGirFile, type RawNode } from \"./parse.js\";\nimport { splitOptionalNamespace } from \"./type-ref.js\";\n\ntype TypeTable = {\n types: (GirType | undefined)[];\n names: (string | undefined)[];\n index: Map<string, number>;\n};\n\ntype DiscoveredNamespace = { header: NamespaceHeader; shell: GirNamespace };\n\nconst INTERNAL_NS_ID = 0;\n\nconst readRepositoryNode = (path: string): RawNode => {\n const root = parseGirFile(path);\n const repository = root.repository;\n\n if (typeof repository !== \"object\" || repository === null) {\n throw new Error(`GIR file at ${path} has no <repository> root`);\n }\n\n return repository as RawNode;\n};\n\nconst locateGirFile = (identifier: string, girPath: string[]): string => {\n const filename = `${identifier}.gir`;\n\n for (const directory of girPath) {\n const candidate = join(directory, filename);\n\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const tried = girPath.map((directory) => join(directory, filename)).join(\", \");\n throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);\n};\n\nclass Library {\n private static drive(library: Library, libraries: string[], girPath: string[]): void {\n const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);\n\n for (const { header, shell } of discovered) {\n populateNamespaceBody(shell, header.namespaceNode, library.parseContext(shell.id));\n }\n\n for (const { shell } of discovered) {\n library.addDeclarations(shell);\n }\n\n library.girFilesValue = girFiles;\n }\n\n static load(libraries: string[], girPath: string[]): Library {\n const library = new Library();\n this.drive(library, libraries, girPath);\n\n return library;\n }\n\n private namespacesByName: Map<string, GirNamespace> = new Map();\n private namespaceById: (GirNamespace | undefined)[] = [];\n private nsNameById: string[] = [];\n private nsIdByName: Map<string, number> = new Map();\n private typeTables: TypeTable[] = [];\n private girFilesValue: string[] = [];\n\n constructor() {\n this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };\n this.namespaceById[INTERNAL_NS_ID] = undefined;\n this.nsNameById[INTERNAL_NS_ID] = \"$internal\";\n }\n\n private ensureNsId(name: string): number {\n const existing = this.nsIdByName.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const nsId = this.typeTables.length;\n this.typeTables[nsId] = { types: [], names: [], index: new Map() };\n this.namespaceById[nsId] = undefined;\n this.nsNameById[nsId] = name;\n this.nsIdByName.set(name, nsId);\n\n return nsId;\n }\n\n private registerNamespace(header: NamespaceHeader): GirNamespace {\n const nsId = this.ensureNsId(header.name);\n const shell = createNamespaceShell(header, nsId);\n this.namespaceById[nsId] = shell;\n this.namespacesByName.set(header.name, shell);\n\n return shell;\n }\n\n private namespaceFor(nsId: number): GirNamespace {\n const namespace = this.namespaceById[nsId];\n\n if (namespace === undefined) {\n throw new Error(`No namespace registered for type table id ${String(nsId)}`);\n }\n\n return namespace;\n }\n\n private typeTableFor(nsId: number): TypeTable {\n const typeTable = this.typeTables[nsId];\n\n if (typeTable === undefined) {\n throw new Error(`No type table for namespace id ${String(nsId)}`);\n }\n\n return typeTable;\n }\n\n private insertIntoTypeTable(\n typeTable: TypeTable,\n slot: { type: GirType | undefined; indexKey?: string; displayName?: string },\n ): number {\n const id = typeTable.types.length;\n typeTable.types.push(slot.type);\n typeTable.names.push(slot.displayName);\n\n if (slot.indexKey !== undefined) {\n typeTable.index.set(slot.indexKey, id);\n }\n\n return id;\n }\n\n private resolveTypeId(nsId: number, name: string, type: GirType | undefined): number {\n const typeTable = this.typeTableFor(nsId);\n const existing = typeTable.index.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n return this.insertIntoTypeTable(typeTable, { type, indexKey: name, displayName: name });\n }\n\n private addType(nsId: number, name: string, type: GirType): void {\n this.typeTableFor(nsId).types[this.resolveTypeId(nsId, name, type)] = type;\n }\n\n private findType(nsId: number, name: string): TypeId {\n return { nsId, id: this.resolveTypeId(nsId, name, undefined) };\n }\n\n private addAnonymousType(nsId: number, type: GirType): TypeId {\n const typeTable = this.typeTableFor(nsId);\n const id = this.insertIntoTypeTable(typeTable, { type });\n\n return { nsId, id };\n }\n\n private findTypeByName(currentNsId: number, name: string): TypeId {\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.ensureNsId(namespaceName);\n\n return this.findType(targetNsId, localName);\n }\n\n private parseContext(nsId: number): ParseContext {\n const context: ParseContext = {\n nsId,\n findType: (name) => this.findTypeByName(nsId, name),\n addPrimitive: (category) => this.addPrimitive(category),\n addVarargs: () => this.addVarargs(),\n addContainer: (type: CArrayType | ListType | HashTableType) => this.addAnonymousType(nsId, type),\n addAnonymousCallback: (node) =>\n this.addAnonymousType(nsId, {\n kind: \"callback\",\n namespace: this.namespaceFor(nsId),\n value: callbackFromNode(node, context),\n }),\n };\n\n return context;\n }\n\n private addPrimitive(category: PrimitiveCategory): TypeId {\n return this.findOrAddContainer(`primitive:${category}`, { kind: \"primitive\", category });\n }\n\n private addVarargs(): TypeId {\n return this.findOrAddContainer(\"varargs\", { kind: \"varargs\" });\n }\n\n private findOrAddContainer(key: string, type: GirType): TypeId {\n const typeTable = this.typeTableFor(INTERNAL_NS_ID);\n const existing = typeTable.index.get(key);\n\n if (existing !== undefined) {\n return { nsId: INTERNAL_NS_ID, id: existing };\n }\n\n const id = this.insertIntoTypeTable(typeTable, { type, indexKey: key });\n\n return { nsId: INTERNAL_NS_ID, id };\n }\n\n private addDeclarations(shell: GirNamespace): void {\n this.addClassDeclarations(shell);\n this.addValueDeclarations(shell);\n }\n\n private addClassDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.classes) {\n this.addType(nsId, value.name, { kind: \"class\", namespace: shell, value });\n }\n\n for (const value of shell.interfaces) {\n this.addType(nsId, value.name, { kind: \"interface\", namespace: shell, value });\n }\n\n for (const value of shell.records) {\n this.addType(nsId, value.name, { kind: \"record\", namespace: shell, value });\n }\n }\n\n private addValueDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.enums) {\n this.addType(nsId, value.name, { kind: \"enum\", namespace: shell, value });\n }\n\n for (const value of shell.callbacks) {\n this.addType(nsId, value.name, { kind: \"callback\", namespace: shell, value });\n }\n\n for (const alias of shell.aliases) {\n this.addType(nsId, alias.name, { kind: \"alias\", namespace: shell, value: alias });\n }\n }\n\n private processIdentifier(input: {\n identifier: string;\n girPath: string[];\n seen: Set<string>;\n queue: string[];\n girFiles: string[];\n discovered: DiscoveredNamespace[];\n }): void {\n const { identifier, girPath, seen, queue, girFiles, discovered } = input;\n const namespaceName = identifier.split(\"-\", 1)[0] ?? identifier;\n\n if (seen.has(namespaceName)) {\n return;\n }\n\n seen.add(namespaceName);\n const path = locateGirFile(identifier, girPath);\n girFiles.push(path);\n const header = parseNamespaceHeader(readRepositoryNode(path));\n const shell = this.registerNamespace(header);\n discovered.push({ header, shell });\n\n for (const include of header.includes) {\n queue.push(`${include.name}-${include.version}`);\n }\n }\n\n private discoverNamespaces(\n libraries: string[],\n girPath: string[],\n ): { discovered: DiscoveredNamespace[]; girFiles: string[] } {\n const queue: string[] = [...libraries];\n const seen: Set<string> = new Set();\n const discovered: DiscoveredNamespace[] = [];\n const girFiles: string[] = [];\n\n while (queue.length > 0) {\n const identifier = queue.shift();\n\n if (identifier !== undefined) {\n this.processIdentifier({ identifier, girPath, seen, queue, girFiles, discovered });\n }\n }\n\n return { discovered, girFiles };\n }\n\n public get namespaces(): Map<string, GirNamespace> {\n return this.namespacesByName;\n }\n\n public get girFiles(): string[] {\n return this.girFilesValue;\n }\n\n typeFor(tid: TypeId): GirType | undefined {\n return this.typeTables[tid.nsId]?.types[tid.id];\n }\n\n nameFor(tid: TypeId): { namespaceName: string; typeName: string } | undefined {\n const typeName = this.typeTables[tid.nsId]?.names[tid.id];\n const namespaceName = this.nsNameById[tid.nsId];\n\n if (typeName === undefined || namespaceName === undefined) {\n return undefined;\n }\n\n return { namespaceName, typeName };\n }\n\n resolveType(currentNamespaceName: string, name: string): GirType | undefined {\n const currentNsId = this.nsIdByName.get(currentNamespaceName);\n\n if (currentNsId === undefined) {\n return undefined;\n }\n\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.nsIdByName.get(namespaceName);\n\n if (targetNsId === undefined) {\n return undefined;\n }\n\n const id = this.typeTableFor(targetNsId).index.get(localName);\n\n if (id === undefined) {\n return undefined;\n }\n\n return this.typeTableFor(targetNsId).types[id];\n }\n}\n\nexport { Library };\n"]}
|
package/dist/gir/namespace.d.ts
CHANGED
|
@@ -1,65 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ParseContext, TypeId } from "./type-id.js";
|
|
2
2
|
import { type GirCallback } from "./callback.js";
|
|
3
3
|
import { type GirClass } from "./class.js";
|
|
4
4
|
import { type GirEnum } from "./enum.js";
|
|
5
5
|
import { type GirFunction } from "./function.js";
|
|
6
6
|
import { type RawNode } from "./parse.js";
|
|
7
|
-
import { type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** Constant value as the raw string from GIR. */
|
|
14
|
-
readonly value: string;
|
|
15
|
-
readonly type: GirTypeRef | undefined;
|
|
7
|
+
import { type GirRecord } from "./record.js";
|
|
8
|
+
type GirConstant = {
|
|
9
|
+
name: string;
|
|
10
|
+
doc: string | undefined;
|
|
11
|
+
value: string;
|
|
12
|
+
type: TypeId | undefined;
|
|
16
13
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
type GirAlias = {
|
|
15
|
+
name: string;
|
|
16
|
+
doc: string | undefined;
|
|
17
|
+
cType: string | undefined;
|
|
18
|
+
target: TypeId | undefined;
|
|
19
|
+
targetCType: string | undefined;
|
|
21
20
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
readonly identifier: string;
|
|
36
|
-
/** Comma-separated `shared-library` value (passed verbatim to `t.fn(...)`). */
|
|
37
|
-
readonly sharedLibrary: string | undefined;
|
|
38
|
-
/** GIR `c:identifier-prefixes` (used to strip type prefixes). */
|
|
39
|
-
readonly cIdentifierPrefixes: readonly string[];
|
|
40
|
-
/** GIR `c:symbol-prefixes` (used to strip function prefixes). */
|
|
41
|
-
readonly cSymbolPrefixes: readonly string[];
|
|
42
|
-
/** Other namespaces referenced via `<include>`. */
|
|
43
|
-
readonly includes: readonly NamespaceInclude[];
|
|
44
|
-
readonly classes: readonly GirClass[];
|
|
45
|
-
readonly interfaces: readonly GirClass[];
|
|
46
|
-
readonly boxeds: readonly GirBoxed[];
|
|
47
|
-
readonly enums: readonly GirEnum[];
|
|
48
|
-
readonly callbacks: readonly GirCallback[];
|
|
49
|
-
readonly functions: readonly GirFunction[];
|
|
50
|
-
readonly constants: readonly GirConstant[];
|
|
51
|
-
readonly aliases: readonly GirAlias[];
|
|
21
|
+
type GirNamespace = {
|
|
22
|
+
id: number;
|
|
23
|
+
name: string;
|
|
24
|
+
sharedLibrary: string | undefined;
|
|
25
|
+
cSymbolPrefixes: string[];
|
|
26
|
+
classes: GirClass[];
|
|
27
|
+
interfaces: GirClass[];
|
|
28
|
+
records: GirRecord[];
|
|
29
|
+
enums: GirEnum[];
|
|
30
|
+
callbacks: GirCallback[];
|
|
31
|
+
functions: GirFunction[];
|
|
32
|
+
constants: GirConstant[];
|
|
33
|
+
aliases: GirAlias[];
|
|
52
34
|
};
|
|
53
|
-
/** A `<include>` entry pointing at another namespace identifier. */
|
|
54
35
|
type NamespaceInclude = {
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
name: string;
|
|
37
|
+
version: string;
|
|
57
38
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
39
|
+
type NamespaceHeader = {
|
|
40
|
+
name: string;
|
|
41
|
+
sharedLibrary: string | undefined;
|
|
42
|
+
cSymbolPrefixes: string[];
|
|
43
|
+
includes: NamespaceInclude[];
|
|
44
|
+
namespaceNode: RawNode;
|
|
45
|
+
};
|
|
46
|
+
declare const namespaceDirectory: (namespace: Pick<GirNamespace, "name">) => string;
|
|
47
|
+
declare const parseNamespaceHeader: (repositoryNode: RawNode) => NamespaceHeader;
|
|
48
|
+
declare const createNamespaceShell: (header: NamespaceHeader, id: number) => GirNamespace;
|
|
49
|
+
declare const populateNamespaceBody: (shell: GirNamespace, namespaceNode: RawNode, context: ParseContext) => void;
|
|
50
|
+
export { namespaceDirectory, parseNamespaceHeader, createNamespaceShell, populateNamespaceBody, type GirConstant, type GirAlias, type GirNamespace, type NamespaceHeader, };
|
|
65
51
|
//# sourceMappingURL=namespace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../src/gir/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,CA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SAAS,CAAC;IAClC,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,QAAA,MAAM,kBAAkB,GAAI,WAAW,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,KAAG,MAAsC,CAAC;AAE3G,QAAA,MAAM,oBAAoB,GAAI,gBAAgB,OAAO,KAAG,eAmBvD,CAAC;AAEF,QAAA,MAAM,oBAAoB,GAAI,QAAQ,eAAe,EAAE,IAAI,MAAM,KAAG,YAalE,CAAC;AAEH,QAAA,MAAM,qBAAqB,GAAI,OAAO,YAAY,EAAE,eAAe,OAAO,EAAE,SAAS,YAAY,KAAG,IAsBnG,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,60 +1,71 @@
|
|
|
1
|
-
import { boxedFromNode, boxedKind } from "./boxed.js";
|
|
2
1
|
import { callbackFromNode } from "./callback.js";
|
|
3
2
|
import { classFromNode } from "./class.js";
|
|
4
3
|
import { enumFromNode } from "./enum.js";
|
|
5
4
|
import { functionFromNode } from "./function.js";
|
|
6
|
-
import { attr,
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export const namespaceFromRepository = (repositoryNode) => {
|
|
14
|
-
const includes = childrenOf(repositoryNode, "include").map((include) => ({
|
|
15
|
-
name: attr(include, "name") ?? "",
|
|
5
|
+
import { attr, getChild, getChildren, getDoc, nameAttr } from "./parse.js";
|
|
6
|
+
import { isVtableRecord, recordFromNode } from "./record.js";
|
|
7
|
+
import { typeRefFromNode } from "./type-ref.js";
|
|
8
|
+
const namespaceDirectory = (namespace) => namespace.name.toLowerCase();
|
|
9
|
+
const parseNamespaceHeader = (repositoryNode) => {
|
|
10
|
+
const includes = getChildren(repositoryNode, "include").map((include) => ({
|
|
11
|
+
name: nameAttr(include),
|
|
16
12
|
version: attr(include, "version") ?? "",
|
|
17
13
|
}));
|
|
18
|
-
const namespaceNode =
|
|
14
|
+
const namespaceNode = getChildren(repositoryNode, "namespace")[0];
|
|
19
15
|
if (namespaceNode === undefined) {
|
|
20
16
|
throw new Error("GIR repository has no <namespace> child");
|
|
21
17
|
}
|
|
22
|
-
const name = attr(namespaceNode, "name") ?? "";
|
|
23
|
-
const version = attr(namespaceNode, "version") ?? "";
|
|
24
18
|
return {
|
|
25
|
-
name,
|
|
26
|
-
version,
|
|
27
|
-
identifier: `${name}-${version}`,
|
|
19
|
+
name: nameAttr(namespaceNode),
|
|
28
20
|
sharedLibrary: attr(namespaceNode, "shared-library"),
|
|
29
|
-
cIdentifierPrefixes: splitPrefixes(attr(namespaceNode, "c:identifier-prefixes")),
|
|
30
21
|
cSymbolPrefixes: splitPrefixes(attr(namespaceNode, "c:symbol-prefixes")),
|
|
31
22
|
includes,
|
|
32
|
-
|
|
33
|
-
interfaces: childrenOf(namespaceNode, "interface").map((iface) => classFromNode(iface, true)),
|
|
34
|
-
boxeds: collectBoxeds(namespaceNode),
|
|
35
|
-
enums: collectEnums(namespaceNode),
|
|
36
|
-
callbacks: childrenOf(namespaceNode, "callback").map(callbackFromNode),
|
|
37
|
-
functions: childrenOf(namespaceNode, "function").map((fn) => functionFromNode(fn, "function")),
|
|
38
|
-
constants: childrenOf(namespaceNode, "constant").map((constant) => ({
|
|
39
|
-
name: attr(constant, "name") ?? "",
|
|
40
|
-
cType: attr(constant, "c:type"),
|
|
41
|
-
cIdentifier: attr(constant, "c:identifier"),
|
|
42
|
-
value: attr(constant, "value") ?? "",
|
|
43
|
-
type: typeRefFromSlot(constant),
|
|
44
|
-
})),
|
|
45
|
-
aliases: childrenOf(namespaceNode, "alias").map((alias) => ({
|
|
46
|
-
name: attr(alias, "name") ?? "",
|
|
47
|
-
target: typeRefFromSlot(alias),
|
|
48
|
-
})),
|
|
23
|
+
namespaceNode,
|
|
49
24
|
};
|
|
50
25
|
};
|
|
26
|
+
const createNamespaceShell = (header, id) => ({
|
|
27
|
+
id,
|
|
28
|
+
name: header.name,
|
|
29
|
+
sharedLibrary: header.sharedLibrary,
|
|
30
|
+
cSymbolPrefixes: header.cSymbolPrefixes,
|
|
31
|
+
classes: [],
|
|
32
|
+
interfaces: [],
|
|
33
|
+
records: [],
|
|
34
|
+
enums: [],
|
|
35
|
+
callbacks: [],
|
|
36
|
+
functions: [],
|
|
37
|
+
constants: [],
|
|
38
|
+
aliases: [],
|
|
39
|
+
});
|
|
40
|
+
const populateNamespaceBody = (shell, namespaceNode, context) => {
|
|
41
|
+
shell.classes = getChildren(namespaceNode, "class").map((klass) => classFromNode(klass, false, context));
|
|
42
|
+
shell.interfaces = getChildren(namespaceNode, "interface").map((iface) => classFromNode(iface, true, context));
|
|
43
|
+
shell.records = collectRecords(namespaceNode, context);
|
|
44
|
+
shell.enums = collectEnums(namespaceNode);
|
|
45
|
+
shell.callbacks = getChildren(namespaceNode, "callback").map((callback) => callbackFromNode(callback, context));
|
|
46
|
+
shell.functions = getChildren(namespaceNode, "function").map((fn) => functionFromNode(fn, context));
|
|
47
|
+
shell.constants = getChildren(namespaceNode, "constant").map((constant) => ({
|
|
48
|
+
name: nameAttr(constant),
|
|
49
|
+
doc: getDoc(constant),
|
|
50
|
+
value: attr(constant, "value") ?? "",
|
|
51
|
+
type: typeRefFromNode(constant, context),
|
|
52
|
+
}));
|
|
53
|
+
shell.aliases = getChildren(namespaceNode, "alias").map((alias) => ({
|
|
54
|
+
name: nameAttr(alias),
|
|
55
|
+
doc: getDoc(alias),
|
|
56
|
+
cType: attr(alias, "c:type"),
|
|
57
|
+
target: typeRefFromNode(alias, context),
|
|
58
|
+
targetCType: attr(getChild(alias, "type"), "c:type"),
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
51
61
|
const splitPrefixes = (raw) => (raw ?? "").split(",").filter((prefix) => prefix.length > 0);
|
|
52
|
-
const
|
|
53
|
-
...
|
|
54
|
-
...
|
|
62
|
+
const collectRecords = (namespaceNode, context) => [
|
|
63
|
+
...getChildren(namespaceNode, "record").map((record) => recordFromNode(record, isVtableRecord(record), false, context)),
|
|
64
|
+
...getChildren(namespaceNode, "union").map((union) => recordFromNode(union, isVtableRecord(union), true, context)),
|
|
55
65
|
];
|
|
56
66
|
const collectEnums = (namespaceNode) => [
|
|
57
|
-
...
|
|
58
|
-
...
|
|
67
|
+
...getChildren(namespaceNode, "enumeration").map((enumeration) => enumFromNode(enumeration, "enumeration")),
|
|
68
|
+
...getChildren(namespaceNode, "bitfield").map((bitfield) => enumFromNode(bitfield, "bitfield")),
|
|
59
69
|
];
|
|
70
|
+
export { namespaceDirectory, parseNamespaceHeader, createNamespaceShell, populateNamespaceBody, };
|
|
60
71
|
//# sourceMappingURL=namespace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../src/gir/namespace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../src/gir/namespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAgB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAoB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AACzF,OAAO,EAAkB,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA6ChD,MAAM,kB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AW,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullable-overrides.d.ts","sourceRoot":"","sources":["../../src/gir/nullable-overrides.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,sCAAsC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAEhE,CAAC;AAEH,OAAO,EAAE,sCAAsC,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullable-overrides.js","sourceRoot":"","sources":["../../src/gir/nullable-overrides.ts"],"names":[],"mappings":"AAAA,MAAM,sCAAsC,GAA0B,IAAI,GAAG,CAAC;IAC1E,CAAC,sCAAsC,EAAE,CAAC,WAAW,CAAC,CAAC;CAC1D,CAAC,CAAC;AAEH,OAAO,EAAE,sCAAsC,EAAE,CAAC","sourcesContent":["const PARAMETERS_MISSING_NULLABLE_ANNOTATION: Map<string, string[]> = new Map([\n [\"gtk_fixed_layout_child_set_transform\", [\"transform\"]],\n]);\n\nexport { PARAMETERS_MISSING_NULLABLE_ANNOTATION };\n"]}
|