@gtkx/ffi 0.1.41 → 0.1.43

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.
@@ -1148,10 +1148,19 @@ ${allArgs ? `${allArgs},` : ""}
1148
1148
  return undefined;
1149
1149
  if (typeName.includes(".")) {
1150
1150
  const [ns, className] = typeName.split(".", 2);
1151
- if (ns === this.options.namespace && className) {
1152
- return normalizeClassName(className);
1151
+ if (!className)
1152
+ return undefined;
1153
+ if (this.options.typeRegistry) {
1154
+ const registered = this.options.typeRegistry.resolve(typeName);
1155
+ if (!registered || (registered.kind !== "class" && registered.kind !== "interface")) {
1156
+ return undefined;
1157
+ }
1153
1158
  }
1154
- return undefined;
1159
+ const normalizedName = normalizeClassName(className);
1160
+ if (ns === this.options.namespace) {
1161
+ return normalizedName;
1162
+ }
1163
+ return `${ns}.${normalizedName}`;
1155
1164
  }
1156
1165
  const normalizedName = normalizeClassName(typeName);
1157
1166
  if (classMap.has(typeName) || classMap.has(normalizedName)) {
@@ -1172,7 +1181,20 @@ ${allArgs ? `${allArgs},` : ""}
1172
1181
  const ffiType = JSON.stringify(this.typeMapper.mapParameter(param).ffi);
1173
1182
  const signalParamClass = this.extractSignalParamClass(param, classMap);
1174
1183
  if (signalParamClass) {
1175
- this.signalClasses.add(signalParamClass);
1184
+ const dotIndex = signalParamClass.indexOf(".");
1185
+ if (dotIndex !== -1) {
1186
+ const ns = signalParamClass.slice(0, dotIndex);
1187
+ const clsName = signalParamClass.slice(dotIndex + 1);
1188
+ this.usedExternalTypes.set(signalParamClass, {
1189
+ namespace: ns,
1190
+ name: clsName,
1191
+ transformedName: clsName,
1192
+ kind: "class",
1193
+ });
1194
+ }
1195
+ else {
1196
+ this.signalClasses.add(signalParamClass);
1197
+ }
1176
1198
  return `{ type: ${ffiType}, getCls: () => ${signalParamClass} }`;
1177
1199
  }
1178
1200
  return `{ type: ${ffiType} }`;
@@ -1,6 +1,7 @@
1
1
  import { call } from "@gtkx/native";
2
2
  import { getObject } from "@gtkx/ffi";
3
3
  import { SocketConnection } from "./socket-connection.js";
4
+ import * as GObject from "../gobject/index.js";
4
5
  import { SocketListener } from "./socket-listener.js";
5
6
  const SIGNAL_META = {
6
7
  incoming: {
@@ -9,7 +10,10 @@ const SIGNAL_META = {
9
10
  type: { type: "gobject", borrowed: true },
10
11
  getCls: () => SocketConnection,
11
12
  },
12
- { type: { type: "gobject", borrowed: true } },
13
+ {
14
+ type: { type: "gobject", borrowed: true },
15
+ getCls: () => GObject.GObject,
16
+ },
13
17
  ],
14
18
  returnType: { type: "boolean" },
15
19
  },
@@ -1,6 +1,7 @@
1
1
  import { call } from "@gtkx/native";
2
2
  import { getObject } from "@gtkx/ffi";
3
3
  import { SocketConnection } from "./socket-connection.js";
4
+ import * as GObject from "../gobject/index.js";
4
5
  import { SocketService } from "./socket-service.js";
5
6
  const SIGNAL_META = {
6
7
  run: {
@@ -9,7 +10,10 @@ const SIGNAL_META = {
9
10
  type: { type: "gobject", borrowed: true },
10
11
  getCls: () => SocketConnection,
11
12
  },
12
- { type: { type: "gobject", borrowed: true } },
13
+ {
14
+ type: { type: "gobject", borrowed: true },
15
+ getCls: () => GObject.GObject,
16
+ },
13
17
  ],
14
18
  returnType: { type: "boolean" },
15
19
  },
@@ -19,7 +23,10 @@ const SIGNAL_META = {
19
23
  type: { type: "gobject", borrowed: true },
20
24
  getCls: () => SocketConnection,
21
25
  },
22
- { type: { type: "gobject", borrowed: true } },
26
+ {
27
+ type: { type: "gobject", borrowed: true },
28
+ getCls: () => GObject.GObject,
29
+ },
23
30
  ],
24
31
  returnType: { type: "boolean" },
25
32
  },
@@ -4,11 +4,15 @@ import * as Gio from "../gio/index.js";
4
4
  import { Widget } from "./widget.js";
5
5
  const SIGNAL_META = {
6
6
  "application-activated": {
7
- params: [{ type: { type: "gobject", borrowed: true } }],
7
+ params: [
8
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gio.AppInfo },
9
+ ],
8
10
  returnType: { type: "undefined" },
9
11
  },
10
12
  "application-selected": {
11
- params: [{ type: { type: "gobject", borrowed: true } }],
13
+ params: [
14
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gio.AppInfo },
15
+ ],
12
16
  returnType: { type: "undefined" },
13
17
  },
14
18
  };
@@ -4,19 +4,21 @@ import * as Gdk from "../gdk/index.js";
4
4
  import { GestureSingle } from "./gesture-single.js";
5
5
  const SIGNAL_META = {
6
6
  "drag-begin": {
7
- params: [{ type: { type: "gobject", borrowed: true } }],
7
+ params: [
8
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Drag },
9
+ ],
8
10
  returnType: { type: "undefined" },
9
11
  },
10
12
  "drag-cancel": {
11
13
  params: [
12
- { type: { type: "gobject", borrowed: true } },
14
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Drag },
13
15
  { type: { type: "int", size: 32, unsigned: false } },
14
16
  ],
15
17
  returnType: { type: "boolean" },
16
18
  },
17
19
  "drag-end": {
18
20
  params: [
19
- { type: { type: "gobject", borrowed: true } },
21
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Drag },
20
22
  { type: { type: "boolean" } },
21
23
  ],
22
24
  returnType: { type: "undefined" },
@@ -4,24 +4,28 @@ import * as Gdk from "../gdk/index.js";
4
4
  import { EventController } from "./event-controller.js";
5
5
  const SIGNAL_META = {
6
6
  accept: {
7
- params: [{ type: { type: "gobject", borrowed: true } }],
7
+ params: [
8
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Drop },
9
+ ],
8
10
  returnType: { type: "boolean" },
9
11
  },
10
12
  "drag-enter": {
11
13
  params: [
12
- { type: { type: "gobject", borrowed: true } },
14
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Drop },
13
15
  { type: { type: "float", size: 64 } },
14
16
  { type: { type: "float", size: 64 } },
15
17
  ],
16
18
  returnType: { type: "int", size: 32, unsigned: false },
17
19
  },
18
20
  "drag-leave": {
19
- params: [{ type: { type: "gobject", borrowed: true } }],
21
+ params: [
22
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Drop },
23
+ ],
20
24
  returnType: { type: "undefined" },
21
25
  },
22
26
  "drag-motion": {
23
27
  params: [
24
- { type: { type: "gobject", borrowed: true } },
28
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Drop },
25
29
  { type: { type: "float", size: 64 } },
26
30
  { type: { type: "float", size: 64 } },
27
31
  ],
@@ -29,7 +33,7 @@ const SIGNAL_META = {
29
33
  },
30
34
  drop: {
31
35
  params: [
32
- { type: { type: "gobject", borrowed: true } },
36
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Drop },
33
37
  { type: { type: "float", size: 64 } },
34
38
  { type: { type: "float", size: 64 } },
35
39
  ],
@@ -5,7 +5,9 @@ import * as Gdk from "../gdk/index.js";
5
5
  import { EventController } from "./event-controller.js";
6
6
  const SIGNAL_META = {
7
7
  accept: {
8
- params: [{ type: { type: "gobject", borrowed: true } }],
8
+ params: [
9
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Drop },
10
+ ],
9
11
  returnType: { type: "boolean" },
10
12
  },
11
13
  drop: {
@@ -1,9 +1,12 @@
1
1
  import { call } from "@gtkx/native";
2
2
  import { getObject } from "@gtkx/ffi";
3
+ import * as Gdk from "../gdk/index.js";
3
4
  import { EventController } from "./event-controller.js";
4
5
  const SIGNAL_META = {
5
6
  event: {
6
- params: [{ type: { type: "gobject", borrowed: true } }],
7
+ params: [
8
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gdk.Event },
9
+ ],
7
10
  returnType: { type: "boolean" },
8
11
  },
9
12
  };
@@ -9,7 +9,12 @@ const SIGNAL_META = {
9
9
  returnType: { type: "gobject", borrowed: false },
10
10
  },
11
11
  render: {
12
- params: [{ type: { type: "gobject", borrowed: true } }],
12
+ params: [
13
+ {
14
+ type: { type: "gobject", borrowed: true },
15
+ getCls: () => Gdk.GLContext,
16
+ },
17
+ ],
13
18
  returnType: { type: "boolean" },
14
19
  },
15
20
  resize: {
@@ -1,21 +1,42 @@
1
1
  import { call } from "@gtkx/native";
2
2
  import { getObject } from "@gtkx/ffi";
3
+ import * as GObject from "../gobject/index.js";
3
4
  import { ListItemFactory } from "./list-item-factory.js";
4
5
  const SIGNAL_META = {
5
6
  bind: {
6
- params: [{ type: { type: "gobject", borrowed: true } }],
7
+ params: [
8
+ {
9
+ type: { type: "gobject", borrowed: true },
10
+ getCls: () => GObject.GObject,
11
+ },
12
+ ],
7
13
  returnType: { type: "undefined" },
8
14
  },
9
15
  setup: {
10
- params: [{ type: { type: "gobject", borrowed: true } }],
16
+ params: [
17
+ {
18
+ type: { type: "gobject", borrowed: true },
19
+ getCls: () => GObject.GObject,
20
+ },
21
+ ],
11
22
  returnType: { type: "undefined" },
12
23
  },
13
24
  teardown: {
14
- params: [{ type: { type: "gobject", borrowed: true } }],
25
+ params: [
26
+ {
27
+ type: { type: "gobject", borrowed: true },
28
+ getCls: () => GObject.GObject,
29
+ },
30
+ ],
15
31
  returnType: { type: "undefined" },
16
32
  },
17
33
  unbind: {
18
- params: [{ type: { type: "gobject", borrowed: true } }],
34
+ params: [
35
+ {
36
+ type: { type: "gobject", borrowed: true },
37
+ getCls: () => GObject.GObject,
38
+ },
39
+ ],
19
40
  returnType: { type: "undefined" },
20
41
  },
21
42
  };
@@ -38,7 +38,10 @@ const SIGNAL_META = {
38
38
  "insert-paintable": {
39
39
  params: [
40
40
  { type: { type: "boxed", borrowed: true, innerType: "GtkTextIter" } },
41
- { type: { type: "gobject", borrowed: true } },
41
+ {
42
+ type: { type: "gobject", borrowed: true },
43
+ getCls: () => Gdk.Paintable,
44
+ },
42
45
  ],
43
46
  returnType: { type: "undefined" },
44
47
  },
@@ -65,7 +68,12 @@ const SIGNAL_META = {
65
68
  },
66
69
  "modified-changed": { params: [], returnType: { type: "undefined" } },
67
70
  "paste-done": {
68
- params: [{ type: { type: "gobject", borrowed: true } }],
71
+ params: [
72
+ {
73
+ type: { type: "gobject", borrowed: true },
74
+ getCls: () => Gdk.Clipboard,
75
+ },
76
+ ],
69
77
  returnType: { type: "undefined" },
70
78
  },
71
79
  redo: { params: [], returnType: { type: "undefined" } },
@@ -21,7 +21,9 @@ const SIGNAL_META = {
21
21
  returnType: { type: "undefined" },
22
22
  },
23
23
  "source-mark-updated": {
24
- params: [{ type: { type: "gobject", borrowed: true } }],
24
+ params: [
25
+ { type: { type: "gobject", borrowed: true }, getCls: () => Gtk.TextMark },
26
+ ],
25
27
  returnType: { type: "undefined" },
26
28
  },
27
29
  };
@@ -10,7 +10,10 @@ const SIGNAL_META = {
10
10
  "provider-model-changed": {
11
11
  params: [
12
12
  { type: { type: "gobject", borrowed: true } },
13
- { type: { type: "gobject", borrowed: true } },
13
+ {
14
+ type: { type: "gobject", borrowed: true },
15
+ getCls: () => Gio.ListModel,
16
+ },
14
17
  ],
15
18
  returnType: { type: "undefined" },
16
19
  },
@@ -2,6 +2,7 @@ import { call } from "@gtkx/native";
2
2
  import { getObject } from "@gtkx/ffi";
3
3
  import { Buffer } from "./buffer.js";
4
4
  import { View } from "./view.js";
5
+ import * as GObject from "../gobject/index.js";
5
6
  import * as Gtk from "../gtk/index.js";
6
7
  const SIGNAL_META = {
7
8
  activate: {
@@ -23,7 +24,10 @@ const SIGNAL_META = {
23
24
  },
24
25
  "query-data": {
25
26
  params: [
26
- { type: { type: "gobject", borrowed: true } },
27
+ {
28
+ type: { type: "gobject", borrowed: true },
29
+ getCls: () => GObject.GObject,
30
+ },
27
31
  { type: { type: "int", size: 32, unsigned: true } },
28
32
  ],
29
33
  returnType: { type: "undefined" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/ffi",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "description": "Generated TypeScript FFI bindings for GTK4 libraries",
5
5
  "keywords": [
6
6
  "gtk",
@@ -46,10 +46,10 @@
46
46
  "dist"
47
47
  ],
48
48
  "dependencies": {
49
- "@gtkx/native": "0.1.41"
49
+ "@gtkx/native": "0.1.43"
50
50
  },
51
51
  "devDependencies": {
52
- "@gtkx/gir": "0.1.41"
52
+ "@gtkx/gir": "0.1.43"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsc -b && cp ../../README.md .",