@gtkx/codegen 1.0.0-rc.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/README.md +5 -5
  2. package/dist/analysis/descriptor-render.d.ts +8 -1
  3. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  4. package/dist/analysis/descriptor-render.js +37 -24
  5. package/dist/analysis/descriptor-render.js.map +1 -1
  6. package/dist/analysis/descriptor.d.ts +1 -1
  7. package/dist/analysis/descriptor.d.ts.map +1 -1
  8. package/dist/analysis/descriptor.js.map +1 -1
  9. package/dist/analysis/inheritance.d.ts +1 -2
  10. package/dist/analysis/inheritance.d.ts.map +1 -1
  11. package/dist/analysis/inheritance.js +25 -22
  12. package/dist/analysis/inheritance.js.map +1 -1
  13. package/dist/analysis/nul-terminated-bytes.d.ts +5 -0
  14. package/dist/analysis/nul-terminated-bytes.d.ts.map +1 -0
  15. package/dist/analysis/nul-terminated-bytes.js +18 -0
  16. package/dist/analysis/nul-terminated-bytes.js.map +1 -0
  17. package/dist/analysis/param-capability.d.ts +5 -0
  18. package/dist/analysis/param-capability.d.ts.map +1 -0
  19. package/dist/analysis/param-capability.js +130 -0
  20. package/dist/analysis/param-capability.js.map +1 -0
  21. package/dist/analysis/param-structure.d.ts +11 -4
  22. package/dist/analysis/param-structure.d.ts.map +1 -1
  23. package/dist/analysis/param-structure.js +40 -14
  24. package/dist/analysis/param-structure.js.map +1 -1
  25. package/dist/analysis/type-shape.d.ts +8 -0
  26. package/dist/analysis/type-shape.d.ts.map +1 -0
  27. package/dist/analysis/type-shape.js +12 -0
  28. package/dist/analysis/type-shape.js.map +1 -0
  29. package/dist/compile.d.ts +1 -1
  30. package/dist/compile.d.ts.map +1 -1
  31. package/dist/compile.js.map +1 -1
  32. package/dist/docs/api-reference.d.ts +2 -2
  33. package/dist/docs/api-reference.d.ts.map +1 -1
  34. package/dist/docs/api-reference.js +7 -14
  35. package/dist/docs/api-reference.js.map +1 -1
  36. package/dist/docs/element-page.d.ts +4 -4
  37. package/dist/docs/element-page.d.ts.map +1 -1
  38. package/dist/docs/element-page.js +32 -20
  39. package/dist/docs/element-page.js.map +1 -1
  40. package/dist/docs/handwritten-props.d.ts +9 -0
  41. package/dist/docs/handwritten-props.d.ts.map +1 -0
  42. package/dist/docs/handwritten-props.js +149 -0
  43. package/dist/docs/handwritten-props.js.map +1 -0
  44. package/dist/docs/pipeline.js +2 -2
  45. package/dist/docs/pipeline.js.map +1 -1
  46. package/dist/docs/render.d.ts +25 -5
  47. package/dist/docs/render.d.ts.map +1 -1
  48. package/dist/docs/render.js +84 -22
  49. package/dist/docs/render.js.map +1 -1
  50. package/dist/docs/symbol-page.d.ts +17 -0
  51. package/dist/docs/symbol-page.d.ts.map +1 -1
  52. package/dist/docs/symbol-page.js +128 -43
  53. package/dist/docs/symbol-page.js.map +1 -1
  54. package/dist/fingerprint.d.ts +1 -1
  55. package/dist/fingerprint.d.ts.map +1 -1
  56. package/dist/fingerprint.js.map +1 -1
  57. package/dist/gir/ancestry.d.ts +2 -2
  58. package/dist/gir/ancestry.d.ts.map +1 -1
  59. package/dist/gir/ancestry.js +11 -1
  60. package/dist/gir/ancestry.js.map +1 -1
  61. package/dist/gir/annotations.d.ts +22 -0
  62. package/dist/gir/annotations.d.ts.map +1 -0
  63. package/dist/gir/annotations.js +15 -0
  64. package/dist/gir/annotations.js.map +1 -0
  65. package/dist/gir/callback.d.ts +1 -0
  66. package/dist/gir/callback.d.ts.map +1 -1
  67. package/dist/gir/callback.js +1 -0
  68. package/dist/gir/callback.js.map +1 -1
  69. package/dist/gir/class.d.ts +32 -1
  70. package/dist/gir/class.d.ts.map +1 -1
  71. package/dist/gir/class.js +8 -3
  72. package/dist/gir/class.js.map +1 -1
  73. package/dist/gir/enum.d.ts +21 -1
  74. package/dist/gir/enum.d.ts.map +1 -1
  75. package/dist/gir/enum.js +9 -9
  76. package/dist/gir/enum.js.map +1 -1
  77. package/dist/gir/field.d.ts +19 -3
  78. package/dist/gir/field.d.ts.map +1 -1
  79. package/dist/gir/field.js +7 -8
  80. package/dist/gir/field.js.map +1 -1
  81. package/dist/gir/function.d.ts +15 -0
  82. package/dist/gir/function.d.ts.map +1 -1
  83. package/dist/gir/function.js.map +1 -1
  84. package/dist/gir/libraries.d.ts +1 -3
  85. package/dist/gir/libraries.d.ts.map +1 -1
  86. package/dist/gir/libraries.js +0 -1
  87. package/dist/gir/libraries.js.map +1 -1
  88. package/dist/gir/library.d.ts +36 -0
  89. package/dist/gir/library.d.ts.map +1 -1
  90. package/dist/gir/library.js +34 -0
  91. package/dist/gir/library.js.map +1 -1
  92. package/dist/gir/namespace.d.ts +38 -0
  93. package/dist/gir/namespace.d.ts.map +1 -1
  94. package/dist/gir/namespace.js +4 -5
  95. package/dist/gir/namespace.js.map +1 -1
  96. package/dist/gir/parameter.d.ts +39 -0
  97. package/dist/gir/parameter.d.ts.map +1 -1
  98. package/dist/gir/parameter.js +7 -3
  99. package/dist/gir/parameter.js.map +1 -1
  100. package/dist/gir/parse.d.ts +3 -1
  101. package/dist/gir/parse.d.ts.map +1 -1
  102. package/dist/gir/parse.js +6 -3
  103. package/dist/gir/parse.js.map +1 -1
  104. package/dist/gir/primitives.d.ts +1 -0
  105. package/dist/gir/primitives.d.ts.map +1 -1
  106. package/dist/gir/primitives.js.map +1 -1
  107. package/dist/gir/property.d.ts +16 -0
  108. package/dist/gir/property.d.ts.map +1 -1
  109. package/dist/gir/property.js +3 -3
  110. package/dist/gir/property.js.map +1 -1
  111. package/dist/gir/record.d.ts +22 -0
  112. package/dist/gir/record.d.ts.map +1 -1
  113. package/dist/gir/record.js +3 -2
  114. package/dist/gir/record.js.map +1 -1
  115. package/dist/gir/size.d.ts +5 -4
  116. package/dist/gir/size.d.ts.map +1 -1
  117. package/dist/gir/size.js.map +1 -1
  118. package/dist/gir/type-id.d.ts +35 -0
  119. package/dist/gir/type-id.d.ts.map +1 -1
  120. package/dist/gir/type-id.js +1 -0
  121. package/dist/gir/type-id.js.map +1 -1
  122. package/dist/gir/type-ref.d.ts.map +1 -1
  123. package/dist/gir/type-ref.js +1 -0
  124. package/dist/gir/type-ref.js.map +1 -1
  125. package/dist/gir/type.d.ts +20 -0
  126. package/dist/gir/type.d.ts.map +1 -1
  127. package/dist/gir/type.js.map +1 -1
  128. package/dist/khronos/args.d.ts +7 -6
  129. package/dist/khronos/args.d.ts.map +1 -1
  130. package/dist/khronos/args.js +28 -6
  131. package/dist/khronos/args.js.map +1 -1
  132. package/dist/khronos/doc-context.d.ts +29 -0
  133. package/dist/khronos/doc-context.d.ts.map +1 -0
  134. package/dist/khronos/doc-context.js +29 -0
  135. package/dist/khronos/doc-context.js.map +1 -0
  136. package/dist/khronos/extensions.d.ts +13 -0
  137. package/dist/khronos/extensions.d.ts.map +1 -0
  138. package/dist/khronos/extensions.js +49 -0
  139. package/dist/khronos/extensions.js.map +1 -0
  140. package/dist/khronos/jsdoc.d.ts +17 -11
  141. package/dist/khronos/jsdoc.d.ts.map +1 -1
  142. package/dist/khronos/jsdoc.js +104 -46
  143. package/dist/khronos/jsdoc.js.map +1 -1
  144. package/dist/khronos/model.d.ts +42 -3
  145. package/dist/khronos/model.d.ts.map +1 -1
  146. package/dist/khronos/model.js +218 -63
  147. package/dist/khronos/model.js.map +1 -1
  148. package/dist/khronos/modules.d.ts +9 -6
  149. package/dist/khronos/modules.d.ts.map +1 -1
  150. package/dist/khronos/modules.js +96 -26
  151. package/dist/khronos/modules.js.map +1 -1
  152. package/dist/khronos/notes.d.ts +19 -0
  153. package/dist/khronos/notes.d.ts.map +1 -0
  154. package/dist/khronos/notes.js +35 -0
  155. package/dist/khronos/notes.js.map +1 -0
  156. package/dist/khronos/param-pair.d.ts +1 -1
  157. package/dist/khronos/param-pair.d.ts.map +1 -1
  158. package/dist/khronos/param-pair.js.map +1 -1
  159. package/dist/khronos/pipeline.d.ts +3 -1
  160. package/dist/khronos/pipeline.d.ts.map +1 -1
  161. package/dist/khronos/pipeline.js +58 -27
  162. package/dist/khronos/pipeline.js.map +1 -1
  163. package/dist/khronos/plan.d.ts +3 -3
  164. package/dist/khronos/plan.d.ts.map +1 -1
  165. package/dist/khronos/plan.js +2 -2
  166. package/dist/khronos/plan.js.map +1 -1
  167. package/dist/khronos/render.d.ts +8 -6
  168. package/dist/khronos/render.d.ts.map +1 -1
  169. package/dist/khronos/render.js +35 -26
  170. package/dist/khronos/render.js.map +1 -1
  171. package/dist/khronos/select.d.ts +21 -4
  172. package/dist/khronos/select.d.ts.map +1 -1
  173. package/dist/khronos/select.js +47 -34
  174. package/dist/khronos/select.js.map +1 -1
  175. package/dist/react/element-config.d.ts +2 -2
  176. package/dist/react/element-config.d.ts.map +1 -1
  177. package/dist/react/element-config.js.map +1 -1
  178. package/dist/runner.d.ts +1 -7
  179. package/dist/runner.d.ts.map +1 -1
  180. package/dist/runner.js.map +1 -1
  181. package/dist/store/compile-store.d.ts +1 -1
  182. package/dist/store/compile-store.d.ts.map +1 -1
  183. package/dist/store/compile-store.js.map +1 -1
  184. package/dist/store/gi/callable-doc.d.ts +11 -0
  185. package/dist/store/gi/callable-doc.d.ts.map +1 -0
  186. package/dist/store/gi/callable-doc.js +62 -0
  187. package/dist/store/gi/callable-doc.js.map +1 -0
  188. package/dist/store/gi/callables.d.ts +3 -1
  189. package/dist/store/gi/callables.d.ts.map +1 -1
  190. package/dist/store/gi/callables.js +12 -12
  191. package/dist/store/gi/callables.js.map +1 -1
  192. package/dist/store/gi/callback.d.ts.map +1 -1
  193. package/dist/store/gi/callback.js +2 -2
  194. package/dist/store/gi/callback.js.map +1 -1
  195. package/dist/store/gi/class.d.ts.map +1 -1
  196. package/dist/store/gi/class.js +5 -3
  197. package/dist/store/gi/class.js.map +1 -1
  198. package/dist/store/gi/closure-invocation.d.ts +4 -0
  199. package/dist/store/gi/closure-invocation.d.ts.map +1 -0
  200. package/dist/store/gi/closure-invocation.js +22 -0
  201. package/dist/store/gi/closure-invocation.js.map +1 -0
  202. package/dist/store/gi/constant.d.ts.map +1 -1
  203. package/dist/store/gi/constant.js +3 -2
  204. package/dist/store/gi/constant.js.map +1 -1
  205. package/dist/store/gi/constructor-props.d.ts.map +1 -1
  206. package/dist/store/gi/constructor-props.js +18 -20
  207. package/dist/store/gi/constructor-props.js.map +1 -1
  208. package/dist/store/gi/doc-spec.d.ts +14 -0
  209. package/dist/store/gi/doc-spec.d.ts.map +1 -0
  210. package/dist/store/gi/doc-spec.js +23 -0
  211. package/dist/store/gi/doc-spec.js.map +1 -0
  212. package/dist/store/gi/enum.d.ts.map +1 -1
  213. package/dist/store/gi/enum.js +29 -16
  214. package/dist/store/gi/enum.js.map +1 -1
  215. package/dist/store/gi/function.d.ts.map +1 -1
  216. package/dist/store/gi/function.js +27 -12
  217. package/dist/store/gi/function.js.map +1 -1
  218. package/dist/store/gi/interface.d.ts.map +1 -1
  219. package/dist/store/gi/interface.js +130 -16
  220. package/dist/store/gi/interface.js.map +1 -1
  221. package/dist/store/gi/item-comparators.d.ts.map +1 -1
  222. package/dist/store/gi/item-comparators.js +3 -5
  223. package/dist/store/gi/item-comparators.js.map +1 -1
  224. package/dist/store/gi/method.d.ts +9 -1
  225. package/dist/store/gi/method.d.ts.map +1 -1
  226. package/dist/store/gi/method.js +69 -26
  227. package/dist/store/gi/method.js.map +1 -1
  228. package/dist/store/gi/param-marshal.d.ts +4 -1
  229. package/dist/store/gi/param-marshal.d.ts.map +1 -1
  230. package/dist/store/gi/param-marshal.js +5 -1
  231. package/dist/store/gi/param-marshal.js.map +1 -1
  232. package/dist/store/gi/pipeline.d.ts.map +1 -1
  233. package/dist/store/gi/pipeline.js +3 -2
  234. package/dist/store/gi/pipeline.js.map +1 -1
  235. package/dist/store/gi/properties.d.ts.map +1 -1
  236. package/dist/store/gi/properties.js +2 -2
  237. package/dist/store/gi/properties.js.map +1 -1
  238. package/dist/store/gi/property-accessor.d.ts +3 -1
  239. package/dist/store/gi/property-accessor.d.ts.map +1 -1
  240. package/dist/store/gi/property-accessor.js +6 -5
  241. package/dist/store/gi/property-accessor.js.map +1 -1
  242. package/dist/store/gi/record-constructor.d.ts.map +1 -1
  243. package/dist/store/gi/record-constructor.js +3 -1
  244. package/dist/store/gi/record-constructor.js.map +1 -1
  245. package/dist/store/gi/record-field-accessor.d.ts +3 -1
  246. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  247. package/dist/store/gi/record-field-accessor.js +3 -2
  248. package/dist/store/gi/record-field-accessor.js.map +1 -1
  249. package/dist/store/gi/record-layout.js +1 -1
  250. package/dist/store/gi/record-layout.js.map +1 -1
  251. package/dist/store/gi/record.d.ts.map +1 -1
  252. package/dist/store/gi/record.js +3 -2
  253. package/dist/store/gi/record.js.map +1 -1
  254. package/dist/store/gi/registration.d.ts +1 -1
  255. package/dist/store/gi/registration.js +2 -2
  256. package/dist/store/gi/registration.js.map +1 -1
  257. package/dist/store/gi/runtime-override.d.ts +2 -1
  258. package/dist/store/gi/runtime-override.d.ts.map +1 -1
  259. package/dist/store/gi/runtime-override.js +8 -5
  260. package/dist/store/gi/runtime-override.js.map +1 -1
  261. package/dist/store/gi/signal.d.ts.map +1 -1
  262. package/dist/store/gi/signal.js +14 -15
  263. package/dist/store/gi/signal.js.map +1 -1
  264. package/dist/store/gi/value-marshalable.d.ts +1 -2
  265. package/dist/store/gi/value-marshalable.d.ts.map +1 -1
  266. package/dist/store/gi/value-marshalable.js +1 -1
  267. package/dist/store/gi/value-marshalable.js.map +1 -1
  268. package/dist/store/gi/vtable.d.ts +16 -1
  269. package/dist/store/gi/vtable.d.ts.map +1 -1
  270. package/dist/store/gi/vtable.js +214 -51
  271. package/dist/store/gi/vtable.js.map +1 -1
  272. package/dist/store/jsx/element-components.d.ts +1 -1
  273. package/dist/store/jsx/element-components.d.ts.map +1 -1
  274. package/dist/store/jsx/element-components.js +6 -4
  275. package/dist/store/jsx/element-components.js.map +1 -1
  276. package/dist/store/jsx/element-prop-imports.d.ts +1 -3
  277. package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
  278. package/dist/store/jsx/element-prop-imports.js.map +1 -1
  279. package/dist/store/jsx/element-prop-types.d.ts +3 -0
  280. package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
  281. package/dist/store/jsx/element-prop-types.js +7 -1
  282. package/dist/store/jsx/element-prop-types.js.map +1 -1
  283. package/dist/store/jsx/intrinsic-elements.d.ts +4 -0
  284. package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -1
  285. package/dist/store/jsx/intrinsic-elements.js.map +1 -1
  286. package/dist/store/jsx/jsx.d.ts.map +1 -1
  287. package/dist/store/jsx/jsx.js +7 -6
  288. package/dist/store/jsx/jsx.js.map +1 -1
  289. package/dist/store/jsx/metadata.js +2 -2
  290. package/dist/store/jsx/metadata.js.map +1 -1
  291. package/dist/store/jsx/pipeline.d.ts +1 -1
  292. package/dist/store/jsx/pipeline.d.ts.map +1 -1
  293. package/dist/store/jsx/pipeline.js.map +1 -1
  294. package/dist/store/jsx/props.d.ts +1 -7
  295. package/dist/store/jsx/props.d.ts.map +1 -1
  296. package/dist/store/jsx/props.js +14 -6
  297. package/dist/store/jsx/props.js.map +1 -1
  298. package/dist/writer/context.d.ts +2 -1
  299. package/dist/writer/context.d.ts.map +1 -1
  300. package/dist/writer/context.js +3 -0
  301. package/dist/writer/context.js.map +1 -1
  302. package/dist/writer/doc-tags.d.ts +21 -0
  303. package/dist/writer/doc-tags.d.ts.map +1 -0
  304. package/dist/writer/doc-tags.js +38 -0
  305. package/dist/writer/doc-tags.js.map +1 -0
  306. package/dist/writer/doc.d.ts +3 -1
  307. package/dist/writer/doc.d.ts.map +1 -1
  308. package/dist/writer/doc.js +19 -6
  309. package/dist/writer/doc.js.map +1 -1
  310. package/dist/writer/gtk-doc.d.ts +1 -1
  311. package/dist/writer/gtk-doc.d.ts.map +1 -1
  312. package/dist/writer/gtk-doc.js +64 -15
  313. package/dist/writer/gtk-doc.js.map +1 -1
  314. package/dist/writer/module.d.ts +8 -2
  315. package/dist/writer/module.d.ts.map +1 -1
  316. package/dist/writer/module.js +13 -1
  317. package/dist/writer/module.js.map +1 -1
  318. package/overrides/gdk/rgba.ts.ejs +26 -0
  319. package/overrides/gobject/object.ts.ejs +48 -3
  320. package/overrides/gobject/value.ts.ejs +7 -0
  321. package/overrides/graphene/structs.ts.ejs +55 -0
  322. package/package.json +4 -4
  323. package/src/analysis/descriptor-render.ts +47 -28
  324. package/src/analysis/descriptor.ts +0 -3
  325. package/src/analysis/inheritance.ts +35 -34
  326. package/src/analysis/nul-terminated-bytes.ts +31 -0
  327. package/src/analysis/param-capability.ts +172 -0
  328. package/src/analysis/param-structure.ts +83 -23
  329. package/src/analysis/type-shape.ts +24 -0
  330. package/src/compile.ts +1 -1
  331. package/src/docs/api-reference.ts +36 -25
  332. package/src/docs/element-page.ts +53 -47
  333. package/src/docs/handwritten-props.ts +230 -0
  334. package/src/docs/pipeline.ts +2 -2
  335. package/src/docs/render.ts +146 -32
  336. package/src/docs/symbol-page.ts +224 -79
  337. package/src/fingerprint.ts +0 -1
  338. package/src/gir/ancestry.ts +15 -1
  339. package/src/gir/annotations.ts +37 -0
  340. package/src/gir/callback.ts +2 -0
  341. package/src/gir/class.ts +42 -4
  342. package/src/gir/enum.ts +30 -10
  343. package/src/gir/field.ts +24 -9
  344. package/src/gir/function.ts +15 -0
  345. package/src/gir/libraries.ts +11 -3
  346. package/src/gir/library.ts +51 -2
  347. package/src/gir/namespace.ts +41 -5
  348. package/src/gir/parameter.ts +47 -3
  349. package/src/gir/parse.ts +8 -2
  350. package/src/gir/primitives.ts +1 -0
  351. package/src/gir/property.ts +18 -3
  352. package/src/gir/record.ts +24 -2
  353. package/src/gir/size.ts +8 -3
  354. package/src/gir/type-id.ts +49 -3
  355. package/src/gir/type-ref.ts +1 -0
  356. package/src/gir/type.ts +50 -6
  357. package/src/khronos/args.ts +36 -13
  358. package/src/khronos/doc-context.ts +62 -0
  359. package/src/khronos/extensions.ts +85 -0
  360. package/src/khronos/jsdoc.ts +152 -56
  361. package/src/khronos/model.ts +314 -69
  362. package/src/khronos/modules.ts +134 -40
  363. package/src/khronos/notes.ts +74 -0
  364. package/src/khronos/param-pair.ts +1 -1
  365. package/src/khronos/pipeline.ts +94 -41
  366. package/src/khronos/plan.ts +4 -5
  367. package/src/khronos/render.ts +62 -50
  368. package/src/khronos/select.ts +91 -50
  369. package/src/react/element-config.ts +2 -2
  370. package/src/runner.ts +1 -8
  371. package/src/store/compile-store.ts +1 -1
  372. package/src/store/gi/callable-doc.ts +102 -0
  373. package/src/store/gi/callables.ts +18 -12
  374. package/src/store/gi/callback.ts +3 -2
  375. package/src/store/gi/class.ts +6 -3
  376. package/src/store/gi/closure-invocation.ts +26 -0
  377. package/src/store/gi/constant.ts +3 -4
  378. package/src/store/gi/constructor-props.ts +19 -23
  379. package/src/store/gi/doc-spec.ts +38 -0
  380. package/src/store/gi/enum.ts +55 -20
  381. package/src/store/gi/function.ts +43 -21
  382. package/src/store/gi/interface.ts +214 -26
  383. package/src/store/gi/item-comparators.ts +3 -5
  384. package/src/store/gi/method.ts +98 -42
  385. package/src/store/gi/param-marshal.ts +15 -1
  386. package/src/store/gi/pipeline.ts +7 -2
  387. package/src/store/gi/properties.ts +3 -2
  388. package/src/store/gi/property-accessor.ts +9 -4
  389. package/src/store/gi/record-constructor.ts +6 -1
  390. package/src/store/gi/record-field-accessor.ts +5 -3
  391. package/src/store/gi/record-layout.ts +1 -1
  392. package/src/store/gi/record.ts +8 -2
  393. package/src/store/gi/registration.ts +3 -3
  394. package/src/store/gi/runtime-override.ts +13 -6
  395. package/src/store/gi/signal.ts +19 -20
  396. package/src/store/gi/value-marshalable.ts +1 -1
  397. package/src/store/gi/vtable.ts +361 -60
  398. package/src/store/jsx/element-components.ts +8 -5
  399. package/src/store/jsx/element-prop-imports.ts +1 -3
  400. package/src/store/jsx/element-prop-types.ts +10 -1
  401. package/src/store/jsx/intrinsic-elements.ts +4 -0
  402. package/src/store/jsx/jsx.ts +8 -6
  403. package/src/store/jsx/metadata.ts +2 -2
  404. package/src/store/jsx/pipeline.ts +1 -1
  405. package/src/store/jsx/props.ts +20 -7
  406. package/src/writer/context.ts +5 -1
  407. package/src/writer/doc-tags.ts +70 -0
  408. package/src/writer/doc.ts +29 -6
  409. package/src/writer/gtk-doc.ts +82 -15
  410. package/src/writer/module.ts +25 -2
package/src/gir/parse.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { createXmlParser } from "../xml.js";
3
3
 
4
+ /** An element of the parsed GIR XML: attributes under `@_`-prefixed keys, children under their tag names. */
4
5
  type RawNode = Record<string, unknown>;
5
6
 
6
7
  const MULTI_TAGS: Set<string> = new Set([
@@ -16,6 +17,7 @@ const MULTI_TAGS: Set<string> = new Set([
16
17
  "alias",
17
18
  "union",
18
19
  "method",
20
+ "virtual-method",
19
21
  "constructor",
20
22
  "property",
21
23
  "field",
@@ -141,12 +143,12 @@ const docTextFromObject = (value: object): string | undefined => {
141
143
  return typeof text === "string" ? normalizeDoc(text) : undefined;
142
144
  };
143
145
 
144
- const getDoc = (node: RawNode | undefined): string | undefined => {
146
+ const docElementText = (node: RawNode | undefined, tag: string): string | undefined => {
145
147
  if (node === undefined) {
146
148
  return undefined;
147
149
  }
148
150
 
149
- const value = firstDocValue(node.doc);
151
+ const value = firstDocValue(node[tag]);
150
152
 
151
153
  if (typeof value === "string") {
152
154
  return normalizeDoc(value);
@@ -159,6 +161,9 @@ const getDoc = (node: RawNode | undefined): string | undefined => {
159
161
  return docTextFromObject(value);
160
162
  };
161
163
 
164
+ const getDoc = (node: RawNode | undefined): string | undefined => docElementText(node, "doc");
165
+ const getDocDeprecated = (node: RawNode | undefined): string | undefined => docElementText(node, "doc-deprecated");
166
+
162
167
  export {
163
168
  GIR_CONSTRUCTOR_TAG,
164
169
  parseGirFile,
@@ -170,5 +175,6 @@ export {
170
175
  getChildren,
171
176
  getChild,
172
177
  getDoc,
178
+ getDocDeprecated,
173
179
  type RawNode,
174
180
  };
@@ -1,3 +1,4 @@
1
+ /** A fundamental C type GIR can name, collapsed to the marshalling category GTKX treats it as. */
1
2
  type PrimitiveCategory =
2
3
  | "void" |
3
4
  "boolean" |
@@ -1,20 +1,36 @@
1
1
  import type { ParseContext, TypeId } from "./type-id.js";
2
+ import { documentedFromNode, type GirAnnotations } from "./annotations.js";
2
3
  import { type ParameterTransfer, transferOwnership } from "./parameter.js";
3
- import { attr, getDoc, isAttrTrue, nameAttr, type RawNode } from "./parse.js";
4
+ import { attr, isAttrTrue, type RawNode } from "./parse.js";
4
5
  import { typeRefFromNode } from "./type-ref.js";
5
6
 
7
+ /** A GObject property declared on a class or interface, with the annotations its accessors are generated from. */
6
8
  type GirProperty = {
9
+ /** Canonical property name, dashed the way GObject registers it. */
7
10
  name: string;
11
+ /** Documentation prose from GIR, emitted as the accessor's JSDoc. */
8
12
  doc: string | undefined;
13
+ /** Release and deprecation annotations GIR carries on the property. */
14
+ annotations: GirAnnotations;
15
+ /** The property's value type, absent when GIR declares none. */
9
16
  type: TypeId | undefined;
17
+ /** Whether GObject exposes the value for reading, which admits a generated getter. */
10
18
  readable: boolean;
19
+ /** Whether GObject accepts a value for the property, which admits a generated setter. */
11
20
  writable: boolean;
21
+ /** Whether GObject sets the property during construction, using its default when none is supplied. */
12
22
  construct: boolean;
23
+ /** Whether the property can only be set at construction. */
13
24
  constructOnly: boolean;
25
+ /** Whether GIR exposes the property to bindings. */
14
26
  introspectable: boolean;
27
+ /** How ownership of the value transfers, which decides the descriptor the accessors marshal through. */
15
28
  transferOwnership: ParameterTransfer;
29
+ /** Method GIR names as reading the property, which the generated getter delegates to. */
16
30
  getter: string | undefined;
31
+ /** Method GIR names as writing the property, which the generated setter delegates to. */
17
32
  setter: string | undefined;
33
+ /** The property's default, as GIR spells it. */
18
34
  defaultValue: string | undefined;
19
35
  };
20
36
 
@@ -22,8 +38,7 @@ const isConstructableProperty = (property: GirProperty): boolean =>
22
38
  property.writable || property.construct || property.constructOnly;
23
39
 
24
40
  const propertyFromNode = (node: RawNode, context: ParseContext): GirProperty => ({
25
- name: nameAttr(node),
26
- doc: getDoc(node),
41
+ ...documentedFromNode(node),
27
42
  type: typeRefFromNode(node, context),
28
43
  readable: isAttrTrue(node, "readable", true),
29
44
  writable: isAttrTrue(node, "writable"),
package/src/gir/record.ts CHANGED
@@ -1,26 +1,48 @@
1
1
  import type { ParseContext } from "./type-id.js";
2
+ import { documentedFromNode, type GirAnnotations } from "./annotations.js";
2
3
  import { collectFields, type GirField } from "./field.js";
3
4
  import { functionFromNode, type GirFunction } from "./function.js";
4
- import { attr, getChildren, getDoc, GIR_CONSTRUCTOR_TAG, isAttrTrue, type RawNode } from "./parse.js";
5
+ import { attr, getChildren, GIR_CONSTRUCTOR_TAG, isAttrTrue, type RawNode } from "./parse.js";
5
6
 
7
+ /** A C struct or union declared by a GIR namespace: a plain record, a boxed type, or a GObject vtable. */
6
8
  type GirRecord = {
9
+ /** Whether the record is the class or interface struct holding another type's virtual methods. */
7
10
  isVtable: boolean;
11
+ /** Name within the declaring namespace, such as `"TextIter"`. */
8
12
  name: string;
13
+ /** Raw gtk-doc text from the GIR, undefined when the record is undocumented. */
9
14
  doc: string | undefined;
15
+ /** Release and deprecation annotations GIR carries on the record. */
16
+ annotations: GirAnnotations;
17
+ /** C struct name, such as `"GtkTextIter"`. */
10
18
  cType: string | undefined;
19
+ /** GLib type name the record is registered under, present when it is a boxed type. */
11
20
  glibTypeName: string | undefined;
21
+ /** Name of the function registering the record's GType, such as `"gtk_text_iter_get_type"`. */
12
22
  glibGetType: string | undefined;
23
+ /** Name of the function taking a reference, for reference-counted records. */
13
24
  glibRefFunc: string | undefined;
25
+ /** Name of the function dropping a reference, for reference-counted records. */
14
26
  glibUnrefFunc: string | undefined;
27
+ /** Name of the function duplicating an instance, used when the record has no ref function. */
15
28
  copyFunc: string | undefined;
29
+ /** Name of the function releasing an instance, used when the record has no unref function. */
16
30
  freeFunc: string | undefined;
31
+ /** Whether the struct is only ever handled behind a pointer, so its layout stays hidden. */
17
32
  disguised: boolean;
33
+ /** Whether the struct's fields are private, so instances cannot be allocated or read directly. */
18
34
  opaque: boolean;
35
+ /** Whether the record is exposed to language bindings. */
19
36
  introspectable: boolean;
37
+ /** Struct members: the named fields first, then the anonymous inline unions, then the inline records. */
20
38
  fields: GirField[];
39
+ /** Functions taking an instance of the record as their first argument. */
21
40
  methods: GirFunction[];
41
+ /** Functions returning a new instance of the record. */
22
42
  constructors: GirFunction[];
43
+ /** Functions scoped to the record but taking no instance. */
23
44
  functions: GirFunction[];
45
+ /** Whether the record is a union, so its fields overlap instead of following one another. */
24
46
  isUnion: boolean;
25
47
  };
26
48
 
@@ -31,8 +53,8 @@ const recordFromNode = (
31
53
  context: ParseContext,
32
54
  ): GirRecord => ({
33
55
  isVtable,
56
+ ...documentedFromNode(node),
34
57
  name: attr(node, "name") ?? attr(node, "glib:name") ?? "",
35
- doc: getDoc(node),
36
58
  cType: attr(node, "c:type"),
37
59
  glibTypeName: attr(node, "glib:type-name"),
38
60
  glibGetType: attr(node, "glib:get-type"),
package/src/gir/size.ts CHANGED
@@ -11,6 +11,11 @@ type FieldSlot = {
11
11
  bitWidth: number | undefined;
12
12
  };
13
13
 
14
+ type FieldSlots = {
15
+ slots: FieldSlot[];
16
+ size: number;
17
+ };
18
+
14
19
  type FieldLayoutInput = {
15
20
  layout: FieldLayout;
16
21
  bits: number | undefined;
@@ -39,7 +44,7 @@ const roundUp = (value: number, multiple: number): number => {
39
44
  return remainder === 0 ? value : value + (multiple - remainder);
40
45
  };
41
46
 
42
- const computeUnionSlots = (fields: FieldLayoutInput[]): { slots: FieldSlot[]; size: number } => {
47
+ const computeUnionSlots = (fields: FieldLayoutInput[]): FieldSlots => {
43
48
  let maxSize = 0;
44
49
  let maxAlign = 1;
45
50
 
@@ -95,7 +100,7 @@ const processStructField = (state: StructLayoutState, slots: FieldSlot[], field:
95
100
  pushBitfield({ state, slots, field, align, bits: field.bits });
96
101
  };
97
102
 
98
- const computeStructSlots = (fields: FieldLayoutInput[]): { slots: FieldSlot[]; size: number } => {
103
+ const computeStructSlots = (fields: FieldLayoutInput[]): FieldSlots => {
99
104
  const slots: FieldSlot[] = [];
100
105
  const state: StructLayoutState = { bitCursor: 0, maxAlign: 1 };
101
106
 
@@ -106,7 +111,7 @@ const computeStructSlots = (fields: FieldLayoutInput[]): { slots: FieldSlot[]; s
106
111
  return { slots, size: roundUp(roundUp(state.bitCursor, 8) / 8, state.maxAlign) };
107
112
  };
108
113
 
109
- const computeFieldSlots = (fields: FieldLayoutInput[], isUnion = false): { slots: FieldSlot[]; size: number } =>
114
+ const computeFieldSlots = (fields: FieldLayoutInput[], isUnion = false): FieldSlots =>
110
115
  isUnion ? computeUnionSlots(fields) : computeStructSlots(fields);
111
116
 
112
117
  export { layoutOfPrimitive, computeFieldSlots, type FieldLayout, type FieldSlot, type FieldLayoutInput };
@@ -1,43 +1,89 @@
1
1
  import type { RawNode } from "./parse.js";
2
2
  import type { PrimitiveCategory } from "./primitives.js";
3
3
 
4
- type TypeId = { nsId: number; id: number };
4
+ /** A reference to a parsed type: the type table holding it, and its slot in that table. */
5
+ type TypeId = {
6
+ /** Id of the table holding the type: a namespace's, or the internal one primitives and varargs intern into. */
7
+ nsId: number;
8
+ /** Slot the type occupies in that table. */
9
+ id: number;
10
+ };
11
+
12
+ /** Which GLib container a {@link ListType} is. */
5
13
  type ListFlavor = (typeof LIST_FLAVOR_BY_NAME)[keyof typeof LIST_FLAVOR_BY_NAME];
6
- type PrimitiveType = { kind: "primitive"; category: PrimitiveCategory };
7
- type VarargsType = { kind: "varargs" };
8
14
 
15
+ /** A type that marshals directly as a value, such as `gint` or `utf8`. */
16
+ type PrimitiveType = {
17
+ /** Discriminates {@link StructuralType}. */
18
+ kind: "primitive";
19
+ /** The scalar the type marshals as. */
20
+ category: PrimitiveCategory;
21
+ };
22
+
23
+ /** The trailing `...` argument list of a variadic C function. */
24
+ type VarargsType = {
25
+ /** Discriminates {@link StructuralType}. */
26
+ kind: "varargs";
27
+ };
28
+
29
+ /** A C array, along with whatever the GIR says about how its length is determined. */
9
30
  type CArrayType = {
31
+ /** Discriminates {@link StructuralType}. */
10
32
  kind: "carray";
33
+ /** Type of the array's elements, paired with `elementCType` to build the element descriptor. */
11
34
  element: TypeId;
35
+ /** C declaration of an element, which tells an inline struct apart from a pointer to one. */
12
36
  elementCType: string | undefined;
37
+ /** C declaration of the array itself. */
38
+ arrayCType: string | undefined;
39
+ /** Index of the parameter, or of the sibling record field, carrying the length. */
13
40
  lengthParameterIndex: number | undefined;
41
+ /** Element count when the array has a fixed size. */
14
42
  fixedSize: number | undefined;
43
+ /** Whether the array ends at a null element. */
15
44
  isZeroTerminated: boolean;
16
45
  };
17
46
 
47
+ /** A GLib list or array container over a single element type. */
18
48
  type ListType = {
49
+ /** Discriminates {@link StructuralType}. */
19
50
  kind: "list";
51
+ /** Which container the type is. */
20
52
  flavor: ListFlavor;
53
+ /** Type the container's elements marshal as, which the list descriptor wraps. */
21
54
  element: TypeId;
22
55
  };
23
56
 
57
+ /** A `GLib.HashTable`. */
24
58
  type HashTableType = {
59
+ /** Discriminates {@link StructuralType}. */
25
60
  kind: "hashtable";
61
+ /** Type the keys marshal as, rendered as the key half of a `Record` or `Map`. */
26
62
  key: TypeId;
63
+ /** Type the values marshal as, rendered as the value half of a `Record` or `Map`. */
27
64
  value: TypeId;
28
65
  };
29
66
 
67
+ /** A type the GIR describes by its structure rather than by a name it declares. */
30
68
  type StructuralType = PrimitiveType | VarargsType | CArrayType | ListType | HashTableType;
31
69
 
70
+ /** The hooks the GIR parsers use to reference and register types while walking one namespace. */
32
71
  type ParseContext = {
72
+ /** Id of the namespace being parsed. */
33
73
  nsId: number;
74
+ /** Resolves a GIR type name, optionally namespace-qualified, reserving a slot when it is not parsed yet. */
34
75
  findType(name: string): TypeId;
76
+ /** Interns a primitive type and returns its id. */
35
77
  addPrimitive(category: PrimitiveCategory): TypeId;
78
+ /** Interns the varargs type and returns its id. */
36
79
  addVarargs(): TypeId;
80
+ /** Registers an unnamed container type in the namespace and returns its id. */
37
81
  addContainer(type: CArrayType | ListType | HashTableType): TypeId;
82
+ /** Parses an inline `<callback>` node, registers it as an unnamed type, and returns its id. */
38
83
  addAnonymousCallback(node: RawNode): TypeId;
39
84
  };
40
85
 
86
+ /** GIR type names of the GLib containers, mapped to the {@link ListFlavor} each one parses to. */
41
87
  const LIST_FLAVOR_BY_NAME = {
42
88
  "GLib.List": "glist",
43
89
  "GLib.SList": "gslist",
@@ -88,6 +88,7 @@ const arrayTypeRefFromNode = (arrayNode: RawNode, context: ParseContext): TypeId
88
88
  kind: "carray",
89
89
  element,
90
90
  elementCType: elementNode === undefined ? undefined : attr(elementNode, "c:type"),
91
+ arrayCType: attr(arrayNode, "c:type"),
91
92
  lengthParameterIndex: intAttr(arrayNode, "length"),
92
93
  fixedSize: intAttr(arrayNode, "fixed-size"),
93
94
  isZeroTerminated: isAttrTrue(arrayNode, "zero-terminated", true),
package/src/gir/type.ts CHANGED
@@ -5,14 +5,58 @@ import type { GirAlias, GirNamespace } from "./namespace.js";
5
5
  import type { GirRecord } from "./record.js";
6
6
  import type { StructuralType } from "./type-id.js";
7
7
 
8
+ /** A named entity a GIR namespace declares, discriminated by `kind` and carrying the parsed node. */
8
9
  type EntityType =
9
- | { kind: "class"; namespace: GirNamespace; value: GirClass } |
10
- { kind: "interface"; namespace: GirNamespace; value: GirClass } |
11
- { kind: "record"; namespace: GirNamespace; value: GirRecord } |
12
- { kind: "enum"; namespace: GirNamespace; value: GirEnum } |
13
- { kind: "callback"; namespace: GirNamespace; value: GirCallback } |
14
- { kind: "alias"; namespace: GirNamespace; value: GirAlias };
10
+ | {
11
+ /** Discriminates {@link EntityType}. */
12
+ kind: "class";
13
+ /** Namespace declaring the class. */
14
+ namespace: GirNamespace;
15
+ /** Parsed class, carrying its GType metadata and the members it declares. */
16
+ value: GirClass;
17
+ } |
18
+ {
19
+ /** Discriminates {@link EntityType}. */
20
+ kind: "interface";
21
+ /** Namespace declaring the interface. */
22
+ namespace: GirNamespace;
23
+ /** Parsed interface, modeled the same way as a class. */
24
+ value: GirClass;
25
+ } |
26
+ {
27
+ /** Discriminates {@link EntityType}. */
28
+ kind: "record";
29
+ /** Namespace declaring the record. */
30
+ namespace: GirNamespace;
31
+ /** Parsed record, either a struct or a union. */
32
+ value: GirRecord;
33
+ } |
34
+ {
35
+ /** Discriminates {@link EntityType}. */
36
+ kind: "enum";
37
+ /** Namespace declaring the enumeration. */
38
+ namespace: GirNamespace;
39
+ /** Parsed enumeration or bitfield. */
40
+ value: GirEnum;
41
+ } |
42
+ {
43
+ /** Discriminates {@link EntityType}. */
44
+ kind: "callback";
45
+ /** Namespace declaring the callback. */
46
+ namespace: GirNamespace;
47
+ /** Parsed callback signature. */
48
+ value: GirCallback;
49
+ } |
50
+ {
51
+ /** Discriminates {@link EntityType}. */
52
+ kind: "alias";
53
+ /** Namespace declaring the alias. */
54
+ namespace: GirNamespace;
55
+ /** Parsed alias, holding the type it stands for. */
56
+ value: GirAlias;
57
+ };
15
58
 
59
+ /** What a GIR type reference resolves to: a structural type, or an entity a namespace declares. */
16
60
  type GirType = StructuralType | EntityType;
17
61
 
18
62
  export { type EntityType, type GirType };
@@ -1,6 +1,6 @@
1
1
  import { toCamelIdentifier } from "@gtkx/utils";
2
2
  import type { GlCommand, GlParam } from "./model.js";
3
- import type { CommandPlan, GlScalar, ParamPlan } from "./plan.js";
3
+ import type { CommandPlan, GlScalar, ParamPlan, ReturnPlan } from "./plan.js";
4
4
  import {
5
5
  tArray,
6
6
  tBoolean,
@@ -15,14 +15,14 @@ import {
15
15
  import { paramPairAt } from "./param-pair.js";
16
16
 
17
17
  type InArg = {
18
- out: false;
18
+ isOut: false;
19
19
  name: string;
20
20
  tsType: string;
21
21
  descriptor: string;
22
22
  };
23
23
 
24
24
  type OutArg = {
25
- out: true;
25
+ isOut: true;
26
26
  cellName: string;
27
27
  seed: string;
28
28
  tsType: string;
@@ -31,7 +31,7 @@ type OutArg = {
31
31
  };
32
32
 
33
33
  type PlannedArg = InArg | OutArg;
34
- type OutArgCell = Pick<OutArg, "out" | "cellName" | "paramIndex">;
34
+ type OutArgCell = Pick<OutArg, "isOut" | "cellName" | "paramIndex">;
35
35
  type OutArgFields = Pick<OutArg, "seed" | "tsType" | "descriptor">;
36
36
 
37
37
  type OutArgFieldsOptions = {
@@ -54,6 +54,29 @@ const OUT_PLAN_KINDS: Set<string> = new Set(["ref-out", "ref-array-out", "ref-fi
54
54
  const scalarAliasOrGroup = (scalar: GlScalar, group: string | undefined): string =>
55
55
  group !== undefined && scalar.isGroupBearing === true ? group : scalar.tsAlias;
56
56
 
57
+ const returnPlanTsType = (plan: ReturnPlan, group: string | undefined): string => {
58
+ switch (plan.kind) {
59
+ case "void": {
60
+ return "void";
61
+ }
62
+ case "scalar": {
63
+ return scalarAliasOrGroup(plan.scalar, group);
64
+ }
65
+ case "boolean": {
66
+ return "boolean";
67
+ }
68
+ case "string": {
69
+ return "string";
70
+ }
71
+ case "sync": {
72
+ return "GLsync";
73
+ }
74
+ case "opaque-pointer": {
75
+ return "GLpointer";
76
+ }
77
+ }
78
+ };
79
+
57
80
  const paramIndexByName = (command: GlCommand, name: string): number => {
58
81
  const index = command.params.findIndex((param) => param.name === name);
59
82
 
@@ -71,7 +94,7 @@ const arrayInTsType = (scalar: GlScalar, group: string | undefined): string => {
71
94
  };
72
95
 
73
96
  const inArg = (name: string, tsType: string, descriptor: string): InArg => ({
74
- out: false,
97
+ isOut: false,
75
98
  name,
76
99
  tsType,
77
100
  descriptor,
@@ -141,7 +164,7 @@ const outArgFields = (options: OutArgFieldsOptions): OutArgFields => {
141
164
 
142
165
  return {
143
166
  seed: `const ${cellName} = { value: new Array<number>(${lenIdentifier}).fill(0) };`,
144
- tsType: `${track(plan.scalar.tsAlias)}[]`,
167
+ tsType: `${track(scalarAliasOrGroup(plan.scalar, param.group))}[]`,
145
168
  descriptor: tRef(tSizedArray(plan.scalar.descriptor, sizeIndex)),
146
169
  };
147
170
  }
@@ -182,14 +205,14 @@ const buildOutArg = (options: BuildArgOptions, track: (alias: string) => string)
182
205
  }
183
206
 
184
207
  const cellName = `out${String(outIndex)}`;
185
- const cell: OutArgCell = { out: true, cellName, paramIndex: index };
208
+ const cell: OutArgCell = { isOut: true, cellName, paramIndex: index };
186
209
 
187
210
  return { ...cell, ...outArgFields({ command, plan, param, cellName, track }) };
188
211
  };
189
212
 
190
213
  const isOutPlan = (plan: ParamPlan): boolean => OUT_PLAN_KINDS.has(plan.kind);
191
- const isInArg = (arg: PlannedArg): arg is InArg => !arg.out;
192
- const isOutArg = (arg: PlannedArg): arg is OutArg => arg.out;
214
+ const isInArg = (arg: PlannedArg): arg is InArg => !arg.isOut;
215
+ const isOutArg = (arg: PlannedArg): arg is OutArg => arg.isOut;
193
216
 
194
217
  const buildArg = (options: BuildArgOptions, name: string, track: (alias: string) => string): PlannedArg =>
195
218
  isOutPlan(options.plan) ? buildOutArg(options, track) : buildInArg(options, name, track);
@@ -203,7 +226,7 @@ const trackInto =
203
226
  };
204
227
 
205
228
  const planArgs = (
206
- plan: CommandPlan & { ok: true },
229
+ plan: CommandPlan & { isOk: true },
207
230
  usedTypes: Set<string>,
208
231
  ): { args: PlannedArg[]; ins: InArg[]; outs: OutArg[] } => {
209
232
  const track = trackInto(usedTypes);
@@ -230,7 +253,7 @@ const planArgs = (
230
253
  };
231
254
 
232
255
  const scalarPrefixArg = (
233
- plan: CommandPlan & { ok: true },
256
+ plan: CommandPlan & { isOk: true },
234
257
  index: number,
235
258
  track: (alias: string) => string,
236
259
  ): InArg | undefined => {
@@ -251,7 +274,7 @@ const scalarPrefixArg = (
251
274
  );
252
275
  };
253
276
 
254
- const scalarPrefixArgs = (plan: CommandPlan & { ok: true }, usedTypes: Set<string>): InArg[] | undefined => {
277
+ const scalarPrefixArgs = (plan: CommandPlan & { isOk: true }, usedTypes: Set<string>): InArg[] | undefined => {
255
278
  const track = trackInto(usedTypes);
256
279
  const prefix: InArg[] = [];
257
280
 
@@ -268,4 +291,4 @@ const scalarPrefixArgs = (plan: CommandPlan & { ok: true }, usedTypes: Set<strin
268
291
  return prefix;
269
292
  };
270
293
 
271
- export { scalarAliasOrGroup, trackInto, planArgs, scalarPrefixArgs, type InArg, type OutArg };
294
+ export { returnPlanTsType, scalarAliasOrGroup, trackInto, planArgs, scalarPrefixArgs, type InArg, type OutArg };
@@ -0,0 +1,62 @@
1
+ import { sortStrings } from "@gtkx/utils";
2
+ import type { GlExtensionAttribution, GlExtensionIndex } from "./extensions.js";
3
+ import type { GlEnum, GlRegistry, GlType } from "./model.js";
4
+ import type { CommandPlan } from "./plan.js";
5
+
6
+ type GlDocEnumRow = {
7
+ token: GlEnum;
8
+ exportName: string;
9
+ };
10
+
11
+ type GlDocContext = {
12
+ registryComment?: string;
13
+ kinds: Map<string, string>;
14
+ types: Map<string, GlType>;
15
+ aliasTargets: Map<string, string[]>;
16
+ extensionCommands: Map<string, GlExtensionAttribution[]>;
17
+ extensionEnums: Map<string, GlExtensionAttribution[]>;
18
+ bitmaskGroups: Set<string>;
19
+ emittedCommands: Set<string>;
20
+ groupMembers: Map<string, string[]>;
21
+ };
22
+
23
+ type BuildDocContextOptions = {
24
+ registry: GlRegistry;
25
+ extensions: GlExtensionIndex;
26
+ plans: (CommandPlan & { isOk: true })[];
27
+ enumRows: GlDocEnumRow[];
28
+ };
29
+
30
+ const buildGroupMembers = (rows: GlDocEnumRow[]): Map<string, string[]> => {
31
+ const members: Map<string, string[]> = new Map();
32
+
33
+ for (const row of rows) {
34
+ for (const group of row.token.groups) {
35
+ members.set(group, [...(members.get(group) ?? []), row.exportName]);
36
+ }
37
+ }
38
+
39
+ for (const [group, names] of members) {
40
+ members.set(group, sortStrings(names));
41
+ }
42
+
43
+ return members;
44
+ };
45
+
46
+ const buildDocContext = (options: BuildDocContextOptions): GlDocContext => {
47
+ const { registry, extensions, plans, enumRows } = options;
48
+
49
+ return {
50
+ ...(registry.comment !== undefined && { registryComment: registry.comment }),
51
+ kinds: registry.kinds,
52
+ types: registry.types,
53
+ aliasTargets: registry.aliasTargets,
54
+ extensionCommands: extensions.commands,
55
+ extensionEnums: extensions.enums,
56
+ bitmaskGroups: registry.bitmaskGroups,
57
+ emittedCommands: new Set(plans.map((plan) => plan.command.name)),
58
+ groupMembers: buildGroupMembers(enumRows),
59
+ };
60
+ };
61
+
62
+ export { buildDocContext, type GlDocContext };
@@ -0,0 +1,85 @@
1
+ import { sortStrings } from "@gtkx/utils";
2
+ import type { GlExtension, GlInterfaceBlock, GlRegistry } from "./model.js";
3
+ import type { GlSelection } from "./select.js";
4
+
5
+ type GlExtensionAttribution = {
6
+ name: string;
7
+ notes: string[];
8
+ };
9
+
10
+ type GlExtensionIndex = {
11
+ commands: Map<string, GlExtensionAttribution[]>;
12
+ enums: Map<string, GlExtensionAttribution[]>;
13
+ };
14
+
15
+ type PendingIndex = Map<string, Map<string, string[]>>;
16
+
17
+ type PendingExtensionIndex = {
18
+ commands: PendingIndex;
19
+ enums: PendingIndex;
20
+ };
21
+
22
+ const SUPPORTED_APIS: Set<string> = new Set(["gl", "glcore"]);
23
+
24
+ const isExtensionSupported = (extension: GlExtension): boolean =>
25
+ extension.supported.some((api) => SUPPORTED_APIS.has(api));
26
+
27
+ const isBlockIncluded = (block: GlInterfaceBlock, selection: GlSelection): boolean =>
28
+ block.kind === "require" &&
29
+ (block.api === undefined || block.api === selection.api) &&
30
+ (block.profile === undefined || block.profile === selection.profile);
31
+
32
+ const blockNotes = (extension: GlExtension, block: GlInterfaceBlock): string[] => [
33
+ ...(extension.comment === undefined ? [] : [extension.comment]),
34
+ ...(block.comment === undefined ? [] : [block.comment]),
35
+ ];
36
+
37
+ const appendMembers = (index: PendingIndex, names: string[], extension: string, notes: string[]): void => {
38
+ for (const name of names) {
39
+ const byExtension = index.get(name) ?? new Map<string, string[]>();
40
+ byExtension.set(extension, [...(byExtension.get(extension) ?? []), ...notes]);
41
+ index.set(name, byExtension);
42
+ }
43
+ };
44
+
45
+ const indexExtension = (index: PendingExtensionIndex, extension: GlExtension, selection: GlSelection): void => {
46
+ for (const block of extension.blocks) {
47
+ if (!isBlockIncluded(block, selection)) {
48
+ continue;
49
+ }
50
+
51
+ const notes = blockNotes(extension, block);
52
+ appendMembers(index.commands, block.commands, extension.name, notes);
53
+ appendMembers(index.enums, block.enums, extension.name, notes);
54
+ }
55
+ };
56
+
57
+ const attributionsFor = (byExtension: Map<string, string[]>): GlExtensionAttribution[] =>
58
+ sortStrings(byExtension.keys()).map((name) => ({
59
+ name,
60
+ notes: [...new Set(byExtension.get(name))],
61
+ }));
62
+
63
+ const finalizeIndex = (pending: PendingIndex): Map<string, GlExtensionAttribution[]> => {
64
+ const index: Map<string, GlExtensionAttribution[]> = new Map();
65
+
66
+ for (const [name, byExtension] of pending) {
67
+ index.set(name, attributionsFor(byExtension));
68
+ }
69
+
70
+ return index;
71
+ };
72
+
73
+ const buildExtensionIndex = (registry: GlRegistry, selection: GlSelection): GlExtensionIndex => {
74
+ const pending: PendingExtensionIndex = { commands: new Map(), enums: new Map() };
75
+
76
+ for (const extension of registry.extensions) {
77
+ if (isExtensionSupported(extension)) {
78
+ indexExtension(pending, extension, selection);
79
+ }
80
+ }
81
+
82
+ return { commands: finalizeIndex(pending.commands), enums: finalizeIndex(pending.enums) };
83
+ };
84
+
85
+ export { buildExtensionIndex, type GlExtensionAttribution, type GlExtensionIndex };