@gtkx/runtime 1.0.0-rc.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/application-class.d.ts +32 -0
- package/dist/application-class.d.ts.map +1 -0
- package/dist/application-class.js +68 -0
- package/dist/application-class.js.map +1 -0
- package/dist/arg.d.ts +2 -1
- package/dist/arg.d.ts.map +1 -1
- package/dist/arg.js +2 -1
- package/dist/arg.js.map +1 -1
- package/dist/bind.d.ts +11 -0
- package/dist/bind.d.ts.map +1 -1
- package/dist/bind.js +11 -0
- package/dist/bind.js.map +1 -1
- package/dist/callback.d.ts +2 -1
- package/dist/callback.d.ts.map +1 -1
- package/dist/callback.js +118 -20
- package/dist/callback.js.map +1 -1
- package/dist/closure.d.ts +26 -0
- package/dist/closure.d.ts.map +1 -0
- package/dist/closure.js +99 -0
- package/dist/closure.js.map +1 -0
- package/dist/descriptors.d.ts +74 -3
- package/dist/descriptors.d.ts.map +1 -1
- package/dist/descriptors.js +44 -0
- package/dist/descriptors.js.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/fn.d.ts +19 -2
- package/dist/fn.d.ts.map +1 -1
- package/dist/fn.js +64 -27
- package/dist/fn.js.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -0
- package/dist/internal.js.map +1 -1
- package/dist/library.d.ts +2 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +2 -1
- package/dist/library.js.map +1 -1
- package/dist/lifecycle.d.ts +43 -11
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +62 -19
- package/dist/lifecycle.js.map +1 -1
- package/dist/listeners.d.ts.map +1 -1
- package/dist/listeners.js +3 -1
- package/dist/listeners.js.map +1 -1
- package/dist/mixin.d.ts +3 -2
- package/dist/mixin.d.ts.map +1 -1
- package/dist/mixin.js +13 -1
- package/dist/mixin.js.map +1 -1
- package/dist/native-value.d.ts.map +1 -1
- package/dist/native-value.js +4 -3
- package/dist/native-value.js.map +1 -1
- package/dist/object.d.ts +34 -6
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +89 -25
- package/dist/object.js.map +1 -1
- package/dist/param-spec.d.ts +11 -0
- package/dist/param-spec.d.ts.map +1 -0
- package/dist/param-spec.js +149 -0
- package/dist/param-spec.js.map +1 -0
- package/dist/promisify.d.ts.map +1 -1
- package/dist/promisify.js +3 -2
- package/dist/promisify.js.map +1 -1
- package/dist/properties.d.ts +38 -7
- package/dist/properties.d.ts.map +1 -1
- package/dist/properties.js +305 -42
- package/dist/properties.js.map +1 -1
- package/dist/register-class.d.ts +117 -12
- package/dist/register-class.d.ts.map +1 -1
- package/dist/register-class.js +108 -76
- package/dist/register-class.js.map +1 -1
- package/dist/registry.d.ts +69 -19
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +70 -26
- package/dist/registry.js.map +1 -1
- package/dist/signal.d.ts +9 -2
- package/dist/signal.d.ts.map +1 -1
- package/dist/signal.js +63 -7
- package/dist/signal.js.map +1 -1
- package/dist/type.d.ts +2 -1
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js +2 -0
- package/dist/type.js.map +1 -1
- package/dist/value.d.ts +8 -1
- package/dist/value.d.ts.map +1 -1
- package/dist/value.js +42 -13
- package/dist/value.js.map +1 -1
- package/dist/vfunc-call.d.ts +37 -0
- package/dist/vfunc-call.d.ts.map +1 -0
- package/dist/vfunc-call.js +168 -0
- package/dist/vfunc-call.js.map +1 -0
- package/dist/vfunc-seeds.d.ts +12 -0
- package/dist/vfunc-seeds.d.ts.map +1 -0
- package/dist/vfunc-seeds.js +19 -0
- package/dist/vfunc-seeds.js.map +1 -0
- package/dist/vfunc.d.ts +8 -0
- package/dist/vfunc.d.ts.map +1 -0
- package/dist/vfunc.js +23 -0
- package/dist/vfunc.js.map +1 -0
- package/package.json +4 -4
- package/src/application-class.ts +116 -0
- package/src/arg.ts +2 -1
- package/src/bind.ts +11 -0
- package/src/callback.ts +162 -22
- package/src/closure.ts +136 -0
- package/src/descriptors.ts +85 -24
- package/src/error.ts +1 -0
- package/src/fn.ts +92 -31
- package/src/index.ts +21 -6
- package/src/internal.ts +1 -0
- package/src/library.ts +2 -1
- package/src/lifecycle.ts +90 -23
- package/src/listeners.ts +3 -1
- package/src/mixin.ts +15 -2
- package/src/native-value.ts +5 -3
- package/src/object.ts +128 -34
- package/src/param-spec.ts +235 -0
- package/src/promisify.ts +4 -2
- package/src/properties.ts +458 -45
- package/src/register-class.ts +326 -109
- package/src/registry.ts +138 -40
- package/src/signal.ts +84 -14
- package/src/type.ts +3 -1
- package/src/value.ts +55 -10
- package/src/vfunc-call.ts +243 -0
- package/src/vfunc-seeds.ts +36 -0
- package/src/vfunc.ts +31 -0
package/dist/register-class.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { registerClass as nativeRegisterClass, } from "@gtkx/native";
|
|
2
2
|
import { getParentClass, walkClassChain } from "@gtkx/utils";
|
|
3
3
|
import { wrapCallback } from "./callback.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
4
|
+
import { insertMixinLayer } from "./mixin.js";
|
|
5
|
+
import { buildPropertyDispatch, GET_PROPERTY_VFUNC, makeGetProperty, makeSetProperty, SET_PROPERTY_VFUNC, toNativeProperties, } from "./properties.js";
|
|
6
|
+
import { getClassType, getInterfaceMixin, markDerivedClass, registerClassType, } from "./registry.js";
|
|
7
|
+
import { TYPE_INTERFACE, TYPE_INVALID, typeFundamental, typeInterfaces, typeIsA } from "./type.js";
|
|
8
|
+
import { findClassVfuncDescriptor, findInterfaceVfuncDescriptor } from "./vfunc.js";
|
|
8
9
|
const VALUE_ARG_INDEX = 2;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* @param klass The subclass to register.
|
|
16
|
-
* @returns The same class, now registered.
|
|
17
|
-
*/
|
|
10
|
+
const PROPERTY_VFUNC_SPECS = [
|
|
11
|
+
{ methodName: GET_PROPERTY_VFUNC, isValueOut: true, makeDispatch: makeGetProperty },
|
|
12
|
+
{ methodName: SET_PROPERTY_VFUNC, isValueOut: false, makeDispatch: makeSetProperty },
|
|
13
|
+
];
|
|
14
|
+
const PROPERTY_VFUNC_NAMES = new Set(PROPERTY_VFUNC_SPECS.map((spec) => spec.methodName));
|
|
18
15
|
function registerClass(klass, options = {}) {
|
|
19
16
|
const parentType = resolveParentType(klass);
|
|
20
17
|
if (parentType === TYPE_INVALID) {
|
|
@@ -24,35 +21,84 @@ function registerClass(klass, options = {}) {
|
|
|
24
21
|
if (!name) {
|
|
25
22
|
throw new Error("registerClass: cannot derive a GType name (anonymous class with no typeName option)");
|
|
26
23
|
}
|
|
24
|
+
const declaredTypes = resolveInterfaceTypes(klass, options.implements ?? []);
|
|
25
|
+
const adoptedTypes = declaredTypes.filter((gtype) => !typeIsA(parentType, gtype));
|
|
27
26
|
const properties = options.properties ?? {};
|
|
28
|
-
const
|
|
29
|
-
const
|
|
27
|
+
const { methods, inheritedNames } = collectInstanceMembers(klass);
|
|
28
|
+
const dispatch = buildPropertyDispatch({ klass, properties, adoptedTypes });
|
|
29
|
+
const classVfuncs = [
|
|
30
|
+
...discoverClassVfuncs(klass, methods),
|
|
31
|
+
...propertyVfuncs({ klass, methods, dispatch, adoptedTypes }),
|
|
32
|
+
];
|
|
30
33
|
const claimedMethodNames = new Set(classVfuncs.map((vfunc) => vfunc.methodName));
|
|
31
|
-
const interfaceBindings =
|
|
34
|
+
const interfaceBindings = discoverInterfaceBindings(methods, parentType, declaredTypes, claimedMethodNames);
|
|
32
35
|
const nativeOptions = toNativeOptions(classVfuncs, interfaceBindings, properties);
|
|
33
36
|
const newType = nativeRegisterClass(name, parentType, nativeOptions);
|
|
34
37
|
registerClassType(klass, newType);
|
|
38
|
+
markDerivedClass(klass);
|
|
39
|
+
applyInterfaceMixins(klass, adoptedTypes, inheritedNames);
|
|
35
40
|
return klass;
|
|
36
41
|
}
|
|
42
|
+
function resolveInterfaceType(klass, entry) {
|
|
43
|
+
const gtype = getClassType(entry);
|
|
44
|
+
if (typeFundamental(gtype) !== TYPE_INTERFACE) {
|
|
45
|
+
const label = typeof entry === "function" ? entry.name : String(entry);
|
|
46
|
+
throw new TypeError(`registerClass: ${klass.name} lists '${label}' in implements, which is not a registered interface`);
|
|
47
|
+
}
|
|
48
|
+
return gtype;
|
|
49
|
+
}
|
|
50
|
+
function resolveInterfaceTypes(klass, entries) {
|
|
51
|
+
return [...new Set(entries.map((entry) => resolveInterfaceType(klass, entry)))];
|
|
52
|
+
}
|
|
53
|
+
function applyInterfaceMixins(klass, adoptedTypes, inheritedNames) {
|
|
54
|
+
for (const gtype of adoptedTypes) {
|
|
55
|
+
const mixin = getInterfaceMixin(gtype);
|
|
56
|
+
if (mixin !== undefined) {
|
|
57
|
+
insertMixinLayer(klass, mixin, inheritedNames);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
37
61
|
function resolveParentType(klass) {
|
|
38
62
|
return (walkClassChain(getParentClass(klass), (cls) => {
|
|
39
63
|
const gtype = getClassType(cls);
|
|
40
64
|
return gtype === TYPE_INVALID ? undefined : gtype;
|
|
41
65
|
}) ?? TYPE_INVALID);
|
|
42
66
|
}
|
|
43
|
-
function
|
|
67
|
+
function addOwnMember(members, proto, name, isInherited) {
|
|
68
|
+
if (name === "constructor") {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (isInherited) {
|
|
72
|
+
members.inheritedNames.add(name);
|
|
73
|
+
}
|
|
74
|
+
if (members.names.has(name)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
members.names.add(name);
|
|
78
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
79
|
+
if (typeof descriptor?.value === "function") {
|
|
80
|
+
members.methods.set(name, descriptor.value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function addOwnMembers(members, klass, isInherited) {
|
|
44
84
|
const proto = klass.prototype;
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
85
|
+
if (proto === undefined) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
for (const name of Object.getOwnPropertyNames(proto)) {
|
|
89
|
+
addOwnMember(members, proto, name, isInherited);
|
|
47
90
|
}
|
|
48
|
-
return Object.getOwnPropertyNames(proto).filter((name) => {
|
|
49
|
-
if (name === "constructor") {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
return typeof Object.getOwnPropertyDescriptor(proto, name)?.value === "function";
|
|
53
|
-
});
|
|
54
91
|
}
|
|
55
|
-
function
|
|
92
|
+
function collectInstanceMembers(klass) {
|
|
93
|
+
const members = { methods: new Map(), names: new Set(), inheritedNames: new Set() };
|
|
94
|
+
let cls = klass;
|
|
95
|
+
while (cls !== null && getClassType(cls) === TYPE_INVALID) {
|
|
96
|
+
addOwnMembers(members, cls, cls !== klass);
|
|
97
|
+
cls = getParentClass(cls);
|
|
98
|
+
}
|
|
99
|
+
return members;
|
|
100
|
+
}
|
|
101
|
+
function buildDiscoveredVfunc(fn, methodName, resolveDescriptor, skip) {
|
|
56
102
|
if (skip?.has(methodName)) {
|
|
57
103
|
return undefined;
|
|
58
104
|
}
|
|
@@ -60,75 +106,54 @@ function buildDiscoveredVfunc(proto, methodName, resolveDescriptor, skip) {
|
|
|
60
106
|
if (!descriptor) {
|
|
61
107
|
return undefined;
|
|
62
108
|
}
|
|
63
|
-
const fn = proto[methodName];
|
|
64
|
-
if (!fn) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
109
|
return {
|
|
68
110
|
...descriptor,
|
|
69
111
|
methodName,
|
|
70
112
|
fn: wrapVfunc(fn, descriptor.argDescriptors, descriptor.returnDescriptor),
|
|
71
113
|
};
|
|
72
114
|
}
|
|
73
|
-
function collectDiscoveredVfuncs(
|
|
74
|
-
const proto = klass.prototype;
|
|
115
|
+
function collectDiscoveredVfuncs(methods, resolveDescriptor, skip) {
|
|
75
116
|
const result = [];
|
|
76
|
-
for (const methodName of
|
|
77
|
-
const discovered = buildDiscoveredVfunc(
|
|
117
|
+
for (const [methodName, fn] of methods) {
|
|
118
|
+
const discovered = buildDiscoveredVfunc(fn, methodName, resolveDescriptor, skip);
|
|
78
119
|
if (discovered) {
|
|
79
120
|
result.push(discovered);
|
|
80
121
|
}
|
|
81
122
|
}
|
|
82
123
|
return result;
|
|
83
124
|
}
|
|
84
|
-
function discoverClassVfuncs(klass) {
|
|
85
|
-
return collectDiscoveredVfuncs(
|
|
86
|
-
const descriptor = findClassVfuncDescriptor(klass, methodName);
|
|
87
|
-
if (descriptor && UNSUPPORTED_CONSTRUCT_VFUNCS.has(methodName)) {
|
|
88
|
-
throw new Error(`registerClass: overriding the GObject construct-time vtable slot '${methodName}' is not ` +
|
|
89
|
-
"supported; run construct-time initialization in the subclass constructor, after " +
|
|
90
|
-
"super(...), instead");
|
|
91
|
-
}
|
|
92
|
-
return descriptor ?? undefined;
|
|
93
|
-
});
|
|
125
|
+
function discoverClassVfuncs(klass, methods) {
|
|
126
|
+
return collectDiscoveredVfuncs(methods, (methodName) => findClassVfuncDescriptor(klass, methodName) ?? undefined, PROPERTY_VFUNC_NAMES);
|
|
94
127
|
}
|
|
95
128
|
function wrapVfunc(fn, argDescriptors, returnDescriptor) {
|
|
96
129
|
return wrapCallback(fn, { argDescriptors, returnDescriptor }, "this");
|
|
97
130
|
}
|
|
98
|
-
function
|
|
131
|
+
function discoverInterfaceBindings(methods, parentGtype, declaredTypes, claimedMethodNames) {
|
|
132
|
+
const declared = new Set(declaredTypes);
|
|
133
|
+
const gtypes = new Set([...typeInterfaces(parentGtype), ...declaredTypes]);
|
|
99
134
|
const bindings = [];
|
|
100
|
-
for (const
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
103
|
-
bindings.push({ gtype
|
|
135
|
+
for (const gtype of gtypes) {
|
|
136
|
+
const vfuncs = discoverInterfaceVfuncs(methods, gtype, claimedMethodNames);
|
|
137
|
+
if (vfuncs.length > 0 || declared.has(gtype)) {
|
|
138
|
+
bindings.push({ gtype, vfuncs });
|
|
104
139
|
}
|
|
105
140
|
}
|
|
106
141
|
return bindings;
|
|
107
142
|
}
|
|
108
|
-
function discoverInterfaceVfuncs(
|
|
109
|
-
|
|
110
|
-
if (!vfuncRegistry) {
|
|
111
|
-
return [];
|
|
112
|
-
}
|
|
113
|
-
return collectDiscoveredVfuncs(klass, (methodName) => {
|
|
114
|
-
const entry = vfuncRegistry[methodName];
|
|
115
|
-
return entry?.kind === "interface" ? entry : undefined;
|
|
116
|
-
}, claimedMethodNames);
|
|
143
|
+
function discoverInterfaceVfuncs(methods, interfaceGtype, claimedMethodNames) {
|
|
144
|
+
return collectDiscoveredVfuncs(methods, (methodName) => findInterfaceVfuncDescriptor(interfaceGtype, methodName), claimedMethodNames);
|
|
117
145
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
146
|
+
const hasDispatchedProperties = (dispatch, adoptedTypes) => dispatch.accessors.length > 0 || adoptedTypes.length > 0;
|
|
147
|
+
function propertyVfuncFor(source, spec) {
|
|
148
|
+
const { klass, methods, dispatch, adoptedTypes } = source;
|
|
149
|
+
const dispatched = hasDispatchedProperties(dispatch, adoptedTypes)
|
|
150
|
+
? spec.makeDispatch(dispatch)
|
|
151
|
+
: undefined;
|
|
152
|
+
const fn = methods.get(spec.methodName) ?? dispatched;
|
|
153
|
+
return fn === undefined ? undefined : buildPropertyVfunc(klass, spec.methodName, fn, spec.isValueOut);
|
|
123
154
|
}
|
|
124
|
-
function propertyVfuncs(
|
|
125
|
-
|
|
126
|
-
return [];
|
|
127
|
-
}
|
|
128
|
-
return [
|
|
129
|
-
buildPropertyVfunc(klass, "getProperty", makeGetProperty(accessors), true),
|
|
130
|
-
buildPropertyVfunc(klass, "setProperty", makeSetProperty(accessors), false),
|
|
131
|
-
];
|
|
155
|
+
function propertyVfuncs(source) {
|
|
156
|
+
return PROPERTY_VFUNC_SPECS.map((spec) => propertyVfuncFor(source, spec)).filter((vfunc) => vfunc !== undefined);
|
|
132
157
|
}
|
|
133
158
|
function markValueCallerAllocated(argDescriptors) {
|
|
134
159
|
return argDescriptors.map((arg, index) => index === VALUE_ARG_INDEX ? { ...arg, isCallerAllocated: true } : arg);
|
|
@@ -148,6 +173,17 @@ function buildPropertyVfunc(klass, methodName, fn, isValueOut) {
|
|
|
148
173
|
fn: wrapVfunc(fn, argDescriptors, descriptor.returnDescriptor),
|
|
149
174
|
};
|
|
150
175
|
}
|
|
176
|
+
function toNativeInterface(binding) {
|
|
177
|
+
const nativeInterface = {
|
|
178
|
+
type: binding.gtype,
|
|
179
|
+
vfuncs: [...binding.vfuncs],
|
|
180
|
+
};
|
|
181
|
+
const vtableSize = binding.vfuncs[0]?.vtableSize;
|
|
182
|
+
if (vtableSize !== undefined) {
|
|
183
|
+
nativeInterface.vtableSize = vtableSize;
|
|
184
|
+
}
|
|
185
|
+
return nativeInterface;
|
|
186
|
+
}
|
|
151
187
|
function toNativeOptions(classVfuncs, interfaceBindings, properties) {
|
|
152
188
|
const hasInterfaces = interfaceBindings.length > 0;
|
|
153
189
|
const hasClassVfuncs = classVfuncs.length > 0;
|
|
@@ -163,11 +199,7 @@ function toNativeOptions(classVfuncs, interfaceBindings, properties) {
|
|
|
163
199
|
options.vfuncs = [...classVfuncs];
|
|
164
200
|
}
|
|
165
201
|
if (hasInterfaces) {
|
|
166
|
-
options.interfaces = interfaceBindings.map((binding) => (
|
|
167
|
-
type: binding.gtype,
|
|
168
|
-
vtableSize: binding.vtableSize,
|
|
169
|
-
vfuncs: [...binding.vfuncs],
|
|
170
|
-
}));
|
|
202
|
+
options.interfaces = interfaceBindings.map((binding) => toNativeInterface(binding));
|
|
171
203
|
}
|
|
172
204
|
return options;
|
|
173
205
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-class.js","sourceRoot":"","sources":["../src/register-class.ts"],"names":[],"mappings":"AACA,OAAO,EACH,aAAa,IAAI,mBAAmB,GAGvC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAiB,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACH,cAAc,EACd,eAAe,EACf,eAAe,EAGf,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,YAAY,EACZ,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,GAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAoBzD,MAAM,4BAA4B,GAAgB,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;AACzG,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B;;;;;;;;GAQG;AACH,SAAS,aAAa,CAAqB,KAAQ,EAAE,UAAgC,EAAE;IACnF,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAE5C,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;QAC9B,MAAM,IAAI,SAAS,CAAC,kBAAkB,KAAK,CAAC,IAAI,yCAAyC,CAAC,CAAC;IAC/F,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC;IAE5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,qFAAqF,CAAC,CAAC;IAC3G,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;IAC5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C,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACrD,IAAI,EAAE,OAAO,CAAC,KAAK;YACnB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;SAC9B,CAAC,CAAC,CAAC;IACR,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { Descriptor } from \"@gtkx/native\";\nimport {\n registerClass as nativeRegisterClass,\n type RegisterClassOptions as NativeRegisterClassOptions,\n type RegisterClassVfunc as NativeRegisterClassVfunc,\n} from \"@gtkx/native\";\nimport { type AnyClass, getParentClass, walkClassChain } from \"@gtkx/utils\";\nimport { wrapCallback } from \"./callback.js\";\nimport {\n buildAccessors,\n makeGetProperty,\n makeSetProperty,\n type PropertyAccessor,\n type PropertySpec,\n toNativeProperties,\n} from \"./properties.js\";\nimport {\n getClassType,\n getInterfaceVfuncRegistry,\n getVfuncRegistry,\n registerClassType,\n type VfuncDescriptor,\n} from \"./registry.js\";\nimport { TYPE_INVALID, typeInterfaces } from \"./type.js\";\n\n/** What {@link registerClass} adds to the new GType beyond the vtable slots it discovers on the class. */\ntype RegisterClassOptions = {\n /** Name to register the new GType under, defaulting to the class's own name. */\n typeName?: string;\n /**\n * Properties to install on the new type, keyed by canonical name and valued with the\n * `GObject.ParamSpec` describing each. Every property gains dashed, underscored and camelCased\n * prototype accessors that emit `notify` on write, unless the class already defines that name.\n */\n properties?: Record<string, PropertySpec>;\n};\n\ntype VfuncFn = NativeRegisterClassVfunc[\"fn\"];\ntype DiscoveredVfunc<K extends \"class\" | \"interface\"> = VfuncDescriptor<K> & { methodName: string; fn: VfuncFn };\ntype DiscoveredClassVfunc = DiscoveredVfunc<\"class\">;\ntype DiscoveredInterfaceVfunc = DiscoveredVfunc<\"interface\">;\ntype InterfaceVfuncBinding = { gtype: bigint; vtableSize: number; vfuncs: DiscoveredInterfaceVfunc[] };\n\nconst UNSUPPORTED_CONSTRUCT_VFUNCS: Set<string> = new Set([\"constructed\", \"setProperty\", \"getProperty\"]);\nconst VALUE_ARG_INDEX = 2;\n\n/**\n * Registers a subclass of a wrapper class as a new GType, wiring up any class and\n * inherited-interface virtual functions it overrides. Throws if the class does not\n * extend a registered wrapper class, has no derivable type name, or overrides an\n * unsupported construct-time vtable slot.\n *\n * @param klass The subclass to register.\n * @returns The same class, now registered.\n */\nfunction registerClass<T extends AnyClass>(klass: T, options: RegisterClassOptions = {}): T {\n const parentType = resolveParentType(klass);\n\n if (parentType === TYPE_INVALID) {\n throw new TypeError(`registerClass: ${klass.name} must extend a registered wrapper class`);\n }\n\n const name = options.typeName ?? klass.name;\n\n if (!name) {\n throw new Error(\"registerClass: cannot derive a GType name (anonymous class with no typeName option)\");\n }\n\n const properties = options.properties ?? {};\n const accessors = buildAccessors(klass, properties);\n const classVfuncs = [...discoverClassVfuncs(klass), ...propertyVfuncs(klass, accessors)];\n const claimedMethodNames = new Set(classVfuncs.map((vfunc) => vfunc.methodName));\n const interfaceBindings = discoverInheritedInterfaceVfuncs(klass, parentType, claimedMethodNames);\n const nativeOptions = toNativeOptions(classVfuncs, interfaceBindings, properties);\n const newType: bigint = nativeRegisterClass(name, parentType, nativeOptions);\n registerClassType(klass, newType);\n\n return klass;\n}\n\nfunction resolveParentType(klass: AnyClass): bigint {\n return (\n walkClassChain(getParentClass(klass), (cls) => {\n const gtype = getClassType(cls);\n\n return gtype === TYPE_INVALID ? undefined : gtype;\n }) ?? TYPE_INVALID\n );\n}\n\nfunction ownInstanceMethodNames(klass: AnyClass): string[] {\n const proto = (klass as { prototype?: object }).prototype;\n\n if (!proto) {\n return [];\n }\n\n return Object.getOwnPropertyNames(proto).filter((name) => {\n if (name === \"constructor\") {\n return false;\n }\n\n return typeof Object.getOwnPropertyDescriptor(proto, name)?.value === \"function\";\n });\n}\n\nfunction buildDiscoveredVfunc<K extends \"class\" | \"interface\">(\n proto: Record<string, VfuncFn>,\n methodName: string,\n resolveDescriptor: (methodName: string) => VfuncDescriptor<K> | undefined,\n skip: Set<string> | undefined,\n): DiscoveredVfunc<K> | undefined {\n if (skip?.has(methodName)) {\n return undefined;\n }\n\n const descriptor = resolveDescriptor(methodName);\n\n if (!descriptor) {\n return undefined;\n }\n\n const fn = proto[methodName];\n\n if (!fn) {\n return undefined;\n }\n\n return {\n ...descriptor,\n methodName,\n fn: wrapVfunc(fn, descriptor.argDescriptors, descriptor.returnDescriptor),\n };\n}\n\nfunction collectDiscoveredVfuncs<K extends \"class\" | \"interface\">(\n klass: AnyClass,\n resolveDescriptor: (methodName: string) => VfuncDescriptor<K> | undefined,\n skip?: Set<string>,\n): DiscoveredVfunc<K>[] {\n const proto = (klass as { prototype: Record<string, VfuncFn> }).prototype;\n const result: DiscoveredVfunc<K>[] = [];\n\n for (const methodName of ownInstanceMethodNames(klass)) {\n const discovered = buildDiscoveredVfunc(proto, methodName, resolveDescriptor, skip);\n\n if (discovered) {\n result.push(discovered);\n }\n }\n\n return result;\n}\n\nfunction discoverClassVfuncs(klass: AnyClass): DiscoveredClassVfunc[] {\n return collectDiscoveredVfuncs(klass, (methodName) => {\n const descriptor = findClassVfuncDescriptor(klass, methodName);\n\n if (descriptor && UNSUPPORTED_CONSTRUCT_VFUNCS.has(methodName)) {\n throw new Error(\n `registerClass: overriding the GObject construct-time vtable slot '${methodName}' is not ` +\n \"supported; run construct-time initialization in the subclass constructor, after \" +\n \"super(...), instead\",\n );\n }\n\n return descriptor ?? undefined;\n });\n}\n\nfunction wrapVfunc(\n fn: VfuncFn,\n argDescriptors: NativeRegisterClassVfunc[\"argDescriptors\"],\n returnDescriptor: NativeRegisterClassVfunc[\"returnDescriptor\"],\n): VfuncFn {\n return wrapCallback(fn as (...args: unknown[]) => unknown, { argDescriptors, returnDescriptor }, \"this\");\n}\n\nfunction discoverInheritedInterfaceVfuncs(\n klass: AnyClass,\n parentGtype: bigint,\n claimedMethodNames: Set<string>,\n): InterfaceVfuncBinding[] {\n const bindings: InterfaceVfuncBinding[] = [];\n\n for (const interfaceGtype of typeInterfaces(parentGtype)) {\n const [first, ...rest] = discoverInterfaceVfuncs(klass, interfaceGtype, claimedMethodNames);\n\n if (first !== undefined) {\n bindings.push({ gtype: interfaceGtype, vtableSize: first.vtableSize, vfuncs: [first, ...rest] });\n }\n }\n\n return bindings;\n}\n\nfunction discoverInterfaceVfuncs(\n klass: AnyClass,\n interfaceGtype: bigint,\n claimedMethodNames: Set<string>,\n): DiscoveredInterfaceVfunc[] {\n const vfuncRegistry = getInterfaceVfuncRegistry(interfaceGtype);\n\n if (!vfuncRegistry) {\n return [];\n }\n\n return collectDiscoveredVfuncs(\n klass,\n (methodName) => {\n const entry = vfuncRegistry[methodName];\n\n return entry?.kind === \"interface\" ? entry : undefined;\n },\n claimedMethodNames,\n );\n}\n\nfunction findClassVfuncDescriptor(klass: AnyClass, methodName: string): VfuncDescriptor<\"class\"> | null {\n return (\n walkClassChain(getParentClass(klass), (cls) => {\n const entry = getVfuncRegistry(cls)?.[methodName];\n\n return entry?.kind === \"class\" ? entry : undefined;\n }) ?? null\n );\n}\n\nfunction propertyVfuncs(klass: AnyClass, accessors: PropertyAccessor[]): DiscoveredClassVfunc[] {\n if (accessors.length === 0) {\n return [];\n }\n\n return [\n buildPropertyVfunc(klass, \"getProperty\", makeGetProperty(accessors), true),\n buildPropertyVfunc(klass, \"setProperty\", makeSetProperty(accessors), false),\n ];\n}\n\nfunction markValueCallerAllocated(argDescriptors: Descriptor[]): Descriptor[] {\n return argDescriptors.map((arg, index) =>\n index === VALUE_ARG_INDEX ? { ...arg, isCallerAllocated: true } : arg);\n}\n\nfunction buildPropertyVfunc(\n klass: AnyClass,\n methodName: string,\n fn: VfuncFn,\n isValueOut: boolean,\n): DiscoveredClassVfunc {\n const descriptor = findClassVfuncDescriptor(klass, methodName);\n\n if (!descriptor) {\n throw new Error(`registerClass: the parent class exposes no '${methodName}' vtable slot`);\n }\n\n const argDescriptors = isValueOut\n ? markValueCallerAllocated(descriptor.argDescriptors)\n : descriptor.argDescriptors;\n\n return {\n ...descriptor,\n methodName,\n argDescriptors,\n fn: wrapVfunc(fn, argDescriptors, descriptor.returnDescriptor),\n };\n}\n\nfunction toNativeOptions(\n classVfuncs: DiscoveredClassVfunc[],\n interfaceBindings: InterfaceVfuncBinding[],\n properties: Record<string, PropertySpec>,\n): NativeRegisterClassOptions | undefined {\n const hasInterfaces = interfaceBindings.length > 0;\n const hasClassVfuncs = classVfuncs.length > 0;\n const hasProperties = Object.keys(properties).length > 0;\n\n if (!hasClassVfuncs && !hasInterfaces && !hasProperties) {\n return undefined;\n }\n\n const options: NativeRegisterClassOptions = {};\n\n if (hasProperties) {\n options.properties = toNativeProperties(properties);\n }\n\n if (hasClassVfuncs) {\n options.vfuncs = [...classVfuncs];\n }\n\n if (hasInterfaces) {\n options.interfaces = interfaceBindings.map((binding) => ({\n type: binding.gtype,\n vtableSize: binding.vtableSize,\n vfuncs: [...binding.vfuncs],\n }));\n }\n\n return options;\n}\n\nexport { registerClass };\n"]}
|
|
1
|
+
{"version":3,"file":"register-class.js","sourceRoot":"","sources":["../src/register-class.ts"],"names":[],"mappings":"AACA,OAAO,EACH,aAAa,IAAI,mBAAmB,GAIvC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAiB,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,eAAe,EAGf,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,E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AED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,OAAO,EAAkB,aAAa,EAAE,CAAC","sourcesContent":["import type { Descriptor } from \"@gtkx/native\";\nimport {\n registerClass as nativeRegisterClass,\n type RegisterClassInterface as NativeRegisterClassInterface,\n type RegisterClassOptions as NativeRegisterClassOptions,\n type RegisterClassVfunc as NativeRegisterClassVfunc,\n} from \"@gtkx/native\";\nimport { type AnyClass, getParentClass, walkClassChain } from \"@gtkx/utils\";\nimport { wrapCallback } from \"./callback.js\";\nimport { insertMixinLayer } from \"./mixin.js\";\nimport {\n buildPropertyDispatch,\n GET_PROPERTY_VFUNC,\n makeGetProperty,\n makeSetProperty,\n type PropertyDispatch,\n type PropertySpec,\n SET_PROPERTY_VFUNC,\n toNativeProperties,\n} from \"./properties.js\";\nimport {\n getClassType,\n getInterfaceMixin,\n markDerivedClass,\n registerClassType,\n type VfuncDescriptor,\n} from \"./registry.js\";\nimport { TYPE_INTERFACE, TYPE_INVALID, typeFundamental, typeInterfaces, typeIsA } from \"./type.js\";\nimport { findClassVfuncDescriptor, findInterfaceVfuncDescriptor } from \"./vfunc.js\";\n\n/**\n * A generated interface value, such as `Gio.ListModel`, in the form {@link registerClass} takes it.\n * `__impl__` exists only in the type system: it carries the interface's `Impl` type, of which a class\n * has to match every member it declares itself, which rejects a class value and a member whose\n * signature does not fit the slot it fills. Leaving a slot to the interface is not rejected,\n * because `registerClass` does not reject it either: every member of an `Impl` type is optional,\n * and the `Partial` holds that open whatever the type declares. The `object` beside it keeps\n * TypeScript from also demanding one member in common. An interface that introspection describes\n * no vtable for carries `unknown`, since it has no slot a class could fill.\n */\ntype Interface<TImpl> = AnyClass & {\n /** Type-level slot holding the interface's `Impl` type; no value ever carries it. */\n __impl__: (impl: Partial<TImpl> & object) => void;\n};\n\n/**\n * One key of `RegisterClassOptions.properties` with every underscore turned into the dash a canonical\n * GObject property name separates its words with.\n */\ntype Dashed<TName extends string> = TName extends `${infer THead}_${infer TTail}`\n ? Dashed<`${THead}-${TTail}`>\n : TName;\n\n/**\n * One dashed key in the camelCase spelling the accessors {@link registerClass} installs carry, which is\n * the spelling the hooks that address a property by name take.\n */\ntype Camelized<TName extends string> = TName extends `${infer THead}-${infer TTail}`\n ? `${THead}${Capitalize<Camelized<TTail>>}`\n : TName;\n\n/**\n * The names a registered class carries in its property map: every key of\n * `RegisterClassOptions.properties` in camelCase, whichever of the three spellings it was written in.\n * A `properties` object given a type of its own rather than left to inference has `string` for its key\n * type and names nothing, because a name only known as `string` addresses no member in particular.\n */\ntype InstalledNames<TProperties> = string extends keyof TProperties\n ? never\n : Camelized<Dashed<keyof TProperties & string>>;\n\n/**\n * An instance of a registered class: everything the class itself declares, plus the property map the\n * hooks that address a property by name, such as `useProperty` from `@gtkx/react`, read the installed\n * names off. Each name is typed with the value type the class declares for the member of that name,\n * so a property the class does not `declare` contributes nothing.\n */\ntype RegisteredInstance<TInstance, TProperties> = TInstance & {\n /** Type-level map from installed property name to value type; no value ever carries it. */\n __properties__: Pick<TInstance, InstalledNames<TProperties> & keyof TInstance>;\n};\n\n/**\n * The construct signature and prototype a registered class carries, both giving\n * {@link RegisteredInstance}. The signature stays abstract for as long as the class itself is, so\n * registering an abstract base leaves it as impossible to construct as it was.\n */\ntype RegisteredConstructor<TClass, TArgs extends unknown[], TInstance> = {\n /** Object the class's instances inherit from. */\n prototype: TInstance;\n} & (TClass extends new (...args: never) => unknown\n ? new (...args: TArgs) => TInstance\n : abstract new (...args: TArgs) => TInstance);\n\n/**\n * The class {@link registerClass} hands back: the same class, with the same statics, whose instances\n * carry the properties `RegisterClassOptions.properties` installed. Binding the call to a name, rather\n * than discarding it, is what carries those names into the type system.\n */\ntype RegisteredClass<TClass extends AnyClass, TProperties> =\n TClass extends abstract new (...args: infer TArgs) => infer TInstance\n ? Omit<TClass, \"prototype\"> & RegisteredConstructor<TClass, TArgs, RegisteredInstance<TInstance, TProperties>>\n : never;\n\n/** What {@link registerClass} adds to the new GType beyond the vtable slots it discovers on the class. */\ntype RegisterClassOptions<TInstance extends object, TProperties extends Record<string, PropertySpec>> = {\n /** Name to register the new GType under, defaulting to the class's own name. */\n typeName?: string;\n /**\n * Interfaces the new type implements on top of the ones it inherits, given as the interface values\n * themselves, such as `Gio.ListModel`. Their vtable slots are filled from the `vfunc`-prefixed methods on\n * the class's prototype chain, each of which has to match the interface's `Impl` type, such as\n * `Gio.ListModelImpl`.\n */\n implements?: Interface<TInstance>[];\n /**\n * Properties to install on the new type, keyed by the name JavaScript addresses each one by and\n * valued with the `GObject.ParamSpec` describing it. A key is read in camelCase however it is\n * written, so `dewPoint`, `dew_point` and `dew-point` all name the same member, and the ParamSpec\n * has to carry the canonical spelling of that name, `dew-point`, or registration throws: the\n * ParamSpec's name is the one GObject emits `notify` with, and a name the key does not spell\n * reaches nothing that listens for it. Every property gains prototype accessors, one for the key\n * as written, one for it with dashes turned into underscores and one for it in camelCase, each\n * unless the class already defines that name. They serve the value from storage of their own on\n * the instance, which is also what the type's `get_property` and `set_property` slots read and\n * write, so a value set from JavaScript, from `g_object_set_property` and at construction all\n * land in the same place.\n *\n * A write the ParamSpec would refuse throws rather than reaching GObject, which reports such a\n * write as a GLib critical and drops it: a `TypeError` for a read-only or construct-only\n * property and for a value of a type the property cannot hold, and a `RangeError` for a value\n * the ParamSpec rejects. The same two checks run over a value handed to the constructor, where\n * a construct-only property is the one that is writable. An accepted write emits one `notify`,\n * which a `freeze_notify` batch collects; a write of the value the property already holds is\n * dropped and emits none.\n *\n * A class that defines the camelCase member itself owns the property: its own accessor decides\n * what a write means, the other two spellings forward to it, and the type's property slots read\n * and write it rather than the generated storage.\n */\n properties?: TProperties;\n};\n\n/** {@link RegisterClassOptions} with the widest instance and property types {@link registerClass} accepts. */\ntype AnyRegisterClassOptions = RegisterClassOptions<object, Record<string, PropertySpec>>;\ntype VfuncFn = NativeRegisterClassVfunc[\"fn\"];\ntype DiscoveredVfunc = VfuncDescriptor & { methodName: string; fn: VfuncFn };\ntype MethodTable = Map<string, VfuncFn>;\ntype InstanceMembers = { methods: MethodTable; names: Set<string>; inheritedNames: Set<string> };\n\ntype InterfaceVfuncBinding = {\n gtype: bigint;\n vfuncs: DiscoveredVfunc[];\n};\n\ntype PropertyVfuncSource = {\n klass: AnyClass;\n methods: MethodTable;\n dispatch: PropertyDispatch;\n adoptedTypes: bigint[];\n};\n\ntype PropertyVfuncSpec = {\n methodName: string;\n isValueOut: boolean;\n makeDispatch: (dispatch: PropertyDispatch) => VfuncFn;\n};\n\nconst VALUE_ARG_INDEX = 2;\n\nconst PROPERTY_VFUNC_SPECS: PropertyVfuncSpec[] = [\n { methodName: GET_PROPERTY_VFUNC, isValueOut: true, makeDispatch: makeGetProperty },\n { methodName: SET_PROPERTY_VFUNC, isValueOut: false, makeDispatch: makeSetProperty },\n];\n\nconst PROPERTY_VFUNC_NAMES: Set<string> = new Set(PROPERTY_VFUNC_SPECS.map((spec) => spec.methodName));\n\n/**\n * Registers a subclass of a wrapper class as a new GType, wiring up any class and interface\n * virtual functions it overrides, both for the interfaces it inherits and for the ones\n * `RegisterClassOptions.implements` names.\n *\n * Throws when the class does not extend a registered wrapper class, when it has no derivable type\n * name, when an entry in `RegisterClassOptions.implements` is not a registered interface, when a\n * listed interface has a prerequisite that neither the parent type nor another listed interface meets,\n * and when an entry in `RegisterClassOptions.properties` names its `GObject.ParamSpec` something other\n * than the canonical spelling of the key it sits under.\n *\n * A slot is filled from the `vfunc`-prefixed methods on the class's prototype chain, up to but not\n * including the registered ancestor the class extends, so a method an intermediate base class\n * declares fills a slot the same way one the class itself declares does. A slot nothing on that\n * chain fills is left untouched.\n *\n * Declare every slot as a method: a class field holding a function, such as `vfuncGetNItems = () => 1`,\n * is assigned to each instance after registration and never reaches the vtable.\n *\n * An override of `vfuncConstructed` runs from inside the base constructor, before JavaScript\n * installs the subclass's field initializers and runs its constructor body, so a field still\n * reads `undefined` there and reading a `#private` field throws. Declare state the override\n * touches without an initializer, and assign private state from the constructor body after\n * `super()`. An instance a native caller creates, through `GObject.newv` or `Gtk.Builder`,\n * never runs the subclass constructor at all, so its declared fields stay uninitialized for\n * the object's whole life.\n *\n * @param klass The subclass to register.\n * @param options What the new GType gains beyond the vtable slots the class overrides.\n * @returns The same class, now registered, with every name in `options.properties` in its property map.\n */\nfunction registerClass<\n T extends AnyClass,\n TProperties extends Record<string, PropertySpec> = Record<never, PropertySpec>,\n>(klass: T, options?: RegisterClassOptions<T[\"prototype\"], TProperties>): RegisteredClass<T, TProperties>;\n\nfunction registerClass(klass: AnyClass, options: AnyRegisterClassOptions = {}): AnyClass {\n const parentType = resolveParentType(klass);\n\n if (parentType === TYPE_INVALID) {\n throw new TypeError(`registerClass: ${klass.name} must extend a registered wrapper class`);\n }\n\n const name = options.typeName ?? klass.name;\n\n if (!name) {\n throw new Error(\"registerClass: cannot derive a GType name (anonymous class with no typeName option)\");\n }\n\n const declaredTypes = resolveInterfaceTypes(klass, options.implements ?? []);\n const adoptedTypes = declaredTypes.filter((gtype) => !typeIsA(parentType, gtype));\n const properties = options.properties ?? {};\n const { methods, inheritedNames } = collectInstanceMembers(klass);\n const dispatch = buildPropertyDispatch({ klass, properties, adoptedTypes });\n\n const classVfuncs = [\n ...discoverClassVfuncs(klass, methods),\n ...propertyVfuncs({ klass, methods, dispatch, adoptedTypes }),\n ];\n\n const claimedMethodNames = new Set(classVfuncs.map((vfunc) => vfunc.methodName));\n const interfaceBindings = discoverInterfaceBindings(methods, parentType, declaredTypes, claimedMethodNames);\n const nativeOptions = toNativeOptions(classVfuncs, interfaceBindings, properties);\n const newType: bigint = nativeRegisterClass(name, parentType, nativeOptions);\n registerClassType(klass, newType);\n markDerivedClass(klass);\n applyInterfaceMixins(klass, adoptedTypes, inheritedNames);\n\n return klass;\n}\n\nfunction resolveInterfaceType(klass: AnyClass, entry: AnyClass): bigint {\n const gtype = getClassType(entry);\n\n if (typeFundamental(gtype) !== TYPE_INTERFACE) {\n const label = typeof entry === \"function\" ? entry.name : String(entry);\n\n throw new TypeError(\n `registerClass: ${klass.name} lists '${label}' in implements, which is not a registered interface`,\n );\n }\n\n return gtype;\n}\n\nfunction resolveInterfaceTypes(klass: AnyClass, entries: AnyClass[]): bigint[] {\n return [...new Set(entries.map((entry) => resolveInterfaceType(klass, entry)))];\n}\n\nfunction applyInterfaceMixins(klass: AnyClass, adoptedTypes: bigint[], inheritedNames: Set<string>): void {\n for (const gtype of adoptedTypes) {\n const mixin = getInterfaceMixin(gtype);\n\n if (mixin !== undefined) {\n insertMixinLayer(klass, mixin, inheritedNames);\n }\n }\n}\n\nfunction resolveParentType(klass: AnyClass): bigint {\n return (\n walkClassChain(getParentClass(klass), (cls) => {\n const gtype = getClassType(cls);\n\n return gtype === TYPE_INVALID ? undefined : gtype;\n }) ?? TYPE_INVALID\n );\n}\n\nfunction addOwnMember(members: InstanceMembers, proto: object, name: string, isInherited: boolean): void {\n if (name === \"constructor\") {\n return;\n }\n\n if (isInherited) {\n members.inheritedNames.add(name);\n }\n\n if (members.names.has(name)) {\n return;\n }\n\n members.names.add(name);\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n\n if (typeof descriptor?.value === \"function\") {\n members.methods.set(name, descriptor.value as VfuncFn);\n }\n}\n\nfunction addOwnMembers(members: InstanceMembers, klass: AnyClass, isInherited: boolean): void {\n const proto = (klass as { prototype?: object }).prototype;\n\n if (proto === undefined) {\n return;\n }\n\n for (const name of Object.getOwnPropertyNames(proto)) {\n addOwnMember(members, proto, name, isInherited);\n }\n}\n\nfunction collectInstanceMembers(klass: AnyClass): InstanceMembers {\n const members: InstanceMembers = { methods: new Map(), names: new Set(), inheritedNames: new Set() };\n let cls: AnyClass | null = klass;\n\n while (cls !== null && getClassType(cls) === TYPE_INVALID) {\n addOwnMembers(members, cls, cls !== klass);\n cls = getParentClass(cls);\n }\n\n return members;\n}\n\nfunction buildDiscoveredVfunc(\n fn: VfuncFn,\n methodName: string,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip: Set<string> | undefined,\n): DiscoveredVfunc | undefined {\n if (skip?.has(methodName)) {\n return undefined;\n }\n\n const descriptor = resolveDescriptor(methodName);\n\n if (!descriptor) {\n return undefined;\n }\n\n return {\n ...descriptor,\n methodName,\n fn: wrapVfunc(fn, descriptor.argDescriptors, descriptor.returnDescriptor),\n };\n}\n\nfunction collectDiscoveredVfuncs(\n methods: MethodTable,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip?: Set<string>,\n): DiscoveredVfunc[] {\n const result: DiscoveredVfunc[] = [];\n\n for (const [methodName, fn] of methods) {\n const discovered = buildDiscoveredVfunc(fn, methodName, resolveDescriptor, skip);\n\n if (discovered) {\n result.push(discovered);\n }\n }\n\n return result;\n}\n\nfunction discoverClassVfuncs(klass: AnyClass, methods: MethodTable): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findClassVfuncDescriptor(klass, methodName) ?? undefined,\n PROPERTY_VFUNC_NAMES,\n );\n}\n\nfunction wrapVfunc(\n fn: VfuncFn,\n argDescriptors: NativeRegisterClassVfunc[\"argDescriptors\"],\n returnDescriptor: NativeRegisterClassVfunc[\"returnDescriptor\"],\n): VfuncFn {\n return wrapCallback(fn as (...args: unknown[]) => unknown, { argDescriptors, returnDescriptor }, \"this\");\n}\n\nfunction discoverInterfaceBindings(\n methods: MethodTable,\n parentGtype: bigint,\n declaredTypes: bigint[],\n claimedMethodNames: Set<string>,\n): InterfaceVfuncBinding[] {\n const declared: Set<bigint> = new Set(declaredTypes);\n const gtypes: Set<bigint> = new Set([...typeInterfaces(parentGtype), ...declaredTypes]);\n const bindings: InterfaceVfuncBinding[] = [];\n\n for (const gtype of gtypes) {\n const vfuncs = discoverInterfaceVfuncs(methods, gtype, claimedMethodNames);\n\n if (vfuncs.length > 0 || declared.has(gtype)) {\n bindings.push({ gtype, vfuncs });\n }\n }\n\n return bindings;\n}\n\nfunction discoverInterfaceVfuncs(\n methods: MethodTable,\n interfaceGtype: bigint,\n claimedMethodNames: Set<string>,\n): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findInterfaceVfuncDescriptor(interfaceGtype, methodName),\n claimedMethodNames,\n );\n}\n\nconst hasDispatchedProperties = (dispatch: PropertyDispatch, adoptedTypes: bigint[]): boolean =>\n dispatch.accessors.length > 0 || adoptedTypes.length > 0;\n\nfunction propertyVfuncFor(\n source: PropertyVfuncSource,\n spec: PropertyVfuncSpec,\n): DiscoveredVfunc | undefined {\n const { klass, methods, dispatch, adoptedTypes } = source;\n\n const dispatched = hasDispatchedProperties(dispatch, adoptedTypes)\n ? spec.makeDispatch(dispatch)\n : undefined;\n\n const fn = methods.get(spec.methodName) ?? dispatched;\n\n return fn === undefined ? undefined : buildPropertyVfunc(klass, spec.methodName, fn, spec.isValueOut);\n}\n\nfunction propertyVfuncs(source: PropertyVfuncSource): DiscoveredVfunc[] {\n return PROPERTY_VFUNC_SPECS.map((spec) => propertyVfuncFor(source, spec)).filter(\n (vfunc) => vfunc !== undefined,\n );\n}\n\nfunction markValueCallerAllocated(argDescriptors: Descriptor[]): Descriptor[] {\n return argDescriptors.map((arg, index) =>\n index === VALUE_ARG_INDEX ? { ...arg, isCallerAllocated: true } : arg);\n}\n\nfunction buildPropertyVfunc(\n klass: AnyClass,\n methodName: string,\n fn: VfuncFn,\n isValueOut: boolean,\n): DiscoveredVfunc {\n const descriptor = findClassVfuncDescriptor(klass, methodName);\n\n if (!descriptor) {\n throw new Error(`registerClass: the parent class exposes no '${methodName}' vtable slot`);\n }\n\n const argDescriptors = isValueOut\n ? markValueCallerAllocated(descriptor.argDescriptors)\n : descriptor.argDescriptors;\n\n return {\n ...descriptor,\n methodName,\n argDescriptors,\n fn: wrapVfunc(fn, argDescriptors, descriptor.returnDescriptor),\n };\n}\n\nfunction toNativeInterface(binding: InterfaceVfuncBinding): NativeRegisterClassInterface {\n const nativeInterface: NativeRegisterClassInterface = {\n type: binding.gtype,\n vfuncs: [...binding.vfuncs],\n };\n\n const vtableSize = binding.vfuncs[0]?.vtableSize;\n\n if (vtableSize !== undefined) {\n nativeInterface.vtableSize = vtableSize;\n }\n\n return nativeInterface;\n}\n\nfunction toNativeOptions(\n classVfuncs: DiscoveredVfunc[],\n interfaceBindings: InterfaceVfuncBinding[],\n properties: Record<string, PropertySpec>,\n): NativeRegisterClassOptions | undefined {\n const hasInterfaces = interfaceBindings.length > 0;\n const hasClassVfuncs = classVfuncs.length > 0;\n const hasProperties = Object.keys(properties).length > 0;\n\n if (!hasClassVfuncs && !hasInterfaces && !hasProperties) {\n return undefined;\n }\n\n const options: NativeRegisterClassOptions = {};\n\n if (hasProperties) {\n options.properties = toNativeProperties(properties);\n }\n\n if (hasClassVfuncs) {\n options.vfuncs = [...classVfuncs];\n }\n\n if (hasInterfaces) {\n options.interfaces = interfaceBindings.map((binding) => toNativeInterface(binding));\n }\n\n return options;\n}\n\nexport { type Interface, registerClass };\n"]}
|
package/dist/registry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnyClass } from "@gtkx/utils";
|
|
2
1
|
import { type ExternalObject, type Handle, type RegisterClassVfunc as NativeRegisterClassVfunc } from "@gtkx/native";
|
|
2
|
+
import { type AnyClass } from "@gtkx/utils";
|
|
3
3
|
import type { Mixin } from "./mixin.js";
|
|
4
4
|
import { type TypedClass } from "./type.js";
|
|
5
5
|
/**
|
|
@@ -8,29 +8,73 @@ import { type TypedClass } from "./type.js";
|
|
|
8
8
|
*/
|
|
9
9
|
type StaticBase<C, K extends PropertyKey = "new"> = Omit<C, K> & (C extends new (...args: infer A) => infer R ? new (...args: A) => R : never);
|
|
10
10
|
/** One overridable vtable slot: where it sits in the vtable struct and how it is marshalled. */
|
|
11
|
-
type VfuncDescriptor
|
|
12
|
-
/** Whether the slot lives in a class struct or in an interface vtable. */
|
|
13
|
-
kind: K;
|
|
11
|
+
type VfuncDescriptor = {
|
|
14
12
|
/** GIR name of the type struct holding the slot, without its namespace, such as `WidgetClass`. */
|
|
15
13
|
className: string;
|
|
16
14
|
/** Name of the slot's field in that struct. */
|
|
17
15
|
vfuncName: string;
|
|
18
16
|
/** Byte offset of the slot within the struct. */
|
|
19
17
|
byteOffset: number;
|
|
20
|
-
/**
|
|
21
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Byte size of an interface's vtable struct, used to bounds-check `VfuncDescriptor.byteOffset`.
|
|
20
|
+
* A class struct is bounds-checked against the size `g_type_query` reports for it, so a slot in
|
|
21
|
+
* one carries no size of its own.
|
|
22
|
+
*/
|
|
23
|
+
vtableSize?: number;
|
|
22
24
|
/** Descriptor for each argument the slot receives, starting with the instance. */
|
|
23
25
|
argDescriptors: NativeRegisterClassVfunc["argDescriptors"];
|
|
24
26
|
/** Descriptor for the value the slot returns. */
|
|
25
27
|
returnDescriptor: NativeRegisterClassVfunc["returnDescriptor"];
|
|
28
|
+
/**
|
|
29
|
+
* The slot takes a trailing `GError**` that `VfuncDescriptor.argDescriptors` leaves out, the
|
|
30
|
+
* way GIR leaves it out of a callable's parameters. A call through the slot has to append it
|
|
31
|
+
* or it passes one argument fewer than the implementation reads.
|
|
32
|
+
*/
|
|
33
|
+
canThrow?: boolean;
|
|
26
34
|
};
|
|
27
35
|
/**
|
|
28
36
|
* The vtable slots a wrapper class or interface exposes, keyed by the JavaScript method name that
|
|
29
37
|
* overrides each one.
|
|
30
38
|
*/
|
|
31
|
-
type VfuncRegistry = Record<string, VfuncDescriptor
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
type VfuncRegistry = Record<string, VfuncDescriptor>;
|
|
40
|
+
/**
|
|
41
|
+
* How one property an interface declares reaches the vtable, given as the interface's own accessor
|
|
42
|
+
* members. A direction introspection does not route through a vtable slot is left out, and the
|
|
43
|
+
* property owns that direction's state itself.
|
|
44
|
+
*/
|
|
45
|
+
type InterfaceProperty = {
|
|
46
|
+
/** Member reading the slot the property's value comes from, such as `getEnabled`. */
|
|
47
|
+
getter?: string;
|
|
48
|
+
/** Member writing the slot the property's value goes to, such as `setActionName`. */
|
|
49
|
+
setter?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* What an interface's vtable struct looks like, for the classes that adopt the interface.
|
|
53
|
+
* `g_type_query` reports no size for an interface, so each slot's generated metadata carries the
|
|
54
|
+
* struct's byte size to bounds-check the slot's offset; an interface introspection describes no
|
|
55
|
+
* vtable for simply contributes no slots.
|
|
56
|
+
*/
|
|
57
|
+
type InterfaceLayout = {
|
|
58
|
+
/** The slots the struct declares, keyed by the JavaScript method name that fills each one. */
|
|
59
|
+
vfuncs?: VfuncRegistry;
|
|
60
|
+
/**
|
|
61
|
+
* The properties a vtable slot backs, keyed by canonical property name, so a class adopting the
|
|
62
|
+
* interface answers `g_object_get` and `g_object_set` with what the slot holds.
|
|
63
|
+
*/
|
|
64
|
+
properties?: Record<string, InterfaceProperty>;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Returns the GType a class was registered under, or the invalid type when it carries none. The tag is
|
|
68
|
+
* read off the class's own prototype, so a subclass that never went through `registerClass` reports the
|
|
69
|
+
* invalid type rather than inheriting the one its parent was registered with.
|
|
70
|
+
*/
|
|
71
|
+
declare function getClassType(cls: AnyClass | undefined): bigint;
|
|
72
|
+
/**
|
|
73
|
+
* Returns the GType the given instance's handle carries, or the invalid type when it has no handle.
|
|
74
|
+
* This is the object's own type rather than the type of the class it was wrapped as, and the two differ
|
|
75
|
+
* for an object GTK created itself, such as the row widget inside a `Gtk.ListView`, which GTKX wraps as
|
|
76
|
+
* the nearest registered ancestor.
|
|
77
|
+
*/
|
|
34
78
|
declare function getInstanceType(instance: object): bigint;
|
|
35
79
|
declare function registerClassType(cls: AnyClass, type: bigint): void;
|
|
36
80
|
/**
|
|
@@ -42,21 +86,24 @@ declare function registerClassType(cls: AnyClass, type: bigint): void;
|
|
|
42
86
|
* overrides.
|
|
43
87
|
*/
|
|
44
88
|
declare function registerWrapperClass(cls: AnyClass, type: bigint, vfuncs?: VfuncRegistry): void;
|
|
89
|
+
declare function markDerivedClass(cls: AnyClass): void;
|
|
90
|
+
declare function resolveWrapperType(instance: object): bigint;
|
|
45
91
|
/**
|
|
46
92
|
* Registers a GInterface, associating its GType with a mixin used to compose the
|
|
47
|
-
* interface onto wrapper classes and
|
|
93
|
+
* interface onto wrapper classes and, when introspection describes its vtable, that layout.
|
|
48
94
|
* @param cls Class carrying the interface's GType tag.
|
|
49
95
|
* @param type GType of the interface.
|
|
50
96
|
* @param mixin Mixin that applies the interface to a wrapper class.
|
|
51
|
-
* @param
|
|
52
|
-
* implementing class overrides.
|
|
97
|
+
* @param layout The interface's vtable struct, so `registerClass` can bind the slots an
|
|
98
|
+
* implementing class overrides and take over the ones it leaves alone.
|
|
53
99
|
*/
|
|
54
|
-
declare function registerInterface(cls: AnyClass, type: bigint, mixin: Mixin,
|
|
100
|
+
declare function registerInterface(cls: AnyClass, type: bigint, mixin: Mixin, layout?: InterfaceLayout): void;
|
|
55
101
|
/**
|
|
56
102
|
* Wraps a native handle in a JS wrapper instance. With no class, resolves and
|
|
57
|
-
* reuses the wrapper for the handle's runtime GType (composing interface mixins)
|
|
58
|
-
*
|
|
59
|
-
*
|
|
103
|
+
* reuses the wrapper for the handle's runtime GType (composing interface mixins),
|
|
104
|
+
* and hands back an instance that already carries a handle unchanged; with an
|
|
105
|
+
* explicit class, creates a bare instance backed by the handle. Returns null for
|
|
106
|
+
* a null or undefined handle.
|
|
60
107
|
* @param handle Native handle to wrap.
|
|
61
108
|
* @param cls Wrapper class to instantiate, or omitted to resolve it from the runtime type.
|
|
62
109
|
*/
|
|
@@ -71,13 +118,16 @@ declare function wrapHandle(handle: ExternalObject<Handle> | null | undefined, c
|
|
|
71
118
|
*/
|
|
72
119
|
declare function getWrapperClass(type: bigint): AnyClass;
|
|
73
120
|
declare function resolveWrapperClass(type: bigint): AnyClass | null;
|
|
121
|
+
declare function getInterfaceMixin(type: bigint): Mixin | undefined;
|
|
122
|
+
declare function wrapObject(value: unknown): object | null;
|
|
123
|
+
declare function instanceClassName(instance: object): string;
|
|
74
124
|
/** Returns the native handle bound to a wrapper instance, throwing if none is set. */
|
|
75
125
|
declare function getHandle(instance: object): ExternalObject<Handle>;
|
|
76
|
-
/** Returns the native handle bound to an instance, or undefined when there is none or the instance is null. */
|
|
77
|
-
declare function tryGetHandle(instance: object | null | undefined): ExternalObject<Handle> | undefined;
|
|
78
126
|
/** Associates a native handle with a wrapper instance. */
|
|
79
127
|
declare function setHandle(instance: object, handle: ExternalObject<Handle>): void;
|
|
128
|
+
declare function registerWrapper(handle: ExternalObject<Handle>, instance: object): void;
|
|
80
129
|
declare function getVfuncRegistry(cls: object): VfuncRegistry | undefined;
|
|
81
130
|
declare function getInterfaceVfuncRegistry(type: bigint): VfuncRegistry | undefined;
|
|
82
|
-
|
|
131
|
+
declare function getInterfaceProperties(type: bigint): Record<string, InterfaceProperty> | undefined;
|
|
132
|
+
export { getClassType, getInstanceType, markDerivedClass, registerClassType, registerWrapperClass, registerInterface, wrapHandle, getWrapperClass, resolveWrapperClass, getHandle, setHandle, getVfuncRegistry, getInterfaceMixin, getInterfaceProperties, getInterfaceVfuncRegistry, instanceClassName, registerWrapper, resolveWrapperType, wrapObject, type InterfaceProperty, type StaticBase, type VfuncDescriptor, };
|
|
83
133
|
//# sourceMappingURL=registry.d.ts.map
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,kBAAkB,IAAI,wBAAwB,EAEtD,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAiB,MAAM,YAAY,CAAC;AACvD,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