@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.
Files changed (112) hide show
  1. package/README.md +1 -1
  2. package/dist/application-class.d.ts +5 -0
  3. package/dist/application-class.d.ts.map +1 -1
  4. package/dist/application-class.js +11 -1
  5. package/dist/application-class.js.map +1 -1
  6. package/dist/callback.d.ts +2 -2
  7. package/dist/callback.d.ts.map +1 -1
  8. package/dist/callback.js +51 -54
  9. package/dist/callback.js.map +1 -1
  10. package/dist/closure.js +1 -1
  11. package/dist/closure.js.map +1 -1
  12. package/dist/default-application.d.ts +4 -0
  13. package/dist/default-application.d.ts.map +1 -0
  14. package/dist/default-application.js +17 -0
  15. package/dist/default-application.js.map +1 -0
  16. package/dist/descriptors.d.ts +34 -9
  17. package/dist/descriptors.d.ts.map +1 -1
  18. package/dist/descriptors.js +42 -17
  19. package/dist/descriptors.js.map +1 -1
  20. package/dist/exit-hook.js +13 -0
  21. package/dist/exit-hook.js.map +1 -1
  22. package/dist/fn.d.ts +5 -0
  23. package/dist/fn.d.ts.map +1 -1
  24. package/dist/fn.js +11 -13
  25. package/dist/fn.js.map +1 -1
  26. package/dist/folded-lengths.d.ts +16 -0
  27. package/dist/folded-lengths.d.ts.map +1 -0
  28. package/dist/folded-lengths.js +38 -0
  29. package/dist/folded-lengths.js.map +1 -0
  30. package/dist/internal.d.ts +1 -0
  31. package/dist/internal.d.ts.map +1 -1
  32. package/dist/internal.js +1 -0
  33. package/dist/internal.js.map +1 -1
  34. package/dist/library.d.ts +2 -1
  35. package/dist/library.d.ts.map +1 -1
  36. package/dist/library.js +2 -1
  37. package/dist/library.js.map +1 -1
  38. package/dist/lifecycle.d.ts +16 -1
  39. package/dist/lifecycle.d.ts.map +1 -1
  40. package/dist/lifecycle.js +44 -14
  41. package/dist/lifecycle.js.map +1 -1
  42. package/dist/listeners.d.ts.map +1 -1
  43. package/dist/listeners.js +16 -4
  44. package/dist/listeners.js.map +1 -1
  45. package/dist/native-value.js +2 -2
  46. package/dist/native-value.js.map +1 -1
  47. package/dist/object.d.ts +7 -2
  48. package/dist/object.d.ts.map +1 -1
  49. package/dist/object.js +7 -2
  50. package/dist/object.js.map +1 -1
  51. package/dist/param-spec.d.ts.map +1 -1
  52. package/dist/param-spec.js +18 -20
  53. package/dist/param-spec.js.map +1 -1
  54. package/dist/properties.d.ts +2 -1
  55. package/dist/properties.d.ts.map +1 -1
  56. package/dist/properties.js +13 -9
  57. package/dist/properties.js.map +1 -1
  58. package/dist/register-class.d.ts +33 -3
  59. package/dist/register-class.d.ts.map +1 -1
  60. package/dist/register-class.js +21 -7
  61. package/dist/register-class.js.map +1 -1
  62. package/dist/registry.d.ts +14 -4
  63. package/dist/registry.d.ts.map +1 -1
  64. package/dist/registry.js +24 -15
  65. package/dist/registry.js.map +1 -1
  66. package/dist/signal.d.ts +2 -2
  67. package/dist/signal.d.ts.map +1 -1
  68. package/dist/signal.js +22 -18
  69. package/dist/signal.js.map +1 -1
  70. package/dist/t.d.ts +3 -1
  71. package/dist/t.d.ts.map +1 -1
  72. package/dist/t.js +1 -0
  73. package/dist/t.js.map +1 -1
  74. package/dist/tuple.d.ts +6 -3
  75. package/dist/tuple.d.ts.map +1 -1
  76. package/dist/tuple.js +9 -7
  77. package/dist/tuple.js.map +1 -1
  78. package/dist/value.d.ts +3 -1
  79. package/dist/value.d.ts.map +1 -1
  80. package/dist/value.js +64 -18
  81. package/dist/value.js.map +1 -1
  82. package/dist/vfunc-call.d.ts.map +1 -1
  83. package/dist/vfunc-call.js +5 -1
  84. package/dist/vfunc-call.js.map +1 -1
  85. package/dist/vfunc.d.ts.map +1 -1
  86. package/dist/vfunc.js +9 -3
  87. package/dist/vfunc.js.map +1 -1
  88. package/package.json +14 -4
  89. package/src/application-class.ts +12 -2
  90. package/src/callback.ts +70 -66
  91. package/src/closure.ts +1 -1
  92. package/src/default-application.ts +21 -0
  93. package/src/descriptors.ts +98 -29
  94. package/src/exit-hook.ts +18 -0
  95. package/src/fn.ts +23 -13
  96. package/src/folded-lengths.ts +64 -0
  97. package/src/internal.ts +1 -0
  98. package/src/library.ts +2 -1
  99. package/src/lifecycle.ts +60 -14
  100. package/src/listeners.ts +22 -5
  101. package/src/native-value.ts +2 -2
  102. package/src/object.ts +7 -2
  103. package/src/param-spec.ts +21 -22
  104. package/src/properties.ts +23 -9
  105. package/src/register-class.ts +66 -11
  106. package/src/registry.ts +43 -20
  107. package/src/signal.ts +32 -28
  108. package/src/t.ts +4 -1
  109. package/src/tuple.ts +18 -12
  110. package/src/value.ts +94 -19
  111. package/src/vfunc-call.ts +5 -1
  112. package/src/vfunc.ts +10 -3
@@ -1 +1 @@
1
- {"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,OAAO,EAMH,KAAK,UAAU,EAGlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAwD,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE7G,OAAO,EAAyC,KAAK,WAAW,EAAkB,MAAM,YAAY,CAAC;AAErG,KAAK,aAAa,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,UAAU,CAAC;IACzB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,KAAK,gBAAgB,GAAG,aAAa,GAAG;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EA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f,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GACpB,CAAC"}
@@ -5,7 +5,7 @@ import { LIB, PARAM_T, VALUE_T } from "./library.js";
5
5
  import { getParamFlags, getParamValueType, isParamConstructOnly, isParamLaxlyValidated, isParamWritable, valueGuardFor, wasParamValueModified, } from "./param-spec.js";
6
6
  import { getHandle, getInterfaceProperties, instanceClassName } from "./registry.js";
7
7
  import { typeName } from "./type.js";
8
- import { fromValue, intoValue, newValueForType, valueWriterFor } from "./value.js";
8
+ import { fromValue, newValueForType, valueNarrowerFor, valueWriterFor, } from "./value.js";
9
9
  const FIRST_PROPERTY_ID = 1;
10
10
  const GET_PROPERTY_VFUNC = "vfuncGetProperty";
11
11
  const SET_PROPERTY_VFUNC = "vfuncSetProperty";
@@ -24,6 +24,7 @@ const canonicalCase = (name) => kebabCase(name).replaceAll("_", "-");
24
24
  const accessorNames = (name) => [...new Set([name, underscoreCase(name), camelCase(name)])];
25
25
  const typeLabel = (type) => typeName(type) ?? String(type);
26
26
  const defaultValueFor = (handle) => paramSpecDefaultValue(handle);
27
+ const heldValue = (value) => value ?? null;
27
28
  const holdsReason = (check) => `the property holds values of type '${typeLabel(check.valueType)}'`;
28
29
  function checkFor(handle, name) {
29
30
  const valueType = getParamValueType(handle);
@@ -34,6 +35,7 @@ function checkFor(handle, name) {
34
35
  flags: getParamFlags(handle),
35
36
  valueType,
36
37
  canHoldValue: valueGuardFor(valueType),
38
+ narrowValue: valueNarrowerFor(valueType),
37
39
  };
38
40
  }
39
41
  function findPropertySpec(klass, name) {
@@ -85,10 +87,13 @@ function assertWritable(instance, check, value) {
85
87
  }
86
88
  throw new TypeError(propertyMessage(instance, check, refusalTail(check, value, READ_ONLY_REASON)));
87
89
  }
90
+ function writeHeld(check, gValue, value) {
91
+ check.write ??= valueWriterFor(check.valueType);
92
+ check.write(gValue, check.narrowValue(value));
93
+ }
88
94
  function fillCheckedValue(instance, check, gValue, value) {
89
95
  assertValueFits(instance, check, value);
90
- check.write ??= valueWriterFor(check.valueType);
91
- check.write(gValue, value);
96
+ writeHeld(check, gValue, value);
92
97
  assertValueValidates(instance, check, value, gValue);
93
98
  }
94
99
  function checkedValueFor(instance, check, value) {
@@ -121,10 +126,10 @@ function readStored(instance, accessor) {
121
126
  return instance[accessor.storage];
122
127
  }
123
128
  function storeValue(instance, accessor, value) {
124
- instance[accessor.storage] = value;
129
+ instance[accessor.storage] = heldValue(value);
125
130
  }
126
131
  function writeStored(instance, accessor, value) {
127
- if (readStored(instance, accessor) === value) {
132
+ if (readStored(instance, accessor) === heldValue(value)) {
128
133
  return;
129
134
  }
130
135
  storeValue(instance, accessor, value);
@@ -132,12 +137,11 @@ function writeStored(instance, accessor, value) {
132
137
  }
133
138
  function writeProperty(instance, accessor, value) {
134
139
  const stored = instance;
135
- if (readStored(stored, accessor) === value) {
140
+ if (readStored(stored, accessor) === heldValue(value)) {
136
141
  return;
137
142
  }
138
143
  assertValueAccepted(instance, accessor, value);
139
- storeValue(stored, accessor, value);
140
- instance.notify?.(accessor.propertyName);
144
+ writeStored(stored, accessor, accessor.narrowValue(value));
141
145
  }
142
146
  function storedGetter(accessor) {
143
147
  return function get() {
@@ -274,7 +278,7 @@ function makeGetProperty(dispatch) {
274
278
  const accessor = resolveAccessor(dispatch, propertyId, pspec);
275
279
  const current = readCurrent(this, accessor);
276
280
  assertValueServes(this, accessor, current);
277
- intoValue(getHandle(value), current);
281
+ writeHeld(accessor, getHandle(value), current);
278
282
  };
279
283
  }
280
284
  function makeSetProperty(dispatch) {
@@ -1 +1 @@
1
- {"version":3,"file":"properties.js","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,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EACH,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GAIrB,CAAC","sourcesContent":["import type { ExternalObject, Handle, RegisterClassProperty } from \"@gtkx/native\";\nimport type { AnyClass } from \"@gtkx/utils\";\nimport { camelCase, kebabCase } from \"@gtkx/utils\";\nimport { bind } from \"./bind.js\";\nimport { biguint64T, stringT, structT, voidT } from \"./descriptors.js\";\nimport { LIB, PARAM_T, VALUE_T } from \"./library.js\";\nimport {\n getParamFlags,\n getParamValueType,\n isParamConstructOnly,\n isParamLaxlyValidated,\n isParamWritable,\n type ValueGuard,\n valueGuardFor,\n wasParamValueModified,\n} from \"./param-spec.js\";\nimport { getHandle, getInterfaceProperties, instanceClassName, type InterfaceProperty } from \"./registry.js\";\nimport { typeName } from \"./type.js\";\nimport { fromValue, intoValue, newValueForType, type ValueWriter, valueWriterFor } from \"./value.js\";\n\ntype PropertyCheck = {\n name: string;\n propertyName: string;\n handle: ExternalObject<Handle>;\n flags: number;\n valueType: bigint;\n canHoldValue: ValueGuard;\n write?: ValueWriter;\n scratch?: ExternalObject<Handle>;\n};\n\ntype PropertyAccessor = PropertyCheck & {\n memberName: string;\n storage: symbol;\n hasGeneratedMember: boolean;\n isInterfaceProperty?: boolean;\n delegate?: InterfaceProperty;\n};\n\n/** A `GObject.ParamSpec` wrapper describing one property's name, type, flags and default. */\ntype PropertySpec = object;\n\ntype PropertyDispatch = {\n accessors: PropertyAccessor[];\n delegates: Map<string, InterfaceProperty>;\n};\n\ntype PropertyDispatchSource = {\n klass: AnyClass;\n properties: Record<string, PropertySpec>;\n adoptedTypes: bigint[];\n};\n\ntype ConstructProperty = {\n name: string;\n value: ExternalObject<Handle>;\n};\n\ntype NotifyingObject = { notify?: (propertyName: string) => void };\n\nconst FIRST_PROPERTY_ID = 1;\nconst GET_PROPERTY_VFUNC = \"vfuncGetProperty\";\nconst SET_PROPERTY_VFUNC = \"vfuncSetProperty\";\nconst READ_ONLY_REASON = \"the property is read-only\";\nconst CONSTRUCT_ONLY_REASON = \"the property can only be set when the object is constructed\";\nconst CLASS_T = structT(\"borrowed\");\nconst interfaceStorages: Map<string, symbol> = new Map();\nconst paramSpecDefaultValue = bind(LIB, \"g_param_spec_get_default_value\", [PARAM_T], VALUE_T);\nconst paramSpecName = bind(LIB, \"g_param_spec_get_name\", [PARAM_T], stringT(\"borrowed\"));\nconst typeClassRef = bind(LIB, \"g_type_class_ref\", [biguint64T], CLASS_T);\nconst typeClassUnref = bind(LIB, \"g_type_class_unref\", [CLASS_T], voidT);\nconst classFindProperty = bind(LIB, \"g_object_class_find_property\", [CLASS_T, stringT(\"borrowed\")], PARAM_T);\n\nconst getPropertyName = (pspec: PropertySpec): string => paramSpecName(getHandle(pspec)) as string;\nconst underscoreCase = (name: string): string => name.replaceAll(\"-\", \"_\");\nconst canonicalCase = (name: string): string => kebabCase(name).replaceAll(\"_\", \"-\");\nconst accessorNames = (name: string): string[] => [...new Set([name, underscoreCase(name), camelCase(name)])];\nconst typeLabel = (type: bigint): string => typeName(type) ?? String(type);\n\nconst defaultValueFor = (handle: ExternalObject<Handle>): ExternalObject<Handle> =>\n paramSpecDefaultValue(handle) as ExternalObject<Handle>;\n\nconst holdsReason = (check: PropertyCheck): string =>\n `the property holds values of type '${typeLabel(check.valueType)}'`;\n\nfunction checkFor(handle: ExternalObject<Handle>, name: string): PropertyCheck {\n const valueType = getParamValueType(handle);\n\n return {\n name,\n propertyName: paramSpecName(handle) as string,\n handle,\n flags: getParamFlags(handle),\n valueType,\n canHoldValue: valueGuardFor(valueType),\n };\n}\n\nfunction findPropertySpec(klass: ExternalObject<Handle>, name: string): ExternalObject<Handle> | null {\n const found = classFindProperty(klass, name) as ExternalObject<Handle> | null;\n\n return found ?? (classFindProperty(klass, canonicalCase(name)) as ExternalObject<Handle> | null);\n}\n\nfunction describeValue(value: unknown): string {\n if (typeof value === \"string\") {\n return JSON.stringify(value);\n }\n\n if (typeof value === \"object\" && value !== null) {\n return instanceClassName(value);\n }\n\n return String(value);\n}\n\nfunction propertyMessage(instance: object, check: PropertyCheck, tail: string): string {\n return `${instanceClassName(instance)}.${check.name}: ${tail}`;\n}\n\nfunction refusalTail(check: PropertyCheck, value: unknown, reason: string): string {\n return `cannot set property '${check.propertyName}' to ${describeValue(value)}; ${reason}`;\n}\n\nfunction serveTail(check: PropertyCheck, value: unknown): string {\n return `cannot serve property '${check.propertyName}' from ${describeValue(value)}; ${holdsReason(check)}`;\n}\n\nfunction assertValueFits(instance: object, check: PropertyCheck, value: unknown): void {\n if (check.canHoldValue(value)) {\n return;\n }\n\n const tail = refusalTail(check, value, holdsReason(check));\n throw new TypeError(propertyMessage(instance, check, tail));\n}\n\nfunction assertValueServes(instance: object, check: PropertyCheck, value: unknown): void {\n if (check.canHoldValue(value)) {\n return;\n }\n\n throw new TypeError(propertyMessage(instance, check, serveTail(check, value)));\n}\n\nfunction assertValueValidates(\n instance: object,\n check: PropertyCheck,\n value: unknown,\n gValue: ExternalObject<Handle>,\n): void {\n if (!wasParamValueModified(check.handle, gValue) || isParamLaxlyValidated(check.flags)) {\n return;\n }\n\n const reason =\n `the value is invalid or out of range for type '${typeLabel(check.valueType)}', ` +\n `and GObject would put ${describeValue(fromValue(gValue))} in its place`;\n\n throw new RangeError(propertyMessage(instance, check, refusalTail(check, value, reason)));\n}\n\nfunction assertWritable(instance: object, check: PropertyCheck, value: unknown): void {\n if (isParamWritable(check.flags)) {\n return;\n }\n\n throw new TypeError(propertyMessage(instance, check, refusalTail(check, value, READ_ONLY_REASON)));\n}\n\nfunction fillCheckedValue(\n instance: object,\n check: PropertyCheck,\n gValue: ExternalObject<Handle>,\n value: unknown,\n): void {\n assertValueFits(instance, check, value);\n check.write ??= valueWriterFor(check.valueType);\n check.write(gValue, value);\n assertValueValidates(instance, check, value, gValue);\n}\n\nfunction checkedValueFor(instance: object, check: PropertyCheck, value: unknown): ExternalObject<Handle> {\n const gValue = newValueForType(check.valueType);\n fillCheckedValue(instance, check, gValue, value);\n\n return gValue;\n}\n\nfunction assertValueAccepted(instance: object, check: PropertyCheck, value: unknown): void {\n check.scratch ??= newValueForType(check.valueType);\n fillCheckedValue(instance, check, check.scratch, value);\n}\n\nfunction constructValueFor(wrapper: object, check: PropertyCheck, value: unknown): ConstructProperty {\n assertWritable(wrapper, check, value);\n\n return { name: check.propertyName, value: checkedValueFor(wrapper, check, value) };\n}\n\nfunction constructPropertyFor(\n gtype: bigint,\n name: string,\n value: unknown,\n wrapper: object,\n): ConstructProperty | undefined {\n const klass = typeClassRef(gtype) as ExternalObject<Handle>;\n\n try {\n const pspec = findPropertySpec(klass, name);\n\n return pspec === null ? undefined : constructValueFor(wrapper, checkFor(pspec, name), value);\n } finally {\n typeClassUnref(klass);\n }\n}\n\nfunction readStored(instance: Record<symbol, unknown>, accessor: PropertyAccessor): unknown {\n if (!Object.hasOwn(instance, accessor.storage)) {\n instance[accessor.storage] = fromValue(defaultValueFor(accessor.handle));\n }\n\n return instance[accessor.storage];\n}\n\nfunction storeValue(instance: Record<symbol, unknown>, accessor: PropertyAccessor, value: unknown): void {\n instance[accessor.storage] = value;\n}\n\nfunction writeStored(instance: Record<symbol, unknown>, accessor: PropertyAccessor, value: unknown): void {\n if (readStored(instance, accessor) === value) {\n return;\n }\n\n storeValue(instance, accessor, value);\n (instance as NotifyingObject).notify?.(accessor.propertyName);\n}\n\nfunction writeProperty(instance: object, accessor: PropertyAccessor, value: unknown): void {\n const stored = instance as Record<symbol, unknown>;\n\n if (readStored(stored, accessor) === value) {\n return;\n }\n\n assertValueAccepted(instance, accessor, value);\n storeValue(stored, accessor, value);\n (instance as NotifyingObject).notify?.(accessor.propertyName);\n}\n\nfunction storedGetter(accessor: PropertyAccessor): (this: object) => unknown {\n return function get(this: object) {\n return readStored(this as Record<symbol, unknown>, accessor);\n };\n}\n\nfunction memberGetter(accessor: PropertyAccessor): (this: object) => unknown {\n return function get(this: object) {\n return (this as Record<string, unknown>)[accessor.memberName];\n };\n}\n\nfunction memberSetter(accessor: PropertyAccessor): (this: object, value: unknown) => void {\n return function set(this: object, value: unknown) {\n (this as Record<string, unknown>)[accessor.memberName] = value;\n };\n}\n\nfunction refusalFor(accessor: PropertyAccessor, reason: string): (this: object, value: unknown) => void {\n return function set(this: object, value: unknown) {\n throw new TypeError(propertyMessage(this, accessor, refusalTail(accessor, value, reason)));\n };\n}\n\nfunction checkedSetter(accessor: PropertyAccessor): (this: object, value: unknown) => void {\n if (!isParamWritable(accessor.flags)) {\n return refusalFor(accessor, READ_ONLY_REASON);\n }\n\n if (isParamConstructOnly(accessor.flags)) {\n return refusalFor(accessor, CONSTRUCT_ONLY_REASON);\n }\n\n return function set(this: object, value: unknown) {\n writeProperty(this, accessor, value);\n };\n}\n\nfunction hasOwnMember(prototype: object, alias: string): boolean {\n return Object.getOwnPropertyDescriptor(prototype, alias) !== undefined;\n}\n\nfunction defineAccessor(prototype: object, descriptor: PropertyDescriptor, alias: string): void {\n if (hasOwnMember(prototype, alias)) {\n return;\n }\n\n Object.defineProperty(prototype, alias, descriptor);\n}\n\nfunction installAccessors(klass: AnyClass, accessor: PropertyAccessor): void {\n const prototype = (klass as { prototype: object }).prototype;\n accessor.hasGeneratedMember = !hasOwnMember(prototype, accessor.memberName);\n\n const descriptor: PropertyDescriptor = {\n configurable: true,\n enumerable: true,\n get: accessor.hasGeneratedMember ? storedGetter(accessor) : memberGetter(accessor),\n set: accessor.hasGeneratedMember ? checkedSetter(accessor) : memberSetter(accessor),\n };\n\n for (const alias of accessorNames(accessor.name)) {\n defineAccessor(prototype, descriptor, alias);\n }\n}\n\nfunction storageFor(propertyName: string): symbol {\n const existing = interfaceStorages.get(propertyName);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const created = Symbol(`gtkx:property:${propertyName}`);\n interfaceStorages.set(propertyName, created);\n\n return created;\n}\n\nfunction interfaceAccessorFor(dispatch: PropertyDispatch, pspec: PropertySpec): PropertyAccessor {\n const handle = getHandle(pspec);\n const propertyName = paramSpecName(handle) as string;\n const delegate = dispatch.delegates.get(propertyName);\n\n const accessor: PropertyAccessor = {\n ...checkFor(handle, propertyName),\n memberName: camelCase(propertyName),\n storage: storageFor(propertyName),\n hasGeneratedMember: false,\n isInterfaceProperty: true,\n };\n\n if (delegate !== undefined) {\n accessor.delegate = delegate;\n }\n\n return accessor;\n}\n\nfunction resolveAccessor(\n dispatch: PropertyDispatch,\n propertyId: number,\n pspec: PropertySpec,\n): PropertyAccessor {\n const accessor = dispatch.accessors[propertyId - FIRST_PROPERTY_ID];\n\n if (accessor !== undefined) {\n return accessor;\n }\n\n const created = interfaceAccessorFor(dispatch, pspec);\n dispatch.accessors[propertyId - FIRST_PROPERTY_ID] = created;\n\n return created;\n}\n\nfunction callMember(instance: object, member: string, args: unknown[]): unknown {\n const fn: unknown = (instance as Record<string, unknown>)[member];\n\n if (typeof fn !== \"function\") {\n throw new TypeError(`registerClass: ${instanceClassName(instance)} has no '${member}' member`);\n }\n\n return (fn as (...values: unknown[]) => unknown).apply(instance, args);\n}\n\nfunction backingMemberFor(instance: object, accessor: PropertyAccessor): string | undefined {\n if (accessor.hasGeneratedMember && !Object.hasOwn(instance, accessor.memberName)) {\n return undefined;\n }\n\n return accessor.memberName;\n}\n\nfunction readCurrent(instance: object, accessor: PropertyAccessor): unknown {\n const getter = accessor.delegate?.getter;\n\n if (getter !== undefined) {\n return callMember(instance, getter, []);\n }\n\n if (accessor.isInterfaceProperty === true) {\n return readStored(instance as Record<symbol, unknown>, accessor);\n }\n\n const member = backingMemberFor(instance, accessor);\n\n return member === undefined\n ? readStored(instance as Record<symbol, unknown>, accessor)\n : (instance as Record<string, unknown>)[member];\n}\n\nfunction writeCurrent(instance: object, accessor: PropertyAccessor, value: unknown): void {\n const setter = accessor.delegate?.setter;\n\n if (setter !== undefined) {\n callMember(instance, setter, [value]);\n\n return;\n }\n\n if (accessor.isInterfaceProperty === true) {\n writeStored(instance as Record<symbol, unknown>, accessor, value);\n\n return;\n }\n\n const member = backingMemberFor(instance, accessor);\n\n if (member === undefined) {\n storeValue(instance as Record<symbol, unknown>, accessor, value);\n\n return;\n }\n\n (instance as Record<string, unknown>)[member] = value;\n}\n\nfunction makeGetProperty(dispatch: PropertyDispatch) {\n return function getProperty(this: object, propertyId: number, value: object, pspec: PropertySpec): void {\n const accessor = resolveAccessor(dispatch, propertyId, pspec);\n const current = readCurrent(this, accessor);\n assertValueServes(this, accessor, current);\n intoValue(getHandle(value), current);\n };\n}\n\nfunction makeSetProperty(dispatch: PropertyDispatch) {\n return function setProperty(this: object, propertyId: number, value: object, pspec: PropertySpec): void {\n const accessor = resolveAccessor(dispatch, propertyId, pspec);\n writeCurrent(this, accessor, fromValue(getHandle(value)));\n };\n}\n\nfunction assertCanonicalName(klass: AnyClass, name: string, propertyName: string): void {\n const canonical = canonicalCase(name);\n\n if (propertyName === canonical) {\n return;\n }\n\n throw new TypeError(\n `registerClass: ${klass.name} keys the property '${name}' to a GObject.ParamSpec named ` +\n `'${propertyName}', which is the name GObject notifies under; name the ParamSpec '${canonical}'`,\n );\n}\n\nfunction assertCanonicalNames(klass: AnyClass, properties: Record<string, PropertySpec>): void {\n for (const [name, pspec] of Object.entries(properties)) {\n assertCanonicalName(klass, name, getPropertyName(pspec));\n }\n}\n\nfunction buildAccessor(klass: AnyClass, name: string, pspec: PropertySpec): PropertyAccessor {\n const accessor: PropertyAccessor = {\n ...checkFor(getHandle(pspec), name),\n memberName: camelCase(name),\n storage: Symbol(`gtkx:property:${name}`),\n hasGeneratedMember: false,\n };\n\n installAccessors(klass, accessor);\n\n return accessor;\n}\n\nfunction buildAccessors(source: PropertyDispatchSource): PropertyAccessor[] {\n const { klass, properties } = source;\n assertCanonicalNames(klass, properties);\n\n return Object.entries(properties).map(([name, pspec]) => buildAccessor(klass, name, pspec));\n}\n\nfunction addInterfaceDelegates(delegates: Map<string, InterfaceProperty>, gtype: bigint): void {\n const properties = getInterfaceProperties(gtype) ?? {};\n\n for (const [name, delegate] of Object.entries(properties)) {\n if (!delegates.has(name)) {\n delegates.set(name, delegate);\n }\n }\n}\n\nfunction interfaceDelegatesFor(adoptedTypes: bigint[]): Map<string, InterfaceProperty> {\n const delegates: Map<string, InterfaceProperty> = new Map();\n\n for (const gtype of adoptedTypes) {\n addInterfaceDelegates(delegates, gtype);\n }\n\n return delegates;\n}\n\nfunction buildPropertyDispatch(source: PropertyDispatchSource): PropertyDispatch {\n return {\n accessors: buildAccessors(source),\n delegates: interfaceDelegatesFor(source.adoptedTypes),\n };\n}\n\nfunction toNativeProperties(properties: Record<string, PropertySpec>): RegisterClassProperty[] {\n return Object.values(properties).map((pspec, index) => ({\n id: index + FIRST_PROPERTY_ID,\n pspec: getHandle(pspec),\n }));\n}\n\nexport {\n buildPropertyDispatch,\n constructPropertyFor,\n GET_PROPERTY_VFUNC,\n makeGetProperty,\n makeSetProperty,\n SET_PROPERTY_VFUNC,\n toNativeProperties,\n type ConstructProperty,\n type PropertyDispatch,\n type PropertySpec,\n};\n"]}
1
+ {"version":3,"file":"properties.js","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EACH,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EAEf,aAAa,EACb,qBAAqB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,iBAAiB,EAA0B,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACH,SAAS,E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kB,EAClB,kBAAkB,GAIrB,CAAC","sourcesContent":["import type { ExternalObject, Handle, RegisterClassProperty } from \"@gtkx/native\";\nimport type { AnyClass } from \"@gtkx/utils\";\nimport { camelCase, kebabCase } from \"@gtkx/utils\";\nimport { bind } from \"./bind.js\";\nimport { biguint64T, stringT, structT, voidT } from \"./descriptors.js\";\nimport { LIB, PARAM_T, VALUE_T } from \"./library.js\";\nimport {\n getParamFlags,\n getParamValueType,\n isParamConstructOnly,\n isParamLaxlyValidated,\n isParamWritable,\n type ValueGuard,\n valueGuardFor,\n wasParamValueModified,\n} from \"./param-spec.js\";\nimport { getHandle, getInterfaceProperties, instanceClassName, type InterfaceProperty } from \"./registry.js\";\nimport { typeName } from \"./type.js\";\nimport {\n fromValue,\n newValueForType,\n type ValueNarrower,\n valueNarrowerFor,\n type ValueWriter,\n valueWriterFor,\n} from \"./value.js\";\n\ntype PropertyCheck = {\n name: string;\n propertyName: string;\n handle: ExternalObject<Handle>;\n flags: number;\n valueType: bigint;\n canHoldValue: ValueGuard;\n narrowValue: ValueNarrower;\n write?: ValueWriter;\n scratch?: ExternalObject<Handle>;\n};\n\ntype PropertyAccessor = PropertyCheck & {\n memberName: string;\n storage: symbol;\n hasGeneratedMember: boolean;\n isInterfaceProperty?: boolean;\n delegate?: InterfaceProperty;\n};\n\n/** A `GObject.ParamSpec` wrapper describing one property's name, type, flags and default. */\ntype PropertySpec = object;\n\ntype PropertyDispatch = {\n accessors: PropertyAccessor[];\n delegates: Map<string, InterfaceProperty>;\n};\n\ntype PropertyDispatchSource = {\n klass: AnyClass;\n properties: Record<string, PropertySpec>;\n adoptedTypes: bigint[];\n};\n\ntype ConstructProperty = {\n name: string;\n value: ExternalObject<Handle>;\n};\n\ntype NotifyingObject = { notify?: (propertyName: string) => void };\n\nconst FIRST_PROPERTY_ID = 1;\nconst GET_PROPERTY_VFUNC = \"vfuncGetProperty\";\nconst SET_PROPERTY_VFUNC = \"vfuncSetProperty\";\nconst READ_ONLY_REASON = \"the property is read-only\";\nconst CONSTRUCT_ONLY_REASON = \"the property can only be set when the object is constructed\";\nconst CLASS_T = structT(\"borrowed\");\nconst interfaceStorages: Map<string, symbol> = new Map();\nconst paramSpecDefaultValue = bind(LIB, \"g_param_spec_get_default_value\", [PARAM_T], VALUE_T);\nconst paramSpecName = bind(LIB, \"g_param_spec_get_name\", [PARAM_T], stringT(\"borrowed\"));\nconst typeClassRef = bind(LIB, \"g_type_class_ref\", [biguint64T], CLASS_T);\nconst typeClassUnref = bind(LIB, \"g_type_class_unref\", [CLASS_T], voidT);\nconst classFindProperty = bind(LIB, \"g_object_class_find_property\", [CLASS_T, stringT(\"borrowed\")], PARAM_T);\n\nconst getPropertyName = (pspec: PropertySpec): string => paramSpecName(getHandle(pspec)) as string;\nconst underscoreCase = (name: string): string => name.replaceAll(\"-\", \"_\");\nconst canonicalCase = (name: string): string => kebabCase(name).replaceAll(\"_\", \"-\");\nconst accessorNames = (name: string): string[] => [...new Set([name, underscoreCase(name), camelCase(name)])];\nconst typeLabel = (type: bigint): string => typeName(type) ?? String(type);\n\nconst defaultValueFor = (handle: ExternalObject<Handle>): ExternalObject<Handle> =>\n paramSpecDefaultValue(handle) as ExternalObject<Handle>;\n\nconst heldValue = (value: unknown): unknown => value ?? null;\n\nconst holdsReason = (check: PropertyCheck): string =>\n `the property holds values of type '${typeLabel(check.valueType)}'`;\n\nfunction checkFor(handle: ExternalObject<Handle>, name: string): PropertyCheck {\n const valueType = getParamValueType(handle);\n\n return {\n name,\n propertyName: paramSpecName(handle) as string,\n handle,\n flags: getParamFlags(handle),\n valueType,\n canHoldValue: valueGuardFor(valueType),\n narrowValue: valueNarrowerFor(valueType),\n };\n}\n\nfunction findPropertySpec(klass: ExternalObject<Handle>, name: string): ExternalObject<Handle> | null {\n const found = classFindProperty(klass, name) as ExternalObject<Handle> | null;\n\n return found ?? (classFindProperty(klass, canonicalCase(name)) as ExternalObject<Handle> | null);\n}\n\nfunction describeValue(value: unknown): string {\n if (typeof value === \"string\") {\n return JSON.stringify(value);\n }\n\n if (typeof value === \"object\" && value !== null) {\n return instanceClassName(value);\n }\n\n return String(value);\n}\n\nfunction propertyMessage(instance: object, check: PropertyCheck, tail: string): string {\n return `${instanceClassName(instance)}.${check.name}: ${tail}`;\n}\n\nfunction refusalTail(check: PropertyCheck, value: unknown, reason: string): string {\n return `cannot set property '${check.propertyName}' to ${describeValue(value)}; ${reason}`;\n}\n\nfunction serveTail(check: PropertyCheck, value: unknown): string {\n return `cannot serve property '${check.propertyName}' from ${describeValue(value)}; ${holdsReason(check)}`;\n}\n\nfunction assertValueFits(instance: object, check: PropertyCheck, value: unknown): void {\n if (check.canHoldValue(value)) {\n return;\n }\n\n const tail = refusalTail(check, value, holdsReason(check));\n throw new TypeError(propertyMessage(instance, check, tail));\n}\n\nfunction assertValueServes(instance: object, check: PropertyCheck, value: unknown): void {\n if (check.canHoldValue(value)) {\n return;\n }\n\n throw new TypeError(propertyMessage(instance, check, serveTail(check, value)));\n}\n\nfunction assertValueValidates(\n instance: object,\n check: PropertyCheck,\n value: unknown,\n gValue: ExternalObject<Handle>,\n): void {\n if (!wasParamValueModified(check.handle, gValue) || isParamLaxlyValidated(check.flags)) {\n return;\n }\n\n const reason =\n `the value is invalid or out of range for type '${typeLabel(check.valueType)}', ` +\n `and GObject would put ${describeValue(fromValue(gValue))} in its place`;\n\n throw new RangeError(propertyMessage(instance, check, refusalTail(check, value, reason)));\n}\n\nfunction assertWritable(instance: object, check: PropertyCheck, value: unknown): void {\n if (isParamWritable(check.flags)) {\n return;\n }\n\n throw new TypeError(propertyMessage(instance, check, refusalTail(check, value, READ_ONLY_REASON)));\n}\n\nfunction writeHeld(check: PropertyCheck, gValue: ExternalObject<Handle>, value: unknown): void {\n check.write ??= valueWriterFor(check.valueType);\n check.write(gValue, check.narrowValue(value));\n}\n\nfunction fillCheckedValue(\n instance: object,\n check: PropertyCheck,\n gValue: ExternalObject<Handle>,\n value: unknown,\n): void {\n assertValueFits(instance, check, value);\n writeHeld(check, gValue, value);\n assertValueValidates(instance, check, value, gValue);\n}\n\nfunction checkedValueFor(instance: object, check: PropertyCheck, value: unknown): ExternalObject<Handle> {\n const gValue = newValueForType(check.valueType);\n fillCheckedValue(instance, check, gValue, value);\n\n return gValue;\n}\n\nfunction assertValueAccepted(instance: object, check: PropertyCheck, value: unknown): void {\n check.scratch ??= newValueForType(check.valueType);\n fillCheckedValue(instance, check, check.scratch, value);\n}\n\nfunction constructValueFor(wrapper: object, check: PropertyCheck, value: unknown): ConstructProperty {\n assertWritable(wrapper, check, value);\n\n return { name: check.propertyName, value: checkedValueFor(wrapper, check, value) };\n}\n\nfunction constructPropertyFor(\n gtype: bigint,\n name: string,\n value: unknown,\n wrapper: object,\n): ConstructProperty | undefined {\n const klass = typeClassRef(gtype) as ExternalObject<Handle>;\n\n try {\n const pspec = findPropertySpec(klass, name);\n\n return pspec === null ? undefined : constructValueFor(wrapper, checkFor(pspec, name), value);\n } finally {\n typeClassUnref(klass);\n }\n}\n\nfunction readStored(instance: Record<symbol, unknown>, accessor: PropertyAccessor): unknown {\n if (!Object.hasOwn(instance, accessor.storage)) {\n instance[accessor.storage] = fromValue(defaultValueFor(accessor.handle));\n }\n\n return instance[accessor.storage];\n}\n\nfunction storeValue(instance: Record<symbol, unknown>, accessor: PropertyAccessor, value: unknown): void {\n instance[accessor.storage] = heldValue(value);\n}\n\nfunction writeStored(instance: Record<symbol, unknown>, accessor: PropertyAccessor, value: unknown): void {\n if (readStored(instance, accessor) === heldValue(value)) {\n return;\n }\n\n storeValue(instance, accessor, value);\n (instance as NotifyingObject).notify?.(accessor.propertyName);\n}\n\nfunction writeProperty(instance: object, accessor: PropertyAccessor, value: unknown): void {\n const stored = instance as Record<symbol, unknown>;\n\n if (readStored(stored, accessor) === heldValue(value)) {\n return;\n }\n\n assertValueAccepted(instance, accessor, value);\n writeStored(stored, accessor, accessor.narrowValue(value));\n}\n\nfunction storedGetter(accessor: PropertyAccessor): (this: object) => unknown {\n return function get(this: object) {\n return readStored(this as Record<symbol, unknown>, accessor);\n };\n}\n\nfunction memberGetter(accessor: PropertyAccessor): (this: object) => unknown {\n return function get(this: object) {\n return (this as Record<string, unknown>)[accessor.memberName];\n };\n}\n\nfunction memberSetter(accessor: PropertyAccessor): (this: object, value: unknown) => void {\n return function set(this: object, value: unknown) {\n (this as Record<string, unknown>)[accessor.memberName] = value;\n };\n}\n\nfunction refusalFor(accessor: PropertyAccessor, reason: string): (this: object, value: unknown) => void {\n return function set(this: object, value: unknown) {\n throw new TypeError(propertyMessage(this, accessor, refusalTail(accessor, value, reason)));\n };\n}\n\nfunction checkedSetter(accessor: PropertyAccessor): (this: object, value: unknown) => void {\n if (!isParamWritable(accessor.flags)) {\n return refusalFor(accessor, READ_ONLY_REASON);\n }\n\n if (isParamConstructOnly(accessor.flags)) {\n return refusalFor(accessor, CONSTRUCT_ONLY_REASON);\n }\n\n return function set(this: object, value: unknown) {\n writeProperty(this, accessor, value);\n };\n}\n\nfunction hasOwnMember(prototype: object, alias: string): boolean {\n return Object.getOwnPropertyDescriptor(prototype, alias) !== undefined;\n}\n\nfunction defineAccessor(prototype: object, descriptor: PropertyDescriptor, alias: string): void {\n if (hasOwnMember(prototype, alias)) {\n return;\n }\n\n Object.defineProperty(prototype, alias, descriptor);\n}\n\nfunction installAccessors(klass: AnyClass, accessor: PropertyAccessor): void {\n const prototype = (klass as { prototype: object }).prototype;\n accessor.hasGeneratedMember = !hasOwnMember(prototype, accessor.memberName);\n\n const descriptor: PropertyDescriptor = {\n configurable: true,\n enumerable: true,\n get: accessor.hasGeneratedMember ? storedGetter(accessor) : memberGetter(accessor),\n set: accessor.hasGeneratedMember ? checkedSetter(accessor) : memberSetter(accessor),\n };\n\n for (const alias of accessorNames(accessor.name)) {\n defineAccessor(prototype, descriptor, alias);\n }\n}\n\nfunction storageFor(propertyName: string): symbol {\n const existing = interfaceStorages.get(propertyName);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const created = Symbol(`gtkx:property:${propertyName}`);\n interfaceStorages.set(propertyName, created);\n\n return created;\n}\n\nfunction interfaceAccessorFor(dispatch: PropertyDispatch, pspec: PropertySpec): PropertyAccessor {\n const handle = getHandle(pspec);\n const propertyName = paramSpecName(handle) as string;\n const delegate = dispatch.delegates.get(propertyName);\n\n const accessor: PropertyAccessor = {\n ...checkFor(handle, propertyName),\n memberName: camelCase(propertyName),\n storage: storageFor(propertyName),\n hasGeneratedMember: false,\n isInterfaceProperty: true,\n };\n\n if (delegate !== undefined) {\n accessor.delegate = delegate;\n }\n\n return accessor;\n}\n\nfunction resolveAccessor(\n dispatch: PropertyDispatch,\n propertyId: number,\n pspec: PropertySpec,\n): PropertyAccessor {\n const accessor = dispatch.accessors[propertyId - FIRST_PROPERTY_ID];\n\n if (accessor !== undefined) {\n return accessor;\n }\n\n const created = interfaceAccessorFor(dispatch, pspec);\n dispatch.accessors[propertyId - FIRST_PROPERTY_ID] = created;\n\n return created;\n}\n\nfunction callMember(instance: object, member: string, args: unknown[]): unknown {\n const fn: unknown = (instance as Record<string, unknown>)[member];\n\n if (typeof fn !== \"function\") {\n throw new TypeError(`registerClass: ${instanceClassName(instance)} has no '${member}' member`);\n }\n\n return (fn as (...values: unknown[]) => unknown).apply(instance, args);\n}\n\nfunction backingMemberFor(instance: object, accessor: PropertyAccessor): string | undefined {\n if (accessor.hasGeneratedMember && !Object.hasOwn(instance, accessor.memberName)) {\n return undefined;\n }\n\n return accessor.memberName;\n}\n\nfunction readCurrent(instance: object, accessor: PropertyAccessor): unknown {\n const getter = accessor.delegate?.getter;\n\n if (getter !== undefined) {\n return callMember(instance, getter, []);\n }\n\n if (accessor.isInterfaceProperty === true) {\n return readStored(instance as Record<symbol, unknown>, accessor);\n }\n\n const member = backingMemberFor(instance, accessor);\n\n return member === undefined\n ? readStored(instance as Record<symbol, unknown>, accessor)\n : (instance as Record<string, unknown>)[member];\n}\n\nfunction writeCurrent(instance: object, accessor: PropertyAccessor, value: unknown): void {\n const setter = accessor.delegate?.setter;\n\n if (setter !== undefined) {\n callMember(instance, setter, [value]);\n\n return;\n }\n\n if (accessor.isInterfaceProperty === true) {\n writeStored(instance as Record<symbol, unknown>, accessor, value);\n\n return;\n }\n\n const member = backingMemberFor(instance, accessor);\n\n if (member === undefined) {\n storeValue(instance as Record<symbol, unknown>, accessor, value);\n\n return;\n }\n\n (instance as Record<string, unknown>)[member] = value;\n}\n\nfunction makeGetProperty(dispatch: PropertyDispatch) {\n return function getProperty(this: object, propertyId: number, value: object, pspec: PropertySpec): void {\n const accessor = resolveAccessor(dispatch, propertyId, pspec);\n const current = readCurrent(this, accessor);\n assertValueServes(this, accessor, current);\n writeHeld(accessor, getHandle(value), current);\n };\n}\n\nfunction makeSetProperty(dispatch: PropertyDispatch) {\n return function setProperty(this: object, propertyId: number, value: object, pspec: PropertySpec): void {\n const accessor = resolveAccessor(dispatch, propertyId, pspec);\n writeCurrent(this, accessor, fromValue(getHandle(value)));\n };\n}\n\nfunction assertCanonicalName(klass: AnyClass, name: string, propertyName: string): void {\n const canonical = canonicalCase(name);\n\n if (propertyName === canonical) {\n return;\n }\n\n throw new TypeError(\n `registerClass: ${klass.name} keys the property '${name}' to a GObject.ParamSpec named ` +\n `'${propertyName}', which is the name GObject notifies under; name the ParamSpec '${canonical}'`,\n );\n}\n\nfunction assertCanonicalNames(klass: AnyClass, properties: Record<string, PropertySpec>): void {\n for (const [name, pspec] of Object.entries(properties)) {\n assertCanonicalName(klass, name, getPropertyName(pspec));\n }\n}\n\nfunction buildAccessor(klass: AnyClass, name: string, pspec: PropertySpec): PropertyAccessor {\n const accessor: PropertyAccessor = {\n ...checkFor(getHandle(pspec), name),\n memberName: camelCase(name),\n storage: Symbol(`gtkx:property:${name}`),\n hasGeneratedMember: false,\n };\n\n installAccessors(klass, accessor);\n\n return accessor;\n}\n\nfunction buildAccessors(source: PropertyDispatchSource): PropertyAccessor[] {\n const { klass, properties } = source;\n assertCanonicalNames(klass, properties);\n\n return Object.entries(properties).map(([name, pspec]) => buildAccessor(klass, name, pspec));\n}\n\nfunction addInterfaceDelegates(delegates: Map<string, InterfaceProperty>, gtype: bigint): void {\n const properties = getInterfaceProperties(gtype) ?? {};\n\n for (const [name, delegate] of Object.entries(properties)) {\n if (!delegates.has(name)) {\n delegates.set(name, delegate);\n }\n }\n}\n\nfunction interfaceDelegatesFor(adoptedTypes: bigint[]): Map<string, InterfaceProperty> {\n const delegates: Map<string, InterfaceProperty> = new Map();\n\n for (const gtype of adoptedTypes) {\n addInterfaceDelegates(delegates, gtype);\n }\n\n return delegates;\n}\n\nfunction buildPropertyDispatch(source: PropertyDispatchSource): PropertyDispatch {\n return {\n accessors: buildAccessors(source),\n delegates: interfaceDelegatesFor(source.adoptedTypes),\n };\n}\n\nfunction toNativeProperties(properties: Record<string, PropertySpec>): RegisterClassProperty[] {\n return Object.values(properties).map((pspec, index) => ({\n id: index + FIRST_PROPERTY_ID,\n pspec: getHandle(pspec),\n }));\n}\n\nexport {\n buildPropertyDispatch,\n constructPropertyFor,\n GET_PROPERTY_VFUNC,\n makeGetProperty,\n makeSetProperty,\n SET_PROPERTY_VFUNC,\n toNativeProperties,\n type ConstructProperty,\n type PropertyDispatch,\n type PropertySpec,\n};\n"]}
@@ -26,7 +26,7 @@ type Dashed<TName extends string> = TName extends `${infer THead}_${infer TTail}
26
26
  type Camelized<TName extends string> = TName extends `${infer THead}-${infer TTail}` ? `${THead}${Capitalize<Camelized<TTail>>}` : TName;
27
27
  /**
28
28
  * The names a registered class carries in its property map: every key of
29
- * `RegisterClassOptions.properties` in camelCase, whichever of the three spellings it was written in.
29
+ * `RegisterClassOptions.properties` in camelCase, whichever spelling it was written in.
30
30
  * A `properties` object given a type of its own rather than left to inference has `string` for its key
31
31
  * type and names nothing, because a name only known as `string` addresses no member in particular.
32
32
  */
@@ -83,13 +83,43 @@ type RegisterClassOptions<TInstance extends object, TProperties extends Record<s
83
83
  * A write the ParamSpec would refuse throws rather than reaching GObject, which reports such a
84
84
  * write as a GLib critical and drops it: a `TypeError` for a read-only or construct-only
85
85
  * property and for a value of a type the property cannot hold, and a `RangeError` for a value
86
- * the ParamSpec rejects. The same two checks run over a value handed to the constructor, where
86
+ * the ParamSpec rejects. The same checks run over a value handed to the constructor, where
87
87
  * a construct-only property is the one that is writable. An accepted write emits one `notify`,
88
88
  * which a `freeze_notify` batch collects; a write of the value the property already holds is
89
89
  * dropped and emits none.
90
90
  *
91
+ * `null` and `undefined` both mean NULL, and mean it only where the ParamSpec's own type holds
92
+ * NULL, which is a string, string-array, boxed, object, interface, param, variant or pointer
93
+ * property. Such a property holds the `null` either spelling wrote, so the member, the type's
94
+ * `get_property` slot and `g_object_get_property` serve the same thing, and writing the other
95
+ * spelling over it emits no `notify`. Every other property, so every integer, floating-point,
96
+ * boolean, enum, flags and GType one, refuses both with the same `TypeError` it refuses a
97
+ * string with, and keeps the value it already holds. It refuses them for what it holds rather
98
+ * than for its range, whatever that range is: the type is checked before the range, so a
99
+ * `gint` whose range excludes 0 answers a nullish with that same `TypeError` and never with
100
+ * the `RangeError` that names the value GObject would put in its place. The one place
101
+ * `undefined` means something else is the constructor, which reads it as the property not
102
+ * being given at all and leaves it at the ParamSpec's default, so a property is never handed a
103
+ * value it cannot serve back.
104
+ *
105
+ * A floating-point property takes every JavaScript number, `NaN` and both infinities
106
+ * included, and its ParamSpec alone rules on which of them the range admits: a `gdouble`
107
+ * bounded by `-Infinity` and `Infinity` holds either infinity, and a magnitude a bounded
108
+ * one excludes, like any `NaN`, comes back as the `RangeError` that names what GObject
109
+ * would put in its place rather than as the `TypeError` a type the property cannot hold
110
+ * earns. A `gfloat` property holds what GObject narrows the double to, so it serves `0.1`
111
+ * back as `0.10000000149011612` and a finite magnitude no `gfloat` reaches as an infinity,
112
+ * which the range then rules on in turn. That narrowing belongs to the property alone: the
113
+ * same magnitude written to a `gfloat` through a generated binding, a signal argument or a
114
+ * closure return is refused outright rather than narrowed.
115
+ *
116
+ * A generated property of a wrapped type answers a nullish differently, and the two halves of
117
+ * the API disagree here: that property marshals what it is written through its descriptor
118
+ * rather than through the checks above, so `new Gtk.Label({ widthRequest: null })` and a later
119
+ * write of `null` to that member both land 0, where a `gint` installed here refuses both.
120
+ *
91
121
  * A class that defines the camelCase member itself owns the property: its own accessor decides
92
- * what a write means, the other two spellings forward to it, and the type's property slots read
122
+ * what a write means, the other spellings forward to it, and the type's property slots read
93
123
  * and write it rather than the generated storage.
94
124
  */
95
125
  properties?: TProperties;
@@ -1 +1 @@
1
- {"version":3,"file":"register-class.d.ts","sourceRoot":"","sources":["../src/register-class.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,QAAQ,EAAkC,MAAM,aAAa,CAAC;AAG5E,OAAO,EAMH,KAAK,YAAY,EAGpB,MAAM,iBAAiB,CAAC;AAWzB;;;;;;;;;GASG;AACH,KAAK,SAAS,CAAC,KAAK,IAAI,QAAQ,GAAG;IAC/B,qFAAqF;IACrF,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC;CACrD,CAAC;AAEF;;;GAGG;AACH,KAAK,MAAM,CAAC,KAAK,SAAS,MAAM,IAAI,KAAK,SAAS,GAAG,MAAM,KAAK,IAAI,MAAM,KAAK,EAAE,GAC3E,MAAM,CAAC,GAAG,KAAK,IAAI,KAAK,EAAE,CAAC,GAC3B,KAAK,CAAC;AAEZ;;;GAGG;AACH,KAAK,SAAS,CAAC,KAAK,SAAS,MAAM,IAAI,KAAK,SAAS,GAAG,MAAM,KAAK,IAAI,MAAM,KAAK,EAAE,GAC9E,GAAG,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,GACzC,KAAK,CAAC;AAEZ;;;;;GAKG;AACH,KAAK,cAAc,CAAC,WAAW,IAAI,MAAM,SAAS,MAAM,WAAW,GAC7D,KAAK,GACL,SAAS,CAAC,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC;AAEpD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AC5B,CAAC;AAwCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,iBAAS,aAAa,CAClB,CAAC,SAAS,QAAQ,EAClB,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,EAChF,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;AAyU1G,OAAO,EAAE,KAAK,SAAS,EAAE,aAAa,EAAE,CAAC"}
@@ -6,7 +6,9 @@ import { buildPropertyDispatch, GET_PROPERTY_VFUNC, makeGetProperty, makeSetProp
6
6
  import { getClassType, getInterfaceMixin, markDerivedClass, registerClassType, } from "./registry.js";
7
7
  import { TYPE_INTERFACE, TYPE_INVALID, typeFundamental, typeInterfaces, typeIsA } from "./type.js";
8
8
  import { findClassVfuncDescriptor, findInterfaceVfuncDescriptor } from "./vfunc.js";
9
+ const INSTANCE_ARG_INDEX = 0;
9
10
  const VALUE_ARG_INDEX = 2;
11
+ const TEARDOWN_VFUNC_NAMES = new Set(["dispose", "finalize"]);
10
12
  const PROPERTY_VFUNC_SPECS = [
11
13
  { methodName: GET_PROPERTY_VFUNC, isValueOut: true, makeDispatch: makeGetProperty },
12
14
  { methodName: SET_PROPERTY_VFUNC, isValueOut: false, makeDispatch: makeSetProperty },
@@ -106,10 +108,12 @@ function buildDiscoveredVfunc(fn, methodName, resolveDescriptor, skip) {
106
108
  if (!descriptor) {
107
109
  return undefined;
108
110
  }
111
+ const argDescriptors = slotArgDescriptors(descriptor);
109
112
  return {
110
113
  ...descriptor,
111
114
  methodName,
112
- fn: wrapVfunc(fn, descriptor.argDescriptors, descriptor.returnDescriptor),
115
+ argDescriptors,
116
+ fn: wrapVfunc(fn, argDescriptors, descriptor),
113
117
  };
114
118
  }
115
119
  function collectDiscoveredVfuncs(methods, resolveDescriptor, skip) {
@@ -125,8 +129,8 @@ function collectDiscoveredVfuncs(methods, resolveDescriptor, skip) {
125
129
  function discoverClassVfuncs(klass, methods) {
126
130
  return collectDiscoveredVfuncs(methods, (methodName) => findClassVfuncDescriptor(klass, methodName) ?? undefined, PROPERTY_VFUNC_NAMES);
127
131
  }
128
- function wrapVfunc(fn, argDescriptors, returnDescriptor) {
129
- return wrapCallback(fn, { argDescriptors, returnDescriptor }, "this");
132
+ function wrapVfunc(fn, argDescriptors, descriptor) {
133
+ return wrapCallback(fn, { argDescriptors, returnDescriptor: descriptor.returnDescriptor }, "vfunc");
130
134
  }
131
135
  function discoverInterfaceBindings(methods, parentGtype, declaredTypes, claimedMethodNames) {
132
136
  const declared = new Set(declaredTypes);
@@ -155,8 +159,18 @@ function propertyVfuncFor(source, spec) {
155
159
  function propertyVfuncs(source) {
156
160
  return PROPERTY_VFUNC_SPECS.map((spec) => propertyVfuncFor(source, spec)).filter((vfunc) => vfunc !== undefined);
157
161
  }
158
- function markValueCallerAllocated(argDescriptors) {
159
- return argDescriptors.map((arg, index) => index === VALUE_ARG_INDEX ? { ...arg, isCallerAllocated: true } : arg);
162
+ function markArg(argDescriptors, index, patch) {
163
+ return argDescriptors.map((arg, at) => (at === index ? { ...arg, ...patch } : arg));
164
+ }
165
+ function isTeardownSlot(descriptor) {
166
+ return (TEARDOWN_VFUNC_NAMES.has(descriptor.vfuncName) &&
167
+ descriptor.argDescriptors[INSTANCE_ARG_INDEX]?.kind === "object");
168
+ }
169
+ function slotArgDescriptors(descriptor) {
170
+ if (!isTeardownSlot(descriptor)) {
171
+ return descriptor.argDescriptors;
172
+ }
173
+ return markArg(descriptor.argDescriptors, INSTANCE_ARG_INDEX, { isCallScoped: true });
160
174
  }
161
175
  function buildPropertyVfunc(klass, methodName, fn, isValueOut) {
162
176
  const descriptor = findClassVfuncDescriptor(klass, methodName);
@@ -164,13 +178,13 @@ function buildPropertyVfunc(klass, methodName, fn, isValueOut) {
164
178
  throw new Error(`registerClass: the parent class exposes no '${methodName}' vtable slot`);
165
179
  }
166
180
  const argDescriptors = isValueOut
167
- ? markValueCallerAllocated(descriptor.argDescriptors)
181
+ ? markArg(descriptor.argDescriptors, VALUE_ARG_INDEX, { isCallerAllocated: true })
168
182
  : descriptor.argDescriptors;
169
183
  return {
170
184
  ...descriptor,
171
185
  methodName,
172
186
  argDescriptors,
173
- fn: wrapVfunc(fn, argDescriptors, descriptor.returnDescriptor),
187
+ fn: wrapVfunc(fn, argDescriptors, descriptor),
174
188
  };
175
189
  }
176
190
  function toNativeInterface(binding) {
@@ -1 +1 @@
1
- {"version":3,"file":"register-class.js","sourceRoot":"","sources":["../src/register-class.ts"],"names":[],"mappings":"AACA,OAAO,EACH,aAAa,IAAI,mBAAmB,GAIvC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAiB,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,eAAe,EAGf,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AA4IpF,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,MAAM,oBAAoB,GAAwB;IAC9C,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE;IACnF,EAAE,UAAU,EAAE,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UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,eAAe,CAAC,UAAU,GAAG,UAAU,CAAC;IAC5C,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED,SAAS,eAAe,CACpB,WAA8B,EAC9B,iBAA0C,EAC1C,UAAwC;IAExC,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAEzD,IAAI,CAAC,cAAc,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,EAAE,CAAC;QACtD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,OAAO,GAA+B,EAAE,CAAC;IAE/C,IAAI,aAAa,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACjB,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,OAAO,EAAkB,aAAa,EAAE,CAAC","sourcesContent":["import type { Descriptor } from \"@gtkx/native\";\nimport {\n registerClass as nativeRegisterClass,\n type RegisterClassInterface as NativeRegisterClassInterface,\n type RegisterClassOptions as NativeRegisterClassOptions,\n type RegisterClassVfunc as NativeRegisterClassVfunc,\n} from \"@gtkx/native\";\nimport { type AnyClass, getParentClass, walkClassChain } from \"@gtkx/utils\";\nimport { wrapCallback } from \"./callback.js\";\nimport { insertMixinLayer } from \"./mixin.js\";\nimport {\n buildPropertyDispatch,\n GET_PROPERTY_VFUNC,\n makeGetProperty,\n makeSetProperty,\n type PropertyDispatch,\n type PropertySpec,\n SET_PROPERTY_VFUNC,\n toNativeProperties,\n} from \"./properties.js\";\nimport {\n getClassType,\n getInterfaceMixin,\n markDerivedClass,\n registerClassType,\n type VfuncDescriptor,\n} from \"./registry.js\";\nimport { TYPE_INTERFACE, TYPE_INVALID, typeFundamental, typeInterfaces, typeIsA } from \"./type.js\";\nimport { findClassVfuncDescriptor, findInterfaceVfuncDescriptor } from \"./vfunc.js\";\n\n/**\n * A generated interface value, such as `Gio.ListModel`, in the form {@link registerClass} takes it.\n * `__impl__` exists only in the type system: it carries the interface's `Impl` type, of which a class\n * has to match every member it declares itself, which rejects a class value and a member whose\n * signature does not fit the slot it fills. Leaving a slot to the interface is not rejected,\n * because `registerClass` does not reject it either: every member of an `Impl` type is optional,\n * and the `Partial` holds that open whatever the type declares. The `object` beside it keeps\n * TypeScript from also demanding one member in common. An interface that introspection describes\n * no vtable for carries `unknown`, since it has no slot a class could fill.\n */\ntype Interface<TImpl> = AnyClass & {\n /** Type-level slot holding the interface's `Impl` type; no value ever carries it. */\n __impl__: (impl: Partial<TImpl> & object) => void;\n};\n\n/**\n * One key of `RegisterClassOptions.properties` with every underscore turned into the dash a canonical\n * GObject property name separates its words with.\n */\ntype Dashed<TName extends string> = TName extends `${infer THead}_${infer TTail}`\n ? Dashed<`${THead}-${TTail}`>\n : TName;\n\n/**\n * One dashed key in the camelCase spelling the accessors {@link registerClass} installs carry, which is\n * the spelling the hooks that address a property by name take.\n */\ntype Camelized<TName extends string> = TName extends `${infer THead}-${infer TTail}`\n ? `${THead}${Capitalize<Camelized<TTail>>}`\n : TName;\n\n/**\n * The names a registered class carries in its property map: every key of\n * `RegisterClassOptions.properties` in camelCase, whichever of the three spellings it was written in.\n * A `properties` object given a type of its own rather than left to inference has `string` for its key\n * type and names nothing, because a name only known as `string` addresses no member in particular.\n */\ntype InstalledNames<TProperties> = string extends keyof TProperties\n ? never\n : Camelized<Dashed<keyof TProperties & string>>;\n\n/**\n * An instance of a registered class: everything the class itself declares, plus the property map the\n * hooks that address a property by name, such as `useProperty` from `@gtkx/react`, read the installed\n * names off. Each name is typed with the value type the class declares for the member of that name,\n * so a property the class does not `declare` contributes nothing.\n */\ntype RegisteredInstance<TInstance, TProperties> = TInstance & {\n /** Type-level map from installed property name to value type; no value ever carries it. */\n __properties__: Pick<TInstance, InstalledNames<TProperties> & keyof TInstance>;\n};\n\n/**\n * The construct signature and prototype a registered class carries, both giving\n * {@link RegisteredInstance}. The signature stays abstract for as long as the class itself is, so\n * registering an abstract base leaves it as impossible to construct as it was.\n */\ntype RegisteredConstructor<TClass, TArgs extends unknown[], TInstance> = {\n /** Object the class's instances inherit from. */\n prototype: TInstance;\n} & (TClass extends new (...args: never) => unknown\n ? new (...args: TArgs) => TInstance\n : abstract new (...args: TArgs) => TInstance);\n\n/**\n * The class {@link registerClass} hands back: the same class, with the same statics, whose instances\n * carry the properties `RegisterClassOptions.properties` installed. Binding the call to a name, rather\n * than discarding it, is what carries those names into the type system.\n */\ntype RegisteredClass<TClass extends AnyClass, TProperties> =\n TClass extends abstract new (...args: infer TArgs) => infer TInstance\n ? Omit<TClass, \"prototype\"> & RegisteredConstructor<TClass, TArgs, RegisteredInstance<TInstance, TProperties>>\n : never;\n\n/** What {@link registerClass} adds to the new GType beyond the vtable slots it discovers on the class. */\ntype RegisterClassOptions<TInstance extends object, TProperties extends Record<string, PropertySpec>> = {\n /** Name to register the new GType under, defaulting to the class's own name. */\n typeName?: string;\n /**\n * Interfaces the new type implements on top of the ones it inherits, given as the interface values\n * themselves, such as `Gio.ListModel`. Their vtable slots are filled from the `vfunc`-prefixed methods on\n * the class's prototype chain, each of which has to match the interface's `Impl` type, such as\n * `Gio.ListModelImpl`.\n */\n implements?: Interface<TInstance>[];\n /**\n * Properties to install on the new type, keyed by the name JavaScript addresses each one by and\n * valued with the `GObject.ParamSpec` describing it. A key is read in camelCase however it is\n * written, so `dewPoint`, `dew_point` and `dew-point` all name the same member, and the ParamSpec\n * has to carry the canonical spelling of that name, `dew-point`, or registration throws: the\n * ParamSpec's name is the one GObject emits `notify` with, and a name the key does not spell\n * reaches nothing that listens for it. Every property gains prototype accessors, one for the key\n * as written, one for it with dashes turned into underscores and one for it in camelCase, each\n * unless the class already defines that name. They serve the value from storage of their own on\n * the instance, which is also what the type's `get_property` and `set_property` slots read and\n * write, so a value set from JavaScript, from `g_object_set_property` and at construction all\n * land in the same place.\n *\n * A write the ParamSpec would refuse throws rather than reaching GObject, which reports such a\n * write as a GLib critical and drops it: a `TypeError` for a read-only or construct-only\n * property and for a value of a type the property cannot hold, and a `RangeError` for a value\n * the ParamSpec rejects. The same two checks run over a value handed to the constructor, where\n * a construct-only property is the one that is writable. An accepted write emits one `notify`,\n * which a `freeze_notify` batch collects; a write of the value the property already holds is\n * dropped and emits none.\n *\n * A class that defines the camelCase member itself owns the property: its own accessor decides\n * what a write means, the other two spellings forward to it, and the type's property slots read\n * and write it rather than the generated storage.\n */\n properties?: TProperties;\n};\n\n/** {@link RegisterClassOptions} with the widest instance and property types {@link registerClass} accepts. */\ntype AnyRegisterClassOptions = RegisterClassOptions<object, Record<string, PropertySpec>>;\ntype VfuncFn = NativeRegisterClassVfunc[\"fn\"];\ntype DiscoveredVfunc = VfuncDescriptor & { methodName: string; fn: VfuncFn };\ntype MethodTable = Map<string, VfuncFn>;\ntype InstanceMembers = { methods: MethodTable; names: Set<string>; inheritedNames: Set<string> };\n\ntype InterfaceVfuncBinding = {\n gtype: bigint;\n vfuncs: DiscoveredVfunc[];\n};\n\ntype PropertyVfuncSource = {\n klass: AnyClass;\n methods: MethodTable;\n dispatch: PropertyDispatch;\n adoptedTypes: bigint[];\n};\n\ntype PropertyVfuncSpec = {\n methodName: string;\n isValueOut: boolean;\n makeDispatch: (dispatch: PropertyDispatch) => VfuncFn;\n};\n\nconst VALUE_ARG_INDEX = 2;\n\nconst PROPERTY_VFUNC_SPECS: PropertyVfuncSpec[] = [\n { methodName: GET_PROPERTY_VFUNC, isValueOut: true, makeDispatch: makeGetProperty },\n { methodName: SET_PROPERTY_VFUNC, isValueOut: false, makeDispatch: makeSetProperty },\n];\n\nconst PROPERTY_VFUNC_NAMES: Set<string> = new Set(PROPERTY_VFUNC_SPECS.map((spec) => spec.methodName));\n\n/**\n * Registers a subclass of a wrapper class as a new GType, wiring up any class and interface\n * virtual functions it overrides, both for the interfaces it inherits and for the ones\n * `RegisterClassOptions.implements` names.\n *\n * Throws when the class does not extend a registered wrapper class, when it has no derivable type\n * name, when an entry in `RegisterClassOptions.implements` is not a registered interface, when a\n * listed interface has a prerequisite that neither the parent type nor another listed interface meets,\n * and when an entry in `RegisterClassOptions.properties` names its `GObject.ParamSpec` something other\n * than the canonical spelling of the key it sits under.\n *\n * A slot is filled from the `vfunc`-prefixed methods on the class's prototype chain, up to but not\n * including the registered ancestor the class extends, so a method an intermediate base class\n * declares fills a slot the same way one the class itself declares does. A slot nothing on that\n * chain fills is left untouched.\n *\n * Declare every slot as a method: a class field holding a function, such as `vfuncGetNItems = () => 1`,\n * is assigned to each instance after registration and never reaches the vtable.\n *\n * An override of `vfuncConstructed` runs from inside the base constructor, before JavaScript\n * installs the subclass's field initializers and runs its constructor body, so a field still\n * reads `undefined` there and reading a `#private` field throws. Declare state the override\n * touches without an initializer, and assign private state from the constructor body after\n * `super()`. An instance a native caller creates, through `GObject.newv` or `Gtk.Builder`,\n * never runs the subclass constructor at all, so its declared fields stay uninitialized for\n * the object's whole life.\n *\n * @param klass The subclass to register.\n * @param options What the new GType gains beyond the vtable slots the class overrides.\n * @returns The same class, now registered, with every name in `options.properties` in its property map.\n */\nfunction registerClass<\n T extends AnyClass,\n TProperties extends Record<string, PropertySpec> = Record<never, PropertySpec>,\n>(klass: T, options?: RegisterClassOptions<T[\"prototype\"], TProperties>): RegisteredClass<T, TProperties>;\n\nfunction registerClass(klass: AnyClass, options: AnyRegisterClassOptions = {}): AnyClass {\n const parentType = resolveParentType(klass);\n\n if (parentType === TYPE_INVALID) {\n throw new TypeError(`registerClass: ${klass.name} must extend a registered wrapper class`);\n }\n\n const name = options.typeName ?? klass.name;\n\n if (!name) {\n throw new Error(\"registerClass: cannot derive a GType name (anonymous class with no typeName option)\");\n }\n\n const declaredTypes = resolveInterfaceTypes(klass, options.implements ?? []);\n const adoptedTypes = declaredTypes.filter((gtype) => !typeIsA(parentType, gtype));\n const properties = options.properties ?? {};\n const { methods, inheritedNames } = collectInstanceMembers(klass);\n const dispatch = buildPropertyDispatch({ klass, properties, adoptedTypes });\n\n const classVfuncs = [\n ...discoverClassVfuncs(klass, methods),\n ...propertyVfuncs({ klass, methods, dispatch, adoptedTypes }),\n ];\n\n const claimedMethodNames = new Set(classVfuncs.map((vfunc) => vfunc.methodName));\n const interfaceBindings = discoverInterfaceBindings(methods, parentType, declaredTypes, claimedMethodNames);\n const nativeOptions = toNativeOptions(classVfuncs, interfaceBindings, properties);\n const newType: bigint = nativeRegisterClass(name, parentType, nativeOptions);\n registerClassType(klass, newType);\n markDerivedClass(klass);\n applyInterfaceMixins(klass, adoptedTypes, inheritedNames);\n\n return klass;\n}\n\nfunction resolveInterfaceType(klass: AnyClass, entry: AnyClass): bigint {\n const gtype = getClassType(entry);\n\n if (typeFundamental(gtype) !== TYPE_INTERFACE) {\n const label = typeof entry === \"function\" ? entry.name : String(entry);\n\n throw new TypeError(\n `registerClass: ${klass.name} lists '${label}' in implements, which is not a registered interface`,\n );\n }\n\n return gtype;\n}\n\nfunction resolveInterfaceTypes(klass: AnyClass, entries: AnyClass[]): bigint[] {\n return [...new Set(entries.map((entry) => resolveInterfaceType(klass, entry)))];\n}\n\nfunction applyInterfaceMixins(klass: AnyClass, adoptedTypes: bigint[], inheritedNames: Set<string>): void {\n for (const gtype of adoptedTypes) {\n const mixin = getInterfaceMixin(gtype);\n\n if (mixin !== undefined) {\n insertMixinLayer(klass, mixin, inheritedNames);\n }\n }\n}\n\nfunction resolveParentType(klass: AnyClass): bigint {\n return (\n walkClassChain(getParentClass(klass), (cls) => {\n const gtype = getClassType(cls);\n\n return gtype === TYPE_INVALID ? undefined : gtype;\n }) ?? TYPE_INVALID\n );\n}\n\nfunction addOwnMember(members: InstanceMembers, proto: object, name: string, isInherited: boolean): void {\n if (name === \"constructor\") {\n return;\n }\n\n if (isInherited) {\n members.inheritedNames.add(name);\n }\n\n if (members.names.has(name)) {\n return;\n }\n\n members.names.add(name);\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n\n if (typeof descriptor?.value === \"function\") {\n members.methods.set(name, descriptor.value as VfuncFn);\n }\n}\n\nfunction addOwnMembers(members: InstanceMembers, klass: AnyClass, isInherited: boolean): void {\n const proto = (klass as { prototype?: object }).prototype;\n\n if (proto === undefined) {\n return;\n }\n\n for (const name of Object.getOwnPropertyNames(proto)) {\n addOwnMember(members, proto, name, isInherited);\n }\n}\n\nfunction collectInstanceMembers(klass: AnyClass): InstanceMembers {\n const members: InstanceMembers = { methods: new Map(), names: new Set(), inheritedNames: new Set() };\n let cls: AnyClass | null = klass;\n\n while (cls !== null && getClassType(cls) === TYPE_INVALID) {\n addOwnMembers(members, cls, cls !== klass);\n cls = getParentClass(cls);\n }\n\n return members;\n}\n\nfunction buildDiscoveredVfunc(\n fn: VfuncFn,\n methodName: string,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip: Set<string> | undefined,\n): DiscoveredVfunc | undefined {\n if (skip?.has(methodName)) {\n return undefined;\n }\n\n const descriptor = resolveDescriptor(methodName);\n\n if (!descriptor) {\n return undefined;\n }\n\n return {\n ...descriptor,\n methodName,\n fn: wrapVfunc(fn, descriptor.argDescriptors, descriptor.returnDescriptor),\n };\n}\n\nfunction collectDiscoveredVfuncs(\n methods: MethodTable,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip?: Set<string>,\n): DiscoveredVfunc[] {\n const result: DiscoveredVfunc[] = [];\n\n for (const [methodName, fn] of methods) {\n const discovered = buildDiscoveredVfunc(fn, methodName, resolveDescriptor, skip);\n\n if (discovered) {\n result.push(discovered);\n }\n }\n\n return result;\n}\n\nfunction discoverClassVfuncs(klass: AnyClass, methods: MethodTable): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findClassVfuncDescriptor(klass, methodName) ?? undefined,\n PROPERTY_VFUNC_NAMES,\n );\n}\n\nfunction wrapVfunc(\n fn: VfuncFn,\n argDescriptors: NativeRegisterClassVfunc[\"argDescriptors\"],\n returnDescriptor: NativeRegisterClassVfunc[\"returnDescriptor\"],\n): VfuncFn {\n return wrapCallback(fn as (...args: unknown[]) => unknown, { argDescriptors, returnDescriptor }, \"this\");\n}\n\nfunction discoverInterfaceBindings(\n methods: MethodTable,\n parentGtype: bigint,\n declaredTypes: bigint[],\n claimedMethodNames: Set<string>,\n): InterfaceVfuncBinding[] {\n const declared: Set<bigint> = new Set(declaredTypes);\n const gtypes: Set<bigint> = new Set([...typeInterfaces(parentGtype), ...declaredTypes]);\n const bindings: InterfaceVfuncBinding[] = [];\n\n for (const gtype of gtypes) {\n const vfuncs = discoverInterfaceVfuncs(methods, gtype, claimedMethodNames);\n\n if (vfuncs.length > 0 || declared.has(gtype)) {\n bindings.push({ gtype, vfuncs });\n }\n }\n\n return bindings;\n}\n\nfunction discoverInterfaceVfuncs(\n methods: MethodTable,\n interfaceGtype: bigint,\n claimedMethodNames: Set<string>,\n): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findInterfaceVfuncDescriptor(interfaceGtype, methodName),\n claimedMethodNames,\n );\n}\n\nconst hasDispatchedProperties = (dispatch: PropertyDispatch, adoptedTypes: bigint[]): boolean =>\n dispatch.accessors.length > 0 || adoptedTypes.length > 0;\n\nfunction propertyVfuncFor(\n source: PropertyVfuncSource,\n spec: PropertyVfuncSpec,\n): DiscoveredVfunc | undefined {\n const { klass, methods, dispatch, adoptedTypes } = source;\n\n const dispatched = hasDispatchedProperties(dispatch, adoptedTypes)\n ? spec.makeDispatch(dispatch)\n : undefined;\n\n const fn = methods.get(spec.methodName) ?? dispatched;\n\n return fn === undefined ? undefined : buildPropertyVfunc(klass, spec.methodName, fn, spec.isValueOut);\n}\n\nfunction propertyVfuncs(source: PropertyVfuncSource): DiscoveredVfunc[] {\n return PROPERTY_VFUNC_SPECS.map((spec) => propertyVfuncFor(source, spec)).filter(\n (vfunc) => vfunc !== undefined,\n );\n}\n\nfunction markValueCallerAllocated(argDescriptors: Descriptor[]): Descriptor[] {\n return argDescriptors.map((arg, index) =>\n index === VALUE_ARG_INDEX ? { ...arg, isCallerAllocated: true } : arg);\n}\n\nfunction buildPropertyVfunc(\n klass: AnyClass,\n methodName: string,\n fn: VfuncFn,\n isValueOut: boolean,\n): DiscoveredVfunc {\n const descriptor = findClassVfuncDescriptor(klass, methodName);\n\n if (!descriptor) {\n throw new Error(`registerClass: the parent class exposes no '${methodName}' vtable slot`);\n }\n\n const argDescriptors = isValueOut\n ? markValueCallerAllocated(descriptor.argDescriptors)\n : descriptor.argDescriptors;\n\n return {\n ...descriptor,\n methodName,\n argDescriptors,\n fn: wrapVfunc(fn, argDescriptors, descriptor.returnDescriptor),\n };\n}\n\nfunction toNativeInterface(binding: InterfaceVfuncBinding): NativeRegisterClassInterface {\n const nativeInterface: NativeRegisterClassInterface = {\n type: binding.gtype,\n vfuncs: [...binding.vfuncs],\n };\n\n const vtableSize = binding.vfuncs[0]?.vtableSize;\n\n if (vtableSize !== undefined) {\n nativeInterface.vtableSize = vtableSize;\n }\n\n return nativeInterface;\n}\n\nfunction toNativeOptions(\n classVfuncs: DiscoveredVfunc[],\n interfaceBindings: InterfaceVfuncBinding[],\n properties: Record<string, PropertySpec>,\n): NativeRegisterClassOptions | undefined {\n const hasInterfaces = interfaceBindings.length > 0;\n const hasClassVfuncs = classVfuncs.length > 0;\n const hasProperties = Object.keys(properties).length > 0;\n\n if (!hasClassVfuncs && !hasInterfaces && !hasProperties) {\n return undefined;\n }\n\n const options: NativeRegisterClassOptions = {};\n\n if (hasProperties) {\n options.properties = toNativeProperties(properties);\n }\n\n if (hasClassVfuncs) {\n options.vfuncs = [...classVfuncs];\n }\n\n if (hasInterfaces) {\n options.interfaces = interfaceBindings.map((binding) => toNativeInterface(binding));\n }\n\n return options;\n}\n\nexport { type Interface, registerClass };\n"]}
1
+ {"version":3,"file":"register-class.js","sourceRoot":"","sources":["../src/register-class.ts"],"names":[],"mappings":"AACA,OAAO,EACH,aAAa,IAAI,mBAAmB,GAIvC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAiB,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,eAAe,EAGf,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AA4KpF,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,oBAAoB,GAAgB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;AAE3E,MAAM,oBAAoB,GAAwB;IAC9C,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE;IACnF,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU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,CAAC,MAAM,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,OAAO,EAAkB,aAAa,EAAE,CAAC","sourcesContent":["import type { Descriptor } from \"@gtkx/native\";\nimport {\n registerClass as nativeRegisterClass,\n type RegisterClassInterface as NativeRegisterClassInterface,\n type RegisterClassOptions as NativeRegisterClassOptions,\n type RegisterClassVfunc as NativeRegisterClassVfunc,\n} from \"@gtkx/native\";\nimport { type AnyClass, getParentClass, walkClassChain } from \"@gtkx/utils\";\nimport { wrapCallback } from \"./callback.js\";\nimport { insertMixinLayer } from \"./mixin.js\";\nimport {\n buildPropertyDispatch,\n GET_PROPERTY_VFUNC,\n makeGetProperty,\n makeSetProperty,\n type PropertyDispatch,\n type PropertySpec,\n SET_PROPERTY_VFUNC,\n toNativeProperties,\n} from \"./properties.js\";\nimport {\n getClassType,\n getInterfaceMixin,\n markDerivedClass,\n registerClassType,\n type VfuncDescriptor,\n} from \"./registry.js\";\nimport { TYPE_INTERFACE, TYPE_INVALID, typeFundamental, typeInterfaces, typeIsA } from \"./type.js\";\nimport { findClassVfuncDescriptor, findInterfaceVfuncDescriptor } from \"./vfunc.js\";\n\n/**\n * A generated interface value, such as `Gio.ListModel`, in the form {@link registerClass} takes it.\n * `__impl__` exists only in the type system: it carries the interface's `Impl` type, of which a class\n * has to match every member it declares itself, which rejects a class value and a member whose\n * signature does not fit the slot it fills. Leaving a slot to the interface is not rejected,\n * because `registerClass` does not reject it either: every member of an `Impl` type is optional,\n * and the `Partial` holds that open whatever the type declares. The `object` beside it keeps\n * TypeScript from also demanding one member in common. An interface that introspection describes\n * no vtable for carries `unknown`, since it has no slot a class could fill.\n */\ntype Interface<TImpl> = AnyClass & {\n /** Type-level slot holding the interface's `Impl` type; no value ever carries it. */\n __impl__: (impl: Partial<TImpl> & object) => void;\n};\n\n/**\n * One key of `RegisterClassOptions.properties` with every underscore turned into the dash a canonical\n * GObject property name separates its words with.\n */\ntype Dashed<TName extends string> = TName extends `${infer THead}_${infer TTail}`\n ? Dashed<`${THead}-${TTail}`>\n : TName;\n\n/**\n * One dashed key in the camelCase spelling the accessors {@link registerClass} installs carry, which is\n * the spelling the hooks that address a property by name take.\n */\ntype Camelized<TName extends string> = TName extends `${infer THead}-${infer TTail}`\n ? `${THead}${Capitalize<Camelized<TTail>>}`\n : TName;\n\n/**\n * The names a registered class carries in its property map: every key of\n * `RegisterClassOptions.properties` in camelCase, whichever spelling it was written in.\n * A `properties` object given a type of its own rather than left to inference has `string` for its key\n * type and names nothing, because a name only known as `string` addresses no member in particular.\n */\ntype InstalledNames<TProperties> = string extends keyof TProperties\n ? never\n : Camelized<Dashed<keyof TProperties & string>>;\n\n/**\n * An instance of a registered class: everything the class itself declares, plus the property map the\n * hooks that address a property by name, such as `useProperty` from `@gtkx/react`, read the installed\n * names off. Each name is typed with the value type the class declares for the member of that name,\n * so a property the class does not `declare` contributes nothing.\n */\ntype RegisteredInstance<TInstance, TProperties> = TInstance & {\n /** Type-level map from installed property name to value type; no value ever carries it. */\n __properties__: Pick<TInstance, InstalledNames<TProperties> & keyof TInstance>;\n};\n\n/**\n * The construct signature and prototype a registered class carries, both giving\n * {@link RegisteredInstance}. The signature stays abstract for as long as the class itself is, so\n * registering an abstract base leaves it as impossible to construct as it was.\n */\ntype RegisteredConstructor<TClass, TArgs extends unknown[], TInstance> = {\n /** Object the class's instances inherit from. */\n prototype: TInstance;\n} & (TClass extends new (...args: never) => unknown\n ? new (...args: TArgs) => TInstance\n : abstract new (...args: TArgs) => TInstance);\n\n/**\n * The class {@link registerClass} hands back: the same class, with the same statics, whose instances\n * carry the properties `RegisterClassOptions.properties` installed. Binding the call to a name, rather\n * than discarding it, is what carries those names into the type system.\n */\ntype RegisteredClass<TClass extends AnyClass, TProperties> =\n TClass extends abstract new (...args: infer TArgs) => infer TInstance\n ? Omit<TClass, \"prototype\"> & RegisteredConstructor<TClass, TArgs, RegisteredInstance<TInstance, TProperties>>\n : never;\n\n/** What {@link registerClass} adds to the new GType beyond the vtable slots it discovers on the class. */\ntype RegisterClassOptions<TInstance extends object, TProperties extends Record<string, PropertySpec>> = {\n /** Name to register the new GType under, defaulting to the class's own name. */\n typeName?: string;\n /**\n * Interfaces the new type implements on top of the ones it inherits, given as the interface values\n * themselves, such as `Gio.ListModel`. Their vtable slots are filled from the `vfunc`-prefixed methods on\n * the class's prototype chain, each of which has to match the interface's `Impl` type, such as\n * `Gio.ListModelImpl`.\n */\n implements?: Interface<TInstance>[];\n /**\n * Properties to install on the new type, keyed by the name JavaScript addresses each one by and\n * valued with the `GObject.ParamSpec` describing it. A key is read in camelCase however it is\n * written, so `dewPoint`, `dew_point` and `dew-point` all name the same member, and the ParamSpec\n * has to carry the canonical spelling of that name, `dew-point`, or registration throws: the\n * ParamSpec's name is the one GObject emits `notify` with, and a name the key does not spell\n * reaches nothing that listens for it. Every property gains prototype accessors, one for the key\n * as written, one for it with dashes turned into underscores and one for it in camelCase, each\n * unless the class already defines that name. They serve the value from storage of their own on\n * the instance, which is also what the type's `get_property` and `set_property` slots read and\n * write, so a value set from JavaScript, from `g_object_set_property` and at construction all\n * land in the same place.\n *\n * A write the ParamSpec would refuse throws rather than reaching GObject, which reports such a\n * write as a GLib critical and drops it: a `TypeError` for a read-only or construct-only\n * property and for a value of a type the property cannot hold, and a `RangeError` for a value\n * the ParamSpec rejects. The same checks run over a value handed to the constructor, where\n * a construct-only property is the one that is writable. An accepted write emits one `notify`,\n * which a `freeze_notify` batch collects; a write of the value the property already holds is\n * dropped and emits none.\n *\n * `null` and `undefined` both mean NULL, and mean it only where the ParamSpec's own type holds\n * NULL, which is a string, string-array, boxed, object, interface, param, variant or pointer\n * property. Such a property holds the `null` either spelling wrote, so the member, the type's\n * `get_property` slot and `g_object_get_property` serve the same thing, and writing the other\n * spelling over it emits no `notify`. Every other property, so every integer, floating-point,\n * boolean, enum, flags and GType one, refuses both with the same `TypeError` it refuses a\n * string with, and keeps the value it already holds. It refuses them for what it holds rather\n * than for its range, whatever that range is: the type is checked before the range, so a\n * `gint` whose range excludes 0 answers a nullish with that same `TypeError` and never with\n * the `RangeError` that names the value GObject would put in its place. The one place\n * `undefined` means something else is the constructor, which reads it as the property not\n * being given at all and leaves it at the ParamSpec's default, so a property is never handed a\n * value it cannot serve back.\n *\n * A floating-point property takes every JavaScript number, `NaN` and both infinities\n * included, and its ParamSpec alone rules on which of them the range admits: a `gdouble`\n * bounded by `-Infinity` and `Infinity` holds either infinity, and a magnitude a bounded\n * one excludes, like any `NaN`, comes back as the `RangeError` that names what GObject\n * would put in its place rather than as the `TypeError` a type the property cannot hold\n * earns. A `gfloat` property holds what GObject narrows the double to, so it serves `0.1`\n * back as `0.10000000149011612` and a finite magnitude no `gfloat` reaches as an infinity,\n * which the range then rules on in turn. That narrowing belongs to the property alone: the\n * same magnitude written to a `gfloat` through a generated binding, a signal argument or a\n * closure return is refused outright rather than narrowed.\n *\n * A generated property of a wrapped type answers a nullish differently, and the two halves of\n * the API disagree here: that property marshals what it is written through its descriptor\n * rather than through the checks above, so `new Gtk.Label({ widthRequest: null })` and a later\n * write of `null` to that member both land 0, where a `gint` installed here refuses both.\n *\n * A class that defines the camelCase member itself owns the property: its own accessor decides\n * what a write means, the other spellings forward to it, and the type's property slots read\n * and write it rather than the generated storage.\n */\n properties?: TProperties;\n};\n\n/** {@link RegisterClassOptions} with the widest instance and property types {@link registerClass} accepts. */\ntype AnyRegisterClassOptions = RegisterClassOptions<object, Record<string, PropertySpec>>;\ntype VfuncFn = NativeRegisterClassVfunc[\"fn\"];\ntype DiscoveredVfunc = VfuncDescriptor & { methodName: string; fn: VfuncFn };\ntype MethodTable = Map<string, VfuncFn>;\ntype InstanceMembers = { methods: MethodTable; names: Set<string>; inheritedNames: Set<string> };\n\ntype InterfaceVfuncBinding = {\n gtype: bigint;\n vfuncs: DiscoveredVfunc[];\n};\n\ntype PropertyVfuncSource = {\n klass: AnyClass;\n methods: MethodTable;\n dispatch: PropertyDispatch;\n adoptedTypes: bigint[];\n};\n\ntype PropertyVfuncSpec = {\n methodName: string;\n isValueOut: boolean;\n makeDispatch: (dispatch: PropertyDispatch) => VfuncFn;\n};\n\ntype ArgPatch = { isCallerAllocated: true } | { isCallScoped: true };\n\nconst INSTANCE_ARG_INDEX = 0;\nconst VALUE_ARG_INDEX = 2;\nconst TEARDOWN_VFUNC_NAMES: Set<string> = new Set([\"dispose\", \"finalize\"]);\n\nconst PROPERTY_VFUNC_SPECS: PropertyVfuncSpec[] = [\n { methodName: GET_PROPERTY_VFUNC, isValueOut: true, makeDispatch: makeGetProperty },\n { methodName: SET_PROPERTY_VFUNC, isValueOut: false, makeDispatch: makeSetProperty },\n];\n\nconst PROPERTY_VFUNC_NAMES: Set<string> = new Set(PROPERTY_VFUNC_SPECS.map((spec) => spec.methodName));\n\n/**\n * Registers a subclass of a wrapper class as a new GType, wiring up any class and interface\n * virtual functions it overrides, both for the interfaces it inherits and for the ones\n * `RegisterClassOptions.implements` names.\n *\n * Throws when the class does not extend a registered wrapper class, when it has no derivable type\n * name, when an entry in `RegisterClassOptions.implements` is not a registered interface, when a\n * listed interface has a prerequisite that neither the parent type nor another listed interface meets,\n * and when an entry in `RegisterClassOptions.properties` names its `GObject.ParamSpec` something other\n * than the canonical spelling of the key it sits under.\n *\n * A slot is filled from the `vfunc`-prefixed methods on the class's prototype chain, up to but not\n * including the registered ancestor the class extends, so a method an intermediate base class\n * declares fills a slot the same way one the class itself declares does. A slot nothing on that\n * chain fills is left untouched.\n *\n * Declare every slot as a method: a class field holding a function, such as `vfuncGetNItems = () => 1`,\n * is assigned to each instance after registration and never reaches the vtable.\n *\n * An override of `vfuncConstructed` runs from inside the base constructor, before JavaScript\n * installs the subclass's field initializers and runs its constructor body, so a field still\n * reads `undefined` there and reading a `#private` field throws. Declare state the override\n * touches without an initializer, and assign private state from the constructor body after\n * `super()`. An instance a native caller creates, through `GObject.newv` or `Gtk.Builder`,\n * never runs the subclass constructor at all, so its declared fields stay uninitialized for\n * the object's whole life.\n *\n * @param klass The subclass to register.\n * @param options What the new GType gains beyond the vtable slots the class overrides.\n * @returns The same class, now registered, with every name in `options.properties` in its property map.\n */\nfunction registerClass<\n T extends AnyClass,\n TProperties extends Record<string, PropertySpec> = Record<never, PropertySpec>,\n>(klass: T, options?: RegisterClassOptions<T[\"prototype\"], TProperties>): RegisteredClass<T, TProperties>;\n\nfunction registerClass(klass: AnyClass, options: AnyRegisterClassOptions = {}): AnyClass {\n const parentType = resolveParentType(klass);\n\n if (parentType === TYPE_INVALID) {\n throw new TypeError(`registerClass: ${klass.name} must extend a registered wrapper class`);\n }\n\n const name = options.typeName ?? klass.name;\n\n if (!name) {\n throw new Error(\"registerClass: cannot derive a GType name (anonymous class with no typeName option)\");\n }\n\n const declaredTypes = resolveInterfaceTypes(klass, options.implements ?? []);\n const adoptedTypes = declaredTypes.filter((gtype) => !typeIsA(parentType, gtype));\n const properties = options.properties ?? {};\n const { methods, inheritedNames } = collectInstanceMembers(klass);\n const dispatch = buildPropertyDispatch({ klass, properties, adoptedTypes });\n\n const classVfuncs = [\n ...discoverClassVfuncs(klass, methods),\n ...propertyVfuncs({ klass, methods, dispatch, adoptedTypes }),\n ];\n\n const claimedMethodNames = new Set(classVfuncs.map((vfunc) => vfunc.methodName));\n const interfaceBindings = discoverInterfaceBindings(methods, parentType, declaredTypes, claimedMethodNames);\n const nativeOptions = toNativeOptions(classVfuncs, interfaceBindings, properties);\n const newType: bigint = nativeRegisterClass(name, parentType, nativeOptions);\n registerClassType(klass, newType);\n markDerivedClass(klass);\n applyInterfaceMixins(klass, adoptedTypes, inheritedNames);\n\n return klass;\n}\n\nfunction resolveInterfaceType(klass: AnyClass, entry: AnyClass): bigint {\n const gtype = getClassType(entry);\n\n if (typeFundamental(gtype) !== TYPE_INTERFACE) {\n const label = typeof entry === \"function\" ? entry.name : String(entry);\n\n throw new TypeError(\n `registerClass: ${klass.name} lists '${label}' in implements, which is not a registered interface`,\n );\n }\n\n return gtype;\n}\n\nfunction resolveInterfaceTypes(klass: AnyClass, entries: AnyClass[]): bigint[] {\n return [...new Set(entries.map((entry) => resolveInterfaceType(klass, entry)))];\n}\n\nfunction applyInterfaceMixins(klass: AnyClass, adoptedTypes: bigint[], inheritedNames: Set<string>): void {\n for (const gtype of adoptedTypes) {\n const mixin = getInterfaceMixin(gtype);\n\n if (mixin !== undefined) {\n insertMixinLayer(klass, mixin, inheritedNames);\n }\n }\n}\n\nfunction resolveParentType(klass: AnyClass): bigint {\n return (\n walkClassChain(getParentClass(klass), (cls) => {\n const gtype = getClassType(cls);\n\n return gtype === TYPE_INVALID ? undefined : gtype;\n }) ?? TYPE_INVALID\n );\n}\n\nfunction addOwnMember(members: InstanceMembers, proto: object, name: string, isInherited: boolean): void {\n if (name === \"constructor\") {\n return;\n }\n\n if (isInherited) {\n members.inheritedNames.add(name);\n }\n\n if (members.names.has(name)) {\n return;\n }\n\n members.names.add(name);\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n\n if (typeof descriptor?.value === \"function\") {\n members.methods.set(name, descriptor.value as VfuncFn);\n }\n}\n\nfunction addOwnMembers(members: InstanceMembers, klass: AnyClass, isInherited: boolean): void {\n const proto = (klass as { prototype?: object }).prototype;\n\n if (proto === undefined) {\n return;\n }\n\n for (const name of Object.getOwnPropertyNames(proto)) {\n addOwnMember(members, proto, name, isInherited);\n }\n}\n\nfunction collectInstanceMembers(klass: AnyClass): InstanceMembers {\n const members: InstanceMembers = { methods: new Map(), names: new Set(), inheritedNames: new Set() };\n let cls: AnyClass | null = klass;\n\n while (cls !== null && getClassType(cls) === TYPE_INVALID) {\n addOwnMembers(members, cls, cls !== klass);\n cls = getParentClass(cls);\n }\n\n return members;\n}\n\nfunction buildDiscoveredVfunc(\n fn: VfuncFn,\n methodName: string,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip: Set<string> | undefined,\n): DiscoveredVfunc | undefined {\n if (skip?.has(methodName)) {\n return undefined;\n }\n\n const descriptor = resolveDescriptor(methodName);\n\n if (!descriptor) {\n return undefined;\n }\n\n const argDescriptors = slotArgDescriptors(descriptor);\n\n return {\n ...descriptor,\n methodName,\n argDescriptors,\n fn: wrapVfunc(fn, argDescriptors, descriptor),\n };\n}\n\nfunction collectDiscoveredVfuncs(\n methods: MethodTable,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip?: Set<string>,\n): DiscoveredVfunc[] {\n const result: DiscoveredVfunc[] = [];\n\n for (const [methodName, fn] of methods) {\n const discovered = buildDiscoveredVfunc(fn, methodName, resolveDescriptor, skip);\n\n if (discovered) {\n result.push(discovered);\n }\n }\n\n return result;\n}\n\nfunction discoverClassVfuncs(klass: AnyClass, methods: MethodTable): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findClassVfuncDescriptor(klass, methodName) ?? undefined,\n PROPERTY_VFUNC_NAMES,\n );\n}\n\nfunction wrapVfunc(\n fn: VfuncFn,\n argDescriptors: NativeRegisterClassVfunc[\"argDescriptors\"],\n descriptor: VfuncDescriptor,\n): VfuncFn {\n return wrapCallback(\n fn as (...args: unknown[]) => unknown,\n { argDescriptors, returnDescriptor: descriptor.returnDescriptor },\n \"vfunc\",\n );\n}\n\nfunction discoverInterfaceBindings(\n methods: MethodTable,\n parentGtype: bigint,\n declaredTypes: bigint[],\n claimedMethodNames: Set<string>,\n): InterfaceVfuncBinding[] {\n const declared: Set<bigint> = new Set(declaredTypes);\n const gtypes: Set<bigint> = new Set([...typeInterfaces(parentGtype), ...declaredTypes]);\n const bindings: InterfaceVfuncBinding[] = [];\n\n for (const gtype of gtypes) {\n const vfuncs = discoverInterfaceVfuncs(methods, gtype, claimedMethodNames);\n\n if (vfuncs.length > 0 || declared.has(gtype)) {\n bindings.push({ gtype, vfuncs });\n }\n }\n\n return bindings;\n}\n\nfunction discoverInterfaceVfuncs(\n methods: MethodTable,\n interfaceGtype: bigint,\n claimedMethodNames: Set<string>,\n): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findInterfaceVfuncDescriptor(interfaceGtype, methodName),\n claimedMethodNames,\n );\n}\n\nconst hasDispatchedProperties = (dispatch: PropertyDispatch, adoptedTypes: bigint[]): boolean =>\n dispatch.accessors.length > 0 || adoptedTypes.length > 0;\n\nfunction propertyVfuncFor(\n source: PropertyVfuncSource,\n spec: PropertyVfuncSpec,\n): DiscoveredVfunc | undefined {\n const { klass, methods, dispatch, adoptedTypes } = source;\n\n const dispatched = hasDispatchedProperties(dispatch, adoptedTypes)\n ? spec.makeDispatch(dispatch)\n : undefined;\n\n const fn = methods.get(spec.methodName) ?? dispatched;\n\n return fn === undefined ? undefined : buildPropertyVfunc(klass, spec.methodName, fn, spec.isValueOut);\n}\n\nfunction propertyVfuncs(source: PropertyVfuncSource): DiscoveredVfunc[] {\n return PROPERTY_VFUNC_SPECS.map((spec) => propertyVfuncFor(source, spec)).filter(\n (vfunc) => vfunc !== undefined,\n );\n}\n\nfunction markArg(argDescriptors: Descriptor[], index: number, patch: ArgPatch): Descriptor[] {\n return argDescriptors.map((arg, at) => (at === index ? { ...arg, ...patch } : arg));\n}\n\nfunction isTeardownSlot(descriptor: VfuncDescriptor): boolean {\n return (\n TEARDOWN_VFUNC_NAMES.has(descriptor.vfuncName) &&\n descriptor.argDescriptors[INSTANCE_ARG_INDEX]?.kind === \"object\"\n );\n}\n\nfunction slotArgDescriptors(descriptor: VfuncDescriptor): Descriptor[] {\n if (!isTeardownSlot(descriptor)) {\n return descriptor.argDescriptors;\n }\n\n return markArg(descriptor.argDescriptors, INSTANCE_ARG_INDEX, { isCallScoped: true });\n}\n\nfunction buildPropertyVfunc(\n klass: AnyClass,\n methodName: string,\n fn: VfuncFn,\n isValueOut: boolean,\n): DiscoveredVfunc {\n const descriptor = findClassVfuncDescriptor(klass, methodName);\n\n if (!descriptor) {\n throw new Error(`registerClass: the parent class exposes no '${methodName}' vtable slot`);\n }\n\n const argDescriptors = isValueOut\n ? markArg(descriptor.argDescriptors, VALUE_ARG_INDEX, { isCallerAllocated: true })\n : descriptor.argDescriptors;\n\n return {\n ...descriptor,\n methodName,\n argDescriptors,\n fn: wrapVfunc(fn, argDescriptors, descriptor),\n };\n}\n\nfunction toNativeInterface(binding: InterfaceVfuncBinding): NativeRegisterClassInterface {\n const nativeInterface: NativeRegisterClassInterface = {\n type: binding.gtype,\n vfuncs: [...binding.vfuncs],\n };\n\n const vtableSize = binding.vfuncs[0]?.vtableSize;\n\n if (vtableSize !== undefined) {\n nativeInterface.vtableSize = vtableSize;\n }\n\n return nativeInterface;\n}\n\nfunction toNativeOptions(\n classVfuncs: DiscoveredVfunc[],\n interfaceBindings: InterfaceVfuncBinding[],\n properties: Record<string, PropertySpec>,\n): NativeRegisterClassOptions | undefined {\n const hasInterfaces = interfaceBindings.length > 0;\n const hasClassVfuncs = classVfuncs.length > 0;\n const hasProperties = Object.keys(properties).length > 0;\n\n if (!hasClassVfuncs && !hasInterfaces && !hasProperties) {\n return undefined;\n }\n\n const options: NativeRegisterClassOptions = {};\n\n if (hasProperties) {\n options.properties = toNativeProperties(properties);\n }\n\n if (hasClassVfuncs) {\n options.vfuncs = [...classVfuncs];\n }\n\n if (hasInterfaces) {\n options.interfaces = interfaceBindings.map((binding) => toNativeInterface(binding));\n }\n\n return options;\n}\n\nexport { type Interface, registerClass };\n"]}
@@ -3,10 +3,13 @@ import { type AnyClass } from "@gtkx/utils";
3
3
  import type { Mixin } from "./mixin.js";
4
4
  import { type TypedClass } from "./type.js";
5
5
  /**
6
- * Static side of class `C` with its construct signature preserved but the member
7
- * named `K` (default `"new"`) removed.
6
+ * Static side of class `C` with its construct signature preserved but the members named `K`
7
+ * removed. A generated class lists every static it declares itself, so a static it narrows never
8
+ * has to stay assignable to the one it shadows. The signature is kept abstract so an abstract `C`
9
+ * survives it: a subclass extends the result, and only the subclass's own declarations decide
10
+ * which statics reach it.
8
11
  */
9
- type StaticBase<C, K extends PropertyKey = "new"> = Omit<C, K> & (C extends new (...args: infer A) => infer R ? new (...args: A) => R : never);
12
+ type StaticBase<C, K extends PropertyKey> = Omit<C, K> & (C extends abstract new (...args: infer A) => infer R ? abstract new (...args: A) => R : never);
10
13
  /** One overridable vtable slot: where it sits in the vtable struct and how it is marshalled. */
11
14
  type VfuncDescriptor = {
12
15
  /** GIR name of the type struct holding the slot, without its namespace, such as `WidgetClass`. */
@@ -25,6 +28,12 @@ type VfuncDescriptor = {
25
28
  argDescriptors: NativeRegisterClassVfunc["argDescriptors"];
26
29
  /** Descriptor for the value the slot returns. */
27
30
  returnDescriptor: NativeRegisterClassVfunc["returnDescriptor"];
31
+ /**
32
+ * GIR marks the slot's return value as one the bindings do not surface, so a call through the
33
+ * slot drops it and an implementation of the slot reports success in its place, while
34
+ * `VfuncDescriptor.returnDescriptor` keeps the C type the slot is called against either way.
35
+ */
36
+ isReturnSkipped?: boolean;
28
37
  /**
29
38
  * The slot takes a trailing `GError**` that `VfuncDescriptor.argDescriptors` leaves out, the
30
39
  * way GIR leaves it out of a callable's parameters. A call through the slot has to append it
@@ -120,6 +129,7 @@ declare function getWrapperClass(type: bigint): AnyClass;
120
129
  declare function resolveWrapperClass(type: bigint): AnyClass | null;
121
130
  declare function getInterfaceMixin(type: bigint): Mixin | undefined;
122
131
  declare function wrapObject(value: unknown): object | null;
132
+ declare function wrapCallScopedObject(value: unknown): object | null;
123
133
  declare function instanceClassName(instance: object): string;
124
134
  /** Returns the native handle bound to a wrapper instance, throwing if none is set. */
125
135
  declare function getHandle(instance: object): ExternalObject<Handle>;
@@ -129,5 +139,5 @@ declare function registerWrapper(handle: ExternalObject<Handle>, instance: objec
129
139
  declare function getVfuncRegistry(cls: object): VfuncRegistry | undefined;
130
140
  declare function getInterfaceVfuncRegistry(type: bigint): VfuncRegistry | undefined;
131
141
  declare function getInterfaceProperties(type: bigint): Record<string, InterfaceProperty> | undefined;
132
- export { getClassType, getInstanceType, markDerivedClass, registerClassType, registerWrapperClass, registerInterface, wrapHandle, getWrapperClass, resolveWrapperClass, getHandle, setHandle, getVfuncRegistry, getInterfaceMixin, getInterfaceProperties, getInterfaceVfuncRegistry, instanceClassName, registerWrapper, resolveWrapperType, wrapObject, type InterfaceProperty, type StaticBase, type VfuncDescriptor, };
142
+ export { getClassType, getInstanceType, markDerivedClass, registerClassType, registerWrapperClass, registerInterface, wrapHandle, getWrapperClass, resolveWrapperClass, getHandle, setHandle, getVfuncRegistry, getInterfaceMixin, getInterfaceProperties, getInterfaceVfuncRegistry, instanceClassName, registerWrapper, resolveWrapperType, wrapCallScopedObject, wrapObject, type InterfaceProperty, type StaticBase, type VfuncDescriptor, };
133
143
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,kBAAkB,IAAI,wBAAwB,EAEtD,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAiB,MAAM,YAAY,CAAC;AACvD,OAAO,EAAgB,KAAK,UAAU,EAAiD,MAAM,WAAW,CAAC;AAEzG;;;GAGG;AACH,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAC1D,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AAElF,gGAAgG;AAChG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