@gtkx/runtime 1.0.0 → 1.2.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 +1 -1
- package/dist/application-class.d.ts +5 -0
- package/dist/application-class.d.ts.map +1 -1
- package/dist/application-class.js +11 -1
- package/dist/application-class.js.map +1 -1
- package/dist/callback.d.ts +2 -2
- package/dist/callback.d.ts.map +1 -1
- package/dist/callback.js +51 -54
- package/dist/callback.js.map +1 -1
- package/dist/closure.js +1 -1
- package/dist/closure.js.map +1 -1
- package/dist/default-application.d.ts +4 -0
- package/dist/default-application.d.ts.map +1 -0
- package/dist/default-application.js +17 -0
- package/dist/default-application.js.map +1 -0
- package/dist/descriptors.d.ts +34 -9
- package/dist/descriptors.d.ts.map +1 -1
- package/dist/descriptors.js +42 -17
- package/dist/descriptors.js.map +1 -1
- package/dist/exit-hook.js +13 -0
- package/dist/exit-hook.js.map +1 -1
- package/dist/fn.d.ts +5 -0
- package/dist/fn.d.ts.map +1 -1
- package/dist/fn.js +11 -13
- package/dist/fn.js.map +1 -1
- package/dist/folded-lengths.d.ts +16 -0
- package/dist/folded-lengths.d.ts.map +1 -0
- package/dist/folded-lengths.js +38 -0
- package/dist/folded-lengths.js.map +1 -0
- 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 +16 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +44 -14
- package/dist/lifecycle.js.map +1 -1
- package/dist/listeners.d.ts.map +1 -1
- package/dist/listeners.js +16 -4
- package/dist/listeners.js.map +1 -1
- package/dist/native-value.js +2 -2
- package/dist/native-value.js.map +1 -1
- package/dist/object.d.ts +7 -2
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +7 -2
- package/dist/object.js.map +1 -1
- package/dist/param-spec.d.ts.map +1 -1
- package/dist/param-spec.js +18 -20
- package/dist/param-spec.js.map +1 -1
- package/dist/properties.d.ts +2 -1
- package/dist/properties.d.ts.map +1 -1
- package/dist/properties.js +13 -9
- package/dist/properties.js.map +1 -1
- package/dist/register-class.d.ts +33 -3
- package/dist/register-class.d.ts.map +1 -1
- package/dist/register-class.js +21 -7
- package/dist/register-class.js.map +1 -1
- package/dist/registry.d.ts +14 -4
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +24 -15
- package/dist/registry.js.map +1 -1
- package/dist/signal.d.ts +2 -2
- package/dist/signal.d.ts.map +1 -1
- package/dist/signal.js +22 -18
- package/dist/signal.js.map +1 -1
- package/dist/t.d.ts +3 -1
- package/dist/t.d.ts.map +1 -1
- package/dist/t.js +1 -0
- package/dist/t.js.map +1 -1
- package/dist/tuple.d.ts +6 -3
- package/dist/tuple.d.ts.map +1 -1
- package/dist/tuple.js +9 -7
- package/dist/tuple.js.map +1 -1
- package/dist/value.d.ts +3 -1
- package/dist/value.d.ts.map +1 -1
- package/dist/value.js +64 -18
- package/dist/value.js.map +1 -1
- package/dist/vfunc-call.d.ts.map +1 -1
- package/dist/vfunc-call.js +5 -1
- package/dist/vfunc-call.js.map +1 -1
- package/dist/vfunc.d.ts.map +1 -1
- package/dist/vfunc.js +9 -3
- package/dist/vfunc.js.map +1 -1
- package/package.json +14 -4
- package/src/application-class.ts +12 -2
- package/src/callback.ts +70 -66
- package/src/closure.ts +1 -1
- package/src/default-application.ts +21 -0
- package/src/descriptors.ts +98 -29
- package/src/exit-hook.ts +18 -0
- package/src/fn.ts +23 -13
- package/src/folded-lengths.ts +64 -0
- package/src/internal.ts +1 -0
- package/src/library.ts +2 -1
- package/src/lifecycle.ts +60 -14
- package/src/listeners.ts +22 -5
- package/src/native-value.ts +2 -2
- package/src/object.ts +7 -2
- package/src/param-spec.ts +21 -22
- package/src/properties.ts +23 -9
- package/src/register-class.ts +66 -11
- package/src/registry.ts +43 -20
- package/src/signal.ts +32 -28
- package/src/t.ts +4 -1
- package/src/tuple.ts +18 -12
- package/src/value.ts +94 -19
- package/src/vfunc-call.ts +5 -1
- package/src/vfunc.ts +10 -3
package/dist/descriptors.js
CHANGED
|
@@ -32,6 +32,7 @@ const voidT = { kind: "void" };
|
|
|
32
32
|
const unicharT = { kind: "unichar" };
|
|
33
33
|
/** Descriptor for an opaque `gpointer`, taken from a typed array's memory or a numeric address. */
|
|
34
34
|
const bufferT = { kind: "buffer" };
|
|
35
|
+
const fundamentalLifecycles = new Map();
|
|
35
36
|
/**
|
|
36
37
|
* Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer
|
|
37
38
|
* used when the string is passed by reference.
|
|
@@ -112,12 +113,19 @@ const structT = (ownership = "borrowed", options = {}) => {
|
|
|
112
113
|
}
|
|
113
114
|
return result;
|
|
114
115
|
};
|
|
116
|
+
const recordFundamentalLifecycle = (typeName, lifecycle) => {
|
|
117
|
+
if (!fundamentalLifecycles.has(typeName)) {
|
|
118
|
+
fundamentalLifecycles.set(typeName, lifecycle);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const fundamentalLifecycleFor = (typeName) => fundamentalLifecycles.get(typeName);
|
|
115
122
|
/** Builds a descriptor for a fundamental type whose lifetime is managed by named ref and unref functions. */
|
|
116
123
|
const fundamentalT = (sharedLibrary, refFnName, unrefFnName, options = {}) => {
|
|
117
124
|
const ownership = options.ownership ?? "borrowed";
|
|
118
125
|
const result = { kind: "fundamental", ownership, sharedLibrary, refFnName, unrefFnName };
|
|
119
126
|
if (options.typeName !== undefined) {
|
|
120
127
|
result.typeName = options.typeName;
|
|
128
|
+
recordFundamentalLifecycle(options.typeName, { sharedLibrary, refFnName, unrefFnName });
|
|
121
129
|
}
|
|
122
130
|
if (options.wrapperClass !== undefined) {
|
|
123
131
|
result.wrapperClass = options.wrapperClass;
|
|
@@ -133,47 +141,64 @@ const arrayT = (itemDescriptor, arrayKind = "array", ownership = "borrowed", opt
|
|
|
133
141
|
if (options?.elementSize !== undefined) {
|
|
134
142
|
result.elementSize = options.elementSize;
|
|
135
143
|
}
|
|
144
|
+
if (options?.baseParamIndex !== undefined) {
|
|
145
|
+
result.baseParamIndex = options.baseParamIndex;
|
|
146
|
+
}
|
|
136
147
|
if (options?.sizeParamIndex !== undefined) {
|
|
137
148
|
result.sizeParamIndex = options.sizeParamIndex;
|
|
138
149
|
}
|
|
139
150
|
if (options?.fixedSize !== undefined) {
|
|
140
151
|
result.fixedSize = options.fixedSize;
|
|
141
152
|
}
|
|
153
|
+
if (options?.isBytes === true) {
|
|
154
|
+
result.isBytes = true;
|
|
155
|
+
}
|
|
142
156
|
return result;
|
|
143
157
|
};
|
|
144
158
|
/** Builds a descriptor for a `GList` of items. */
|
|
145
|
-
const listT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "glist", ownership);
|
|
159
|
+
const listT = (itemDescriptor, ownership = "borrowed", options = {}) => arrayT(itemDescriptor, "glist", ownership, options);
|
|
146
160
|
/** Builds a descriptor for a `GSList` of items. */
|
|
147
|
-
const slistT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gslist", ownership);
|
|
161
|
+
const slistT = (itemDescriptor, ownership = "borrowed", options = {}) => arrayT(itemDescriptor, "gslist", ownership, options);
|
|
148
162
|
/** Builds a descriptor for a `GPtrArray` of items. */
|
|
149
|
-
const ptrArrayT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gptrarray", ownership);
|
|
150
|
-
/** Builds a descriptor for a `GArray` of items
|
|
151
|
-
const gArrayT = (itemDescriptor, ownership = "borrowed",
|
|
163
|
+
const ptrArrayT = (itemDescriptor, ownership = "borrowed", options = {}) => arrayT(itemDescriptor, "gptrarray", ownership, options);
|
|
164
|
+
/** Builds a descriptor for a `GArray` of items. */
|
|
165
|
+
const gArrayT = (itemDescriptor, ownership = "borrowed", options = {}) => arrayT(itemDescriptor, "garray", ownership, options);
|
|
152
166
|
/** Builds a descriptor for a `GByteArray`. */
|
|
153
|
-
const byteArrayT = (ownership = "borrowed") => arrayT(uint8T, "gbytearray", ownership);
|
|
167
|
+
const byteArrayT = (ownership = "borrowed") => arrayT(uint8T, "gbytearray", ownership, { isBytes: true });
|
|
154
168
|
/** Builds a descriptor for a C array whose length is carried by another argument. */
|
|
155
|
-
const sizedArrayT = (itemDescriptor, sizeParamIndex, ownership = "borrowed",
|
|
169
|
+
const sizedArrayT = (itemDescriptor, sizeParamIndex, ownership = "borrowed", options = {}) => arrayT(itemDescriptor, "sized", ownership, { ...options, sizeParamIndex });
|
|
170
|
+
/**
|
|
171
|
+
* Builds a descriptor for an out pointer into the buffer another argument supplied, decoded as the
|
|
172
|
+
* elements from where it points to the end of that buffer.
|
|
173
|
+
*/
|
|
174
|
+
const cursorArrayT = (itemDescriptor, bounds, ownership = "borrowed", options = {}) => arrayT(itemDescriptor, "cursor", ownership, { ...options, ...bounds });
|
|
156
175
|
/** Builds a descriptor for a C array of a fixed length. */
|
|
157
|
-
const fixedArrayT = (itemDescriptor, fixedSize, ownership = "borrowed",
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const result = { kind: "callback", argDescriptors, returnDescriptor };
|
|
161
|
-
if (options?.hasDestroy !== undefined) {
|
|
176
|
+
const fixedArrayT = (itemDescriptor, fixedSize, ownership = "borrowed", options = {}) => arrayT(itemDescriptor, "fixed", ownership, { ...options, fixedSize });
|
|
177
|
+
const applyClosureOptions = (result, options) => {
|
|
178
|
+
if (options.hasDestroy !== undefined) {
|
|
162
179
|
result.hasDestroy = options.hasDestroy;
|
|
163
180
|
}
|
|
164
|
-
if (options
|
|
181
|
+
if (options.destroyKind !== undefined) {
|
|
165
182
|
result.destroyKind = options.destroyKind;
|
|
166
183
|
}
|
|
167
|
-
if (options
|
|
184
|
+
if (options.hasUserData !== undefined) {
|
|
168
185
|
result.hasUserData = options.hasUserData;
|
|
169
186
|
}
|
|
170
|
-
if (options
|
|
187
|
+
if (options.userDataIndex !== undefined) {
|
|
171
188
|
result.userDataIndex = options.userDataIndex;
|
|
172
189
|
}
|
|
173
|
-
if (options
|
|
190
|
+
if (options.scope !== undefined) {
|
|
174
191
|
result.scope = options.scope;
|
|
175
192
|
}
|
|
193
|
+
};
|
|
194
|
+
/** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */
|
|
195
|
+
const callbackT = (argDescriptors, returnDescriptor, options) => {
|
|
196
|
+
const result = { kind: "callback", argDescriptors, returnDescriptor };
|
|
197
|
+
if (options === undefined) {
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
applyClosureOptions(result, options);
|
|
176
201
|
return result;
|
|
177
202
|
};
|
|
178
|
-
export { int8T, uint8T, int16T, uint16T, int32T, uint32T, int64T, uint64T, bigint64T, biguint64T, gtypeT, float32T, float64T, booleanT, voidT, unicharT, bufferT, stringT, objectT, refT, hashTableT, enumT, flagsT, boxedT, structT, fundamentalT, arrayT, listT, slistT, ptrArrayT, gArrayT, byteArrayT, sizedArrayT, fixedArrayT, callbackT, };
|
|
203
|
+
export { int8T, uint8T, int16T, uint16T, int32T, uint32T, int64T, uint64T, bigint64T, biguint64T, gtypeT, float32T, float64T, booleanT, voidT, unicharT, bufferT, stringT, objectT, refT, hashTableT, enumT, flagsT, boxedT, structT, fundamentalLifecycleFor, fundamentalT, arrayT, listT, slistT, ptrArrayT, gArrayT, byteArrayT, sizedArrayT, fixedArrayT, cursorArrayT, callbackT, };
|
|
179
204
|
//# sourceMappingURL=descriptors.js.map
|
package/dist/descriptors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../src/descriptors.ts"],"names":[],"mappings":"AA2IA,wDAAwD;AACxD,MAAM,KAAK,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/C,yDAAyD;AACzD,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClD,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C;IACjD,CAAC;IAED,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EACH,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,UAAU,EACV,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,GAQZ,CAAC","sourcesContent":["import type { ArrayKind, Descriptor, Ownership } from \"@gtkx/native\";\nimport type { AnyClass } from \"@gtkx/utils\";\n\n/** Descriptor variant for a `gint8`. */\ntype Int8Descriptor = Extract<Descriptor, { kind: \"int8\" }>;\n/** Descriptor variant for a `guint8`. */\ntype Uint8Descriptor = Extract<Descriptor, { kind: \"uint8\" }>;\n/** Descriptor variant for a `gint16`. */\ntype Int16Descriptor = Extract<Descriptor, { kind: \"int16\" }>;\n/** Descriptor variant for a `guint16`. */\ntype Uint16Descriptor = Extract<Descriptor, { kind: \"uint16\" }>;\n/** Descriptor variant for a `gint32`. */\ntype Int32Descriptor = Extract<Descriptor, { kind: \"int32\" }>;\n/** Descriptor variant for a `guint32`. */\ntype Uint32Descriptor = Extract<Descriptor, { kind: \"uint32\" }>;\n/** Descriptor variant for a `gint64` marshalled as a number. */\ntype Int64Descriptor = Extract<Descriptor, { kind: \"int64\" }>;\n/** Descriptor variant for a `guint64` marshalled as a number. */\ntype Uint64Descriptor = Extract<Descriptor, { kind: \"uint64\" }>;\n/** Descriptor variant for a `gint64` marshalled as a bigint. */\ntype BigInt64Descriptor = Extract<Descriptor, { kind: \"bigint64\" }>;\n/** Descriptor variant for a `guint64` marshalled as a bigint. */\ntype BigUint64Descriptor = Extract<Descriptor, { kind: \"biguint64\" }>;\n/** Descriptor variant for a `gfloat`. */\ntype Float32Descriptor = Extract<Descriptor, { kind: \"float32\" }>;\n/** Descriptor variant for a `gdouble`. */\ntype Float64Descriptor = Extract<Descriptor, { kind: \"float64\" }>;\n/** Descriptor variant for an enumeration, carrying the library and `get_type` symbol its GType comes from. */\ntype EnumDescriptor = Extract<Descriptor, { kind: \"enum\" }>;\n/** Descriptor variant for a flags type, carrying the library and `get_type` symbol its GType comes from. */\ntype FlagsDescriptor = Extract<Descriptor, { kind: \"flags\" }>;\n/** Descriptor variant for a `gboolean`. */\ntype BooleanDescriptor = Extract<Descriptor, { kind: \"boolean\" }>;\n/** Descriptor variant for a C string. */\ntype StringDescriptor = Extract<Descriptor, { kind: \"string\" }>;\n/** Descriptor variant for a `GObject`. */\ntype ObjectDescriptor = Extract<Descriptor, { kind: \"object\" }>;\n/** Descriptor variant for a `gunichar`. */\ntype UnicharDescriptor = Extract<Descriptor, { kind: \"unichar\" }>;\n/** Descriptor variant for the absence of a value. */\ntype VoidDescriptor = Extract<Descriptor, { kind: \"void\" }>;\n/** Descriptor variant for an opaque `gpointer`. */\ntype BufferDescriptor = Extract<Descriptor, { kind: \"buffer\" }>;\n/** Descriptor variant for a `GBoxed` value. */\ntype BoxedDescriptor = Extract<Descriptor, { kind: \"boxed\" }>;\n\n/** Descriptor variant for a plain C struct, extended with the class its decoded value is wrapped in. */\ntype StructDescriptor = Extract<Descriptor, { kind: \"struct\" }> & {\n /** Class a decoded value is wrapped in; without it the wrapper comes from the value's own GType. */\n wrapperClass?: AnyClass;\n};\n\n/** Descriptor variant for a ref-counted fundamental type, extended with the class its decoded value is wrapped in. */\ntype FundamentalDescriptor = Extract<Descriptor, { kind: \"fundamental\" }> & {\n /** Class a decoded value is wrapped in; without it the wrapper comes from the type named by `typeName`. */\n wrapperClass?: AnyClass;\n};\n\n/** Descriptor variant for an array of items in one of the supported container layouts. */\ntype ArrayDescriptor = Extract<Descriptor, { kind: \"array\" }>;\n/** Descriptor variant for a `GHashTable`, marshalled as an array of key/value pairs. */\ntype HashTableDescriptor = Extract<Descriptor, { kind: \"hashtable\" }>;\n/** Descriptor variant for a function pointer a JavaScript function is marshalled into. */\ntype CallbackDescriptor = Extract<Descriptor, { kind: \"callback\" }>;\n/** Descriptor variant for a pointer to another descriptor's value, for an output or inout argument. */\ntype RefDescriptor = Extract<Descriptor, { kind: \"ref\" }>;\n\n/** Descriptor for a `GType`: a `guint64` marked so it resolves to `G_TYPE_GTYPE` rather than an integer. */\ntype TypeDescriptor = BigUint64Descriptor & {\n /** Distinguishes a GType from a plain `guint64` when the GLib type and the GValue type are resolved. */\n type: true;\n};\n\n/** How a boxed value is stored, and where its GType and free function are resolved from. */\ntype BoxedOptions = {\n /** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */\n isCallerAllocated?: boolean;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n /** Whether a decoded value is owned by the caller; defaults to `\"borrowed\"`. */\n ownership?: Ownership;\n /** Library `getTypeFnName` and `freeFnName` are resolved in. */\n sharedLibrary?: string;\n /** Symbol returning the boxed GType, used when the type is not already registered under its name. */\n getTypeFnName?: string;\n /** Symbol that frees the value, for a boxed type with no GType of its own. */\n freeFnName?: string;\n /** Byte size of the value, needed to copy it into an inline field. */\n size?: number;\n};\n\n/** How the callee takes a callback's closure, and how long that closure has to stay alive. */\ntype CallbackOptions = {\n /** The callee also takes a destroy notify, which frees the closure once it is done with it. */\n hasDestroy?: boolean;\n /** Signature of that destroy notify; defaults to `destroyNotify`, a one-argument `GDestroyNotify`. */\n destroyKind?: CallbackDescriptor[\"destroyKind\"];\n /** The callee also takes a `user_data` pointer; without one the closure can never be freed. */\n hasUserData?: boolean;\n /** Position of `user_data` among the callback's own arguments, dropped before the closure is called. */\n userDataIndex?: number;\n /** Lifetime of the closure; defaults to `notified` when `hasDestroy` is set and `call` otherwise. */\n scope?: CallbackDescriptor[\"scope\"];\n};\n\n/** The lengths and strides a C array layout needs beyond its element type. */\ntype ArrayOptions = {\n /** Stride in bytes between elements stored inline in the array. */\n elementSize?: number | undefined;\n /** Position of the argument carrying the element count, for a length-bounded array. */\n sizeParamIndex?: number | undefined;\n /** Element count of a fixed-length array. */\n fixedSize?: number | undefined;\n};\n\n/** How a ref-counted fundamental value is named, wrapped and stored. */\ntype FundamentalOptions = {\n /** Whether a decoded value is owned by the caller; defaults to `\"borrowed\"`. */\n ownership?: Ownership;\n /** GLib type name the wrapper class is looked up by. */\n typeName?: string;\n /** Class a decoded value is wrapped in, instead of the one registered for `typeName`. */\n wrapperClass?: AnyClass;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n};\n\n/** How a plain C struct is stored and wrapped. */\ntype StructOptions = {\n /** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */\n isCallerAllocated?: boolean;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n /** Byte size of the struct, needed to copy it rather than borrow the pointer. */\n size?: number;\n /** Class a decoded value is wrapped in, instead of the one registered for its GType. */\n wrapperClass?: AnyClass;\n};\n\n/** Descriptor for a `gint8`, marshalled as a number. */\nconst int8T: Int8Descriptor = { kind: \"int8\" };\n/** Descriptor for a `guint8`, marshalled as a number. */\nconst uint8T: Uint8Descriptor = { kind: \"uint8\" };\n/** Descriptor for a `gint16`, marshalled as a number. */\nconst int16T: Int16Descriptor = { kind: \"int16\" };\n/** Descriptor for a `guint16`, marshalled as a number. */\nconst uint16T: Uint16Descriptor = { kind: \"uint16\" };\n/** Descriptor for a `gint32`, marshalled as a number. */\nconst int32T: Int32Descriptor = { kind: \"int32\" };\n/** Descriptor for a `guint32`, marshalled as a number. */\nconst uint32T: Uint32Descriptor = { kind: \"uint32\" };\n/** Descriptor for a `gint64`, marshalled as a number and rejected outside the 2^53 safe range. */\nconst int64T: Int64Descriptor = { kind: \"int64\" };\n/** Descriptor for a `guint64`, marshalled as a number and rejected outside the 2^53 safe range. */\nconst uint64T: Uint64Descriptor = { kind: \"uint64\" };\n/** Descriptor for a `gint64`, marshalled as a bigint so the full 64-bit range survives. */\nconst bigint64T: BigInt64Descriptor = { kind: \"bigint64\" };\n/** Descriptor for a `guint64`, marshalled as a bigint so the full 64-bit range survives. */\nconst biguint64T: BigUint64Descriptor = { kind: \"biguint64\" };\n/** Descriptor for a `GType`, marshalled as a bigint and recognized as a GType by GValue conversion. */\nconst gtypeT: TypeDescriptor = { kind: \"biguint64\", type: true };\n/** Descriptor for a `gfloat`. */\nconst float32T: Float32Descriptor = { kind: \"float32\" };\n/** Descriptor for a `gdouble`. */\nconst float64T: Float64Descriptor = { kind: \"float64\" };\n/** Descriptor for a `gboolean`, marshalled as a JavaScript boolean. */\nconst booleanT: BooleanDescriptor = { kind: \"boolean\" };\n/** Descriptor for the absence of a value, used as the return descriptor of a `void` function. */\nconst voidT: VoidDescriptor = { kind: \"void\" };\n/** Descriptor for a `gunichar`, marshalled as a single-character string or a codepoint number. */\nconst unicharT: UnicharDescriptor = { kind: \"unichar\" };\n/** Descriptor for an opaque `gpointer`, taken from a typed array's memory or a numeric address. */\nconst bufferT: BufferDescriptor = { kind: \"buffer\" };\n\n/**\n * Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer\n * used when the string is passed by reference.\n */\nconst stringT = (ownership: Ownership = \"borrowed\", length?: number): StringDescriptor =>\n length === undefined ? { kind: \"string\", ownership } : { kind: \"string\", ownership, length };\n\n/** Builds a descriptor for a `GObject`, wrapped in the class registered for its runtime GType. */\nconst objectT = (ownership: Ownership = \"borrowed\"): ObjectDescriptor => ({ kind: \"object\", ownership });\n\n/** Wraps a descriptor in a pointer to it, for an output or inout argument. */\nconst refT = (innerDescriptor: Descriptor, isInout = false): RefDescriptor =>\n isInout ? { kind: \"ref\", innerDescriptor, inout: true } : { kind: \"ref\", innerDescriptor };\n\n/** Builds a descriptor for a `GHashTable`, marshalled as an array of key/value pairs. */\nconst hashTableT = (\n keyDescriptor: Descriptor,\n valueDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n): HashTableDescriptor => ({\n kind: \"hashtable\",\n keyDescriptor,\n valueDescriptor,\n ownership,\n});\n\n/** Builds a descriptor for an enumeration, resolving its GType from the named `get_type` function. */\nconst enumT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): EnumDescriptor => ({\n kind: \"enum\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n isSigned,\n});\n\n/** Builds a descriptor for a flags type, resolving its GType from the named `get_type` function. */\nconst flagsT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): FlagsDescriptor => ({\n kind: \"flags\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n isSigned,\n});\n\nconst applyBoxedNames = (result: BoxedDescriptor, options: BoxedOptions): void => {\n if (options.sharedLibrary !== undefined) {\n result.sharedLibrary = options.sharedLibrary;\n }\n\n if (options.getTypeFnName !== undefined) {\n result.getTypeFnName = options.getTypeFnName;\n }\n\n if (options.freeFnName !== undefined) {\n result.freeFnName = options.freeFnName;\n }\n};\n\nconst applyBoxedOptions = (result: BoxedDescriptor, options: BoxedOptions): void => {\n applyBoxedNames(result, options);\n\n if (options.isCallerAllocated) {\n result.isCallerAllocated = true;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n};\n\n/** Builds a descriptor for a `GBoxed` value of the named type. */\nconst boxedT = (typeName: string, options: BoxedOptions = {}): BoxedDescriptor => {\n const result: BoxedDescriptor = {\n kind: \"boxed\",\n ownership: options.ownership ?? \"borrowed\",\n typeName,\n };\n\n applyBoxedOptions(result, options);\n\n return result;\n};\n\n/** Builds a descriptor for a plain C struct. */\nconst structT = (ownership: Ownership = \"borrowed\", options: StructOptions = {}): StructDescriptor => {\n const result: StructDescriptor = { kind: \"struct\", ownership };\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.isCallerAllocated) {\n result.isCallerAllocated = true;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n return result;\n};\n\n/** Builds a descriptor for a fundamental type whose lifetime is managed by named ref and unref functions. */\nconst fundamentalT = (\n sharedLibrary: string,\n refFnName: string,\n unrefFnName: string,\n options: FundamentalOptions = {},\n): FundamentalDescriptor => {\n const ownership = options.ownership ?? \"borrowed\";\n const result: FundamentalDescriptor = { kind: \"fundamental\", ownership, sharedLibrary, refFnName, unrefFnName };\n\n if (options.typeName !== undefined) {\n result.typeName = options.typeName;\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n return result;\n};\n\n/** Builds a descriptor for an array of items in one of the supported container layouts. */\nconst arrayT = (\n itemDescriptor: Descriptor,\n arrayKind: ArrayKind = \"array\",\n ownership: Ownership = \"borrowed\",\n options?: ArrayOptions,\n): ArrayDescriptor => {\n const result: ArrayDescriptor = { kind: \"array\", itemDescriptor, arrayKind, ownership };\n\n if (options?.elementSize !== undefined) {\n result.elementSize = options.elementSize;\n }\n\n if (options?.sizeParamIndex !== undefined) {\n result.sizeParamIndex = options.sizeParamIndex;\n }\n\n if (options?.fixedSize !== undefined) {\n result.fixedSize = options.fixedSize;\n }\n\n return result;\n};\n\n/** Builds a descriptor for a `GList` of items. */\nconst listT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"glist\", ownership);\n\n/** Builds a descriptor for a `GSList` of items. */\nconst slistT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gslist\", ownership);\n\n/** Builds a descriptor for a `GPtrArray` of items. */\nconst ptrArrayT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gptrarray\", ownership);\n\n/** Builds a descriptor for a `GArray` of items, optionally with an explicit element size. */\nconst gArrayT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor =>\n arrayT(itemDescriptor, \"garray\", ownership, elementSize === undefined ? undefined : { elementSize });\n\n/** Builds a descriptor for a `GByteArray`. */\nconst byteArrayT = (ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(uint8T, \"gbytearray\", ownership);\n\n/** Builds a descriptor for a C array whose length is carried by another argument. */\nconst sizedArrayT = (\n itemDescriptor: Descriptor,\n sizeParamIndex: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"sized\", ownership, { sizeParamIndex, elementSize });\n\n/** Builds a descriptor for a C array of a fixed length. */\nconst fixedArrayT = (\n itemDescriptor: Descriptor,\n fixedSize: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"fixed\", ownership, { fixedSize, elementSize });\n\n/** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */\nconst callbackT = (\n argDescriptors: Descriptor[],\n returnDescriptor: Descriptor,\n options?: CallbackOptions,\n): CallbackDescriptor => {\n const result: CallbackDescriptor = { kind: \"callback\", argDescriptors, returnDescriptor };\n\n if (options?.hasDestroy !== undefined) {\n result.hasDestroy = options.hasDestroy;\n }\n\n if (options?.destroyKind !== undefined) {\n result.destroyKind = options.destroyKind;\n }\n\n if (options?.hasUserData !== undefined) {\n result.hasUserData = options.hasUserData;\n }\n\n if (options?.userDataIndex !== undefined) {\n result.userDataIndex = options.userDataIndex;\n }\n\n if (options?.scope !== undefined) {\n result.scope = options.scope;\n }\n\n return result;\n};\n\nexport {\n int8T,\n uint8T,\n int16T,\n uint16T,\n int32T,\n uint32T,\n int64T,\n uint64T,\n bigint64T,\n biguint64T,\n gtypeT,\n float32T,\n float64T,\n booleanT,\n voidT,\n unicharT,\n bufferT,\n stringT,\n objectT,\n refT,\n hashTableT,\n enumT,\n flagsT,\n boxedT,\n structT,\n fundamentalT,\n arrayT,\n listT,\n slistT,\n ptrArrayT,\n gArrayT,\n byteArrayT,\n sizedArrayT,\n fixedArrayT,\n callbackT,\n type BoxedDescriptor,\n type StructDescriptor,\n type FundamentalDescriptor,\n type ArrayDescriptor,\n type HashTableDescriptor,\n type CallbackDescriptor,\n type RefDescriptor,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../src/descriptors.ts"],"names":[],"mappings":"AAgKA,wDAAwD;AACxD,MAAM,KAAK,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/C,yDAAyD;AACzD,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClD,yDAAyD;AACzD,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClD,0DAA0D;AAC1D,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACrD,yDAAyD;AACzD,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClD,0DAA0D;AAC1D,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACrD,kGAAkG;AAClG,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAClD,mGAAmG;AACnG,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACrD,2FAA2F;AAC3F,MAAM,SAAS,GAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC3D,4FAA4F;AAC5F,MAAM,UAAU,GAAwB,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAC9D,uGAAuG;AACv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rayKind, Descriptor, Ownership } from \"@gtkx/native\";\nimport type { AnyClass } from \"@gtkx/utils\";\n\n/** Descriptor variant for a `gint8`. */\ntype Int8Descriptor = Extract<Descriptor, { kind: \"int8\" }>;\n/** Descriptor variant for a `guint8`. */\ntype Uint8Descriptor = Extract<Descriptor, { kind: \"uint8\" }>;\n/** Descriptor variant for a `gint16`. */\ntype Int16Descriptor = Extract<Descriptor, { kind: \"int16\" }>;\n/** Descriptor variant for a `guint16`. */\ntype Uint16Descriptor = Extract<Descriptor, { kind: \"uint16\" }>;\n/** Descriptor variant for a `gint32`. */\ntype Int32Descriptor = Extract<Descriptor, { kind: \"int32\" }>;\n/** Descriptor variant for a `guint32`. */\ntype Uint32Descriptor = Extract<Descriptor, { kind: \"uint32\" }>;\n/** Descriptor variant for a `gint64` marshalled as a number. */\ntype Int64Descriptor = Extract<Descriptor, { kind: \"int64\" }>;\n/** Descriptor variant for a `guint64` marshalled as a number. */\ntype Uint64Descriptor = Extract<Descriptor, { kind: \"uint64\" }>;\n/** Descriptor variant for a `gint64` marshalled as a bigint. */\ntype BigInt64Descriptor = Extract<Descriptor, { kind: \"bigint64\" }>;\n/** Descriptor variant for a `guint64` marshalled as a bigint. */\ntype BigUint64Descriptor = Extract<Descriptor, { kind: \"biguint64\" }>;\n/** Descriptor variant for a `gfloat`. */\ntype Float32Descriptor = Extract<Descriptor, { kind: \"float32\" }>;\n/** Descriptor variant for a `gdouble`. */\ntype Float64Descriptor = Extract<Descriptor, { kind: \"float64\" }>;\n/** Descriptor variant for an enumeration, carrying the library and `get_type` symbol its GType comes from. */\ntype EnumDescriptor = Extract<Descriptor, { kind: \"enum\" }>;\n/** Descriptor variant for a flags type, carrying the library and `get_type` symbol its GType comes from. */\ntype FlagsDescriptor = Extract<Descriptor, { kind: \"flags\" }>;\n/** Descriptor variant for a `gboolean`. */\ntype BooleanDescriptor = Extract<Descriptor, { kind: \"boolean\" }>;\n/** Descriptor variant for a C string. */\ntype StringDescriptor = Extract<Descriptor, { kind: \"string\" }>;\n/** Descriptor variant for a `GObject`. */\ntype ObjectDescriptor = Extract<Descriptor, { kind: \"object\" }>;\n/** Descriptor variant for a `gunichar`. */\ntype UnicharDescriptor = Extract<Descriptor, { kind: \"unichar\" }>;\n/** Descriptor variant for the absence of a value. */\ntype VoidDescriptor = Extract<Descriptor, { kind: \"void\" }>;\n/** Descriptor variant for an opaque `gpointer`. */\ntype BufferDescriptor = Extract<Descriptor, { kind: \"buffer\" }>;\n/** Descriptor variant for a `GBoxed` value. */\ntype BoxedDescriptor = Extract<Descriptor, { kind: \"boxed\" }>;\n\n/** Descriptor variant for a plain C struct, extended with the class its decoded value is wrapped in. */\ntype StructDescriptor = Extract<Descriptor, { kind: \"struct\" }> & {\n /** Class a decoded value is wrapped in; without it the wrapper comes from the value's own GType. */\n wrapperClass?: AnyClass;\n};\n\n/** Descriptor variant for a ref-counted fundamental type, extended with the class its decoded value is wrapped in. */\ntype FundamentalDescriptor = Extract<Descriptor, { kind: \"fundamental\" }> & {\n /** Class a decoded value is wrapped in; without it the wrapper comes from the type named by `typeName`. */\n wrapperClass?: AnyClass;\n};\n\n/** Descriptor variant for an array of items in one of the supported container layouts. */\ntype ArrayDescriptor = Extract<Descriptor, { kind: \"array\" }>;\n/** Descriptor variant for a `GHashTable`, marshalled as an array of key/value pairs. */\ntype HashTableDescriptor = Extract<Descriptor, { kind: \"hashtable\" }>;\n/** Descriptor variant for a function pointer a JavaScript function is marshalled into. */\ntype CallbackDescriptor = Extract<Descriptor, { kind: \"callback\" }>;\n/** Descriptor variant for a pointer to another descriptor's value, for an output or inout argument. */\ntype RefDescriptor = Extract<Descriptor, { kind: \"ref\" }>;\n\n/** Descriptor for a `GType`: a `guint64` marked so it resolves to `G_TYPE_GTYPE` rather than an integer. */\ntype TypeDescriptor = BigUint64Descriptor & {\n /** Distinguishes a GType from a plain `guint64` when the GLib type and the GValue type are resolved. */\n type: true;\n};\n\n/** How a boxed value is stored, and where its GType and free function are resolved from. */\ntype BoxedOptions = {\n /** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */\n isCallerAllocated?: boolean;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n /** Whether a decoded value is owned by the caller; defaults to `\"borrowed\"`. */\n ownership?: Ownership;\n /** Library `getTypeFnName` and `freeFnName` are resolved in. */\n sharedLibrary?: string;\n /** Symbol returning the boxed GType, used when the type is not already registered under its name. */\n getTypeFnName?: string;\n /** Symbol that frees the value, for a boxed type with no GType of its own. */\n freeFnName?: string;\n /** Byte size of the value, needed to copy it into an inline field. */\n size?: number;\n};\n\n/**\n * What the bindings do with a callback's return value, how the callee takes its closure, and how\n * long that closure has to stay alive.\n */\ntype CallbackOptions = {\n /** The callee also takes a destroy notify, which frees the closure once it is done with it. */\n hasDestroy?: boolean;\n /** Signature of that destroy notify; defaults to `destroyNotify`, a one-argument `GDestroyNotify`. */\n destroyKind?: CallbackDescriptor[\"destroyKind\"];\n /** The callee also takes a `user_data` pointer; without one the closure can never be freed. */\n hasUserData?: boolean;\n /** Position of `user_data` among the callback's own arguments, dropped before the closure is called. */\n userDataIndex?: number;\n /** Lifetime of the closure; defaults to `notified` when `hasDestroy` is set and `call` otherwise. */\n scope?: CallbackDescriptor[\"scope\"];\n};\n\n/** The lengths and strides a C array layout needs beyond its element type. */\ntype ArrayOptions = {\n /** Stride in bytes between elements stored inline in the array. */\n elementSize?: number | undefined;\n /** Position of the argument whose buffer a cursor array points into. */\n baseParamIndex?: number | undefined;\n /** Position of the argument carrying the element count, for a length-bounded array. */\n sizeParamIndex?: number | undefined;\n /** Element count of a fixed-length array. */\n fixedSize?: number | undefined;\n /** Whether the array carries raw bytes, and so decodes to a `Uint8Array` rather than to numbers. */\n isBytes?: boolean | undefined;\n};\n\n/** Where a cursor array's base buffer and total length come from. */\ntype CursorBounds = {\n /** Position of the argument holding the buffer the cursor points into. */\n baseParamIndex: number;\n /** Position of the argument carrying that buffer's element count. */\n sizeParamIndex: number;\n};\n\n/** How a ref-counted fundamental value is named, wrapped and stored. */\ntype FundamentalOptions = {\n /** Whether a decoded value is owned by the caller; defaults to `\"borrowed\"`. */\n ownership?: Ownership;\n /** GLib type name the wrapper class is looked up by. */\n typeName?: string;\n /** Class a decoded value is wrapped in, instead of the one registered for `typeName`. */\n wrapperClass?: AnyClass;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n};\n\ntype FundamentalLifecycle = {\n sharedLibrary: string;\n refFnName: string;\n unrefFnName: string;\n};\n\n/** How a plain C struct is stored and wrapped. */\ntype StructOptions = {\n /** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */\n isCallerAllocated?: boolean;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n /** Byte size of the struct, needed to copy it rather than borrow the pointer. */\n size?: number;\n /** Class a decoded value is wrapped in, instead of the one registered for its GType. */\n wrapperClass?: AnyClass;\n};\n\n/** Descriptor for a `gint8`, marshalled as a number. */\nconst int8T: Int8Descriptor = { kind: \"int8\" };\n/** Descriptor for a `guint8`, marshalled as a number. */\nconst uint8T: Uint8Descriptor = { kind: \"uint8\" };\n/** Descriptor for a `gint16`, marshalled as a number. */\nconst int16T: Int16Descriptor = { kind: \"int16\" };\n/** Descriptor for a `guint16`, marshalled as a number. */\nconst uint16T: Uint16Descriptor = { kind: \"uint16\" };\n/** Descriptor for a `gint32`, marshalled as a number. */\nconst int32T: Int32Descriptor = { kind: \"int32\" };\n/** Descriptor for a `guint32`, marshalled as a number. */\nconst uint32T: Uint32Descriptor = { kind: \"uint32\" };\n/** Descriptor for a `gint64`, marshalled as a number and rejected outside the 2^53 safe range. */\nconst int64T: Int64Descriptor = { kind: \"int64\" };\n/** Descriptor for a `guint64`, marshalled as a number and rejected outside the 2^53 safe range. */\nconst uint64T: Uint64Descriptor = { kind: \"uint64\" };\n/** Descriptor for a `gint64`, marshalled as a bigint so the full 64-bit range survives. */\nconst bigint64T: BigInt64Descriptor = { kind: \"bigint64\" };\n/** Descriptor for a `guint64`, marshalled as a bigint so the full 64-bit range survives. */\nconst biguint64T: BigUint64Descriptor = { kind: \"biguint64\" };\n/** Descriptor for a `GType`, marshalled as a bigint and recognized as a GType by GValue conversion. */\nconst gtypeT: TypeDescriptor = { kind: \"biguint64\", type: true };\n/** Descriptor for a `gfloat`. */\nconst float32T: Float32Descriptor = { kind: \"float32\" };\n/** Descriptor for a `gdouble`. */\nconst float64T: Float64Descriptor = { kind: \"float64\" };\n/** Descriptor for a `gboolean`, marshalled as a JavaScript boolean. */\nconst booleanT: BooleanDescriptor = { kind: \"boolean\" };\n/** Descriptor for the absence of a value, used as the return descriptor of a `void` function. */\nconst voidT: VoidDescriptor = { kind: \"void\" };\n/** Descriptor for a `gunichar`, marshalled as a single-character string or a codepoint number. */\nconst unicharT: UnicharDescriptor = { kind: \"unichar\" };\n/** Descriptor for an opaque `gpointer`, taken from a typed array's memory or a numeric address. */\nconst bufferT: BufferDescriptor = { kind: \"buffer\" };\nconst fundamentalLifecycles: Map<string, FundamentalLifecycle> = new Map();\n\n/**\n * Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer\n * used when the string is passed by reference.\n */\nconst stringT = (ownership: Ownership = \"borrowed\", length?: number): StringDescriptor =>\n length === undefined ? { kind: \"string\", ownership } : { kind: \"string\", ownership, length };\n\n/** Builds a descriptor for a `GObject`, wrapped in the class registered for its runtime GType. */\nconst objectT = (ownership: Ownership = \"borrowed\"): ObjectDescriptor => ({ kind: \"object\", ownership });\n\n/** Wraps a descriptor in a pointer to it, for an output or inout argument. */\nconst refT = (innerDescriptor: Descriptor, isInout = false): RefDescriptor =>\n isInout ? { kind: \"ref\", innerDescriptor, inout: true } : { kind: \"ref\", innerDescriptor };\n\n/** Builds a descriptor for a `GHashTable`, marshalled as an array of key/value pairs. */\nconst hashTableT = (\n keyDescriptor: Descriptor,\n valueDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n): HashTableDescriptor => ({\n kind: \"hashtable\",\n keyDescriptor,\n valueDescriptor,\n ownership,\n});\n\n/** Builds a descriptor for an enumeration, resolving its GType from the named `get_type` function. */\nconst enumT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): EnumDescriptor => ({\n kind: \"enum\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n isSigned,\n});\n\n/** Builds a descriptor for a flags type, resolving its GType from the named `get_type` function. */\nconst flagsT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): FlagsDescriptor => ({\n kind: \"flags\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n isSigned,\n});\n\nconst applyBoxedNames = (result: BoxedDescriptor, options: BoxedOptions): void => {\n if (options.sharedLibrary !== undefined) {\n result.sharedLibrary = options.sharedLibrary;\n }\n\n if (options.getTypeFnName !== undefined) {\n result.getTypeFnName = options.getTypeFnName;\n }\n\n if (options.freeFnName !== undefined) {\n result.freeFnName = options.freeFnName;\n }\n};\n\nconst applyBoxedOptions = (result: BoxedDescriptor, options: BoxedOptions): void => {\n applyBoxedNames(result, options);\n\n if (options.isCallerAllocated) {\n result.isCallerAllocated = true;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n};\n\n/** Builds a descriptor for a `GBoxed` value of the named type. */\nconst boxedT = (typeName: string, options: BoxedOptions = {}): BoxedDescriptor => {\n const result: BoxedDescriptor = {\n kind: \"boxed\",\n ownership: options.ownership ?? \"borrowed\",\n typeName,\n };\n\n applyBoxedOptions(result, options);\n\n return result;\n};\n\n/** Builds a descriptor for a plain C struct. */\nconst structT = (ownership: Ownership = \"borrowed\", options: StructOptions = {}): StructDescriptor => {\n const result: StructDescriptor = { kind: \"struct\", ownership };\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.isCallerAllocated) {\n result.isCallerAllocated = true;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n return result;\n};\n\nconst recordFundamentalLifecycle = (typeName: string, lifecycle: FundamentalLifecycle): void => {\n if (!fundamentalLifecycles.has(typeName)) {\n fundamentalLifecycles.set(typeName, lifecycle);\n }\n};\n\nconst fundamentalLifecycleFor = (typeName: string): FundamentalLifecycle | undefined =>\n fundamentalLifecycles.get(typeName);\n\n/** Builds a descriptor for a fundamental type whose lifetime is managed by named ref and unref functions. */\nconst fundamentalT = (\n sharedLibrary: string,\n refFnName: string,\n unrefFnName: string,\n options: FundamentalOptions = {},\n): FundamentalDescriptor => {\n const ownership = options.ownership ?? \"borrowed\";\n const result: FundamentalDescriptor = { kind: \"fundamental\", ownership, sharedLibrary, refFnName, unrefFnName };\n\n if (options.typeName !== undefined) {\n result.typeName = options.typeName;\n recordFundamentalLifecycle(options.typeName, { sharedLibrary, refFnName, unrefFnName });\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n return result;\n};\n\n/** Builds a descriptor for an array of items in one of the supported container layouts. */\nconst arrayT = (\n itemDescriptor: Descriptor,\n arrayKind: ArrayKind = \"array\",\n ownership: Ownership = \"borrowed\",\n options?: ArrayOptions,\n): ArrayDescriptor => {\n const result: ArrayDescriptor = { kind: \"array\", itemDescriptor, arrayKind, ownership };\n\n if (options?.elementSize !== undefined) {\n result.elementSize = options.elementSize;\n }\n\n if (options?.baseParamIndex !== undefined) {\n result.baseParamIndex = options.baseParamIndex;\n }\n\n if (options?.sizeParamIndex !== undefined) {\n result.sizeParamIndex = options.sizeParamIndex;\n }\n\n if (options?.fixedSize !== undefined) {\n result.fixedSize = options.fixedSize;\n }\n\n if (options?.isBytes === true) {\n result.isBytes = true;\n }\n\n return result;\n};\n\n/** Builds a descriptor for a `GList` of items. */\nconst listT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n options: ArrayOptions = {},\n): ArrayDescriptor => arrayT(itemDescriptor, \"glist\", ownership, options);\n\n/** Builds a descriptor for a `GSList` of items. */\nconst slistT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n options: ArrayOptions = {},\n): ArrayDescriptor => arrayT(itemDescriptor, \"gslist\", ownership, options);\n\n/** Builds a descriptor for a `GPtrArray` of items. */\nconst ptrArrayT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n options: ArrayOptions = {},\n): ArrayDescriptor => arrayT(itemDescriptor, \"gptrarray\", ownership, options);\n\n/** Builds a descriptor for a `GArray` of items. */\nconst gArrayT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n options: ArrayOptions = {},\n): ArrayDescriptor => arrayT(itemDescriptor, \"garray\", ownership, options);\n\n/** Builds a descriptor for a `GByteArray`. */\nconst byteArrayT = (ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(uint8T, \"gbytearray\", ownership, { isBytes: true });\n\n/** Builds a descriptor for a C array whose length is carried by another argument. */\nconst sizedArrayT = (\n itemDescriptor: Descriptor,\n sizeParamIndex: number,\n ownership: Ownership = \"borrowed\",\n options: ArrayOptions = {},\n): ArrayDescriptor => arrayT(itemDescriptor, \"sized\", ownership, { ...options, sizeParamIndex });\n\n/**\n * Builds a descriptor for an out pointer into the buffer another argument supplied, decoded as the\n * elements from where it points to the end of that buffer.\n */\nconst cursorArrayT = (\n itemDescriptor: Descriptor,\n bounds: CursorBounds,\n ownership: Ownership = \"borrowed\",\n options: ArrayOptions = {},\n): ArrayDescriptor => arrayT(itemDescriptor, \"cursor\", ownership, { ...options, ...bounds });\n\n/** Builds a descriptor for a C array of a fixed length. */\nconst fixedArrayT = (\n itemDescriptor: Descriptor,\n fixedSize: number,\n ownership: Ownership = \"borrowed\",\n options: ArrayOptions = {},\n): ArrayDescriptor => arrayT(itemDescriptor, \"fixed\", ownership, { ...options, fixedSize });\n\nconst applyClosureOptions = (result: CallbackDescriptor, options: CallbackOptions): void => {\n if (options.hasDestroy !== undefined) {\n result.hasDestroy = options.hasDestroy;\n }\n\n if (options.destroyKind !== undefined) {\n result.destroyKind = options.destroyKind;\n }\n\n if (options.hasUserData !== undefined) {\n result.hasUserData = options.hasUserData;\n }\n\n if (options.userDataIndex !== undefined) {\n result.userDataIndex = options.userDataIndex;\n }\n\n if (options.scope !== undefined) {\n result.scope = options.scope;\n }\n};\n\n/** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */\nconst callbackT = (\n argDescriptors: Descriptor[],\n returnDescriptor: Descriptor,\n options?: CallbackOptions,\n): CallbackDescriptor => {\n const result: CallbackDescriptor = { kind: \"callback\", argDescriptors, returnDescriptor };\n\n if (options === undefined) {\n return result;\n }\n\n applyClosureOptions(result, options);\n\n return result;\n};\n\nexport {\n int8T,\n uint8T,\n int16T,\n uint16T,\n int32T,\n uint32T,\n int64T,\n uint64T,\n bigint64T,\n biguint64T,\n gtypeT,\n float32T,\n float64T,\n booleanT,\n voidT,\n unicharT,\n bufferT,\n stringT,\n objectT,\n refT,\n hashTableT,\n enumT,\n flagsT,\n boxedT,\n structT,\n fundamentalLifecycleFor,\n fundamentalT,\n arrayT,\n listT,\n slistT,\n ptrArrayT,\n gArrayT,\n byteArrayT,\n sizedArrayT,\n fixedArrayT,\n cursorArrayT,\n callbackT,\n type BoxedDescriptor,\n type StructDescriptor,\n type FundamentalDescriptor,\n type ArrayDescriptor,\n type HashTableDescriptor,\n type CallbackDescriptor,\n type RefDescriptor,\n};\n"]}
|
package/dist/exit-hook.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
import { quit } from "./lifecycle.js";
|
|
2
|
+
const TERMINATION_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM"];
|
|
3
|
+
const isSoleHandler = (signal) => process.listenerCount(signal) === 1;
|
|
4
|
+
const quitOnSignal = (signal) => {
|
|
5
|
+
if (!isSoleHandler(signal)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
quit();
|
|
9
|
+
process.removeAllListeners(signal);
|
|
10
|
+
process.kill(process.pid, signal);
|
|
11
|
+
};
|
|
2
12
|
process.on("exit", quit);
|
|
13
|
+
for (const signal of TERMINATION_SIGNALS) {
|
|
14
|
+
process.on(signal, quitOnSignal);
|
|
15
|
+
}
|
|
3
16
|
//# sourceMappingURL=exit-hook.js.map
|
package/dist/exit-hook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-hook.js","sourceRoot":"","sources":["../src/exit-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC","sourcesContent":["import { quit } from \"./lifecycle.js\";\n\nprocess.on(\"exit\", quit);\n"]}
|
|
1
|
+
{"version":3,"file":"exit-hook.js","sourceRoot":"","sources":["../src/exit-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,MAAM,mBAAmB,GAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAE9E,MAAM,aAAa,GAAG,CAAC,MAAsB,EAAW,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAE/F,MAAM,YAAY,GAAG,CAAC,MAAsB,EAAQ,EAAE;IAClD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO;IACX,CAAC;IAED,IAAI,EAAE,CAAC;IACP,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAEzB,KAAK,MAAM,MAAM,IAAI,mBAAmB,EAAE,CAAC;IACvC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import { quit } from \"./lifecycle.js\";\n\nconst TERMINATION_SIGNALS: NodeJS.Signals[] = [\"SIGHUP\", \"SIGINT\", \"SIGTERM\"];\n\nconst isSoleHandler = (signal: NodeJS.Signals): boolean => process.listenerCount(signal) === 1;\n\nconst quitOnSignal = (signal: NodeJS.Signals): void => {\n if (!isSoleHandler(signal)) {\n return;\n }\n\n quit();\n process.removeAllListeners(signal);\n process.kill(process.pid, signal);\n};\n\nprocess.on(\"exit\", quit);\n\nfor (const signal of TERMINATION_SIGNALS) {\n process.on(signal, quitOnSignal);\n}\n"]}
|
package/dist/fn.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ type FnSpec = {
|
|
|
7
7
|
args: Arg[];
|
|
8
8
|
/** Descriptor for the C return value, packed first when output arguments are also returned. */
|
|
9
9
|
returns: Descriptor;
|
|
10
|
+
/**
|
|
11
|
+
* The callee returns a value the bindings do not surface, so the call is made against the
|
|
12
|
+
* declared return type and the value is dropped instead of being packed into the result.
|
|
13
|
+
*/
|
|
14
|
+
isReturnSkipped?: boolean;
|
|
10
15
|
/** The function takes a trailing `GError**`, whose contents are thrown as an error on return. */
|
|
11
16
|
canThrow?: boolean;
|
|
12
17
|
/**
|
package/dist/fn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAO,MAAM,cAAc,CAAC;AAEpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,KAAK,GAAG,EAAiE,MAAM,UAAU,CAAC;AASnG,wDAAwD;AACxD,KAAK,MAAM,GAAG;IACV,uFAAuF;IACvF,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,+FAA+F;IAC/F,OAAO,EAAE,UAAU,CAAC;IACpB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AKlG;AAED,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/fn.js
CHANGED
|
@@ -6,7 +6,7 @@ import { checkError } from "./error.js";
|
|
|
6
6
|
import { LIB } from "./library.js";
|
|
7
7
|
import { fromNative } from "./native-value.js";
|
|
8
8
|
import { getHandle } from "./registry.js";
|
|
9
|
-
import { packTupleResult } from "./tuple.js";
|
|
9
|
+
import { hasSurfacedPrimary, packTupleResult } from "./tuple.js";
|
|
10
10
|
const NO_OUT_PARAMS = [];
|
|
11
11
|
const buildNativeArgTypes = (args, canThrow) => {
|
|
12
12
|
const nativeArgTypes = args.map((argSpec) => argSpec.direction !== undefined && argSpec.isCallerAllocated !== true ? refT(argSpec.type) : argSpec.type);
|
|
@@ -74,27 +74,25 @@ const resizeInputs = (inputs, argCount) => {
|
|
|
74
74
|
}
|
|
75
75
|
return inputs;
|
|
76
76
|
};
|
|
77
|
-
const directCallable = (descriptor, returnDescriptor, argCount) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
};
|
|
77
|
+
const directCallable = (descriptor, returnDescriptor, hasPrimary, argCount) => {
|
|
78
|
+
const marshal = (inputs) => fromNative(returnDescriptor, call(descriptor, resizeInputs(inputs, argCount)));
|
|
79
|
+
if (hasPrimary) {
|
|
80
|
+
return (...inputs) => marshal(inputs);
|
|
82
81
|
}
|
|
83
|
-
return (...inputs) =>
|
|
82
|
+
return (...inputs) => {
|
|
83
|
+
marshal(inputs);
|
|
84
|
+
};
|
|
84
85
|
};
|
|
85
86
|
function fromNativeCallable(descriptor, spec, getRefSeeds) {
|
|
86
87
|
const { args, returns: returnDescriptor, canThrow = false } = spec;
|
|
87
|
-
const hasPrimary = returnDescriptor.
|
|
88
|
+
const hasPrimary = hasSurfacedPrimary(returnDescriptor, spec.isReturnSkipped);
|
|
88
89
|
const plans = buildArgSpecs(args);
|
|
89
90
|
const outPlans = plans.filter((plan) => plan.isOutParam);
|
|
90
91
|
const arePassThrough = plans.every((plan, index) => isPassThroughPlan(plan, index));
|
|
91
92
|
if (!canThrow && arePassThrough) {
|
|
92
|
-
return directCallable(descriptor, returnDescriptor, plans.length);
|
|
93
|
+
return directCallable(descriptor, returnDescriptor, hasPrimary, plans.length);
|
|
93
94
|
}
|
|
94
|
-
const shape = (inputs, nativeValues, nativeResult) =>
|
|
95
|
-
const primary = hasPrimary ? fromNative(returnDescriptor, nativeResult) : undefined;
|
|
96
|
-
return packTupleResult(readOutParams(outPlans, inputs, nativeValues), primary, hasPrimary);
|
|
97
|
-
};
|
|
95
|
+
const shape = (inputs, nativeValues, nativeResult) => packTupleResult(readOutParams(outPlans, inputs, nativeValues), fromNative(returnDescriptor, nativeResult), hasPrimary);
|
|
98
96
|
if (canThrow) {
|
|
99
97
|
return (...inputs) => {
|
|
100
98
|
const nativeValues = buildNativeValues(plans, inputs, getRefSeeds?.());
|
package/dist/fn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.js","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAY,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA4B7C,MAAM,aAAa,GAAc,EAAE,C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BAAkB,EAAE,CAAC","sourcesContent":["import type { CallDescriptor, Descriptor, ExternalObject, Ref } from \"@gtkx/native\";\nimport { call, bind as nativeBind } from \"@gtkx/native\";\nimport type { RefSeeds } from \"./vfunc-seeds.js\";\nimport { type Arg, isCallerAllocatedArg, isOutputArg, isRefArg, requiresInputArg } from \"./arg.js\";\nimport { wrapCallbackValue } from \"./callback.js\";\nimport { boxedT, refT } from \"./descriptors.js\";\nimport { checkError } from \"./error.js\";\nimport { LIB } from \"./library.js\";\nimport { fromNative } from \"./native-value.js\";\nimport { getHandle } from \"./registry.js\";\nimport { packTupleResult } from \"./tuple.js\";\n\n/** The signature a native function is bound against. */\ntype FnSpec = {\n /** The C arguments in declaration order, including the ones the callee writes into. */\n args: Arg[];\n /** Descriptor for the C return value, packed first when output arguments are also returned. */\n returns: Descriptor;\n /** The function takes a trailing `GError**`, whose contents are thrown as an error on return. */\n canThrow?: boolean;\n /**\n * How many of `args` precede the callee's ellipsis, marking it variadic. Omitting it binds a\n * fixed-arity call, which passes the wrong argument classes to a variadic callee on some\n * architectures.\n */\n fixedArgCount?: number;\n};\n\ntype ArgSpec = {\n arg: Arg;\n index: number;\n isRef: boolean;\n isCallerAllocated: boolean;\n requiresInput: boolean;\n inputIndex: number;\n isOutParam: boolean;\n};\n\nconst NO_OUT_PARAMS: unknown[] = [];\n\nconst buildNativeArgTypes = (args: Arg[], canThrow: boolean): Descriptor[] => {\n const nativeArgTypes = args.map((argSpec) =>\n argSpec.direction !== undefined && argSpec.isCallerAllocated !== true ? refT(argSpec.type) : argSpec.type,\n );\n\n if (canThrow) {\n nativeArgTypes.push(\n refT(boxedT(\"GError\", { ownership: \"full\", sharedLibrary: LIB, getTypeFnName: \"g_error_get_type\" })),\n );\n }\n\n return nativeArgTypes;\n};\n\nconst buildArgSpecs = (args: Arg[]): ArgSpec[] => {\n let inputCursor = 0;\n\n return args.map((arg, index) => {\n const isRef = isRefArg(arg);\n const requiresInput = requiresInputArg(arg);\n const isOutParam = isOutputArg(arg) && arg.isConsumed !== true;\n\n return {\n arg,\n index,\n isRef,\n isCallerAllocated: isCallerAllocatedArg(arg),\n requiresInput,\n inputIndex: requiresInput ? inputCursor++ : -1,\n isOutParam,\n };\n });\n};\n\nconst resolveCallerAllocated = (inputs: unknown[], inputIndex: number): unknown => {\n const wrapper = inputs[inputIndex];\n\n return wrapper == null ? wrapper : getHandle(wrapper);\n};\n\nconst buildRefValue = (spec: ArgSpec, inputs: unknown[], seeds: RefSeeds | undefined): Ref => ({\n value: spec.requiresInput ? inputs[spec.inputIndex] : (seeds?.get(spec.index) ?? null),\n});\n\nconst buildNativeValue = (spec: ArgSpec, inputs: unknown[], seeds: RefSeeds | undefined): unknown => {\n const { arg, isRef, isCallerAllocated, inputIndex } = spec;\n\n if (isCallerAllocated) {\n return resolveCallerAllocated(inputs, inputIndex);\n }\n\n if (isRef) {\n return buildRefValue(spec, inputs, seeds);\n }\n\n if (arg.type.kind === \"callback\") {\n return wrapCallbackValue(arg.type, inputs[inputIndex]);\n }\n\n return inputs[inputIndex];\n};\n\nconst buildNativeValues = (plans: ArgSpec[], inputs: unknown[], seeds: RefSeeds | undefined): unknown[] =>\n plans.map((plan) => buildNativeValue(plan, inputs, seeds));\n\nconst readOutParams = (outPlans: ArgSpec[], inputs: unknown[], nativeValues: unknown[]): unknown[] => {\n if (outPlans.length === 0) {\n return NO_OUT_PARAMS;\n }\n\n return Array.from(outPlans, (plan) =>\n plan.isCallerAllocated\n ? inputs[plan.inputIndex]\n : fromNative(plan.arg.type, (nativeValues[plan.index] as Ref).value));\n};\n\nconst isPassThroughPlan = (plan: ArgSpec, index: number): boolean =>\n plan.inputIndex === index &&\n !plan.isRef &&\n !plan.isCallerAllocated &&\n plan.arg.type.kind !== \"callback\";\n\nconst resizeInputs = (inputs: unknown[], argCount: number): unknown[] => {\n while (inputs.length < argCount) {\n inputs.push(undefined);\n }\n\n if (inputs.length > argCount) {\n inputs.length = argCount;\n }\n\n return inputs;\n};\n\nconst directCallable = (\n descriptor: ExternalObject<CallDescriptor>,\n returnDescriptor: Descriptor,\n argCount: number,\n): ((...inputs: unknown[]) => unknown) => {\n if (returnDescriptor.kind === \"void\") {\n return (...inputs) => {\n call(descriptor, resizeInputs(inputs, argCount));\n };\n }\n\n return (...inputs) => fromNative(returnDescriptor, call(descriptor, resizeInputs(inputs, argCount)));\n};\n\nfunction fromNativeCallable(\n descriptor: ExternalObject<CallDescriptor>,\n spec: FnSpec,\n getRefSeeds?: () => RefSeeds | undefined,\n): (...inputs: unknown[]) => unknown {\n const { args, returns: returnDescriptor, canThrow = false } = spec;\n const hasPrimary = returnDescriptor.kind !== \"void\";\n const plans = buildArgSpecs(args);\n const outPlans = plans.filter((plan) => plan.isOutParam);\n const arePassThrough = plans.every((plan, index) => isPassThroughPlan(plan, index));\n\n if (!canThrow && arePassThrough) {\n return directCallable(descriptor, returnDescriptor, plans.length);\n }\n\n const shape = (inputs: unknown[], nativeValues: unknown[], nativeResult: unknown): unknown => {\n const primary = hasPrimary ? fromNative(returnDescriptor, nativeResult) : undefined;\n\n return packTupleResult(readOutParams(outPlans, inputs, nativeValues), primary, hasPrimary);\n };\n\n if (canThrow) {\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs, getRefSeeds?.());\n const errorRef: Ref = { value: null };\n nativeValues.push(errorRef);\n const nativeResult = call(descriptor, nativeValues);\n checkError(errorRef);\n\n return shape(inputs, nativeValues, nativeResult);\n };\n }\n\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs, getRefSeeds?.());\n\n return shape(inputs, nativeValues, call(descriptor, nativeValues));\n };\n}\n\n/**\n * Binds a symbol in a shared library to a callable that marshals its inputs and packs output\n * arguments into the result. When the spec sets `canThrow`, the reported `GError` is thrown.\n *\n * @param sharedLibrary Shared library the symbol is looked up in.\n * @param symbol Name of the C symbol to bind.\n * @param spec Argument and return descriptors the call is marshalled through.\n */\nfunction fn(sharedLibrary: string, symbol: string, spec: FnSpec): (...inputs: unknown[]) => unknown {\n const nativeArgTypes = buildNativeArgTypes(spec.args, spec.canThrow ?? false);\n const descriptor = nativeBind(sharedLibrary, symbol, nativeArgTypes, spec.returns, spec.fixedArgCount);\n\n return fromNativeCallable(descriptor, spec);\n}\n\nexport { buildNativeArgTypes, fn, fromNativeCallable };\n"]}
|
|
1
|
+
{"version":3,"file":"fn.js","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAY,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAiCjE,MAAM,aAAa,GAAc,EAAE,CAAC;AAEpC,MAAM,mBAAmB,GAAG,CAAC,IAAW,EAAE,QAAiB,EAAgB,EAAE;IACzE,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACxC,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,iBAAiB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAC5G,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACX,cAAc,CAAC,IAAI,CACf,IAAI,CAAC,MAAM,CAAC,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CAAC;YAErB,OAAO,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;QACrD,CAAC,CAAC;IACN,CAAC;IAED,OAAO,CAAC,GAAG,MAAM,EAAE,EAAE;QACjB,MAAM,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;QAEvE,OAAO,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;IACvE,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,EAAE,CAAC,aAAqB,EAAE,MAAc,EAAE,IAAY;IAC3D,MAAM,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC;IAC9E,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAEvG,OAAO,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import type { CallDescriptor, Descriptor, ExternalObject, Ref } from \"@gtkx/native\";\nimport { call, bind as nativeBind } from \"@gtkx/native\";\nimport type { RefSeeds } from \"./vfunc-seeds.js\";\nimport { type Arg, isCallerAllocatedArg, isOutputArg, isRefArg, requiresInputArg } from \"./arg.js\";\nimport { wrapCallbackValue } from \"./callback.js\";\nimport { boxedT, refT } from \"./descriptors.js\";\nimport { checkError } from \"./error.js\";\nimport { LIB } from \"./library.js\";\nimport { fromNative } from \"./native-value.js\";\nimport { getHandle } from \"./registry.js\";\nimport { hasSurfacedPrimary, packTupleResult } from \"./tuple.js\";\n\n/** The signature a native function is bound against. */\ntype FnSpec = {\n /** The C arguments in declaration order, including the ones the callee writes into. */\n args: Arg[];\n /** Descriptor for the C return value, packed first when output arguments are also returned. */\n returns: Descriptor;\n /**\n * The callee returns a value the bindings do not surface, so the call is made against the\n * declared return type and the value is dropped instead of being packed into the result.\n */\n isReturnSkipped?: boolean;\n /** The function takes a trailing `GError**`, whose contents are thrown as an error on return. */\n canThrow?: boolean;\n /**\n * How many of `args` precede the callee's ellipsis, marking it variadic. Omitting it binds a\n * fixed-arity call, which passes the wrong argument classes to a variadic callee on some\n * architectures.\n */\n fixedArgCount?: number;\n};\n\ntype ArgSpec = {\n arg: Arg;\n index: number;\n isRef: boolean;\n isCallerAllocated: boolean;\n requiresInput: boolean;\n inputIndex: number;\n isOutParam: boolean;\n};\n\nconst NO_OUT_PARAMS: unknown[] = [];\n\nconst buildNativeArgTypes = (args: Arg[], canThrow: boolean): Descriptor[] => {\n const nativeArgTypes = args.map((argSpec) =>\n argSpec.direction !== undefined && argSpec.isCallerAllocated !== true ? refT(argSpec.type) : argSpec.type,\n );\n\n if (canThrow) {\n nativeArgTypes.push(\n refT(boxedT(\"GError\", { ownership: \"full\", sharedLibrary: LIB, getTypeFnName: \"g_error_get_type\" })),\n );\n }\n\n return nativeArgTypes;\n};\n\nconst buildArgSpecs = (args: Arg[]): ArgSpec[] => {\n let inputCursor = 0;\n\n return args.map((arg, index) => {\n const isRef = isRefArg(arg);\n const requiresInput = requiresInputArg(arg);\n const isOutParam = isOutputArg(arg) && arg.isConsumed !== true;\n\n return {\n arg,\n index,\n isRef,\n isCallerAllocated: isCallerAllocatedArg(arg),\n requiresInput,\n inputIndex: requiresInput ? inputCursor++ : -1,\n isOutParam,\n };\n });\n};\n\nconst resolveCallerAllocated = (inputs: unknown[], inputIndex: number): unknown => {\n const wrapper = inputs[inputIndex];\n\n return wrapper == null ? wrapper : getHandle(wrapper);\n};\n\nconst buildRefValue = (spec: ArgSpec, inputs: unknown[], seeds: RefSeeds | undefined): Ref => ({\n value: spec.requiresInput ? inputs[spec.inputIndex] : (seeds?.get(spec.index) ?? null),\n});\n\nconst buildNativeValue = (spec: ArgSpec, inputs: unknown[], seeds: RefSeeds | undefined): unknown => {\n const { arg, isRef, isCallerAllocated, inputIndex } = spec;\n\n if (isCallerAllocated) {\n return resolveCallerAllocated(inputs, inputIndex);\n }\n\n if (isRef) {\n return buildRefValue(spec, inputs, seeds);\n }\n\n if (arg.type.kind === \"callback\") {\n return wrapCallbackValue(arg.type, inputs[inputIndex]);\n }\n\n return inputs[inputIndex];\n};\n\nconst buildNativeValues = (plans: ArgSpec[], inputs: unknown[], seeds: RefSeeds | undefined): unknown[] =>\n plans.map((plan) => buildNativeValue(plan, inputs, seeds));\n\nconst readOutParams = (outPlans: ArgSpec[], inputs: unknown[], nativeValues: unknown[]): unknown[] => {\n if (outPlans.length === 0) {\n return NO_OUT_PARAMS;\n }\n\n return Array.from(outPlans, (plan) =>\n plan.isCallerAllocated\n ? inputs[plan.inputIndex]\n : fromNative(plan.arg.type, (nativeValues[plan.index] as Ref).value));\n};\n\nconst isPassThroughPlan = (plan: ArgSpec, index: number): boolean =>\n plan.inputIndex === index &&\n !plan.isRef &&\n !plan.isCallerAllocated &&\n plan.arg.type.kind !== \"callback\";\n\nconst resizeInputs = (inputs: unknown[], argCount: number): unknown[] => {\n while (inputs.length < argCount) {\n inputs.push(undefined);\n }\n\n if (inputs.length > argCount) {\n inputs.length = argCount;\n }\n\n return inputs;\n};\n\nconst directCallable = (\n descriptor: ExternalObject<CallDescriptor>,\n returnDescriptor: Descriptor,\n hasPrimary: boolean,\n argCount: number,\n): ((...inputs: unknown[]) => unknown) => {\n const marshal = (inputs: unknown[]): unknown =>\n fromNative(returnDescriptor, call(descriptor, resizeInputs(inputs, argCount)));\n\n if (hasPrimary) {\n return (...inputs) => marshal(inputs);\n }\n\n return (...inputs) => {\n marshal(inputs);\n };\n};\n\nfunction fromNativeCallable(\n descriptor: ExternalObject<CallDescriptor>,\n spec: FnSpec,\n getRefSeeds?: () => RefSeeds | undefined,\n): (...inputs: unknown[]) => unknown {\n const { args, returns: returnDescriptor, canThrow = false } = spec;\n const hasPrimary = hasSurfacedPrimary(returnDescriptor, spec.isReturnSkipped);\n const plans = buildArgSpecs(args);\n const outPlans = plans.filter((plan) => plan.isOutParam);\n const arePassThrough = plans.every((plan, index) => isPassThroughPlan(plan, index));\n\n if (!canThrow && arePassThrough) {\n return directCallable(descriptor, returnDescriptor, hasPrimary, plans.length);\n }\n\n const shape = (inputs: unknown[], nativeValues: unknown[], nativeResult: unknown): unknown =>\n packTupleResult(\n readOutParams(outPlans, inputs, nativeValues),\n fromNative(returnDescriptor, nativeResult),\n hasPrimary,\n );\n\n if (canThrow) {\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs, getRefSeeds?.());\n const errorRef: Ref = { value: null };\n nativeValues.push(errorRef);\n const nativeResult = call(descriptor, nativeValues);\n checkError(errorRef);\n\n return shape(inputs, nativeValues, nativeResult);\n };\n }\n\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs, getRefSeeds?.());\n\n return shape(inputs, nativeValues, call(descriptor, nativeValues));\n };\n}\n\n/**\n * Binds a symbol in a shared library to a callable that marshals its inputs and packs output\n * arguments into the result. When the spec sets `canThrow`, the reported `GError` is thrown.\n *\n * @param sharedLibrary Shared library the symbol is looked up in.\n * @param symbol Name of the C symbol to bind.\n * @param spec Argument and return descriptors the call is marshalled through.\n */\nfunction fn(sharedLibrary: string, symbol: string, spec: FnSpec): (...inputs: unknown[]) => unknown {\n const nativeArgTypes = buildNativeArgTypes(spec.args, spec.canThrow ?? false);\n const descriptor = nativeBind(sharedLibrary, symbol, nativeArgTypes, spec.returns, spec.fixedArgCount);\n\n return fromNativeCallable(descriptor, spec);\n}\n\nexport { buildNativeArgTypes, fn, fromNativeCallable };\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Descriptor } from "@gtkx/native";
|
|
2
|
+
type LengthSource = {
|
|
3
|
+
kind: "return";
|
|
4
|
+
} | {
|
|
5
|
+
kind: "outArg";
|
|
6
|
+
argIndex: number;
|
|
7
|
+
};
|
|
8
|
+
type LengthSources = Map<number, LengthSource[]>;
|
|
9
|
+
type FoldedLengthSpec = {
|
|
10
|
+
argDescriptors: Descriptor[];
|
|
11
|
+
returnDescriptor: Descriptor;
|
|
12
|
+
userDataIndex?: number | undefined;
|
|
13
|
+
};
|
|
14
|
+
declare const foldedLengthSources: (spec: FoldedLengthSpec) => LengthSources;
|
|
15
|
+
export { foldedLengthSources, type LengthSource, type LengthSources };
|
|
16
|
+
//# sourceMappingURL=folded-lengths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folded-lengths.d.ts","sourceRoot":"","sources":["../src/folded-lengths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,KAAK,YAAY,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9E,KAAK,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;AAEjD,KAAK,gBAAgB,GAAG;IACpB,cAAc,EAAE,UAAU,EAAE,CAAC;IAC7B,gBAAgB,EAAE,UAAU,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,CAAC;AA6CF,QAAA,MAAM,mBAAmB,GAAI,MAAM,gBAAgB,KAAG,aAOrD,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const sizedArrayLengthIndex = (descriptor) => descriptor.kind === "array" && descriptor.arrayKind === "sized" ? descriptor.sizeParamIndex : undefined;
|
|
2
|
+
const outArgLengthIndex = (descriptor) => descriptor?.kind === "ref" ? sizedArrayLengthIndex(descriptor.innerDescriptor) : undefined;
|
|
3
|
+
const effectiveArgIndex = (argIndex, userDataIndex) => {
|
|
4
|
+
if (argIndex === undefined || userDataIndex === undefined || argIndex < userDataIndex) {
|
|
5
|
+
return argIndex;
|
|
6
|
+
}
|
|
7
|
+
return argIndex === userDataIndex ? undefined : argIndex - 1;
|
|
8
|
+
};
|
|
9
|
+
const addLengthSource = (sources, index, source) => {
|
|
10
|
+
if (index === undefined) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const existing = sources.get(index);
|
|
14
|
+
if (existing === undefined) {
|
|
15
|
+
sources.set(index, [source]);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
existing.push(source);
|
|
19
|
+
};
|
|
20
|
+
const addOutArgLengthSources = (sources, spec) => {
|
|
21
|
+
const { userDataIndex } = spec;
|
|
22
|
+
for (const [declaredIndex, descriptor] of spec.argDescriptors.entries()) {
|
|
23
|
+
const argIndex = effectiveArgIndex(declaredIndex, userDataIndex);
|
|
24
|
+
if (argIndex !== undefined) {
|
|
25
|
+
const lengthIndex = effectiveArgIndex(outArgLengthIndex(descriptor), userDataIndex);
|
|
26
|
+
addLengthSource(sources, lengthIndex, { kind: "outArg", argIndex });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const foldedLengthSources = (spec) => {
|
|
31
|
+
const sources = new Map();
|
|
32
|
+
const returnLengthIndex = effectiveArgIndex(sizedArrayLengthIndex(spec.returnDescriptor), spec.userDataIndex);
|
|
33
|
+
addLengthSource(sources, returnLengthIndex, { kind: "return" });
|
|
34
|
+
addOutArgLengthSources(sources, spec);
|
|
35
|
+
return sources;
|
|
36
|
+
};
|
|
37
|
+
export { foldedLengthSources };
|
|
38
|
+
//# sourceMappingURL=folded-lengths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folded-lengths.js","sourceRoot":"","sources":["../src/folded-lengths.ts"],"names":[],"mappings":"AAWA,M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AAa,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC;QACtE,MAAM,QAAQ,GAAG,iBAAiB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QAEjE,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,WAAW,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,CAAC;YACpF,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxE,CAAC;IACL,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,IAAsB,EAAiB,EAAE;IAClE,MAAM,OAAO,GAAkB,IAAI,GAAG,EAAE,CAAC;IACzC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9G,eAAe,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChE,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAEtC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAyC,CAAC","sourcesContent":["import type { Descriptor } from \"@gtkx/native\";\n\ntype LengthSource = { kind: \"return\" } | { kind: \"outArg\"; argIndex: number };\ntype LengthSources = Map<number, LengthSource[]>;\n\ntype FoldedLengthSpec = {\n argDescriptors: Descriptor[];\n returnDescriptor: Descriptor;\n userDataIndex?: number | undefined;\n};\n\nconst sizedArrayLengthIndex = (descriptor: Descriptor): number | undefined =>\n descriptor.kind === \"array\" && descriptor.arrayKind === \"sized\" ? descriptor.sizeParamIndex : undefined;\n\nconst outArgLengthIndex = (descriptor: Descriptor | undefined): number | undefined =>\n descriptor?.kind === \"ref\" ? sizedArrayLengthIndex(descriptor.innerDescriptor) : undefined;\n\nconst effectiveArgIndex = (argIndex: number | undefined, userDataIndex: number | undefined): number | undefined => {\n if (argIndex === undefined || userDataIndex === undefined || argIndex < userDataIndex) {\n return argIndex;\n }\n\n return argIndex === userDataIndex ? undefined : argIndex - 1;\n};\n\nconst addLengthSource = (sources: LengthSources, index: number | undefined, source: LengthSource): void => {\n if (index === undefined) {\n return;\n }\n\n const existing = sources.get(index);\n\n if (existing === undefined) {\n sources.set(index, [source]);\n\n return;\n }\n\n existing.push(source);\n};\n\nconst addOutArgLengthSources = (sources: LengthSources, spec: FoldedLengthSpec): void => {\n const { userDataIndex } = spec;\n\n for (const [declaredIndex, descriptor] of spec.argDescriptors.entries()) {\n const argIndex = effectiveArgIndex(declaredIndex, userDataIndex);\n\n if (argIndex !== undefined) {\n const lengthIndex = effectiveArgIndex(outArgLengthIndex(descriptor), userDataIndex);\n addLengthSource(sources, lengthIndex, { kind: \"outArg\", argIndex });\n }\n }\n};\n\nconst foldedLengthSources = (spec: FoldedLengthSpec): LengthSources => {\n const sources: LengthSources = new Map();\n const returnLengthIndex = effectiveArgIndex(sizedArrayLengthIndex(spec.returnDescriptor), spec.userDataIndex);\n addLengthSource(sources, returnLengthIndex, { kind: \"return\" });\n addOutArgLengthSources(sources, spec);\n\n return sources;\n};\n\nexport { foldedLengthSources, type LengthSource, type LengthSources };\n"]}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { checkError, createErrorDomain } from "./error.js";
|
|
2
|
+
export { type ApplicationInstance, getApplicationInstance } from "./lifecycle.js";
|
|
2
3
|
export { registerClassType, resolveWrapperClass, wrapHandle } from "./registry.js";
|
|
3
4
|
export { hasSignalListener } from "./signal.js";
|
|
4
5
|
export { resolveType } from "./type.js";
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACH,SAAS,EACT,aAAa,EACb,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,OAAO,GACV,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,KAAK,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACH,SAAS,EACT,aAAa,EACb,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,OAAO,GACV,MAAM,YAAY,CAAC"}
|
package/dist/internal.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { checkError, createErrorDomain } from "./error.js";
|
|
2
|
+
export { getApplicationInstance } from "./lifecycle.js";
|
|
2
3
|
export { registerClassType, resolveWrapperClass, wrapHandle } from "./registry.js";
|
|
3
4
|
export { hasSignalListener } from "./signal.js";
|
|
4
5
|
export { resolveType } from "./type.js";
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACH,SAAS,EACT,aAAa,EACb,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,OAAO,GACV,MAAM,YAAY,CAAC","sourcesContent":["export { checkError, createErrorDomain } from \"./error.js\";\nexport { registerClassType, resolveWrapperClass, wrapHandle } from \"./registry.js\";\nexport { hasSignalListener } from \"./signal.js\";\nexport { resolveType } from \"./type.js\";\nexport {\n fromValue,\n getBoxedValue,\n getValueType,\n inoutValueForBoxedDescriptor,\n newValueForDescriptor,\n outValueForBoxedDescriptor,\n toValue,\n} from \"./value.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAA4B,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACH,SAAS,EACT,aAAa,EACb,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,OAAO,GACV,MAAM,YAAY,CAAC","sourcesContent":["export { checkError, createErrorDomain } from \"./error.js\";\nexport { type ApplicationInstance, getApplicationInstance } from \"./lifecycle.js\";\nexport { registerClassType, resolveWrapperClass, wrapHandle } from \"./registry.js\";\nexport { hasSignalListener } from \"./signal.js\";\nexport { resolveType } from \"./type.js\";\nexport {\n fromValue,\n getBoxedValue,\n getValueType,\n inoutValueForBoxedDescriptor,\n newValueForDescriptor,\n outValueForBoxedDescriptor,\n toValue,\n} from \"./value.js\";\n"]}
|
package/dist/library.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type BoxedDescriptor, type FundamentalDescriptor } from "./descriptors.js";
|
|
2
2
|
declare const LIB = "libgobject-2.0.so.0,libglib-2.0.so.0";
|
|
3
|
+
declare const GIO_LIB = "libgio-2.0.so.0";
|
|
3
4
|
declare const VALUE_SIZE = 24;
|
|
4
5
|
declare const CLOSURE_SIZE = 32;
|
|
5
6
|
declare const VALUE_T: BoxedDescriptor;
|
|
6
7
|
declare const PARAM_T: FundamentalDescriptor;
|
|
7
8
|
declare const VARIANT_T: FundamentalDescriptor;
|
|
8
|
-
export { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };
|
|
9
|
+
export { CLOSURE_SIZE, GIO_LIB, LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };
|
|
9
10
|
//# sourceMappingURL=library.d.ts.map
|
package/dist/library.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAU,KAAK,qBAAqB,EAAgB,MAAM,kBAAkB,CAAC;AAE1G,QAAA,MAAM,GAAG,yCAAyC,CAAC;AACnD,QAAA,MAAM,UAAU,KAAK,CAAC;AACtB,QAAA,MAAM,YAAY,KAAK,CAAC;AACxB,QAAA,MAAM,OAAO,EAAE,eAA6F,CAAC;AAE7G,QAAA,MAAM,OAAO,EAAE,qBAGb,CAAC;AAEH,QAAA,MAAM,SAAS,EAAE,qBAGf,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAU,KAAK,qBAAqB,EAAgB,MAAM,kBAAkB,CAAC;AAE1G,QAAA,MAAM,GAAG,yCAAyC,CAAC;AACnD,QAAA,MAAM,OAAO,oBAAoB,CAAC;AAClC,QAAA,MAAM,UAAU,KAAK,CAAC;AACtB,QAAA,MAAM,YAAY,KAAK,CAAC;AACxB,QAAA,MAAM,OAAO,EAAE,eAA6F,CAAC;AAE7G,QAAA,MAAM,OAAO,EAAE,qBAGb,CAAC;AAEH,QAAA,MAAM,SAAS,EAAE,qBAGf,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/library.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { boxedT, fundamentalT } from "./descriptors.js";
|
|
2
2
|
const LIB = "libgobject-2.0.so.0,libglib-2.0.so.0";
|
|
3
|
+
const GIO_LIB = "libgio-2.0.so.0";
|
|
3
4
|
const VALUE_SIZE = 24;
|
|
4
5
|
const CLOSURE_SIZE = 32;
|
|
5
6
|
const VALUE_T = boxedT("GValue", { sharedLibrary: LIB, getTypeFnName: "g_value_get_type" });
|
|
@@ -11,5 +12,5 @@ const VARIANT_T = fundamentalT(LIB, "g_variant_ref", "g_variant_unref", {
|
|
|
11
12
|
ownership: "borrowed",
|
|
12
13
|
typeName: "GVariant",
|
|
13
14
|
});
|
|
14
|
-
export { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };
|
|
15
|
+
export { CLOSURE_SIZE, GIO_LIB, LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };
|
|
15
16
|
//# sourceMappingURL=library.js.map
|
package/dist/library.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.js","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAA8B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE1G,MAAM,GAAG,GAAG,sCAAsC,CAAC;AACnD,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,OAAO,GAAoB,MAAM,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAE7G,MAAM,OAAO,GAA0B,YAAY,CAAC,GAAG,EAAE,kBAAkB,EAAE,oBAAoB,EAAE;IAC/F,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,QAAQ;CACrB,CAAC,CAAC;AAEH,MAAM,SAAS,GAA0B,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,iBAAiB,EAAE;IAC3F,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,UAAU;CACvB,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { type BoxedDescriptor, boxedT, type FundamentalDescriptor, fundamentalT } from \"./descriptors.js\";\n\nconst LIB = \"libgobject-2.0.so.0,libglib-2.0.so.0\";\nconst VALUE_SIZE = 24;\nconst CLOSURE_SIZE = 32;\nconst VALUE_T: BoxedDescriptor = boxedT(\"GValue\", { sharedLibrary: LIB, getTypeFnName: \"g_value_get_type\" });\n\nconst PARAM_T: FundamentalDescriptor = fundamentalT(LIB, \"g_param_spec_ref\", \"g_param_spec_unref\", {\n ownership: \"borrowed\",\n typeName: \"GParam\",\n});\n\nconst VARIANT_T: FundamentalDescriptor = fundamentalT(LIB, \"g_variant_ref\", \"g_variant_unref\", {\n ownership: \"borrowed\",\n typeName: \"GVariant\",\n});\n\nexport { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };\n"]}
|
|
1
|
+
{"version":3,"file":"library.js","sourceRoot":"","sources":["../src/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAA8B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE1G,MAAM,GAAG,GAAG,sCAAsC,CAAC;AACnD,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAClC,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,OAAO,GAAoB,MAAM,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAE7G,MAAM,OAAO,GAA0B,YAAY,CAAC,GAAG,EAAE,kBAAkB,EAAE,oBAAoB,EAAE;IAC/F,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,QAAQ;CACrB,CAAC,CAAC;AAEH,MAAM,SAAS,GAA0B,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,iBAAiB,EAAE;IAC3F,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,UAAU;CACvB,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { type BoxedDescriptor, boxedT, type FundamentalDescriptor, fundamentalT } from \"./descriptors.js\";\n\nconst LIB = \"libgobject-2.0.so.0,libglib-2.0.so.0\";\nconst GIO_LIB = \"libgio-2.0.so.0\";\nconst VALUE_SIZE = 24;\nconst CLOSURE_SIZE = 32;\nconst VALUE_T: BoxedDescriptor = boxedT(\"GValue\", { sharedLibrary: LIB, getTypeFnName: \"g_value_get_type\" });\n\nconst PARAM_T: FundamentalDescriptor = fundamentalT(LIB, \"g_param_spec_ref\", \"g_param_spec_unref\", {\n ownership: \"borrowed\",\n typeName: \"GParam\",\n});\n\nconst VARIANT_T: FundamentalDescriptor = fundamentalT(LIB, \"g_variant_ref\", \"g_variant_unref\", {\n ownership: \"borrowed\",\n typeName: \"GVariant\",\n});\n\nexport { CLOSURE_SIZE, GIO_LIB, LIB, VALUE_SIZE, VALUE_T, PARAM_T, VARIANT_T };\n"]}
|
package/dist/lifecycle.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ type ApplicationLike = {
|
|
|
26
26
|
/** Emits one of the application's own signals. */
|
|
27
27
|
emit(signal: "shutdown"): unknown;
|
|
28
28
|
};
|
|
29
|
+
type ApplicationInstance = "primary" | "remote" | "shutDown" | "unregistered";
|
|
29
30
|
/** What {@link runApplication} reports about the process it just started. */
|
|
30
31
|
type RunApplicationResult = {
|
|
31
32
|
/** Whether this process owns the application ID and may build a user interface. */
|
|
@@ -45,6 +46,7 @@ declare const quit: () => void;
|
|
|
45
46
|
* @param callback Invoked during shutdown.
|
|
46
47
|
*/
|
|
47
48
|
declare const onExit: (callback: () => void) => void;
|
|
49
|
+
declare const getApplicationInstance: (application: ApplicationLike) => ApplicationInstance;
|
|
48
50
|
/**
|
|
49
51
|
* Hands `argv` to GLib's own command line handling, which parses the application's options, prints
|
|
50
52
|
* `--help`, runs `handle-local-options`, registers the application, and either activates it or
|
|
@@ -63,6 +65,13 @@ declare const onExit: (callback: () => void) => void;
|
|
|
63
65
|
* user interface may be built here, because a remote application has no `GtkApplicationImpl` and
|
|
64
66
|
* attaching a window to it crashes.
|
|
65
67
|
*
|
|
68
|
+
* The application also claims the process-wide default `Gio.Application.getDefault()` returns, before
|
|
69
|
+
* its command line is parsed, so an `activate` handler and anything the host reads afterwards see the
|
|
70
|
+
* application being started rather than an earlier one. That holds whether the start ends registered,
|
|
71
|
+
* remote or unregistered: a refused command line still has to be reportable through the default, which
|
|
72
|
+
* is how `gtkx dev` learns which application its entry mounted. {@link quitApplication} gives the
|
|
73
|
+
* default back up, since GLib drops it only at finalize.
|
|
74
|
+
*
|
|
66
75
|
* @param application The application to start.
|
|
67
76
|
* @param argv The command line, whose first entry names the program as `--help` should print it.
|
|
68
77
|
* @returns Whether this process may build a user interface, and the status to exit with.
|
|
@@ -77,8 +86,14 @@ declare const runApplication: (application: ApplicationLike, argv: string[]) =>
|
|
|
77
86
|
* quitting, which GLib never undoes. An application that has already quit falls back to emitting
|
|
78
87
|
* `shutdown`, which releases the runtime and leaves the registration for GLib to drop at finalize.
|
|
79
88
|
*
|
|
89
|
+
* The process-wide default {@link runApplication} claimed is given up whichever of those paths the
|
|
90
|
+
* application took, including the ones that have no teardown left to do, so
|
|
91
|
+
* `Gio.Application.getDefault()` never hands back an application that has been torn down or that
|
|
92
|
+
* never registered in the first place. GLib clears that default only at finalize, which a
|
|
93
|
+
* garbage-collected wrapper reaches arbitrarily late or never.
|
|
94
|
+
*
|
|
80
95
|
* @param application The application to shut down.
|
|
81
96
|
*/
|
|
82
97
|
declare const quitApplication: (application: ApplicationLike) => void;
|
|
83
|
-
export { onExit, quit, runApplication, quitApplication, type
|
|
98
|
+
export { getApplicationInstance, onExit, quit, runApplication, quitApplication, type ApplicationInstance, type RunApplicationResult, };
|
|
84
99
|
//# sourceMappingURL=lifecycle.d.ts.map
|