@gtkx/runtime 1.2.2 → 1.3.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.
Files changed (91) hide show
  1. package/README.md +2 -1
  2. package/dist/arg.d.ts +6 -1
  3. package/dist/arg.d.ts.map +1 -1
  4. package/dist/arg.js +2 -1
  5. package/dist/arg.js.map +1 -1
  6. package/dist/closure.d.ts.map +1 -1
  7. package/dist/closure.js +2 -11
  8. package/dist/closure.js.map +1 -1
  9. package/dist/descriptors.d.ts +21 -3
  10. package/dist/descriptors.d.ts.map +1 -1
  11. package/dist/descriptors.js +50 -21
  12. package/dist/descriptors.js.map +1 -1
  13. package/dist/fn.d.ts +2 -0
  14. package/dist/fn.d.ts.map +1 -1
  15. package/dist/fn.js +50 -10
  16. package/dist/fn.js.map +1 -1
  17. package/dist/index.d.ts +11 -5
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +10 -4
  20. package/dist/index.js.map +1 -1
  21. package/dist/mixin.d.ts +2 -1
  22. package/dist/mixin.d.ts.map +1 -1
  23. package/dist/mixin.js +1 -1
  24. package/dist/mixin.js.map +1 -1
  25. package/dist/native-value.d.ts +9 -3
  26. package/dist/native-value.d.ts.map +1 -1
  27. package/dist/native-value.js +86 -9
  28. package/dist/native-value.js.map +1 -1
  29. package/dist/object.d.ts +14 -6
  30. package/dist/object.d.ts.map +1 -1
  31. package/dist/object.js +21 -10
  32. package/dist/object.js.map +1 -1
  33. package/dist/param-spec.d.ts +31 -1
  34. package/dist/param-spec.d.ts.map +1 -1
  35. package/dist/param-spec.js +66 -5
  36. package/dist/param-spec.js.map +1 -1
  37. package/dist/promisify.d.ts +13 -1
  38. package/dist/promisify.d.ts.map +1 -1
  39. package/dist/promisify.js +14 -1
  40. package/dist/promisify.js.map +1 -1
  41. package/dist/properties.d.ts +28 -1
  42. package/dist/properties.d.ts.map +1 -1
  43. package/dist/properties.js +139 -8
  44. package/dist/properties.js.map +1 -1
  45. package/dist/regex.d.ts +25 -0
  46. package/dist/regex.d.ts.map +1 -0
  47. package/dist/regex.js +59 -0
  48. package/dist/regex.js.map +1 -0
  49. package/dist/register-class.d.ts +154 -11
  50. package/dist/register-class.d.ts.map +1 -1
  51. package/dist/register-class.js +157 -19
  52. package/dist/register-class.js.map +1 -1
  53. package/dist/registry.d.ts +48 -4
  54. package/dist/registry.d.ts.map +1 -1
  55. package/dist/registry.js +147 -3
  56. package/dist/registry.js.map +1 -1
  57. package/dist/signal.d.ts +8 -1
  58. package/dist/signal.d.ts.map +1 -1
  59. package/dist/signal.js +41 -3
  60. package/dist/signal.js.map +1 -1
  61. package/dist/type.d.ts +2 -1
  62. package/dist/type.d.ts.map +1 -1
  63. package/dist/type.js +5 -1
  64. package/dist/type.js.map +1 -1
  65. package/dist/value.d.ts +48 -4
  66. package/dist/value.d.ts.map +1 -1
  67. package/dist/value.js +172 -16
  68. package/dist/value.js.map +1 -1
  69. package/dist/variant.d.ts +75 -26
  70. package/dist/variant.d.ts.map +1 -1
  71. package/dist/variant.js +44 -29
  72. package/dist/variant.js.map +1 -1
  73. package/package.json +4 -4
  74. package/src/arg.ts +6 -1
  75. package/src/closure.ts +2 -14
  76. package/src/descriptors.ts +74 -21
  77. package/src/fn.ts +73 -17
  78. package/src/index.ts +31 -4
  79. package/src/mixin.ts +1 -1
  80. package/src/native-value.ts +146 -14
  81. package/src/object.ts +23 -11
  82. package/src/param-spec.ts +94 -8
  83. package/src/promisify.ts +27 -1
  84. package/src/properties.ts +184 -5
  85. package/src/regex.ts +92 -0
  86. package/src/register-class.ts +446 -38
  87. package/src/registry.ts +219 -4
  88. package/src/signal.ts +77 -0
  89. package/src/type.ts +7 -0
  90. package/src/value.ts +268 -14
  91. package/src/variant.ts +184 -53
package/README.md CHANGED
@@ -98,7 +98,7 @@ GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing r
98
98
  - a React reconciler that exposes every GObject as a JSX element,
99
99
  - a CLI for scaffolding, development, and production builds,
100
100
  - a dev server with Fast Refresh that patches your running UI in place,
101
- - CSS-in-JS styling and high-level list, grid, and dialog components,
101
+ - CSS-in-JS styling, React Spring animations, and high-level list, grid, and dialog components,
102
102
  - a Testing Library-style API for querying and driving your widgets in tests,
103
103
  - and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
104
104
 
@@ -157,6 +157,7 @@ Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
157
157
  - [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the counter above.
158
158
  - [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): a React port of the official GTK4 widget showcase, covering lists, dialogs, gestures, CSS, and OpenGL.
159
159
  - [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): a WebKitWebView-based web browser.
160
+ - [`animations`](https://github.com/gtkx-org/gtkx/tree/main/examples/animations): a tour of `@gtkx/animated`, React Spring animations driven by the GTK frame clock.
160
161
  - [`tutorial`](https://github.com/gtkx-org/gtkx/tree/main/examples/tutorial): the Tasks app the documentation builds.
161
162
 
162
163
  ## Status
package/dist/arg.d.ts CHANGED
@@ -9,11 +9,16 @@ type Arg = {
9
9
  isCallerAllocated?: boolean;
10
10
  /** When true, the argument is consumed internally and left out of the packed result. */
11
11
  isConsumed?: boolean;
12
+ /** When true, the argument is a `GValue` the callee fills in, packed into the result as what it holds. */
13
+ isUnpacked?: boolean;
14
+ /** When true, the caller must provide the argument: `undefined` is rejected instead of reaching C as `NULL`. */
15
+ isRequired?: boolean;
12
16
  };
13
17
  declare const isOutputArg: (arg: Arg) => boolean;
14
18
  declare const isInoutArg: (arg: Arg) => boolean;
15
19
  declare const isCallerAllocatedArg: (arg: Arg) => boolean;
20
+ declare const isUnpackedArg: (arg: Arg) => boolean;
16
21
  declare const isRefArg: (arg: Arg) => boolean;
17
22
  declare const requiresInputArg: (arg: Arg) => boolean;
18
- export { isOutputArg, isInoutArg, isCallerAllocatedArg, isRefArg, requiresInputArg, type Arg };
23
+ export { isOutputArg, isInoutArg, isCallerAllocatedArg, isRefArg, isUnpackedArg, requiresInputArg, type Arg };
19
24
  //# sourceMappingURL=arg.d.ts.map
package/dist/arg.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"arg.d.ts","sourceRoot":"","sources":["../src/arg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,iGAAiG;AACjG,KAAK,GAAG,GAAG;IACP,kGAAkG;IAClG,IAAI,EAAE,UAAU,CAAC;IACjB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;IAC5B,wGAAwG;IACxG,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,wFAAwF;IACxF,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,QAAA,MAAM,WAAW,GAAI,KAAK,GAAG,KAAG,OAAsC,CAAC;AACvE,QAAA,MAAM,UAAU,GAAI,KAAK,GAAG,KAAG,OAAoC,CAAC;AACpE,QAAA,MAAM,oBAAoB,GAAI,KAAK,GAAG,KAAG,OAAyC,CAAC;AACnF,QAAA,MAAM,QAAQ,GAAI,KAAK,GAAG,KAAG,OAAwE,CAAC;AACtG,QAAA,MAAM,gBAAgB,GAAI,KAAK,GAAG,KAAG,OAA4C,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,KAAK,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"arg.d.ts","sourceRoot":"","sources":["../src/arg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,iGAAiG;AACjG,KAAK,GAAG,GAAG;IACP,kGAAkG;IAClG,IAAI,EAAE,UAAU,CAAC;IACjB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;IAC5B,wGAAwG;IACxG,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,wFAAwF;IACxF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0GAA0G;IAC1G,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gHAAgH;IAChH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,QAAA,MAAM,WAAW,GAAI,KAAK,GAAG,KAAG,OAAsC,CAAC;AACvE,QAAA,MAAM,UAAU,GAAI,KAAK,GAAG,KAAG,OAAoC,CAAC;AACpE,QAAA,MAAM,oBAAoB,GAAI,KAAK,GAAG,KAAG,OAAyC,CAAC;AACnF,QAAA,MAAM,aAAa,GAAI,KAAK,GAAG,KAAG,OAAkC,CAAC;AACrE,QAAA,MAAM,QAAQ,GAAI,KAAK,GAAG,KAAG,OAAwE,CAAC;AACtG,QAAA,MAAM,gBAAgB,GAAI,KAAK,GAAG,KAAG,OAA4C,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,GAAG,EAAE,CAAC"}
package/dist/arg.js CHANGED
@@ -1,7 +1,8 @@
1
1
  const isOutputArg = (arg) => arg.direction !== undefined;
2
2
  const isInoutArg = (arg) => arg.direction === "inout";
3
3
  const isCallerAllocatedArg = (arg) => arg.isCallerAllocated === true;
4
+ const isUnpackedArg = (arg) => arg.isUnpacked === true;
4
5
  const isRefArg = (arg) => arg.direction !== undefined && arg.isCallerAllocated !== true;
5
6
  const requiresInputArg = (arg) => !isRefArg(arg) || isInoutArg(arg);
6
- export { isOutputArg, isInoutArg, isCallerAllocatedArg, isRefArg, requiresInputArg };
7
+ export { isOutputArg, isInoutArg, isCallerAllocatedArg, isRefArg, isUnpackedArg, requiresInputArg };
7
8
  //# sourceMappingURL=arg.js.map
package/dist/arg.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"arg.js","sourceRoot":"","sources":["../src/arg.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC;AACvE,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,OAAO,CAAC;AACpE,MAAM,oBAAoB,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,GAAG,CAAC,iBAAiB,KAAK,IAAI,CAAC;AACnF,MAAM,QAAQ,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,GAAG,CAAC,iBAAiB,KAAK,IAAI,CAAC;AACtG,MAAM,gBAAgB,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAE,QAAQ,EAAE,gBAAgB,EAAY,CAAC","sourcesContent":["import type { Descriptor } from \"@gtkx/native\";\n\n/** How one argument of a native call or signal emission is marshalled and which way it flows. */\ntype Arg = {\n /** Descriptor the value is marshalled with, wrapped in a pointer to it for an output argument. */\n type: Descriptor;\n /** Direction of an output argument, omitted for a plain input argument. */\n direction?: \"out\" | \"inout\";\n /** When true, the caller supplies the storage the callee writes into, rather than a pointer to fill. */\n isCallerAllocated?: boolean;\n /** When true, the argument is consumed internally and left out of the packed result. */\n isConsumed?: boolean;\n};\n\nconst isOutputArg = (arg: Arg): boolean => arg.direction !== undefined;\nconst isInoutArg = (arg: Arg): boolean => arg.direction === \"inout\";\nconst isCallerAllocatedArg = (arg: Arg): boolean => arg.isCallerAllocated === true;\nconst isRefArg = (arg: Arg): boolean => arg.direction !== undefined && arg.isCallerAllocated !== true;\nconst requiresInputArg = (arg: Arg): boolean => !isRefArg(arg) || isInoutArg(arg);\n\nexport { isOutputArg, isInoutArg, isCallerAllocatedArg, isRefArg, requiresInputArg, type Arg };\n"]}
1
+ {"version":3,"file":"arg.js","sourceRoot":"","sources":["../src/arg.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC;AACvE,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,OAAO,CAAC;AACpE,MAAM,oBAAoB,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,GAAG,CAAC,iBAAiB,KAAK,IAAI,CAAC;AACnF,MAAM,aAAa,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,GAAG,CAAC,UAAU,KAAK,IAAI,CAAC;AACrE,MAAM,QAAQ,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,GAAG,CAAC,iBAAiB,KAAK,IAAI,CAAC;AACtG,MAAM,gBAAgB,GAAG,CAAC,GAAQ,EAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAY,CAAC","sourcesContent":["import type { Descriptor } from \"@gtkx/native\";\n\n/** How one argument of a native call or signal emission is marshalled and which way it flows. */\ntype Arg = {\n /** Descriptor the value is marshalled with, wrapped in a pointer to it for an output argument. */\n type: Descriptor;\n /** Direction of an output argument, omitted for a plain input argument. */\n direction?: \"out\" | \"inout\";\n /** When true, the caller supplies the storage the callee writes into, rather than a pointer to fill. */\n isCallerAllocated?: boolean;\n /** When true, the argument is consumed internally and left out of the packed result. */\n isConsumed?: boolean;\n /** When true, the argument is a `GValue` the callee fills in, packed into the result as what it holds. */\n isUnpacked?: boolean;\n /** When true, the caller must provide the argument: `undefined` is rejected instead of reaching C as `NULL`. */\n isRequired?: boolean;\n};\n\nconst isOutputArg = (arg: Arg): boolean => arg.direction !== undefined;\nconst isInoutArg = (arg: Arg): boolean => arg.direction === \"inout\";\nconst isCallerAllocatedArg = (arg: Arg): boolean => arg.isCallerAllocated === true;\nconst isUnpackedArg = (arg: Arg): boolean => arg.isUnpacked === true;\nconst isRefArg = (arg: Arg): boolean => arg.direction !== undefined && arg.isCallerAllocated !== true;\nconst requiresInputArg = (arg: Arg): boolean => !isRefArg(arg) || isInoutArg(arg);\n\nexport { isOutputArg, isInoutArg, isCallerAllocatedArg, isRefArg, isUnpackedArg, requiresInputArg, type Arg };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"closure.d.ts","sourceRoot":"","sources":["../src/closure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAQ,MAAM,cAAc,CAAC;AAStE;;;;;;;GAOG;AACH,KAAK,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;AAyFrD;;;;;GAKG;AACH,iBAAS,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAUzD;AAED,oGAAoG;AACpG,iBAAS,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,CAExE;AAED,sGAAsG;AACtG,cAAM,mBAAoB,SAAQ,SAAS;IACvC,6EAA6E;IAC7D,IAAI,SAAyB;CAChD;AAED,OAAO,EAAE,KAAK,eAAe,EAAE,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"closure.d.ts","sourceRoot":"","sources":["../src/closure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAQ,MAAM,cAAc,CAAC;AAStE;;;;;;;GAOG;AACH,KAAK,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;AA6ErD;;;;;GAKG;AACH,iBAAS,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAUzD;AAED,oGAAoG;AACpG,iBAAS,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,CAExE;AAED,sGAAsG;AACtG,cAAM,mBAAoB,SAAQ,SAAS;IACvC,6EAA6E;IAC7D,IAAI,SAAyB;CAChD;AAED,OAAO,EAAE,KAAK,eAAe,EAAE,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC"}
package/dist/closure.js CHANGED
@@ -3,7 +3,7 @@ import {} from "@gtkx/utils";
3
3
  import { bind } from "./bind.js";
4
4
  import { boxedT, callbackT, sizedArrayT, structT, uint32T, uint64T, voidT } from "./descriptors.js";
5
5
  import { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T } from "./library.js";
6
- import { getClassType, getHandle, getWrapperClass, instanceClassName, wrapHandle } from "./registry.js";
6
+ import { describeValueKind, getClassType, getHandle, getWrapperClass, wrapHandle } from "./registry.js";
7
7
  import { resolveBoxedType, typeIsA } from "./type.js";
8
8
  import { fromValue, getValueType, intoValue } from "./value.js";
9
9
  const CCLOSURE_CALLBACK_OFFSET = CLOSURE_SIZE;
@@ -44,15 +44,6 @@ const gClosureSetMarshal = bind(LIB, "g_closure_set_marshal", [CLOSURE_T, uint64
44
44
  const isClosureInstance = (value) => typeIsA(getClassType(value.constructor), resolveBoxedType(CLOSURE_T));
45
45
  const getNestedValue = (param) => wrapHandle(gValueGetBoxed(param), getWrapperClass(resolveBoxedType(VALUE_T)));
46
46
  const fromParamValue = (param) => getValueType(param) === resolveBoxedType(VALUE_T) ? getNestedValue(param) : fromValue(param);
47
- function describeValue(value) {
48
- if (value === null) {
49
- return "null";
50
- }
51
- if (typeof value !== "object") {
52
- return typeof value;
53
- }
54
- return instanceClassName(value);
55
- }
56
47
  function marshalFor(callback) {
57
48
  return (_closure, returnValue, _count, paramValues) => {
58
49
  const values = paramValues;
@@ -84,7 +75,7 @@ function toClosure(value) {
84
75
  if (typeof value === "object" && value !== null && isClosureInstance(value)) {
85
76
  return getHandle(value);
86
77
  }
87
- throw new ClosureMarshalError(`Cannot marshal ${describeValue(value)} into a GObject.Closure`);
78
+ throw new ClosureMarshalError(`Cannot marshal ${describeValueKind(value)} into a GObject.Closure`);
88
79
  }
89
80
  /** Same as {@link toClosure}, but passes a null or undefined value through as no closure at all. */
90
81
  function tryToClosure(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"closure.js","sourceRoot":"","sources":["../src/closure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,IAAI,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAiB,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAYhE,MAAM,wBAAwB,GAAG,YAAY,CAAC;AAC9C,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,oBAAoB,EAAE,CAAC,C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AC;AACN,CAAC;AAED,SAAS,UAAU,CAAC,QAAyB;IACzC,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAA2B,CAAC;IAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,wBAAwB,CAAC,CAAC;IAChE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpB,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEpC,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,KAAc;IAC7B,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC,KAAwB,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,aAAa,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnG,CAAC;AAED,oGAAoG;AACpG,SAAS,YAAY,CAAC,KAAc;IAChC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,sGAAsG;AACtG,MAAM,mBAAoB,SAAQ,SAAS;IACvC,6EAA6E;IAC7D,IAAI,GAAG,qBAAqB,CAAC;CAChD;AAED,OAAO,EAAwB,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { type ExternalObject, type Handle, read } from \"@gtkx/native\";\nimport { type AnyClass } from \"@gtkx/utils\";\nimport { bind } from \"./bind.js\";\nimport { boxedT, callbackT, sizedArrayT, structT, uint32T, uint64T, voidT } from \"./descriptors.js\";\nimport { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T } from \"./library.js\";\nimport { getClassType, getHandle, getWrapperClass, instanceClassName, wrapHandle } from \"./registry.js\";\nimport { resolveBoxedType, typeIsA } from \"./type.js\";\nimport { fromValue, getValueType, intoValue } from \"./value.js\";\n\n/**\n * Handler backing a `GClosure`. It receives the closure's parameters already converted from their\n * `GValue`s, and its result is written back into the closure's return `GValue` when it has one.\n *\n * A parameter that is itself a `GValue`, such as the target a property binding transform fills in,\n * arrives as the caller's own `GObject.Value` rather than a copy, so writing to it is how the\n * handler produces that parameter's value. It stops being valid once the handler returns.\n */\ntype ClosureCallback = (...args: never[]) => unknown;\n\nconst CCLOSURE_CALLBACK_OFFSET = CLOSURE_SIZE;\nconst N_PARAM_VALUES_INDEX = 2;\nconst MARSHAL_DATA_INDEX = 5;\nconst CLOSURE_T = boxedT(\"GClosure\", { sharedLibrary: LIB, getTypeFnName: \"g_closure_get_type\" });\n\nconst OWNED_CLOSURE_T = boxedT(\"GClosure\", {\n ownership: \"full\",\n sharedLibrary: LIB,\n getTypeFnName: \"g_closure_get_type\",\n});\n\nconst MARSHAL_VALUE_T = boxedT(\"GValue\", {\n sharedLibrary: LIB,\n getTypeFnName: \"g_value_get_type\",\n size: VALUE_SIZE,\n isCallerAllocated: true,\n});\n\nconst MARSHAL_T = callbackT(\n [\n CLOSURE_T,\n MARSHAL_VALUE_T,\n uint32T,\n sizedArrayT(MARSHAL_VALUE_T, N_PARAM_VALUES_INDEX, \"borrowed\", { elementSize: VALUE_SIZE }),\n uint64T,\n uint64T,\n ],\n voidT,\n {\n hasUserData: true,\n userDataIndex: MARSHAL_DATA_INDEX,\n hasDestroy: true,\n destroyKind: \"closureNotify\",\n scope: \"notified\",\n },\n);\n\nconst NESTED_VALUE_T = structT(\"borrowed\");\nconst gCclosureNew = bind(LIB, \"g_cclosure_new\", [MARSHAL_T], OWNED_CLOSURE_T);\nconst gValueGetBoxed = bind(LIB, \"g_value_get_boxed\", [VALUE_T], NESTED_VALUE_T);\nconst gClosureRef = bind(LIB, \"g_closure_ref\", [CLOSURE_T], uint64T);\nconst gClosureSink = bind(LIB, \"g_closure_sink\", [CLOSURE_T], voidT);\nconst gClosureSetMarshal = bind(LIB, \"g_closure_set_marshal\", [CLOSURE_T, uint64T], voidT);\n\nconst isClosureInstance = (value: object): boolean =>\n typeIsA(getClassType(value.constructor as AnyClass), resolveBoxedType(CLOSURE_T));\n\nconst getNestedValue = (param: ExternalObject<Handle>): object | null =>\n wrapHandle(gValueGetBoxed(param) as ExternalObject<Handle> | null, getWrapperClass(resolveBoxedType(VALUE_T)));\n\nconst fromParamValue = (param: ExternalObject<Handle>): unknown =>\n getValueType(param) === resolveBoxedType(VALUE_T) ? getNestedValue(param) : fromValue(param);\n\nfunction describeValue(value: unknown): string {\n if (value === null) {\n return \"null\";\n }\n\n if (typeof value !== \"object\") {\n return typeof value;\n }\n\n return instanceClassName(value);\n}\n\nfunction marshalFor(callback: ClosureCallback): (...args: unknown[]) => void {\n return (_closure: unknown, returnValue: unknown, _count: unknown, paramValues: unknown): void => {\n const values = paramValues as ExternalObject<Handle>[];\n const args = values.map((value) => fromParamValue(value));\n const result = (callback as (...values: unknown[]) => unknown)(...(args as never[]));\n\n if (returnValue !== null) {\n intoValue(returnValue as ExternalObject<Handle>, result);\n }\n };\n}\n\nfunction newClosure(callback: ClosureCallback): ExternalObject<Handle> {\n const handle = gCclosureNew(marshalFor(callback)) as ExternalObject<Handle>;\n const marshal = read(handle, uint64T, CCLOSURE_CALLBACK_OFFSET);\n gClosureRef(handle);\n gClosureSink(handle);\n gClosureSetMarshal(handle, marshal);\n\n return handle;\n}\n\n/**\n * Marshals a value passed where a `GObject.Closure` is expected into a closure handle: a function\n * becomes a new `GClosure` dispatching into it, and an existing closure yields its own handle.\n * @param value Function to wrap, or an already-built closure.\n * @throws {ClosureMarshalError} When the value is neither.\n */\nfunction toClosure(value: unknown): ExternalObject<Handle> {\n if (typeof value === \"function\") {\n return newClosure(value as ClosureCallback);\n }\n\n if (typeof value === \"object\" && value !== null && isClosureInstance(value)) {\n return getHandle(value);\n }\n\n throw new ClosureMarshalError(`Cannot marshal ${describeValue(value)} into a GObject.Closure`);\n}\n\n/** Same as {@link toClosure}, but passes a null or undefined value through as no closure at all. */\nfunction tryToClosure(value: unknown): ExternalObject<Handle> | undefined {\n return value == null ? undefined : toClosure(value);\n}\n\n/** Thrown when a value passed where a `GObject.Closure` is expected cannot be marshalled into one. */\nclass ClosureMarshalError extends TypeError {\n /** Name callers match on when the error is caught as a plain `TypeError`. */\n public override name = \"ClosureMarshalError\";\n}\n\nexport { type ClosureCallback, ClosureMarshalError, toClosure, tryToClosure };\n"]}
1
+ {"version":3,"file":"closure.js","sourceRoot":"","sources":["../src/closure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,IAAI,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAiB,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAYhE,MAAM,wBAAwB,GAAG,YAAY,CAAC;AAC9C,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,SAAS,GAA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AAE,OAAO,EAAE,wBAAwB,CAAC,CAAC;IAChE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpB,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEpC,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,KAAc;IAC7B,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC,KAAwB,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,iBAAiB,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACvG,CAAC;AAED,oGAAoG;AACpG,SAAS,YAAY,CAAC,KAAc;IAChC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,sGAAsG;AACtG,MAAM,mBAAoB,SAAQ,SAAS;IACvC,6EAA6E;IAC7D,IAAI,GAAG,qBAAqB,CAAC;CAChD;AAED,OAAO,EAAwB,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { type ExternalObject, type Handle, read } from \"@gtkx/native\";\nimport { type AnyClass } from \"@gtkx/utils\";\nimport { bind } from \"./bind.js\";\nimport { boxedT, callbackT, sizedArrayT, structT, uint32T, uint64T, voidT } from \"./descriptors.js\";\nimport { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T } from \"./library.js\";\nimport { describeValueKind, getClassType, getHandle, getWrapperClass, wrapHandle } from \"./registry.js\";\nimport { resolveBoxedType, typeIsA } from \"./type.js\";\nimport { fromValue, getValueType, intoValue } from \"./value.js\";\n\n/**\n * Handler backing a `GClosure`. It receives the closure's parameters already converted from their\n * `GValue`s, and its result is written back into the closure's return `GValue` when it has one.\n *\n * A parameter that is itself a `GValue`, such as the target a property binding transform fills in,\n * arrives as the caller's own `GObject.Value` rather than a copy, so writing to it is how the\n * handler produces that parameter's value. It stops being valid once the handler returns.\n */\ntype ClosureCallback = (...args: never[]) => unknown;\n\nconst CCLOSURE_CALLBACK_OFFSET = CLOSURE_SIZE;\nconst N_PARAM_VALUES_INDEX = 2;\nconst MARSHAL_DATA_INDEX = 5;\nconst CLOSURE_T = boxedT(\"GClosure\", { sharedLibrary: LIB, getTypeFnName: \"g_closure_get_type\" });\n\nconst OWNED_CLOSURE_T = boxedT(\"GClosure\", {\n ownership: \"full\",\n sharedLibrary: LIB,\n getTypeFnName: \"g_closure_get_type\",\n});\n\nconst MARSHAL_VALUE_T = boxedT(\"GValue\", {\n sharedLibrary: LIB,\n getTypeFnName: \"g_value_get_type\",\n size: VALUE_SIZE,\n isCallerAllocated: true,\n});\n\nconst MARSHAL_T = callbackT(\n [\n CLOSURE_T,\n MARSHAL_VALUE_T,\n uint32T,\n sizedArrayT(MARSHAL_VALUE_T, N_PARAM_VALUES_INDEX, \"borrowed\", { elementSize: VALUE_SIZE }),\n uint64T,\n uint64T,\n ],\n voidT,\n {\n hasUserData: true,\n userDataIndex: MARSHAL_DATA_INDEX,\n hasDestroy: true,\n destroyKind: \"closureNotify\",\n scope: \"notified\",\n },\n);\n\nconst NESTED_VALUE_T = structT(\"borrowed\");\nconst gCclosureNew = bind(LIB, \"g_cclosure_new\", [MARSHAL_T], OWNED_CLOSURE_T);\nconst gValueGetBoxed = bind(LIB, \"g_value_get_boxed\", [VALUE_T], NESTED_VALUE_T);\nconst gClosureRef = bind(LIB, \"g_closure_ref\", [CLOSURE_T], uint64T);\nconst gClosureSink = bind(LIB, \"g_closure_sink\", [CLOSURE_T], voidT);\nconst gClosureSetMarshal = bind(LIB, \"g_closure_set_marshal\", [CLOSURE_T, uint64T], voidT);\n\nconst isClosureInstance = (value: object): boolean =>\n typeIsA(getClassType(value.constructor as AnyClass), resolveBoxedType(CLOSURE_T));\n\nconst getNestedValue = (param: ExternalObject<Handle>): object | null =>\n wrapHandle(gValueGetBoxed(param) as ExternalObject<Handle> | null, getWrapperClass(resolveBoxedType(VALUE_T)));\n\nconst fromParamValue = (param: ExternalObject<Handle>): unknown =>\n getValueType(param) === resolveBoxedType(VALUE_T) ? getNestedValue(param) : fromValue(param);\n\nfunction marshalFor(callback: ClosureCallback): (...args: unknown[]) => void {\n return (_closure: unknown, returnValue: unknown, _count: unknown, paramValues: unknown): void => {\n const values = paramValues as ExternalObject<Handle>[];\n const args = values.map((value) => fromParamValue(value));\n const result = (callback as (...values: unknown[]) => unknown)(...(args as never[]));\n\n if (returnValue !== null) {\n intoValue(returnValue as ExternalObject<Handle>, result);\n }\n };\n}\n\nfunction newClosure(callback: ClosureCallback): ExternalObject<Handle> {\n const handle = gCclosureNew(marshalFor(callback)) as ExternalObject<Handle>;\n const marshal = read(handle, uint64T, CCLOSURE_CALLBACK_OFFSET);\n gClosureRef(handle);\n gClosureSink(handle);\n gClosureSetMarshal(handle, marshal);\n\n return handle;\n}\n\n/**\n * Marshals a value passed where a `GObject.Closure` is expected into a closure handle: a function\n * becomes a new `GClosure` dispatching into it, and an existing closure yields its own handle.\n * @param value Function to wrap, or an already-built closure.\n * @throws {ClosureMarshalError} When the value is neither.\n */\nfunction toClosure(value: unknown): ExternalObject<Handle> {\n if (typeof value === \"function\") {\n return newClosure(value as ClosureCallback);\n }\n\n if (typeof value === \"object\" && value !== null && isClosureInstance(value)) {\n return getHandle(value);\n }\n\n throw new ClosureMarshalError(`Cannot marshal ${describeValueKind(value)} into a GObject.Closure`);\n}\n\n/** Same as {@link toClosure}, but passes a null or undefined value through as no closure at all. */\nfunction tryToClosure(value: unknown): ExternalObject<Handle> | undefined {\n return value == null ? undefined : toClosure(value);\n}\n\n/** Thrown when a value passed where a `GObject.Closure` is expected cannot be marshalled into one. */\nclass ClosureMarshalError extends TypeError {\n /** Name callers match on when the error is caught as a plain `TypeError`. */\n public override name = \"ClosureMarshalError\";\n}\n\nexport { type ClosureCallback, ClosureMarshalError, toClosure, tryToClosure };\n"]}
@@ -149,6 +149,11 @@ type CallbackOptions = {
149
149
  hasUserData?: boolean;
150
150
  /** Position of `user_data` among the callback's own arguments, dropped before the closure is called. */
151
151
  userDataIndex?: number;
152
+ /**
153
+ * The callback's C signature ends with a `GError**`, which receives a `GError` built from
154
+ * whatever the JavaScript function throws while the callback returns its failure value.
155
+ */
156
+ canThrow?: boolean;
152
157
  /** Lifetime of the closure; defaults to `notified` when `hasDestroy` is set and `call` otherwise. */
153
158
  scope?: CallbackDescriptor["scope"];
154
159
  };
@@ -164,6 +169,12 @@ type ArrayOptions = {
164
169
  fixedSize?: number | undefined;
165
170
  /** Whether the array carries raw bytes, and so decodes to a `Uint8Array` rather than to numbers. */
166
171
  isBytes?: boolean | undefined;
172
+ /**
173
+ * Whether the caller supplies the storage for a fixed-length out array: the runtime allocates
174
+ * a buffer of the element stride times the fixed element count, passes its pointer, and
175
+ * decodes the elements the callee wrote into it.
176
+ */
177
+ isCallerAllocated?: boolean | undefined;
167
178
  };
168
179
  /** Where a cursor array's base buffer and total length come from. */
169
180
  type CursorBounds = {
@@ -180,6 +191,8 @@ type FundamentalOptions = {
180
191
  typeName?: string;
181
192
  /** Class a decoded value is wrapped in, instead of the one registered for `typeName`. */
182
193
  wrapperClass?: AnyClass;
194
+ /** The caller owns the storage the callee fills, so a decoded value is borrowed instead of acquired. */
195
+ isCallerAllocated?: boolean;
183
196
  /** The value is embedded in the containing struct rather than reached through a pointer. */
184
197
  isInline?: boolean;
185
198
  };
@@ -233,6 +246,7 @@ declare const voidT: VoidDescriptor;
233
246
  declare const unicharT: UnicharDescriptor;
234
247
  /** Descriptor for an opaque `gpointer`, taken from a typed array's memory or a numeric address. */
235
248
  declare const bufferT: BufferDescriptor;
249
+ declare const isGtypeDescriptor: (descriptor: Descriptor) => descriptor is TypeDescriptor;
236
250
  /**
237
251
  * Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer
238
252
  * used when the string is passed by reference.
@@ -246,8 +260,12 @@ declare const refT: (innerDescriptor: Descriptor, isInout?: boolean) => RefDescr
246
260
  declare const hashTableT: (keyDescriptor: Descriptor, valueDescriptor: Descriptor, ownership?: Ownership) => HashTableDescriptor;
247
261
  /** Builds a descriptor for an enumeration, resolving its GType from the named `get_type` function. */
248
262
  declare const enumT: (sharedLibrary: string, typeFnName: string, isSigned: boolean) => EnumDescriptor;
249
- /** Builds a descriptor for a flags type, resolving its GType from the named `get_type` function. */
250
- declare const flagsT: (sharedLibrary: string, typeFnName: string, isSigned: boolean) => FlagsDescriptor;
263
+ /**
264
+ * Builds a descriptor for a flags type, resolving its GType from the named `get_type` function.
265
+ * For flags without a registered GType, pass empty library and function names and supply `mask`,
266
+ * the union of all valid bits, which invalid combinations are rejected against.
267
+ */
268
+ declare const flagsT: (sharedLibrary: string, typeFnName: string, isSigned: boolean, mask?: number) => FlagsDescriptor;
251
269
  /** Builds a descriptor for a `GBoxed` value of the named type. */
252
270
  declare const boxedT: (typeName: string, options?: BoxedOptions) => BoxedDescriptor;
253
271
  /** Builds a descriptor for a plain C struct. */
@@ -278,5 +296,5 @@ declare const cursorArrayT: (itemDescriptor: Descriptor, bounds: CursorBounds, o
278
296
  declare const fixedArrayT: (itemDescriptor: Descriptor, fixedSize: number, ownership?: Ownership, options?: ArrayOptions) => ArrayDescriptor;
279
297
  /** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */
280
298
  declare const callbackT: (argDescriptors: Descriptor[], returnDescriptor: Descriptor, options?: CallbackOptions) => CallbackDescriptor;
281
- 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, type BoxedDescriptor, type StructDescriptor, type FundamentalDescriptor, type ArrayDescriptor, type HashTableDescriptor, type CallbackDescriptor, type RefDescriptor, };
299
+ export { int8T, uint8T, int16T, uint16T, int32T, uint32T, int64T, uint64T, bigint64T, biguint64T, gtypeT, isGtypeDescriptor, 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, type BoxedDescriptor, type StructDescriptor, type FundamentalDescriptor, type ArrayDescriptor, type HashTableDescriptor, type CallbackDescriptor, type RefDescriptor, };
282
300
  //# sourceMappingURL=descriptors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"descriptors.d.ts","sourceRoot":"","sources":["../src/descriptors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wCAAwC;AACxC,KAAK,cAAc,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAC5D,yCAAyC;AACzC,KAAK,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAC9D,yCAAyC;AACzC,KAAK,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAC9D,0CAA0C;AAC1C,KAAK,gBAAgB,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE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,YAAY,EACpB,YAAW,SAAsB,EACjC,UAAS,YAAiB,KAC3B,eAAyF,CAAC;AAE7F,2DAA2D;AAC3D,QAAA,MAAM,WAAW,GACb,gBAAgB,UAAU,EAC1B,WAAW,MAAM,EACjB,YAAW,SAAsB,EACjC,UAAS,YAAiB,KAC3B,eAAwF,CAAC;AAgC5F,2GAA2G;AAC3G,QAAA,MAAM,SAAS,GACX,gBAAgB,UAAU,EAAE,EAC5B,kBAAkB,UAAU,EAC5B,UAAU,eAAe,KAC1B,kBAUF,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,iBAAiB,EACjB,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,uBAAuB,EACvB,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,aAAa,GACrB,CAAC"}
@@ -33,6 +33,7 @@ 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
35
  const fundamentalLifecycles = new Map();
36
+ const isGtypeDescriptor = (descriptor) => descriptor.kind === "biguint64" && "type" in descriptor;
36
37
  /**
37
38
  * Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer
38
39
  * used when the string is passed by reference.
@@ -56,13 +57,23 @@ const enumT = (sharedLibrary, typeFnName, isSigned) => ({
56
57
  getTypeFnName: typeFnName,
57
58
  isSigned,
58
59
  });
59
- /** Builds a descriptor for a flags type, resolving its GType from the named `get_type` function. */
60
- const flagsT = (sharedLibrary, typeFnName, isSigned) => ({
61
- kind: "flags",
62
- sharedLibrary,
63
- getTypeFnName: typeFnName,
64
- isSigned,
65
- });
60
+ /**
61
+ * Builds a descriptor for a flags type, resolving its GType from the named `get_type` function.
62
+ * For flags without a registered GType, pass empty library and function names and supply `mask`,
63
+ * the union of all valid bits, which invalid combinations are rejected against.
64
+ */
65
+ const flagsT = (sharedLibrary, typeFnName, isSigned, mask) => {
66
+ const result = {
67
+ kind: "flags",
68
+ sharedLibrary,
69
+ getTypeFnName: typeFnName,
70
+ isSigned,
71
+ };
72
+ if (mask !== undefined) {
73
+ result.mask = mask;
74
+ }
75
+ return result;
76
+ };
66
77
  const applyBoxedNames = (result, options) => {
67
78
  if (options.sharedLibrary !== undefined) {
68
79
  result.sharedLibrary = options.sharedLibrary;
@@ -130,29 +141,41 @@ const fundamentalT = (sharedLibrary, refFnName, unrefFnName, options = {}) => {
130
141
  if (options.wrapperClass !== undefined) {
131
142
  result.wrapperClass = options.wrapperClass;
132
143
  }
144
+ if (options.isCallerAllocated) {
145
+ result.isCallerAllocated = true;
146
+ }
133
147
  if (options.isInline) {
134
148
  result.isInline = true;
135
149
  }
136
150
  return result;
137
151
  };
138
- /** Builds a descriptor for an array of items in one of the supported container layouts. */
139
- const arrayT = (itemDescriptor, arrayKind = "array", ownership = "borrowed", options) => {
140
- const result = { kind: "array", itemDescriptor, arrayKind, ownership };
141
- if (options?.elementSize !== undefined) {
142
- result.elementSize = options.elementSize;
143
- }
144
- if (options?.baseParamIndex !== undefined) {
152
+ const applyArrayBounds = (result, options) => {
153
+ if (options.baseParamIndex !== undefined) {
145
154
  result.baseParamIndex = options.baseParamIndex;
146
155
  }
147
- if (options?.sizeParamIndex !== undefined) {
156
+ if (options.sizeParamIndex !== undefined) {
148
157
  result.sizeParamIndex = options.sizeParamIndex;
149
158
  }
150
- if (options?.fixedSize !== undefined) {
159
+ if (options.fixedSize !== undefined) {
151
160
  result.fixedSize = options.fixedSize;
152
161
  }
153
- if (options?.isBytes === true) {
162
+ };
163
+ /** Builds a descriptor for an array of items in one of the supported container layouts. */
164
+ const arrayT = (itemDescriptor, arrayKind = "array", ownership = "borrowed", options) => {
165
+ const result = { kind: "array", itemDescriptor, arrayKind, ownership };
166
+ if (options === undefined) {
167
+ return result;
168
+ }
169
+ applyArrayBounds(result, options);
170
+ if (options.elementSize !== undefined) {
171
+ result.elementSize = options.elementSize;
172
+ }
173
+ if (options.isBytes === true) {
154
174
  result.isBytes = true;
155
175
  }
176
+ if (options.isCallerAllocated === true) {
177
+ result.isCallerAllocated = true;
178
+ }
156
179
  return result;
157
180
  };
158
181
  /** Builds a descriptor for a `GList` of items. */
@@ -174,21 +197,27 @@ const sizedArrayT = (itemDescriptor, sizeParamIndex, ownership = "borrowed", opt
174
197
  const cursorArrayT = (itemDescriptor, bounds, ownership = "borrowed", options = {}) => arrayT(itemDescriptor, "cursor", ownership, { ...options, ...bounds });
175
198
  /** Builds a descriptor for a C array of a fixed length. */
176
199
  const fixedArrayT = (itemDescriptor, fixedSize, ownership = "borrowed", options = {}) => arrayT(itemDescriptor, "fixed", ownership, { ...options, fixedSize });
177
- const applyClosureOptions = (result, options) => {
200
+ const applyClosureLifetimeOptions = (result, options) => {
178
201
  if (options.hasDestroy !== undefined) {
179
202
  result.hasDestroy = options.hasDestroy;
180
203
  }
181
204
  if (options.destroyKind !== undefined) {
182
205
  result.destroyKind = options.destroyKind;
183
206
  }
207
+ if (options.scope !== undefined) {
208
+ result.scope = options.scope;
209
+ }
210
+ };
211
+ const applyClosureOptions = (result, options) => {
212
+ applyClosureLifetimeOptions(result, options);
184
213
  if (options.hasUserData !== undefined) {
185
214
  result.hasUserData = options.hasUserData;
186
215
  }
187
216
  if (options.userDataIndex !== undefined) {
188
217
  result.userDataIndex = options.userDataIndex;
189
218
  }
190
- if (options.scope !== undefined) {
191
- result.scope = options.scope;
219
+ if (options.canThrow !== undefined) {
220
+ result.canThrow = options.canThrow;
192
221
  }
193
222
  };
194
223
  /** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */
@@ -200,5 +229,5 @@ const callbackT = (argDescriptors, returnDescriptor, options) => {
200
229
  applyClosureOptions(result, options);
201
230
  return result;
202
231
  };
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, };
232
+ export { int8T, uint8T, int16T, uint16T, int32T, uint32T, int64T, uint64T, bigint64T, biguint64T, gtypeT, isGtypeDescriptor, 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, };
204
233
  //# sourceMappingURL=descriptors.js.map
@@ -1 +1 @@
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,IA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K,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,uBAAuB,EACvB,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,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/**\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"]}
1
+ {"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../src/descriptors.ts"],"names":[],"mappings":"AA6KA,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;AACvG,MAAM,MAAM,GAAmB,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACjE,iCAAiC;AACjC,MAAM,QAAQ,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACxD,kCAAkC;AAClC,MAAM,QAAQ,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACxD,uEAAuE;AACvE,MAAM,QAAQ,GAAsB,EAAE,IAAI,EAAE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E,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;IAE1F,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAErC,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,iBAAiB,EACjB,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,uBAAuB,EACvB,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,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/**\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 /**\n * The callback's C signature ends with a `GError**`, which receives a `GError` built from\n * whatever the JavaScript function throws while the callback returns its failure value.\n */\n canThrow?: boolean;\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 * Whether the caller supplies the storage for a fixed-length out array: the runtime allocates\n * a buffer of the element stride times the fixed element count, passes its pointer, and\n * decodes the elements the callee wrote into it.\n */\n isCallerAllocated?: 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 caller owns the storage the callee fills, so a decoded value is borrowed instead of acquired. */\n isCallerAllocated?: boolean;\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\nconst isGtypeDescriptor = (descriptor: Descriptor): descriptor is TypeDescriptor =>\n descriptor.kind === \"biguint64\" && \"type\" in descriptor;\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/**\n * Builds a descriptor for a flags type, resolving its GType from the named `get_type` function.\n * For flags without a registered GType, pass empty library and function names and supply `mask`,\n * the union of all valid bits, which invalid combinations are rejected against.\n */\nconst flagsT = (sharedLibrary: string, typeFnName: string, isSigned: boolean, mask?: number): FlagsDescriptor => {\n const result: FlagsDescriptor = {\n kind: \"flags\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n isSigned,\n };\n\n if (mask !== undefined) {\n result.mask = mask;\n }\n\n return result;\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.isCallerAllocated) {\n result.isCallerAllocated = true;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n return result;\n};\n\nconst applyArrayBounds = (result: ArrayDescriptor, options: ArrayOptions): void => {\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\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 === undefined) {\n return result;\n }\n\n applyArrayBounds(result, options);\n\n if (options.elementSize !== undefined) {\n result.elementSize = options.elementSize;\n }\n\n if (options.isBytes === true) {\n result.isBytes = true;\n }\n\n if (options.isCallerAllocated === true) {\n result.isCallerAllocated = 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 applyClosureLifetimeOptions = (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.scope !== undefined) {\n result.scope = options.scope;\n }\n};\n\nconst applyClosureOptions = (result: CallbackDescriptor, options: CallbackOptions): void => {\n applyClosureLifetimeOptions(result, options);\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.canThrow !== undefined) {\n result.canThrow = options.canThrow;\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 isGtypeDescriptor,\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/fn.d.ts CHANGED
@@ -20,6 +20,8 @@ type FnSpec = {
20
20
  * architectures.
21
21
  */
22
22
  fixedArgCount?: number;
23
+ /** The callee returns a `GValue`, surfaced as what it holds rather than as the value itself. */
24
+ isReturnUnpacked?: boolean;
23
25
  };
24
26
  declare const buildNativeArgTypes: (args: Arg[], canThrow: boolean) => Descriptor[];
25
27
  declare function fromNativeCallable(descriptor: ExternalObject<CallDescriptor>, spec: FnSpec, getRefSeeds?: () => RefSeeds | undefined): (...inputs: unknown[]) => unknown;
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;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iGAAiG;IACjG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAcF,QAAA,MAAM,mBAAmB,GAAI,MAAM,GAAG,EAAE,EAAE,UAAU,OAAO,KAAG,UAAU,EAYvE,CAAC;AAoGF,iBAAS,kBAAkB,CACvB,UAAU,EAAE,cAAc,CAAC,cAAc,CAAC,EAC1C,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,QAAQ,GAAG,SAAS,GACzC,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,OAAO,CAmCnC;AAED;;;;;;;GAOG;AACH,iBAAS,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,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