@gtkx/codegen 1.1.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 (149) hide show
  1. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  2. package/dist/analysis/descriptor-render.js +14 -10
  3. package/dist/analysis/descriptor-render.js.map +1 -1
  4. package/dist/analysis/descriptor.d.ts +11 -5
  5. package/dist/analysis/descriptor.d.ts.map +1 -1
  6. package/dist/analysis/descriptor.js +25 -9
  7. package/dist/analysis/descriptor.js.map +1 -1
  8. package/dist/analysis/interface-conflicts.d.ts +3 -1
  9. package/dist/analysis/interface-conflicts.d.ts.map +1 -1
  10. package/dist/analysis/interface-conflicts.js +3 -8
  11. package/dist/analysis/interface-conflicts.js.map +1 -1
  12. package/dist/analysis/ts-type.d.ts +3 -2
  13. package/dist/analysis/ts-type.d.ts.map +1 -1
  14. package/dist/analysis/ts-type.js +16 -9
  15. package/dist/analysis/ts-type.js.map +1 -1
  16. package/dist/analysis/type-shape.d.ts +3 -2
  17. package/dist/analysis/type-shape.d.ts.map +1 -1
  18. package/dist/analysis/type-shape.js +2 -1
  19. package/dist/analysis/type-shape.js.map +1 -1
  20. package/dist/compile.d.ts +4 -5
  21. package/dist/compile.d.ts.map +1 -1
  22. package/dist/compile.js +56 -4
  23. package/dist/compile.js.map +1 -1
  24. package/dist/docs/api-reference.d.ts +2 -0
  25. package/dist/docs/api-reference.d.ts.map +1 -1
  26. package/dist/docs/api-reference.js +1 -1
  27. package/dist/docs/api-reference.js.map +1 -1
  28. package/dist/docs/pipeline.d.ts +1 -0
  29. package/dist/docs/pipeline.d.ts.map +1 -1
  30. package/dist/docs/pipeline.js +10 -3
  31. package/dist/docs/pipeline.js.map +1 -1
  32. package/dist/docs/symbol-page.d.ts.map +1 -1
  33. package/dist/docs/symbol-page.js +1 -3
  34. package/dist/docs/symbol-page.js.map +1 -1
  35. package/dist/fingerprint.d.ts +11 -5
  36. package/dist/fingerprint.d.ts.map +1 -1
  37. package/dist/fingerprint.js +22 -19
  38. package/dist/fingerprint.js.map +1 -1
  39. package/dist/gi.d.ts +1 -0
  40. package/dist/gi.d.ts.map +1 -1
  41. package/dist/gi.js +7 -2
  42. package/dist/gi.js.map +1 -1
  43. package/dist/gir/gir-path.d.ts +1 -1
  44. package/dist/gir/gir-path.js +1 -1
  45. package/dist/gir/gir-path.js.map +1 -1
  46. package/dist/gir/library.d.ts +5 -1
  47. package/dist/gir/library.d.ts.map +1 -1
  48. package/dist/gir/library.js +8 -1
  49. package/dist/gir/library.js.map +1 -1
  50. package/dist/gir/parse.d.ts.map +1 -1
  51. package/dist/gir/parse.js +4 -1
  52. package/dist/gir/parse.js.map +1 -1
  53. package/dist/gir/primitives.js +1 -1
  54. package/dist/gir/primitives.js.map +1 -1
  55. package/dist/khronos/args.d.ts.map +1 -1
  56. package/dist/khronos/args.js +8 -6
  57. package/dist/khronos/args.js.map +1 -1
  58. package/dist/khronos/render.d.ts.map +1 -1
  59. package/dist/khronos/render.js +8 -4
  60. package/dist/khronos/render.js.map +1 -1
  61. package/dist/runner.d.ts +2 -0
  62. package/dist/runner.d.ts.map +1 -1
  63. package/dist/runner.js +5 -3
  64. package/dist/runner.js.map +1 -1
  65. package/dist/staging.d.ts.map +1 -1
  66. package/dist/staging.js +1 -1
  67. package/dist/staging.js.map +1 -1
  68. package/dist/store/compile-store.d.ts +0 -1
  69. package/dist/store/compile-store.d.ts.map +1 -1
  70. package/dist/store/compile-store.js +7 -34
  71. package/dist/store/compile-store.js.map +1 -1
  72. package/dist/store/gi/callables.d.ts +1 -3
  73. package/dist/store/gi/callables.d.ts.map +1 -1
  74. package/dist/store/gi/callables.js +19 -4
  75. package/dist/store/gi/callables.js.map +1 -1
  76. package/dist/store/gi/class.d.ts.map +1 -1
  77. package/dist/store/gi/class.js +48 -9
  78. package/dist/store/gi/class.js.map +1 -1
  79. package/dist/store/gi/constant.js +1 -1
  80. package/dist/store/gi/constant.js.map +1 -1
  81. package/dist/store/gi/enum.d.ts.map +1 -1
  82. package/dist/store/gi/enum.js +2 -5
  83. package/dist/store/gi/enum.js.map +1 -1
  84. package/dist/store/gi/interface.js +2 -2
  85. package/dist/store/gi/interface.js.map +1 -1
  86. package/dist/store/gi/method.d.ts.map +1 -1
  87. package/dist/store/gi/method.js +4 -7
  88. package/dist/store/gi/method.js.map +1 -1
  89. package/dist/store/gi/property-accessor.d.ts +0 -3
  90. package/dist/store/gi/property-accessor.d.ts.map +1 -1
  91. package/dist/store/gi/property-accessor.js +15 -108
  92. package/dist/store/gi/property-accessor.js.map +1 -1
  93. package/dist/store/gi/record-constructor.js +3 -3
  94. package/dist/store/gi/record-constructor.js.map +1 -1
  95. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  96. package/dist/store/gi/record-field-accessor.js +15 -3
  97. package/dist/store/gi/record-field-accessor.js.map +1 -1
  98. package/dist/store/gi/return-wrap.js +1 -1
  99. package/dist/store/gi/return-wrap.js.map +1 -1
  100. package/dist/store/gi/signal.d.ts.map +1 -1
  101. package/dist/store/gi/signal.js +25 -4
  102. package/dist/store/gi/signal.js.map +1 -1
  103. package/dist/store/jsx-store.d.ts.map +1 -1
  104. package/dist/store/jsx-store.js +0 -1
  105. package/dist/store/jsx-store.js.map +1 -1
  106. package/dist/store/store-fs.d.ts +0 -1
  107. package/dist/store/store-fs.d.ts.map +1 -1
  108. package/dist/store/store-fs.js +2 -7
  109. package/dist/store/store-fs.js.map +1 -1
  110. package/dist/xml.d.ts +1 -0
  111. package/dist/xml.d.ts.map +1 -1
  112. package/dist/xml.js +28 -1
  113. package/dist/xml.js.map +1 -1
  114. package/overrides/gobject/object.ts.ejs +2 -0
  115. package/package.json +3 -3
  116. package/src/analysis/descriptor-render.ts +19 -10
  117. package/src/analysis/descriptor.ts +43 -9
  118. package/src/analysis/interface-conflicts.ts +6 -8
  119. package/src/analysis/ts-type.ts +30 -11
  120. package/src/analysis/type-shape.ts +5 -2
  121. package/src/compile.ts +87 -6
  122. package/src/docs/api-reference.ts +3 -1
  123. package/src/docs/pipeline.ts +13 -7
  124. package/src/docs/symbol-page.ts +0 -4
  125. package/src/fingerprint.ts +31 -38
  126. package/src/gi.ts +9 -2
  127. package/src/gir/gir-path.ts +1 -1
  128. package/src/gir/library.ts +9 -1
  129. package/src/gir/parse.ts +6 -1
  130. package/src/gir/primitives.ts +1 -1
  131. package/src/khronos/args.ts +9 -6
  132. package/src/khronos/render.ts +8 -6
  133. package/src/runner.ts +7 -3
  134. package/src/staging.ts +1 -3
  135. package/src/store/compile-store.ts +7 -40
  136. package/src/store/gi/callables.ts +26 -7
  137. package/src/store/gi/class.ts +63 -7
  138. package/src/store/gi/constant.ts +1 -1
  139. package/src/store/gi/enum.ts +2 -6
  140. package/src/store/gi/interface.ts +2 -2
  141. package/src/store/gi/method.ts +4 -9
  142. package/src/store/gi/property-accessor.ts +22 -193
  143. package/src/store/gi/record-constructor.ts +3 -3
  144. package/src/store/gi/record-field-accessor.ts +18 -3
  145. package/src/store/gi/return-wrap.ts +1 -1
  146. package/src/store/gi/signal.ts +30 -4
  147. package/src/store/jsx-store.ts +0 -1
  148. package/src/store/store-fs.ts +3 -9
  149. package/src/xml.ts +43 -1
@@ -1 +1 @@
1
- {"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/store/gi/method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAI7D,OAAO,EACH,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,GAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EAEjB,eAAe,EACf,mBAAmB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAqB,oBAAoB,EAA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AC;IAE1C,OAAO,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC;AACvE,CAAC,CAAC;AAEF,OAAO,EACH,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,GACf,CAAC","sourcesContent":["import { camelCase, sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { GirType } from \"../../gir/type.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport {\n isSkippedPrimaryReturn,\n renderCallbackType,\n renderDescriptor,\n renderSelfDescriptor,\n shouldOmitPrimaryReturn,\n} from \"../../analysis/descriptor-render.js\";\nimport {\n arrayLengthSources,\n closureAndDestroyIndices,\n emittedArgIndices,\n foldedLengthIndices,\n foldOutParamShape,\n type InputParameter,\n inputParameters,\n parameterIdentifier,\n} from \"../../analysis/param-structure.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { type GirParameter, isCallerAllocatedOut, isInoutParameter, isOutParameter } from \"../../gir/parameter.js\";\nimport { hasUnknownArrayLength, type TypeId } from \"../../gir/type-id.js\";\nimport { areClosuresInvoked } from \"./closure-invocation.js\";\nimport { itemComparatorArgDescriptors, itemComparatorTsType } from \"./item-comparators.js\";\nimport {\n isClosureType,\n isCollectibleCallerOut,\n isHandlePassedInPlace,\n isHandlePassing,\n renderCallerOutInstance,\n} from \"./param-marshal.js\";\n\ntype PromisifiedStep = { hasSeenOptional: boolean; expression: string | undefined };\n\ntype InputParameterOptions = {\n shouldSkip: (parameter: GirParameter) => boolean;\n isOptionalExtra: (parameter: GirParameter) => boolean;\n};\n\ntype CallExpressionOptions = {\n fn: GirFunction;\n isForcedNullable?: boolean | undefined;\n};\n\ntype PromisifyContext = {\n context: ModuleContext;\n asyncFn: GirFunction;\n closureIndices: Set<number>;\n lengthSources: Map<number, number>;\n};\n\ntype WriteMethodBodyOptions = {\n bindingExpression: string;\n returnTypeOverride?: string | undefined;\n};\n\ntype CallArgPlan = {\n paramLiteral: string;\n inputExpr: string | undefined;\n};\n\ntype ReturnDescriptorPlan = {\n descriptor: string;\n isSkipped: boolean;\n};\n\ntype ParamDescriptorOptions = {\n direction?: \"out\" | \"inout\";\n isCallerAllocated?: boolean;\n isConsumed?: boolean;\n};\n\ntype ArgIndexOptions = {\n argIndexOffset: number;\n argIndexMap: Map<number, number>;\n};\n\ntype PlanArgsContext = {\n fn: GirFunction;\n instanceOffset: number;\n argIndex: ArgIndexOptions;\n lengthSources: Map<number, number>;\n closureIndices: Set<number>;\n folded: Set<number>;\n};\n\nconst memberName = (girName: string): string => {\n const camel = camelCase(girName);\n\n return /^\\d/.test(camel) ? `_${camel}` : camel;\n};\n\nconst methodExportName = (fn: GirFunction): string => memberName(fn.name);\n\nconst arrayLengthArgument = (source: GirParameter, sourceIndex: number): string => {\n const identifier = parameterIdentifier(source, sourceIndex);\n\n return source.nullable || source.optional ? `(${identifier}?.length ?? 0)` : `${identifier}.length`;\n};\n\nconst renderMethodSignature = (context: ModuleContext, fn: GirFunction): string =>\n renderInputParameters(context, fn, {\n shouldSkip: () => false,\n isOptionalExtra: () => false,\n });\n\nconst closureAnnotation = (context: ModuleContext, base: string): string => {\n context.addRuntimeTypeImport(\"ClosureCallback\");\n\n return `${base} | ClosureCallback`;\n};\n\nconst requiresClosureMarshal = (context: ModuleContext, fn: GirFunction, ref: TypeId): boolean =>\n isClosureType(context, ref) && areClosuresInvoked(fn);\n\nconst requiresClosureAnnotation = (context: ModuleContext, fn: GirFunction, parameter: GirParameter): boolean =>\n parameter.type !== undefined && requiresClosureMarshal(context, fn, parameter.type);\n\nconst parameterAnnotation = (context: ModuleContext, fn: GirFunction, parameter: GirParameter): string => {\n const comparator = itemComparatorTsType(context, fn, parameter);\n\n if (comparator !== undefined) {\n return comparator;\n }\n\n const base = renderTsType(context, parameter.type, parameter.nullable);\n\n return requiresClosureAnnotation(context, fn, parameter) ? closureAnnotation(context, base) : base;\n};\n\nconst isParameterOptional = (parameter: GirParameter, isOptionalExtra: (parameter: GirParameter) => boolean): boolean =>\n parameter.optional || isOptionalExtra(parameter);\n\nconst formatParameterPart = (name: string, annotation: string, isOptional: boolean): string =>\n isOptional ? `${name}?: ${annotation}` : `${name}: ${annotation}`;\n\nconst renderInputParameters = (context: ModuleContext, fn: GirFunction, options: InputParameterOptions): string => {\n const parts: string[] = [];\n let hasSeenOptional = false;\n\n for (const { parameter, index } of inputParameters(context.library, fn)) {\n if (options.shouldSkip(parameter)) {\n continue;\n }\n\n const name = parameterIdentifier(parameter, index);\n\n if (isParameterOptional(parameter, options.isOptionalExtra)) {\n hasSeenOptional = true;\n }\n\n const annotation = parameterAnnotation(context, fn, parameter);\n parts.push(formatParameterPart(name, annotation, hasSeenOptional));\n }\n\n return parts.join(\", \");\n};\n\nconst isReturnedOutParameter = (context: ModuleContext, parameter: GirParameter): boolean =>\n isOutParameter(parameter) ||\n (isCallerAllocatedOut(parameter) && isCollectibleCallerOut(context, parameter)) ||\n isInoutParameter(parameter);\n\nconst returnedOutParameters = (context: ModuleContext, fn: GirFunction): InputParameter[] => {\n const folded = foldedLengthIndices(context.library, fn);\n const result: InputParameter[] = [];\n\n for (const [index, parameter] of fn.parameters.entries()) {\n if (isReturnedOutParameter(context, parameter) && !folded.has(index)) {\n result.push({ parameter, index });\n }\n }\n\n return result;\n};\n\nconst renderMethodReturnType = (context: ModuleContext, fn: GirFunction): string => {\n const outs = returnedOutParameters(context, fn);\n\n const primary = shouldOmitPrimaryReturn(context.library, fn.returnValue)\n ? undefined\n : renderTsType(context, fn.returnValue.type, fn.returnValue.nullable);\n\n if (outs.length === 0) {\n return primary ?? \"void\";\n }\n\n const outTypes = outs.map(({ parameter }) => renderTsType(context, parameter.type, parameter.nullable));\n\n return foldOutParamShape(primary, outTypes);\n};\n\nconst classifyPromisifiedParameter = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n state: { cancellableIndex: number; hasSeenOptional: boolean },\n): PromisifiedStep => {\n if (parameter.isVarargs) {\n return { hasSeenOptional: state.hasSeenOptional, expression: undefined };\n }\n\n if (index === state.cancellableIndex) {\n return { hasSeenOptional: true, expression: undefined };\n }\n\n if (shouldSkipPromisifiedParameter(promisify, parameter, index)) {\n return { hasSeenOptional: state.hasSeenOptional, expression: undefined };\n }\n\n const hasSeenOptional = state.hasSeenOptional || parameter.optional;\n\n return { hasSeenOptional, expression: promisifiedArgument(promisify, parameter, index, hasSeenOptional) };\n};\n\nconst collectPromisifiedArguments = (promisify: PromisifyContext, cancellableIndex: number): string[] => {\n const expressions: string[] = [];\n let hasSeenOptional = false;\n\n for (const [index, parameter] of promisify.asyncFn.parameters.entries()) {\n const step = classifyPromisifiedParameter(promisify, parameter, index, {\n cancellableIndex,\n hasSeenOptional,\n });\n\n hasSeenOptional = step.hasSeenOptional;\n\n if (step.expression !== undefined) {\n expressions.push(step.expression);\n }\n }\n\n return expressions;\n};\n\nconst renderCancellableExpression = (parameters: GirParameter[], cancellableIndex: number): string => {\n if (cancellableIndex < 0) {\n return \"null\";\n }\n\n const parameter = parameters[cancellableIndex];\n\n return parameter === undefined ? \"null\" : parameterIdentifier(parameter, cancellableIndex);\n};\n\nconst renderPromisifiedBody = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishExpression: string,\n bindingExpression: string,\n): string => {\n context.addRuntimeImport(\"promisify\");\n const cancellableIndex = findCancellableIndex(context, asyncFn.parameters);\n\n const promisifyContext: PromisifyContext = {\n context,\n asyncFn,\n closureIndices: closureAndDestroyIndices(asyncFn),\n lengthSources: arrayLengthSources(context.library, asyncFn),\n };\n\n const leadingExpressions: string[] = [];\n\n if (asyncFn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n leadingExpressions.push(\"getHandle(this)\");\n }\n\n leadingExpressions.push(...collectPromisifiedArguments(promisifyContext, cancellableIndex));\n const cancellableExpression = renderCancellableExpression(asyncFn.parameters, cancellableIndex);\n const leadingArguments = leadingExpressions.length > 0 ? `, ${leadingExpressions.join(\", \")}` : \"\";\n\n return `return promisify(${bindingExpression}, ${finishExpression}, ${cancellableExpression}${leadingArguments});`;\n};\n\nconst finishCallExpression = (asyncFn: GirFunction, finishFn: GirFunction, ownerName: string): string =>\n asyncFn.instance !== undefined && finishFn.instance === undefined\n ? `${ownerName}.${methodExportName(finishFn)}.bind(${ownerName})`\n : `this.${methodExportName(finishFn)}.bind(this)`;\n\nconst shouldSkipPromisifiedParameter = (promisify: PromisifyContext, parameter: GirParameter, index: number): boolean =>\n isCallbackParameter(promisify.context, parameter) ||\n promisify.closureIndices.has(index) ||\n (isOutParameter(parameter) && !isCallerAllocatedOut(parameter));\n\nconst promisifiedArgument = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n hasSeenOptional: boolean,\n): string => {\n const { context, asyncFn, lengthSources } = promisify;\n const sourceIndex = lengthSources.get(index);\n const source = sourceIndex === undefined ? undefined : asyncFn.parameters[sourceIndex];\n\n if (sourceIndex !== undefined && source !== undefined) {\n return arrayLengthArgument(source, sourceIndex);\n }\n\n return parameterCallExpression(context, parameter, index, { fn: asyncFn, isForcedNullable: hasSeenOptional });\n};\n\nconst findCancellableIndex = (context: ModuleContext, parameters: GirParameter[]): number =>\n parameters.findIndex((parameter) => isCancellable(context, parameter));\n\nconst renderPromisifiedSignature = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishFn: GirFunction,\n): { signature: string; returnType: string } => {\n const signature = renderInputParameters(context, asyncFn, {\n shouldSkip: (parameter) => isCallbackParameter(context, parameter),\n isOptionalExtra: (parameter) => isCancellable(context, parameter),\n });\n\n const finishReturn = renderMethodReturnType(context, finishFn);\n\n return { signature, returnType: `Promise<${finishReturn}>` };\n};\n\nconst isCancellable = (context: ModuleContext, parameter: GirParameter): boolean =>\n parameter.type !== undefined && context.library.nameFor(parameter.type)?.typeName === \"Cancellable\";\n\nconst isCallbackParameter = (context: ModuleContext, parameter: GirParameter): boolean => {\n const ref = parameter.type;\n\n if (ref === undefined) {\n return false;\n }\n\n return context.library.typeFor(ref)?.kind === \"callback\";\n};\n\nconst renderMethodBody = (context: ModuleContext, fn: GirFunction, options: WriteMethodBodyOptions): string => {\n const { bindingExpression, returnTypeOverride } = options;\n\n const inputs = planCallArgs(context, fn)\n .map((arg) => arg.inputExpr)\n .filter((expression): expression is string => expression !== undefined);\n\n const callExpression = `${bindingExpression}(${inputs.join(\", \")})`;\n const annotation = returnTypeOverride ?? renderMethodReturnType(context, fn);\n\n return annotation === \"void\" ? `${callExpression};` : `return ${callExpression} as ${annotation};`;\n};\n\nconst paramDescriptorLiteral = (descriptor: string, options: ParamDescriptorOptions): string => {\n const parts = [`type: ${descriptor}`];\n\n if (options.direction !== undefined) {\n parts.push(`direction: ${sourceStringLiteral(options.direction)}`);\n }\n\n if (options.isCallerAllocated === true) {\n parts.push(\"isCallerAllocated: true\");\n }\n\n if (options.isConsumed === true) {\n parts.push(\"isConsumed: true\");\n }\n\n return `{ ${parts.join(\", \")} }`;\n};\n\nconst renderReturnDescriptor = (context: ModuleContext, fn: GirFunction): ReturnDescriptorPlan => {\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n const descriptor = renderDescriptor(context, fn.returnValue.type, fn.returnValue.transferOwnership, {\n argIndexOffset: instanceOffset,\n argIndexMap: emittedArgIndices(fn, instanceOffset),\n isNewlyCreated: fn.instance === undefined,\n });\n\n return { descriptor, isSkipped: isSkippedPrimaryReturn(context.library, fn.returnValue) };\n};\n\nconst planCallArgs = (context: ModuleContext, fn: GirFunction): CallArgPlan[] => {\n const plan: CallArgPlan[] = [];\n\n if (fn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n\n plan.push({\n paramLiteral: `{ type: ${renderSelfDescriptor(context, fn.instance)} }`,\n inputExpr: \"getHandle(this)\",\n });\n }\n\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n const planContext: PlanArgsContext = {\n fn,\n instanceOffset,\n argIndex: { argIndexOffset: instanceOffset, argIndexMap: emittedArgIndices(fn, instanceOffset) },\n lengthSources: arrayLengthSources(context.library, fn),\n closureIndices: closureAndDestroyIndices(fn),\n folded: foldedLengthIndices(context.library, fn),\n };\n\n for (const [index, parameter] of fn.parameters.entries()) {\n const entry = planParameter(context, parameter, index, planContext);\n\n if (entry !== undefined) {\n plan.push(entry);\n }\n }\n\n return plan;\n};\n\nconst isSkippedPlanParameter = (parameter: GirParameter, index: number, closureIndices: Set<number>): boolean =>\n parameter.isVarargs || closureIndices.has(index);\n\nconst planParameter = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan | undefined => {\n const { folded, closureIndices, lengthSources } = planContext;\n\n if (isSkippedPlanParameter(parameter, index, closureIndices)) {\n return undefined;\n }\n\n if (isOutParameter(parameter)) {\n return planOutParam(context, parameter, planContext.argIndex, folded.has(index));\n }\n\n if (isCallerAllocatedOut(parameter)) {\n return planCallerOut(context, parameter, planContext.argIndex);\n }\n\n if (isInoutParameter(parameter)) {\n return planInoutArgument(context, parameter, index, planContext);\n }\n\n const sourceIndex = lengthSources.get(index);\n\n if (sourceIndex !== undefined) {\n return planLengthArgument(context, parameter, sourceIndex, planContext);\n }\n\n return planInParam(context, parameter, index, planContext);\n};\n\nconst planInoutArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn, folded, lengthSources } = planContext;\n const lengthSourceIndex = lengthSources.get(index);\n const lengthSourceParam = lengthSourceIndex === undefined ? undefined : fn.parameters[lengthSourceIndex];\n\n const lengthSource =\n lengthSourceIndex !== undefined && lengthSourceParam !== undefined\n ? { source: lengthSourceParam, index: lengthSourceIndex }\n : undefined;\n\n return planInoutParam(context, parameter, {\n fn,\n index,\n argIndex: planContext.argIndex,\n isConsumed: folded.has(index),\n lengthSource,\n });\n};\n\nconst planLengthArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n sourceIndex: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const source = planContext.fn.parameters[sourceIndex];\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, planContext.argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: source === undefined ? \"0\" : arrayLengthArgument(source, sourceIndex),\n };\n};\n\nconst planOutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n isConsumed: boolean,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n ...argIndex,\n cursor: parameter.cursor,\n hasOutIndirection: true,\n });\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", isConsumed }),\n inputExpr: undefined,\n };\n};\n\nconst planCallerOut = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", argIndex);\n\n if (isCollectibleCallerOut(context, parameter)) {\n context.addRuntimeImport(\"getHandle\");\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", isCallerAllocated: true }),\n inputExpr: renderCallerOutInstance(context, parameter),\n };\n }\n\n return { paramLiteral: paramDescriptorLiteral(descriptor, {}), inputExpr: \"undefined\" };\n};\n\nconst planInoutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n options: {\n fn: GirFunction;\n index: number;\n argIndex: ArgIndexOptions;\n isConsumed: boolean;\n lengthSource?: { source: GirParameter; index: number } | undefined;\n },\n): CallArgPlan => {\n const { fn, index, argIndex, isConsumed, lengthSource } = options;\n\n if (isHandlePassedInPlace(context, parameter)) {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {\n direction: \"inout\",\n isCallerAllocated: true,\n isConsumed,\n }),\n inputExpr: parameterIdentifier(parameter, index),\n };\n }\n\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n ...argIndex,\n hasOutIndirection: true,\n });\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"inout\", isConsumed }),\n inputExpr:\n lengthSource === undefined\n ? parameterCallExpression(context, parameter, index, { fn })\n : arrayLengthArgument(lengthSource.source, lengthSource.index),\n };\n};\n\nconst planInParam = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn } = planContext;\n\n const callback = renderCallbackType(\n context,\n parameter.type,\n parameter,\n itemComparatorArgDescriptors(context, fn, parameter),\n );\n\n const descriptor =\n callback ??\n renderDescriptor(\n context,\n parameter.type,\n parameter.transferOwnership,\n planContext.argIndex,\n );\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: parameterCallExpression(context, parameter, index, { fn }),\n };\n};\n\nconst nullableHandleExpression = (name: string): string => `${name} == null ? null : getHandle(${name})`;\n\nconst handleArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n context.addRuntimeImport(\"getHandle\");\n\n return isNullable ? nullableHandleExpression(name) : `getHandle(${name})`;\n};\n\nconst closureArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n const helper = isNullable ? \"tryToClosure\" : \"toClosure\";\n context.addRuntimeImport(helper);\n\n return `${helper}(${name})`;\n};\n\nconst hashtableArgument = (context: ModuleContext, valueRef: TypeId, name: string): string => {\n if (isHandlePassing(context, valueRef)) {\n context.addRuntimeImport(\"getHandle\");\n\n return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, ${nullableHandleExpression(\"v\")}]) : null`;\n }\n\n return `${name} ? globalThis.Array.from(${name}) : null`;\n};\n\nconst mapHandleExpression = (name: string, isNullable: boolean): string =>\n isNullable ? `${name}?.map((item) => getHandle(item))` : `${name}.map((item) => getHandle(item))`;\n\nconst collectionArgument = (\n context: ModuleContext,\n type: GirType | undefined,\n name: string,\n isNullable: boolean,\n): string | undefined => {\n if (type?.kind === \"hashtable\") {\n return hashtableArgument(context, type.value, name);\n }\n\n if (!isMappableSequence(context, type)) {\n return undefined;\n }\n\n context.addRuntimeImport(\"getHandle\");\n\n return mapHandleExpression(name, isNullable);\n};\n\nconst isMappableSequence = (context: ModuleContext, type: GirType | undefined): boolean => {\n if (type?.kind === \"carray\") {\n return !hasUnknownArrayLength(type) && isHandlePassing(context, type.element);\n }\n\n return type?.kind === \"list\" && isHandlePassing(context, type.element);\n};\n\nconst parameterCallExpression = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n options: CallExpressionOptions,\n): string => {\n const { fn, isForcedNullable = false } = options;\n const name = parameterIdentifier(parameter, index);\n const ref = parameter.type;\n\n if (ref === undefined) {\n return name;\n }\n\n const isNullable = parameter.nullable || parameter.optional || isForcedNullable;\n\n if (requiresClosureMarshal(context, fn, ref)) {\n return closureArgument(context, name, isNullable);\n }\n\n if (isHandlePassing(context, ref)) {\n return handleArgument(context, name, isNullable);\n }\n\n const type = context.library.typeFor(ref);\n\n return collectionArgument(context, type, name, isNullable) ?? name;\n};\n\nexport {\n isCallbackParameter,\n memberName,\n methodExportName,\n renderMethodSignature,\n renderMethodReturnType,\n returnedOutParameters,\n renderPromisifiedBody,\n finishCallExpression,\n renderPromisifiedSignature,\n renderMethodBody,\n renderReturnDescriptor,\n planCallArgs,\n};\n"]}
1
+ {"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/store/gi/method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIpF,OAAO,EACH,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,GAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB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O,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC;AACvE,CAAC,CAAC;AAEF,OAAO,EACH,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,GACf,CAAC","sourcesContent":["import { camelCase, escapeIdentifierStart, sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { GirType } from \"../../gir/type.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport {\n isSkippedPrimaryReturn,\n renderCallbackType,\n renderDescriptor,\n renderSelfDescriptor,\n shouldOmitPrimaryReturn,\n} from \"../../analysis/descriptor-render.js\";\nimport {\n arrayLengthSources,\n closureAndDestroyIndices,\n emittedArgIndices,\n foldedLengthIndices,\n foldOutParamShape,\n type InputParameter,\n inputParameters,\n parameterIdentifier,\n} from \"../../analysis/param-structure.js\";\nimport { renderParameterTsType, renderTsType } from \"../../analysis/ts-type.js\";\nimport { type GirParameter, isCallerAllocatedOut, isInoutParameter, isOutParameter } from \"../../gir/parameter.js\";\nimport { hasUnknownArrayLength, type TypeId } from \"../../gir/type-id.js\";\nimport { areClosuresInvoked } from \"./closure-invocation.js\";\nimport { itemComparatorArgDescriptors, itemComparatorTsType } from \"./item-comparators.js\";\nimport {\n isClosureType,\n isCollectibleCallerOut,\n isHandlePassedInPlace,\n isHandlePassing,\n renderCallerOutInstance,\n} from \"./param-marshal.js\";\n\ntype PromisifiedStep = { hasSeenOptional: boolean; expression: string | undefined };\n\ntype InputParameterOptions = {\n shouldSkip: (parameter: GirParameter) => boolean;\n isOptionalExtra: (parameter: GirParameter) => boolean;\n};\n\ntype CallExpressionOptions = {\n fn: GirFunction;\n isForcedNullable?: boolean | undefined;\n};\n\ntype PromisifyContext = {\n context: ModuleContext;\n asyncFn: GirFunction;\n closureIndices: Set<number>;\n lengthSources: Map<number, number>;\n};\n\ntype WriteMethodBodyOptions = {\n bindingExpression: string;\n returnTypeOverride?: string | undefined;\n};\n\ntype CallArgPlan = {\n paramLiteral: string;\n inputExpr: string | undefined;\n};\n\ntype ReturnDescriptorPlan = {\n descriptor: string;\n isSkipped: boolean;\n};\n\ntype ParamDescriptorOptions = {\n direction?: \"out\" | \"inout\";\n isCallerAllocated?: boolean;\n isConsumed?: boolean;\n};\n\ntype ArgIndexOptions = {\n argIndexOffset: number;\n argIndexMap: Map<number, number>;\n};\n\ntype PlanArgsContext = {\n fn: GirFunction;\n instanceOffset: number;\n argIndex: ArgIndexOptions;\n lengthSources: Map<number, number>;\n closureIndices: Set<number>;\n folded: Set<number>;\n};\n\nconst memberName = (girName: string): string => escapeIdentifierStart(camelCase(girName));\nconst methodExportName = (fn: GirFunction): string => memberName(fn.name);\n\nconst arrayLengthArgument = (source: GirParameter, sourceIndex: number): string => {\n const identifier = parameterIdentifier(source, sourceIndex);\n\n return source.nullable || source.optional ? `(${identifier}?.length ?? 0)` : `${identifier}.length`;\n};\n\nconst renderMethodSignature = (context: ModuleContext, fn: GirFunction): string =>\n renderInputParameters(context, fn, {\n shouldSkip: () => false,\n isOptionalExtra: () => false,\n });\n\nconst closureAnnotation = (context: ModuleContext, base: string): string => {\n context.addRuntimeTypeImport(\"ClosureCallback\");\n\n return `${base} | ClosureCallback`;\n};\n\nconst requiresClosureMarshal = (context: ModuleContext, fn: GirFunction, ref: TypeId): boolean =>\n isClosureType(context, ref) && areClosuresInvoked(fn);\n\nconst requiresClosureAnnotation = (context: ModuleContext, fn: GirFunction, parameter: GirParameter): boolean =>\n parameter.type !== undefined && requiresClosureMarshal(context, fn, parameter.type);\n\nconst parameterAnnotation = (context: ModuleContext, fn: GirFunction, parameter: GirParameter): string => {\n const comparator = itemComparatorTsType(context, fn, parameter);\n\n if (comparator !== undefined) {\n return comparator;\n }\n\n const base = renderParameterTsType(context, parameter.type, parameter.nullable);\n\n return requiresClosureAnnotation(context, fn, parameter) ? closureAnnotation(context, base) : base;\n};\n\nconst isParameterOptional = (parameter: GirParameter, isOptionalExtra: (parameter: GirParameter) => boolean): boolean =>\n parameter.optional || isOptionalExtra(parameter);\n\nconst formatParameterPart = (name: string, annotation: string, isOptional: boolean): string =>\n isOptional ? `${name}?: ${annotation}` : `${name}: ${annotation}`;\n\nconst renderInputParameters = (context: ModuleContext, fn: GirFunction, options: InputParameterOptions): string => {\n const parts: string[] = [];\n let hasSeenOptional = false;\n\n for (const { parameter, index } of inputParameters(context.library, fn)) {\n if (options.shouldSkip(parameter)) {\n continue;\n }\n\n const name = parameterIdentifier(parameter, index);\n\n if (isParameterOptional(parameter, options.isOptionalExtra)) {\n hasSeenOptional = true;\n }\n\n const annotation = parameterAnnotation(context, fn, parameter);\n parts.push(formatParameterPart(name, annotation, hasSeenOptional));\n }\n\n return parts.join(\", \");\n};\n\nconst isReturnedOutParameter = (context: ModuleContext, parameter: GirParameter): boolean =>\n isOutParameter(parameter) ||\n (isCallerAllocatedOut(parameter) && isCollectibleCallerOut(context, parameter)) ||\n isInoutParameter(parameter);\n\nconst returnedOutParameters = (context: ModuleContext, fn: GirFunction): InputParameter[] => {\n const folded = foldedLengthIndices(context.library, fn);\n const result: InputParameter[] = [];\n\n for (const [index, parameter] of fn.parameters.entries()) {\n if (isReturnedOutParameter(context, parameter) && !folded.has(index)) {\n result.push({ parameter, index });\n }\n }\n\n return result;\n};\n\nconst renderMethodReturnType = (context: ModuleContext, fn: GirFunction): string => {\n const outs = returnedOutParameters(context, fn);\n\n const primary = shouldOmitPrimaryReturn(context.library, fn.returnValue)\n ? undefined\n : renderTsType(context, fn.returnValue.type, fn.returnValue.nullable);\n\n if (outs.length === 0) {\n return primary ?? \"void\";\n }\n\n const outTypes = outs.map(({ parameter }) => renderTsType(context, parameter.type, parameter.nullable));\n\n return foldOutParamShape(primary, outTypes);\n};\n\nconst classifyPromisifiedParameter = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n state: { cancellableIndex: number; hasSeenOptional: boolean },\n): PromisifiedStep => {\n if (parameter.isVarargs) {\n return { hasSeenOptional: state.hasSeenOptional, expression: undefined };\n }\n\n if (index === state.cancellableIndex) {\n return { hasSeenOptional: true, expression: undefined };\n }\n\n if (shouldSkipPromisifiedParameter(promisify, parameter, index)) {\n return { hasSeenOptional: state.hasSeenOptional, expression: undefined };\n }\n\n const hasSeenOptional = state.hasSeenOptional || parameter.optional;\n\n return { hasSeenOptional, expression: promisifiedArgument(promisify, parameter, index, hasSeenOptional) };\n};\n\nconst collectPromisifiedArguments = (promisify: PromisifyContext, cancellableIndex: number): string[] => {\n const expressions: string[] = [];\n let hasSeenOptional = false;\n\n for (const [index, parameter] of promisify.asyncFn.parameters.entries()) {\n const step = classifyPromisifiedParameter(promisify, parameter, index, {\n cancellableIndex,\n hasSeenOptional,\n });\n\n hasSeenOptional = step.hasSeenOptional;\n\n if (step.expression !== undefined) {\n expressions.push(step.expression);\n }\n }\n\n return expressions;\n};\n\nconst renderCancellableExpression = (parameters: GirParameter[], cancellableIndex: number): string => {\n if (cancellableIndex < 0) {\n return \"null\";\n }\n\n const parameter = parameters[cancellableIndex];\n\n return parameter === undefined ? \"null\" : parameterIdentifier(parameter, cancellableIndex);\n};\n\nconst renderPromisifiedBody = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishExpression: string,\n bindingExpression: string,\n): string => {\n context.addRuntimeImport(\"promisify\");\n const cancellableIndex = findCancellableIndex(context, asyncFn.parameters);\n\n const promisifyContext: PromisifyContext = {\n context,\n asyncFn,\n closureIndices: closureAndDestroyIndices(asyncFn),\n lengthSources: arrayLengthSources(context.library, asyncFn),\n };\n\n const leadingExpressions: string[] = [];\n\n if (asyncFn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n leadingExpressions.push(\"getHandle(this)\");\n }\n\n leadingExpressions.push(...collectPromisifiedArguments(promisifyContext, cancellableIndex));\n const cancellableExpression = renderCancellableExpression(asyncFn.parameters, cancellableIndex);\n const leadingArguments = leadingExpressions.length > 0 ? `, ${leadingExpressions.join(\", \")}` : \"\";\n\n return `return promisify(${bindingExpression}, ${finishExpression}, ${cancellableExpression}${leadingArguments});`;\n};\n\nconst finishCallExpression = (asyncFn: GirFunction, finishFn: GirFunction, ownerName: string): string =>\n asyncFn.instance !== undefined && finishFn.instance === undefined\n ? `${ownerName}.${methodExportName(finishFn)}.bind(${ownerName})`\n : `this.${methodExportName(finishFn)}.bind(this)`;\n\nconst shouldSkipPromisifiedParameter = (promisify: PromisifyContext, parameter: GirParameter, index: number): boolean =>\n isCallbackParameter(promisify.context, parameter) ||\n promisify.closureIndices.has(index) ||\n (isOutParameter(parameter) && !isCallerAllocatedOut(parameter));\n\nconst promisifiedArgument = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n hasSeenOptional: boolean,\n): string => {\n const { context, asyncFn, lengthSources } = promisify;\n const sourceIndex = lengthSources.get(index);\n const source = sourceIndex === undefined ? undefined : asyncFn.parameters[sourceIndex];\n\n if (sourceIndex !== undefined && source !== undefined) {\n return arrayLengthArgument(source, sourceIndex);\n }\n\n return parameterCallExpression(context, parameter, index, { fn: asyncFn, isForcedNullable: hasSeenOptional });\n};\n\nconst findCancellableIndex = (context: ModuleContext, parameters: GirParameter[]): number =>\n parameters.findIndex((parameter) => isCancellable(context, parameter));\n\nconst renderPromisifiedSignature = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishFn: GirFunction,\n): { signature: string; returnType: string } => {\n const signature = renderInputParameters(context, asyncFn, {\n shouldSkip: (parameter) => isCallbackParameter(context, parameter),\n isOptionalExtra: (parameter) => isCancellable(context, parameter),\n });\n\n const finishReturn = renderMethodReturnType(context, finishFn);\n\n return { signature, returnType: `Promise<${finishReturn}>` };\n};\n\nconst isCancellable = (context: ModuleContext, parameter: GirParameter): boolean =>\n parameter.type !== undefined && context.library.nameFor(parameter.type)?.typeName === \"Cancellable\";\n\nconst isCallbackParameter = (context: ModuleContext, parameter: GirParameter): boolean => {\n const ref = parameter.type;\n\n if (ref === undefined) {\n return false;\n }\n\n return context.library.typeFor(ref)?.kind === \"callback\";\n};\n\nconst renderMethodBody = (context: ModuleContext, fn: GirFunction, options: WriteMethodBodyOptions): string => {\n const { bindingExpression, returnTypeOverride } = options;\n\n const inputs = planCallArgs(context, fn)\n .map((arg) => arg.inputExpr)\n .filter((expression): expression is string => expression !== undefined);\n\n const callExpression = `${bindingExpression}(${inputs.join(\", \")})`;\n const annotation = returnTypeOverride ?? renderMethodReturnType(context, fn);\n\n return annotation === \"void\" ? `${callExpression};` : `return ${callExpression} as ${annotation};`;\n};\n\nconst paramDescriptorLiteral = (descriptor: string, options: ParamDescriptorOptions): string => {\n const parts = [`type: ${descriptor}`];\n\n if (options.direction !== undefined) {\n parts.push(`direction: ${sourceStringLiteral(options.direction)}`);\n }\n\n if (options.isCallerAllocated === true) {\n parts.push(\"isCallerAllocated: true\");\n }\n\n if (options.isConsumed === true) {\n parts.push(\"isConsumed: true\");\n }\n\n return `{ ${parts.join(\", \")} }`;\n};\n\nconst renderReturnDescriptor = (context: ModuleContext, fn: GirFunction): ReturnDescriptorPlan => {\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n const descriptor = renderDescriptor(context, fn.returnValue.type, fn.returnValue.transferOwnership, {\n argIndexOffset: instanceOffset,\n argIndexMap: emittedArgIndices(fn, instanceOffset),\n isNewlyCreated: fn.instance === undefined,\n });\n\n return { descriptor, isSkipped: isSkippedPrimaryReturn(context.library, fn.returnValue) };\n};\n\nconst planCallArgs = (context: ModuleContext, fn: GirFunction): CallArgPlan[] => {\n const plan: CallArgPlan[] = [];\n\n if (fn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n\n plan.push({\n paramLiteral: `{ type: ${renderSelfDescriptor(context, fn.instance)} }`,\n inputExpr: \"getHandle(this)\",\n });\n }\n\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n const planContext: PlanArgsContext = {\n fn,\n instanceOffset,\n argIndex: { argIndexOffset: instanceOffset, argIndexMap: emittedArgIndices(fn, instanceOffset) },\n lengthSources: arrayLengthSources(context.library, fn),\n closureIndices: closureAndDestroyIndices(fn),\n folded: foldedLengthIndices(context.library, fn),\n };\n\n for (const [index, parameter] of fn.parameters.entries()) {\n const entry = planParameter(context, parameter, index, planContext);\n\n if (entry !== undefined) {\n plan.push(entry);\n }\n }\n\n return plan;\n};\n\nconst isSkippedPlanParameter = (parameter: GirParameter, index: number, closureIndices: Set<number>): boolean =>\n parameter.isVarargs || closureIndices.has(index);\n\nconst planParameter = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan | undefined => {\n const { folded, closureIndices, lengthSources } = planContext;\n\n if (isSkippedPlanParameter(parameter, index, closureIndices)) {\n return undefined;\n }\n\n if (isOutParameter(parameter)) {\n return planOutParam(context, parameter, planContext.argIndex, folded.has(index));\n }\n\n if (isCallerAllocatedOut(parameter)) {\n return planCallerOut(context, parameter, planContext.argIndex);\n }\n\n if (isInoutParameter(parameter)) {\n return planInoutArgument(context, parameter, index, planContext);\n }\n\n const sourceIndex = lengthSources.get(index);\n\n if (sourceIndex !== undefined) {\n return planLengthArgument(context, parameter, sourceIndex, planContext);\n }\n\n return planInParam(context, parameter, index, planContext);\n};\n\nconst planInoutArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn, folded, lengthSources } = planContext;\n const lengthSourceIndex = lengthSources.get(index);\n const lengthSourceParam = lengthSourceIndex === undefined ? undefined : fn.parameters[lengthSourceIndex];\n\n const lengthSource =\n lengthSourceIndex !== undefined && lengthSourceParam !== undefined\n ? { source: lengthSourceParam, index: lengthSourceIndex }\n : undefined;\n\n return planInoutParam(context, parameter, {\n fn,\n index,\n argIndex: planContext.argIndex,\n isConsumed: folded.has(index),\n lengthSource,\n });\n};\n\nconst planLengthArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n sourceIndex: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const source = planContext.fn.parameters[sourceIndex];\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, planContext.argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: source === undefined ? \"0\" : arrayLengthArgument(source, sourceIndex),\n };\n};\n\nconst planOutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n isConsumed: boolean,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n ...argIndex,\n cursor: parameter.cursor,\n hasOutIndirection: true,\n });\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", isConsumed }),\n inputExpr: undefined,\n };\n};\n\nconst planCallerOut = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", argIndex);\n\n if (isCollectibleCallerOut(context, parameter)) {\n context.addRuntimeImport(\"getHandle\");\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", isCallerAllocated: true }),\n inputExpr: renderCallerOutInstance(context, parameter),\n };\n }\n\n return { paramLiteral: paramDescriptorLiteral(descriptor, {}), inputExpr: \"undefined\" };\n};\n\nconst planInoutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n options: {\n fn: GirFunction;\n index: number;\n argIndex: ArgIndexOptions;\n isConsumed: boolean;\n lengthSource?: { source: GirParameter; index: number } | undefined;\n },\n): CallArgPlan => {\n const { fn, index, argIndex, isConsumed, lengthSource } = options;\n\n if (isHandlePassedInPlace(context, parameter)) {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {\n direction: \"inout\",\n isCallerAllocated: true,\n isConsumed,\n }),\n inputExpr: parameterIdentifier(parameter, index),\n };\n }\n\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n ...argIndex,\n hasOutIndirection: true,\n });\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"inout\", isConsumed }),\n inputExpr:\n lengthSource === undefined\n ? parameterCallExpression(context, parameter, index, { fn })\n : arrayLengthArgument(lengthSource.source, lengthSource.index),\n };\n};\n\nconst planInParam = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn } = planContext;\n\n const callback = renderCallbackType(\n context,\n parameter.type,\n parameter,\n itemComparatorArgDescriptors(context, fn, parameter),\n );\n\n const descriptor =\n callback ??\n renderDescriptor(\n context,\n parameter.type,\n parameter.transferOwnership,\n planContext.argIndex,\n );\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: parameterCallExpression(context, parameter, index, { fn }),\n };\n};\n\nconst nullableHandleExpression = (name: string): string => `${name} == null ? null : getHandle(${name})`;\n\nconst handleArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n context.addRuntimeImport(\"getHandle\");\n\n return isNullable ? nullableHandleExpression(name) : `getHandle(${name})`;\n};\n\nconst closureArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n const helper = isNullable ? \"tryToClosure\" : \"toClosure\";\n context.addRuntimeImport(helper);\n\n return `${helper}(${name})`;\n};\n\nconst hashtableArgument = (context: ModuleContext, valueRef: TypeId, name: string): string => {\n if (isHandlePassing(context, valueRef)) {\n context.addRuntimeImport(\"getHandle\");\n\n return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, ${nullableHandleExpression(\"v\")}]) : null`;\n }\n\n return `${name} ? globalThis.Array.from(${name}) : null`;\n};\n\nconst mapHandleExpression = (name: string, isNullable: boolean): string =>\n isNullable ? `${name}?.map((item) => getHandle(item))` : `${name}.map((item) => getHandle(item))`;\n\nconst collectionArgument = (\n context: ModuleContext,\n type: GirType | undefined,\n name: string,\n isNullable: boolean,\n): string | undefined => {\n if (type?.kind === \"hashtable\") {\n return hashtableArgument(context, type.value, name);\n }\n\n if (!isMappableSequence(context, type)) {\n return undefined;\n }\n\n context.addRuntimeImport(\"getHandle\");\n\n return mapHandleExpression(name, isNullable);\n};\n\nconst isMappableSequence = (context: ModuleContext, type: GirType | undefined): boolean => {\n if (type?.kind === \"carray\") {\n return !hasUnknownArrayLength(type) && isHandlePassing(context, type.element);\n }\n\n return type?.kind === \"list\" && isHandlePassing(context, type.element);\n};\n\nconst parameterCallExpression = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n options: CallExpressionOptions,\n): string => {\n const { fn, isForcedNullable = false } = options;\n const name = parameterIdentifier(parameter, index);\n const ref = parameter.type;\n\n if (ref === undefined) {\n return name;\n }\n\n const isNullable = parameter.nullable || parameter.optional || isForcedNullable;\n\n if (requiresClosureMarshal(context, fn, ref)) {\n return closureArgument(context, name, isNullable);\n }\n\n if (isHandlePassing(context, ref)) {\n return handleArgument(context, name, isNullable);\n }\n\n const type = context.library.typeFor(ref);\n\n return collectionArgument(context, type, name, isNullable) ?? name;\n};\n\nexport {\n isCallbackParameter,\n memberName,\n methodExportName,\n renderMethodSignature,\n renderMethodReturnType,\n returnedOutParameters,\n renderPromisifiedBody,\n finishCallExpression,\n renderPromisifiedSignature,\n renderMethodBody,\n renderReturnDescriptor,\n planCallArgs,\n};\n"]}
@@ -12,14 +12,11 @@ type ResolvedAccessor = {
12
12
  writeType: string;
13
13
  hasGetter: boolean;
14
14
  isWritable: boolean;
15
- getterMember: string | undefined;
16
- setterMember: string | undefined;
17
15
  };
18
16
  type PropertyAccessorArgs = {
19
17
  context: ModuleContext;
20
18
  property: GirProperty;
21
19
  claimedNames: Set<string>;
22
- methodByName: Map<string, GirFunction>;
23
20
  inheritedTypes?: InheritedAccessorTypes | undefined;
24
21
  inheritedNames?: Set<string> | undefined;
25
22
  };
@@ -1 +1 @@
1
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GAAG;IACxB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,WAAW,CAAC;IACtB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,cAAc,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;IACpD,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CAC5C,CAAC;AAsCF,QAAA,MAAM,eAAe,GAAI,MAAM,oBAAoB,KAAG,gBAAgB,GAAG,SAoBxE,CAAC;AAEF,QAAA,MAAM,oBAAoB,GACtB,SAAS,aAAa,EACtB,UAAU,WAAW,EACrB,SAAS,WAAW,EAAE,KACvB,gBAAgB,GAAG,SAYrB,CAAC;AAEF,QAAA,MAAM,oBAAoB,GACtB,SAAS,aAAa,EACtB,UAAU,WAAW,EACrB,SAAS,WAAW,EAAE,KACvB,sBAAsB,GAAG,SAW3B,CAAC;AAeF,QAAA,MAAM,8BAA8B,GAChC,SAAS,aAAa,EACtB,UAAU,WAAW,EACrB,UAAU,gBAAgB,KAC3B,MAaF,CAAC;AAEF,QAAA,MAAM,WAAW,GAAI,UAAU,WAAW,KAAG,MACzB,CAAC;AAErB,QAAA,MAAM,sBAAsB,GAAI,MAAM,oBAAoB,KAAG,MAAM,GAAG,SACqC,CAAC;AAoB5G,QAAA,MAAM,+BAA+B,GAAI,MAAM,oBAAoB,KAAG,MAAM,GAAG,SAC8B,CAAC;AAqB9G,OAAO,EACH,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,+BAA+B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC5B,CAAC"}
@@ -1,14 +1,12 @@
1
- import { camelCase, sourceStringLiteral, toCamelIdentifier } from "@gtkx/utils";
1
+ import { sourceStringLiteral, toCamelIdentifier } from "@gtkx/utils";
2
2
  import { renderDescriptor } from "../../analysis/descriptor-render.js";
3
- import { inputParameters } from "../../analysis/param-structure.js";
4
3
  import { renderTsType } from "../../analysis/ts-type.js";
5
4
  import { isConstructableProperty } from "../../gir/property.js";
6
- import { comparisonContextFor } from "../../writer/comparison-context.js";
7
5
  import { renderBlock } from "../../writer/emit.js";
8
6
  import { isEmittableCallable } from "./callables.js";
9
7
  import { getDoc } from "./doc-spec.js";
10
- import { methodExportName, renderMethodReturnType } from "./method.js";
11
- const NULLABLE_SUFFIX = " | null";
8
+ import { methodExportName } from "./method.js";
9
+ const NON_NULLABLE_KINDS = new Set(["primitive", "enum"]);
12
10
  const isNullablePropertyType = (context, type) => {
13
11
  if (type === undefined) {
14
12
  return false;
@@ -17,118 +15,44 @@ const isNullablePropertyType = (context, type) => {
17
15
  if (resolved === undefined) {
18
16
  return true;
19
17
  }
20
- if (resolved.kind === "primitive") {
21
- return false;
22
- }
23
- if (resolved.kind === "enum") {
24
- return false;
25
- }
26
18
  if (resolved.kind === "alias") {
27
19
  return isNullablePropertyType(context, resolved.value.target);
28
20
  }
29
- return true;
30
- };
31
- const resolveDelegate = (args, attribute, member, isDelegatable) => {
32
- const method = member !== undefined && attribute !== undefined ? args.methodByName.get(attribute) : undefined;
33
- if (member === undefined || method === undefined || !isDelegatable(method)) {
34
- return undefined;
35
- }
36
- return { member, method };
37
- };
38
- const resolveGetterDelegate = (args, jsName) => {
39
- const { context, property, claimedNames } = args;
40
- const member = delegateMember(property.getter, jsName, claimedNames);
41
- return resolveDelegate(args, property.getter, member, (method) => inputParameters(context.library, method).length === 0 &&
42
- !renderMethodReturnType(context, method).startsWith("["));
43
- };
44
- const resolveSetterDelegate = (args, jsName, isWritable) => {
45
- const { context, property, claimedNames } = args;
46
- const member = isWritable ? delegateMember(property.setter, jsName, claimedNames) : undefined;
47
- return resolveDelegate(args, property.setter, member, (method) => inputParameters(context.library, method).length === 1);
48
- };
49
- const baseTypeName = (type) => type.endsWith(NULLABLE_SUFFIX) ? type.slice(0, -NULLABLE_SUFFIX.length) : type;
50
- const areDelegateBaseTypesAgreeing = (context, getter, setter) => {
51
- const setterParam = setter?.method.parameters[0];
52
- if (setterParam === undefined || getter === undefined) {
53
- return true;
54
- }
55
- const scratch = comparisonContextFor(context);
56
- const read = baseTypeName(renderMethodReturnType(scratch, getter.method));
57
- const written = baseTypeName(renderTsType(scratch, setterParam.type, false));
58
- return read === written;
59
- };
60
- const resolveDelegates = (args, jsName, isWritable) => {
61
- const getter = resolveGetterDelegate(args, jsName);
62
- const setter = resolveSetterDelegate(args, jsName, isWritable);
63
- if (areDelegateBaseTypesAgreeing(args.context, getter, setter)) {
64
- return { getter, setter };
65
- }
66
- return { getter, setter: undefined };
67
- };
68
- const declaredPropertyType = (context, property) => renderTsType(context, property.type, isNullablePropertyType(context, property.type));
69
- const resolveOwnTypes = (context, property, delegates) => {
70
- const getterMethod = delegates.getter?.method;
71
- const setterParam = delegates.setter?.method.parameters[0];
72
- return {
73
- readType: getterMethod === undefined
74
- ? declaredPropertyType(context, property)
75
- : renderMethodReturnType(context, getterMethod),
76
- writeType: setterParam === undefined
77
- ? declaredPropertyType(context, property)
78
- : renderTsType(context, setterParam.type, setterParam.nullable || setterParam.optional),
79
- };
80
- };
81
- const isAssignableType = (source, target) => source === target || baseTypeName(target) === source;
82
- const agreeingDelegates = (delegates, ownTypes, declaredTypes) => ({
83
- getter: isAssignableType(ownTypes.readType, declaredTypes.readType) ? delegates.getter : undefined,
84
- setter: isAssignableType(declaredTypes.writeType, ownTypes.writeType) ? delegates.setter : undefined,
85
- });
86
- const resolveTypedDelegates = (args, resolved) => {
87
- const ownTypes = resolveOwnTypes(args.context, args.property, resolved);
88
- const types = {
89
- readType: args.inheritedTypes?.readType ?? ownTypes.readType,
90
- writeType: args.inheritedTypes?.writeType ?? ownTypes.writeType,
91
- };
92
- return { types, delegates: agreeingDelegates(resolved, ownTypes, types) };
21
+ return !NON_NULLABLE_KINDS.has(resolved.kind);
93
22
  };
23
+ const declaredPropertyType = (context, property) => renderTsType(context, property.type, property.defaultValue === "NULL" || isNullablePropertyType(context, property.type));
94
24
  const isSkippedAccessor = (args, jsName) => !args.property.introspectable ||
95
25
  args.claimedNames.has(jsName) ||
96
26
  args.inheritedNames?.has(jsName) === true ||
97
27
  jsName === "constructor";
28
+ const isAccessorEmittable = (args, jsName, isWritable) => !isSkippedAccessor(args, jsName) && (args.property.readable || isWritable);
98
29
  const resolveAccessor = (args) => {
99
30
  const { property } = args;
100
31
  const jsName = toCamelIdentifier(property.name);
101
- if (isSkippedAccessor(args, jsName)) {
102
- return undefined;
103
- }
104
32
  const isWritable = isConstructableProperty(property) && !property.constructOnly;
105
- const { types, delegates } = resolveTypedDelegates(args, resolveDelegates(args, jsName, isWritable));
106
- const hasGetter = property.readable || delegates.getter !== undefined;
107
- if (!hasGetter && !isWritable) {
33
+ if (!isAccessorEmittable(args, jsName, isWritable)) {
108
34
  return undefined;
109
35
  }
36
+ const declared = declaredPropertyType(args.context, property);
37
+ const hasGetter = property.readable;
110
38
  return {
111
39
  property,
112
40
  jsName,
113
- readType: types.readType,
114
- writeType: types.writeType,
41
+ readType: args.inheritedTypes?.readType ?? declared,
42
+ writeType: args.inheritedTypes?.writeType ?? declared,
115
43
  hasGetter,
116
44
  isWritable,
117
- getterMember: delegates.getter?.member,
118
- setterMember: delegates.setter?.member,
119
45
  };
120
46
  };
121
47
  const resolveOwnerAccessor = (context, property, methods) => {
122
- const methodByName = new Map();
123
48
  const claimedNames = new Set();
124
49
  for (const method of methods) {
125
50
  if (!isEmittableCallable(context, method)) {
126
51
  continue;
127
52
  }
128
- methodByName.set(method.name, method);
129
53
  claimedNames.add(methodExportName(method));
130
54
  }
131
- return resolveAccessor({ context, property, claimedNames, methodByName });
55
+ return resolveAccessor({ context, property, claimedNames });
132
56
  };
133
57
  const resolveAccessorTypes = (context, property, methods) => {
134
58
  const accessor = resolveOwnerAccessor(context, property, methods);
@@ -148,14 +72,13 @@ const withAccessor = (args, render) => {
148
72
  return render(accessor);
149
73
  };
150
74
  const renderResolvedPropertyAccessor = (context, property, accessor) => {
151
- const { jsName, readType, writeType, hasGetter, isWritable, setterMember } = accessor;
75
+ const { jsName, readType, writeType, hasGetter, isWritable } = accessor;
152
76
  const blocks = [];
153
77
  if (hasGetter) {
154
- blocks.push(renderBlock(`get ${jsName}(): ${readType}`, renderGetterBody(context, property, accessor)));
78
+ blocks.push(renderBlock(`get ${jsName}(): ${readType}`, renderGenericGetBody(context, property, readType)));
155
79
  }
156
80
  if (isWritable) {
157
- const setterBody = setterMember === undefined ? renderGenericSetBody(context, property) : `this.${setterMember}(value);`;
158
- blocks.push(renderBlock(`set ${jsName}(value: ${writeType})`, setterBody));
81
+ blocks.push(renderBlock(`set ${jsName}(value: ${writeType})`, renderGenericSetBody(context, property)));
159
82
  }
160
83
  return `${propertyDoc(property)}${blocks.join("\n\n")}`;
161
84
  };
@@ -188,21 +111,5 @@ const renderGenericSetBody = (context, property) => {
188
111
  const descriptor = renderPropertyDescriptor(context, property);
189
112
  return `setObjectProperty(this, ${sourceStringLiteral(property.name)}, ${descriptor}, value);`;
190
113
  };
191
- const renderGetterBody = (context, property, accessor) => accessor.getterMember === undefined
192
- ? renderGenericGetBody(context, property, accessor.readType)
193
- : `return this.${accessor.getterMember}();`;
194
- const delegateMember = (attribute, accessorName, claimedNames) => {
195
- if (attribute === undefined) {
196
- return undefined;
197
- }
198
- const member = camelCase(attribute);
199
- if (member === accessorName) {
200
- return undefined;
201
- }
202
- if (!claimedNames.has(member)) {
203
- return undefined;
204
- }
205
- return member;
206
- };
207
114
  export { propertyDoc, resolveAccessor, resolveOwnerAccessor, resolveAccessorTypes, renderResolvedPropertyAccessor, renderPropertyAccessor, renderPropertyAccessorSignature, };
208
115
  //# sourceMappingURL=property-accessor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"property-accessor.js","sourceRoot":"","sources":["../../../src/store/gi/property-accessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,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AAC,YAAY,KAAK,SAAS;IAC/B,CAAC,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC5D,CAAC,CAAC,eAAe,QAAQ,CAAC,YAAY,KAAK,CAAC;AAEpD,MAAM,cAAc,GAAG,CACnB,SAA6B,EAC7B,YAAoB,EACpB,YAAyB,EACP,EAAE;IACpB,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;IAEpC,IAAI,MAAM,KAAK,YAAY,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EACH,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,+BAA+B,GAIlC,CAAC","sourcesContent":["import { camelCase, sourceStringLiteral, toCamelIdentifier } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { renderDescriptor } from \"../../analysis/descriptor-render.js\";\nimport { inputParameters } from \"../../analysis/param-structure.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { type GirProperty, isConstructableProperty } from \"../../gir/property.js\";\nimport { comparisonContextFor } from \"../../writer/comparison-context.js\";\nimport { renderBlock } from \"../../writer/emit.js\";\nimport { isEmittableCallable } from \"./callables.js\";\nimport { getDoc } from \"./doc-spec.js\";\nimport { methodExportName, renderMethodReturnType } from \"./method.js\";\n\ntype AccessorTypes = {\n readType: string;\n writeType: string;\n};\n\ntype InheritedAccessorTypes = {\n readType: string | undefined;\n writeType: string | undefined;\n};\n\ntype ResolvedAccessor = {\n property: GirProperty;\n jsName: string;\n readType: string;\n writeType: string;\n hasGetter: boolean;\n isWritable: boolean;\n getterMember: string | undefined;\n setterMember: string | undefined;\n};\n\ntype PropertyAccessorArgs = {\n context: ModuleContext;\n property: GirProperty;\n claimedNames: Set<string>;\n methodByName: Map<string, GirFunction>;\n inheritedTypes?: InheritedAccessorTypes | undefined;\n inheritedNames?: Set<string> | undefined;\n};\n\ntype AccessorDelegate = { member: string; method: GirFunction };\ntype AccessorDelegates = { getter: AccessorDelegate | undefined; setter: AccessorDelegate | undefined };\ntype TypedDelegates = { types: AccessorTypes; delegates: AccessorDelegates };\n\nconst NULLABLE_SUFFIX = \" | null\";\n\nconst isNullablePropertyType = (context: ModuleContext, type: TypeId | undefined): boolean => {\n if (type === undefined) {\n return false;\n }\n\n const resolved = context.library.typeFor(type);\n\n if (resolved === undefined) {\n return true;\n }\n\n if (resolved.kind === \"primitive\") {\n return false;\n }\n\n if (resolved.kind === \"enum\") {\n return false;\n }\n\n if (resolved.kind === \"alias\") {\n return isNullablePropertyType(context, resolved.value.target);\n }\n\n return true;\n};\n\nconst resolveDelegate = (\n args: PropertyAccessorArgs,\n attribute: string | undefined,\n member: string | undefined,\n isDelegatable: (method: GirFunction) => boolean,\n): AccessorDelegate | undefined => {\n const method = member !== undefined && attribute !== undefined ? args.methodByName.get(attribute) : undefined;\n\n if (member === undefined || method === undefined || !isDelegatable(method)) {\n return undefined;\n }\n\n return { member, method };\n};\n\nconst resolveGetterDelegate = (args: PropertyAccessorArgs, jsName: string): AccessorDelegate | undefined => {\n const { context, property, claimedNames } = args;\n const member = delegateMember(property.getter, jsName, claimedNames);\n\n return resolveDelegate(\n args,\n property.getter,\n member,\n (method) =>\n inputParameters(context.library, method).length === 0 &&\n !renderMethodReturnType(context, method).startsWith(\"[\"),\n );\n};\n\nconst resolveSetterDelegate = (\n args: PropertyAccessorArgs,\n jsName: string,\n isWritable: boolean,\n): AccessorDelegate | undefined => {\n const { context, property, claimedNames } = args;\n const member = isWritable ? delegateMember(property.setter, jsName, claimedNames) : undefined;\n\n return resolveDelegate(\n args,\n property.setter,\n member,\n (method) => inputParameters(context.library, method).length === 1,\n );\n};\n\nconst baseTypeName = (type: string): string =>\n type.endsWith(NULLABLE_SUFFIX) ? type.slice(0, -NULLABLE_SUFFIX.length) : type;\n\nconst areDelegateBaseTypesAgreeing = (\n context: ModuleContext,\n getter: AccessorDelegate | undefined,\n setter: AccessorDelegate | undefined,\n): boolean => {\n const setterParam = setter?.method.parameters[0];\n\n if (setterParam === undefined || getter === undefined) {\n return true;\n }\n\n const scratch = comparisonContextFor(context);\n const read = baseTypeName(renderMethodReturnType(scratch, getter.method));\n const written = baseTypeName(renderTsType(scratch, setterParam.type, false));\n\n return read === written;\n};\n\nconst resolveDelegates = (args: PropertyAccessorArgs, jsName: string, isWritable: boolean): AccessorDelegates => {\n const getter = resolveGetterDelegate(args, jsName);\n const setter = resolveSetterDelegate(args, jsName, isWritable);\n\n if (areDelegateBaseTypesAgreeing(args.context, getter, setter)) {\n return { getter, setter };\n }\n\n return { getter, setter: undefined };\n};\n\nconst declaredPropertyType = (context: ModuleContext, property: GirProperty): string =>\n renderTsType(context, property.type, isNullablePropertyType(context, property.type));\n\nconst resolveOwnTypes = (\n context: ModuleContext,\n property: GirProperty,\n delegates: AccessorDelegates,\n): AccessorTypes => {\n const getterMethod = delegates.getter?.method;\n const setterParam = delegates.setter?.method.parameters[0];\n\n return {\n readType: getterMethod === undefined\n ? declaredPropertyType(context, property)\n : renderMethodReturnType(context, getterMethod),\n writeType: setterParam === undefined\n ? declaredPropertyType(context, property)\n : renderTsType(context, setterParam.type, setterParam.nullable || setterParam.optional),\n };\n};\n\nconst isAssignableType = (source: string, target: string): boolean =>\n source === target || baseTypeName(target) === source;\n\nconst agreeingDelegates = (\n delegates: AccessorDelegates,\n ownTypes: AccessorTypes,\n declaredTypes: AccessorTypes,\n): AccessorDelegates => ({\n getter: isAssignableType(ownTypes.readType, declaredTypes.readType) ? delegates.getter : undefined,\n setter: isAssignableType(declaredTypes.writeType, ownTypes.writeType) ? delegates.setter : undefined,\n});\n\nconst resolveTypedDelegates = (args: PropertyAccessorArgs, resolved: AccessorDelegates): TypedDelegates => {\n const ownTypes = resolveOwnTypes(args.context, args.property, resolved);\n\n const types = {\n readType: args.inheritedTypes?.readType ?? ownTypes.readType,\n writeType: args.inheritedTypes?.writeType ?? ownTypes.writeType,\n };\n\n return { types, delegates: agreeingDelegates(resolved, ownTypes, types) };\n};\n\nconst isSkippedAccessor = (args: PropertyAccessorArgs, jsName: string): boolean =>\n !args.property.introspectable ||\n args.claimedNames.has(jsName) ||\n args.inheritedNames?.has(jsName) === true ||\n jsName === \"constructor\";\n\nconst resolveAccessor = (args: PropertyAccessorArgs): ResolvedAccessor | undefined => {\n const { property } = args;\n const jsName = toCamelIdentifier(property.name);\n\n if (isSkippedAccessor(args, jsName)) {\n return undefined;\n }\n\n const isWritable = isConstructableProperty(property) && !property.constructOnly;\n const { types, delegates } = resolveTypedDelegates(args, resolveDelegates(args, jsName, isWritable));\n const hasGetter = property.readable || delegates.getter !== undefined;\n\n if (!hasGetter && !isWritable) {\n return undefined;\n }\n\n return {\n property,\n jsName,\n readType: types.readType,\n writeType: types.writeType,\n hasGetter,\n isWritable,\n getterMember: delegates.getter?.member,\n setterMember: delegates.setter?.member,\n };\n};\n\nconst resolveOwnerAccessor = (\n context: ModuleContext,\n property: GirProperty,\n methods: GirFunction[],\n): ResolvedAccessor | undefined => {\n const methodByName: Map<string, GirFunction> = new Map();\n const claimedNames: Set<string> = new Set();\n\n for (const method of methods) {\n if (!isEmittableCallable(context, method)) {\n continue;\n }\n\n methodByName.set(method.name, method);\n claimedNames.add(methodExportName(method));\n }\n\n return resolveAccessor({ context, property, claimedNames, methodByName });\n};\n\nconst resolveAccessorTypes = (\n context: ModuleContext,\n property: GirProperty,\n methods: GirFunction[],\n): InheritedAccessorTypes | undefined => {\n const accessor = resolveOwnerAccessor(context, property, methods);\n\n if (accessor === undefined) {\n return undefined;\n }\n\n return {\n readType: accessor.hasGetter ? accessor.readType : undefined,\n writeType: accessor.isWritable ? accessor.writeType : undefined,\n };\n};\n\nconst withAccessor = (\n args: PropertyAccessorArgs,\n render: (accessor: ResolvedAccessor) => string,\n): string | undefined => {\n const accessor = resolveAccessor(args);\n\n if (accessor === undefined) {\n return undefined;\n }\n\n return render(accessor);\n};\n\nconst renderResolvedPropertyAccessor = (\n context: ModuleContext,\n property: GirProperty,\n accessor: ResolvedAccessor,\n): string => {\n const { jsName, readType, writeType, hasGetter, isWritable, setterMember } = accessor;\n const blocks: string[] = [];\n\n if (hasGetter) {\n blocks.push(renderBlock(`get ${jsName}(): ${readType}`, renderGetterBody(context, property, accessor)));\n }\n\n if (isWritable) {\n const setterBody =\n setterMember === undefined ? renderGenericSetBody(context, property) : `this.${setterMember}(value);`;\n\n blocks.push(renderBlock(`set ${jsName}(value: ${writeType})`, setterBody));\n }\n\n return `${propertyDoc(property)}${blocks.join(\"\\n\\n\")}`;\n};\n\nconst propertyDoc = (property: GirProperty): string =>\n getDoc(property);\n\nconst renderPropertyAccessor = (args: PropertyAccessorArgs): string | undefined =>\n withAccessor(args, (accessor) => renderResolvedPropertyAccessor(args.context, args.property, accessor));\n\nconst renderAccessorPairSignature = (accessor: ResolvedAccessor): string => {\n const { jsName, readType, writeType, hasGetter, isWritable } = accessor;\n\n if (!hasGetter) {\n return `set ${jsName}(value: ${writeType});`;\n }\n\n if (!isWritable) {\n return `get ${jsName}(): ${readType};`;\n }\n\n if (readType === writeType) {\n return `${jsName}: ${readType};`;\n }\n\n return `get ${jsName}(): ${readType};\\nset ${jsName}(value: ${writeType});`;\n};\n\nconst renderPropertyAccessorSignature = (args: PropertyAccessorArgs): string | undefined =>\n withAccessor(args, (accessor) => `${propertyDoc(args.property)}${renderAccessorPairSignature(accessor)}`);\n\nconst renderPropertyDescriptor = (context: ModuleContext, property: GirProperty): string =>\n renderDescriptor(context, property.type, property.transferOwnership);\n\nconst renderGenericGetBody = (context: ModuleContext, property: GirProperty, tsType: string): string => {\n context.addRuntimeImport(\"getObjectProperty\");\n context.addRuntimeImport(\"t\");\n const descriptor = renderPropertyDescriptor(context, property);\n\n return `return getObjectProperty(this, ${sourceStringLiteral(property.name)}, ${descriptor}) as ${tsType};`;\n};\n\nconst renderGenericSetBody = (context: ModuleContext, property: GirProperty): string => {\n context.addRuntimeImport(\"setObjectProperty\");\n context.addRuntimeImport(\"t\");\n const descriptor = renderPropertyDescriptor(context, property);\n\n return `setObjectProperty(this, ${sourceStringLiteral(property.name)}, ${descriptor}, value);`;\n};\n\nconst renderGetterBody = (context: ModuleContext, property: GirProperty, accessor: ResolvedAccessor): string =>\n accessor.getterMember === undefined\n ? renderGenericGetBody(context, property, accessor.readType)\n : `return this.${accessor.getterMember}();`;\n\nconst delegateMember = (\n attribute: string | undefined,\n accessorName: string,\n claimedNames: Set<string>,\n): string | undefined => {\n if (attribute === undefined) {\n return undefined;\n }\n\n const member = camelCase(attribute);\n\n if (member === accessorName) {\n return undefined;\n }\n\n if (!claimedNames.has(member)) {\n return undefined;\n }\n\n return member;\n};\n\nexport {\n propertyDoc,\n resolveAccessor,\n resolveOwnerAccessor,\n resolveAccessorTypes,\n renderResolvedPropertyAccessor,\n renderPropertyAccessor,\n renderPropertyAccessorSignature,\n type InheritedAccessorTypes,\n type ResolvedAccessor,\n type PropertyAccessorArgs,\n};\n"]}
1
+ {"version":3,"file":"property-accessor.js","sourceRoot":"","sources":["../../../src/store/gi/property-accessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAoB,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAClF,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StringLiteral, toCamelIdentifier } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { renderDescriptor } from \"../../analysis/descriptor-render.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { type GirProperty, isConstructableProperty } from \"../../gir/property.js\";\nimport { renderBlock } from \"../../writer/emit.js\";\nimport { isEmittableCallable } from \"./callables.js\";\nimport { getDoc } from \"./doc-spec.js\";\nimport { methodExportName } from \"./method.js\";\n\ntype InheritedAccessorTypes = {\n readType: string | undefined;\n writeType: string | undefined;\n};\n\ntype ResolvedAccessor = {\n property: GirProperty;\n jsName: string;\n readType: string;\n writeType: string;\n hasGetter: boolean;\n isWritable: boolean;\n};\n\ntype PropertyAccessorArgs = {\n context: ModuleContext;\n property: GirProperty;\n claimedNames: Set<string>;\n inheritedTypes?: InheritedAccessorTypes | undefined;\n inheritedNames?: Set<string> | undefined;\n};\n\nconst NON_NULLABLE_KINDS: Set<string> = new Set([\"primitive\", \"enum\"]);\n\nconst isNullablePropertyType = (context: ModuleContext, type: TypeId | undefined): boolean => {\n if (type === undefined) {\n return false;\n }\n\n const resolved = context.library.typeFor(type);\n\n if (resolved === undefined) {\n return true;\n }\n\n if (resolved.kind === \"alias\") {\n return isNullablePropertyType(context, resolved.value.target);\n }\n\n return !NON_NULLABLE_KINDS.has(resolved.kind);\n};\n\nconst declaredPropertyType = (context: ModuleContext, property: GirProperty): string =>\n renderTsType(\n context,\n property.type,\n property.defaultValue === \"NULL\" || isNullablePropertyType(context, property.type),\n );\n\nconst isSkippedAccessor = (args: PropertyAccessorArgs, jsName: string): boolean =>\n !args.property.introspectable ||\n args.claimedNames.has(jsName) ||\n args.inheritedNames?.has(jsName) === true ||\n jsName === \"constructor\";\n\nconst isAccessorEmittable = (args: PropertyAccessorArgs, jsName: string, isWritable: boolean): boolean =>\n !isSkippedAccessor(args, jsName) && (args.property.readable || isWritable);\n\nconst resolveAccessor = (args: PropertyAccessorArgs): ResolvedAccessor | undefined => {\n const { property } = args;\n const jsName = toCamelIdentifier(property.name);\n const isWritable = isConstructableProperty(property) && !property.constructOnly;\n\n if (!isAccessorEmittable(args, jsName, isWritable)) {\n return undefined;\n }\n\n const declared = declaredPropertyType(args.context, property);\n const hasGetter = property.readable;\n\n return {\n property,\n jsName,\n readType: args.inheritedTypes?.readType ?? declared,\n writeType: args.inheritedTypes?.writeType ?? declared,\n hasGetter,\n isWritable,\n };\n};\n\nconst resolveOwnerAccessor = (\n context: ModuleContext,\n property: GirProperty,\n methods: GirFunction[],\n): ResolvedAccessor | undefined => {\n const claimedNames: Set<string> = new Set();\n\n for (const method of methods) {\n if (!isEmittableCallable(context, method)) {\n continue;\n }\n\n claimedNames.add(methodExportName(method));\n }\n\n return resolveAccessor({ context, property, claimedNames });\n};\n\nconst resolveAccessorTypes = (\n context: ModuleContext,\n property: GirProperty,\n methods: GirFunction[],\n): InheritedAccessorTypes | undefined => {\n const accessor = resolveOwnerAccessor(context, property, methods);\n\n if (accessor === undefined) {\n return undefined;\n }\n\n return {\n readType: accessor.hasGetter ? accessor.readType : undefined,\n writeType: accessor.isWritable ? accessor.writeType : undefined,\n };\n};\n\nconst withAccessor = (\n args: PropertyAccessorArgs,\n render: (accessor: ResolvedAccessor) => string,\n): string | undefined => {\n const accessor = resolveAccessor(args);\n\n if (accessor === undefined) {\n return undefined;\n }\n\n return render(accessor);\n};\n\nconst renderResolvedPropertyAccessor = (\n context: ModuleContext,\n property: GirProperty,\n accessor: ResolvedAccessor,\n): string => {\n const { jsName, readType, writeType, hasGetter, isWritable } = accessor;\n const blocks: string[] = [];\n\n if (hasGetter) {\n blocks.push(renderBlock(`get ${jsName}(): ${readType}`, renderGenericGetBody(context, property, readType)));\n }\n\n if (isWritable) {\n blocks.push(renderBlock(`set ${jsName}(value: ${writeType})`, renderGenericSetBody(context, property)));\n }\n\n return `${propertyDoc(property)}${blocks.join(\"\\n\\n\")}`;\n};\n\nconst propertyDoc = (property: GirProperty): string =>\n getDoc(property);\n\nconst renderPropertyAccessor = (args: PropertyAccessorArgs): string | undefined =>\n withAccessor(args, (accessor) => renderResolvedPropertyAccessor(args.context, args.property, accessor));\n\nconst renderAccessorPairSignature = (accessor: ResolvedAccessor): string => {\n const { jsName, readType, writeType, hasGetter, isWritable } = accessor;\n\n if (!hasGetter) {\n return `set ${jsName}(value: ${writeType});`;\n }\n\n if (!isWritable) {\n return `get ${jsName}(): ${readType};`;\n }\n\n if (readType === writeType) {\n return `${jsName}: ${readType};`;\n }\n\n return `get ${jsName}(): ${readType};\\nset ${jsName}(value: ${writeType});`;\n};\n\nconst renderPropertyAccessorSignature = (args: PropertyAccessorArgs): string | undefined =>\n withAccessor(args, (accessor) => `${propertyDoc(args.property)}${renderAccessorPairSignature(accessor)}`);\n\nconst renderPropertyDescriptor = (context: ModuleContext, property: GirProperty): string =>\n renderDescriptor(context, property.type, property.transferOwnership);\n\nconst renderGenericGetBody = (context: ModuleContext, property: GirProperty, tsType: string): string => {\n context.addRuntimeImport(\"getObjectProperty\");\n context.addRuntimeImport(\"t\");\n const descriptor = renderPropertyDescriptor(context, property);\n\n return `return getObjectProperty(this, ${sourceStringLiteral(property.name)}, ${descriptor}) as ${tsType};`;\n};\n\nconst renderGenericSetBody = (context: ModuleContext, property: GirProperty): string => {\n context.addRuntimeImport(\"setObjectProperty\");\n context.addRuntimeImport(\"t\");\n const descriptor = renderPropertyDescriptor(context, property);\n\n return `setObjectProperty(this, ${sourceStringLiteral(property.name)}, ${descriptor}, value);`;\n};\n\nexport {\n propertyDoc,\n resolveAccessor,\n resolveOwnerAccessor,\n resolveAccessorTypes,\n renderResolvedPropertyAccessor,\n renderPropertyAccessor,\n renderPropertyAccessorSignature,\n type InheritedAccessorTypes,\n type ResolvedAccessor,\n type PropertyAccessorArgs,\n};\n"]}
@@ -71,9 +71,9 @@ const renderRecordConstructor = (context, spec) => {
71
71
  context.addRuntimeImport("setHandle");
72
72
  const statements = [
73
73
  ...superCall,
74
- `const handle = alloc(${allocArgs(context, record, size).join(", ")});`,
74
+ `const __handle = alloc(${allocArgs(context, record, size).join(", ")});`,
75
75
  ...renderFieldWrites(context, slots),
76
- "setHandle(this, handle);",
76
+ "setHandle(this, __handle);",
77
77
  ];
78
78
  return renderBlock(`constructor(props: ${className}ConstructorProps = {})`, statements.join("\n"));
79
79
  };
@@ -91,7 +91,7 @@ const renderFieldWrite = (context, entry) => {
91
91
  const write = emitFieldWrite(context, {
92
92
  descriptor,
93
93
  slot: entry.slot,
94
- targetExpr: "handle",
94
+ targetExpr: "__handle",
95
95
  valueExpr: `props.${name}`,
96
96
  });
97
97
  return `if (props.${name} !== undefined) ${write}`;
@@ -1 +1 @@
1
- {"version":3,"file":"record-constructor.js","sourceRoot":"","sources":["../../../src/store/gi/record-constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAkB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAwB,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAW/D,MAAM,mBAAmB,GAAG,CAAC,OAAsB,EA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AC,eAAe,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,OAAsB,EAAE,KAAwB,EAAU,EAAE;IAClF,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAE9B,MAAM,UAAU,GAAG,OAAO,CAAC,eAAe,CACtC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CACzG,CAAC;IAEF,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEjD,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE;QAClC,UAAU;QACV,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,SAAS,IAAI,EAAE;KAC7B,CAAC,CAAC;IAEH,OAAO,aAAa,IAAI,mBAAmB,KAAK,EAAE,CAAC;AACvD,CAAC,CAAC;AAEF,OAAO,EAAE,qCAAqC,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["import { sourceStringLiteral, toCamelIdentifier } from \"@gtkx/utils\";\nimport type { GirField } from \"../../gir/field.js\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { GirRecord } from \"../../gir/record.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { renderDescriptor } from \"../../analysis/descriptor-render.js\";\nimport { inputParameters, parameterIdentifier } from \"../../analysis/param-structure.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { renderBlock, renderBracedOrEmpty } from \"../../writer/emit.js\";\nimport { type Callables, staticMembers } from \"./callables.js\";\nimport { getDoc } from \"./doc-spec.js\";\nimport { renderSourceGtype } from \"./gtype-binding.js\";\nimport { emitFieldWrite, isEmittableField, isInlineField } from \"./record-field-accessor.js\";\nimport { computeRecordFieldSlots, type RecordFieldSlot } from \"./record-layout.js\";\nimport { isConstructibleRecord } from \"./value-marshalable.js\";\n\ntype WritableFieldSlot = RecordFieldSlot & { field: GirField & { type: TypeId } };\n\ntype RecordConstructorSpec = {\n record: GirRecord;\n className: string;\n callables: Callables;\n isErrorSubclass: boolean;\n};\n\nconst isWritableFieldSlot = (context: ModuleContext, entry: RecordFieldSlot): entry is WritableFieldSlot =>\n entry.field.writable && isEmittableField(context, entry.field);\n\nconst renderRecordConstructorPropsInterface = (\n context: ModuleContext,\n record: GirRecord,\n className: string,\n): string => {\n const head = `export interface ${className}ConstructorProps`;\n const { slots } = computeRecordFieldSlots(context, record.fields, record.isUnion);\n\n const lines = slots\n .filter((entry): entry is WritableFieldSlot => isWritableFieldSlot(context, entry))\n .map(\n (entry) =>\n `${getDoc(entry.field)}${toCamelIdentifier(entry.field.name)}?: ` +\n `${renderTsType(context, entry.field.type, true)};`,\n );\n\n return renderBracedOrEmpty(head, lines.join(\"\\n\"));\n};\n\nconst isSelfReturning = (context: ModuleContext, record: GirRecord, callable: GirFunction): boolean => {\n const ref = callable.returnValue.type;\n const name = ref === undefined ? undefined : context.library.nameFor(ref);\n\n return name?.namespaceName === context.namespace.name && name.typeName === record.name;\n};\n\nconst renderStaticCall = (context: ModuleContext, callable: GirFunction, name: string): string => {\n const args = inputParameters(context.library, callable).map(({ parameter, index }) =>\n parameterIdentifier(parameter, index));\n\n return `${name}(${args.join(\", \")})`;\n};\n\nconst constructionHint = (context: ModuleContext, spec: RecordConstructorSpec): string | undefined => {\n const candidates = staticMembers(context, spec.callables).filter(({ callable }) =>\n isSelfReturning(context, spec.record, callable));\n\n const candidate = candidates.find(({ name }) => name === \"new\") ?? candidates[0];\n\n return candidate === undefined ? undefined : renderStaticCall(context, candidate.callable, candidate.name);\n};\n\nconst unconstructibleMessage = (context: ModuleContext, spec: RecordConstructorSpec): string => {\n const qualified = `${context.namespace.name}.${spec.className}`;\n const hint = constructionHint(context, spec);\n\n return hint === undefined\n ? `Cannot construct ${qualified} with new: its instances come from the functions that return them.`\n : `Cannot construct ${qualified} with new: use ${qualified}.${hint} instead.`;\n};\n\nconst renderUnconstructibleGuard = (context: ModuleContext, spec: RecordConstructorSpec): string => {\n const superCall = spec.isErrorSubclass ? [\"super();\"] : [];\n const message = sourceStringLiteral(unconstructibleMessage(context, spec));\n\n return renderBlock(\"constructor()\", [...superCall, `throw new globalThis.Error(${message});`].join(\"\\n\"));\n};\n\nconst renderEmptyConstructor = (className: string, isErrorSubclass: boolean): string =>\n isErrorSubclass\n ? renderBlock(`constructor(props: ${className}ConstructorProps = {})`, \"super();\")\n : `constructor(props: ${className}ConstructorProps = {}) {}`;\n\nconst renderFieldWrites = (context: ModuleContext, slots: RecordFieldSlot[]): string[] => {\n const statements: string[] = [];\n\n for (const entry of slots) {\n if (isWritableFieldSlot(context, entry)) {\n statements.push(renderFieldWrite(context, entry));\n }\n }\n\n return statements;\n};\n\nconst renderRecordConstructor = (context: ModuleContext, spec: RecordConstructorSpec): string => {\n const { record, className, isErrorSubclass } = spec;\n\n if (!isConstructibleRecord(context, context.namespace.name, record)) {\n return renderUnconstructibleGuard(context, spec);\n }\n\n const superCall = isErrorSubclass ? [\"super();\"] : [];\n const { slots, size } = computeRecordFieldSlots(context, record.fields, record.isUnion);\n\n if (size === 0) {\n return renderEmptyConstructor(className, isErrorSubclass);\n }\n\n context.addRuntimeImport(\"alloc\");\n context.addRuntimeImport(\"setHandle\");\n\n const statements = [\n ...superCall,\n `const handle = alloc(${allocArgs(context, record, size).join(\", \")});`,\n ...renderFieldWrites(context, slots),\n \"setHandle(this, handle);\",\n ];\n\n return renderBlock(`constructor(props: ${className}ConstructorProps = {})`, statements.join(\"\\n\"));\n};\n\nconst allocArgs = (context: ModuleContext, record: GirRecord, size: number): string[] => {\n const args = [String(size)];\n\n if (renderSourceGtype(context, record) !== undefined) {\n args.push(\"this.__type__\");\n }\n\n return args;\n};\n\nconst renderFieldWrite = (context: ModuleContext, entry: WritableFieldSlot): string => {\n context.addRuntimeImport(\"t\");\n\n const descriptor = context.hoistDescriptor(\n renderDescriptor(context, entry.field.type, \"none\", { isInline: isInlineField(context, entry.field) }),\n );\n\n const name = toCamelIdentifier(entry.field.name);\n\n const write = emitFieldWrite(context, {\n descriptor,\n slot: entry.slot,\n targetExpr: \"handle\",\n valueExpr: `props.${name}`,\n });\n\n return `if (props.${name} !== undefined) ${write}`;\n};\n\nexport { renderRecordConstructorPropsInterface, renderRecordConstructor };\n"]}
1
+ {"version":3,"file":"record-constructor.js","sourceRoot":"","sources":["../../../src/store/gi/record-constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAkB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAwB,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAW/D,MAAM,mBAAmB,GAAG,CAAC,OAAsB,EAAE,KAAsB,EAA8B,EAAE,CACvG,KAAK,CAAC,KAAK,CAAC,QAAQ,IAAI,gBAAgB,CAAC,OAAO,E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BAAgB,GAAG,CAAC,OAAsB,EAAE,KAAwB,EAAU,EAAE;IAClF,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAE9B,MAAM,UAAU,GAAG,OAAO,CAAC,eAAe,CACtC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CACzG,CAAC;IAEF,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEjD,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE;QAClC,UAAU;QACV,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,SAAS,EAAE,SAAS,IAAI,EAAE;KAC7B,CAAC,CAAC;IAEH,OAAO,aAAa,IAAI,mBAAmB,KAAK,EAAE,CAAC;AACvD,CAAC,CAAC;AAEF,OAAO,EAAE,qCAAqC,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["import { sourceStringLiteral, toCamelIdentifier } from \"@gtkx/utils\";\nimport type { GirField } from \"../../gir/field.js\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { GirRecord } from \"../../gir/record.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { renderDescriptor } from \"../../analysis/descriptor-render.js\";\nimport { inputParameters, parameterIdentifier } from \"../../analysis/param-structure.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { renderBlock, renderBracedOrEmpty } from \"../../writer/emit.js\";\nimport { type Callables, staticMembers } from \"./callables.js\";\nimport { getDoc } from \"./doc-spec.js\";\nimport { renderSourceGtype } from \"./gtype-binding.js\";\nimport { emitFieldWrite, isEmittableField, isInlineField } from \"./record-field-accessor.js\";\nimport { computeRecordFieldSlots, type RecordFieldSlot } from \"./record-layout.js\";\nimport { isConstructibleRecord } from \"./value-marshalable.js\";\n\ntype WritableFieldSlot = RecordFieldSlot & { field: GirField & { type: TypeId } };\n\ntype RecordConstructorSpec = {\n record: GirRecord;\n className: string;\n callables: Callables;\n isErrorSubclass: boolean;\n};\n\nconst isWritableFieldSlot = (context: ModuleContext, entry: RecordFieldSlot): entry is WritableFieldSlot =>\n entry.field.writable && isEmittableField(context, entry.field);\n\nconst renderRecordConstructorPropsInterface = (\n context: ModuleContext,\n record: GirRecord,\n className: string,\n): string => {\n const head = `export interface ${className}ConstructorProps`;\n const { slots } = computeRecordFieldSlots(context, record.fields, record.isUnion);\n\n const lines = slots\n .filter((entry): entry is WritableFieldSlot => isWritableFieldSlot(context, entry))\n .map(\n (entry) =>\n `${getDoc(entry.field)}${toCamelIdentifier(entry.field.name)}?: ` +\n `${renderTsType(context, entry.field.type, true)};`,\n );\n\n return renderBracedOrEmpty(head, lines.join(\"\\n\"));\n};\n\nconst isSelfReturning = (context: ModuleContext, record: GirRecord, callable: GirFunction): boolean => {\n const ref = callable.returnValue.type;\n const name = ref === undefined ? undefined : context.library.nameFor(ref);\n\n return name?.namespaceName === context.namespace.name && name.typeName === record.name;\n};\n\nconst renderStaticCall = (context: ModuleContext, callable: GirFunction, name: string): string => {\n const args = inputParameters(context.library, callable).map(({ parameter, index }) =>\n parameterIdentifier(parameter, index));\n\n return `${name}(${args.join(\", \")})`;\n};\n\nconst constructionHint = (context: ModuleContext, spec: RecordConstructorSpec): string | undefined => {\n const candidates = staticMembers(context, spec.callables).filter(({ callable }) =>\n isSelfReturning(context, spec.record, callable));\n\n const candidate = candidates.find(({ name }) => name === \"new\") ?? candidates[0];\n\n return candidate === undefined ? undefined : renderStaticCall(context, candidate.callable, candidate.name);\n};\n\nconst unconstructibleMessage = (context: ModuleContext, spec: RecordConstructorSpec): string => {\n const qualified = `${context.namespace.name}.${spec.className}`;\n const hint = constructionHint(context, spec);\n\n return hint === undefined\n ? `Cannot construct ${qualified} with new: its instances come from the functions that return them.`\n : `Cannot construct ${qualified} with new: use ${qualified}.${hint} instead.`;\n};\n\nconst renderUnconstructibleGuard = (context: ModuleContext, spec: RecordConstructorSpec): string => {\n const superCall = spec.isErrorSubclass ? [\"super();\"] : [];\n const message = sourceStringLiteral(unconstructibleMessage(context, spec));\n\n return renderBlock(\"constructor()\", [...superCall, `throw new globalThis.Error(${message});`].join(\"\\n\"));\n};\n\nconst renderEmptyConstructor = (className: string, isErrorSubclass: boolean): string =>\n isErrorSubclass\n ? renderBlock(`constructor(props: ${className}ConstructorProps = {})`, \"super();\")\n : `constructor(props: ${className}ConstructorProps = {}) {}`;\n\nconst renderFieldWrites = (context: ModuleContext, slots: RecordFieldSlot[]): string[] => {\n const statements: string[] = [];\n\n for (const entry of slots) {\n if (isWritableFieldSlot(context, entry)) {\n statements.push(renderFieldWrite(context, entry));\n }\n }\n\n return statements;\n};\n\nconst renderRecordConstructor = (context: ModuleContext, spec: RecordConstructorSpec): string => {\n const { record, className, isErrorSubclass } = spec;\n\n if (!isConstructibleRecord(context, context.namespace.name, record)) {\n return renderUnconstructibleGuard(context, spec);\n }\n\n const superCall = isErrorSubclass ? [\"super();\"] : [];\n const { slots, size } = computeRecordFieldSlots(context, record.fields, record.isUnion);\n\n if (size === 0) {\n return renderEmptyConstructor(className, isErrorSubclass);\n }\n\n context.addRuntimeImport(\"alloc\");\n context.addRuntimeImport(\"setHandle\");\n\n const statements = [\n ...superCall,\n `const __handle = alloc(${allocArgs(context, record, size).join(\", \")});`,\n ...renderFieldWrites(context, slots),\n \"setHandle(this, __handle);\",\n ];\n\n return renderBlock(`constructor(props: ${className}ConstructorProps = {})`, statements.join(\"\\n\"));\n};\n\nconst allocArgs = (context: ModuleContext, record: GirRecord, size: number): string[] => {\n const args = [String(size)];\n\n if (renderSourceGtype(context, record) !== undefined) {\n args.push(\"this.__type__\");\n }\n\n return args;\n};\n\nconst renderFieldWrite = (context: ModuleContext, entry: WritableFieldSlot): string => {\n context.addRuntimeImport(\"t\");\n\n const descriptor = context.hoistDescriptor(\n renderDescriptor(context, entry.field.type, \"none\", { isInline: isInlineField(context, entry.field) }),\n );\n\n const name = toCamelIdentifier(entry.field.name);\n\n const write = emitFieldWrite(context, {\n descriptor,\n slot: entry.slot,\n targetExpr: \"__handle\",\n valueExpr: `props.${name}`,\n });\n\n return `if (props.${name} !== undefined) ${write}`;\n};\n\nexport { renderRecordConstructorPropsInterface, renderRecordConstructor };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"record-field-accessor.d.ts","sourceRoot":"","sources":["../../../src/store/gi/record-field-accessor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAM7D,OAAO,EAAmD,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI3G,KAAK,cAAc,GAAG;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAOF,KAAK,gBAAgB,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,WAAW,EAAE,cAAc,CAAC;CAC/B,CAAC;AA2EF,QAAA,MAAM,gBAAgB,GAAI,SAAS,aAAa,EAAE,OAAO,QAAQ,KAAG,KAAK,IAAI,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAIhE,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