@ts-for-gir/cli 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -0
- package/lib/commands/doc.d.ts +27 -0
- package/lib/commands/doc.js +48 -0
- package/lib/commands/doc.js.map +1 -0
- package/lib/commands/generate.d.ts +45 -0
- package/lib/commands/generate.js +71 -0
- package/lib/commands/generate.js.map +1 -0
- package/lib/commands/index.d.ts +3 -0
- package/lib/commands/index.js +4 -0
- package/lib/commands/index.js.map +1 -0
- package/lib/commands/list.d.ts +21 -0
- package/lib/commands/list.js +77 -0
- package/lib/commands/list.js.map +1 -0
- package/lib/config.d.ts +103 -0
- package/lib/config.js +385 -0
- package/lib/config.js.map +1 -0
- package/lib/conflict-resolver.d.ts +154 -0
- package/lib/conflict-resolver.js +1095 -0
- package/lib/conflict-resolver.js.map +1 -0
- package/lib/constants.d.ts +18 -0
- package/lib/constants.js +23 -0
- package/lib/constants.js.map +1 -0
- package/lib/generation-handler.d.ts +12 -0
- package/lib/generation-handler.js +63 -0
- package/lib/generation-handler.js.map +1 -0
- package/lib/generator.d.ts +5 -0
- package/lib/generator.js +2 -0
- package/lib/generator.js.map +1 -0
- package/lib/gir-factory.d.ts +50 -0
- package/lib/gir-factory.js +354 -0
- package/lib/gir-factory.js.map +1 -0
- package/lib/gir-module.d.ts +256 -0
- package/lib/gir-module.js +2075 -0
- package/lib/gir-module.js.map +1 -0
- package/lib/html-doc-generator.d.ts +13 -0
- package/lib/html-doc-generator.js +18 -0
- package/lib/html-doc-generator.js.map +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/injection/callbacks/gjs/Gio-2.0.d.ts +2 -0
- package/lib/injection/callbacks/gjs/Gio-2.0.js +36 -0
- package/lib/injection/callbacks/gjs/Gio-2.0.js.map +1 -0
- package/lib/injection/callbacks/gjs/index.d.ts +2 -0
- package/lib/injection/callbacks/gjs/index.js +3 -0
- package/lib/injection/callbacks/gjs/index.js.map +1 -0
- package/lib/injection/callbacks/index.d.ts +4 -0
- package/lib/injection/callbacks/index.js +4 -0
- package/lib/injection/callbacks/index.js.map +1 -0
- package/lib/injection/callbacks/node-gtk/index.d.ts +2 -0
- package/lib/injection/callbacks/node-gtk/index.js +2 -0
- package/lib/injection/callbacks/node-gtk/index.js.map +1 -0
- package/lib/injection/classes/GLib-2-0.d.ts +2 -0
- package/lib/injection/classes/GLib-2-0.js +35 -0
- package/lib/injection/classes/GLib-2-0.js.map +1 -0
- package/lib/injection/classes/gjs/GLib-2.0.d.ts +2 -0
- package/lib/injection/classes/gjs/GLib-2.0.js +74 -0
- package/lib/injection/classes/gjs/GLib-2.0.js.map +1 -0
- package/lib/injection/classes/gjs/GObject-2.0.d.ts +2 -0
- package/lib/injection/classes/gjs/GObject-2.0.js +634 -0
- package/lib/injection/classes/gjs/GObject-2.0.js.map +1 -0
- package/lib/injection/classes/gjs/Gio-2.0.d.ts +5 -0
- package/lib/injection/classes/gjs/Gio-2.0.js +218 -0
- package/lib/injection/classes/gjs/Gio-2.0.js.map +1 -0
- package/lib/injection/classes/gjs/index.d.ts +2 -0
- package/lib/injection/classes/gjs/index.js +5 -0
- package/lib/injection/classes/gjs/index.js.map +1 -0
- package/lib/injection/classes/index.d.ts +4 -0
- package/lib/injection/classes/index.js +5 -0
- package/lib/injection/classes/index.js.map +1 -0
- package/lib/injection/classes/node-gtk/GLib-2.0.d.ts +2 -0
- package/lib/injection/classes/node-gtk/GLib-2.0.js +19 -0
- package/lib/injection/classes/node-gtk/GLib-2.0.js.map +1 -0
- package/lib/injection/classes/node-gtk/GObject-2.0.d.ts +2 -0
- package/lib/injection/classes/node-gtk/GObject-2.0.js +66 -0
- package/lib/injection/classes/node-gtk/GObject-2.0.js.map +1 -0
- package/lib/injection/classes/node-gtk/Gdk-4.0.d.ts +2 -0
- package/lib/injection/classes/node-gtk/Gdk-4.0.js +32 -0
- package/lib/injection/classes/node-gtk/Gdk-4.0.js.map +1 -0
- package/lib/injection/classes/node-gtk/Gio-2.0.d.ts +2 -0
- package/lib/injection/classes/node-gtk/Gio-2.0.js +14 -0
- package/lib/injection/classes/node-gtk/Gio-2.0.js.map +1 -0
- package/lib/injection/classes/node-gtk/Graphene-1.0.d.ts +2 -0
- package/lib/injection/classes/node-gtk/Graphene-1.0.js +133 -0
- package/lib/injection/classes/node-gtk/Graphene-1.0.js.map +1 -0
- package/lib/injection/classes/node-gtk/Gtk-3.0.d.ts +2 -0
- package/lib/injection/classes/node-gtk/Gtk-3.0.js +31 -0
- package/lib/injection/classes/node-gtk/Gtk-3.0.js.map +1 -0
- package/lib/injection/classes/node-gtk/Gtk-4.0.d.ts +2 -0
- package/lib/injection/classes/node-gtk/Gtk-4.0.js +52 -0
- package/lib/injection/classes/node-gtk/Gtk-4.0.js.map +1 -0
- package/lib/injection/classes/node-gtk/Pango-1.0.d.ts +2 -0
- package/lib/injection/classes/node-gtk/Pango-1.0.js +31 -0
- package/lib/injection/classes/node-gtk/Pango-1.0.js.map +1 -0
- package/lib/injection/classes/node-gtk/index.d.ts +2 -0
- package/lib/injection/classes/node-gtk/index.js +19 -0
- package/lib/injection/classes/node-gtk/index.js.map +1 -0
- package/lib/injection/index.d.ts +3 -0
- package/lib/injection/index.js +4 -0
- package/lib/injection/index.js.map +1 -0
- package/lib/injection/injector.d.ts +17 -0
- package/lib/injection/injector.js +136 -0
- package/lib/injection/injector.js.map +1 -0
- package/lib/logger.d.ts +36 -0
- package/lib/logger.js +133 -0
- package/lib/logger.js.map +1 -0
- package/lib/messages.d.ts +30 -0
- package/lib/messages.js +45 -0
- package/lib/messages.js.map +1 -0
- package/lib/module-loader.d.ts +131 -0
- package/lib/module-loader.js +467 -0
- package/lib/module-loader.js.map +1 -0
- package/lib/start.d.ts +2 -0
- package/lib/start.js +15 -0
- package/lib/start.js.map +1 -0
- package/lib/symtable.d.ts +24 -0
- package/lib/symtable.js +63 -0
- package/lib/symtable.js.map +1 -0
- package/lib/template-processor.d.ts +46 -0
- package/lib/template-processor.js +154 -0
- package/lib/template-processor.js.map +1 -0
- package/lib/transformation.d.ts +156 -0
- package/lib/transformation.js +523 -0
- package/lib/transformation.js.map +1 -0
- package/lib/type-definition-generator.d.ts +117 -0
- package/lib/type-definition-generator.js +929 -0
- package/lib/type-definition-generator.js.map +1 -0
- package/lib/types/answer-version.d.ts +4 -0
- package/lib/types/answer-version.js +2 -0
- package/lib/types/answer-version.js.map +1 -0
- package/lib/types/build-type.d.ts +1 -0
- package/lib/types/build-type.js +2 -0
- package/lib/types/build-type.js.map +1 -0
- package/lib/types/class-parent.d.ts +11 -0
- package/lib/types/class-parent.js +2 -0
- package/lib/types/class-parent.js.map +1 -0
- package/lib/types/config-flags.d.ts +4 -0
- package/lib/types/config-flags.js +2 -0
- package/lib/types/config-flags.js.map +1 -0
- package/lib/types/conflict-child-element.d.ts +10 -0
- package/lib/types/conflict-child-element.js +2 -0
- package/lib/types/conflict-child-element.js.map +1 -0
- package/lib/types/conflict-grouped-element.d.ts +6 -0
- package/lib/types/conflict-grouped-element.js +2 -0
- package/lib/types/conflict-grouped-element.js.map +1 -0
- package/lib/types/conflict-grouped-elements.d.ts +4 -0
- package/lib/types/conflict-grouped-elements.js +2 -0
- package/lib/types/conflict-grouped-elements.js.map +1 -0
- package/lib/types/construct-name.d.ts +1 -0
- package/lib/types/construct-name.js +2 -0
- package/lib/types/construct-name.js.map +1 -0
- package/lib/types/dependency-map.d.ts +4 -0
- package/lib/types/dependency-map.js +2 -0
- package/lib/types/dependency-map.js.map +1 -0
- package/lib/types/dependency.d.ts +14 -0
- package/lib/types/dependency.js +2 -0
- package/lib/types/dependency.js.map +1 -0
- package/lib/types/environment.d.ts +1 -0
- package/lib/types/environment.js +2 -0
- package/lib/types/environment.js.map +1 -0
- package/lib/types/generate-config.d.ts +30 -0
- package/lib/types/generate-config.js +2 -0
- package/lib/types/generate-config.js.map +1 -0
- package/lib/types/generator-type.d.ts +4 -0
- package/lib/types/generator-type.js +6 -0
- package/lib/types/generator-type.js.map +1 -0
- package/lib/types/gir-alias-element.d.ts +13 -0
- package/lib/types/gir-alias-element.js +2 -0
- package/lib/types/gir-alias-element.js.map +1 -0
- package/lib/types/gir-annotation.d.ts +9 -0
- package/lib/types/gir-annotation.js +2 -0
- package/lib/types/gir-annotation.js.map +1 -0
- package/lib/types/gir-any-element.d.ts +2 -0
- package/lib/types/gir-any-element.js +2 -0
- package/lib/types/gir-any-element.js.map +1 -0
- package/lib/types/gir-any-type.d.ts +5 -0
- package/lib/types/gir-any-type.js +2 -0
- package/lib/types/gir-any-type.js.map +1 -0
- package/lib/types/gir-array-type.d.ts +20 -0
- package/lib/types/gir-array-type.js +3 -0
- package/lib/types/gir-array-type.js.map +1 -0
- package/lib/types/gir-bitfield-element.d.ts +17 -0
- package/lib/types/gir-bitfield-element.js +2 -0
- package/lib/types/gir-bitfield-element.js.map +1 -0
- package/lib/types/gir-boolean.d.ts +1 -0
- package/lib/types/gir-boolean.js +2 -0
- package/lib/types/gir-boolean.js.map +1 -0
- package/lib/types/gir-boxed-element.d.ts +15 -0
- package/lib/types/gir-boxed-element.js +2 -0
- package/lib/types/gir-boxed-element.js.map +1 -0
- package/lib/types/gir-c-include.d.ts +7 -0
- package/lib/types/gir-c-include.js +2 -0
- package/lib/types/gir-c-include.js.map +1 -0
- package/lib/types/gir-callable-attrs.d.ts +15 -0
- package/lib/types/gir-callable-attrs.js +3 -0
- package/lib/types/gir-callable-attrs.js.map +1 -0
- package/lib/types/gir-callable-param-element.d.ts +30 -0
- package/lib/types/gir-callable-param-element.js +2 -0
- package/lib/types/gir-callable-param-element.js.map +1 -0
- package/lib/types/gir-callable-param.d.ts +7 -0
- package/lib/types/gir-callable-param.js +2 -0
- package/lib/types/gir-callable-param.js.map +1 -0
- package/lib/types/gir-callable-return.d.ts +22 -0
- package/lib/types/gir-callable-return.js +2 -0
- package/lib/types/gir-callable-return.js.map +1 -0
- package/lib/types/gir-callback-element.d.ts +15 -0
- package/lib/types/gir-callback-element.js +2 -0
- package/lib/types/gir-callback-element.js.map +1 -0
- package/lib/types/gir-class-element.d.ts +48 -0
- package/lib/types/gir-class-element.js +2 -0
- package/lib/types/gir-class-element.js.map +1 -0
- package/lib/types/gir-constant-element.d.ts +15 -0
- package/lib/types/gir-constant-element.js +2 -0
- package/lib/types/gir-constant-element.js.map +1 -0
- package/lib/types/gir-constructor-element.d.ts +8 -0
- package/lib/types/gir-constructor-element.js +2 -0
- package/lib/types/gir-constructor-element.js.map +1 -0
- package/lib/types/gir-direction.d.ts +5 -0
- package/lib/types/gir-direction.js +7 -0
- package/lib/types/gir-direction.js.map +1 -0
- package/lib/types/gir-doc-element.d.ts +68 -0
- package/lib/types/gir-doc-element.js +2 -0
- package/lib/types/gir-doc-element.js.map +1 -0
- package/lib/types/gir-enum-element.d.ts +19 -0
- package/lib/types/gir-enum-element.js +2 -0
- package/lib/types/gir-enum-element.js.map +1 -0
- package/lib/types/gir-field-element.d.ts +18 -0
- package/lib/types/gir-field-element.js +2 -0
- package/lib/types/gir-field-element.js.map +1 -0
- package/lib/types/gir-function-element.d.ts +8 -0
- package/lib/types/gir-function-element.js +2 -0
- package/lib/types/gir-function-element.js.map +1 -0
- package/lib/types/gir-implements.d.ts +8 -0
- package/lib/types/gir-implements.js +2 -0
- package/lib/types/gir-implements.js.map +1 -0
- package/lib/types/gir-include.d.ts +9 -0
- package/lib/types/gir-include.js +2 -0
- package/lib/types/gir-include.js.map +1 -0
- package/lib/types/gir-info-attrs.d.ts +13 -0
- package/lib/types/gir-info-attrs.js +2 -0
- package/lib/types/gir-info-attrs.js.map +1 -0
- package/lib/types/gir-info-elements.d.ts +5 -0
- package/lib/types/gir-info-elements.js +2 -0
- package/lib/types/gir-info-elements.js.map +1 -0
- package/lib/types/gir-instance-parameter.d.ts +21 -0
- package/lib/types/gir-instance-parameter.js +2 -0
- package/lib/types/gir-instance-parameter.js.map +1 -0
- package/lib/types/gir-interface-element.d.ts +31 -0
- package/lib/types/gir-interface-element.js +2 -0
- package/lib/types/gir-interface-element.js.map +1 -0
- package/lib/types/gir-member-element.d.ts +17 -0
- package/lib/types/gir-member-element.js +2 -0
- package/lib/types/gir-member-element.js.map +1 -0
- package/lib/types/gir-method-element.d.ts +13 -0
- package/lib/types/gir-method-element.js +2 -0
- package/lib/types/gir-method-element.js.map +1 -0
- package/lib/types/gir-module-resolved-by.d.ts +10 -0
- package/lib/types/gir-module-resolved-by.js +2 -0
- package/lib/types/gir-module-resolved-by.js.map +1 -0
- package/lib/types/gir-modules-grouped-map.d.ts +4 -0
- package/lib/types/gir-modules-grouped-map.js +2 -0
- package/lib/types/gir-modules-grouped-map.js.map +1 -0
- package/lib/types/gir-modules-grouped.d.ts +12 -0
- package/lib/types/gir-modules-grouped.js +2 -0
- package/lib/types/gir-modules-grouped.js.map +1 -0
- package/lib/types/gir-namespace.d.ts +30 -0
- package/lib/types/gir-namespace.js +2 -0
- package/lib/types/gir-namespace.js.map +1 -0
- package/lib/types/gir-package.d.ts +7 -0
- package/lib/types/gir-package.js +2 -0
- package/lib/types/gir-package.js.map +1 -0
- package/lib/types/gir-prerequisite.d.ts +5 -0
- package/lib/types/gir-prerequisite.js +2 -0
- package/lib/types/gir-prerequisite.js.map +1 -0
- package/lib/types/gir-property-element.d.ts +21 -0
- package/lib/types/gir-property-element.js +2 -0
- package/lib/types/gir-property-element.js.map +1 -0
- package/lib/types/gir-record-element.d.ts +30 -0
- package/lib/types/gir-record-element.js +2 -0
- package/lib/types/gir-record-element.js.map +1 -0
- package/lib/types/gir-repository.d.ts +16 -0
- package/lib/types/gir-repository.js +2 -0
- package/lib/types/gir-repository.js.map +1 -0
- package/lib/types/gir-signal.d.ts +25 -0
- package/lib/types/gir-signal.js +2 -0
- package/lib/types/gir-signal.js.map +1 -0
- package/lib/types/gir-transfer-ownership-type.d.ts +5 -0
- package/lib/types/gir-transfer-ownership-type.js +7 -0
- package/lib/types/gir-transfer-ownership-type.js.map +1 -0
- package/lib/types/gir-transfer-ownership.d.ts +5 -0
- package/lib/types/gir-transfer-ownership.js +2 -0
- package/lib/types/gir-transfer-ownership.js.map +1 -0
- package/lib/types/gir-type.d.ts +14 -0
- package/lib/types/gir-type.js +2 -0
- package/lib/types/gir-type.js.map +1 -0
- package/lib/types/gir-union-element.d.ts +22 -0
- package/lib/types/gir-union-element.js +2 -0
- package/lib/types/gir-union-element.js.map +1 -0
- package/lib/types/gir-unparsed-number.d.ts +2 -0
- package/lib/types/gir-unparsed-number.js +2 -0
- package/lib/types/gir-unparsed-number.js.map +1 -0
- package/lib/types/gir-var-args.d.ts +5 -0
- package/lib/types/gir-var-args.js +2 -0
- package/lib/types/gir-var-args.js.map +1 -0
- package/lib/types/gir-virtual-method.d.ts +10 -0
- package/lib/types/gir-virtual-method.js +2 -0
- package/lib/types/gir-virtual-method.js.map +1 -0
- package/lib/types/index.d.ts +118 -0
- package/lib/types/index.js +119 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/inheritance-table.d.ts +3 -0
- package/lib/types/inheritance-table.js +2 -0
- package/lib/types/inheritance-table.js.map +1 -0
- package/lib/types/injection-callback.d.ts +16 -0
- package/lib/types/injection-callback.js +2 -0
- package/lib/types/injection-callback.js.map +1 -0
- package/lib/types/injection-class.d.ts +24 -0
- package/lib/types/injection-class.js +2 -0
- package/lib/types/injection-class.js.map +1 -0
- package/lib/types/injection-function.d.ts +7 -0
- package/lib/types/injection-function.js +2 -0
- package/lib/types/injection-function.js.map +1 -0
- package/lib/types/injection-generic-parameter.d.ts +2 -0
- package/lib/types/injection-generic-parameter.js +2 -0
- package/lib/types/injection-generic-parameter.js.map +1 -0
- package/lib/types/injection-instance-parameter.d.ts +2 -0
- package/lib/types/injection-instance-parameter.js +2 -0
- package/lib/types/injection-instance-parameter.js.map +1 -0
- package/lib/types/injection-parameter.d.ts +8 -0
- package/lib/types/injection-parameter.js +2 -0
- package/lib/types/injection-parameter.js.map +1 -0
- package/lib/types/injection-property.d.ts +4 -0
- package/lib/types/injection-property.js +2 -0
- package/lib/types/injection-property.js.map +1 -0
- package/lib/types/injection-type.d.ts +2 -0
- package/lib/types/injection-type.js +2 -0
- package/lib/types/injection-type.js.map +1 -0
- package/lib/types/injection.d.ts +5 -0
- package/lib/types/injection.js +2 -0
- package/lib/types/injection.js.map +1 -0
- package/lib/types/local-name-check.d.ts +4 -0
- package/lib/types/local-name-check.js +2 -0
- package/lib/types/local-name-check.js.map +1 -0
- package/lib/types/local-name-type.d.ts +1 -0
- package/lib/types/local-name-type.js +2 -0
- package/lib/types/local-name-type.js.map +1 -0
- package/lib/types/local-name.d.ts +7 -0
- package/lib/types/local-name.js +2 -0
- package/lib/types/local-name.js.map +1 -0
- package/lib/types/local-names.d.ts +4 -0
- package/lib/types/local-names.js +2 -0
- package/lib/types/local-names.js.map +1 -0
- package/lib/types/module-type.d.ts +1 -0
- package/lib/types/module-type.js +2 -0
- package/lib/types/module-type.js.map +1 -0
- package/lib/types/parsed-gir.d.ts +4 -0
- package/lib/types/parsed-gir.js +2 -0
- package/lib/types/parsed-gir.js.map +1 -0
- package/lib/types/part-of-class.d.ts +7 -0
- package/lib/types/part-of-class.js +2 -0
- package/lib/types/part-of-class.js.map +1 -0
- package/lib/types/part-of-module.d.ts +6 -0
- package/lib/types/part-of-module.js +2 -0
- package/lib/types/part-of-module.js.map +1 -0
- package/lib/types/resolve-type.d.ts +4 -0
- package/lib/types/resolve-type.js +6 -0
- package/lib/types/resolve-type.js.map +1 -0
- package/lib/types/sym-table-items.d.ts +4 -0
- package/lib/types/sym-table-items.js +2 -0
- package/lib/types/sym-table-items.js.map +1 -0
- package/lib/types/transformation-case.d.ts +1 -0
- package/lib/types/transformation-case.js +2 -0
- package/lib/types/transformation-case.js.map +1 -0
- package/lib/types/transformations.d.ts +11 -0
- package/lib/types/transformations.js +2 -0
- package/lib/types/transformations.js.map +1 -0
- package/lib/types/ts-alias.d.ts +10 -0
- package/lib/types/ts-alias.js +2 -0
- package/lib/types/ts-alias.js.map +1 -0
- package/lib/types/ts-callback-interface.d.ts +10 -0
- package/lib/types/ts-callback-interface.js +2 -0
- package/lib/types/ts-callback-interface.js.map +1 -0
- package/lib/types/ts-callback.d.ts +17 -0
- package/lib/types/ts-callback.js +2 -0
- package/lib/types/ts-callback.js.map +1 -0
- package/lib/types/ts-class.d.ts +85 -0
- package/lib/types/ts-class.js +2 -0
- package/lib/types/ts-class.js.map +1 -0
- package/lib/types/ts-doc-tag.d.ts +21 -0
- package/lib/types/ts-doc-tag.js +2 -0
- package/lib/types/ts-doc-tag.js.map +1 -0
- package/lib/types/ts-doc.d.ts +20 -0
- package/lib/types/ts-doc.js +2 -0
- package/lib/types/ts-doc.js.map +1 -0
- package/lib/types/ts-enum.d.ts +12 -0
- package/lib/types/ts-enum.js +2 -0
- package/lib/types/ts-enum.js.map +1 -0
- package/lib/types/ts-function.d.ts +44 -0
- package/lib/types/ts-function.js +2 -0
- package/lib/types/ts-function.js.map +1 -0
- package/lib/types/ts-generic-parameter.d.ts +8 -0
- package/lib/types/ts-generic-parameter.js +2 -0
- package/lib/types/ts-generic-parameter.js.map +1 -0
- package/lib/types/ts-instance-parameter.d.ts +4 -0
- package/lib/types/ts-instance-parameter.js +2 -0
- package/lib/types/ts-instance-parameter.js.map +1 -0
- package/lib/types/ts-member.d.ts +10 -0
- package/lib/types/ts-member.js +2 -0
- package/lib/types/ts-member.js.map +1 -0
- package/lib/types/ts-method.d.ts +5 -0
- package/lib/types/ts-method.js +2 -0
- package/lib/types/ts-method.js.map +1 -0
- package/lib/types/ts-parameter.d.ts +15 -0
- package/lib/types/ts-parameter.js +2 -0
- package/lib/types/ts-parameter.js.map +1 -0
- package/lib/types/ts-property.d.ts +17 -0
- package/lib/types/ts-property.js +2 -0
- package/lib/types/ts-property.js.map +1 -0
- package/lib/types/ts-signal.d.ts +17 -0
- package/lib/types/ts-signal.js +2 -0
- package/lib/types/ts-signal.js.map +1 -0
- package/lib/types/ts-type-name.d.ts +1 -0
- package/lib/types/ts-type-name.js +2 -0
- package/lib/types/ts-type-name.js.map +1 -0
- package/lib/types/ts-type-separator.d.ts +1 -0
- package/lib/types/ts-type-separator.js +2 -0
- package/lib/types/ts-type-separator.js.map +1 -0
- package/lib/types/ts-type.d.ts +22 -0
- package/lib/types/ts-type.js +2 -0
- package/lib/types/ts-type.js.map +1 -0
- package/lib/types/ts-var.d.ts +17 -0
- package/lib/types/ts-var.js +2 -0
- package/lib/types/ts-var.js.map +1 -0
- package/lib/types/type-gir-alias.d.ts +2 -0
- package/lib/types/type-gir-alias.js +2 -0
- package/lib/types/type-gir-alias.js.map +1 -0
- package/lib/types/type-gir-class.d.ts +2 -0
- package/lib/types/type-gir-class.js +2 -0
- package/lib/types/type-gir-class.js.map +1 -0
- package/lib/types/type-gir-element.d.ts +3 -0
- package/lib/types/type-gir-element.js +2 -0
- package/lib/types/type-gir-element.js.map +1 -0
- package/lib/types/type-gir-enumeration-member.d.ts +2 -0
- package/lib/types/type-gir-enumeration-member.js +2 -0
- package/lib/types/type-gir-enumeration-member.js.map +1 -0
- package/lib/types/type-gir-enumeration.d.ts +2 -0
- package/lib/types/type-gir-enumeration.js +2 -0
- package/lib/types/type-gir-enumeration.js.map +1 -0
- package/lib/types/type-gir-function.d.ts +1 -0
- package/lib/types/type-gir-function.js +2 -0
- package/lib/types/type-gir-function.js.map +1 -0
- package/lib/types/type-gir-interface.d.ts +2 -0
- package/lib/types/type-gir-interface.js +2 -0
- package/lib/types/type-gir-interface.js.map +1 -0
- package/lib/types/type-gir-method.d.ts +2 -0
- package/lib/types/type-gir-method.js +2 -0
- package/lib/types/type-gir-method.js.map +1 -0
- package/lib/types/type-gir-parameter.d.ts +1 -0
- package/lib/types/type-gir-parameter.js +2 -0
- package/lib/types/type-gir-parameter.js.map +1 -0
- package/lib/types/type-gir-property.d.ts +2 -0
- package/lib/types/type-gir-property.js +2 -0
- package/lib/types/type-gir-property.js.map +1 -0
- package/lib/types/type-gir-variable.d.ts +1 -0
- package/lib/types/type-gir-variable.js +2 -0
- package/lib/types/type-gir-variable.js.map +1 -0
- package/lib/types/type-ts-element.d.ts +3 -0
- package/lib/types/type-ts-element.js +2 -0
- package/lib/types/type-ts-element.js.map +1 -0
- package/lib/types/type-ts-enumeration-member.d.ts +2 -0
- package/lib/types/type-ts-enumeration-member.js +2 -0
- package/lib/types/type-ts-enumeration-member.js.map +1 -0
- package/lib/types/type-ts-function.d.ts +1 -0
- package/lib/types/type-ts-function.js +2 -0
- package/lib/types/type-ts-function.js.map +1 -0
- package/lib/types/type-ts-property.d.ts +1 -0
- package/lib/types/type-ts-property.js +2 -0
- package/lib/types/type-ts-property.js.map +1 -0
- package/lib/types/user-config-load-result.d.ts +6 -0
- package/lib/types/user-config-load-result.js +2 -0
- package/lib/types/user-config-load-result.js.map +1 -0
- package/lib/types/user-config.d.ts +38 -0
- package/lib/types/user-config.js +2 -0
- package/lib/types/user-config.js.map +1 -0
- package/lib/utils.d.ts +88 -0
- package/lib/utils.js +189 -0
- package/lib/utils.js.map +1 -0
- package/package.json +72 -0
- package/src/commands/doc.ts +65 -0
- package/src/commands/generate.ts +86 -0
- package/src/commands/index.ts +3 -0
- package/src/commands/list.ts +96 -0
- package/src/config.ts +426 -0
- package/src/conflict-resolver.ts +1350 -0
- package/src/constants.ts +29 -0
- package/src/generation-handler.ts +79 -0
- package/src/generator.ts +10 -0
- package/src/gir-factory.ts +488 -0
- package/src/gir-module.ts +2816 -0
- package/src/html-doc-generator.ts +23 -0
- package/src/index.ts +17 -0
- package/src/injection/callbacks/gjs/Gio-2.0.ts +37 -0
- package/src/injection/callbacks/gjs/index.ts +5 -0
- package/src/injection/callbacks/index.ts +6 -0
- package/src/injection/callbacks/node-gtk/index.ts +3 -0
- package/src/injection/classes/GLib-2-0.ts +36 -0
- package/src/injection/classes/gjs/GLib-2.0.ts +75 -0
- package/src/injection/classes/gjs/GObject-2.0.ts +635 -0
- package/src/injection/classes/gjs/Gio-2.0.ts +219 -0
- package/src/injection/classes/gjs/index.ts +7 -0
- package/src/injection/classes/index.ts +7 -0
- package/src/injection/classes/node-gtk/GLib-2.0.ts +20 -0
- package/src/injection/classes/node-gtk/GObject-2.0.ts +67 -0
- package/src/injection/classes/node-gtk/Gdk-4.0.ts +33 -0
- package/src/injection/classes/node-gtk/Gio-2.0.ts +15 -0
- package/src/injection/classes/node-gtk/Graphene-1.0.ts +134 -0
- package/src/injection/classes/node-gtk/Gtk-3.0.ts +32 -0
- package/src/injection/classes/node-gtk/Gtk-4.0.ts +53 -0
- package/src/injection/classes/node-gtk/Pango-1.0.ts +32 -0
- package/src/injection/classes/node-gtk/index.ts +21 -0
- package/src/injection/index.ts +3 -0
- package/src/injection/injector.ts +179 -0
- package/src/logger.ts +134 -0
- package/src/messages.ts +68 -0
- package/src/module-loader.ts +573 -0
- package/src/start.ts +16 -0
- package/src/symtable.ts +70 -0
- package/src/template-processor.ts +170 -0
- package/src/transformation.ts +583 -0
- package/src/type-definition-generator.ts +1387 -0
- package/src/types/answer-version.ts +4 -0
- package/src/types/build-type.ts +1 -0
- package/src/types/class-parent.ts +12 -0
- package/src/types/config-flags.ts +5 -0
- package/src/types/conflict-child-element.ts +11 -0
- package/src/types/conflict-grouped-element.ts +7 -0
- package/src/types/conflict-grouped-elements.ts +5 -0
- package/src/types/construct-name.ts +11 -0
- package/src/types/dependency-map.ts +4 -0
- package/src/types/dependency.ts +14 -0
- package/src/types/environment.ts +1 -0
- package/src/types/generate-config.ts +31 -0
- package/src/types/generator-type.ts +4 -0
- package/src/types/gir-alias-element.ts +15 -0
- package/src/types/gir-annotation.ts +10 -0
- package/src/types/gir-any-element.ts +35 -0
- package/src/types/gir-any-type.ts +7 -0
- package/src/types/gir-array-type.ts +23 -0
- package/src/types/gir-bitfield-element.ts +20 -0
- package/src/types/gir-boolean.ts +1 -0
- package/src/types/gir-boxed-element.ts +19 -0
- package/src/types/gir-c-include.ts +7 -0
- package/src/types/gir-callable-attrs.ts +19 -0
- package/src/types/gir-callable-param-element.ts +45 -0
- package/src/types/gir-callable-param.ts +9 -0
- package/src/types/gir-callable-return.ts +25 -0
- package/src/types/gir-callback-element.ts +28 -0
- package/src/types/gir-class-element.ts +71 -0
- package/src/types/gir-constant-element.ts +17 -0
- package/src/types/gir-constructor-element.ts +18 -0
- package/src/types/gir-direction.ts +5 -0
- package/src/types/gir-doc-element.ts +73 -0
- package/src/types/gir-enum-element.ts +28 -0
- package/src/types/gir-field-element.ts +31 -0
- package/src/types/gir-function-element.ts +19 -0
- package/src/types/gir-implements.ts +9 -0
- package/src/types/gir-include.ts +9 -0
- package/src/types/gir-info-attrs.ts +16 -0
- package/src/types/gir-info-elements.ts +8 -0
- package/src/types/gir-instance-parameter.ts +25 -0
- package/src/types/gir-interface-element.ts +53 -0
- package/src/types/gir-member-element.ts +19 -0
- package/src/types/gir-method-element.ts +25 -0
- package/src/types/gir-module-resolved-by.ts +11 -0
- package/src/types/gir-modules-grouped-map.ts +5 -0
- package/src/types/gir-modules-grouped.ts +13 -0
- package/src/types/gir-namespace.ts +47 -0
- package/src/types/gir-package.ts +7 -0
- package/src/types/gir-prerequisite.ts +5 -0
- package/src/types/gir-property-element.ts +31 -0
- package/src/types/gir-record-element.ts +47 -0
- package/src/types/gir-repository.ts +20 -0
- package/src/types/gir-signal.ts +43 -0
- package/src/types/gir-transfer-ownership-type.ts +5 -0
- package/src/types/gir-transfer-ownership.ts +6 -0
- package/src/types/gir-type.ts +16 -0
- package/src/types/gir-union-element.ts +35 -0
- package/src/types/gir-unparsed-number.ts +2 -0
- package/src/types/gir-var-args.ts +6 -0
- package/src/types/gir-virtual-method.ts +22 -0
- package/src/types/index.ts +118 -0
- package/src/types/inheritance-table.ts +3 -0
- package/src/types/injection-callback.ts +20 -0
- package/src/types/injection-class.ts +30 -0
- package/src/types/injection-function.ts +23 -0
- package/src/types/injection-generic-parameter.ts +3 -0
- package/src/types/injection-instance-parameter.ts +3 -0
- package/src/types/injection-parameter.ts +9 -0
- package/src/types/injection-property.ts +7 -0
- package/src/types/injection-type.ts +3 -0
- package/src/types/injection.ts +6 -0
- package/src/types/local-name-check.ts +5 -0
- package/src/types/local-name-type.ts +1 -0
- package/src/types/local-name.ts +8 -0
- package/src/types/local-names.ts +5 -0
- package/src/types/module-type.ts +1 -0
- package/src/types/parsed-gir.ts +5 -0
- package/src/types/part-of-class.ts +9 -0
- package/src/types/part-of-module.ts +8 -0
- package/src/types/resolve-type.ts +4 -0
- package/src/types/sym-table-items.ts +5 -0
- package/src/types/transformation-case.ts +7 -0
- package/src/types/transformations.ts +12 -0
- package/src/types/ts-alias.ts +11 -0
- package/src/types/ts-callback-interface.ts +11 -0
- package/src/types/ts-callback.ts +21 -0
- package/src/types/ts-class.ts +109 -0
- package/src/types/ts-doc-tag.ts +23 -0
- package/src/types/ts-doc.ts +23 -0
- package/src/types/ts-enum.ts +15 -0
- package/src/types/ts-function.ts +59 -0
- package/src/types/ts-generic-parameter.ts +8 -0
- package/src/types/ts-instance-parameter.ts +4 -0
- package/src/types/ts-member.ts +11 -0
- package/src/types/ts-method.ts +6 -0
- package/src/types/ts-parameter.ts +20 -0
- package/src/types/ts-property.ts +22 -0
- package/src/types/ts-signal.ts +21 -0
- package/src/types/ts-type-name.ts +1 -0
- package/src/types/ts-type-separator.ts +1 -0
- package/src/types/ts-type.ts +25 -0
- package/src/types/ts-var.ts +21 -0
- package/src/types/type-gir-alias.ts +2 -0
- package/src/types/type-gir-class.ts +2 -0
- package/src/types/type-gir-element.ts +25 -0
- package/src/types/type-gir-enumeration-member.ts +2 -0
- package/src/types/type-gir-enumeration.ts +2 -0
- package/src/types/type-gir-function.ts +8 -0
- package/src/types/type-gir-interface.ts +2 -0
- package/src/types/type-gir-method.ts +2 -0
- package/src/types/type-gir-parameter.ts +1 -0
- package/src/types/type-gir-property.ts +2 -0
- package/src/types/type-gir-variable.ts +1 -0
- package/src/types/type-ts-element.ts +13 -0
- package/src/types/type-ts-enumeration-member.ts +2 -0
- package/src/types/type-ts-function.ts +1 -0
- package/src/types/type-ts-property.ts +1 -0
- package/src/types/user-config-load-result.ts +6 -0
- package/src/types/user-config.ts +39 -0
- package/src/utils.ts +217 -0
- package/templates/Cogl-2.0.d.ts +0 -0
- package/templates/Gjs/GObject-2.0.d.ts +238 -0
- package/templates/Gjs/Gio-2.0.d.ts +64 -0
- package/templates/Gjs/Gjs.d.ts +135 -0
- package/templates/Gjs/Gjs.js +21 -0
- package/templates/Gjs/cast.ts +52 -0
- package/templates/Gjs/index.d.ts +279 -0
- package/templates/Gjs/index.js +4 -0
- package/templates/Gjs/module.d.ts +10 -0
- package/templates/Gjs/module.js +16 -0
- package/templates/Granite-1.0.d.ts +7 -0
- package/templates/Granite-7.0.d.ts +7 -0
- package/templates/GstBase-0.10.d.ts +5 -0
- package/templates/RygelServer-2.6.d.ts +3 -0
- package/templates/node-gtk/GObject-2.0.d.ts +57 -0
- package/templates/node-gtk/index.d.ts +40 -0
- package/templates/node-gtk/index.js +9 -0
- package/templates/node-gtk/module.d.ts +10 -0
- package/templates/node-gtk/module.js +17 -0
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is where transformations take place for gjs and node-gtk.
|
|
3
|
+
* For example a function names should be transformed to lowerCamelCase for node-gtk but should keep their original name for gjs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Transformations,
|
|
8
|
+
Environment,
|
|
9
|
+
ConstructName,
|
|
10
|
+
GenerateConfig,
|
|
11
|
+
GirCallableParamElement,
|
|
12
|
+
GirEnumElement,
|
|
13
|
+
GirBitfieldElement,
|
|
14
|
+
} from './types/index.js'
|
|
15
|
+
import { lowerCamelCase, upperCamelCase, isFirstCharNumeric } from './utils.js'
|
|
16
|
+
import { Logger } from './logger.js'
|
|
17
|
+
import { NEW_LINE_REG_EXP } from './constants.js'
|
|
18
|
+
import {
|
|
19
|
+
WARN_RENAMED_PROPERTY,
|
|
20
|
+
WARN_RENAMED_CLASS,
|
|
21
|
+
WARN_RENAMED_CONSTANT,
|
|
22
|
+
WARN_RENAMED_FIELD,
|
|
23
|
+
WARN_RENAMED_FUNCTION,
|
|
24
|
+
WARN_RENAMED_ENUM,
|
|
25
|
+
WARN_RENAMED_PARAMETER,
|
|
26
|
+
} from './messages.js'
|
|
27
|
+
|
|
28
|
+
export const POD_TYPE_MAP_ARRAY = {
|
|
29
|
+
guint8: 'Uint8Array',
|
|
30
|
+
// Int8Array would probably be more appropriate for gint8, but Uint8Array is better supported
|
|
31
|
+
gint8: 'Uint8Array',
|
|
32
|
+
gunichar: 'string',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @see https://developer.gnome.org/glib/stable/glib-Basic-Types.html
|
|
37
|
+
*/
|
|
38
|
+
export const POD_TYPE_MAP = {
|
|
39
|
+
utf8: 'string',
|
|
40
|
+
none: 'void',
|
|
41
|
+
double: 'number',
|
|
42
|
+
'double*': 'number',
|
|
43
|
+
guint: 'number',
|
|
44
|
+
'guint*': 'number',
|
|
45
|
+
guint8: 'number',
|
|
46
|
+
'guint8*': 'number',
|
|
47
|
+
'guint8**': 'number',
|
|
48
|
+
guint16: 'number',
|
|
49
|
+
'guint16*': 'number',
|
|
50
|
+
gint16: 'number',
|
|
51
|
+
'gint16*': 'number',
|
|
52
|
+
guint32: 'number',
|
|
53
|
+
'guint32*': 'number',
|
|
54
|
+
guint64: 'number',
|
|
55
|
+
'guint64*': 'number',
|
|
56
|
+
gunichar: 'string',
|
|
57
|
+
'gunichar*': 'string',
|
|
58
|
+
gint: 'number',
|
|
59
|
+
'gint*': 'number',
|
|
60
|
+
gint8: 'number',
|
|
61
|
+
'gint8*': 'number',
|
|
62
|
+
gint32: 'number',
|
|
63
|
+
'gint32*': 'number',
|
|
64
|
+
gint64: 'number',
|
|
65
|
+
'gint64*': 'number',
|
|
66
|
+
gushort: 'number',
|
|
67
|
+
'gushort*': 'number',
|
|
68
|
+
gfloat: 'number',
|
|
69
|
+
'gfloat*': 'number',
|
|
70
|
+
gboolean: 'boolean',
|
|
71
|
+
'gboolean*': 'boolean',
|
|
72
|
+
gpointer: 'object',
|
|
73
|
+
'gpointer*': 'object',
|
|
74
|
+
gconstpointer: 'object',
|
|
75
|
+
gchar: 'number',
|
|
76
|
+
guchar: 'number',
|
|
77
|
+
glong: 'number',
|
|
78
|
+
gulong: 'number',
|
|
79
|
+
gdouble: 'number',
|
|
80
|
+
gssize: 'number',
|
|
81
|
+
gsize: 'number',
|
|
82
|
+
long: 'number',
|
|
83
|
+
object: 'any',
|
|
84
|
+
gshort: 'number',
|
|
85
|
+
filename: 'string',
|
|
86
|
+
va_list: 'any',
|
|
87
|
+
guintptr: 'number',
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const C_TYPE_MAP = (value: string): string | undefined => {
|
|
91
|
+
const cTypeMap = {
|
|
92
|
+
'char*': 'string',
|
|
93
|
+
'gchar*': 'string',
|
|
94
|
+
'gchar**': 'string', // TODO CHECKME
|
|
95
|
+
'gchar***': 'string', // TODO CHECKME
|
|
96
|
+
'const gchar*': 'string', // TODO CHECKME
|
|
97
|
+
'const char*': 'string', // TODO CHECKME
|
|
98
|
+
uint8: 'number',
|
|
99
|
+
int8: 'number',
|
|
100
|
+
int32: 'number',
|
|
101
|
+
uint16: 'number',
|
|
102
|
+
'int*': 'number',
|
|
103
|
+
int: 'number',
|
|
104
|
+
boolean: 'boolean',
|
|
105
|
+
}
|
|
106
|
+
const result = cTypeMap[value as keyof typeof cTypeMap]
|
|
107
|
+
return result
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Gjs is permissive for byte-array in parameters but strict for out/return
|
|
111
|
+
// See <https://discourse.gnome.org/t/gjs-bytearray-vs-glib-bytes/4900>
|
|
112
|
+
export const FULL_TYPE_MAP = (environment: Environment, value: string, out = true): string | undefined => {
|
|
113
|
+
let ba: string
|
|
114
|
+
let gb: string | undefined
|
|
115
|
+
if (environment === 'gjs') {
|
|
116
|
+
ba = 'Uint8Array'
|
|
117
|
+
if (out === false) {
|
|
118
|
+
ba += ' | Gjs.byteArray.ByteArray'
|
|
119
|
+
gb = 'GLib.Bytes | Uint8Array | Gjs.byteArray.ByteArray'
|
|
120
|
+
} else {
|
|
121
|
+
gb = undefined // No transformation
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
// TODO
|
|
125
|
+
ba = 'any'
|
|
126
|
+
gb = 'any'
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const fullTypeMap = {
|
|
130
|
+
'GObject.Value': 'any',
|
|
131
|
+
'GObject.Closure': 'GObject.TClosure',
|
|
132
|
+
'GLib.ByteArray': ba,
|
|
133
|
+
'GLib.Bytes': gb,
|
|
134
|
+
GType: 'GObject.GType',
|
|
135
|
+
'GObject.Type': 'GObject.GType',
|
|
136
|
+
Type: 'GObject.GType',
|
|
137
|
+
'GObject.GType': 'GObject.GType',
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const result = fullTypeMap[value as keyof typeof fullTypeMap]
|
|
141
|
+
return result
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** The reserved variable names listed here cannot be resolved simply by quotation marks */
|
|
145
|
+
export const RESERVED_QUOTE_VARIABLE_NAMES = ['constructor']
|
|
146
|
+
|
|
147
|
+
export const RESERVED_VARIABLE_NAMES = [
|
|
148
|
+
'in',
|
|
149
|
+
'function',
|
|
150
|
+
'true',
|
|
151
|
+
'false',
|
|
152
|
+
'break',
|
|
153
|
+
'arguments',
|
|
154
|
+
'eval',
|
|
155
|
+
'default',
|
|
156
|
+
'new',
|
|
157
|
+
'extends',
|
|
158
|
+
'with',
|
|
159
|
+
'var',
|
|
160
|
+
'class',
|
|
161
|
+
'delete',
|
|
162
|
+
'return',
|
|
163
|
+
'constructor',
|
|
164
|
+
'this', // TODO check if this is used as we would use this in javascript, if so, this is only allowed as the first parameter
|
|
165
|
+
]
|
|
166
|
+
|
|
167
|
+
export const RESERVED_CLASS_NAMES = [
|
|
168
|
+
'break',
|
|
169
|
+
'boolean',
|
|
170
|
+
'case',
|
|
171
|
+
'catch',
|
|
172
|
+
'class',
|
|
173
|
+
'const',
|
|
174
|
+
'continue',
|
|
175
|
+
'debugger',
|
|
176
|
+
'default',
|
|
177
|
+
'delete',
|
|
178
|
+
'do',
|
|
179
|
+
'else',
|
|
180
|
+
'enum',
|
|
181
|
+
'export',
|
|
182
|
+
'extends',
|
|
183
|
+
'false',
|
|
184
|
+
'finally',
|
|
185
|
+
'for',
|
|
186
|
+
'function',
|
|
187
|
+
'if',
|
|
188
|
+
'implements',
|
|
189
|
+
'import',
|
|
190
|
+
'in',
|
|
191
|
+
'instanceof',
|
|
192
|
+
'interface',
|
|
193
|
+
'let',
|
|
194
|
+
'new',
|
|
195
|
+
'number',
|
|
196
|
+
'package',
|
|
197
|
+
'private',
|
|
198
|
+
'protected',
|
|
199
|
+
'public',
|
|
200
|
+
'return',
|
|
201
|
+
'static',
|
|
202
|
+
'super',
|
|
203
|
+
'switch',
|
|
204
|
+
'string',
|
|
205
|
+
'this',
|
|
206
|
+
'throw',
|
|
207
|
+
'true',
|
|
208
|
+
'try',
|
|
209
|
+
'typeof',
|
|
210
|
+
'var',
|
|
211
|
+
'void',
|
|
212
|
+
'while',
|
|
213
|
+
'with',
|
|
214
|
+
'yield',
|
|
215
|
+
]
|
|
216
|
+
|
|
217
|
+
export const RESERVED_FUNCTION_NAMES = ['false', 'true', 'break']
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Some classes already have their own `.connect`, `.disconnect` or `.emit` methods,
|
|
221
|
+
* so these cannot be overwritten with the Gjs signal methods which have the same name.
|
|
222
|
+
*/
|
|
223
|
+
export const GOBJECT_SIGNAL_METHOD_NAMES = ['connect', 'connect_after', 'emit', 'disconnect']
|
|
224
|
+
|
|
225
|
+
export const IGNORE_GIR_TYPE_TS_DOC_TYPES = [
|
|
226
|
+
'method',
|
|
227
|
+
'enum',
|
|
228
|
+
'enum-member',
|
|
229
|
+
'bitfield-member',
|
|
230
|
+
'property',
|
|
231
|
+
'function',
|
|
232
|
+
'static-function',
|
|
233
|
+
'constant',
|
|
234
|
+
]
|
|
235
|
+
|
|
236
|
+
export const RESERVED_NAMESPACE_NAMES = {}
|
|
237
|
+
|
|
238
|
+
export class Transformation {
|
|
239
|
+
/**
|
|
240
|
+
* Rules for the name conventions
|
|
241
|
+
* For node-gtk naming conventions see https://github.com/romgrk/node-gtk#naming-conventions
|
|
242
|
+
* For gjs see https://gjs-docs.gnome.org/ and https://wiki.gnome.org/Attic/Gjs
|
|
243
|
+
*/
|
|
244
|
+
private transformations: Transformations = {
|
|
245
|
+
functionName: {
|
|
246
|
+
node: {
|
|
247
|
+
transformation: 'lowerCamelCase',
|
|
248
|
+
},
|
|
249
|
+
gjs: {
|
|
250
|
+
transformation: 'original',
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
enumName: {
|
|
254
|
+
node: {
|
|
255
|
+
transformation: 'original',
|
|
256
|
+
},
|
|
257
|
+
gjs: {
|
|
258
|
+
transformation: 'original',
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
enumMember: {
|
|
262
|
+
node: {
|
|
263
|
+
transformation: 'upperCase',
|
|
264
|
+
},
|
|
265
|
+
gjs: {
|
|
266
|
+
transformation: 'upperCase',
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
signalName: {
|
|
270
|
+
node: {
|
|
271
|
+
transformation: 'original',
|
|
272
|
+
},
|
|
273
|
+
gjs: {
|
|
274
|
+
transformation: 'original',
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
// GJS always re-writes - to _ (I think?)
|
|
278
|
+
propertyName: {
|
|
279
|
+
node: {
|
|
280
|
+
transformation: 'lowerCamelCase',
|
|
281
|
+
},
|
|
282
|
+
gjs: {
|
|
283
|
+
transformation: 'underscores',
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
parameterName: {
|
|
287
|
+
node: {
|
|
288
|
+
transformation: 'lowerCamelCase',
|
|
289
|
+
},
|
|
290
|
+
gjs: {
|
|
291
|
+
transformation: 'underscores',
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
fieldName: {
|
|
295
|
+
node: {
|
|
296
|
+
transformation: 'lowerCamelCase',
|
|
297
|
+
},
|
|
298
|
+
gjs: {
|
|
299
|
+
transformation: 'underscores',
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
constantName: {
|
|
303
|
+
node: {
|
|
304
|
+
transformation: 'original',
|
|
305
|
+
},
|
|
306
|
+
gjs: {
|
|
307
|
+
transformation: 'original',
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
importName: {
|
|
311
|
+
node: {
|
|
312
|
+
transformation: 'upperCamelCase',
|
|
313
|
+
},
|
|
314
|
+
gjs: {
|
|
315
|
+
transformation: 'upperCamelCase',
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
signalInterfaceName: {
|
|
319
|
+
node: {
|
|
320
|
+
transformation: 'upperCamelCase',
|
|
321
|
+
},
|
|
322
|
+
gjs: {
|
|
323
|
+
transformation: 'upperCamelCase',
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
private log: Logger
|
|
329
|
+
|
|
330
|
+
constructor(moduleName = 'Transformation', private readonly config: GenerateConfig) {
|
|
331
|
+
this.log = new Logger(config.environment, config.verbose, moduleName)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
public transformSignalInterfaceName(name: string): string {
|
|
335
|
+
name = this.transform('signalInterfaceName', name)
|
|
336
|
+
return name
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
public transformModuleNamespaceName(name: string): string {
|
|
340
|
+
name = this.transformNumericName(name)
|
|
341
|
+
name = this.transform('importName', name)
|
|
342
|
+
|
|
343
|
+
if (RESERVED_NAMESPACE_NAMES[name]) {
|
|
344
|
+
name = `${name}_`
|
|
345
|
+
}
|
|
346
|
+
return name
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
public transformClassName(name: string): string {
|
|
350
|
+
const originalName = `${name}`
|
|
351
|
+
name = this.transformNumericName(name)
|
|
352
|
+
|
|
353
|
+
if (RESERVED_CLASS_NAMES.includes(name)) {
|
|
354
|
+
name = `${name}_`
|
|
355
|
+
}
|
|
356
|
+
if (originalName !== name) {
|
|
357
|
+
this.log.warn(WARN_RENAMED_CLASS(originalName, name))
|
|
358
|
+
}
|
|
359
|
+
return name
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* // E.g. the NetworkManager-1.0 has enum names starting with 80211
|
|
364
|
+
* @param girEnum The enum
|
|
365
|
+
* @returns The transformed name
|
|
366
|
+
*/
|
|
367
|
+
public transformEnumName(girEnum: GirEnumElement | GirBitfieldElement): string {
|
|
368
|
+
let name = girEnum.$.name
|
|
369
|
+
name = this.transform('enumName', name)
|
|
370
|
+
const originalName = `${name}`
|
|
371
|
+
|
|
372
|
+
// For an example enum starting with a number see https://gjs-docs.gnome.org/nm10~1.20.8/nm.80211mode
|
|
373
|
+
name = this.transformNumericName(name)
|
|
374
|
+
|
|
375
|
+
if (RESERVED_CLASS_NAMES.includes(name)) {
|
|
376
|
+
name = `${name}_`
|
|
377
|
+
}
|
|
378
|
+
if (originalName !== name) {
|
|
379
|
+
this.log.warn(WARN_RENAMED_ENUM(originalName, name))
|
|
380
|
+
}
|
|
381
|
+
return name
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
public transformEnumMember(memberName: string): string {
|
|
385
|
+
memberName = this.transform('enumMember', memberName)
|
|
386
|
+
memberName = this.transformNumericName(memberName)
|
|
387
|
+
|
|
388
|
+
return memberName
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
public transformFunctionName(name: string, isVirtual: boolean): string {
|
|
392
|
+
name = this.transform('functionName', name)
|
|
393
|
+
|
|
394
|
+
// node-gtk has no `vfunc_` prefix for virtual methods
|
|
395
|
+
if (isVirtual && this.config.environment === 'gjs') {
|
|
396
|
+
name = 'vfunc_' + name
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const originalName = `${name}`
|
|
400
|
+
|
|
401
|
+
name = this.transformNumericName(name)
|
|
402
|
+
|
|
403
|
+
if (RESERVED_FUNCTION_NAMES.includes(name)) {
|
|
404
|
+
name = `${name}_TODO`
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (originalName !== name) {
|
|
408
|
+
this.log.warn(WARN_RENAMED_FUNCTION(originalName, name))
|
|
409
|
+
}
|
|
410
|
+
return name
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
public transformReservedVariableNames(name: string, allowQuotes: boolean) {
|
|
414
|
+
if (RESERVED_VARIABLE_NAMES.includes(name)) {
|
|
415
|
+
if (allowQuotes && !RESERVED_QUOTE_VARIABLE_NAMES.includes(name)) {
|
|
416
|
+
name = `"${name}"`
|
|
417
|
+
} else {
|
|
418
|
+
name = `${name}_`
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return name
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* E.g. GstVideo-1.0 has a class `VideoScaler` with a method called `2d`
|
|
426
|
+
* or NetworkManager-1.0 has methods starting with `80211`
|
|
427
|
+
*/
|
|
428
|
+
public transformPropertyName(name: string, allowQuotes: boolean): string {
|
|
429
|
+
name = this.transform('propertyName', name)
|
|
430
|
+
const originalName = `${name}`
|
|
431
|
+
|
|
432
|
+
name = this.transformReservedVariableNames(name, allowQuotes)
|
|
433
|
+
name = this.transformNumericName(name, allowQuotes)
|
|
434
|
+
|
|
435
|
+
if (originalName !== name) {
|
|
436
|
+
this.log.warn(WARN_RENAMED_PROPERTY(originalName, name))
|
|
437
|
+
}
|
|
438
|
+
return name
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
public transformConstantName(name: string, allowQuotes: boolean): string {
|
|
442
|
+
name = this.transform('constantName', name)
|
|
443
|
+
const originalName = `${name}`
|
|
444
|
+
|
|
445
|
+
name = this.transformReservedVariableNames(name, allowQuotes)
|
|
446
|
+
name = this.transformNumericName(name, allowQuotes)
|
|
447
|
+
|
|
448
|
+
if (originalName !== name) {
|
|
449
|
+
this.log.warn(WARN_RENAMED_CONSTANT(originalName, name))
|
|
450
|
+
}
|
|
451
|
+
return name
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
public transformFieldName(name: string, allowQuotes: boolean): string {
|
|
455
|
+
name = this.transform('fieldName', name)
|
|
456
|
+
const originalName = `${name}`
|
|
457
|
+
|
|
458
|
+
name = this.transformReservedVariableNames(name, allowQuotes)
|
|
459
|
+
name = this.transformNumericName(name, allowQuotes)
|
|
460
|
+
if (originalName !== name) {
|
|
461
|
+
this.log.warn(WARN_RENAMED_FIELD(originalName, name))
|
|
462
|
+
}
|
|
463
|
+
return name
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
public transformParameterName(param: GirCallableParamElement, allowQuotes: boolean): string {
|
|
467
|
+
let name = param.$.name || '-'
|
|
468
|
+
// Such a variable name exists in `GConf-2.0.d.ts` class `Engine` method `change_set_from_current`
|
|
469
|
+
if (name === '...') {
|
|
470
|
+
return '...args'
|
|
471
|
+
}
|
|
472
|
+
name = this.transform('parameterName', name)
|
|
473
|
+
const originalName = `${name}`
|
|
474
|
+
|
|
475
|
+
name = this.transformReservedVariableNames(name, allowQuotes)
|
|
476
|
+
name = this.transformNumericName(name, allowQuotes)
|
|
477
|
+
if (originalName !== name) {
|
|
478
|
+
this.log.warn(WARN_RENAMED_PARAMETER(originalName, name))
|
|
479
|
+
}
|
|
480
|
+
return name
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Fixes type names, e.g. Return types or enum definitions can not start with numbers
|
|
485
|
+
* @param typeName
|
|
486
|
+
*/
|
|
487
|
+
public transformTypeName(name: string): string {
|
|
488
|
+
name = this.transformNumericName(name)
|
|
489
|
+
return name
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
public transform(construct: ConstructName, transformMe: string): string {
|
|
493
|
+
const transformations = this.transformations[construct][this.config.environment].transformation
|
|
494
|
+
if (transformations === 'original') {
|
|
495
|
+
return transformMe
|
|
496
|
+
}
|
|
497
|
+
if (transformations === 'lowerCamelCase') {
|
|
498
|
+
return lowerCamelCase(transformMe)
|
|
499
|
+
}
|
|
500
|
+
if (transformations === 'upperCamelCase') {
|
|
501
|
+
return upperCamelCase(transformMe)
|
|
502
|
+
}
|
|
503
|
+
if (transformations === 'upperCase') {
|
|
504
|
+
return transformMe.toUpperCase()
|
|
505
|
+
}
|
|
506
|
+
if (transformations === 'lowerCase') {
|
|
507
|
+
return transformMe.toLowerCase()
|
|
508
|
+
}
|
|
509
|
+
if (transformations === 'underscores') {
|
|
510
|
+
return transformMe.replace(/-|_/g, '_')
|
|
511
|
+
}
|
|
512
|
+
return transformMe
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* In JavaScript there can be no variables, methods, class names or enum names that start with a number.
|
|
517
|
+
* This method converts such names.
|
|
518
|
+
* TODO: Prepends an `@` to numeric starting names, how does gjs and node-gtk do that?
|
|
519
|
+
* @param name
|
|
520
|
+
* @param allowQuotes
|
|
521
|
+
*/
|
|
522
|
+
private transformNumericName(name: string, allowQuotes = false): string {
|
|
523
|
+
if (isFirstCharNumeric(name)) {
|
|
524
|
+
if (allowQuotes) name = `"${name}"`
|
|
525
|
+
else name = `TODO_${name}`
|
|
526
|
+
}
|
|
527
|
+
return name
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Replaces "@any_property" with "`any_property`"
|
|
532
|
+
* @param description E.g. "Creates a binding between @source_property on @source and @target_property on @target."
|
|
533
|
+
* @returns E.g. "Creates a binding between `source_property` on `source` and `target_property` on `target`."
|
|
534
|
+
*/
|
|
535
|
+
private transformGirDocHighlights(description: string) {
|
|
536
|
+
const highlights = description.match(/@[A-Za-z_-]*[^\s.]/gm)
|
|
537
|
+
if (highlights) {
|
|
538
|
+
for (const highlight of highlights) {
|
|
539
|
+
description = description.replace(highlight, `\`${highlight.slice(1)}\``)
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return description
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Replaces:
|
|
547
|
+
* |[<!-- language="C" -->
|
|
548
|
+
* g_object_notify_by_pspec (self, properties[PROP_FOO]);
|
|
549
|
+
* ]|
|
|
550
|
+
*
|
|
551
|
+
* with
|
|
552
|
+
* ```c
|
|
553
|
+
* g_object_notify_by_pspec (self, properties[PROP_FOO]);
|
|
554
|
+
* ```
|
|
555
|
+
*
|
|
556
|
+
* @param description
|
|
557
|
+
*/
|
|
558
|
+
private transformGirDocCodeBlocks(description: string) {
|
|
559
|
+
description = description.replaceAll(/\|\[<!-- language="C" -->/gm, '\n```c').replaceAll(/\]\|/gm, '```\n')
|
|
560
|
+
return description
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Transforms the documentation text to markdown
|
|
565
|
+
* TODO: Transform references to link tags: https://tsdoc.org/pages/tags/link/
|
|
566
|
+
* @param text
|
|
567
|
+
* @returns
|
|
568
|
+
*/
|
|
569
|
+
public transformGirDoc(text: string) {
|
|
570
|
+
text = this.transformGirDocHighlights(text)
|
|
571
|
+
text = this.transformGirDocCodeBlocks(text)
|
|
572
|
+
return text
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Transforms the tsDoc tag <text> like `@param name <text>`
|
|
577
|
+
* @param text
|
|
578
|
+
* @returns
|
|
579
|
+
*/
|
|
580
|
+
public transformGirDocTagText(text: string) {
|
|
581
|
+
return text.replace(NEW_LINE_REG_EXP, ' ')
|
|
582
|
+
}
|
|
583
|
+
}
|