@ts-for-gir/cli 3.0.0-beta.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +160 -35
- package/lib/commands/doc.d.ts +1 -17
- package/lib/commands/doc.js +7 -13
- package/lib/commands/doc.js.map +1 -1
- package/lib/commands/generate.d.ts +1 -37
- package/lib/commands/generate.js +8 -24
- package/lib/commands/generate.js.map +1 -1
- package/lib/commands/list.d.ts +1 -11
- package/lib/commands/list.js +6 -10
- package/lib/commands/list.js.map +1 -1
- package/lib/config.d.ts +21 -5
- package/lib/config.js +164 -86
- package/lib/config.js.map +1 -1
- package/lib/generation-handler.d.ts +3 -4
- package/lib/generation-handler.js +7 -11
- package/lib/generation-handler.js.map +1 -1
- package/lib/index.d.ts +0 -12
- package/lib/index.js +0 -12
- package/lib/index.js.map +1 -1
- package/lib/module-loader.d.ts +35 -24
- package/lib/module-loader.js +3 -8
- package/lib/module-loader.js.map +1 -1
- package/lib/utils.d.ts +0 -262
- package/lib/utils.js +8 -371
- package/lib/utils.js.map +1 -1
- package/package.json +32 -37
- package/src/commands/doc.ts +9 -14
- package/src/commands/generate.ts +10 -24
- package/src/commands/list.ts +8 -10
- package/src/config.ts +178 -92
- package/src/generation-handler.ts +11 -12
- package/src/index.ts +0 -12
- package/src/module-loader.ts +39 -31
- package/src/utils.ts +8 -401
- package/lib/conflict-resolver.d.ts +0 -155
- package/lib/conflict-resolver.js +0 -1103
- package/lib/conflict-resolver.js.map +0 -1
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- package/lib/constants.js.map +0 -1
- package/lib/dependency-manager.d.ts +0 -34
- package/lib/dependency-manager.js +0 -78
- package/lib/dependency-manager.js.map +0 -1
- package/lib/generator.d.ts +0 -5
- package/lib/generator.js +0 -2
- package/lib/generator.js.map +0 -1
- package/lib/gir-factory.d.ts +0 -51
- package/lib/gir-factory.js +0 -361
- package/lib/gir-factory.js.map +0 -1
- package/lib/gir-module.d.ts +0 -257
- package/lib/gir-module.js +0 -2086
- package/lib/gir-module.js.map +0 -1
- package/lib/html-doc-generator.d.ts +0 -13
- package/lib/html-doc-generator.js +0 -18
- package/lib/html-doc-generator.js.map +0 -1
- package/lib/injection/callbacks/gjs/Gio-2.0.d.ts +0 -2
- package/lib/injection/callbacks/gjs/Gio-2.0.js +0 -36
- package/lib/injection/callbacks/gjs/Gio-2.0.js.map +0 -1
- package/lib/injection/callbacks/gjs/index.d.ts +0 -2
- package/lib/injection/callbacks/gjs/index.js +0 -3
- package/lib/injection/callbacks/gjs/index.js.map +0 -1
- package/lib/injection/callbacks/index.d.ts +0 -4
- package/lib/injection/callbacks/index.js +0 -4
- package/lib/injection/callbacks/index.js.map +0 -1
- package/lib/injection/callbacks/node-gtk/index.d.ts +0 -2
- package/lib/injection/callbacks/node-gtk/index.js +0 -2
- package/lib/injection/callbacks/node-gtk/index.js.map +0 -1
- package/lib/injection/classes/GLib-2-0.d.ts +0 -2
- package/lib/injection/classes/GLib-2-0.js +0 -35
- package/lib/injection/classes/GLib-2-0.js.map +0 -1
- package/lib/injection/classes/gjs/GLib-2.0.d.ts +0 -2
- package/lib/injection/classes/gjs/GLib-2.0.js +0 -200
- package/lib/injection/classes/gjs/GLib-2.0.js.map +0 -1
- package/lib/injection/classes/gjs/GObject-2.0.d.ts +0 -2
- package/lib/injection/classes/gjs/GObject-2.0.js +0 -634
- package/lib/injection/classes/gjs/GObject-2.0.js.map +0 -1
- package/lib/injection/classes/gjs/Gio-2.0.d.ts +0 -5
- package/lib/injection/classes/gjs/Gio-2.0.js +0 -218
- package/lib/injection/classes/gjs/Gio-2.0.js.map +0 -1
- package/lib/injection/classes/gjs/index.d.ts +0 -2
- package/lib/injection/classes/gjs/index.js +0 -5
- package/lib/injection/classes/gjs/index.js.map +0 -1
- package/lib/injection/classes/index.d.ts +0 -4
- package/lib/injection/classes/index.js +0 -5
- package/lib/injection/classes/index.js.map +0 -1
- package/lib/injection/classes/node-gtk/GLib-2.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/GLib-2.0.js +0 -19
- package/lib/injection/classes/node-gtk/GLib-2.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/GObject-2.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/GObject-2.0.js +0 -66
- package/lib/injection/classes/node-gtk/GObject-2.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Gdk-4.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Gdk-4.0.js +0 -32
- package/lib/injection/classes/node-gtk/Gdk-4.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Gio-2.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Gio-2.0.js +0 -14
- package/lib/injection/classes/node-gtk/Gio-2.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Graphene-1.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Graphene-1.0.js +0 -133
- package/lib/injection/classes/node-gtk/Graphene-1.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Gtk-3.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Gtk-3.0.js +0 -31
- package/lib/injection/classes/node-gtk/Gtk-3.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Gtk-4.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Gtk-4.0.js +0 -52
- package/lib/injection/classes/node-gtk/Gtk-4.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Pango-1.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Pango-1.0.js +0 -31
- package/lib/injection/classes/node-gtk/Pango-1.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/index.d.ts +0 -2
- package/lib/injection/classes/node-gtk/index.js +0 -19
- package/lib/injection/classes/node-gtk/index.js.map +0 -1
- package/lib/injection/index.d.ts +0 -3
- package/lib/injection/index.js +0 -4
- package/lib/injection/index.js.map +0 -1
- package/lib/injection/injector.d.ts +0 -17
- package/lib/injection/injector.js +0 -139
- package/lib/injection/injector.js.map +0 -1
- package/lib/logger.d.ts +0 -36
- package/lib/logger.js +0 -137
- package/lib/logger.js.map +0 -1
- package/lib/messages.d.ts +0 -31
- package/lib/messages.js +0 -46
- package/lib/messages.js.map +0 -1
- package/lib/symtable.d.ts +0 -24
- package/lib/symtable.js +0 -63
- package/lib/symtable.js.map +0 -1
- package/lib/template-processor.d.ts +0 -74
- package/lib/template-processor.js +0 -165
- package/lib/template-processor.js.map +0 -1
- package/lib/transformation.d.ts +0 -156
- package/lib/transformation.js +0 -523
- package/lib/transformation.js.map +0 -1
- package/lib/type-definition-generator.d.ts +0 -116
- package/lib/type-definition-generator.js +0 -991
- package/lib/type-definition-generator.js.map +0 -1
- package/lib/types/answer-version.d.ts +0 -4
- package/lib/types/answer-version.js +0 -2
- package/lib/types/answer-version.js.map +0 -1
- package/lib/types/build-type.d.ts +0 -1
- package/lib/types/build-type.js +0 -2
- package/lib/types/build-type.js.map +0 -1
- package/lib/types/class-parent.d.ts +0 -13
- package/lib/types/class-parent.js +0 -2
- package/lib/types/class-parent.js.map +0 -1
- package/lib/types/config-flags.d.ts +0 -4
- package/lib/types/config-flags.js +0 -2
- package/lib/types/config-flags.js.map +0 -1
- package/lib/types/conflict-child-element.d.ts +0 -10
- package/lib/types/conflict-child-element.js +0 -2
- package/lib/types/conflict-child-element.js.map +0 -1
- package/lib/types/conflict-grouped-element.d.ts +0 -6
- package/lib/types/conflict-grouped-element.js +0 -2
- package/lib/types/conflict-grouped-element.js.map +0 -1
- package/lib/types/conflict-grouped-elements.d.ts +0 -4
- package/lib/types/conflict-grouped-elements.js +0 -2
- package/lib/types/conflict-grouped-elements.js.map +0 -1
- package/lib/types/construct-name.d.ts +0 -1
- package/lib/types/construct-name.js +0 -2
- package/lib/types/construct-name.js.map +0 -1
- package/lib/types/dependency-map.d.ts +0 -4
- package/lib/types/dependency-map.js +0 -2
- package/lib/types/dependency-map.js.map +0 -1
- package/lib/types/dependency.d.ts +0 -15
- package/lib/types/dependency.js +0 -2
- package/lib/types/dependency.js.map +0 -1
- package/lib/types/environment.d.ts +0 -1
- package/lib/types/environment.js +0 -2
- package/lib/types/environment.js.map +0 -1
- package/lib/types/file-info.d.ts +0 -14
- package/lib/types/file-info.js +0 -2
- package/lib/types/file-info.js.map +0 -1
- package/lib/types/generate-config.d.ts +0 -32
- package/lib/types/generate-config.js +0 -2
- package/lib/types/generate-config.js.map +0 -1
- package/lib/types/generator-type.d.ts +0 -4
- package/lib/types/generator-type.js +0 -6
- package/lib/types/generator-type.js.map +0 -1
- package/lib/types/gir-alias-element.d.ts +0 -13
- package/lib/types/gir-alias-element.js +0 -2
- package/lib/types/gir-alias-element.js.map +0 -1
- package/lib/types/gir-annotation.d.ts +0 -9
- package/lib/types/gir-annotation.js +0 -2
- package/lib/types/gir-annotation.js.map +0 -1
- package/lib/types/gir-any-element.d.ts +0 -2
- package/lib/types/gir-any-element.js +0 -2
- package/lib/types/gir-any-element.js.map +0 -1
- package/lib/types/gir-any-type.d.ts +0 -5
- package/lib/types/gir-any-type.js +0 -2
- package/lib/types/gir-any-type.js.map +0 -1
- package/lib/types/gir-array-type.d.ts +0 -20
- package/lib/types/gir-array-type.js +0 -3
- package/lib/types/gir-array-type.js.map +0 -1
- package/lib/types/gir-bitfield-element.d.ts +0 -17
- package/lib/types/gir-bitfield-element.js +0 -2
- package/lib/types/gir-bitfield-element.js.map +0 -1
- package/lib/types/gir-boolean.d.ts +0 -1
- package/lib/types/gir-boolean.js +0 -2
- package/lib/types/gir-boolean.js.map +0 -1
- package/lib/types/gir-boxed-element.d.ts +0 -15
- package/lib/types/gir-boxed-element.js +0 -2
- package/lib/types/gir-boxed-element.js.map +0 -1
- package/lib/types/gir-c-include.d.ts +0 -7
- package/lib/types/gir-c-include.js +0 -2
- package/lib/types/gir-c-include.js.map +0 -1
- package/lib/types/gir-callable-attrs.d.ts +0 -15
- package/lib/types/gir-callable-attrs.js +0 -3
- package/lib/types/gir-callable-attrs.js.map +0 -1
- package/lib/types/gir-callable-param-element.d.ts +0 -30
- package/lib/types/gir-callable-param-element.js +0 -2
- package/lib/types/gir-callable-param-element.js.map +0 -1
- package/lib/types/gir-callable-param.d.ts +0 -7
- package/lib/types/gir-callable-param.js +0 -2
- package/lib/types/gir-callable-param.js.map +0 -1
- package/lib/types/gir-callable-return.d.ts +0 -22
- package/lib/types/gir-callable-return.js +0 -2
- package/lib/types/gir-callable-return.js.map +0 -1
- package/lib/types/gir-callback-element.d.ts +0 -15
- package/lib/types/gir-callback-element.js +0 -2
- package/lib/types/gir-callback-element.js.map +0 -1
- package/lib/types/gir-class-element.d.ts +0 -48
- package/lib/types/gir-class-element.js +0 -2
- package/lib/types/gir-class-element.js.map +0 -1
- package/lib/types/gir-constant-element.d.ts +0 -15
- package/lib/types/gir-constant-element.js +0 -2
- package/lib/types/gir-constant-element.js.map +0 -1
- package/lib/types/gir-constructor-element.d.ts +0 -8
- package/lib/types/gir-constructor-element.js +0 -2
- package/lib/types/gir-constructor-element.js.map +0 -1
- package/lib/types/gir-direction.d.ts +0 -5
- package/lib/types/gir-direction.js +0 -7
- package/lib/types/gir-direction.js.map +0 -1
- package/lib/types/gir-doc-element.d.ts +0 -68
- package/lib/types/gir-doc-element.js +0 -2
- package/lib/types/gir-doc-element.js.map +0 -1
- package/lib/types/gir-enum-element.d.ts +0 -19
- package/lib/types/gir-enum-element.js +0 -2
- package/lib/types/gir-enum-element.js.map +0 -1
- package/lib/types/gir-field-element.d.ts +0 -18
- package/lib/types/gir-field-element.js +0 -2
- package/lib/types/gir-field-element.js.map +0 -1
- package/lib/types/gir-function-element.d.ts +0 -8
- package/lib/types/gir-function-element.js +0 -2
- package/lib/types/gir-function-element.js.map +0 -1
- package/lib/types/gir-implements.d.ts +0 -8
- package/lib/types/gir-implements.js +0 -2
- package/lib/types/gir-implements.js.map +0 -1
- package/lib/types/gir-include.d.ts +0 -9
- package/lib/types/gir-include.js +0 -2
- package/lib/types/gir-include.js.map +0 -1
- package/lib/types/gir-info-attrs.d.ts +0 -13
- package/lib/types/gir-info-attrs.js +0 -2
- package/lib/types/gir-info-attrs.js.map +0 -1
- package/lib/types/gir-info-elements.d.ts +0 -5
- package/lib/types/gir-info-elements.js +0 -2
- package/lib/types/gir-info-elements.js.map +0 -1
- package/lib/types/gir-instance-parameter.d.ts +0 -21
- package/lib/types/gir-instance-parameter.js +0 -2
- package/lib/types/gir-instance-parameter.js.map +0 -1
- package/lib/types/gir-interface-element.d.ts +0 -31
- package/lib/types/gir-interface-element.js +0 -2
- package/lib/types/gir-interface-element.js.map +0 -1
- package/lib/types/gir-member-element.d.ts +0 -17
- package/lib/types/gir-member-element.js +0 -2
- package/lib/types/gir-member-element.js.map +0 -1
- package/lib/types/gir-method-element.d.ts +0 -13
- package/lib/types/gir-method-element.js +0 -2
- package/lib/types/gir-method-element.js.map +0 -1
- package/lib/types/gir-module-resolved-by.d.ts +0 -10
- package/lib/types/gir-module-resolved-by.js +0 -2
- package/lib/types/gir-module-resolved-by.js.map +0 -1
- package/lib/types/gir-modules-grouped-map.d.ts +0 -4
- package/lib/types/gir-modules-grouped-map.js +0 -2
- package/lib/types/gir-modules-grouped-map.js.map +0 -1
- package/lib/types/gir-modules-grouped.d.ts +0 -12
- package/lib/types/gir-modules-grouped.js +0 -2
- package/lib/types/gir-modules-grouped.js.map +0 -1
- package/lib/types/gir-namespace.d.ts +0 -30
- package/lib/types/gir-namespace.js +0 -2
- package/lib/types/gir-namespace.js.map +0 -1
- package/lib/types/gir-package.d.ts +0 -7
- package/lib/types/gir-package.js +0 -2
- package/lib/types/gir-package.js.map +0 -1
- package/lib/types/gir-prerequisite.d.ts +0 -5
- package/lib/types/gir-prerequisite.js +0 -2
- package/lib/types/gir-prerequisite.js.map +0 -1
- package/lib/types/gir-property-element.d.ts +0 -21
- package/lib/types/gir-property-element.js +0 -2
- package/lib/types/gir-property-element.js.map +0 -1
- package/lib/types/gir-record-element.d.ts +0 -30
- package/lib/types/gir-record-element.js +0 -2
- package/lib/types/gir-record-element.js.map +0 -1
- package/lib/types/gir-repository.d.ts +0 -16
- package/lib/types/gir-repository.js +0 -2
- package/lib/types/gir-repository.js.map +0 -1
- package/lib/types/gir-signal.d.ts +0 -25
- package/lib/types/gir-signal.js +0 -2
- package/lib/types/gir-signal.js.map +0 -1
- package/lib/types/gir-transfer-ownership-type.d.ts +0 -5
- package/lib/types/gir-transfer-ownership-type.js +0 -7
- package/lib/types/gir-transfer-ownership-type.js.map +0 -1
- package/lib/types/gir-transfer-ownership.d.ts +0 -5
- package/lib/types/gir-transfer-ownership.js +0 -2
- package/lib/types/gir-transfer-ownership.js.map +0 -1
- package/lib/types/gir-type.d.ts +0 -14
- package/lib/types/gir-type.js +0 -2
- package/lib/types/gir-type.js.map +0 -1
- package/lib/types/gir-union-element.d.ts +0 -22
- package/lib/types/gir-union-element.js +0 -2
- package/lib/types/gir-union-element.js.map +0 -1
- package/lib/types/gir-unparsed-number.d.ts +0 -2
- package/lib/types/gir-unparsed-number.js +0 -2
- package/lib/types/gir-unparsed-number.js.map +0 -1
- package/lib/types/gir-var-args.d.ts +0 -5
- package/lib/types/gir-var-args.js +0 -2
- package/lib/types/gir-var-args.js.map +0 -1
- package/lib/types/gir-virtual-method.d.ts +0 -10
- package/lib/types/gir-virtual-method.js +0 -2
- package/lib/types/gir-virtual-method.js.map +0 -1
- package/lib/types/index.d.ts +0 -119
- package/lib/types/index.js +0 -120
- package/lib/types/index.js.map +0 -1
- package/lib/types/inheritance-table.d.ts +0 -3
- package/lib/types/inheritance-table.js +0 -2
- package/lib/types/inheritance-table.js.map +0 -1
- package/lib/types/injection-callback.d.ts +0 -16
- package/lib/types/injection-callback.js +0 -2
- package/lib/types/injection-callback.js.map +0 -1
- package/lib/types/injection-class.d.ts +0 -25
- package/lib/types/injection-class.js +0 -2
- package/lib/types/injection-class.js.map +0 -1
- package/lib/types/injection-function.d.ts +0 -7
- package/lib/types/injection-function.js +0 -2
- package/lib/types/injection-function.js.map +0 -1
- package/lib/types/injection-generic-parameter.d.ts +0 -2
- package/lib/types/injection-generic-parameter.js +0 -2
- package/lib/types/injection-generic-parameter.js.map +0 -1
- package/lib/types/injection-instance-parameter.d.ts +0 -2
- package/lib/types/injection-instance-parameter.js +0 -2
- package/lib/types/injection-instance-parameter.js.map +0 -1
- package/lib/types/injection-parameter.d.ts +0 -8
- package/lib/types/injection-parameter.js +0 -2
- package/lib/types/injection-parameter.js.map +0 -1
- package/lib/types/injection-property.d.ts +0 -4
- package/lib/types/injection-property.js +0 -2
- package/lib/types/injection-property.js.map +0 -1
- package/lib/types/injection-type.d.ts +0 -2
- package/lib/types/injection-type.js +0 -2
- package/lib/types/injection-type.js.map +0 -1
- package/lib/types/injection.d.ts +0 -5
- package/lib/types/injection.js +0 -2
- package/lib/types/injection.js.map +0 -1
- package/lib/types/local-name-check.d.ts +0 -4
- package/lib/types/local-name-check.js +0 -2
- package/lib/types/local-name-check.js.map +0 -1
- package/lib/types/local-name-type.d.ts +0 -1
- package/lib/types/local-name-type.js +0 -2
- package/lib/types/local-name-type.js.map +0 -1
- package/lib/types/local-name.d.ts +0 -7
- package/lib/types/local-name.js +0 -2
- package/lib/types/local-name.js.map +0 -1
- package/lib/types/local-names.d.ts +0 -4
- package/lib/types/local-names.js +0 -2
- package/lib/types/local-names.js.map +0 -1
- package/lib/types/module-type.d.ts +0 -1
- package/lib/types/module-type.js +0 -2
- package/lib/types/module-type.js.map +0 -1
- package/lib/types/parsed-gir.d.ts +0 -4
- package/lib/types/parsed-gir.js +0 -2
- package/lib/types/parsed-gir.js.map +0 -1
- package/lib/types/part-of-class.d.ts +0 -7
- package/lib/types/part-of-class.js +0 -2
- package/lib/types/part-of-class.js.map +0 -1
- package/lib/types/part-of-module.d.ts +0 -6
- package/lib/types/part-of-module.js +0 -2
- package/lib/types/part-of-module.js.map +0 -1
- package/lib/types/promisify-func.d.ts +0 -5
- package/lib/types/promisify-func.js +0 -2
- package/lib/types/promisify-func.js.map +0 -1
- package/lib/types/resolve-type.d.ts +0 -4
- package/lib/types/resolve-type.js +0 -6
- package/lib/types/resolve-type.js.map +0 -1
- package/lib/types/sym-table-items.d.ts +0 -4
- package/lib/types/sym-table-items.js +0 -2
- package/lib/types/sym-table-items.js.map +0 -1
- package/lib/types/transformation-case.d.ts +0 -1
- package/lib/types/transformation-case.js +0 -2
- package/lib/types/transformation-case.js.map +0 -1
- package/lib/types/transformations.d.ts +0 -11
- package/lib/types/transformations.js +0 -2
- package/lib/types/transformations.js.map +0 -1
- package/lib/types/ts-alias.d.ts +0 -10
- package/lib/types/ts-alias.js +0 -2
- package/lib/types/ts-alias.js.map +0 -1
- package/lib/types/ts-callback-interface.d.ts +0 -10
- package/lib/types/ts-callback-interface.js +0 -2
- package/lib/types/ts-callback-interface.js.map +0 -1
- package/lib/types/ts-callback.d.ts +0 -17
- package/lib/types/ts-callback.js +0 -2
- package/lib/types/ts-callback.js.map +0 -1
- package/lib/types/ts-class.d.ts +0 -85
- package/lib/types/ts-class.js +0 -2
- package/lib/types/ts-class.js.map +0 -1
- package/lib/types/ts-doc-tag.d.ts +0 -21
- package/lib/types/ts-doc-tag.js +0 -2
- package/lib/types/ts-doc-tag.js.map +0 -1
- package/lib/types/ts-doc.d.ts +0 -20
- package/lib/types/ts-doc.js +0 -2
- package/lib/types/ts-doc.js.map +0 -1
- package/lib/types/ts-enum.d.ts +0 -12
- package/lib/types/ts-enum.js +0 -2
- package/lib/types/ts-enum.js.map +0 -1
- package/lib/types/ts-function.d.ts +0 -44
- package/lib/types/ts-function.js +0 -2
- package/lib/types/ts-function.js.map +0 -1
- package/lib/types/ts-generic-parameter.d.ts +0 -8
- package/lib/types/ts-generic-parameter.js +0 -2
- package/lib/types/ts-generic-parameter.js.map +0 -1
- package/lib/types/ts-instance-parameter.d.ts +0 -4
- package/lib/types/ts-instance-parameter.js +0 -2
- package/lib/types/ts-instance-parameter.js.map +0 -1
- package/lib/types/ts-member.d.ts +0 -10
- package/lib/types/ts-member.js +0 -2
- package/lib/types/ts-member.js.map +0 -1
- package/lib/types/ts-method.d.ts +0 -5
- package/lib/types/ts-method.js +0 -2
- package/lib/types/ts-method.js.map +0 -1
- package/lib/types/ts-parameter.d.ts +0 -15
- package/lib/types/ts-parameter.js +0 -2
- package/lib/types/ts-parameter.js.map +0 -1
- package/lib/types/ts-property.d.ts +0 -17
- package/lib/types/ts-property.js +0 -2
- package/lib/types/ts-property.js.map +0 -1
- package/lib/types/ts-signal.d.ts +0 -17
- package/lib/types/ts-signal.js +0 -2
- package/lib/types/ts-signal.js.map +0 -1
- package/lib/types/ts-type-name.d.ts +0 -1
- package/lib/types/ts-type-name.js +0 -2
- package/lib/types/ts-type-name.js.map +0 -1
- package/lib/types/ts-type-separator.d.ts +0 -1
- package/lib/types/ts-type-separator.js +0 -2
- package/lib/types/ts-type-separator.js.map +0 -1
- package/lib/types/ts-type.d.ts +0 -22
- package/lib/types/ts-type.js +0 -2
- package/lib/types/ts-type.js.map +0 -1
- package/lib/types/ts-var.d.ts +0 -17
- package/lib/types/ts-var.js +0 -2
- package/lib/types/ts-var.js.map +0 -1
- package/lib/types/type-gir-alias.d.ts +0 -2
- package/lib/types/type-gir-alias.js +0 -2
- package/lib/types/type-gir-alias.js.map +0 -1
- package/lib/types/type-gir-class.d.ts +0 -2
- package/lib/types/type-gir-class.js +0 -2
- package/lib/types/type-gir-class.js.map +0 -1
- package/lib/types/type-gir-element.d.ts +0 -3
- package/lib/types/type-gir-element.js +0 -2
- package/lib/types/type-gir-element.js.map +0 -1
- package/lib/types/type-gir-enumeration-member.d.ts +0 -2
- package/lib/types/type-gir-enumeration-member.js +0 -2
- package/lib/types/type-gir-enumeration-member.js.map +0 -1
- package/lib/types/type-gir-enumeration.d.ts +0 -2
- package/lib/types/type-gir-enumeration.js +0 -2
- package/lib/types/type-gir-enumeration.js.map +0 -1
- package/lib/types/type-gir-function.d.ts +0 -1
- package/lib/types/type-gir-function.js +0 -2
- package/lib/types/type-gir-function.js.map +0 -1
- package/lib/types/type-gir-interface.d.ts +0 -2
- package/lib/types/type-gir-interface.js +0 -2
- package/lib/types/type-gir-interface.js.map +0 -1
- package/lib/types/type-gir-method.d.ts +0 -2
- package/lib/types/type-gir-method.js +0 -2
- package/lib/types/type-gir-method.js.map +0 -1
- package/lib/types/type-gir-parameter.d.ts +0 -1
- package/lib/types/type-gir-parameter.js +0 -2
- package/lib/types/type-gir-parameter.js.map +0 -1
- package/lib/types/type-gir-property.d.ts +0 -2
- package/lib/types/type-gir-property.js +0 -2
- package/lib/types/type-gir-property.js.map +0 -1
- package/lib/types/type-gir-variable.d.ts +0 -1
- package/lib/types/type-gir-variable.js +0 -2
- package/lib/types/type-gir-variable.js.map +0 -1
- package/lib/types/type-ts-element.d.ts +0 -3
- package/lib/types/type-ts-element.js +0 -2
- package/lib/types/type-ts-element.js.map +0 -1
- package/lib/types/type-ts-enumeration-member.d.ts +0 -2
- package/lib/types/type-ts-enumeration-member.js +0 -2
- package/lib/types/type-ts-enumeration-member.js.map +0 -1
- package/lib/types/type-ts-function.d.ts +0 -1
- package/lib/types/type-ts-function.js +0 -2
- package/lib/types/type-ts-function.js.map +0 -1
- package/lib/types/type-ts-property.d.ts +0 -1
- package/lib/types/type-ts-property.js +0 -2
- package/lib/types/type-ts-property.js.map +0 -1
- package/lib/types/user-config-load-result.d.ts +0 -6
- package/lib/types/user-config-load-result.js +0 -2
- package/lib/types/user-config-load-result.js.map +0 -1
- package/lib/types/user-config.d.ts +0 -40
- package/lib/types/user-config.js +0 -2
- package/lib/types/user-config.js.map +0 -1
- package/src/conflict-resolver.ts +0 -1358
- package/src/constants.ts +0 -29
- package/src/dependency-manager.ts +0 -91
- package/src/generator.ts +0 -10
- package/src/gir-factory.ts +0 -499
- package/src/gir-module.ts +0 -2827
- package/src/html-doc-generator.ts +0 -23
- package/src/injection/callbacks/gjs/Gio-2.0.ts +0 -37
- package/src/injection/callbacks/gjs/index.ts +0 -5
- package/src/injection/callbacks/index.ts +0 -6
- package/src/injection/callbacks/node-gtk/index.ts +0 -3
- package/src/injection/classes/GLib-2-0.ts +0 -36
- package/src/injection/classes/gjs/GLib-2.0.ts +0 -201
- package/src/injection/classes/gjs/GObject-2.0.ts +0 -635
- package/src/injection/classes/gjs/Gio-2.0.ts +0 -219
- package/src/injection/classes/gjs/index.ts +0 -7
- package/src/injection/classes/index.ts +0 -7
- package/src/injection/classes/node-gtk/GLib-2.0.ts +0 -20
- package/src/injection/classes/node-gtk/GObject-2.0.ts +0 -67
- package/src/injection/classes/node-gtk/Gdk-4.0.ts +0 -33
- package/src/injection/classes/node-gtk/Gio-2.0.ts +0 -15
- package/src/injection/classes/node-gtk/Graphene-1.0.ts +0 -134
- package/src/injection/classes/node-gtk/Gtk-3.0.ts +0 -32
- package/src/injection/classes/node-gtk/Gtk-4.0.ts +0 -53
- package/src/injection/classes/node-gtk/Pango-1.0.ts +0 -32
- package/src/injection/classes/node-gtk/index.ts +0 -21
- package/src/injection/index.ts +0 -3
- package/src/injection/injector.ts +0 -184
- package/src/logger.ts +0 -134
- package/src/messages.ts +0 -69
- package/src/symtable.ts +0 -72
- package/src/template-processor.ts +0 -199
- package/src/transformation.ts +0 -583
- package/src/type-definition-generator.ts +0 -1460
- package/src/types/answer-version.ts +0 -4
- package/src/types/build-type.ts +0 -1
- package/src/types/class-parent.ts +0 -14
- package/src/types/config-flags.ts +0 -5
- package/src/types/conflict-child-element.ts +0 -11
- package/src/types/conflict-grouped-element.ts +0 -7
- package/src/types/conflict-grouped-elements.ts +0 -5
- package/src/types/construct-name.ts +0 -11
- package/src/types/dependency-map.ts +0 -4
- package/src/types/dependency.ts +0 -16
- package/src/types/environment.ts +0 -1
- package/src/types/file-info.ts +0 -14
- package/src/types/generate-config.ts +0 -33
- package/src/types/generator-type.ts +0 -4
- package/src/types/gir-alias-element.ts +0 -15
- package/src/types/gir-annotation.ts +0 -10
- package/src/types/gir-any-element.ts +0 -35
- package/src/types/gir-any-type.ts +0 -7
- package/src/types/gir-array-type.ts +0 -23
- package/src/types/gir-bitfield-element.ts +0 -20
- package/src/types/gir-boolean.ts +0 -1
- package/src/types/gir-boxed-element.ts +0 -19
- package/src/types/gir-c-include.ts +0 -7
- package/src/types/gir-callable-attrs.ts +0 -19
- package/src/types/gir-callable-param-element.ts +0 -45
- package/src/types/gir-callable-param.ts +0 -9
- package/src/types/gir-callable-return.ts +0 -25
- package/src/types/gir-callback-element.ts +0 -28
- package/src/types/gir-class-element.ts +0 -71
- package/src/types/gir-constant-element.ts +0 -17
- package/src/types/gir-constructor-element.ts +0 -18
- package/src/types/gir-direction.ts +0 -5
- package/src/types/gir-doc-element.ts +0 -73
- package/src/types/gir-enum-element.ts +0 -28
- package/src/types/gir-field-element.ts +0 -31
- package/src/types/gir-function-element.ts +0 -19
- package/src/types/gir-implements.ts +0 -9
- package/src/types/gir-include.ts +0 -9
- package/src/types/gir-info-attrs.ts +0 -16
- package/src/types/gir-info-elements.ts +0 -8
- package/src/types/gir-instance-parameter.ts +0 -25
- package/src/types/gir-interface-element.ts +0 -53
- package/src/types/gir-member-element.ts +0 -19
- package/src/types/gir-method-element.ts +0 -25
- package/src/types/gir-module-resolved-by.ts +0 -11
- package/src/types/gir-modules-grouped-map.ts +0 -5
- package/src/types/gir-modules-grouped.ts +0 -13
- package/src/types/gir-namespace.ts +0 -47
- package/src/types/gir-package.ts +0 -7
- package/src/types/gir-prerequisite.ts +0 -5
- package/src/types/gir-property-element.ts +0 -31
- package/src/types/gir-record-element.ts +0 -47
- package/src/types/gir-repository.ts +0 -20
- package/src/types/gir-signal.ts +0 -43
- package/src/types/gir-transfer-ownership-type.ts +0 -5
- package/src/types/gir-transfer-ownership.ts +0 -6
- package/src/types/gir-type.ts +0 -16
- package/src/types/gir-union-element.ts +0 -35
- package/src/types/gir-unparsed-number.ts +0 -2
- package/src/types/gir-var-args.ts +0 -6
- package/src/types/gir-virtual-method.ts +0 -22
- package/src/types/index.ts +0 -119
- package/src/types/inheritance-table.ts +0 -3
- package/src/types/injection-callback.ts +0 -20
- package/src/types/injection-class.ts +0 -30
- package/src/types/injection-function.ts +0 -23
- package/src/types/injection-generic-parameter.ts +0 -3
- package/src/types/injection-instance-parameter.ts +0 -3
- package/src/types/injection-parameter.ts +0 -9
- package/src/types/injection-property.ts +0 -7
- package/src/types/injection-type.ts +0 -3
- package/src/types/injection.ts +0 -6
- package/src/types/local-name-check.ts +0 -5
- package/src/types/local-name-type.ts +0 -1
- package/src/types/local-name.ts +0 -8
- package/src/types/local-names.ts +0 -5
- package/src/types/module-type.ts +0 -1
- package/src/types/parsed-gir.ts +0 -5
- package/src/types/part-of-class.ts +0 -9
- package/src/types/part-of-module.ts +0 -8
- package/src/types/resolve-type.ts +0 -4
- package/src/types/sym-table-items.ts +0 -5
- package/src/types/transformation-case.ts +0 -7
- package/src/types/transformations.ts +0 -12
- package/src/types/ts-alias.ts +0 -11
- package/src/types/ts-callback-interface.ts +0 -11
- package/src/types/ts-callback.ts +0 -21
- package/src/types/ts-class.ts +0 -109
- package/src/types/ts-doc-tag.ts +0 -23
- package/src/types/ts-doc.ts +0 -23
- package/src/types/ts-enum.ts +0 -15
- package/src/types/ts-function.ts +0 -59
- package/src/types/ts-generic-parameter.ts +0 -8
- package/src/types/ts-instance-parameter.ts +0 -4
- package/src/types/ts-member.ts +0 -11
- package/src/types/ts-method.ts +0 -6
- package/src/types/ts-parameter.ts +0 -20
- package/src/types/ts-property.ts +0 -22
- package/src/types/ts-signal.ts +0 -21
- package/src/types/ts-type-name.ts +0 -1
- package/src/types/ts-type-separator.ts +0 -1
- package/src/types/ts-type.ts +0 -25
- package/src/types/ts-var.ts +0 -21
- package/src/types/type-gir-alias.ts +0 -2
- package/src/types/type-gir-class.ts +0 -2
- package/src/types/type-gir-element.ts +0 -25
- package/src/types/type-gir-enumeration-member.ts +0 -2
- package/src/types/type-gir-enumeration.ts +0 -2
- package/src/types/type-gir-function.ts +0 -8
- package/src/types/type-gir-interface.ts +0 -2
- package/src/types/type-gir-method.ts +0 -2
- package/src/types/type-gir-parameter.ts +0 -1
- package/src/types/type-gir-property.ts +0 -2
- package/src/types/type-gir-variable.ts +0 -1
- package/src/types/type-ts-element.ts +0 -13
- package/src/types/type-ts-enumeration-member.ts +0 -2
- package/src/types/type-ts-function.ts +0 -1
- package/src/types/type-ts-property.ts +0 -1
- package/src/types/user-config-load-result.ts +0 -6
- package/src/types/user-config.ts +0 -41
- package/templates/Cogl-2.0.d.ts +0 -0
- package/templates/Gjs/GObject-2.0.d.ts +0 -238
- package/templates/Gjs/Gio-2.0.d.ts +0 -64
- package/templates/Gjs/Gjs.d.ts +0 -204
- package/templates/Gjs/Gjs.js +0 -21
- package/templates/Gjs/GnomeShell.d.ts +0 -152
- package/templates/Gjs/GnomeShell.js +0 -10
- package/templates/Gjs/index.d.ts +0 -594
- package/templates/Gjs/index.js +0 -4
- package/templates/Gjs/misc/dbusUtils.d.ts +0 -15
- package/templates/Gjs/misc/dbusUtils.js +0 -6
- package/templates/Gjs/misc/extensionUtils.d.ts +0 -99
- package/templates/Gjs/misc/extensionUtils.js +0 -6
- package/templates/Gjs/misc/fileUtils.d.ts +0 -51
- package/templates/Gjs/misc/fileUtils.js +0 -6
- package/templates/Gjs/misc/gnomeSession.d.ts +0 -74
- package/templates/Gjs/misc/gnomeSession.js +0 -6
- package/templates/Gjs/misc/parentalControlsManager.d.ts +0 -42
- package/templates/Gjs/misc/parentalControlsManager.js +0 -6
- package/templates/Gjs/misc/signals.d.ts +0 -15
- package/templates/Gjs/misc/signals.js +0 -6
- package/templates/Gjs/module.d.ts +0 -6
- package/templates/Gjs/module.js +0 -16
- package/templates/Gjs/tsconfig.alias.json +0 -10
- package/templates/Gjs/ui/accessDialog.d.ts +0 -19
- package/templates/Gjs/ui/accessDialog.js +0 -6
- package/templates/Gjs/ui/altTab.d.ts +0 -124
- package/templates/Gjs/ui/altTab.js +0 -6
- package/templates/Gjs/ui/animation.d.ts +0 -58
- package/templates/Gjs/ui/animation.js +0 -6
- package/templates/Gjs/ui/appDisplay.d.ts +0 -204
- package/templates/Gjs/ui/appDisplay.js +0 -6
- package/templates/Gjs/ui/appFavorites.d.ts +0 -34
- package/templates/Gjs/ui/appFavorites.js +0 -6
- package/templates/Gjs/ui/appMenu.d.ts +0 -74
- package/templates/Gjs/ui/appMenu.js +0 -6
- package/templates/Gjs/ui/audioDeviceSelection.d.ts +0 -51
- package/templates/Gjs/ui/audioDeviceSelection.js +0 -6
- package/templates/Gjs/ui/background.d.ts +0 -255
- package/templates/Gjs/ui/background.js +0 -5
- package/templates/Gjs/ui/backgroundMenu.d.ts +0 -19
- package/templates/Gjs/ui/backgroundMenu.js +0 -5
- package/templates/Gjs/ui/barLevel.d.ts +0 -42
- package/templates/Gjs/ui/barLevel.js +0 -5
- package/templates/Gjs/ui/boxpointer.d.ts +0 -103
- package/templates/Gjs/ui/boxpointer.js +0 -5
- package/templates/Gjs/ui/calendar.d.ts +0 -261
- package/templates/Gjs/ui/calendar.js +0 -5
- package/templates/Gjs/ui/components/__init__.d.ts +0 -9
- package/templates/Gjs/ui/components/__init__.js +0 -6
- package/templates/Gjs/ui/components/automountManager.d.ts +0 -8
- package/templates/Gjs/ui/components/automountManager.js +0 -6
- package/templates/Gjs/ui/components/autorunManager.d.ts +0 -8
- package/templates/Gjs/ui/components/autorunManager.js +0 -6
- package/templates/Gjs/ui/components/index.d.ts +0 -6
- package/templates/Gjs/ui/components/index.js +0 -6
- package/templates/Gjs/ui/components/keyring.d.ts +0 -19
- package/templates/Gjs/ui/components/keyring.js +0 -6
- package/templates/Gjs/ui/components/networkAgent.d.ts +0 -10
- package/templates/Gjs/ui/components/networkAgent.js +0 -6
- package/templates/Gjs/ui/components/polkitAgent.d.ts +0 -19
- package/templates/Gjs/ui/components/polkitAgent.js +0 -6
- package/templates/Gjs/ui/components/telepathyClient.d.ts +0 -10
- package/templates/Gjs/ui/components/telepathyClient.js +0 -6
- package/templates/Gjs/ui/dialog.d.ts +0 -78
- package/templates/Gjs/ui/dialog.js +0 -0
- package/templates/Gjs/ui/dnd.d.ts +0 -127
- package/templates/Gjs/ui/dnd.js +0 -6
- package/templates/Gjs/ui/iconGrid.d.ts +0 -172
- package/templates/Gjs/ui/iconGrid.js +0 -6
- package/templates/Gjs/ui/layout.d.ts +0 -311
- package/templates/Gjs/ui/layout.js +0 -6
- package/templates/Gjs/ui/main.d.ts +0 -215
- package/templates/Gjs/ui/main.js +0 -6
- package/templates/Gjs/ui/messageList.d.ts +0 -113
- package/templates/Gjs/ui/messageList.js +0 -6
- package/templates/Gjs/ui/messageTray.d.ts +0 -423
- package/templates/Gjs/ui/messageTray.js +0 -6
- package/templates/Gjs/ui/modalDialog.d.ts +0 -96
- package/templates/Gjs/ui/modalDialog.js +0 -6
- package/templates/Gjs/ui/mpris.d.ts +0 -78
- package/templates/Gjs/ui/mpris.js +0 -6
- package/templates/Gjs/ui/notificationDaemon.d.ts +0 -5
- package/templates/Gjs/ui/notificationDaemon.js +0 -6
- package/templates/Gjs/ui/panel.d.ts +0 -65
- package/templates/Gjs/ui/panel.js +0 -6
- package/templates/Gjs/ui/panelMenu.d.ts +0 -51
- package/templates/Gjs/ui/panelMenu.js +0 -6
- package/templates/Gjs/ui/popupMenu.d.ts +0 -228
- package/templates/Gjs/ui/popupMenu.js +0 -6
- package/templates/Gjs/ui/ripples.d.ts +0 -44
- package/templates/Gjs/ui/ripples.js +0 -6
- package/templates/Gjs/ui/search.d.ts +0 -158
- package/templates/Gjs/ui/search.js +0 -6
- package/templates/Gjs/ui/switcherPopup.d.ts +0 -107
- package/templates/Gjs/ui/switcherPopup.js +0 -6
- package/templates/Gjs/ui/userWidget.d.ts +0 -13
- package/templates/Gjs/ui/userWidget.js +0 -6
- package/templates/Granite-1.0.d.ts +0 -7
- package/templates/Granite-7.0.d.ts +0 -7
- package/templates/GstBase-0.10.d.ts +0 -5
- package/templates/RygelServer-2.6.d.ts +0 -3
- package/templates/node-gtk/GObject-2.0.d.ts +0 -57
- package/templates/node-gtk/index.d.ts +0 -40
- package/templates/node-gtk/index.js +0 -9
- package/templates/node-gtk/module.d.ts +0 -6
- package/templates/node-gtk/module.js +0 -17
package/lib/gir-module.js
DELETED
|
@@ -1,2086 +0,0 @@
|
|
|
1
|
-
// TODO move this class into a web-worker? https://www.npmjs.com/package/web-worker
|
|
2
|
-
import { Transformation, C_TYPE_MAP, FULL_TYPE_MAP, POD_TYPE_MAP, POD_TYPE_MAP_ARRAY, IGNORE_GIR_TYPE_TS_DOC_TYPES, } from './transformation.js';
|
|
3
|
-
import { STATIC_NAME_ALREADY_EXISTS, MAX_CLASS_PARENT_DEPTH } from './constants.js';
|
|
4
|
-
import { Logger } from './logger.js';
|
|
5
|
-
import { Injector } from './injection/injector.js';
|
|
6
|
-
import { GirFactory } from './gir-factory.js';
|
|
7
|
-
import { ConflictResolver } from './conflict-resolver.js';
|
|
8
|
-
import { DependencyManager } from './dependency-manager.js';
|
|
9
|
-
import { NO_TSDATA, WARN_NOT_FOUND_TYPE, WARN_CONSTANT_ALREADY_EXPORTED, WARN_DUPLICATE_SYMBOL, WARN_DUPLICATE_PARAMETER, WARN_DUPLICATE_ENUM_IDENTIFIER, } from './messages.js';
|
|
10
|
-
import { isEqual, find, clone, girBool, removeNamespace, addNamespace, girElementIsIntrospectable } from './utils.js';
|
|
11
|
-
import { SymTable } from './symtable.js';
|
|
12
|
-
export class GirModule {
|
|
13
|
-
config;
|
|
14
|
-
/**
|
|
15
|
-
* Array of all gir modules
|
|
16
|
-
*/
|
|
17
|
-
static allGirModules = [];
|
|
18
|
-
/**
|
|
19
|
-
* E.g. 'Gtk'
|
|
20
|
-
*/
|
|
21
|
-
namespace;
|
|
22
|
-
/**
|
|
23
|
-
* E.g. '3.0'
|
|
24
|
-
*/
|
|
25
|
-
version = '0.0';
|
|
26
|
-
/**
|
|
27
|
-
* E.g. 'Gtk-3.0'
|
|
28
|
-
*/
|
|
29
|
-
packageName;
|
|
30
|
-
/**
|
|
31
|
-
* E.g. 'Gtk30'
|
|
32
|
-
* Is used in the generated index.d.ts, for example: `import * as Gtk30 from "./Gtk-3.0.js";`
|
|
33
|
-
*/
|
|
34
|
-
importName;
|
|
35
|
-
dependencies = [];
|
|
36
|
-
_transitiveDependencies = [];
|
|
37
|
-
set transitiveDependencies(deps) {
|
|
38
|
-
this._transitiveDependencies = this.checkTransitiveDependencies(deps);
|
|
39
|
-
}
|
|
40
|
-
get transitiveDependencies() {
|
|
41
|
-
return this._transitiveDependencies;
|
|
42
|
-
}
|
|
43
|
-
get allDependencies() {
|
|
44
|
-
return [...new Set([...this.dependencies, ...this.transitiveDependencies])];
|
|
45
|
-
}
|
|
46
|
-
repo;
|
|
47
|
-
ns = { $: { name: '', version: '0.0' } };
|
|
48
|
-
/**
|
|
49
|
-
* Used to find namespaces that are used in other modules
|
|
50
|
-
*/
|
|
51
|
-
symTable;
|
|
52
|
-
transformation;
|
|
53
|
-
girFactory = new GirFactory();
|
|
54
|
-
dependencyManager;
|
|
55
|
-
conflictResolver;
|
|
56
|
-
log;
|
|
57
|
-
inject;
|
|
58
|
-
extends;
|
|
59
|
-
/**
|
|
60
|
-
* To prevent constants from being exported twice, the names already exported are saved here for comparison.
|
|
61
|
-
* Please note: Such a case is only known for Zeitgeist-2.0 with the constant "ATTACHMENT"
|
|
62
|
-
*/
|
|
63
|
-
constNames = {};
|
|
64
|
-
constructor(xml, config) {
|
|
65
|
-
this.config = config;
|
|
66
|
-
this.repo = xml.repository;
|
|
67
|
-
if (!this.repo.namespace || !this.repo.namespace.length) {
|
|
68
|
-
throw new Error(`Namespace not found!`);
|
|
69
|
-
}
|
|
70
|
-
this.dependencyManager = DependencyManager.getInstance(this.config);
|
|
71
|
-
this.dependencies = this.dependencyManager.fromGirIncludes(this.repo.include || []);
|
|
72
|
-
this.ns = this.repo.namespace[0];
|
|
73
|
-
this.namespace = this.ns.$.name;
|
|
74
|
-
this.version = this.ns.$.version;
|
|
75
|
-
this.packageName = `${this.namespace}-${this.version}`;
|
|
76
|
-
this.transformation = new Transformation(this.packageName, config);
|
|
77
|
-
this.log = new Logger(config.environment, config.verbose, this.packageName || 'GirModule');
|
|
78
|
-
this.conflictResolver = new ConflictResolver(config.environment, config.verbose);
|
|
79
|
-
this.inject = new Injector(this.config.environment);
|
|
80
|
-
this.importName = this.transformation.transformModuleNamespaceName(this.packageName);
|
|
81
|
-
this.symTable = new SymTable(this.config, this.packageName, this.namespace);
|
|
82
|
-
}
|
|
83
|
-
checkTransitiveDependencies(transitiveDependencies) {
|
|
84
|
-
// Always pull in GObject-2.0, as we may need it for e.g. GObject-2.0.type
|
|
85
|
-
if (this.packageName !== 'GObject-2.0') {
|
|
86
|
-
if (!find(transitiveDependencies, (x) => x.packageName === 'GObject-2.0')) {
|
|
87
|
-
transitiveDependencies.push(this.dependencyManager.get('GObject', '2.0'));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// Add missing dependencies
|
|
91
|
-
if (this.packageName === 'UnityExtras-7.0') {
|
|
92
|
-
if (!find(transitiveDependencies, (x) => x.packageName === 'Unity-7.0')) {
|
|
93
|
-
transitiveDependencies.push(this.dependencyManager.get('Unity', '7.0'));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (this.packageName === 'UnityExtras-6.0') {
|
|
97
|
-
if (!find(transitiveDependencies, (x) => x.packageName === 'Unity-6.0')) {
|
|
98
|
-
transitiveDependencies.push(this.dependencyManager.get('Unity', '6.0'));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (this.packageName === 'GTop-2.0') {
|
|
102
|
-
if (!find(transitiveDependencies, (x) => x.packageName === 'GLib-2.0')) {
|
|
103
|
-
transitiveDependencies.push(this.dependencyManager.get('GLib', '2.0'));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return transitiveDependencies;
|
|
107
|
-
}
|
|
108
|
-
getTsDoc(girDoc) {
|
|
109
|
-
const tsDoc = {
|
|
110
|
-
text: '',
|
|
111
|
-
tags: [],
|
|
112
|
-
};
|
|
113
|
-
if (girDoc.doc?.[0]?._) {
|
|
114
|
-
let text = girDoc.doc?.[0]?._ || '';
|
|
115
|
-
text = this.transformation.transformGirDoc(text);
|
|
116
|
-
tsDoc.text = text;
|
|
117
|
-
}
|
|
118
|
-
return tsDoc;
|
|
119
|
-
}
|
|
120
|
-
getTsDocGirElementTags(tsTypeName, girTypeName) {
|
|
121
|
-
const tags = [];
|
|
122
|
-
if (!girTypeName || IGNORE_GIR_TYPE_TS_DOC_TYPES.includes(girTypeName)) {
|
|
123
|
-
return tags;
|
|
124
|
-
}
|
|
125
|
-
tags.push({
|
|
126
|
-
tagName: girTypeName,
|
|
127
|
-
paramName: '',
|
|
128
|
-
text: '',
|
|
129
|
-
});
|
|
130
|
-
return tags;
|
|
131
|
-
}
|
|
132
|
-
getTsDocInParamTags(inParams) {
|
|
133
|
-
const tags = [];
|
|
134
|
-
if (!inParams?.length) {
|
|
135
|
-
return tags;
|
|
136
|
-
}
|
|
137
|
-
for (const inParam of inParams) {
|
|
138
|
-
if (!inParam._tsData) {
|
|
139
|
-
throw new Error(NO_TSDATA('getTsDocInParamTags'));
|
|
140
|
-
}
|
|
141
|
-
if (!inParam._tsData?.doc) {
|
|
142
|
-
inParam._tsData.doc = this.getTsDoc(inParam);
|
|
143
|
-
}
|
|
144
|
-
if (inParam._tsData?.name) {
|
|
145
|
-
tags.push({
|
|
146
|
-
paramName: inParam._tsData.name,
|
|
147
|
-
tagName: 'param',
|
|
148
|
-
text: inParam._tsData.doc.text
|
|
149
|
-
? this.transformation.transformGirDocTagText(inParam._tsData.doc.text)
|
|
150
|
-
: '',
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return tags;
|
|
155
|
-
}
|
|
156
|
-
annotateFunctionArguments(girFunc) {
|
|
157
|
-
const funcName = girFunc._fullSymName;
|
|
158
|
-
if (funcName && girFunc.parameters) {
|
|
159
|
-
for (const girParams of girFunc.parameters) {
|
|
160
|
-
if (girParams.parameter) {
|
|
161
|
-
for (const girParam of girParams.parameter) {
|
|
162
|
-
girParam._module = this;
|
|
163
|
-
if (girParam.$ && girParam.$.name) {
|
|
164
|
-
girParam._fullSymName = `${funcName}.${girParam.$.name}`;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
annotateFunctionReturn(girFunc) {
|
|
172
|
-
const retVals = girFunc['return-value'];
|
|
173
|
-
if (retVals && girFunc._fullSymName)
|
|
174
|
-
for (const retVal of retVals) {
|
|
175
|
-
retVal._module = this;
|
|
176
|
-
retVal.girTypeName = 'callable-return';
|
|
177
|
-
if (retVal.$ && retVal.$.name) {
|
|
178
|
-
retVal._fullSymName = `${girFunc._fullSymName}.${retVal.$.name}`;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Functions which are not part of a class
|
|
184
|
-
* @param girFuncs
|
|
185
|
-
*/
|
|
186
|
-
annotateFunctions(girFuncs) {
|
|
187
|
-
if (Array.isArray(girFuncs))
|
|
188
|
-
for (const girFunc of girFuncs) {
|
|
189
|
-
if (girFunc?.$?.name) {
|
|
190
|
-
// girFunc._girType = girType
|
|
191
|
-
girFunc._fullSymName = `${this.namespace}.${girFunc.$.name}`;
|
|
192
|
-
this.annotateFunctionArguments(girFunc);
|
|
193
|
-
this.annotateFunctionReturn(girFunc);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Functions and methods of a class
|
|
199
|
-
*/
|
|
200
|
-
annotateMethods(girClass, girFuncs) {
|
|
201
|
-
if (Array.isArray(girFuncs))
|
|
202
|
-
for (const girFunc of girFuncs) {
|
|
203
|
-
if (girFunc?.$?.name) {
|
|
204
|
-
// girFunc._girType = girType
|
|
205
|
-
// girFunc._tsType = tsType
|
|
206
|
-
girFunc._class = girClass;
|
|
207
|
-
const nsName = girClass ? girClass._fullSymName : this.namespace;
|
|
208
|
-
if (nsName)
|
|
209
|
-
girFunc._fullSymName = `${nsName}.${girFunc.$.name}`;
|
|
210
|
-
this.annotateFunctionArguments(girFunc);
|
|
211
|
-
this.annotateFunctionReturn(girFunc);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Variables which are not part of a class
|
|
217
|
-
*/
|
|
218
|
-
annotateVariables(girVars) {
|
|
219
|
-
for (const girVar of girVars) {
|
|
220
|
-
girVar._module = this;
|
|
221
|
-
if (girVar.$ && girVar.$.name) {
|
|
222
|
-
girVar._fullSymName = `${this.namespace}.${girVar.$.name}`;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Fields are variables which are part of a class
|
|
228
|
-
* @see https://www.typescriptlang.org/docs/handbook/2/classes.html#fields
|
|
229
|
-
*/
|
|
230
|
-
annotateFields(girClass, girVars) {
|
|
231
|
-
for (const girVar of girVars) {
|
|
232
|
-
const nsName = girClass ? girClass._fullSymName : this.namespace;
|
|
233
|
-
girVar._module = this;
|
|
234
|
-
if (girClass) {
|
|
235
|
-
girVar._class = girClass;
|
|
236
|
-
}
|
|
237
|
-
if (girVar.$ && girVar.$.name && nsName) {
|
|
238
|
-
girVar._fullSymName = `${nsName}.${girVar.$.name}`;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
annotateClass(girClass) {
|
|
243
|
-
girClass._module = this;
|
|
244
|
-
girClass._fullSymName = `${this.namespace}.${girClass.$.name}`;
|
|
245
|
-
const constructors = Array.isArray(girClass.constructor) ? girClass.constructor : [];
|
|
246
|
-
const signals = (girClass.signal ||
|
|
247
|
-
girClass['glib:signal'] ||
|
|
248
|
-
[]);
|
|
249
|
-
const functions = girClass.function || [];
|
|
250
|
-
const methods = girClass.method || [];
|
|
251
|
-
const vMethods = girClass['virtual-method'] || new Array();
|
|
252
|
-
const properties = girClass.property;
|
|
253
|
-
const fields = girClass.field;
|
|
254
|
-
this.annotateMethods(girClass, constructors);
|
|
255
|
-
this.annotateMethods(girClass, functions);
|
|
256
|
-
this.annotateMethods(girClass, methods);
|
|
257
|
-
this.annotateMethods(girClass, vMethods);
|
|
258
|
-
this.annotateMethods(girClass, signals);
|
|
259
|
-
if (properties)
|
|
260
|
-
this.annotateFields(girClass, properties);
|
|
261
|
-
if (fields)
|
|
262
|
-
this.annotateFields(girClass, fields);
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Annotates the custom `_module`, `_fullSymName` and `_girType` properties.
|
|
266
|
-
* Also registers the element on the `symTable`.
|
|
267
|
-
* @param girElements
|
|
268
|
-
* @param girType
|
|
269
|
-
*/
|
|
270
|
-
annotateAndRegisterGirElement(girElements) {
|
|
271
|
-
for (const girElement of girElements) {
|
|
272
|
-
if (girElement?.$ && girElement.$.name) {
|
|
273
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
274
|
-
if (!girElementIsIntrospectable(girElement))
|
|
275
|
-
continue;
|
|
276
|
-
girElement._module = this;
|
|
277
|
-
girElement._fullSymName = `${this.namespace}.${girElement.$.name}`;
|
|
278
|
-
if (this.symTable.get(this.allDependencies, girElement._fullSymName)) {
|
|
279
|
-
this.log.warn(WARN_DUPLICATE_SYMBOL(girElement._fullSymName));
|
|
280
|
-
}
|
|
281
|
-
this.symTable.set(this.allDependencies, girElement._fullSymName, girElement);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* TODO: find better name for this method
|
|
287
|
-
* @param girVar
|
|
288
|
-
* @param fullTypeName
|
|
289
|
-
* @returns e.g.
|
|
290
|
-
* ```ts
|
|
291
|
-
* {
|
|
292
|
-
* namespace: "Gtk",
|
|
293
|
-
* resValue: "Gtk.Widget"
|
|
294
|
-
* }
|
|
295
|
-
*
|
|
296
|
-
*/
|
|
297
|
-
fullTypeLookup(girVar, fullTypeName) {
|
|
298
|
-
let resValue = '';
|
|
299
|
-
let namespace = '';
|
|
300
|
-
if (!fullTypeName) {
|
|
301
|
-
return {
|
|
302
|
-
value: resValue,
|
|
303
|
-
fullTypeName,
|
|
304
|
-
namespace,
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
// Fully qualify our type name
|
|
308
|
-
if (!fullTypeName.includes('.')) {
|
|
309
|
-
let tryFullTypeName = '';
|
|
310
|
-
if (!resValue && girVar._module && girVar._module !== this) {
|
|
311
|
-
tryFullTypeName = `${girVar._module.namespace}.${fullTypeName}`;
|
|
312
|
-
resValue = this.fullTypeLookupWithNamespace(tryFullTypeName).value;
|
|
313
|
-
if (resValue) {
|
|
314
|
-
fullTypeName = tryFullTypeName;
|
|
315
|
-
namespace = girVar._module.namespace;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
if (!resValue) {
|
|
319
|
-
tryFullTypeName = `${this.namespace}.${fullTypeName}`;
|
|
320
|
-
resValue = this.fullTypeLookupWithNamespace(tryFullTypeName).value;
|
|
321
|
-
if (resValue) {
|
|
322
|
-
fullTypeName = tryFullTypeName;
|
|
323
|
-
namespace = this.namespace;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
const girClass = girVar._class;
|
|
327
|
-
if (!resValue && girClass?._module?.namespace && girClass._module !== this) {
|
|
328
|
-
tryFullTypeName = `${girClass._module.namespace}.${fullTypeName}`;
|
|
329
|
-
resValue = this.fullTypeLookupWithNamespace(tryFullTypeName).value;
|
|
330
|
-
if (resValue) {
|
|
331
|
-
fullTypeName = tryFullTypeName;
|
|
332
|
-
namespace = girClass?._module?.namespace;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
if (!resValue && fullTypeName) {
|
|
337
|
-
resValue = this.fullTypeLookupWithNamespace(fullTypeName).value;
|
|
338
|
-
}
|
|
339
|
-
return {
|
|
340
|
-
value: resValue,
|
|
341
|
-
namespace,
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* this method needs to be refactored, an array can also be an array of an array for example
|
|
346
|
-
* @param girVar
|
|
347
|
-
* @returns
|
|
348
|
-
*/
|
|
349
|
-
getArrayData(girVar) {
|
|
350
|
-
let arrayType = null;
|
|
351
|
-
let arrCType;
|
|
352
|
-
let isArray = false;
|
|
353
|
-
let overrideTypeName;
|
|
354
|
-
let typeArray;
|
|
355
|
-
let collection;
|
|
356
|
-
if (girVar.array) {
|
|
357
|
-
collection = girVar.array;
|
|
358
|
-
}
|
|
359
|
-
else if (/^GLib.S?List$/.test(girVar.type?.[0].$?.name || '')) {
|
|
360
|
-
// This converts GLib.List<T> / GLib.SList<T> to T[]
|
|
361
|
-
collection = girVar.type;
|
|
362
|
-
}
|
|
363
|
-
if (collection && collection.length > 0) {
|
|
364
|
-
isArray = true;
|
|
365
|
-
typeArray = collection[0].type;
|
|
366
|
-
if (collection[0].$) {
|
|
367
|
-
const ea = collection[0].$;
|
|
368
|
-
arrCType = ea['c:type'];
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
if (typeArray && typeArray?.length > 0) {
|
|
372
|
-
arrayType = typeArray[0];
|
|
373
|
-
}
|
|
374
|
-
if (isArray && arrayType?.$?.name && POD_TYPE_MAP_ARRAY[arrayType.$.name]) {
|
|
375
|
-
isArray = false;
|
|
376
|
-
overrideTypeName = POD_TYPE_MAP_ARRAY[arrayType.$.name];
|
|
377
|
-
}
|
|
378
|
-
return {
|
|
379
|
-
arrCType,
|
|
380
|
-
arrayType,
|
|
381
|
-
isArray,
|
|
382
|
-
overrideTypeName,
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Get the typescript type of a GirElement like a `GirPropertyElement` or `GirCallableReturn`
|
|
387
|
-
* @param girVar
|
|
388
|
-
*/
|
|
389
|
-
getTsType(girVar, tsClass, defaults = {}) {
|
|
390
|
-
let type = girVar.type?.[0];
|
|
391
|
-
let fullTypeName = null;
|
|
392
|
-
let typeName = defaults.type || '';
|
|
393
|
-
let isFunction = defaults.isFunction || false;
|
|
394
|
-
let isCallback = defaults.isCallback || false;
|
|
395
|
-
const nullable = this.typeIsNullable(girVar) || defaults.nullable || false;
|
|
396
|
-
const optional = this.typeIsOptional(girVar) || defaults.optional || false;
|
|
397
|
-
const girCallbacks = [];
|
|
398
|
-
const array = this.getArrayData(girVar);
|
|
399
|
-
if (array.overrideTypeName) {
|
|
400
|
-
typeName = array.overrideTypeName;
|
|
401
|
-
}
|
|
402
|
-
if (array.arrayType) {
|
|
403
|
-
type = array.arrayType;
|
|
404
|
-
}
|
|
405
|
-
const cType = type?.$ ? type.$['c:type'] : array.arrCType;
|
|
406
|
-
fullTypeName = type?.$?.name || null;
|
|
407
|
-
const callbacks = girVar.callback;
|
|
408
|
-
if (!typeName && callbacks?.length) {
|
|
409
|
-
for (const girCallback of callbacks) {
|
|
410
|
-
if (!girElementIsIntrospectable(girCallback))
|
|
411
|
-
continue;
|
|
412
|
-
if (!girCallback._tsData) {
|
|
413
|
-
const tsCallback = this.getFunctionTsData(girCallback, 'callback', tsClass, {
|
|
414
|
-
isStatic: false,
|
|
415
|
-
isArrowType: true,
|
|
416
|
-
isGlobal: false,
|
|
417
|
-
isVirtual: false,
|
|
418
|
-
returnType: null,
|
|
419
|
-
generics: [],
|
|
420
|
-
});
|
|
421
|
-
if (!tsCallback)
|
|
422
|
-
continue;
|
|
423
|
-
girCallback._tsData = {
|
|
424
|
-
...tsCallback,
|
|
425
|
-
girTypeName: 'callback',
|
|
426
|
-
tsTypeName: this.girFactory.girTypeNameToTsTypeName('callback', false),
|
|
427
|
-
tsCallbackInterface: this.getCallbackInterfaceTsData(girCallback),
|
|
428
|
-
doc: this.getTsDoc(girCallback),
|
|
429
|
-
overloads: [],
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
if (girCallback._tsData) {
|
|
433
|
-
girCallbacks.push(girCallback);
|
|
434
|
-
isFunction = true;
|
|
435
|
-
isCallback = true;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
if (!isFunction) {
|
|
440
|
-
const res = this.fullTypeLookup(girVar, fullTypeName);
|
|
441
|
-
if (res.value) {
|
|
442
|
-
typeName = res.value;
|
|
443
|
-
fullTypeName = typeName;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
if (!typeName && type?.$?.name && POD_TYPE_MAP[type.$.name]) {
|
|
447
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
448
|
-
typeName = POD_TYPE_MAP[type.$.name];
|
|
449
|
-
}
|
|
450
|
-
if (cType) {
|
|
451
|
-
if (!typeName && C_TYPE_MAP(cType)) {
|
|
452
|
-
typeName = C_TYPE_MAP(cType) || '';
|
|
453
|
-
}
|
|
454
|
-
if (!typeName && POD_TYPE_MAP[cType]) {
|
|
455
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
456
|
-
typeName = POD_TYPE_MAP[cType];
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
if (!typeName) {
|
|
460
|
-
typeName = 'any';
|
|
461
|
-
const logName = cType || fullTypeName || girVar.$.name || '';
|
|
462
|
-
this.log.warn(WARN_NOT_FOUND_TYPE(logName));
|
|
463
|
-
}
|
|
464
|
-
// TODO: transform array to type with generics?
|
|
465
|
-
const tsType = this.girFactory.newTsType({
|
|
466
|
-
...defaults,
|
|
467
|
-
type: typeName,
|
|
468
|
-
optional,
|
|
469
|
-
nullable,
|
|
470
|
-
callbacks: girCallbacks,
|
|
471
|
-
isArray: array.isArray,
|
|
472
|
-
isFunction,
|
|
473
|
-
isCallback,
|
|
474
|
-
});
|
|
475
|
-
return tsType;
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
*
|
|
479
|
-
* @param girFunc
|
|
480
|
-
* @returns
|
|
481
|
-
*/
|
|
482
|
-
getReturnType(girFunc, tsClass, generics = []) {
|
|
483
|
-
let outArrayLengthIndex = -1;
|
|
484
|
-
if (girFunc['return-value'] && girFunc['return-value'].length > 1) {
|
|
485
|
-
throw new Error('Several return values found!');
|
|
486
|
-
}
|
|
487
|
-
// There are no multiple return values, so we always use index 0
|
|
488
|
-
const girVar = girFunc['return-value']?.[0] || null;
|
|
489
|
-
// We still use an array to allow multiple return values for later
|
|
490
|
-
const returnTypes = [];
|
|
491
|
-
if (girVar) {
|
|
492
|
-
returnTypes.push(this.getTsType(girVar, tsClass, { generics }));
|
|
493
|
-
outArrayLengthIndex = girVar.array && girVar.array[0].$?.length ? Number(girVar.array[0].$.length) : -1;
|
|
494
|
-
}
|
|
495
|
-
else {
|
|
496
|
-
returnTypes.push(this.girFactory.newTsType({ type: 'void', generics }));
|
|
497
|
-
}
|
|
498
|
-
const retTypeIsVoid = returnTypes.length === 1 && returnTypes[0].type === 'void';
|
|
499
|
-
return { returnTypes, outArrayLengthIndex, retTypeIsVoid };
|
|
500
|
-
}
|
|
501
|
-
arrayLengthIndexLookup(girVar) {
|
|
502
|
-
if (!girVar.array)
|
|
503
|
-
return -1;
|
|
504
|
-
const arr = girVar.array[0];
|
|
505
|
-
if (!arr.$)
|
|
506
|
-
return -1;
|
|
507
|
-
if (arr.$.length) {
|
|
508
|
-
return parseInt(arr.$.length);
|
|
509
|
-
}
|
|
510
|
-
return -1;
|
|
511
|
-
}
|
|
512
|
-
closureDataIndexLookup(girVar) {
|
|
513
|
-
if (!girVar.$.closure)
|
|
514
|
-
return -1;
|
|
515
|
-
return parseInt(girVar.$.closure);
|
|
516
|
-
}
|
|
517
|
-
destroyDataIndexLookup(girVar) {
|
|
518
|
-
if (!girVar.$.destroy)
|
|
519
|
-
return -1;
|
|
520
|
-
return parseInt(girVar.$.destroy);
|
|
521
|
-
}
|
|
522
|
-
processParams(params, skip, getIndex) {
|
|
523
|
-
for (const param of params) {
|
|
524
|
-
const index = getIndex(param);
|
|
525
|
-
if (index < 0)
|
|
526
|
-
continue;
|
|
527
|
-
if (index >= params.length)
|
|
528
|
-
continue;
|
|
529
|
-
skip.push(params[index]);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Checks if the parameter is nullable (which results in ` | null`).
|
|
534
|
-
*
|
|
535
|
-
* @param girVar girVar to test
|
|
536
|
-
*/
|
|
537
|
-
typeIsNullable(girVar) {
|
|
538
|
-
const a = girVar.$;
|
|
539
|
-
if (!a)
|
|
540
|
-
return false;
|
|
541
|
-
// Ignore depreciated `allow-none` if one of the new implementation `optional` or `nullable` is set
|
|
542
|
-
if (girBool(a.optional) || girBool(a.nullable)) {
|
|
543
|
-
return girBool(a.nullable);
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
546
|
-
return girBool(a.nullable) || girBool(a['allow-none']);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
/**
|
|
550
|
-
* Checks if the parameter is optional (which results in `foo?: bar`).
|
|
551
|
-
* @param girVar girVar to test
|
|
552
|
-
*/
|
|
553
|
-
typeIsOptional(girVar) {
|
|
554
|
-
const a = girVar.$;
|
|
555
|
-
if (!a)
|
|
556
|
-
return false;
|
|
557
|
-
// Ignore depreciated `allow-none` if one of the new implementation `optional` or `nullable` is set
|
|
558
|
-
if (girBool(a.optional) || girBool(a.nullable)) {
|
|
559
|
-
return girBool(a.optional);
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
return girBool(a.optional) || girBool(a['allow-none']);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
setParameterTsData(girParam, girParams, paramNames, skip, parent) {
|
|
566
|
-
// I think it's safest to force inout params to have the
|
|
567
|
-
// same type for in and out
|
|
568
|
-
const tsType = this.getTsType(girParam, parent.parent);
|
|
569
|
-
// const optDirection = girParam.$.direction
|
|
570
|
-
if (girParam._tsData) {
|
|
571
|
-
// this.log.warn('[setParameterTsData] _tsData already set!')
|
|
572
|
-
return girParam._tsData;
|
|
573
|
-
}
|
|
574
|
-
if (tsType.isCallback) {
|
|
575
|
-
throw new Error('Callback type is not implemented here');
|
|
576
|
-
}
|
|
577
|
-
let paramName = this.transformation.transformParameterName(girParam, false);
|
|
578
|
-
if (paramNames.includes(paramName)) {
|
|
579
|
-
this.log.warn(WARN_DUPLICATE_PARAMETER(paramName, girParam._fullSymName));
|
|
580
|
-
paramName += '_';
|
|
581
|
-
}
|
|
582
|
-
paramNames.push(paramName);
|
|
583
|
-
// In Typescript no optional parameters are allowed if the following ones are not optional
|
|
584
|
-
if (tsType.optional) {
|
|
585
|
-
const index = girParams.indexOf(girParam);
|
|
586
|
-
const following = girParams
|
|
587
|
-
.slice(index)
|
|
588
|
-
.filter(() => skip.indexOf(girParam) === -1)
|
|
589
|
-
.filter((p) => p.$.direction !== 'out');
|
|
590
|
-
if (following.some((p) => !this.typeIsOptional(p))) {
|
|
591
|
-
tsType.optional = false;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
const tsParam = {
|
|
595
|
-
name: paramName,
|
|
596
|
-
type: [tsType],
|
|
597
|
-
isRest: false,
|
|
598
|
-
girTypeName: 'callable-param',
|
|
599
|
-
doc: this.getTsDoc(girParam),
|
|
600
|
-
parent,
|
|
601
|
-
};
|
|
602
|
-
girParam._tsData = tsParam;
|
|
603
|
-
// // TODO: remove this, wee need a special solution for Gio.AsyncReadyCallback instead
|
|
604
|
-
girParam = this.inject.toParameterType(girParam);
|
|
605
|
-
return girParam._tsData;
|
|
606
|
-
}
|
|
607
|
-
getInstanceParameterTsData(instanceParameter) {
|
|
608
|
-
const typeName = instanceParameter.type?.[0]?.$?.name || undefined;
|
|
609
|
-
const rec = typeName ? this.ns.record?.find((r) => r.$.name == typeName) : undefined;
|
|
610
|
-
const structFor = rec?.$['glib:is-gtype-struct-for'];
|
|
611
|
-
if (structFor && instanceParameter.$.name) {
|
|
612
|
-
// TODO: Should use of a constructor, and even of an instance, be discouraged?
|
|
613
|
-
return {
|
|
614
|
-
name: instanceParameter.$.name,
|
|
615
|
-
structFor,
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
return undefined;
|
|
619
|
-
}
|
|
620
|
-
setParametersTsData(outArrayLengthIndex, girParams = [], parent) {
|
|
621
|
-
const outParams = [];
|
|
622
|
-
const inParams = [];
|
|
623
|
-
const paramNames = [];
|
|
624
|
-
const instanceParameters = [];
|
|
625
|
-
if (girParams && girParams.length > 0) {
|
|
626
|
-
for (const girParam of girParams) {
|
|
627
|
-
const params = girParam?.parameter || [];
|
|
628
|
-
// Instance parameter needs to be exposed for class methods (see comment above getClassMethods())
|
|
629
|
-
const instanceParameter = girParams[0]['instance-parameter']?.[0];
|
|
630
|
-
if (instanceParameter) {
|
|
631
|
-
instanceParameter._tsData = this.getInstanceParameterTsData(instanceParameter);
|
|
632
|
-
if (instanceParameter._tsData) {
|
|
633
|
-
instanceParameters.push(instanceParameter);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
if (params.length) {
|
|
637
|
-
const skip = outArrayLengthIndex === -1 ? [] : [params[outArrayLengthIndex]];
|
|
638
|
-
this.processParams(params, skip, (girVar) => this.arrayLengthIndexLookup(girVar));
|
|
639
|
-
this.processParams(params, skip, (girVar) => this.closureDataIndexLookup(girVar));
|
|
640
|
-
this.processParams(params, skip, (girVar) => this.destroyDataIndexLookup(girVar));
|
|
641
|
-
for (const param of params) {
|
|
642
|
-
if (skip.includes(param)) {
|
|
643
|
-
continue;
|
|
644
|
-
}
|
|
645
|
-
param._tsData = this.setParameterTsData(param, params, paramNames, skip, parent);
|
|
646
|
-
const optDirection = param.$.direction;
|
|
647
|
-
if (optDirection === 'out' || optDirection === 'inout') {
|
|
648
|
-
outParams.push(param);
|
|
649
|
-
if (optDirection === 'out')
|
|
650
|
-
continue;
|
|
651
|
-
}
|
|
652
|
-
inParams.push(param);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
return { outParams, paramNames, inParams, instanceParameters };
|
|
658
|
-
}
|
|
659
|
-
getVariableTsData(girVar, girTypeName, tsTypeName, tsClass, optional = false, nullable = false, allowQuotes = false, generics = []) {
|
|
660
|
-
if (!girVar.$.name)
|
|
661
|
-
return undefined;
|
|
662
|
-
if (!girVar ||
|
|
663
|
-
!girVar.$ ||
|
|
664
|
-
!girBool(girVar.$.introspectable, true) ||
|
|
665
|
-
girBool(girVar.$.private)) {
|
|
666
|
-
return undefined;
|
|
667
|
-
}
|
|
668
|
-
if (girVar._tsData) {
|
|
669
|
-
// this.log.warn('[getVariableTsData] _tsData already set!')
|
|
670
|
-
return girVar._tsData;
|
|
671
|
-
}
|
|
672
|
-
let name = girVar.$.name;
|
|
673
|
-
switch (girTypeName) {
|
|
674
|
-
case 'property':
|
|
675
|
-
name = this.transformation.transformPropertyName(girVar.$.name, allowQuotes);
|
|
676
|
-
break;
|
|
677
|
-
case 'constant':
|
|
678
|
-
name = this.transformation.transformConstantName(girVar.$.name, allowQuotes);
|
|
679
|
-
break;
|
|
680
|
-
case 'field':
|
|
681
|
-
name = this.transformation.transformFieldName(girVar.$.name, allowQuotes);
|
|
682
|
-
break;
|
|
683
|
-
}
|
|
684
|
-
// Use the out type because it can be a union which isn't appropriate
|
|
685
|
-
// for a property
|
|
686
|
-
const tsType = this.getTsType(girVar, tsClass, { optional, nullable, generics });
|
|
687
|
-
const tsData = {
|
|
688
|
-
name,
|
|
689
|
-
type: [tsType],
|
|
690
|
-
isInjected: false,
|
|
691
|
-
girTypeName,
|
|
692
|
-
tsTypeName,
|
|
693
|
-
doc: this.getTsDoc(girVar),
|
|
694
|
-
};
|
|
695
|
-
tsData.doc.tags.push(...this.getTsDocGirElementTags(tsData.tsTypeName, tsData.girTypeName));
|
|
696
|
-
return tsData;
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
*
|
|
700
|
-
* @param girProp
|
|
701
|
-
* @param girTypeName
|
|
702
|
-
* @param tsTypeName
|
|
703
|
-
* @param construct construct means include the property even if it's construct-only,
|
|
704
|
-
* @param optional optional means if it's construct-only it will also be marked optional (?)
|
|
705
|
-
* @param nullable
|
|
706
|
-
* @returns
|
|
707
|
-
*/
|
|
708
|
-
getPropertyTsData(girProp, girTypeName, tsTypeName, tsClass, construct = false, optional, nullable) {
|
|
709
|
-
if (!girBool(girProp.$.writable) && construct)
|
|
710
|
-
return undefined;
|
|
711
|
-
if (girBool(girProp.$.private))
|
|
712
|
-
return undefined;
|
|
713
|
-
if (girProp._tsData) {
|
|
714
|
-
// this.log.warn('[getPropertyTsData] _tsData already set!')
|
|
715
|
-
return girProp._tsData;
|
|
716
|
-
}
|
|
717
|
-
if (optional === undefined)
|
|
718
|
-
optional = this.typeIsOptional(girProp);
|
|
719
|
-
if (nullable === undefined)
|
|
720
|
-
nullable = this.typeIsNullable(girProp);
|
|
721
|
-
const readonly = !girBool(girProp.$.writable) || (!construct && girBool(girProp.$['construct-only']));
|
|
722
|
-
let tsData;
|
|
723
|
-
switch (girTypeName) {
|
|
724
|
-
case 'property':
|
|
725
|
-
tsData = this.getVariableTsData(girProp, girTypeName, tsTypeName, tsClass, construct && optional, construct && nullable, true);
|
|
726
|
-
break;
|
|
727
|
-
case 'field':
|
|
728
|
-
if (tsTypeName !== 'property') {
|
|
729
|
-
throw new Error(`Wrong tsType: "${tsTypeName}" for girType: "${girTypeName}`);
|
|
730
|
-
}
|
|
731
|
-
tsData = this.getVariableTsData(girProp, girTypeName, tsTypeName, tsClass, construct && optional, construct && nullable, true);
|
|
732
|
-
break;
|
|
733
|
-
default:
|
|
734
|
-
throw new Error(`Unknown property type: ${girTypeName}`);
|
|
735
|
-
}
|
|
736
|
-
if (!tsData?.name) {
|
|
737
|
-
return undefined;
|
|
738
|
-
}
|
|
739
|
-
tsData = {
|
|
740
|
-
...tsData,
|
|
741
|
-
readonly,
|
|
742
|
-
};
|
|
743
|
-
return tsData;
|
|
744
|
-
}
|
|
745
|
-
/**
|
|
746
|
-
*
|
|
747
|
-
* @param girFunc
|
|
748
|
-
* @param prefix E.g. vfunc
|
|
749
|
-
* @param overrideReturnType
|
|
750
|
-
* @param isArrowType
|
|
751
|
-
* @param indentCount
|
|
752
|
-
*/
|
|
753
|
-
getFunctionTsData(girFunc, girTypeName, tsClass, overwrite) {
|
|
754
|
-
if (!girFunc || !girFunc.$ || !girBool(girFunc.$.introspectable, true) || girFunc.$['shadowed-by']) {
|
|
755
|
-
return undefined;
|
|
756
|
-
}
|
|
757
|
-
let hasUnresolvedConflict;
|
|
758
|
-
// TODO: Fix that we overwrite tsData every time seems wrong to me, but if I just return the already defined `_tsData` leads to problems with the overload methods
|
|
759
|
-
if (girFunc._tsData) {
|
|
760
|
-
hasUnresolvedConflict = girFunc._tsData?.hasUnresolvedConflict; // WORKAROUND do not overwrite conflicts
|
|
761
|
-
}
|
|
762
|
-
let name = girFunc.$.name;
|
|
763
|
-
const { returnTypes, outArrayLengthIndex, retTypeIsVoid } = this.getReturnType(girFunc, tsClass);
|
|
764
|
-
const shadows = girFunc.$.shadows;
|
|
765
|
-
if (shadows) {
|
|
766
|
-
name = shadows;
|
|
767
|
-
}
|
|
768
|
-
// Overwrites
|
|
769
|
-
overwrite.isStatic = overwrite.isStatic || girTypeName === 'static-function' || girTypeName === 'constructor';
|
|
770
|
-
overwrite.isGlobal = overwrite.isGlobal || girTypeName === 'function';
|
|
771
|
-
overwrite.isVirtual = overwrite.isVirtual || girTypeName === 'virtual';
|
|
772
|
-
overwrite.isInjected = overwrite.isInjected || false;
|
|
773
|
-
// Function name transformation by environment
|
|
774
|
-
name = this.transformation.transformFunctionName(name, overwrite.isVirtual);
|
|
775
|
-
const tsData = {
|
|
776
|
-
isArrowType: overwrite.isArrowType,
|
|
777
|
-
isStatic: overwrite.isStatic,
|
|
778
|
-
isGlobal: overwrite.isGlobal,
|
|
779
|
-
isVirtual: overwrite.isVirtual,
|
|
780
|
-
isInjected: overwrite.isInjected,
|
|
781
|
-
returnTypes,
|
|
782
|
-
retTypeIsVoid,
|
|
783
|
-
name,
|
|
784
|
-
overrideReturnType: overwrite.returnType || undefined,
|
|
785
|
-
inParams: [],
|
|
786
|
-
outParams: [],
|
|
787
|
-
instanceParameters: [],
|
|
788
|
-
generics: overwrite.generics,
|
|
789
|
-
hasUnresolvedConflict,
|
|
790
|
-
girTypeName,
|
|
791
|
-
tsTypeName: this.girFactory.girTypeNameToTsTypeName(girTypeName, overwrite.isStatic),
|
|
792
|
-
doc: this.getTsDoc(girFunc),
|
|
793
|
-
overloads: [],
|
|
794
|
-
parent: tsClass,
|
|
795
|
-
};
|
|
796
|
-
const { inParams, outParams, instanceParameters } = this.setParametersTsData(outArrayLengthIndex, girFunc.parameters, tsData);
|
|
797
|
-
tsData.inParams.push(...inParams);
|
|
798
|
-
tsData.outParams.push(...outParams);
|
|
799
|
-
tsData.instanceParameters.push(...instanceParameters);
|
|
800
|
-
tsData.doc.tags.push(...this.getTsDocGirElementTags(tsData.tsTypeName, tsData.girTypeName));
|
|
801
|
-
tsData.doc.tags.push(...this.getTsDocInParamTags(tsData?.inParams));
|
|
802
|
-
return tsData;
|
|
803
|
-
}
|
|
804
|
-
getCallbackInterfaceTsData(girCallback) {
|
|
805
|
-
if (!girElementIsIntrospectable(girCallback))
|
|
806
|
-
return undefined;
|
|
807
|
-
const namespace = this.namespace;
|
|
808
|
-
const tsDataInterface = {
|
|
809
|
-
name: `${namespace}.${girCallback.$.name}`,
|
|
810
|
-
generics: [],
|
|
811
|
-
};
|
|
812
|
-
return tsDataInterface;
|
|
813
|
-
}
|
|
814
|
-
setCallbackTsData(girCallback, tsClass) {
|
|
815
|
-
const tsFunction = this.getFunctionTsData(girCallback, 'callback', tsClass, {
|
|
816
|
-
isStatic: false,
|
|
817
|
-
isArrowType: true,
|
|
818
|
-
isGlobal: false,
|
|
819
|
-
isVirtual: false,
|
|
820
|
-
returnType: null,
|
|
821
|
-
generics: [],
|
|
822
|
-
});
|
|
823
|
-
if (tsFunction) {
|
|
824
|
-
const tsCallback = {
|
|
825
|
-
...tsFunction,
|
|
826
|
-
girTypeName: 'callback',
|
|
827
|
-
tsTypeName: this.girFactory.girTypeNameToTsTypeName('callback', false),
|
|
828
|
-
tsCallbackInterface: this.getCallbackInterfaceTsData(girCallback),
|
|
829
|
-
overloads: [],
|
|
830
|
-
};
|
|
831
|
-
girCallback._tsData = tsCallback;
|
|
832
|
-
this.inject.toCallback(girCallback);
|
|
833
|
-
}
|
|
834
|
-
return girCallback._tsData;
|
|
835
|
-
}
|
|
836
|
-
getSignalCallbackInterfaceTsData(girCallback, girClass) {
|
|
837
|
-
if (!girElementIsIntrospectable(girCallback))
|
|
838
|
-
return undefined;
|
|
839
|
-
if (!girClass._tsData || !girClass._module) {
|
|
840
|
-
throw new Error(NO_TSDATA('getSignalCallbackTsData'));
|
|
841
|
-
}
|
|
842
|
-
const className = girClass._tsData.name;
|
|
843
|
-
const signalName = girCallback.$.name;
|
|
844
|
-
const signalInterfaceName = this.transformation.transformSignalInterfaceName(signalName);
|
|
845
|
-
const namespace = girClass._module.namespace;
|
|
846
|
-
const tsDataInterface = {
|
|
847
|
-
name: `${namespace}.${className}.${signalInterfaceName}SignalCallback`,
|
|
848
|
-
generics: [],
|
|
849
|
-
overwriteDoc: {
|
|
850
|
-
text: `Signal callback interface for \`${signalName}\``,
|
|
851
|
-
tags: [],
|
|
852
|
-
},
|
|
853
|
-
};
|
|
854
|
-
return tsDataInterface;
|
|
855
|
-
}
|
|
856
|
-
getConstructorFunctionTsData(parentClass, girConstructor) {
|
|
857
|
-
if (!girElementIsIntrospectable(girConstructor))
|
|
858
|
-
return;
|
|
859
|
-
const constructorTypeName = addNamespace(parentClass.name, parentClass.namespace);
|
|
860
|
-
return this.getFunctionTsData(girConstructor, 'constructor', parentClass, {
|
|
861
|
-
isStatic: true,
|
|
862
|
-
isArrowType: false,
|
|
863
|
-
isGlobal: false,
|
|
864
|
-
isVirtual: false,
|
|
865
|
-
returnType: constructorTypeName,
|
|
866
|
-
generics: [],
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
getSignalCallbackTsData(girSignalFunc, girClass) {
|
|
870
|
-
if (!girClass._tsData) {
|
|
871
|
-
throw new Error(NO_TSDATA('getSignalCallbackTsData'));
|
|
872
|
-
}
|
|
873
|
-
if (girSignalFunc._tsData) {
|
|
874
|
-
return girSignalFunc._tsData;
|
|
875
|
-
}
|
|
876
|
-
// Leads to errors here
|
|
877
|
-
// if (!girElementIsIntrospectable(girSignalFunc)) return undefined
|
|
878
|
-
const name = this.transformation.transform('signalName', girSignalFunc.$.name);
|
|
879
|
-
const { returnTypes, outArrayLengthIndex, retTypeIsVoid } = this.getReturnType(girSignalFunc, girClass._tsData);
|
|
880
|
-
if (this.config.environment === 'node') {
|
|
881
|
-
returnTypes[0].type === 'void';
|
|
882
|
-
}
|
|
883
|
-
const tsCallback = {
|
|
884
|
-
name,
|
|
885
|
-
returnTypes,
|
|
886
|
-
isArrowType: true,
|
|
887
|
-
isStatic: false,
|
|
888
|
-
isGlobal: false,
|
|
889
|
-
isVirtual: false,
|
|
890
|
-
isInjected: false,
|
|
891
|
-
retTypeIsVoid,
|
|
892
|
-
inParams: [],
|
|
893
|
-
instanceParameters: [],
|
|
894
|
-
outParams: [],
|
|
895
|
-
generics: [],
|
|
896
|
-
girTypeName: 'callback',
|
|
897
|
-
tsTypeName: this.girFactory.girTypeNameToTsTypeName('callback', false),
|
|
898
|
-
doc: this.getTsDoc(girSignalFunc),
|
|
899
|
-
overloads: [],
|
|
900
|
-
parent: girClass._tsData,
|
|
901
|
-
};
|
|
902
|
-
const { inParams, outParams, instanceParameters } = this.setParametersTsData(outArrayLengthIndex, girSignalFunc.parameters, tsCallback);
|
|
903
|
-
if (this.config.environment === 'gjs') {
|
|
904
|
-
inParams.unshift(this.girFactory.newGirCallableParamElement({
|
|
905
|
-
name: '$obj',
|
|
906
|
-
type: [
|
|
907
|
-
{
|
|
908
|
-
type: girClass._tsData.name,
|
|
909
|
-
},
|
|
910
|
-
],
|
|
911
|
-
}, tsCallback));
|
|
912
|
-
}
|
|
913
|
-
tsCallback.inParams.push(...inParams);
|
|
914
|
-
tsCallback.outParams.push(...outParams);
|
|
915
|
-
tsCallback.instanceParameters.push(...instanceParameters);
|
|
916
|
-
tsCallback.doc.tags.push(...this.getTsDocGirElementTags(tsCallback.tsTypeName, tsCallback.girTypeName));
|
|
917
|
-
tsCallback.doc.tags.push(...this.getTsDocInParamTags(tsCallback?.inParams));
|
|
918
|
-
return tsCallback;
|
|
919
|
-
}
|
|
920
|
-
/**
|
|
921
|
-
* Generates signal methods like `connect`, `connect_after` and `emit` on Gjs or `connect`, `on`, `once`, `off` and `emit` an node-gtk
|
|
922
|
-
* for a default gir signal element
|
|
923
|
-
* @param girSignal
|
|
924
|
-
* @returns
|
|
925
|
-
*/
|
|
926
|
-
getClassSignalMethodsTsData(girSignal, parentClass) {
|
|
927
|
-
if (!girSignal._tsData) {
|
|
928
|
-
throw new Error(NO_TSDATA('getClassSignalMethodsTsData'));
|
|
929
|
-
}
|
|
930
|
-
const inParams = girSignal._tsData.inParams.slice(1).map((inParam) => {
|
|
931
|
-
const injectParam = {
|
|
932
|
-
...inParam._tsData,
|
|
933
|
-
type: inParam._tsData?.type || [],
|
|
934
|
-
name: inParam._tsData?.name || 'unknown',
|
|
935
|
-
};
|
|
936
|
-
return injectParam;
|
|
937
|
-
});
|
|
938
|
-
return this.girFactory.newTsSignalMethods(girSignal._tsData?.name, girSignal._tsData?.tsCallbackInterface?.name, inParams, parentClass, this.config.environment, false);
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
* Generates signal methods for the GObject properties of a gir class element
|
|
942
|
-
* @param girClass
|
|
943
|
-
*/
|
|
944
|
-
getClassPropertySignalsMethods(girClass) {
|
|
945
|
-
if (!girClass._tsData) {
|
|
946
|
-
throw new Error(NO_TSDATA('getClassPropertySignalsMethods'));
|
|
947
|
-
}
|
|
948
|
-
const tsMethods = [];
|
|
949
|
-
const propertyNames = this.getClassNonStaticPropertyNames(girClass);
|
|
950
|
-
const namespacePrefix = this.namespace === 'GObject' ? '' : 'GObject.';
|
|
951
|
-
// TODO: Signals: Generate SignalMethods instead of direct types
|
|
952
|
-
for (const propertyName of propertyNames) {
|
|
953
|
-
let callbackType = 'any';
|
|
954
|
-
if (this.config.environment === 'gjs') {
|
|
955
|
-
const objParam = `$obj: ${girClass._tsData.name}`;
|
|
956
|
-
// TODO: create arrowType object instead of a pure string type, see Pango-1.0.Pango.FontMapClass.load_font for an example
|
|
957
|
-
callbackType = `((${objParam}, pspec: ${namespacePrefix}ParamSpec) => void)`;
|
|
958
|
-
}
|
|
959
|
-
else if (this.config.environment === 'node') {
|
|
960
|
-
callbackType = `(...args: any[]) => void`;
|
|
961
|
-
}
|
|
962
|
-
tsMethods.push(...this.girFactory.newTsSignalMethods(`notify::${propertyName}`, callbackType, [], girClass._tsData, this.config.environment));
|
|
963
|
-
}
|
|
964
|
-
return tsMethods;
|
|
965
|
-
}
|
|
966
|
-
getGeneralSignalsMethods(parentClass) {
|
|
967
|
-
return this.girFactory.newTsSignalMethods(undefined, undefined, [], parentClass, this.config.environment, true);
|
|
968
|
-
}
|
|
969
|
-
setSignalTsData(girSignal, girClass) {
|
|
970
|
-
if (!girClass._tsData) {
|
|
971
|
-
throw NO_TSDATA('setSignalTsData');
|
|
972
|
-
}
|
|
973
|
-
if (!girSignal._tsData) {
|
|
974
|
-
girSignal._tsData = {
|
|
975
|
-
...this.getSignalCallbackTsData(girSignal, girClass),
|
|
976
|
-
tsCallbackInterface: this.getSignalCallbackInterfaceTsData(girSignal, girClass),
|
|
977
|
-
tsMethods: [],
|
|
978
|
-
girTypeName: 'signal',
|
|
979
|
-
tsTypeName: this.girFactory.girTypeNameToTsTypeName('signal', false),
|
|
980
|
-
doc: this.getTsDoc(girSignal),
|
|
981
|
-
overloads: [],
|
|
982
|
-
};
|
|
983
|
-
girSignal._tsData.doc.tags.push(...this.getTsDocGirElementTags(girSignal._tsData.tsTypeName, girSignal._tsData.girTypeName));
|
|
984
|
-
// TODO: this are the callback parameters
|
|
985
|
-
girSignal._tsData.doc.tags.push(...this.getTsDocInParamTags(girSignal._tsData?.inParams));
|
|
986
|
-
if (!girSignal._tsData) {
|
|
987
|
-
throw NO_TSDATA('setSignalTsData');
|
|
988
|
-
}
|
|
989
|
-
girSignal._tsData.tsMethods = this.getClassSignalMethodsTsData(girSignal, girClass._tsData);
|
|
990
|
-
}
|
|
991
|
-
return girSignal._tsData;
|
|
992
|
-
}
|
|
993
|
-
fixEnumerationDuplicateIdentifier(girEnum) {
|
|
994
|
-
if (!girElementIsIntrospectable(girEnum))
|
|
995
|
-
return girEnum;
|
|
996
|
-
if (!girEnum._tsData) {
|
|
997
|
-
throw new Error(NO_TSDATA('fixEnumerationDuplicateIdentifier'));
|
|
998
|
-
}
|
|
999
|
-
if (!girEnum.member?.length) {
|
|
1000
|
-
return girEnum;
|
|
1001
|
-
}
|
|
1002
|
-
const memberNames = [];
|
|
1003
|
-
for (const girEnumMember of girEnum.member) {
|
|
1004
|
-
if (!girEnumMember._tsData) {
|
|
1005
|
-
throw new Error(NO_TSDATA('fixEnumerationDuplicateIdentifier'));
|
|
1006
|
-
}
|
|
1007
|
-
if (memberNames.find((name) => name === girEnumMember._tsData?.name)) {
|
|
1008
|
-
const renamed = '_' + girEnumMember._tsData.name;
|
|
1009
|
-
this.log.warn(WARN_DUPLICATE_ENUM_IDENTIFIER(girEnumMember._tsData.name, renamed));
|
|
1010
|
-
girEnumMember._tsData.name = renamed;
|
|
1011
|
-
}
|
|
1012
|
-
memberNames.push(girEnumMember._tsData.name);
|
|
1013
|
-
}
|
|
1014
|
-
return girEnum;
|
|
1015
|
-
}
|
|
1016
|
-
getEnumerationMemberTsData(girEnumMember, girTypeName) {
|
|
1017
|
-
const memberName = girEnumMember.$.name || girEnumMember.$['glib:nick'] || girEnumMember.$['c:identifier'];
|
|
1018
|
-
if (!girElementIsIntrospectable(girEnumMember, memberName))
|
|
1019
|
-
return undefined;
|
|
1020
|
-
if (girEnumMember._tsData) {
|
|
1021
|
-
// this.log.warn('[getEnumerationMemberTsData] _tsData already set!')
|
|
1022
|
-
return girEnumMember._tsData;
|
|
1023
|
-
}
|
|
1024
|
-
const name = this.transformation.transformEnumMember(memberName);
|
|
1025
|
-
const tsData = {
|
|
1026
|
-
name,
|
|
1027
|
-
girTypeName,
|
|
1028
|
-
tsTypeName: this.girFactory.girTypeNameToTsTypeName(girTypeName, false),
|
|
1029
|
-
doc: this.getTsDoc(girEnumMember),
|
|
1030
|
-
};
|
|
1031
|
-
tsData.doc.tags.push(...this.getTsDocGirElementTags(tsData.tsTypeName, tsData.girTypeName));
|
|
1032
|
-
return tsData;
|
|
1033
|
-
}
|
|
1034
|
-
getEnumerationTsData(girEnum, girTypeName) {
|
|
1035
|
-
if (!girElementIsIntrospectable(girEnum))
|
|
1036
|
-
return undefined;
|
|
1037
|
-
if (girEnum._tsData) {
|
|
1038
|
-
// this.log.warn('[getEnumerationMemberTsData] _tsData already set!')
|
|
1039
|
-
return girEnum._tsData;
|
|
1040
|
-
}
|
|
1041
|
-
// E.g. the NetworkManager-1.0 has enum names starting with 80211
|
|
1042
|
-
const name = this.transformation.transformEnumName(girEnum);
|
|
1043
|
-
const tsData = {
|
|
1044
|
-
name,
|
|
1045
|
-
girTypeName,
|
|
1046
|
-
tsTypeName: this.girFactory.girTypeNameToTsTypeName(girTypeName, false),
|
|
1047
|
-
doc: this.getTsDoc(girEnum),
|
|
1048
|
-
};
|
|
1049
|
-
tsData.doc.tags.push(...this.getTsDocGirElementTags(tsData.tsTypeName, tsData.girTypeName));
|
|
1050
|
-
return tsData;
|
|
1051
|
-
}
|
|
1052
|
-
getAliasTsData(girAlias, tsClass) {
|
|
1053
|
-
if (!girElementIsIntrospectable(girAlias))
|
|
1054
|
-
return undefined;
|
|
1055
|
-
if (girAlias._tsData) {
|
|
1056
|
-
// this.log.warn('[getEnumerationMemberTsData] _tsData already set!')
|
|
1057
|
-
return girAlias._tsData;
|
|
1058
|
-
}
|
|
1059
|
-
const { type: typeName } = this.getTsType(girAlias, tsClass);
|
|
1060
|
-
const name = girAlias.$.name;
|
|
1061
|
-
const tsData = {
|
|
1062
|
-
name,
|
|
1063
|
-
type: typeName,
|
|
1064
|
-
girTypeName: 'alias',
|
|
1065
|
-
tsTypeName: this.girFactory.girTypeNameToTsTypeName('alias', false),
|
|
1066
|
-
};
|
|
1067
|
-
return tsData;
|
|
1068
|
-
}
|
|
1069
|
-
getConstantTsData(girConst, tsClass) {
|
|
1070
|
-
if (!girElementIsIntrospectable(girConst))
|
|
1071
|
-
return undefined;
|
|
1072
|
-
if (girConst._tsData) {
|
|
1073
|
-
// this.log.warn('[getConstantTsData] _tsData already set!')
|
|
1074
|
-
return girConst._tsData;
|
|
1075
|
-
}
|
|
1076
|
-
let tsData = this.getVariableTsData(girConst, 'constant', 'constant', tsClass, false, false, false);
|
|
1077
|
-
if (tsData?.name) {
|
|
1078
|
-
if (!this.constNames[tsData.name]) {
|
|
1079
|
-
this.constNames[tsData.name] = girConst;
|
|
1080
|
-
}
|
|
1081
|
-
else {
|
|
1082
|
-
this.log.warn(WARN_CONSTANT_ALREADY_EXPORTED(tsData.name));
|
|
1083
|
-
tsData = undefined;
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
return tsData;
|
|
1087
|
-
}
|
|
1088
|
-
getClassConstructPropsTsData(girClass, constructPropNames) {
|
|
1089
|
-
const constructProps = [];
|
|
1090
|
-
const girProperties = girClass.property;
|
|
1091
|
-
if (!girProperties?.length) {
|
|
1092
|
-
return constructProps;
|
|
1093
|
-
}
|
|
1094
|
-
for (const girProp of girProperties) {
|
|
1095
|
-
if (!girElementIsIntrospectable(girProp) || !girProp.$.name)
|
|
1096
|
-
continue;
|
|
1097
|
-
// Do not modify the original girProp, create a new one by clone `girProp` to `girConstrProp`
|
|
1098
|
-
const girConstrProp = clone(girProp);
|
|
1099
|
-
if (!girClass._tsData)
|
|
1100
|
-
continue;
|
|
1101
|
-
if (!girConstrProp._tsData) {
|
|
1102
|
-
girConstrProp._tsData = this.getPropertyTsData(girConstrProp, 'property', 'constructor-property', girClass._tsData, true, true, true, 0);
|
|
1103
|
-
}
|
|
1104
|
-
if (!girConstrProp._tsData) {
|
|
1105
|
-
continue;
|
|
1106
|
-
}
|
|
1107
|
-
const localName = this.checkOrSetLocalName(girConstrProp, constructPropNames, 'property');
|
|
1108
|
-
if (!localName?.added) {
|
|
1109
|
-
continue;
|
|
1110
|
-
}
|
|
1111
|
-
if (girConstrProp._fullSymName)
|
|
1112
|
-
this.symTable.set(this.allDependencies, girConstrProp._fullSymName, girConstrProp);
|
|
1113
|
-
constructProps.push(girConstrProp);
|
|
1114
|
-
}
|
|
1115
|
-
return constructProps;
|
|
1116
|
-
}
|
|
1117
|
-
/**
|
|
1118
|
-
* Some class/static methods are defined in a separate record which is not
|
|
1119
|
-
* exported, but the methods are available as members of the JS constructor.
|
|
1120
|
-
* In gjs one can use an instance of the object, a JS constructor or a GType
|
|
1121
|
-
* as the method's instance-parameter.
|
|
1122
|
-
* @see https://discourse.gnome.org/t/using-class-methods-like-gtk-widget-class-get-css-name-from-gjs/4001
|
|
1123
|
-
* @param girClass
|
|
1124
|
-
*/
|
|
1125
|
-
getClassRecordMethods(girClass) {
|
|
1126
|
-
const girMethods = [];
|
|
1127
|
-
if (!girClass.$.name)
|
|
1128
|
-
return girMethods;
|
|
1129
|
-
const fName = girClass.$.name + 'Class';
|
|
1130
|
-
let rec = this.ns.record?.find((r) => r.$.name == fName);
|
|
1131
|
-
if (!rec || !this.isGtypeStructFor(girClass, rec)) {
|
|
1132
|
-
rec = this.ns.record?.find((r) => this.isGtypeStructFor(girClass, r));
|
|
1133
|
-
fName == rec?.$.name;
|
|
1134
|
-
}
|
|
1135
|
-
if (!rec)
|
|
1136
|
-
return girMethods;
|
|
1137
|
-
// Record methods
|
|
1138
|
-
const methods = rec.method || [];
|
|
1139
|
-
for (const girMethod of methods) {
|
|
1140
|
-
if (!girElementIsIntrospectable(girMethod) || !girClass._tsData)
|
|
1141
|
-
continue;
|
|
1142
|
-
if (!girMethod._tsData)
|
|
1143
|
-
girMethod._tsData = this.getFunctionTsData(girMethod, 'static-function', girClass._tsData, {
|
|
1144
|
-
isStatic: true,
|
|
1145
|
-
isArrowType: false,
|
|
1146
|
-
isGlobal: false,
|
|
1147
|
-
isVirtual: false,
|
|
1148
|
-
returnType: null,
|
|
1149
|
-
generics: [],
|
|
1150
|
-
});
|
|
1151
|
-
if (!girMethod._tsData)
|
|
1152
|
-
continue;
|
|
1153
|
-
if (girMethod._tsData) {
|
|
1154
|
-
if (girMethod._fullSymName)
|
|
1155
|
-
this.symTable.set(this.allDependencies, girMethod._fullSymName, girMethod);
|
|
1156
|
-
girMethods.push(girMethod);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
return girMethods;
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* Instance methods
|
|
1163
|
-
* @param girClass
|
|
1164
|
-
* @param localNames
|
|
1165
|
-
*/
|
|
1166
|
-
getClassMethodsTsData(girClass, localNames) {
|
|
1167
|
-
const girMethods = [];
|
|
1168
|
-
if (girClass.method) {
|
|
1169
|
-
for (const girMethod of girClass.method) {
|
|
1170
|
-
if (!girElementIsIntrospectable(girMethod) || !girClass._tsData)
|
|
1171
|
-
continue;
|
|
1172
|
-
if (!girMethod._tsData)
|
|
1173
|
-
girMethod._tsData = this.getFunctionTsData(girMethod, 'method', girClass._tsData, {
|
|
1174
|
-
isStatic: false,
|
|
1175
|
-
isArrowType: false,
|
|
1176
|
-
isGlobal: false,
|
|
1177
|
-
isVirtual: false,
|
|
1178
|
-
returnType: null,
|
|
1179
|
-
generics: [],
|
|
1180
|
-
});
|
|
1181
|
-
if (!girMethod._tsData)
|
|
1182
|
-
continue;
|
|
1183
|
-
const localName = this.checkOrSetLocalName(girMethod, localNames, 'method');
|
|
1184
|
-
if (localName?.added && localName.method) {
|
|
1185
|
-
if (girMethod._fullSymName)
|
|
1186
|
-
this.symTable.set(this.allDependencies, girMethod._fullSymName, girMethod);
|
|
1187
|
-
girMethods.push(localName.method);
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
return girMethods;
|
|
1192
|
-
}
|
|
1193
|
-
getClassFieldsTsData(girClass, localNames) {
|
|
1194
|
-
const girFields = [];
|
|
1195
|
-
if (!girClass._tsData) {
|
|
1196
|
-
this.log.warn(NO_TSDATA('setClassFieldsTsData'));
|
|
1197
|
-
return girFields;
|
|
1198
|
-
}
|
|
1199
|
-
if (girClass.field) {
|
|
1200
|
-
for (const girField of girClass.field) {
|
|
1201
|
-
if (!girElementIsIntrospectable(girField))
|
|
1202
|
-
continue;
|
|
1203
|
-
if (!girField._tsData)
|
|
1204
|
-
girField._tsData = this.getVariableTsData(girField, 'field', 'property', girClass._tsData, false, false, false);
|
|
1205
|
-
if (!girField._tsData) {
|
|
1206
|
-
continue;
|
|
1207
|
-
}
|
|
1208
|
-
const localName = this.checkOrSetLocalName(girField, localNames, 'field');
|
|
1209
|
-
if (localName?.added && localName.field) {
|
|
1210
|
-
if (girField._fullSymName)
|
|
1211
|
-
this.symTable.set(this.allDependencies, girField._fullSymName, girField);
|
|
1212
|
-
girFields.push(localName.field);
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
return girFields;
|
|
1217
|
-
}
|
|
1218
|
-
getGObjectProperties(girClass) {
|
|
1219
|
-
const girProperties = [];
|
|
1220
|
-
if (girClass._fullSymName && !STATIC_NAME_ALREADY_EXISTS.includes(girClass._fullSymName)) {
|
|
1221
|
-
// Records, classes and interfaces all have a static name
|
|
1222
|
-
const type = this.girFactory.newTsType({ type: 'string' });
|
|
1223
|
-
const staticNameProp = this.girFactory.newGirProperty({
|
|
1224
|
-
isStatic: true,
|
|
1225
|
-
name: 'name',
|
|
1226
|
-
type: [type],
|
|
1227
|
-
girTypeName: 'property',
|
|
1228
|
-
});
|
|
1229
|
-
girProperties.push(staticNameProp);
|
|
1230
|
-
}
|
|
1231
|
-
if (girClass._tsData?.isDerivedFromGObject && girClass._module) {
|
|
1232
|
-
if (this.config.environment === 'gjs') {
|
|
1233
|
-
const type = this.girFactory.newTsType({
|
|
1234
|
-
// TODO: Type not as string
|
|
1235
|
-
type: 'GObject.GType',
|
|
1236
|
-
generics: this.girFactory.newGenerics([
|
|
1237
|
-
{
|
|
1238
|
-
value: girClass._tsData.name,
|
|
1239
|
-
},
|
|
1240
|
-
]),
|
|
1241
|
-
});
|
|
1242
|
-
const staticGTypeProp = this.girFactory.newGirProperty({
|
|
1243
|
-
isStatic: true,
|
|
1244
|
-
name: '$gtype',
|
|
1245
|
-
type: [type],
|
|
1246
|
-
girTypeName: 'property',
|
|
1247
|
-
});
|
|
1248
|
-
girProperties.push(staticGTypeProp);
|
|
1249
|
-
}
|
|
1250
|
-
else if (this.config.environment === 'node') {
|
|
1251
|
-
const staticGTypeProp = this.girFactory.newGirProperty({
|
|
1252
|
-
isStatic: false,
|
|
1253
|
-
name: '__gtype__',
|
|
1254
|
-
type: [{ type: 'number' }],
|
|
1255
|
-
girTypeName: 'property',
|
|
1256
|
-
});
|
|
1257
|
-
girProperties.push(staticGTypeProp);
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
return girProperties;
|
|
1261
|
-
}
|
|
1262
|
-
getClassPropertiesTsData(girClass, localNames) {
|
|
1263
|
-
const girProperties = [];
|
|
1264
|
-
const properties = girClass.property;
|
|
1265
|
-
if (properties) {
|
|
1266
|
-
for (const girProperty of properties) {
|
|
1267
|
-
if (!girElementIsIntrospectable(girProperty) || !girClass._tsData)
|
|
1268
|
-
continue;
|
|
1269
|
-
girProperty._tsData = this.getPropertyTsData(girProperty, 'property', 'property', girClass._tsData);
|
|
1270
|
-
if (!girProperty._tsData)
|
|
1271
|
-
continue;
|
|
1272
|
-
const localName = this.checkOrSetLocalName(girProperty, localNames, 'property');
|
|
1273
|
-
if (localName?.added && localName.property) {
|
|
1274
|
-
if (girProperty._fullSymName)
|
|
1275
|
-
this.symTable.set(this.allDependencies, girProperty._fullSymName, girProperty);
|
|
1276
|
-
girProperties.push(localName.property);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
return girProperties;
|
|
1281
|
-
}
|
|
1282
|
-
getClassNonStaticPropertyNames(girClass) {
|
|
1283
|
-
const propertyNames = [];
|
|
1284
|
-
if (!girClass._tsData) {
|
|
1285
|
-
return propertyNames;
|
|
1286
|
-
}
|
|
1287
|
-
const girProperties = girClass._tsData.properties;
|
|
1288
|
-
if (girProperties.length > 0) {
|
|
1289
|
-
for (const girProperty of girProperties) {
|
|
1290
|
-
if (!girElementIsIntrospectable(girProperty))
|
|
1291
|
-
continue;
|
|
1292
|
-
if (girProperty.$.name &&
|
|
1293
|
-
!propertyNames.includes(girProperty.$.name) &&
|
|
1294
|
-
!girProperty._tsData?.isStatic) {
|
|
1295
|
-
propertyNames.push(girProperty.$.name);
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
// Extended property names
|
|
1300
|
-
for (const fullSymName of Object.keys(girClass._tsData.inherit)) {
|
|
1301
|
-
const girProperties = girClass._tsData.inherit[fullSymName]?.class.properties;
|
|
1302
|
-
if (girProperties.length > 0) {
|
|
1303
|
-
for (const girProperty of girProperties) {
|
|
1304
|
-
if (!girElementIsIntrospectable(girProperty))
|
|
1305
|
-
continue;
|
|
1306
|
-
if (girProperty.$.name &&
|
|
1307
|
-
!propertyNames.includes(girProperty.$.name) &&
|
|
1308
|
-
!girProperty._tsData?.isStatic) {
|
|
1309
|
-
propertyNames.push(girProperty.$.name);
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
// Implemented property names
|
|
1315
|
-
for (const fullSymName of Object.keys(girClass._tsData.implements)) {
|
|
1316
|
-
const girProperties = girClass._tsData.implements[fullSymName]?.interface.properties;
|
|
1317
|
-
if (girProperties.length > 0) {
|
|
1318
|
-
for (const girProperty of girProperties) {
|
|
1319
|
-
if (!girElementIsIntrospectable(girProperty))
|
|
1320
|
-
continue;
|
|
1321
|
-
if (girProperty._tsData &&
|
|
1322
|
-
girProperty.$.name &&
|
|
1323
|
-
!propertyNames.includes(girProperty.$.name) &&
|
|
1324
|
-
!girProperty._tsData?.isStatic) {
|
|
1325
|
-
propertyNames.push(girProperty.$.name);
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
return propertyNames;
|
|
1331
|
-
}
|
|
1332
|
-
getClassConstructorsTsData(girClass) {
|
|
1333
|
-
if (!girClass._tsData) {
|
|
1334
|
-
throw new Error(NO_TSDATA('getClassConstructorsTsData'));
|
|
1335
|
-
}
|
|
1336
|
-
const girConstructors = [];
|
|
1337
|
-
// JS constructor(s)
|
|
1338
|
-
if (girClass._tsData?.isDerivedFromGObject) {
|
|
1339
|
-
const constructorInParam = {
|
|
1340
|
-
name: 'config',
|
|
1341
|
-
type: [
|
|
1342
|
-
{
|
|
1343
|
-
optional: true,
|
|
1344
|
-
type: girClass._tsData.constructPropInterfaceName,
|
|
1345
|
-
},
|
|
1346
|
-
],
|
|
1347
|
-
};
|
|
1348
|
-
const realConstructor = this.girFactory.newGirFunction({
|
|
1349
|
-
name: 'constructor',
|
|
1350
|
-
isStatic: true,
|
|
1351
|
-
inParams: [constructorInParam],
|
|
1352
|
-
girTypeName: 'constructor',
|
|
1353
|
-
}, girClass._tsData);
|
|
1354
|
-
const initConstructor = this.girFactory.newGirFunction({
|
|
1355
|
-
name: '_init',
|
|
1356
|
-
inParams: [constructorInParam],
|
|
1357
|
-
girTypeName: 'method',
|
|
1358
|
-
}, girClass._tsData);
|
|
1359
|
-
girConstructors.push(realConstructor, initConstructor);
|
|
1360
|
-
}
|
|
1361
|
-
if (Array.isArray(girClass.constructor)) {
|
|
1362
|
-
for (const girConstructor of girClass.constructor) {
|
|
1363
|
-
if (!girElementIsIntrospectable(girConstructor))
|
|
1364
|
-
continue;
|
|
1365
|
-
girConstructor._tsData = this.getConstructorFunctionTsData(girClass._tsData, girConstructor);
|
|
1366
|
-
if (!girConstructor._tsData?.name)
|
|
1367
|
-
continue;
|
|
1368
|
-
// Also add `new` pseudo constructors
|
|
1369
|
-
const ADD_NEW_PSEUDO_CONSTRUCTOR = true;
|
|
1370
|
-
// Inject an additional real constructor if static new(...) exists
|
|
1371
|
-
if (girConstructor._tsData.name === 'new') {
|
|
1372
|
-
const realConstructor = clone(girConstructor);
|
|
1373
|
-
realConstructor._tsData = clone(realConstructor._tsData);
|
|
1374
|
-
if (realConstructor._tsData) {
|
|
1375
|
-
realConstructor._tsData.overloads = [];
|
|
1376
|
-
realConstructor.$.name = 'constructor';
|
|
1377
|
-
realConstructor._tsData.name = 'constructor';
|
|
1378
|
-
girConstructors.push(realConstructor);
|
|
1379
|
-
}
|
|
1380
|
-
if (ADD_NEW_PSEUDO_CONSTRUCTOR) {
|
|
1381
|
-
girConstructors.push(girConstructor);
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
else {
|
|
1385
|
-
girConstructors.push(girConstructor);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
return girConstructors;
|
|
1390
|
-
}
|
|
1391
|
-
getClassVirtualMethodsTsData(girClass) {
|
|
1392
|
-
const methods = girClass['virtual-method'] || [];
|
|
1393
|
-
const girMethods = [];
|
|
1394
|
-
for (const girVMethod of methods) {
|
|
1395
|
-
if (!girElementIsIntrospectable(girVMethod) || !girClass._tsData)
|
|
1396
|
-
continue;
|
|
1397
|
-
girVMethod._tsData = this.getFunctionTsData(girVMethod, 'virtual', girClass._tsData, {
|
|
1398
|
-
isStatic: false,
|
|
1399
|
-
isArrowType: false,
|
|
1400
|
-
isGlobal: false,
|
|
1401
|
-
isVirtual: true,
|
|
1402
|
-
returnType: null,
|
|
1403
|
-
generics: [],
|
|
1404
|
-
});
|
|
1405
|
-
if (!girVMethod._tsData)
|
|
1406
|
-
continue;
|
|
1407
|
-
if (girVMethod?._tsData?.name) {
|
|
1408
|
-
girMethods.push(girVMethod);
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
return girMethods;
|
|
1412
|
-
}
|
|
1413
|
-
/**
|
|
1414
|
-
*
|
|
1415
|
-
* @param girClass This is the class / interface the `parentClass` implements signals from
|
|
1416
|
-
* @returns
|
|
1417
|
-
*/
|
|
1418
|
-
getClassSignalsTsData(girClass) {
|
|
1419
|
-
const girSignals = [];
|
|
1420
|
-
const signals = girClass.signal ||
|
|
1421
|
-
girClass['glib:signal'] ||
|
|
1422
|
-
[];
|
|
1423
|
-
if (signals) {
|
|
1424
|
-
for (const girSignal of signals) {
|
|
1425
|
-
girSignal._tsData = this.setSignalTsData(girSignal, girClass);
|
|
1426
|
-
if (!girSignal._tsData)
|
|
1427
|
-
continue;
|
|
1428
|
-
if (girSignal._fullSymName)
|
|
1429
|
-
this.symTable.set(this.allDependencies, girSignal._fullSymName, girSignal);
|
|
1430
|
-
girSignals.push(girSignal);
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
return girSignals;
|
|
1434
|
-
}
|
|
1435
|
-
getClassParentObject(parentName, namespace, type) {
|
|
1436
|
-
let qualifiedParentName;
|
|
1437
|
-
let parentModName;
|
|
1438
|
-
// WORKAROUND: Fix wrong parent names
|
|
1439
|
-
if ((this.packageName === 'GstAudio-0.10' || this.packageName === 'ClutterGst-1.0') &&
|
|
1440
|
-
(parentName === 'GstBase.BaseTransform' ||
|
|
1441
|
-
parentName === 'GstBase.BaseSink' ||
|
|
1442
|
-
parentName === 'GstBase.PushSrc')) {
|
|
1443
|
-
const rename = parentName.replace('GstBase.', 'Gst.');
|
|
1444
|
-
this.log.warn(`[getClassParentObject] Rename parent class "${parentName}" -> "${rename}"`);
|
|
1445
|
-
parentName = rename;
|
|
1446
|
-
}
|
|
1447
|
-
if (parentName === 'GraniteServicesSettingsSerializable') {
|
|
1448
|
-
parentName = 'ServicesSettingsSerializable';
|
|
1449
|
-
this.log.warn(`[getClassParentObject] Rename parent class "GraniteServicesSettingsSerializable" -> "ServicesSettingsSerializable"`);
|
|
1450
|
-
}
|
|
1451
|
-
if (parentName.indexOf('.') < 0) {
|
|
1452
|
-
qualifiedParentName = namespace + '.' + parentName;
|
|
1453
|
-
parentModName = namespace;
|
|
1454
|
-
}
|
|
1455
|
-
else {
|
|
1456
|
-
qualifiedParentName = parentName;
|
|
1457
|
-
const split = parentName.split('.');
|
|
1458
|
-
parentName = split[split.length - 1];
|
|
1459
|
-
parentModName = split.slice(0, split.length - 1).join('.');
|
|
1460
|
-
}
|
|
1461
|
-
const localParentName = parentModName == namespace ? parentName : qualifiedParentName;
|
|
1462
|
-
const dependencyExists = !!this.symTable.get(this.allDependencies, qualifiedParentName);
|
|
1463
|
-
const cls = this.getClassParent({
|
|
1464
|
-
qualifiedParentName,
|
|
1465
|
-
parentName,
|
|
1466
|
-
});
|
|
1467
|
-
return {
|
|
1468
|
-
qualifiedParentName,
|
|
1469
|
-
localParentName,
|
|
1470
|
-
type,
|
|
1471
|
-
parentName,
|
|
1472
|
-
cls,
|
|
1473
|
-
dependencyExists,
|
|
1474
|
-
// TODO: are there other types that can be inherited or implemented?
|
|
1475
|
-
girTypeName: type === 'parent' ? 'class' : 'interface',
|
|
1476
|
-
};
|
|
1477
|
-
}
|
|
1478
|
-
getClassParents(girClass) {
|
|
1479
|
-
const parents = [];
|
|
1480
|
-
if (!girClass._module?.namespace) {
|
|
1481
|
-
throw new Error('Namespace not found!');
|
|
1482
|
-
}
|
|
1483
|
-
if (!girClass._tsData) {
|
|
1484
|
-
throw new Error(NO_TSDATA('getClassParents'));
|
|
1485
|
-
}
|
|
1486
|
-
const prerequisites = girClass?.prerequisite;
|
|
1487
|
-
const implmts = girClass?.implements;
|
|
1488
|
-
if (implmts) {
|
|
1489
|
-
for (const implement of implmts) {
|
|
1490
|
-
const parentName = implement.$?.name;
|
|
1491
|
-
if (!parentName)
|
|
1492
|
-
continue;
|
|
1493
|
-
const parent = this.getClassParentObject(parentName, girClass._module.namespace, 'implements');
|
|
1494
|
-
if (parent.dependencyExists) {
|
|
1495
|
-
parents.push(parent);
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
if (prerequisites) {
|
|
1500
|
-
for (const prerequisite of prerequisites) {
|
|
1501
|
-
const parentName = prerequisite.$?.name;
|
|
1502
|
-
if (!parentName)
|
|
1503
|
-
continue;
|
|
1504
|
-
const parent = this.getClassParentObject(parentName, girClass._module.namespace, 'prerequisite');
|
|
1505
|
-
if (parent.dependencyExists) {
|
|
1506
|
-
parents.push(parent);
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
if (girClass.$.parent) {
|
|
1511
|
-
const parentName = girClass.$.parent;
|
|
1512
|
-
if (parentName) {
|
|
1513
|
-
const parent = this.getClassParentObject(parentName, girClass._module.namespace, 'parent');
|
|
1514
|
-
if (parent.dependencyExists) {
|
|
1515
|
-
parents.push(parent);
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
// Please reply: Do all interfaces always inherit from GObject.Object?
|
|
1520
|
-
// If this is a interface and GObject.Object is not in the parents array, add GObject.Object to the parents
|
|
1521
|
-
if (girClass._tsData.girTypeName === 'interface' && girClass._fullSymName !== 'GObject.Object') {
|
|
1522
|
-
if (!parents.find((parent) => parent.qualifiedParentName === 'GObject.Object')) {
|
|
1523
|
-
// TODO make sure this class exists in symTable
|
|
1524
|
-
const gObjectObjectCls = this.symTable.getByHand('GObject-2.0.GObject.Object') || undefined;
|
|
1525
|
-
const parent = {
|
|
1526
|
-
qualifiedParentName: 'GObject.Object',
|
|
1527
|
-
localParentName: girClass._module.namespace === 'GObject' ? 'Object' : 'GObject.Object',
|
|
1528
|
-
type: 'parent',
|
|
1529
|
-
parentName: 'Object',
|
|
1530
|
-
cls: gObjectObjectCls,
|
|
1531
|
-
dependencyExists: !!gObjectObjectCls,
|
|
1532
|
-
girTypeName: 'class',
|
|
1533
|
-
};
|
|
1534
|
-
if (parent.dependencyExists) {
|
|
1535
|
-
parents.push(parent);
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
return parents;
|
|
1540
|
-
}
|
|
1541
|
-
setClassBaseTsData(girClass, girTypeName) {
|
|
1542
|
-
if (!girClass?.$?.name)
|
|
1543
|
-
return undefined;
|
|
1544
|
-
const girModule = girClass._module ? girClass._module : this;
|
|
1545
|
-
let className = this.transformation.transformClassName(girClass.$.name);
|
|
1546
|
-
/**
|
|
1547
|
-
* E.g. 'Gtk'
|
|
1548
|
-
*/
|
|
1549
|
-
const namespace = girModule.namespace;
|
|
1550
|
-
/**
|
|
1551
|
-
* E.g. '3.0'
|
|
1552
|
-
*/
|
|
1553
|
-
const version = girModule.version;
|
|
1554
|
-
let qualifiedName;
|
|
1555
|
-
if (!className.includes('.')) {
|
|
1556
|
-
qualifiedName = namespace + '.' + className;
|
|
1557
|
-
}
|
|
1558
|
-
else {
|
|
1559
|
-
qualifiedName = className;
|
|
1560
|
-
const split = className.split('.');
|
|
1561
|
-
className = split[split.length - 1];
|
|
1562
|
-
}
|
|
1563
|
-
girClass._tsData = {
|
|
1564
|
-
name: className,
|
|
1565
|
-
qualifiedName,
|
|
1566
|
-
parents: [],
|
|
1567
|
-
namespace,
|
|
1568
|
-
version,
|
|
1569
|
-
isAbstract: this.isAbstractClass(girClass),
|
|
1570
|
-
localNames: {},
|
|
1571
|
-
constructPropNames: {},
|
|
1572
|
-
inheritConstructPropInterfaceNames: [],
|
|
1573
|
-
constructPropInterfaceName: `${namespace}.${className}.ConstructorProperties`,
|
|
1574
|
-
fields: [],
|
|
1575
|
-
properties: [],
|
|
1576
|
-
conflictProperties: [],
|
|
1577
|
-
constructProps: [],
|
|
1578
|
-
propertySignalMethods: [],
|
|
1579
|
-
methods: [],
|
|
1580
|
-
conflictMethods: [],
|
|
1581
|
-
virtualMethods: [],
|
|
1582
|
-
constructors: [],
|
|
1583
|
-
staticFunctions: [],
|
|
1584
|
-
signals: [],
|
|
1585
|
-
generics: [],
|
|
1586
|
-
inherit: {},
|
|
1587
|
-
implements: {},
|
|
1588
|
-
girTypeName,
|
|
1589
|
-
tsTypeName: this.girFactory.girTypeNameToTsTypeName(girTypeName, false),
|
|
1590
|
-
doc: this.getTsDoc(girClass),
|
|
1591
|
-
};
|
|
1592
|
-
girClass._tsData.doc.tags.push(...this.getTsDocGirElementTags(girClass._tsData.tsTypeName, girClass._tsData.girTypeName));
|
|
1593
|
-
girClass._tsData.parents = this.getClassParents(girClass);
|
|
1594
|
-
if (girClass._tsData.parents.length) {
|
|
1595
|
-
for (const parent of girClass._tsData.parents) {
|
|
1596
|
-
girClass._tsData.inheritConstructPropInterfaceNames.push(`${parent.qualifiedParentName}.ConstructorProperties`);
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
girClass._tsData.isDerivedFromGObject = this.isDerivedFromGObject(girClass);
|
|
1600
|
-
return girClass._tsData;
|
|
1601
|
-
}
|
|
1602
|
-
setClassTsData(girClass, girTypeName) {
|
|
1603
|
-
if (!girClass?.$?.name)
|
|
1604
|
-
return undefined;
|
|
1605
|
-
if (girClass._tsData) {
|
|
1606
|
-
return girClass._tsData;
|
|
1607
|
-
}
|
|
1608
|
-
girClass._tsData = this.setClassBaseTsData(girClass, girTypeName);
|
|
1609
|
-
if (!girClass._tsData) {
|
|
1610
|
-
return undefined;
|
|
1611
|
-
}
|
|
1612
|
-
// BASE
|
|
1613
|
-
if (girClass._tsData.isDerivedFromGObject) {
|
|
1614
|
-
girClass._tsData.constructProps.push(...this.getClassConstructPropsTsData(girClass, girClass._tsData.constructPropNames));
|
|
1615
|
-
}
|
|
1616
|
-
girClass._tsData.constructors.push(...this.getClassConstructorsTsData(girClass));
|
|
1617
|
-
girClass._tsData.staticFunctions.push(...this.getClassStaticFunctionsTsData(girClass, girClass._tsData));
|
|
1618
|
-
girClass._tsData.fields.push(...this.getClassFieldsTsData(girClass, girClass._tsData.localNames));
|
|
1619
|
-
girClass._tsData.properties.push(...this.getClassPropertiesTsData(girClass, girClass._tsData.localNames));
|
|
1620
|
-
girClass._tsData.methods.push(...this.getClassMethodsTsData(girClass, girClass._tsData.localNames));
|
|
1621
|
-
girClass._tsData.virtualMethods.push(...this.getClassVirtualMethodsTsData(girClass));
|
|
1622
|
-
girClass._tsData.signals.push(...this.getClassSignalsTsData(girClass));
|
|
1623
|
-
girClass._tsData.properties.push(...this.getGObjectProperties(girClass));
|
|
1624
|
-
// Copy fields, properties, methods, virtual methods and signals from inheritance tree
|
|
1625
|
-
this.traverseInheritanceTree(girClass, girClass._tsData.girTypeName, (extendsCls, depth) => {
|
|
1626
|
-
if (!girClass._tsData || !extendsCls._tsData || !extendsCls._fullSymName || !extendsCls._module) {
|
|
1627
|
-
return;
|
|
1628
|
-
}
|
|
1629
|
-
if (girClass._fullSymName === extendsCls._fullSymName) {
|
|
1630
|
-
return;
|
|
1631
|
-
}
|
|
1632
|
-
const key = extendsCls._module.packageName + '.' + extendsCls._fullSymName;
|
|
1633
|
-
if (girClass._tsData.inherit[key])
|
|
1634
|
-
return;
|
|
1635
|
-
girClass._tsData.inherit[key] = {
|
|
1636
|
-
depth,
|
|
1637
|
-
class: extendsCls._tsData,
|
|
1638
|
-
};
|
|
1639
|
-
});
|
|
1640
|
-
// Copy properties, methods and signals from implemented interface
|
|
1641
|
-
this.forEachInterface(girClass, girClass._tsData.girTypeName, (iface, depth) => {
|
|
1642
|
-
if (!girClass._tsData || !iface._tsData || !iface._fullSymName || !iface._module) {
|
|
1643
|
-
return;
|
|
1644
|
-
}
|
|
1645
|
-
if (girClass._fullSymName === iface._fullSymName) {
|
|
1646
|
-
return;
|
|
1647
|
-
}
|
|
1648
|
-
const key = iface._module.packageName + '.' + iface._fullSymName;
|
|
1649
|
-
if (girClass._tsData.implements[key])
|
|
1650
|
-
return;
|
|
1651
|
-
girClass._tsData.implements[key] = {
|
|
1652
|
-
depth,
|
|
1653
|
-
interface: iface._tsData,
|
|
1654
|
-
};
|
|
1655
|
-
});
|
|
1656
|
-
this.inject.toClass(girClass);
|
|
1657
|
-
girClass._tsData.propertySignalMethods.push(...this.getClassPropertySignalsMethods(girClass), ...this.getGeneralSignalsMethods(girClass._tsData));
|
|
1658
|
-
if (this.config.fixConflicts) {
|
|
1659
|
-
this.conflictResolver.repairClass(girClass);
|
|
1660
|
-
}
|
|
1661
|
-
return girClass._tsData;
|
|
1662
|
-
}
|
|
1663
|
-
isDerivedFromGObject(girClass) {
|
|
1664
|
-
if (typeof girClass._tsData?.isDerivedFromGObject === 'boolean')
|
|
1665
|
-
return girClass._tsData.isDerivedFromGObject;
|
|
1666
|
-
let ret = false;
|
|
1667
|
-
const onClassOrInterface = (cls) => {
|
|
1668
|
-
if (cls._tsData?.isDerivedFromGObject === true || cls._fullSymName === 'GObject.Object') {
|
|
1669
|
-
ret = true;
|
|
1670
|
-
}
|
|
1671
|
-
};
|
|
1672
|
-
if (!girClass._tsData)
|
|
1673
|
-
throw new Error(NO_TSDATA('isDerivedFromGObject'));
|
|
1674
|
-
this.traverseInheritanceTree(girClass, girClass._tsData.tsTypeName, onClassOrInterface);
|
|
1675
|
-
this.forEachInterface(girClass, girClass._tsData.tsTypeName, onClassOrInterface);
|
|
1676
|
-
return ret;
|
|
1677
|
-
}
|
|
1678
|
-
getClassParent(parent) {
|
|
1679
|
-
let parentPtr = undefined;
|
|
1680
|
-
if (this.symTable.get(this.allDependencies, parent.qualifiedParentName)) {
|
|
1681
|
-
parentPtr =
|
|
1682
|
-
this.symTable.get(this.allDependencies, parent.qualifiedParentName) || undefined;
|
|
1683
|
-
}
|
|
1684
|
-
if (!parentPtr && parent.parentName == 'Object') {
|
|
1685
|
-
parentPtr = this.symTable.getByHand('GObject-2.0.GObject.Object') || undefined;
|
|
1686
|
-
}
|
|
1687
|
-
return parentPtr;
|
|
1688
|
-
}
|
|
1689
|
-
traverseInheritanceTree(girClass, gitTypeName, callback, depth = 0, recursive = true) {
|
|
1690
|
-
if (!girClass.$.name)
|
|
1691
|
-
return;
|
|
1692
|
-
if (!girClass._tsData)
|
|
1693
|
-
girClass._tsData = this.setClassTsData(girClass, gitTypeName);
|
|
1694
|
-
if (!girClass._tsData)
|
|
1695
|
-
return;
|
|
1696
|
-
callback(girClass, depth);
|
|
1697
|
-
const parents = girClass._tsData.parents;
|
|
1698
|
-
if (recursive && parents.length) {
|
|
1699
|
-
++depth;
|
|
1700
|
-
if (depth >= MAX_CLASS_PARENT_DEPTH) {
|
|
1701
|
-
this.log.error('[traverseInheritanceTree] Maximum recursion depth reached');
|
|
1702
|
-
return;
|
|
1703
|
-
}
|
|
1704
|
-
for (const parent of parents) {
|
|
1705
|
-
if (!parent.parentName || parent.type !== 'parent') {
|
|
1706
|
-
continue;
|
|
1707
|
-
}
|
|
1708
|
-
if (parent.cls) {
|
|
1709
|
-
if (parent.cls === girClass) {
|
|
1710
|
-
this.log.warn('[traverseInheritanceTree] A class cannot inherit itself');
|
|
1711
|
-
continue;
|
|
1712
|
-
}
|
|
1713
|
-
this.traverseInheritanceTree(parent.cls, parent.girTypeName, callback, depth, recursive);
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
forEachInterface(girIface, girTypeName, callback, recursive = true, depth = 0) {
|
|
1719
|
-
if (!girIface.$.name)
|
|
1720
|
-
return;
|
|
1721
|
-
if (!girIface._tsData)
|
|
1722
|
-
girIface._tsData = this.setClassTsData(girIface, girTypeName);
|
|
1723
|
-
if (!girIface._tsData) {
|
|
1724
|
-
throw new Error(NO_TSDATA('forEachInterface'));
|
|
1725
|
-
}
|
|
1726
|
-
const parents = girIface._tsData.parents;
|
|
1727
|
-
if (parents.length) {
|
|
1728
|
-
++depth;
|
|
1729
|
-
for (const parent of parents) {
|
|
1730
|
-
if (!parent.parentName || parent.type === 'parent') {
|
|
1731
|
-
continue;
|
|
1732
|
-
}
|
|
1733
|
-
if (parent.cls) {
|
|
1734
|
-
callback(parent.cls, depth);
|
|
1735
|
-
// iface's prerequisite is also an interface, or it's
|
|
1736
|
-
// a class and we also want to recurse classes
|
|
1737
|
-
if (recursive)
|
|
1738
|
-
this.forEachInterface(parent.cls, parent.girTypeName, callback, recursive, depth);
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
/**
|
|
1744
|
-
*
|
|
1745
|
-
* @param girElement
|
|
1746
|
-
* @param localNames Can be (constructor) properties, fields or methods
|
|
1747
|
-
* @param type
|
|
1748
|
-
*/
|
|
1749
|
-
checkOrSetLocalName(girElement, localNames, type) {
|
|
1750
|
-
let isOverloadable = false;
|
|
1751
|
-
if (!girElement._tsData) {
|
|
1752
|
-
return null;
|
|
1753
|
-
}
|
|
1754
|
-
const name = girElement._tsData?.name;
|
|
1755
|
-
if (!name) {
|
|
1756
|
-
return null;
|
|
1757
|
-
}
|
|
1758
|
-
// Methods are overloadable by typescript
|
|
1759
|
-
// TODO Add support for properties
|
|
1760
|
-
if (type === 'method') {
|
|
1761
|
-
isOverloadable = true;
|
|
1762
|
-
}
|
|
1763
|
-
// Only names of the same type are overloadable
|
|
1764
|
-
if (localNames[name]?.type && localNames[name].type !== type) {
|
|
1765
|
-
// In GIO there are some methods and properties with the same name
|
|
1766
|
-
// E.g. on `WebKit2.WebView.isLoading` and `WebKit2.WebView.isLoading()`
|
|
1767
|
-
// See Gjs doc https://gjs-docs.gnome.org/webkit240~4.0_api/webkit2.webview#property-is_loading
|
|
1768
|
-
// TODO prefer functions over properties (Overwrite the properties with the functions if they have the same name)
|
|
1769
|
-
return null;
|
|
1770
|
-
}
|
|
1771
|
-
// If name is found in localNames this variable was already defined
|
|
1772
|
-
if (localNames?.[name]?.[type]?._tsData) {
|
|
1773
|
-
// Ignore duplicates with the same type
|
|
1774
|
-
// TODO should we use `this.functionSignaturesMatch` here?
|
|
1775
|
-
if (type === 'method') {
|
|
1776
|
-
const tsMethod1 = girElement._tsData;
|
|
1777
|
-
const tsMethod2 = localNames[name][type]._tsData;
|
|
1778
|
-
if (!tsMethod1 || !tsMethod2) {
|
|
1779
|
-
return null;
|
|
1780
|
-
}
|
|
1781
|
-
// if (ConflictResolver.functionConflict(tsMethod1, tsMethod2)) {
|
|
1782
|
-
// return null
|
|
1783
|
-
// }
|
|
1784
|
-
}
|
|
1785
|
-
else {
|
|
1786
|
-
// TODO better handling of property and field
|
|
1787
|
-
if (isEqual(localNames[name][type]?._tsData, girElement._tsData)) {
|
|
1788
|
-
return null;
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
// Ignore if current method is not overloadable
|
|
1792
|
-
if (!isOverloadable) {
|
|
1793
|
-
return null;
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
localNames[name] = localNames[name] || {};
|
|
1797
|
-
const localName = {
|
|
1798
|
-
...localNames[name],
|
|
1799
|
-
[type]: girElement,
|
|
1800
|
-
type,
|
|
1801
|
-
};
|
|
1802
|
-
localNames[name] = localName;
|
|
1803
|
-
return { ...localName, added: true };
|
|
1804
|
-
}
|
|
1805
|
-
isGtypeStructFor(e, rec) {
|
|
1806
|
-
const isFor = rec.$['glib:is-gtype-struct-for'];
|
|
1807
|
-
return isFor && isFor == e.$.name;
|
|
1808
|
-
}
|
|
1809
|
-
/**
|
|
1810
|
-
* E.g GObject.ObjectClass is a abstract class and required by UPowerGlib-1.0, UDisks-2.0 and others
|
|
1811
|
-
* @param girClass
|
|
1812
|
-
* @returns `true` if this is this a abstract class.
|
|
1813
|
-
*/
|
|
1814
|
-
isAbstractClass(girClass) {
|
|
1815
|
-
return girClass.$?.['glib:is-gtype-struct-for'] ? true : false;
|
|
1816
|
-
}
|
|
1817
|
-
/**
|
|
1818
|
-
*
|
|
1819
|
-
* @param girClass
|
|
1820
|
-
* @returns
|
|
1821
|
-
*/
|
|
1822
|
-
getOtherStaticFunctions(girClass) {
|
|
1823
|
-
const girFunctions = [];
|
|
1824
|
-
if (!girClass._tsData)
|
|
1825
|
-
return girFunctions;
|
|
1826
|
-
if (girClass.function?.length) {
|
|
1827
|
-
for (const girFunction of girClass.function) {
|
|
1828
|
-
girFunction._tsData = this.getFunctionTsData(girFunction, 'static-function', girClass._tsData, {
|
|
1829
|
-
isStatic: true,
|
|
1830
|
-
isArrowType: false,
|
|
1831
|
-
isGlobal: false,
|
|
1832
|
-
isVirtual: false,
|
|
1833
|
-
returnType: null,
|
|
1834
|
-
generics: [],
|
|
1835
|
-
});
|
|
1836
|
-
if (!girFunction._tsData?.name)
|
|
1837
|
-
continue;
|
|
1838
|
-
if (girFunction._tsData.name.startsWith('new'))
|
|
1839
|
-
continue;
|
|
1840
|
-
girFunctions.push(girFunction);
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
return girFunctions;
|
|
1844
|
-
}
|
|
1845
|
-
getStaticNewFunctions(girClass, parentClass) {
|
|
1846
|
-
const girFunctions = [];
|
|
1847
|
-
if (girClass.function?.length) {
|
|
1848
|
-
for (const girFunction of girClass.function) {
|
|
1849
|
-
girFunction._tsData = this.getConstructorFunctionTsData(parentClass, girFunction);
|
|
1850
|
-
if (!girFunction._tsData?.name.startsWith('new'))
|
|
1851
|
-
continue;
|
|
1852
|
-
girFunctions.push(girFunction);
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
return girFunctions;
|
|
1856
|
-
}
|
|
1857
|
-
/**
|
|
1858
|
-
* Static methods, <constructor> and <function>
|
|
1859
|
-
* @param girClass
|
|
1860
|
-
* @param constructorTypeName Used to overwrite the constructor return type
|
|
1861
|
-
* @param useReference This value should be `false` for inherited and implemented classes / interfaces.
|
|
1862
|
-
* Otherwise other modules would overwrite the return value of the constructor methods
|
|
1863
|
-
*/
|
|
1864
|
-
getClassStaticFunctionsTsData(girClass, parentClass) {
|
|
1865
|
-
const girStaticFuncs = [];
|
|
1866
|
-
girStaticFuncs.push(...this.getStaticNewFunctions(girClass, parentClass));
|
|
1867
|
-
girStaticFuncs.push(...this.getOtherStaticFunctions(girClass));
|
|
1868
|
-
girStaticFuncs.push(...this.getClassRecordMethods(girClass));
|
|
1869
|
-
return girStaticFuncs;
|
|
1870
|
-
}
|
|
1871
|
-
setModuleTsData() {
|
|
1872
|
-
if (this.ns.enumeration) {
|
|
1873
|
-
for (const girEnum of this.ns.enumeration) {
|
|
1874
|
-
if (girEnum.member) {
|
|
1875
|
-
for (const girEnumMember of girEnum.member) {
|
|
1876
|
-
girEnumMember._tsData = this.getEnumerationMemberTsData(girEnumMember, 'enum-member');
|
|
1877
|
-
if (!girEnumMember._tsData)
|
|
1878
|
-
continue;
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
1881
|
-
girEnum._tsData = this.getEnumerationTsData(girEnum, 'enum');
|
|
1882
|
-
this.fixEnumerationDuplicateIdentifier(girEnum);
|
|
1883
|
-
if (!girEnum._tsData)
|
|
1884
|
-
continue;
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
if (this.ns.bitfield)
|
|
1888
|
-
for (const girBitfield of this.ns.bitfield) {
|
|
1889
|
-
if (girBitfield.member)
|
|
1890
|
-
for (const girEnumMember of girBitfield.member) {
|
|
1891
|
-
girEnumMember._tsData = this.getEnumerationMemberTsData(girEnumMember, 'bitfield-member');
|
|
1892
|
-
}
|
|
1893
|
-
girBitfield._tsData = this.getEnumerationTsData(girBitfield, 'bitfield');
|
|
1894
|
-
if (!girBitfield._tsData)
|
|
1895
|
-
continue;
|
|
1896
|
-
this.fixEnumerationDuplicateIdentifier(girBitfield);
|
|
1897
|
-
}
|
|
1898
|
-
if (this.ns.constant)
|
|
1899
|
-
for (const girConst of this.ns.constant) {
|
|
1900
|
-
girConst._tsData = this.getConstantTsData(girConst, null);
|
|
1901
|
-
if (!girConst._tsData)
|
|
1902
|
-
continue;
|
|
1903
|
-
}
|
|
1904
|
-
if (this.ns.function) {
|
|
1905
|
-
for (const girFunc of this.ns.function) {
|
|
1906
|
-
girFunc._tsData = this.getFunctionTsData(girFunc, 'function', null, {
|
|
1907
|
-
isStatic: false,
|
|
1908
|
-
isArrowType: false,
|
|
1909
|
-
isGlobal: true,
|
|
1910
|
-
isVirtual: false,
|
|
1911
|
-
returnType: null,
|
|
1912
|
-
generics: [],
|
|
1913
|
-
});
|
|
1914
|
-
if (!girFunc._tsData)
|
|
1915
|
-
continue;
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
if (this.ns.callback)
|
|
1919
|
-
for (const girCallback of this.ns.callback) {
|
|
1920
|
-
girCallback._tsData = this.setCallbackTsData(girCallback, null);
|
|
1921
|
-
}
|
|
1922
|
-
if (this.ns.interface)
|
|
1923
|
-
for (const girIface of this.ns.interface) {
|
|
1924
|
-
girIface._tsData = this.setClassTsData(girIface, 'interface');
|
|
1925
|
-
}
|
|
1926
|
-
if (this.ns.class)
|
|
1927
|
-
for (const girClass of this.ns.class) {
|
|
1928
|
-
girClass._tsData = this.setClassTsData(girClass, 'class');
|
|
1929
|
-
if (!girClass._tsData)
|
|
1930
|
-
continue;
|
|
1931
|
-
}
|
|
1932
|
-
if (this.ns.record)
|
|
1933
|
-
for (const girRecord of this.ns.record) {
|
|
1934
|
-
girRecord._tsData = this.setClassTsData(girRecord, 'record');
|
|
1935
|
-
if (!girRecord._tsData)
|
|
1936
|
-
continue;
|
|
1937
|
-
}
|
|
1938
|
-
if (this.ns.union)
|
|
1939
|
-
for (const girUnion of this.ns.union) {
|
|
1940
|
-
girUnion._tsData = this.setClassTsData(girUnion, 'union');
|
|
1941
|
-
if (!girUnion._tsData)
|
|
1942
|
-
continue;
|
|
1943
|
-
}
|
|
1944
|
-
if (this.ns.alias) {
|
|
1945
|
-
for (const girAlias of this.ns.alias) {
|
|
1946
|
-
// GType is not a number in GJS
|
|
1947
|
-
if (this.packageName !== 'GObject-2.0' || girAlias.$.name !== 'Type')
|
|
1948
|
-
girAlias._tsData = this.getAliasTsData(girAlias, null);
|
|
1949
|
-
if (!girAlias._tsData)
|
|
1950
|
-
continue;
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
/**
|
|
1955
|
-
* TODO: find better name for this method
|
|
1956
|
-
* @param fullTypeName
|
|
1957
|
-
* @returns
|
|
1958
|
-
*/
|
|
1959
|
-
fullTypeLookupWithNamespace(fullTypeName) {
|
|
1960
|
-
let resValue = '';
|
|
1961
|
-
let namespace = '';
|
|
1962
|
-
// Check overwrites first
|
|
1963
|
-
if (!resValue && fullTypeName && FULL_TYPE_MAP(this.config.environment, fullTypeName)) {
|
|
1964
|
-
resValue = FULL_TYPE_MAP(this.config.environment, fullTypeName) || '';
|
|
1965
|
-
}
|
|
1966
|
-
// Only use the fullTypeName as the type if it is found in the symTable
|
|
1967
|
-
if (!resValue && this.symTable.get(this.allDependencies, fullTypeName)) {
|
|
1968
|
-
if (fullTypeName.startsWith(this.namespace + '.')) {
|
|
1969
|
-
resValue = removeNamespace(fullTypeName, this.namespace);
|
|
1970
|
-
resValue = this.transformation.transformTypeName(resValue);
|
|
1971
|
-
// TODO: check if resValue is a class, enum or interface before transformClassName
|
|
1972
|
-
resValue = this.transformation.transformClassName(resValue);
|
|
1973
|
-
namespace = this.namespace;
|
|
1974
|
-
resValue = namespace + '.' + resValue;
|
|
1975
|
-
}
|
|
1976
|
-
else {
|
|
1977
|
-
const resValues = fullTypeName.split('.');
|
|
1978
|
-
resValues.map((name) => this.transformation.transformTypeName(name));
|
|
1979
|
-
// TODO: check if resValues[resValues.length - 1] is a class, enum, interface before transformClassName
|
|
1980
|
-
resValues[resValues.length - 1] = this.transformation.transformClassName(resValues[resValues.length - 1]);
|
|
1981
|
-
resValue = resValues.join('.');
|
|
1982
|
-
namespace = resValues[0];
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
return {
|
|
1986
|
-
value: resValue,
|
|
1987
|
-
namespace,
|
|
1988
|
-
};
|
|
1989
|
-
}
|
|
1990
|
-
loadInheritance(inheritanceTable) {
|
|
1991
|
-
// Class hierarchy
|
|
1992
|
-
for (const girClass of this.ns.class ? this.ns.class : []) {
|
|
1993
|
-
let parent = null;
|
|
1994
|
-
if (girClass.$ && girClass.$.parent)
|
|
1995
|
-
parent = girClass.$.parent;
|
|
1996
|
-
if (!parent)
|
|
1997
|
-
continue;
|
|
1998
|
-
if (!girClass._fullSymName)
|
|
1999
|
-
continue;
|
|
2000
|
-
if (!parent.includes('.')) {
|
|
2001
|
-
parent = addNamespace(parent, this.namespace);
|
|
2002
|
-
}
|
|
2003
|
-
const className = girClass._fullSymName;
|
|
2004
|
-
const arr = inheritanceTable[className] || [];
|
|
2005
|
-
arr.push(parent);
|
|
2006
|
-
inheritanceTable[className] = arr;
|
|
2007
|
-
}
|
|
2008
|
-
// Class interface implementations
|
|
2009
|
-
for (const girClass of this.ns.class ? this.ns.class : []) {
|
|
2010
|
-
if (!girClass._fullSymName)
|
|
2011
|
-
continue;
|
|
2012
|
-
const names = [];
|
|
2013
|
-
if (girClass.implements) {
|
|
2014
|
-
for (const girImplements of girClass.implements) {
|
|
2015
|
-
if (girImplements.$.name) {
|
|
2016
|
-
let name = girImplements.$.name;
|
|
2017
|
-
if (!name.includes('.')) {
|
|
2018
|
-
name = girClass._fullSymName.substring(0, girClass._fullSymName.indexOf('.') + 1) + name;
|
|
2019
|
-
}
|
|
2020
|
-
names.push(name);
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
if (names.length > 0) {
|
|
2025
|
-
const className = girClass._fullSymName;
|
|
2026
|
-
const arr = inheritanceTable[className] || [];
|
|
2027
|
-
inheritanceTable[className] = arr.concat(names);
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
loadTypes() {
|
|
2032
|
-
if (this.ns.bitfield)
|
|
2033
|
-
this.annotateAndRegisterGirElement(this.ns.bitfield);
|
|
2034
|
-
if (this.ns.callback)
|
|
2035
|
-
this.annotateAndRegisterGirElement(this.ns.callback);
|
|
2036
|
-
if (this.ns.class)
|
|
2037
|
-
this.annotateAndRegisterGirElement(this.ns.class);
|
|
2038
|
-
if (this.ns.constant)
|
|
2039
|
-
this.annotateAndRegisterGirElement(this.ns.constant);
|
|
2040
|
-
if (this.ns.enumeration)
|
|
2041
|
-
this.annotateAndRegisterGirElement(this.ns.enumeration);
|
|
2042
|
-
if (this.ns.function)
|
|
2043
|
-
this.annotateAndRegisterGirElement(this.ns.function);
|
|
2044
|
-
if (this.ns.interface)
|
|
2045
|
-
this.annotateAndRegisterGirElement(this.ns.interface);
|
|
2046
|
-
if (this.ns.record)
|
|
2047
|
-
this.annotateAndRegisterGirElement(this.ns.record);
|
|
2048
|
-
if (this.ns.union)
|
|
2049
|
-
this.annotateAndRegisterGirElement(this.ns.union);
|
|
2050
|
-
if (this.ns.alias)
|
|
2051
|
-
this.annotateAndRegisterGirElement(this.ns.alias);
|
|
2052
|
-
if (this.ns.callback)
|
|
2053
|
-
for (const girCallback of this.ns.callback)
|
|
2054
|
-
this.annotateFunctionArguments(girCallback);
|
|
2055
|
-
for (const girClass of this.ns.class || []) {
|
|
2056
|
-
this.annotateClass(girClass, 'class');
|
|
2057
|
-
}
|
|
2058
|
-
for (const girClass of this.ns.record || []) {
|
|
2059
|
-
this.annotateClass(girClass, 'record');
|
|
2060
|
-
}
|
|
2061
|
-
for (const girClass of this.ns.interface || []) {
|
|
2062
|
-
this.annotateClass(girClass, 'interface');
|
|
2063
|
-
}
|
|
2064
|
-
if (this.ns.function)
|
|
2065
|
-
this.annotateFunctions(this.ns.function);
|
|
2066
|
-
if (this.ns.callback)
|
|
2067
|
-
this.annotateFunctions(this.ns.callback);
|
|
2068
|
-
if (this.ns.constant)
|
|
2069
|
-
this.annotateVariables(this.ns.constant);
|
|
2070
|
-
}
|
|
2071
|
-
/**
|
|
2072
|
-
* Before processing the typescript data, each module should be initialized first.
|
|
2073
|
-
* This is done in the `GenerationHandler`.
|
|
2074
|
-
*/
|
|
2075
|
-
init(inheritanceTable) {
|
|
2076
|
-
this.loadTypes();
|
|
2077
|
-
this.loadInheritance(inheritanceTable);
|
|
2078
|
-
}
|
|
2079
|
-
/**
|
|
2080
|
-
* Start processing the typescript data
|
|
2081
|
-
*/
|
|
2082
|
-
start() {
|
|
2083
|
-
this.setModuleTsData();
|
|
2084
|
-
}
|
|
2085
|
-
}
|
|
2086
|
-
//# sourceMappingURL=gir-module.js.map
|