@ts-for-gir/cli 3.0.0-beta.9 → 3.0.1
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/src/conflict-resolver.ts
DELETED
|
@@ -1,1358 +0,0 @@
|
|
|
1
|
-
import { GirFactory } from './gir-factory.js'
|
|
2
|
-
import { Logger } from './logger.js'
|
|
3
|
-
import { NO_TSDATA } from './messages.js'
|
|
4
|
-
import { isEqual, merge, clone, typeIsOptional } from './utils.js'
|
|
5
|
-
import { SIGNAL_METHOD_NAMES, MAX_CLASS_PARENT_DEPTH } from './constants.js'
|
|
6
|
-
import type {
|
|
7
|
-
Environment,
|
|
8
|
-
GirClassElement,
|
|
9
|
-
GirRecordElement,
|
|
10
|
-
GirUnionElement,
|
|
11
|
-
GirInterfaceElement,
|
|
12
|
-
GirCallableParamElement,
|
|
13
|
-
GirMethodElement,
|
|
14
|
-
GirVirtualMethodElement,
|
|
15
|
-
GirConstructorElement,
|
|
16
|
-
GirFunctionElement,
|
|
17
|
-
GirPropertyElement,
|
|
18
|
-
GirFieldElement,
|
|
19
|
-
TsSignal,
|
|
20
|
-
TsFunction,
|
|
21
|
-
TsProperty,
|
|
22
|
-
TsVar,
|
|
23
|
-
TsTypeSeparator,
|
|
24
|
-
TsType,
|
|
25
|
-
TsClass,
|
|
26
|
-
TsParameter,
|
|
27
|
-
TypeGirFunction,
|
|
28
|
-
TypeGirProperty,
|
|
29
|
-
ConflictChildElement,
|
|
30
|
-
ConflictGroupedElements,
|
|
31
|
-
ConflictGroupedElement,
|
|
32
|
-
} from './types/index.js'
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Resolve conflicts between types caused by overloads / inheritances and implementations
|
|
36
|
-
* With multiple implementations or a inherit it can happen that the interfaces / parent have the same method and/or property names with incompatible types,
|
|
37
|
-
* we are trying to resolve this conflicts by merging, overloading or removing this conflicts.
|
|
38
|
-
*/
|
|
39
|
-
export class ConflictResolver {
|
|
40
|
-
private log: Logger
|
|
41
|
-
|
|
42
|
-
private girFactory = new GirFactory()
|
|
43
|
-
|
|
44
|
-
constructor(private readonly environment: Environment, private readonly verbose: boolean) {
|
|
45
|
-
this.log = new Logger(environment, verbose, 'ConflictResolver')
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private girElArrToChildArr<T = TsFunction | TsProperty | TsVar>(
|
|
49
|
-
dataArr: Array<
|
|
50
|
-
| GirMethodElement
|
|
51
|
-
| GirVirtualMethodElement
|
|
52
|
-
| GirConstructorElement
|
|
53
|
-
| GirFunctionElement
|
|
54
|
-
| GirPropertyElement
|
|
55
|
-
| GirFieldElement
|
|
56
|
-
>,
|
|
57
|
-
depth: number,
|
|
58
|
-
): ConflictChildElement<T>[] {
|
|
59
|
-
return dataArr
|
|
60
|
-
.filter((data) => !!data?._tsData)
|
|
61
|
-
.map((data) => {
|
|
62
|
-
if (!data?._tsData) throw new Error('_tsData not set!')
|
|
63
|
-
return {
|
|
64
|
-
depth,
|
|
65
|
-
data: data?._tsData as unknown as T,
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private tsElArrToChildArr<T extends ConflictChildElement>(
|
|
71
|
-
dataArr: Array<TsFunction | TsProperty | TsVar>,
|
|
72
|
-
depth: number,
|
|
73
|
-
): T[] {
|
|
74
|
-
return dataArr
|
|
75
|
-
.filter((m) => !!m)
|
|
76
|
-
.map((data) => {
|
|
77
|
-
return {
|
|
78
|
-
depth,
|
|
79
|
-
data,
|
|
80
|
-
} as T
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Get class elements and parent elements (implementations and inherits)
|
|
86
|
-
* @param tsClass
|
|
87
|
-
* @param depth
|
|
88
|
-
* @returns
|
|
89
|
-
*/
|
|
90
|
-
private getClassElements(tsClass: TsClass, depth: number, processedClasses: string[]) {
|
|
91
|
-
const tsClassFullPackageSymName = `${tsClass.namespace}-${tsClass.version}.${tsClass.namespace}.${tsClass.name}`
|
|
92
|
-
|
|
93
|
-
const signalMethods: ConflictChildElement<TsFunction>[] = []
|
|
94
|
-
const propertySignalMethods: ConflictChildElement<TsFunction>[] = []
|
|
95
|
-
const methods: ConflictChildElement<TsFunction>[] = []
|
|
96
|
-
const virtualMethods: ConflictChildElement<TsFunction>[] = []
|
|
97
|
-
const staticFunctions: ConflictChildElement<TsFunction>[] = []
|
|
98
|
-
const constructors: ConflictChildElement<TsFunction>[] = []
|
|
99
|
-
|
|
100
|
-
const properties: ConflictChildElement<TsProperty | TsVar>[] = []
|
|
101
|
-
const fields: ConflictChildElement<TsProperty | TsVar>[] = []
|
|
102
|
-
const constructProps: ConflictChildElement<TsProperty | TsVar>[] = []
|
|
103
|
-
|
|
104
|
-
const depthLimitReached = depth >= MAX_CLASS_PARENT_DEPTH
|
|
105
|
-
const classAlreadyProcessed = processedClasses.includes(tsClassFullPackageSymName)
|
|
106
|
-
|
|
107
|
-
if (depthLimitReached || classAlreadyProcessed) {
|
|
108
|
-
if (depthLimitReached) {
|
|
109
|
-
this.log.error(`[getClassElements] Maximum recursion depth reached (limit: ${MAX_CLASS_PARENT_DEPTH})!`)
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
signalMethods,
|
|
113
|
-
propertySignalMethods,
|
|
114
|
-
methods,
|
|
115
|
-
virtualMethods,
|
|
116
|
-
staticFunctions,
|
|
117
|
-
constructors,
|
|
118
|
-
properties,
|
|
119
|
-
fields,
|
|
120
|
-
constructProps,
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Signals
|
|
125
|
-
const _signals = tsClass.signals.map((s) => s._tsData).filter((s) => !!s) as TsSignal[]
|
|
126
|
-
for (const tsSignal of _signals) {
|
|
127
|
-
signalMethods.push(...this.tsElArrToChildArr<ConflictChildElement<TsFunction>>(tsSignal.tsMethods, depth))
|
|
128
|
-
}
|
|
129
|
-
// Property signals
|
|
130
|
-
propertySignalMethods.push(
|
|
131
|
-
...this.tsElArrToChildArr<ConflictChildElement<TsFunction>>(tsClass.propertySignalMethods, depth),
|
|
132
|
-
)
|
|
133
|
-
// Methods
|
|
134
|
-
if (tsClass.methods.length) methods.push(...this.girElArrToChildArr<TsFunction>(tsClass.methods, depth))
|
|
135
|
-
// Virtual methods
|
|
136
|
-
if (tsClass.virtualMethods.length)
|
|
137
|
-
virtualMethods.push(...this.girElArrToChildArr<TsFunction>(tsClass.virtualMethods, depth))
|
|
138
|
-
// Static functions
|
|
139
|
-
if (tsClass.staticFunctions.length)
|
|
140
|
-
staticFunctions.push(...this.girElArrToChildArr<TsFunction>(tsClass.staticFunctions, depth))
|
|
141
|
-
// Constructors
|
|
142
|
-
if (tsClass.constructors.length)
|
|
143
|
-
constructors.push(...this.girElArrToChildArr<TsFunction>(tsClass.constructors, depth))
|
|
144
|
-
// Properties
|
|
145
|
-
if (tsClass.properties.length)
|
|
146
|
-
properties.push(...this.girElArrToChildArr<TsProperty | TsVar>(tsClass.properties, depth))
|
|
147
|
-
// Fields
|
|
148
|
-
if (tsClass.fields.length) fields.push(...this.girElArrToChildArr<TsProperty | TsVar>(tsClass.fields, depth))
|
|
149
|
-
// Constructor properties
|
|
150
|
-
if (tsClass.constructProps.length)
|
|
151
|
-
constructProps.push(...this.girElArrToChildArr<TsProperty | TsVar>(tsClass.constructProps, depth))
|
|
152
|
-
|
|
153
|
-
for (const ifacePackageFullSymName of Object.keys(tsClass.implements)) {
|
|
154
|
-
if (tsClassFullPackageSymName === ifacePackageFullSymName) {
|
|
155
|
-
this.log.warn("[getImplementedInterfaceElements] A interface can't implement itself")
|
|
156
|
-
continue
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const { interface: implementation, depth: parentDepth } = tsClass.implements[ifacePackageFullSymName]
|
|
160
|
-
const implementationElements = this.getClassElements(
|
|
161
|
-
implementation,
|
|
162
|
-
parentDepth + depth + 1,
|
|
163
|
-
processedClasses,
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
signalMethods.push(...implementationElements.signalMethods)
|
|
167
|
-
propertySignalMethods.push(...implementationElements.propertySignalMethods)
|
|
168
|
-
methods.push(...implementationElements.methods)
|
|
169
|
-
virtualMethods.push(...implementationElements.virtualMethods)
|
|
170
|
-
staticFunctions.push(...implementationElements.staticFunctions)
|
|
171
|
-
constructors.push(...implementationElements.constructors)
|
|
172
|
-
properties.push(...implementationElements.properties)
|
|
173
|
-
fields.push(...implementationElements.fields)
|
|
174
|
-
constructProps.push(...implementationElements.constructProps)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
for (const ifaceFullPackageSymName of Object.keys(tsClass.inherit)) {
|
|
178
|
-
if (tsClassFullPackageSymName === ifaceFullPackageSymName) {
|
|
179
|
-
this.log.warn("[getClassElements] A class can't inherit itself")
|
|
180
|
-
continue
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const { class: inherit, depth: parentDepth } = tsClass.inherit[ifaceFullPackageSymName]
|
|
184
|
-
const inheritElements = this.getClassElements(inherit, parentDepth + depth + 1, processedClasses)
|
|
185
|
-
|
|
186
|
-
signalMethods.push(...inheritElements.signalMethods)
|
|
187
|
-
propertySignalMethods.push(...inheritElements.propertySignalMethods)
|
|
188
|
-
methods.push(...inheritElements.methods)
|
|
189
|
-
virtualMethods.push(...inheritElements.virtualMethods)
|
|
190
|
-
staticFunctions.push(...inheritElements.staticFunctions)
|
|
191
|
-
constructors.push(...inheritElements.constructors)
|
|
192
|
-
properties.push(...inheritElements.properties)
|
|
193
|
-
fields.push(...inheritElements.fields)
|
|
194
|
-
constructProps.push(...inheritElements.constructProps)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
processedClasses.push(tsClassFullPackageSymName)
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
signalMethods,
|
|
201
|
-
propertySignalMethods,
|
|
202
|
-
methods,
|
|
203
|
-
virtualMethods,
|
|
204
|
-
staticFunctions,
|
|
205
|
-
constructors,
|
|
206
|
-
properties,
|
|
207
|
-
fields,
|
|
208
|
-
constructProps,
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
private tsElementIsMethod(el: TsFunction | TsVar) {
|
|
213
|
-
return !this.tsElementIsStatic(el) && this.tsElementIsMethodOrFunction(el)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
private tsElementIsStaticFunction(el: TsFunction | TsVar) {
|
|
217
|
-
return this.tsElementIsStatic(el) && this.tsElementIsMethodOrFunction(el)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
private tsElementIsProperty(el: TsFunction | TsVar) {
|
|
221
|
-
return !this.tsElementIsStatic(el) && this.tsElementIsPropertyOrVariable(el)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
private tsElementIsStaticProperty(el: TsFunction | TsVar) {
|
|
225
|
-
return this.tsElementIsStatic(el) && this.tsElementIsPropertyOrVariable(el)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
private tsElementIsSignal(el: TsFunction | TsVar) {
|
|
229
|
-
return el.tsTypeName === 'event-methods'
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
private tsElementIsConstructor(el: TsFunction | TsVar) {
|
|
233
|
-
return el.tsTypeName === 'constructor'
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
private tsElementIsMethodOrFunction(el: TsFunction | TsVar) {
|
|
237
|
-
return el.tsTypeName === 'function' || el.tsTypeName === 'method' || el.tsTypeName === 'static-function'
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
private tsElementIsPropertyOrVariable(el: TsFunction | TsVar | TsProperty) {
|
|
241
|
-
return (
|
|
242
|
-
el.tsTypeName === 'constant' ||
|
|
243
|
-
el.tsTypeName === 'constructor-property' ||
|
|
244
|
-
el.tsTypeName === 'property' ||
|
|
245
|
-
el.tsTypeName === 'static-property'
|
|
246
|
-
)
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
private tsElementIsStatic(el: TsFunction | TsVar) {
|
|
250
|
-
return (
|
|
251
|
-
// el.tsTypeName === 'constructor' ||
|
|
252
|
-
(el as TsFunction).isStatic || el.tsTypeName === 'static-property' || el.tsTypeName === 'static-function'
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
private typeIsString(type: TsType) {
|
|
257
|
-
return (
|
|
258
|
-
type.type === 'string' ||
|
|
259
|
-
(type.type.startsWith("'") && type.type.endsWith("'")) ||
|
|
260
|
-
(type.type.startsWith('"') && type.type.endsWith('"'))
|
|
261
|
-
)
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
private mergeTypes(leftSeparator: TsTypeSeparator, ...types: Array<TsType | undefined>) {
|
|
265
|
-
const dest: TsType[] = []
|
|
266
|
-
|
|
267
|
-
for (const type of types) {
|
|
268
|
-
if (!type) continue
|
|
269
|
-
if (!dest.find((destType) => isEqual(destType, type))) {
|
|
270
|
-
dest.push({ ...type, leftSeparator })
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return dest
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
private setTypesProperty(types: TsType[], property: 'optional', value: boolean) {
|
|
278
|
-
for (const type of types) {
|
|
279
|
-
type[property] = value
|
|
280
|
-
}
|
|
281
|
-
return types
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Merges two parameter name and type of two parameters
|
|
286
|
-
* @param a
|
|
287
|
-
* @param b
|
|
288
|
-
* @returns
|
|
289
|
-
*/
|
|
290
|
-
private mergeParam(a: GirCallableParamElement | undefined, b: GirCallableParamElement | undefined) {
|
|
291
|
-
if (!a?._tsData && !b?._tsData) {
|
|
292
|
-
throw new Error('At least one parameter must be defined!')
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
let dest: GirCallableParamElement
|
|
296
|
-
|
|
297
|
-
if (a?._tsData && b?._tsData) {
|
|
298
|
-
dest = merge({}, clone(a), clone(b))
|
|
299
|
-
if (!dest._tsData) {
|
|
300
|
-
throw new Error('Error on merge parameters!')
|
|
301
|
-
}
|
|
302
|
-
dest._tsData.type = []
|
|
303
|
-
dest._tsData.type = this.mergeTypes('|', ...a._tsData.type, ...b._tsData.type)
|
|
304
|
-
if (a._tsData.name !== b._tsData.name) {
|
|
305
|
-
dest._tsData.name = `${a._tsData.name}_or_${b._tsData.name}`
|
|
306
|
-
}
|
|
307
|
-
} else {
|
|
308
|
-
dest = clone((a || b) as GirCallableParamElement)
|
|
309
|
-
if (!dest._tsData) {
|
|
310
|
-
throw new Error('Error on merge parameters!')
|
|
311
|
-
}
|
|
312
|
-
// If `a` or `b` is undefined make the types optional
|
|
313
|
-
dest._tsData.type = this.setTypesProperty(dest._tsData.type, 'optional', true)
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (typeIsOptional(dest._tsData.type)) {
|
|
317
|
-
dest._tsData.type = this.setTypesProperty(dest._tsData.type, 'optional', true)
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return dest
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Merges parameter names and types of multiple functions
|
|
325
|
-
* @param params
|
|
326
|
-
* @returns
|
|
327
|
-
*/
|
|
328
|
-
private mergeParams(...params: GirCallableParamElement[][]) {
|
|
329
|
-
let dest: GirCallableParamElement[] = []
|
|
330
|
-
|
|
331
|
-
for (const a of params) {
|
|
332
|
-
for (const b of params) {
|
|
333
|
-
if (a === b) {
|
|
334
|
-
continue
|
|
335
|
-
}
|
|
336
|
-
if (isEqual(a, b)) {
|
|
337
|
-
dest = clone(a)
|
|
338
|
-
} else {
|
|
339
|
-
const length = Math.max(a.length, b.length)
|
|
340
|
-
dest = new Array<GirCallableParamElement>(length)
|
|
341
|
-
for (let i = 0; i < length; i++) {
|
|
342
|
-
const aParam = a[i] as GirCallableParamElement | undefined
|
|
343
|
-
const bParam = b[i] as GirCallableParamElement | undefined
|
|
344
|
-
dest[i] = this.mergeParam(aParam, bParam)
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
return dest
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
private paramCanBeOptional(
|
|
354
|
-
girParam: GirCallableParamElement,
|
|
355
|
-
girParams: GirCallableParamElement[],
|
|
356
|
-
skip: GirCallableParamElement[] = [],
|
|
357
|
-
) {
|
|
358
|
-
if (!girParam._tsData) return false
|
|
359
|
-
let canBeOptional = true
|
|
360
|
-
const index = girParams.indexOf(girParam)
|
|
361
|
-
const following = girParams
|
|
362
|
-
.slice(index)
|
|
363
|
-
.filter((p) => !!p._tsData)
|
|
364
|
-
.filter(() => !skip.includes(girParam))
|
|
365
|
-
.filter((p) => p.$.direction !== 'out')
|
|
366
|
-
.map((p) => p._tsData)
|
|
367
|
-
|
|
368
|
-
if (following.some((p) => p && !typeIsOptional(p.type))) {
|
|
369
|
-
canBeOptional = false
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return canBeOptional
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* In Typescript no optional parameters are allowed if the following ones are not optional
|
|
377
|
-
* @param girParams
|
|
378
|
-
* @returns
|
|
379
|
-
*/
|
|
380
|
-
private fixOptionalParameters(girParams: GirCallableParamElement[]) {
|
|
381
|
-
for (const girParam of girParams) {
|
|
382
|
-
if (!girParam._tsData) throw new Error(NO_TSDATA('fixOptionalParameters'))
|
|
383
|
-
if (typeIsOptional(girParam._tsData.type) && !this.paramCanBeOptional(girParam, girParams)) {
|
|
384
|
-
this.setTypesProperty(girParam._tsData.type, 'optional', false)
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
return girParams
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Merge function types and parameters together
|
|
392
|
-
* @param baseFunc The function to change or null if you want to create a new property
|
|
393
|
-
* @param funcs The functions you want to merge
|
|
394
|
-
* @returns
|
|
395
|
-
*/
|
|
396
|
-
public mergeFunctions(baseFunc: TsFunction | null, ...funcs: TsFunction[]) {
|
|
397
|
-
const returnTypesMap: TsType[] = []
|
|
398
|
-
for (const func of funcs) {
|
|
399
|
-
returnTypesMap.push(...func.returnTypes)
|
|
400
|
-
}
|
|
401
|
-
const returnTypes = this.mergeTypes('|', ...returnTypesMap)
|
|
402
|
-
|
|
403
|
-
const inParamsMap = funcs.map((func) => func.inParams)
|
|
404
|
-
const inParams: GirCallableParamElement[] = []
|
|
405
|
-
if (this.paramsHasConflict(...inParamsMap)) {
|
|
406
|
-
inParams.push(...this.mergeParams(...inParamsMap))
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
const outParamsMap = funcs.map((func) => func.outParams)
|
|
410
|
-
const outParams: GirCallableParamElement[] = []
|
|
411
|
-
if (this.paramsHasConflict(...outParamsMap)) {
|
|
412
|
-
outParams.push(...this.mergeParams(...outParamsMap))
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
if (!funcs[0]) {
|
|
416
|
-
throw new Error('At least one function must exist!')
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
if (baseFunc) {
|
|
420
|
-
baseFunc.returnTypes = returnTypes
|
|
421
|
-
return baseFunc
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
return this.girFactory.newTsFunction(
|
|
425
|
-
{
|
|
426
|
-
name: funcs[0].name,
|
|
427
|
-
returnTypes: returnTypes,
|
|
428
|
-
isStatic: funcs[0].isStatic || false,
|
|
429
|
-
inParams: inParams.map((inParam) => inParam._tsData).filter((inParam) => !!inParam) as TsParameter[],
|
|
430
|
-
outParams: outParams
|
|
431
|
-
.map((outParam) => outParam._tsData)
|
|
432
|
-
.filter((outParam) => !!outParam) as TsParameter[],
|
|
433
|
-
girTypeName: funcs[0].girTypeName,
|
|
434
|
-
},
|
|
435
|
-
funcs[0].parent,
|
|
436
|
-
)
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* Merge property types together
|
|
441
|
-
* @param baseProp The property to change or null if you want to create a new property
|
|
442
|
-
* @param props The properties you want to merge
|
|
443
|
-
* @returns
|
|
444
|
-
*/
|
|
445
|
-
public mergeProperties(typeSeparator: TsTypeSeparator, baseProp: TsProperty | null, ...props: TsProperty[]) {
|
|
446
|
-
const typesMap: TsType[] = []
|
|
447
|
-
for (const prop of props) {
|
|
448
|
-
typesMap.push(...prop.type)
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const types = this.mergeTypes(typeSeparator, ...typesMap)
|
|
452
|
-
|
|
453
|
-
// Merge readonly
|
|
454
|
-
let readonly = false
|
|
455
|
-
for (const prop of props) {
|
|
456
|
-
readonly = readonly || prop.readonly || false
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if (!props[0] || !props[0].name) {
|
|
460
|
-
throw new Error('At least one property to merge must exist!')
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
if (baseProp) {
|
|
464
|
-
baseProp.type = types
|
|
465
|
-
baseProp.readonly = readonly
|
|
466
|
-
return baseProp
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
const newProp = this.girFactory.newTsProperty({
|
|
470
|
-
readonly: readonly,
|
|
471
|
-
isStatic: props[0].isStatic || false,
|
|
472
|
-
name: props[0].name,
|
|
473
|
-
type: types,
|
|
474
|
-
girTypeName: props[0].girTypeName,
|
|
475
|
-
})
|
|
476
|
-
return newProp
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Check if there is a type conflict between the ts elements a and b
|
|
481
|
-
* @param a
|
|
482
|
-
* @param b
|
|
483
|
-
* @returns
|
|
484
|
-
*/
|
|
485
|
-
public hasConflict(a: ConflictChildElement, b: ConflictChildElement) {
|
|
486
|
-
if (a !== b && a.data.name === b.data.name) {
|
|
487
|
-
const name = a.data.name
|
|
488
|
-
// Ignore element with name of:
|
|
489
|
-
if (name === 'constructor' || name === '_init') {
|
|
490
|
-
return false
|
|
491
|
-
}
|
|
492
|
-
if (this.elementHasConflict(a.data, b.data)) {
|
|
493
|
-
return true
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
return false
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
public newAnyTsProperty(name: string, girTypeName: TypeGirProperty) {
|
|
501
|
-
return this.girFactory.newTsProperty({
|
|
502
|
-
name,
|
|
503
|
-
girTypeName,
|
|
504
|
-
type: [{ type: 'any' }],
|
|
505
|
-
})
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* Returns a new any function: `name(...args: any[]): any`
|
|
510
|
-
* @param name The name of the function
|
|
511
|
-
*/
|
|
512
|
-
public newAnyTsFunction(name: string, girTypeName: TypeGirFunction, isStatic: boolean, parent: TsClass | null) {
|
|
513
|
-
return this.girFactory.newTsFunction(
|
|
514
|
-
{
|
|
515
|
-
name,
|
|
516
|
-
isStatic,
|
|
517
|
-
inParams: [
|
|
518
|
-
{
|
|
519
|
-
name: 'args',
|
|
520
|
-
isRest: true,
|
|
521
|
-
type: [this.girFactory.newTsType({ type: 'any', isArray: true })],
|
|
522
|
-
},
|
|
523
|
-
],
|
|
524
|
-
returnTypes: [{ type: 'any' }],
|
|
525
|
-
girTypeName,
|
|
526
|
-
},
|
|
527
|
-
parent,
|
|
528
|
-
)
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
public getCompatibleTsProperty(elements: TsProperty[], baseProp: TsProperty) {
|
|
532
|
-
return elements.find((prop) => !this.propertyHasConflict(baseProp, prop))
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
public getCompatibleTsFunction(elements: TsFunction[], baseFunc: TsFunction) {
|
|
536
|
-
return elements.find((func) => !this.functionHasConflict(baseFunc, func))
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Use this instead of `getCompatibleTsProperty` and `getCompatibleTsProperty` if you can, because it's much faster
|
|
541
|
-
* @param elements
|
|
542
|
-
* @param name
|
|
543
|
-
* @returns
|
|
544
|
-
*/
|
|
545
|
-
public getTsElementByName(elements: (TsProperty | TsFunction)[], name: string) {
|
|
546
|
-
return elements.find((el) => el.name === name)
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
protected canAddConflictProperty(conflictProperties: TsProperty[], prop: TsProperty) {
|
|
550
|
-
const canAdd =
|
|
551
|
-
prop.name &&
|
|
552
|
-
// Only one property can be defined, no overloads
|
|
553
|
-
!this.getTsElementByName(conflictProperties, prop.name) &&
|
|
554
|
-
// Do not set properties with signal method names
|
|
555
|
-
!SIGNAL_METHOD_NAMES(this.environment).includes(prop.name)
|
|
556
|
-
|
|
557
|
-
return canAdd
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
public groupSignalConflicts(signalsMethods: ConflictChildElement<TsFunction>[], baseClass: TsClass) {
|
|
561
|
-
const groupedConflicts: ConflictGroupedElements = {}
|
|
562
|
-
for (const base of signalsMethods) {
|
|
563
|
-
for (const b of signalsMethods) {
|
|
564
|
-
if (base === b) {
|
|
565
|
-
continue
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
if (base.data.name !== 'connect' && base.data.name !== 'connect_after') {
|
|
569
|
-
continue
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
const sigNameParam = base.data.inParams[0]
|
|
573
|
-
// const callbackParam = base.data.inParams[1]
|
|
574
|
-
|
|
575
|
-
const eventName = sigNameParam?._tsData?.type?.[0]?.type
|
|
576
|
-
// TODO do not render the callback type as a full string, create a TSCallback instead
|
|
577
|
-
// const callbackType = callbackParam?._tsData?.type?.[0]?.type
|
|
578
|
-
// console.debug('eventName', eventName, callbackType)
|
|
579
|
-
|
|
580
|
-
if (!eventName || eventName === 'string') {
|
|
581
|
-
continue
|
|
582
|
-
}
|
|
583
|
-
groupedConflicts[eventName] ||= {
|
|
584
|
-
baseElements: [],
|
|
585
|
-
inheritedElements: [],
|
|
586
|
-
baseClass,
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
const groupedConflict = groupedConflicts[eventName]
|
|
590
|
-
const isBaseElement = base.depth === 0
|
|
591
|
-
if (isBaseElement) {
|
|
592
|
-
if (!groupedConflict.baseElements.find((c) => isEqual(c.data, base.data))) {
|
|
593
|
-
groupedConflict.baseElements.push(base)
|
|
594
|
-
}
|
|
595
|
-
} else {
|
|
596
|
-
if (!groupedConflict.inheritedElements.find((c) => isEqual(c.data, base.data))) {
|
|
597
|
-
groupedConflict.inheritedElements.push(base)
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
return groupedConflicts
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
public fixSignalConflicts(groupedElements: ConflictGroupedElements) {
|
|
607
|
-
for (const eventName of Object.keys(groupedElements)) {
|
|
608
|
-
const elements = groupedElements[eventName]
|
|
609
|
-
|
|
610
|
-
const bases = elements.baseElements
|
|
611
|
-
|
|
612
|
-
if (!bases.length) {
|
|
613
|
-
// TODO
|
|
614
|
-
// return this.fixIndirectSignalConflicts(elements.inheritedElements, elements.baseClass)
|
|
615
|
-
return
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
for (const base of bases) {
|
|
619
|
-
if (base.data.hasUnresolvedConflict) {
|
|
620
|
-
continue
|
|
621
|
-
}
|
|
622
|
-
for (const b of elements.inheritedElements) {
|
|
623
|
-
if (b === base || b.data.hasUnresolvedConflict) {
|
|
624
|
-
continue
|
|
625
|
-
}
|
|
626
|
-
// TODO
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* Check conflicts between the implementations / inheritances
|
|
634
|
-
* To fix type errors like:
|
|
635
|
-
* ```
|
|
636
|
-
* Interface 'PopoverMenu' can\'t simultaneously extend types 'Popover' and 'Native'.
|
|
637
|
-
* Named property 'parent' of types 'Popover' and 'Native' are not identical.
|
|
638
|
-
*/
|
|
639
|
-
public fixIndirectConflicts(name: string, elements: ConflictChildElement[], baseClass: TsClass) {
|
|
640
|
-
for (const base of elements) {
|
|
641
|
-
if (base.data.hasUnresolvedConflict) {
|
|
642
|
-
continue
|
|
643
|
-
}
|
|
644
|
-
for (const b of elements) {
|
|
645
|
-
if (b === base || b.data.hasUnresolvedConflict) {
|
|
646
|
-
continue
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
const className = `${baseClass.namespace}-${baseClass.version}.${baseClass.name}`
|
|
650
|
-
|
|
651
|
-
// If a element is a function / method
|
|
652
|
-
if (this.tsElementIsMethodOrFunction(base.data)) {
|
|
653
|
-
const baseFunc = base.data as TsFunction
|
|
654
|
-
|
|
655
|
-
// Function vs. Property
|
|
656
|
-
if (this.tsElementIsPropertyOrVariable(b.data)) {
|
|
657
|
-
this.log.debug(`${className}.${name} External Function vs. Property`, baseFunc, b.data)
|
|
658
|
-
b.data.hasUnresolvedConflict = true
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
// Function vs. Signal
|
|
662
|
-
else if (this.tsElementIsSignal(b.data)) {
|
|
663
|
-
this.log.debug(`${className}.${name} External Function vs. Signal`, baseFunc, b.data)
|
|
664
|
-
baseFunc.hasUnresolvedConflict = true
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
// Function vs. Function
|
|
668
|
-
else if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
669
|
-
const bFunc = b.data as TsFunction
|
|
670
|
-
this.log.debug(
|
|
671
|
-
`${className}.${name} External Function vs. Function`,
|
|
672
|
-
baseFunc.inParams.map((p) => p._tsData?.name).join(', '),
|
|
673
|
-
bFunc.inParams.map((p) => p._tsData?.name).join(', '),
|
|
674
|
-
)
|
|
675
|
-
|
|
676
|
-
// Just add conflicting methods to the class
|
|
677
|
-
if (!baseClass.conflictMethods.includes(baseFunc)) {
|
|
678
|
-
baseClass.conflictMethods.push(baseFunc)
|
|
679
|
-
}
|
|
680
|
-
if (!baseClass.conflictMethods.includes(bFunc)) {
|
|
681
|
-
baseClass.conflictMethods.push(bFunc)
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
// Function vs. Constructor
|
|
686
|
-
else if (this.tsElementIsConstructor(base.data)) {
|
|
687
|
-
const bConstr = b.data as TsFunction
|
|
688
|
-
this.log.debug(`${className}.${name} External Function vs. Constructor`, baseFunc, bConstr)
|
|
689
|
-
|
|
690
|
-
// Just add conflicting methods to the class
|
|
691
|
-
if (!baseClass.conflictMethods.includes(baseFunc)) {
|
|
692
|
-
baseClass.conflictMethods.push(baseFunc)
|
|
693
|
-
}
|
|
694
|
-
if (!baseClass.conflictMethods.includes(bConstr)) {
|
|
695
|
-
baseClass.conflictMethods.push(bConstr)
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
// Function vs. Unknown
|
|
700
|
-
else {
|
|
701
|
-
this.log.debug(`${className}.${name} External Unknown ${b.data.tsTypeName}`, baseFunc, b.data)
|
|
702
|
-
baseFunc.hasUnresolvedConflict = true
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
// If a element is a constructor
|
|
707
|
-
else if (this.tsElementIsConstructor(base.data)) {
|
|
708
|
-
const baseConstr = base.data as TsFunction
|
|
709
|
-
|
|
710
|
-
// Constructor vs. Function
|
|
711
|
-
if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
712
|
-
const bFunc = b.data as TsFunction
|
|
713
|
-
this.log.debug(
|
|
714
|
-
`${className}.${name} External Constructor vs. Function`,
|
|
715
|
-
baseConstr.inParams.map((p) => p._tsData?.name).join(', '),
|
|
716
|
-
bFunc.inParams.map((p) => p._tsData?.name).join(', '),
|
|
717
|
-
)
|
|
718
|
-
|
|
719
|
-
if (!baseClass.conflictMethods.includes(baseConstr)) {
|
|
720
|
-
baseClass.conflictMethods.push(baseConstr)
|
|
721
|
-
}
|
|
722
|
-
if (!baseClass.conflictMethods.includes(bFunc)) {
|
|
723
|
-
baseClass.conflictMethods.push(bFunc)
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
// Constructor vs. Constructor
|
|
728
|
-
else if (this.tsElementIsConstructor(base.data)) {
|
|
729
|
-
this.log.debug(`${className}.${name} External Constructor vs. Constructor`, baseConstr, b.data)
|
|
730
|
-
|
|
731
|
-
const anyFunc = this.newAnyTsFunction(
|
|
732
|
-
name,
|
|
733
|
-
baseConstr.girTypeName,
|
|
734
|
-
baseConstr.isStatic,
|
|
735
|
-
baseConstr.parent,
|
|
736
|
-
)
|
|
737
|
-
|
|
738
|
-
// Check if any function is not already added
|
|
739
|
-
if (!this.getTsElementByName(baseClass.conflictMethods, anyFunc.name)) {
|
|
740
|
-
baseClass.conflictMethods.push(anyFunc)
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// If a element is a property / variable
|
|
746
|
-
else if (this.tsElementIsPropertyOrVariable(base.data)) {
|
|
747
|
-
const baseProp = base.data as TsProperty
|
|
748
|
-
|
|
749
|
-
// Property vs. Function
|
|
750
|
-
if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
751
|
-
const bFunc = b.data as TsFunction
|
|
752
|
-
this.log.debug(
|
|
753
|
-
`${className}.${name} External Property vs. Function`,
|
|
754
|
-
baseProp.type[0].type,
|
|
755
|
-
bFunc,
|
|
756
|
-
)
|
|
757
|
-
baseProp.hasUnresolvedConflict = true
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
// Property vs. Property
|
|
761
|
-
else if (this.tsElementIsPropertyOrVariable(b.data)) {
|
|
762
|
-
const bProp = b.data as TsProperty
|
|
763
|
-
this.log.debug(
|
|
764
|
-
`${className}.${name} External Property vs. Property`,
|
|
765
|
-
baseProp.type[0].type,
|
|
766
|
-
bProp.type[0].type,
|
|
767
|
-
)
|
|
768
|
-
|
|
769
|
-
switch (name) {
|
|
770
|
-
case 'parent':
|
|
771
|
-
case 'window':
|
|
772
|
-
case 'parent_instance':
|
|
773
|
-
case 'priv':
|
|
774
|
-
const mergedProp = this.mergeProperties('&', null, baseProp, bProp)
|
|
775
|
-
if (this.canAddConflictProperty(baseClass.conflictProperties, mergedProp)) {
|
|
776
|
-
baseClass.conflictProperties.push(mergedProp)
|
|
777
|
-
}
|
|
778
|
-
break
|
|
779
|
-
|
|
780
|
-
default:
|
|
781
|
-
const anyProp = this.newAnyTsProperty(name, baseProp.girTypeName)
|
|
782
|
-
if (this.canAddConflictProperty(baseClass.conflictProperties, anyProp)) {
|
|
783
|
-
baseClass.conflictProperties.push(anyProp)
|
|
784
|
-
}
|
|
785
|
-
break
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
// Property vs. Signal
|
|
790
|
-
else if (this.tsElementIsSignal(b.data)) {
|
|
791
|
-
this.log.debug(`${className}.${name} External Property vs. Signal`, baseProp, b.data)
|
|
792
|
-
base.data.hasUnresolvedConflict = true
|
|
793
|
-
} else {
|
|
794
|
-
this.log.error(`${className}.${name} External Unknown ${b.data.tsTypeName}`, baseProp, b.data)
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// Other
|
|
799
|
-
else {
|
|
800
|
-
this.log.error(`${className}.${name} External Unknown ${base.data.tsTypeName}`)
|
|
801
|
-
base.data.hasUnresolvedConflict = true
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
/**
|
|
808
|
-
* Check conflicts within the class itself (ignores implementations / inheritances)
|
|
809
|
-
*/
|
|
810
|
-
public fixInternalConflicts(name: string, elements: ConflictChildElement[], baseClass: TsClass) {
|
|
811
|
-
for (const base of elements) {
|
|
812
|
-
if (base.data.hasUnresolvedConflict) {
|
|
813
|
-
continue
|
|
814
|
-
}
|
|
815
|
-
for (const b of elements) {
|
|
816
|
-
if (b === base || b.data.hasUnresolvedConflict) {
|
|
817
|
-
continue
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
const className = `${baseClass.namespace}-${baseClass.version}.${baseClass.name}`
|
|
821
|
-
|
|
822
|
-
// Conflict between injected and original elements
|
|
823
|
-
if (base.data.isInjected !== b.data.isInjected) {
|
|
824
|
-
if (!base.data.isInjected) {
|
|
825
|
-
base.data.hasUnresolvedConflict = true
|
|
826
|
-
} else if (!b.data.isInjected) {
|
|
827
|
-
b.data.hasUnresolvedConflict = true
|
|
828
|
-
}
|
|
829
|
-
// Copy doc from original element if not set in the injected element
|
|
830
|
-
if (!b.data.doc.text && base.data.doc.text) {
|
|
831
|
-
b.data.doc = base.data.doc
|
|
832
|
-
} else if (!base.data.doc.text && b.data.doc.text) {
|
|
833
|
-
base.data.doc = b.data.doc
|
|
834
|
-
}
|
|
835
|
-
continue
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
// If a element is a function / method
|
|
839
|
-
if (this.tsElementIsMethodOrFunction(base.data)) {
|
|
840
|
-
const baseFunc = base.data as TsFunction
|
|
841
|
-
|
|
842
|
-
// Function vs. Property
|
|
843
|
-
if (this.tsElementIsPropertyOrVariable(b.data)) {
|
|
844
|
-
this.log.debug(`${className}.${name} Internal Function vs. Property`, baseFunc, b.data)
|
|
845
|
-
b.data.hasUnresolvedConflict = true
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
// Function vs. Signal
|
|
849
|
-
else if (this.tsElementIsSignal(b.data)) {
|
|
850
|
-
this.log.debug(`${className}.${name} Internal Function vs. Signal`, baseFunc, b.data)
|
|
851
|
-
// Do nothing
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
// Function vs. Function
|
|
855
|
-
else if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
856
|
-
const bFunc = b.data as TsFunction
|
|
857
|
-
this.log.debug(
|
|
858
|
-
`${className}.${name} Internal Function vs. Function`,
|
|
859
|
-
baseFunc.inParams.map((p) => p._tsData?.name).join(', '),
|
|
860
|
-
bFunc.inParams.map((p) => p._tsData?.name).join(', '),
|
|
861
|
-
)
|
|
862
|
-
|
|
863
|
-
// Conflict between virtual and non-virtual methods (this should only occur in node-gtk, because Gjs has a vfunc_ prefix for virtual methods)
|
|
864
|
-
if (baseFunc.isVirtual !== bFunc.isVirtual) {
|
|
865
|
-
if (!baseFunc.isVirtual) {
|
|
866
|
-
baseFunc.hasUnresolvedConflict = true
|
|
867
|
-
} else {
|
|
868
|
-
bFunc.hasUnresolvedConflict = true
|
|
869
|
-
}
|
|
870
|
-
continue
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
// Do nothing..
|
|
874
|
-
} else {
|
|
875
|
-
this.log.error(`${className}.${name} Internal Unknown ${b.data.tsTypeName}`, baseFunc, b.data)
|
|
876
|
-
b.data.hasUnresolvedConflict = true
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
// If a element is a property / variable
|
|
881
|
-
else if (this.tsElementIsPropertyOrVariable(base.data)) {
|
|
882
|
-
const baseProp = base.data as TsProperty
|
|
883
|
-
|
|
884
|
-
// Property vs. Function
|
|
885
|
-
if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
886
|
-
const bFunc = b.data as TsFunction
|
|
887
|
-
this.log.debug(
|
|
888
|
-
`${className}.${name} Internal Property vs. Function`,
|
|
889
|
-
baseProp.type[0].type,
|
|
890
|
-
bFunc,
|
|
891
|
-
)
|
|
892
|
-
baseProp.hasUnresolvedConflict = true
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
// Property vs. Property
|
|
896
|
-
else if (this.tsElementIsPropertyOrVariable(b.data)) {
|
|
897
|
-
const bProp = b.data as TsProperty
|
|
898
|
-
this.log.debug(
|
|
899
|
-
`${className}.${name} Internal Property vs. Property`,
|
|
900
|
-
baseProp.type[0].type,
|
|
901
|
-
bProp.type[0].type,
|
|
902
|
-
)
|
|
903
|
-
|
|
904
|
-
switch (name) {
|
|
905
|
-
case 'parent':
|
|
906
|
-
case 'window':
|
|
907
|
-
case 'parent_instance':
|
|
908
|
-
this.mergeProperties('&', baseProp, baseProp, bProp)
|
|
909
|
-
break
|
|
910
|
-
|
|
911
|
-
default:
|
|
912
|
-
// Set property type to any
|
|
913
|
-
baseProp.type = [this.girFactory.newTsType({ ...bProp.type, type: 'any' })]
|
|
914
|
-
break
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
// Property vs. Signal
|
|
919
|
-
else if (this.tsElementIsSignal(b.data)) {
|
|
920
|
-
this.log.debug(`${className}.${name} Internal Property vs. Signal`, baseProp, b.data)
|
|
921
|
-
base.data.hasUnresolvedConflict = true
|
|
922
|
-
} else {
|
|
923
|
-
this.log.error(`${className}.${name} Internal Unknown ${b.data.tsTypeName}`, baseProp, b.data)
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
// If a element is a signal
|
|
928
|
-
else if (this.tsElementIsSignal(base.data)) {
|
|
929
|
-
const baseSig = base.data as TsSignal
|
|
930
|
-
// Signal vs. Function
|
|
931
|
-
if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
932
|
-
this.log.debug(`${className}.${name} Internal Signal vs. Function`, baseSig, b.data)
|
|
933
|
-
// Do nothing
|
|
934
|
-
}
|
|
935
|
-
// Signal vs. Property
|
|
936
|
-
else if (this.tsElementIsPropertyOrVariable(b.data)) {
|
|
937
|
-
this.log.debug(`${className}.${name} Internal Signal vs. Property`, baseSig, b.data)
|
|
938
|
-
b.data.hasUnresolvedConflict = true
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
// Other
|
|
943
|
-
else {
|
|
944
|
-
this.log.error(`${className}.${name} Internal Unknown ${base.data.tsTypeName}`)
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
/**
|
|
951
|
-
* Check conflicts of the class with implementations and inheritances
|
|
952
|
-
*/
|
|
953
|
-
public fixDirectConflicts(name: string, elements: ConflictGroupedElement) {
|
|
954
|
-
const className = `${elements.baseClass.namespace}-${elements.baseClass.version}.${elements.baseClass.name}`
|
|
955
|
-
|
|
956
|
-
for (const base of elements.baseElements) {
|
|
957
|
-
if (base.data.hasUnresolvedConflict) {
|
|
958
|
-
continue
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
// Each conflicting elements
|
|
962
|
-
for (const b of elements.inheritedElements) {
|
|
963
|
-
if (b === base || b.data.hasUnresolvedConflict) {
|
|
964
|
-
continue
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
// If base element is a function
|
|
968
|
-
if (this.tsElementIsMethodOrFunction(base.data)) {
|
|
969
|
-
const baseFunc = base.data as TsFunction
|
|
970
|
-
|
|
971
|
-
// Function vs. Function
|
|
972
|
-
if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
973
|
-
const bFunc = b.data as TsFunction
|
|
974
|
-
this.log.debug(
|
|
975
|
-
`${className}.${name} Direct Function vs. Function`,
|
|
976
|
-
baseFunc.inParams.map((p) => p._tsData?.name).join(', '),
|
|
977
|
-
bFunc.inParams.map((p) => p._tsData?.name).join(', '),
|
|
978
|
-
)
|
|
979
|
-
|
|
980
|
-
// Add a function to overload methods if there is not already a compatible version
|
|
981
|
-
if (
|
|
982
|
-
!baseFunc.overloads.includes(bFunc) &&
|
|
983
|
-
!this.getCompatibleTsFunction(baseFunc.overloads, bFunc)
|
|
984
|
-
) {
|
|
985
|
-
baseFunc.overloads.push(bFunc)
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
// Function vs. Constructor
|
|
990
|
-
else if (this.tsElementIsConstructor(b.data)) {
|
|
991
|
-
const bConstr = b.data as TsFunction
|
|
992
|
-
this.log.debug(
|
|
993
|
-
`${className}.${name} Direct Function vs. Constructor`,
|
|
994
|
-
baseFunc.inParams.map((p) => p._tsData?.name).join(', '),
|
|
995
|
-
bConstr.inParams.map((p) => p._tsData?.name).join(', '),
|
|
996
|
-
)
|
|
997
|
-
|
|
998
|
-
// Add a function to overload methods if there is not already a compatible version
|
|
999
|
-
if (!this.getCompatibleTsFunction(baseFunc.overloads, bConstr)) {
|
|
1000
|
-
baseFunc.overloads.push(bConstr)
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
// Function vs. Property
|
|
1005
|
-
else if (this.tsElementIsPropertyOrVariable(b.data)) {
|
|
1006
|
-
this.log.debug(`${className}.${name} Direct Function vs. Property`)
|
|
1007
|
-
b.data.hasUnresolvedConflict = true
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
// Function vs. Signal
|
|
1011
|
-
else if (this.tsElementIsSignal(b.data)) {
|
|
1012
|
-
this.log.debug(`${className}.${name} Direct Function vs. Signal`)
|
|
1013
|
-
// Do nothing
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
// If base element is a property / variable
|
|
1018
|
-
else if (this.tsElementIsPropertyOrVariable(base.data)) {
|
|
1019
|
-
const baseProp = base.data as TsProperty
|
|
1020
|
-
|
|
1021
|
-
// Property vs. Property
|
|
1022
|
-
if (this.tsElementIsPropertyOrVariable(b.data)) {
|
|
1023
|
-
const bProp = b.data as TsProperty
|
|
1024
|
-
this.log.debug(
|
|
1025
|
-
`${className}.${name} Direct Property vs. Property`,
|
|
1026
|
-
baseProp.type[0].type,
|
|
1027
|
-
bProp.type[0].type,
|
|
1028
|
-
)
|
|
1029
|
-
switch (name) {
|
|
1030
|
-
case 'parent':
|
|
1031
|
-
case 'window':
|
|
1032
|
-
case 'parent_instance':
|
|
1033
|
-
this.mergeProperties('&', baseProp, baseProp, bProp)
|
|
1034
|
-
break
|
|
1035
|
-
|
|
1036
|
-
default:
|
|
1037
|
-
// Set property type to any
|
|
1038
|
-
baseProp.type = [this.girFactory.newTsType({ ...bProp.type, type: 'any' })]
|
|
1039
|
-
break
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
// Property vs. Function
|
|
1044
|
-
else if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
1045
|
-
this.log.debug(`${className}.${name} Direct Property vs. Function`)
|
|
1046
|
-
baseProp.hasUnresolvedConflict = true
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
// Property vs. Signal
|
|
1050
|
-
else if (this.tsElementIsSignal(b.data)) {
|
|
1051
|
-
this.log.debug(`${className}.${name} Direct Property vs. Signal`)
|
|
1052
|
-
baseProp.hasUnresolvedConflict = true
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
// If base element is a signal method
|
|
1057
|
-
else if (this.tsElementIsSignal(base.data)) {
|
|
1058
|
-
// Signal vs. Property
|
|
1059
|
-
if (this.tsElementIsPropertyOrVariable(b.data)) {
|
|
1060
|
-
this.log.debug(`${className}.${name} Direct Signal vs. Property`)
|
|
1061
|
-
b.data.hasUnresolvedConflict = true
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
// Signal vs. Function
|
|
1065
|
-
if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
1066
|
-
this.log.debug(`${className}.${name} Direct Signal vs. Function`)
|
|
1067
|
-
const bFunc = b.data as TsFunction
|
|
1068
|
-
const baseSignal = base.data as TsFunction
|
|
1069
|
-
// Add parent class incompatible method as overload
|
|
1070
|
-
if (!this.getCompatibleTsFunction(baseSignal.overloads, bFunc)) {
|
|
1071
|
-
baseSignal.overloads.push(bFunc)
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
// If a element is a constructor
|
|
1076
|
-
else if (this.tsElementIsConstructor(base.data)) {
|
|
1077
|
-
const baseConstr = base.data as TsFunction
|
|
1078
|
-
|
|
1079
|
-
// Constructor vs. Function
|
|
1080
|
-
if (this.tsElementIsMethodOrFunction(b.data)) {
|
|
1081
|
-
const bFunc = b.data as TsFunction
|
|
1082
|
-
this.log.debug(
|
|
1083
|
-
`${className}.${name} Direct Constructor vs. Function`,
|
|
1084
|
-
baseConstr.inParams.map((p) => p._tsData?.name).join(', '),
|
|
1085
|
-
bFunc.inParams.map((p) => p._tsData?.name).join(', '),
|
|
1086
|
-
)
|
|
1087
|
-
|
|
1088
|
-
// Add a function to overload methods if there is not already a compatible version
|
|
1089
|
-
if (!this.getCompatibleTsFunction(baseConstr.overloads, bFunc)) {
|
|
1090
|
-
baseConstr.overloads.push(bFunc)
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
// Constructor vs. Constructor
|
|
1095
|
-
else if (this.tsElementIsConstructor(base.data)) {
|
|
1096
|
-
const bConstr = b.data as TsFunction
|
|
1097
|
-
this.log.debug(`${className}.${name} Direct Constructor vs. Constructor`, baseConstr, bConstr)
|
|
1098
|
-
|
|
1099
|
-
// Add the constructor to overload methods if there is not already a compatible version
|
|
1100
|
-
if (!this.getCompatibleTsFunction(baseConstr.overloads, bConstr)) {
|
|
1101
|
-
baseConstr.overloads.push(bConstr)
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
} else {
|
|
1105
|
-
this.log.warn(`{className}.${name} Unknown ${base.data.tsTypeName}`, base)
|
|
1106
|
-
base.data.hasUnresolvedConflict = true
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
/**
|
|
1113
|
-
* Fix the conflicts of a class
|
|
1114
|
-
* @param groupedElements
|
|
1115
|
-
*/
|
|
1116
|
-
public fixConflicts(groupedElements: ConflictGroupedElements) {
|
|
1117
|
-
for (const key of Object.keys(groupedElements)) {
|
|
1118
|
-
const elements = groupedElements[key]
|
|
1119
|
-
// Remove the key prefix `_`
|
|
1120
|
-
const name = key.substring(1)
|
|
1121
|
-
|
|
1122
|
-
if (elements.baseElements.length === 0) {
|
|
1123
|
-
this.fixIndirectConflicts(name, elements.inheritedElements, elements.baseClass)
|
|
1124
|
-
}
|
|
1125
|
-
this.fixInternalConflicts(name, elements.baseElements, elements.baseClass)
|
|
1126
|
-
|
|
1127
|
-
this.fixDirectConflicts(name, elements)
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
/**
|
|
1132
|
-
* Group conflicts by name and sort them by depth for simpler handling of conflicts
|
|
1133
|
-
*/
|
|
1134
|
-
public groupConflicts(elements: ConflictChildElement[], tsClass: TsClass) {
|
|
1135
|
-
const groupedConflicts: ConflictGroupedElements = {}
|
|
1136
|
-
|
|
1137
|
-
const IGNORE_CONFLICT_NAMES = ['$gtype', '__gtype__']
|
|
1138
|
-
|
|
1139
|
-
for (const a of elements) {
|
|
1140
|
-
const name = a.data.name
|
|
1141
|
-
for (const b of elements) {
|
|
1142
|
-
if (
|
|
1143
|
-
a === b ||
|
|
1144
|
-
!name ||
|
|
1145
|
-
!b.data.name ||
|
|
1146
|
-
IGNORE_CONFLICT_NAMES.includes(name) ||
|
|
1147
|
-
IGNORE_CONFLICT_NAMES.includes(b.data.name)
|
|
1148
|
-
) {
|
|
1149
|
-
continue
|
|
1150
|
-
}
|
|
1151
|
-
if (a && name && b && b.data.name && a !== b && this.hasConflict(a, b)) {
|
|
1152
|
-
const key = `_${name}` // if the key would be `toString` this would be always true so we prefix `_`
|
|
1153
|
-
groupedConflicts[key] ||= {
|
|
1154
|
-
baseElements: [],
|
|
1155
|
-
inheritedElements: [],
|
|
1156
|
-
baseClass: tsClass,
|
|
1157
|
-
}
|
|
1158
|
-
const groupedConflict = groupedConflicts[key]
|
|
1159
|
-
const isBaseElement = a.depth === 0
|
|
1160
|
-
if (isBaseElement) {
|
|
1161
|
-
if (!groupedConflict.baseElements.find((c) => isEqual(c.data, a.data))) {
|
|
1162
|
-
groupedConflict.baseElements.push(a)
|
|
1163
|
-
}
|
|
1164
|
-
} else {
|
|
1165
|
-
if (
|
|
1166
|
-
!groupedConflict.baseElements.find((c) => isEqual(c.data, a.data)) &&
|
|
1167
|
-
!groupedConflict.inheritedElements.find((c) => isEqual(c.data, a.data))
|
|
1168
|
-
) {
|
|
1169
|
-
groupedConflict.inheritedElements.push(a)
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
// Sort by depth
|
|
1177
|
-
for (const key of Object.keys(groupedConflicts)) {
|
|
1178
|
-
groupedConflicts[key].inheritedElements = groupedConflicts[key].inheritedElements.sort(
|
|
1179
|
-
(a, b) => a.depth - b.depth,
|
|
1180
|
-
)
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
return groupedConflicts
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
/**
|
|
1187
|
-
* With multiple implementations or a inherit it can happen that the interfaces / parent have the same method and/or property name with incompatible types.
|
|
1188
|
-
* We merge these types here to solve this problem.
|
|
1189
|
-
* @param girClass
|
|
1190
|
-
*/
|
|
1191
|
-
public repairClass(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement) {
|
|
1192
|
-
if (!girClass._tsData) throw new Error(NO_TSDATA('repairClass'))
|
|
1193
|
-
|
|
1194
|
-
const classElements = this.getClassElements(girClass._tsData, 0, [])
|
|
1195
|
-
|
|
1196
|
-
// Do not pass a reference of the array here
|
|
1197
|
-
const elements = [
|
|
1198
|
-
...classElements.signalMethods,
|
|
1199
|
-
...classElements.propertySignalMethods,
|
|
1200
|
-
...classElements.methods,
|
|
1201
|
-
...classElements.virtualMethods,
|
|
1202
|
-
...classElements.staticFunctions,
|
|
1203
|
-
...classElements.constructors,
|
|
1204
|
-
...classElements.properties,
|
|
1205
|
-
...classElements.fields,
|
|
1206
|
-
]
|
|
1207
|
-
|
|
1208
|
-
const groupedElementConflicts = this.groupConflicts(elements, girClass._tsData)
|
|
1209
|
-
const groupedConstructPropConflicts = this.groupConflicts(classElements.constructProps, girClass._tsData)
|
|
1210
|
-
|
|
1211
|
-
this.fixConflicts(groupedElementConflicts)
|
|
1212
|
-
this.fixConflicts(groupedConstructPropConflicts)
|
|
1213
|
-
|
|
1214
|
-
return girClass
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
/**
|
|
1218
|
-
* Returns true if `p1s` and `p2s` conflicting with each other.
|
|
1219
|
-
* The parameters must have the same length and the same type but can have different names
|
|
1220
|
-
* @param params
|
|
1221
|
-
* @returns
|
|
1222
|
-
*/
|
|
1223
|
-
public paramsHasConflict(...params: GirCallableParamElement[][]) {
|
|
1224
|
-
let conflict = false
|
|
1225
|
-
for (const p1s of params) {
|
|
1226
|
-
for (const p2s of params) {
|
|
1227
|
-
if (p1s.length !== p2s.length) {
|
|
1228
|
-
conflict = true
|
|
1229
|
-
return conflict
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
for (const [i, p1] of p1s.entries()) {
|
|
1233
|
-
const p2 = p2s[i]
|
|
1234
|
-
if (p2._tsData && p1._tsData) {
|
|
1235
|
-
if (this.typesHasConflict(p2._tsData?.type, p1._tsData?.type)) {
|
|
1236
|
-
conflict = true
|
|
1237
|
-
return conflict
|
|
1238
|
-
}
|
|
1239
|
-
} else {
|
|
1240
|
-
conflict = true
|
|
1241
|
-
return conflict
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
return conflict
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
public typesHasConflict(a: TsType[], b: TsType[]) {
|
|
1251
|
-
if (a.length !== b.length) {
|
|
1252
|
-
return true
|
|
1253
|
-
}
|
|
1254
|
-
// return !isEqual(a, b.data)
|
|
1255
|
-
for (let i = 0; i < a.length; i++) {
|
|
1256
|
-
const aType = a[i]
|
|
1257
|
-
const bType = b[i]
|
|
1258
|
-
if (
|
|
1259
|
-
aType.type !== bType.type ||
|
|
1260
|
-
aType.nullable !== bType.nullable ||
|
|
1261
|
-
aType.optional !== bType.optional ||
|
|
1262
|
-
aType.isFunction !== bType.isFunction ||
|
|
1263
|
-
aType.isCallback !== bType.isCallback ||
|
|
1264
|
-
aType.isArray !== bType.isArray ||
|
|
1265
|
-
aType.callbacks.length !== bType.callbacks.length ||
|
|
1266
|
-
aType.generics.length !== bType.generics.length ||
|
|
1267
|
-
!isEqual(aType.callbacks, bType.callbacks) ||
|
|
1268
|
-
!isEqual(aType.generics, bType.generics) ||
|
|
1269
|
-
!isEqual(aType, bType) // TODO
|
|
1270
|
-
) {
|
|
1271
|
-
return true
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
return false
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
/**
|
|
1279
|
-
* Returns `true` if the function / method types of `a` and `b` are not compatible with each other.
|
|
1280
|
-
* The parameters must have the same length and the same type but can have different names
|
|
1281
|
-
* @param a
|
|
1282
|
-
* @param b
|
|
1283
|
-
* @returns
|
|
1284
|
-
*/
|
|
1285
|
-
public functionHasConflict(a: TsFunction, b: TsFunction) {
|
|
1286
|
-
// TODO find a better solution for that, not all this methods are conflicting
|
|
1287
|
-
if (a.isVirtual !== b.isVirtual) {
|
|
1288
|
-
return true
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
if (this.typesHasConflict(a.returnTypes, b.returnTypes)) {
|
|
1292
|
-
return true
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
if (this.paramsHasConflict(a.inParams, b.inParams)) {
|
|
1296
|
-
return true
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
if (this.paramsHasConflict(a.outParams, b.outParams)) {
|
|
1300
|
-
return true
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
return false
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
/**
|
|
1307
|
-
* Returns `true` if the property types of `a` and `b` are not compatible with each other.
|
|
1308
|
-
* @param a
|
|
1309
|
-
* @param b
|
|
1310
|
-
* @returns
|
|
1311
|
-
*/
|
|
1312
|
-
public propertyHasConflict(a: TsVar & TsProperty, b: TsVar & TsProperty) {
|
|
1313
|
-
if (!!a.isStatic !== !!b.isStatic) return false
|
|
1314
|
-
if (a.name !== b.name) return false
|
|
1315
|
-
|
|
1316
|
-
if (!!a.readonly !== !!b.readonly || this.typesHasConflict(a.type, b.type)) return true
|
|
1317
|
-
|
|
1318
|
-
return false
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
public signalHasConflict(a: TsSignal, b: TsSignal) {
|
|
1322
|
-
if (!!a.isStatic !== !!b.isStatic) return false
|
|
1323
|
-
if (a.name !== b.name) return false
|
|
1324
|
-
|
|
1325
|
-
// TODO
|
|
1326
|
-
return false
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
/**
|
|
1330
|
-
* Returns true if the elements (properties or methods) of `a` and `b` are not compatible with each other (has no conflict).
|
|
1331
|
-
* @param a
|
|
1332
|
-
* @param b
|
|
1333
|
-
* @returns
|
|
1334
|
-
*/
|
|
1335
|
-
public elementHasConflict(
|
|
1336
|
-
a: TsFunction | TsVar | TsProperty | TsSignal,
|
|
1337
|
-
b: TsFunction | TsVar | TsProperty | TsSignal,
|
|
1338
|
-
) {
|
|
1339
|
-
if (a.name !== b.name) {
|
|
1340
|
-
return false
|
|
1341
|
-
} else if (this.tsElementIsStatic(a) !== this.tsElementIsStatic(b)) {
|
|
1342
|
-
return false
|
|
1343
|
-
} else if (this.tsElementIsMethodOrFunction(a) && this.tsElementIsMethodOrFunction(b)) {
|
|
1344
|
-
return this.functionHasConflict(a as TsFunction, b as TsFunction)
|
|
1345
|
-
} else if (this.tsElementIsPropertyOrVariable(a) && this.tsElementIsPropertyOrVariable(b)) {
|
|
1346
|
-
return this.propertyHasConflict(a as TsVar & TsProperty, b as TsVar & TsProperty)
|
|
1347
|
-
} else if (this.tsElementIsConstructor(a) && this.tsElementIsConstructor(b)) {
|
|
1348
|
-
return this.functionHasConflict(a as TsFunction, b as TsFunction)
|
|
1349
|
-
} else if (this.tsElementIsSignal(a) && this.tsElementIsSignal(b)) {
|
|
1350
|
-
// TODO
|
|
1351
|
-
return this.signalHasConflict(a as TsSignal, b as TsSignal)
|
|
1352
|
-
} else if (a.tsTypeName !== b.tsTypeName) {
|
|
1353
|
-
return true
|
|
1354
|
-
} else {
|
|
1355
|
-
return true
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
}
|