@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/class.ts CHANGED
@@ -1,35 +1,72 @@
1
1
  import type { ParseContext } from "./type-id.js";
2
+ import { documentedFromNode, type GirAnnotations } from "./annotations.js";
2
3
  import { functionFromNode, type GirFunction } from "./function.js";
3
4
  import { type GirCallable, parseCallable } from "./parameter.js";
4
- import { attr, getChildren, getDoc, GIR_CONSTRUCTOR_TAG, isAttrTrue, nameAttr, type RawNode } from "./parse.js";
5
+ import { attr, getChildren, GIR_CONSTRUCTOR_TAG, isAttrTrue, type RawNode } from "./parse.js";
5
6
  import { type GirProperty, propertyFromNode } from "./property.js";
6
7
 
8
+ /** A `<virtual-method>` on a class or interface: the vtable slot's own documentation and signature. */
9
+ type GirVirtualMethod = GirCallable & {
10
+ /** Method GIR names as invoking this slot, absent when the slot has no invoker. */
11
+ invoker: string | undefined;
12
+ };
13
+
14
+ /** A `<class>` or `<interface>` declared by a GIR namespace. */
7
15
  type GirClass = {
16
+ /** Name GIR gives the type, without its namespace prefix. */
8
17
  name: string;
18
+ /** Documentation GIR carries for the type. */
9
19
  doc: string | undefined;
20
+ /** Release and deprecation annotations GIR carries on the type. */
21
+ annotations: GirAnnotations;
22
+ /** C type of an instance, such as `GtkWidget`. */
10
23
  cType: string | undefined;
24
+ /** The class it derives from, qualified when it lives in another namespace. */
11
25
  parent: string | undefined;
26
+ /** GType name the type registers under, such as `GtkWidget`. */
12
27
  glibTypeName: string | undefined;
28
+ /** C function returning the GType, such as `gtk_widget_get_type`. */
13
29
  glibGetType: string | undefined;
30
+ /** Record holding the class or interface vtable, which virtual method bindings are laid out against. */
14
31
  glibTypeStruct: string | undefined;
32
+ /** C function that takes a reference, on a type that manages its own refcount. */
15
33
  glibRefFunc: string | undefined;
34
+ /** C function that drops a reference, on a type that manages its own refcount. */
16
35
  glibUnrefFunc: string | undefined;
36
+ /** Whether the type is its own GType fundamental rather than a GObject descendant. */
17
37
  fundamental: boolean;
38
+ /** Whether the class cannot be instantiated on its own. */
18
39
  isAbstract: boolean;
40
+ /** Whether the type came from an `<interface>` rather than a `<class>`. */
19
41
  isInterface: boolean;
42
+ /** Whether GIR exposes the type to bindings; codegen skips it when false. */
20
43
  introspectable: boolean;
44
+ /** Interfaces the class implements. */
21
45
  implements: string[];
46
+ /** Types an implementer of this interface must also provide. */
22
47
  prerequisites: string[];
48
+ /** Methods taking an instance. */
23
49
  methods: GirFunction[];
50
+ /** Functions returning a new instance. */
24
51
  constructors: GirFunction[];
52
+ /** Functions namespaced under the type that take no instance. */
25
53
  functions: GirFunction[];
54
+ /** GObject properties the type declares. */
26
55
  properties: GirProperty[];
56
+ /** GObject signals the type declares. */
27
57
  signals: GirCallable[];
58
+ /** Virtual methods the type declares, carrying the documentation their vtable slots are generated from. */
59
+ vfuncs: GirVirtualMethod[];
28
60
  };
29
61
 
62
+ const virtualMethodsFromNode = (node: RawNode, context: ParseContext): GirVirtualMethod[] =>
63
+ getChildren(node, "virtual-method").map((vfunc) => ({
64
+ ...parseCallable(vfunc, context),
65
+ invoker: attr(vfunc, "invoker"),
66
+ }));
67
+
30
68
  const classFromNode = (node: RawNode, isInterface: boolean, context: ParseContext): GirClass => ({
31
- name: nameAttr(node),
32
- doc: getDoc(node),
69
+ ...documentedFromNode(node),
33
70
  cType: attr(node, "c:type"),
34
71
  parent: attr(node, "parent"),
35
72
  glibTypeName: attr(node, "glib:type-name"),
@@ -52,6 +89,7 @@ const classFromNode = (node: RawNode, isInterface: boolean, context: ParseContex
52
89
  functions: getChildren(node, "function").map((fn) => functionFromNode(fn, context)),
53
90
  properties: getChildren(node, "property").map((property) => propertyFromNode(property, context)),
54
91
  signals: getChildren(node, "glib:signal").map((signal) => parseCallable(signal, context)),
92
+ vfuncs: virtualMethodsFromNode(node, context),
55
93
  });
56
94
 
57
- export { classFromNode, type GirClass };
95
+ export { classFromNode, type GirClass, type GirVirtualMethod };
package/src/gir/enum.ts CHANGED
@@ -1,39 +1,59 @@
1
- import { attr, getChildren, getDoc, isAttrTrue, nameAttr, type RawNode } from "./parse.js";
1
+ import { documentedFromNode, type GirAnnotations } from "./annotations.js";
2
+ import { attr, getChildren, isAttrTrue, type RawNode } from "./parse.js";
2
3
 
4
+ /** One member of a {@link GirEnum}. */
3
5
  type EnumMember = {
6
+ /** The member's GIR name, which the emitted key is derived from. */
4
7
  name: string;
8
+ /** Documentation prose from GIR, emitted as the member's JSDoc. */
5
9
  doc: string | undefined;
10
+ /** Release and deprecation annotations GIR carries on the member. */
11
+ annotations: GirAnnotations;
12
+ /** The member's numeric value, `0` when GIR declares none. */
6
13
  value: string;
14
+ /** C constant the member is exposed as, such as `GTK_ORIENTATION_HORIZONTAL`. */
7
15
  cIdentifier: string | undefined;
8
16
  };
9
17
 
18
+ /** Whether an enum is a plain enumeration or a bitfield of flags. */
10
19
  type EnumKind = "enumeration" | "bitfield";
11
20
 
21
+ /** An enumeration or bitfield declared by a GIR namespace. */
12
22
  type GirEnum = {
23
+ /** Whether the declaration is a plain enumeration or a bitfield. */
13
24
  kind: EnumKind;
25
+ /** Name the enum is exported under, without its namespace prefix. */
14
26
  name: string;
27
+ /** Documentation prose from GIR, emitted as the enum's JSDoc. */
15
28
  doc: string | undefined;
29
+ /** Release and deprecation annotations GIR carries on the enum. */
30
+ annotations: GirAnnotations;
31
+ /** GType name of the enum, absent when it is not registered with GLib. */
16
32
  glibTypeName: string | undefined;
33
+ /** C function returning the enum's GType, absent when it is not registered with GLib. */
17
34
  glibGetType: string | undefined;
35
+ /** Quark name of the GError domain the members are codes of, absent on enums that carry no domain. */
18
36
  errorDomain: string | undefined;
37
+ /** Whether the enum is introspectable; code generation skips the ones that are not. */
19
38
  introspectable: boolean;
39
+ /** The enum's members, in declaration order. */
20
40
  members: EnumMember[];
21
41
  };
22
42
 
43
+ const enumMemberFromNode = (node: RawNode): EnumMember => ({
44
+ ...documentedFromNode(node),
45
+ value: attr(node, "value") ?? "0",
46
+ cIdentifier: attr(node, "c:identifier"),
47
+ });
48
+
23
49
  const enumFromNode = (node: RawNode, kind: EnumKind): GirEnum => ({
24
50
  kind,
25
- name: nameAttr(node),
26
- doc: getDoc(node),
51
+ ...documentedFromNode(node),
27
52
  glibTypeName: attr(node, "glib:type-name"),
28
53
  glibGetType: attr(node, "glib:get-type"),
29
54
  errorDomain: attr(node, "glib:error-domain"),
30
55
  introspectable: isAttrTrue(node, "introspectable", true),
31
- members: getChildren(node, "member").map((member) => ({
32
- name: nameAttr(member),
33
- doc: getDoc(member),
34
- value: attr(member, "value") ?? "0",
35
- cIdentifier: attr(member, "c:identifier"),
36
- })),
56
+ members: getChildren(node, "member").map((member) => enumMemberFromNode(member)),
37
57
  });
38
58
 
39
- export { enumFromNode, type GirEnum };
59
+ export { enumFromNode, type EnumMember, type GirEnum };
package/src/gir/field.ts CHANGED
@@ -1,23 +1,39 @@
1
1
  import type { ParseContext, TypeId } from "./type-id.js";
2
- import { attr, getChild, getChildren, getDoc, intAttr, isAttrTrue, nameAttr, type RawNode } from "./parse.js";
2
+ import { documentedFromNode, type GirAnnotations } from "./annotations.js";
3
+ import { attr, getChild, getChildren, intAttr, isAttrTrue, type RawNode } from "./parse.js";
3
4
  import { typeRefFromNode } from "./type-ref.js";
4
5
 
6
+ /**
7
+ * One slot in a record or union layout: a named field, or a nested struct or union
8
+ * whose own members are laid out inline.
9
+ */
5
10
  type GirField = {
11
+ /** Field name as GIR spells it. */
6
12
  name: string;
13
+ /** Documentation prose from GIR, emitted as the field accessor's JSDoc. */
7
14
  doc: string | undefined;
15
+ /** Release and deprecation annotations GIR carries on the field. */
16
+ annotations: GirAnnotations;
17
+ /** The field's value type, absent for a nested struct or union and for one GIR leaves undeclared. */
8
18
  type: TypeId | undefined;
19
+ /** The C type spelled on the field, which decides whether it is read through a pointer. */
9
20
  cType: string | undefined;
21
+ /** Whether the field can be read; one that is neither readable nor writable gets no accessor at all. */
10
22
  readable: boolean;
23
+ /** Whether the field can be written, which is what earns it a setter alongside its getter. */
11
24
  writable: boolean;
25
+ /** Whether the field is private to the library, as every nested struct or union is. */
12
26
  private: boolean;
27
+ /** Width in bits when the field is a C bitfield member. */
13
28
  bits: number | undefined;
29
+ /** Members of a nested struct or union, absent for a named field. */
14
30
  inlineMembers: GirField[] | undefined;
15
- inlineIsUnion: boolean;
31
+ /** Whether {@link GirField.inlineMembers} overlap as a union rather than following one another as a struct. */
32
+ isInlineUnion: boolean;
16
33
  };
17
34
 
18
35
  const fieldFromNode = (node: RawNode, context: ParseContext): GirField => ({
19
- name: nameAttr(node),
20
- doc: getDoc(node),
36
+ ...documentedFromNode(node),
21
37
  type: typeRefFromNode(node, context),
22
38
  cType: attr(getChild(node, "type"), "c:type"),
23
39
  readable: isAttrTrue(node, "readable", true),
@@ -25,12 +41,11 @@ const fieldFromNode = (node: RawNode, context: ParseContext): GirField => ({
25
41
  private: isAttrTrue(node, "private", false),
26
42
  bits: intAttr(node, "bits"),
27
43
  inlineMembers: undefined,
28
- inlineIsUnion: false,
44
+ isInlineUnion: false,
29
45
  });
30
46
 
31
47
  const anonymousMemberFromNode = (node: RawNode, isUnion: boolean, context: ParseContext): GirField => ({
32
- name: nameAttr(node),
33
- doc: getDoc(node),
48
+ ...documentedFromNode(node),
34
49
  type: undefined,
35
50
  cType: undefined,
36
51
  readable: false,
@@ -38,7 +53,7 @@ const anonymousMemberFromNode = (node: RawNode, isUnion: boolean, context: Parse
38
53
  private: true,
39
54
  bits: undefined,
40
55
  inlineMembers: collectFields(node, context),
41
- inlineIsUnion: isUnion,
56
+ isInlineUnion: isUnion,
42
57
  });
43
58
 
44
59
  const collectFields = (node: RawNode, context: ParseContext): GirField[] => [
@@ -47,4 +62,4 @@ const collectFields = (node: RawNode, context: ParseContext): GirField[] => [
47
62
  ...getChildren(node, "record").map((member) => anonymousMemberFromNode(member, false, context)),
48
63
  ];
49
64
 
50
- export { collectFields, fieldFromNode, type GirField };
65
+ export { collectFields, type GirField };
@@ -1,19 +1,34 @@
1
+ import type { GirAnnotations } from "./annotations.js";
1
2
  import type { ParseContext } from "./type-id.js";
2
3
  import { PARAMETERS_MISSING_NULLABLE_ANNOTATION } from "./nullable-overrides.js";
3
4
  import { type GirParameter, type GirReturnValue, parameterFromNode, parseCallable } from "./parameter.js";
4
5
  import { attr, getChild, type RawNode } from "./parse.js";
5
6
 
7
+ /** A callable declared by a GIR namespace, class, or record: a function, a method, or a constructor. */
6
8
  type GirFunction = {
9
+ /** Local name within its owner, taken from the `shadows` annotation when the callable has one. */
7
10
  name: string;
11
+ /** Documentation text carried by the GIR node. */
8
12
  doc: string | undefined;
13
+ /** Release and deprecation annotations GIR carries on the callable. */
14
+ annotations: GirAnnotations;
15
+ /** C symbol the callable is invoked through. */
9
16
  cIdentifier: string | undefined;
17
+ /** Whether the C function takes a trailing `GError` out parameter and can fail. */
10
18
  throws: boolean;
19
+ /** Whether the GIR marks the callable as introspectable, and so bindable. */
11
20
  introspectable: boolean;
21
+ /** Qualified `Type.member` the GIR redirects the callable to, from its `moved-to` annotation. */
12
22
  movedTo: string | undefined;
23
+ /** Name of the callable that shadows this one, from the GIR's `shadowed-by` annotation. */
13
24
  shadowedBy: string | undefined;
25
+ /** Name of the callable that completes this asynchronous one, from the GIR's `glib:finish-func`. */
14
26
  finishFunc: string | undefined;
27
+ /** The instance the callable is invoked on, absent for constructors and namespace-level functions. */
15
28
  instance: GirParameter | undefined;
29
+ /** Parameters other than the instance one, in declaration order. */
16
30
  parameters: GirParameter[];
31
+ /** What the callable returns, with its transfer and nullability. */
17
32
  returnValue: GirReturnValue;
18
33
  };
19
34
 
@@ -1,11 +1,19 @@
1
1
  import { sortStrings } from "@gtkx/utils";
2
2
  import { readdirSync } from "node:fs";
3
3
 
4
- type GirNamespace = { name: string; version: string; identifier: string };
4
+ /** A namespace found on the GIR path, taken from the name of its `.gir` file. */
5
+ type GirNamespace = {
6
+ /** Namespace the file describes, such as `Gtk`. */
7
+ name: string;
8
+ /** API version the file describes, such as `4.0`. */
9
+ version: string;
10
+ /** Name and version joined the way a `libraries` entry spells them, such as `Gtk-4.0`. */
11
+ identifier: string;
12
+ };
13
+
5
14
  /** A `libraries` config value: an explicit list, `"*"` for everything installed, or absent for the default. */
6
- type LibrarySelection = typeof LIBRARIES_WILDCARD | string[] | undefined;
15
+ type LibrarySelection = "*" | string[] | undefined;
7
16
 
8
- /** The `libraries` value that stands for every GIR library installed on the search path. */
9
17
  const LIBRARIES_WILDCARD = "*";
10
18
  const GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\d+(?:\.\d+)*$/;
11
19
  const DEFAULT_LIBRARIES: string[] = ["Gtk-4.0"];
@@ -14,13 +14,23 @@ import {
14
14
  import { parseGirFile, type RawNode } from "./parse.js";
15
15
  import { splitOptionalNamespace } from "./type-ref.js";
16
16
 
17
+ /** The types belonging to one namespace, addressed by the id half of a {@link TypeId}. */
17
18
  type TypeTable = {
19
+ /** Parsed type in each slot, still `undefined` while only a forward reference to it has been seen. */
18
20
  types: (GirType | undefined)[];
21
+ /** Declared name of each slot, `undefined` for anonymous types such as containers and inline callbacks. */
19
22
  names: (string | undefined)[];
23
+ /** Slot id each named type occupies, so repeated references resolve to the same id. */
20
24
  index: Map<string, number>;
21
25
  };
22
26
 
23
- type DiscoveredNamespace = { header: NamespaceHeader; shell: GirNamespace };
27
+ /** A namespace whose header has been read and whose shell is registered, before its body is parsed. */
28
+ type DiscoveredNamespace = {
29
+ /** Attributes and includes read from the namespace's GIR file. */
30
+ header: NamespaceHeader;
31
+ /** Empty namespace registered for the header, populated once every header is known. */
32
+ shell: GirNamespace;
33
+ };
24
34
 
25
35
  const INTERNAL_NS_ID = 0;
26
36
 
@@ -50,6 +60,10 @@ const locateGirFile = (identifier: string, girPath: string[]): string => {
50
60
  throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);
51
61
  };
52
62
 
63
+ /**
64
+ * The parsed GIR universe: every requested namespace plus everything those namespaces include,
65
+ * with types resolvable across namespace boundaries.
66
+ */
53
67
  class Library {
54
68
  private static drive(library: Library, libraries: string[], girPath: string[]): void {
55
69
  const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);
@@ -65,6 +79,13 @@ class Library {
65
79
  library.girFilesValue = girFiles;
66
80
  }
67
81
 
82
+ /**
83
+ * Parses the named GIR libraries along with every namespace they transitively include.
84
+ *
85
+ * @param libraries GIR identifiers to load, such as `Gtk-4.0`.
86
+ * @param girPath Directories searched, in order, for each `.gir` file.
87
+ * @returns A library holding every namespace that was parsed.
88
+ */
68
89
  static load(libraries: string[], girPath: string[]): Library {
69
90
  const library = new Library();
70
91
  this.drive(library, libraries, girPath);
@@ -79,6 +100,7 @@ class Library {
79
100
  private typeTables: TypeTable[] = [];
80
101
  private girFilesValue: string[] = [];
81
102
 
103
+ /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */
82
104
  constructor() {
83
105
  this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };
84
106
  this.namespaceById[INTERNAL_NS_ID] = undefined;
@@ -301,19 +323,38 @@ class Library {
301
323
  return { discovered, girFiles };
302
324
  }
303
325
 
326
+ /** The loaded namespaces, keyed by their GIR name such as `Gtk`. */
304
327
  public get namespaces(): Map<string, GirNamespace> {
305
328
  return this.namespacesByName;
306
329
  }
307
330
 
331
+ /** Paths of the `.gir` files that were read, in the order they were discovered. */
308
332
  public get girFiles(): string[] {
309
333
  return this.girFilesValue;
310
334
  }
311
335
 
336
+ /**
337
+ * Reads the type a {@link TypeId} points at.
338
+ *
339
+ * @param tid The type id to dereference.
340
+ * @returns The parsed type, or `undefined` when nothing has been parsed into that slot.
341
+ */
312
342
  typeFor(tid: TypeId): GirType | undefined {
313
343
  return this.typeTables[tid.nsId]?.types[tid.id];
314
344
  }
315
345
 
316
- nameFor(tid: TypeId): { namespaceName: string; typeName: string } | undefined {
346
+ /**
347
+ * Reads the name a {@link TypeId} was registered under.
348
+ *
349
+ * @param tid The type id to name.
350
+ * @returns The namespace and type name, or `undefined` for an anonymous type.
351
+ */
352
+ nameFor(tid: TypeId): {
353
+ /** GIR namespace to qualify the type with, such as `Gtk`. */
354
+ namespaceName: string;
355
+ /** Unqualified type name as GIR declares it, such as `Widget`. */
356
+ typeName: string;
357
+ } | undefined {
317
358
  const typeName = this.typeTables[tid.nsId]?.names[tid.id];
318
359
  const namespaceName = this.nsNameById[tid.nsId];
319
360
 
@@ -324,6 +365,14 @@ class Library {
324
365
  return { namespaceName, typeName };
325
366
  }
326
367
 
368
+ /**
369
+ * Looks up a type by the name a GIR file writes, resolving an unqualified name against the
370
+ * namespace it appears in and a `Namespace.Type` name against the loaded namespaces.
371
+ *
372
+ * @param currentNamespaceName Namespace the name is written in.
373
+ * @param name Type name, optionally qualified with a namespace prefix.
374
+ * @returns The parsed type, or `undefined` when the name is unknown or only a forward reference to it exists.
375
+ */
327
376
  resolveType(currentNamespaceName: string, name: string): GirType | undefined {
328
377
  const currentNsId = this.nsIdByName.get(currentNamespaceName);
329
378
 
@@ -1,52 +1,90 @@
1
1
  import type { ParseContext, TypeId } from "./type-id.js";
2
+ import { documentedFromNode, type GirAnnotations } from "./annotations.js";
2
3
  import { callbackFromNode, type GirCallback } from "./callback.js";
3
4
  import { classFromNode, type GirClass } from "./class.js";
4
5
  import { enumFromNode, type GirEnum } from "./enum.js";
5
6
  import { functionFromNode, type GirFunction } from "./function.js";
6
- import { attr, getChild, getChildren, getDoc, nameAttr, type RawNode } from "./parse.js";
7
+ import { attr, getChild, getChildren, nameAttr, type RawNode } from "./parse.js";
7
8
  import { type GirRecord, isVtableRecord, recordFromNode } from "./record.js";
8
9
  import { typeRefFromNode } from "./type-ref.js";
9
10
 
11
+ /** A compile-time constant declared by a namespace. */
10
12
  type GirConstant = {
13
+ /** Local name within the namespace. */
11
14
  name: string;
15
+ /** Documentation text carried by the GIR node. */
12
16
  doc: string | undefined;
17
+ /** Release and deprecation annotations GIR carries on the constant. */
18
+ annotations: GirAnnotations;
19
+ /** Literal as written in the GIR, still to be interpreted according to {@link GirConstant.type}. */
13
20
  value: string;
21
+ /** Type of the constant, unresolved until looked up in the library's type tables. */
14
22
  type: TypeId | undefined;
15
23
  };
16
24
 
25
+ /** A named alias for another type. */
17
26
  type GirAlias = {
27
+ /** Local name within the namespace. */
18
28
  name: string;
29
+ /** Documentation text carried by the GIR node. */
19
30
  doc: string | undefined;
31
+ /** Release and deprecation annotations GIR carries on the alias. */
32
+ annotations: GirAnnotations;
33
+ /** C typedef name introduced by the alias. */
20
34
  cType: string | undefined;
35
+ /** Type the alias stands for, unresolved until looked up in the library's type tables. */
21
36
  target: TypeId | undefined;
37
+ /** C type name of the target, which decides how the alias marshals. */
22
38
  targetCType: string | undefined;
23
39
  };
24
40
 
41
+ /** Everything one GIR namespace declares, keyed into the library that parsed it. */
25
42
  type GirNamespace = {
43
+ /** Identifier of the namespace's type table within its library. */
26
44
  id: number;
45
+ /** Namespace name as it appears in the GIR, such as `Gtk`. */
27
46
  name: string;
47
+ /** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
28
48
  sharedLibrary: string | undefined;
49
+ /** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
29
50
  cSymbolPrefixes: string[];
51
+ /** GObject classes declared by the namespace. */
30
52
  classes: GirClass[];
53
+ /** GObject interfaces declared by the namespace. */
31
54
  interfaces: GirClass[];
55
+ /** Structs and unions declared by the namespace. */
32
56
  records: GirRecord[];
57
+ /** Enumerations and bitfields declared by the namespace. */
33
58
  enums: GirEnum[];
59
+ /** Callback types declared by the namespace. */
34
60
  callbacks: GirCallback[];
61
+ /** Free functions declared by the namespace. */
35
62
  functions: GirFunction[];
63
+ /** Compile-time values, emitted as module-level `const` bindings. */
36
64
  constants: GirConstant[];
65
+ /** Typedefs, emitted as TypeScript type aliases and resolvable as types themselves. */
37
66
  aliases: GirAlias[];
38
67
  };
39
68
 
69
+ /** Another namespace a GIR repository depends on. */
40
70
  type NamespaceInclude = {
71
+ /** Name of the included namespace, such as `Gio`. */
41
72
  name: string;
73
+ /** Version of the included namespace, such as `2.0`. */
42
74
  version: string;
43
75
  };
44
76
 
77
+ /** A namespace's declaration and dependencies, read before its body is parsed. */
45
78
  type NamespaceHeader = {
79
+ /** Namespace name as it appears in the GIR, such as `Gtk`. */
46
80
  name: string;
81
+ /** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
47
82
  sharedLibrary: string | undefined;
83
+ /** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
48
84
  cSymbolPrefixes: string[];
85
+ /** Namespaces this repository includes, each of which is parsed in turn. */
49
86
  includes: NamespaceInclude[];
87
+ /** The `<namespace>` node whose children hold the declarations. */
50
88
  namespaceNode: RawNode;
51
89
  };
52
90
 
@@ -97,15 +135,13 @@ const populateNamespaceBody = (shell: GirNamespace, namespaceNode: RawNode, cont
97
135
  shell.functions = getChildren(namespaceNode, "function").map((fn) => functionFromNode(fn, context));
98
136
 
99
137
  shell.constants = getChildren(namespaceNode, "constant").map((constant) => ({
100
- name: nameAttr(constant),
101
- doc: getDoc(constant),
138
+ ...documentedFromNode(constant),
102
139
  value: attr(constant, "value") ?? "",
103
140
  type: typeRefFromNode(constant, context),
104
141
  }));
105
142
 
106
143
  shell.aliases = getChildren(namespaceNode, "alias").map((alias) => ({
107
- name: nameAttr(alias),
108
- doc: getDoc(alias),
144
+ ...documentedFromNode(alias),
109
145
  cType: attr(alias, "c:type"),
110
146
  target: typeRefFromNode(alias, context),
111
147
  targetCType: attr(getChild(alias, "type"), "c:type"),
@@ -1,4 +1,5 @@
1
1
  import type { ParseContext, TypeId } from "./type-id.js";
2
+ import { documentedFromNode, type GirAnnotations } from "./annotations.js";
2
3
  import {
3
4
  attr,
4
5
  getChild,
@@ -12,37 +13,75 @@ import {
12
13
  } from "./parse.js";
13
14
  import { typeRefFromNode } from "./type-ref.js";
14
15
 
16
+ /** Which way a parameter's value travels: into the call, back out of it, or both. */
15
17
  type ParameterDirection = "in" | "out" | "inout";
18
+ /** How much of a value the receiver takes ownership of: none, the whole value, or only its container. */
16
19
  type ParameterTransfer = "none" | "full" | "container";
20
+ /**
21
+ * How long a callback parameter stays valid: for the duration of the call, until its destroy notify runs,
22
+ * until the asynchronous operation invokes it, or forever.
23
+ */
17
24
  type CallbackScope = "call" | "notified" | "async" | "forever";
18
25
 
26
+ /** A parameter of a {@link GirCallable}, with the annotations that decide how it is marshalled. */
19
27
  type GirParameter = {
28
+ /** The name GIR gives the parameter. */
20
29
  name: string;
30
+ /** What the parameter holds, absent when the GIR node declares no type. */
21
31
  type: TypeId | undefined;
32
+ /** The C spelling of the parameter's type, taken from its `type` or `array` child. */
33
+ cType: string | undefined;
34
+ /** Documentation prose from GIR, emitted as the parameter's `@param` text. */
35
+ doc: string | undefined;
36
+ /** Decides whether the parameter is an argument, part of the returned tuple, or both. */
22
37
  direction: ParameterDirection;
38
+ /** Ownership the marshalling descriptor is generated with, deciding whether the receiver frees the value. */
23
39
  transferOwnership: ParameterTransfer;
40
+ /** Whether the value may be null. */
24
41
  nullable: boolean;
42
+ /** Whether the caller may leave the parameter out entirely. */
25
43
  optional: boolean;
44
+ /** Whether the caller supplies the storage an out parameter writes into. */
26
45
  callerAllocates: boolean;
46
+ /** How long a callback parameter stays valid, absent when GIR carries no scope annotation. */
27
47
  scope: CallbackScope | undefined;
48
+ /** Position of the parameter carrying the callback's user data. */
28
49
  closureIndex: number | undefined;
50
+ /** Position of the parameter carrying the callback's destroy notify. */
29
51
  destroyIndex: number | undefined;
52
+ /** Whether the parameter is the `...` varargs marker. */
30
53
  isVarargs: boolean;
31
54
  };
32
55
 
56
+ /** What a {@link GirCallable} hands back, with the annotations that decide how it is marshalled. */
33
57
  type GirReturnValue = {
58
+ /** What the callable returns, absent when the GIR node declares no type. */
34
59
  type: TypeId | undefined;
60
+ /** Documentation prose from GIR, emitted as the callable's `@returns` text. */
61
+ doc: string | undefined;
62
+ /** How much ownership the caller takes of the returned value. */
35
63
  transferOwnership: ParameterTransfer;
64
+ /** Whether the returned value may be null. */
36
65
  nullable: boolean;
66
+ /** Whether GIR marks the value as skipped, keeping it out of the generated signature. */
37
67
  skip: boolean;
38
68
  };
39
69
 
70
+ /** Anything GIR describes with parameters and a return value: functions, methods, signals, and callbacks. */
40
71
  type GirCallable = {
72
+ /** The name GIR gives the callable. */
41
73
  name: string;
74
+ /** The callable's documentation text, absent when GIR carries none. */
42
75
  doc: string | undefined;
76
+ /** Release and deprecation annotations GIR carries on the callable. */
77
+ annotations: GirAnnotations;
78
+ /** The parameters the callable takes, in declaration order. */
43
79
  parameters: GirParameter[];
80
+ /** What the callable hands back. */
44
81
  returnValue: GirReturnValue;
82
+ /** Whether the callable reports failure through a trailing `GError`. */
45
83
  throws: boolean;
84
+ /** Whether GIR exposes the callable to bindings. */
46
85
  introspectable: boolean;
47
86
  };
48
87
 
@@ -62,9 +101,14 @@ const hasNullableAttr = (node: RawNode): boolean =>
62
101
  const hasOptionalAttr = (node: RawNode): boolean =>
63
102
  isAttrTrue(node, "optional") || (!isInDirection(node) && isAttrTrue(node, "allow-none"));
64
103
 
104
+ const parameterCType = (node: RawNode): string | undefined =>
105
+ attr(getChild(node, "type"), "c:type") ?? attr(getChild(node, "array"), "c:type");
106
+
65
107
  const parameterFromNode = (node: RawNode, context: ParseContext): GirParameter => ({
66
108
  name: nameAttr(node),
67
109
  type: typeRefFromNode(node, context),
110
+ cType: parameterCType(node),
111
+ doc: getDoc(node),
68
112
  direction: parseEnumAttr(attr(node, "direction"), DIRECTIONS, "in", "direction"),
69
113
  transferOwnership: transferOwnership(node),
70
114
  nullable: hasNullableAttr(node),
@@ -86,11 +130,12 @@ const isInoutParameter = (parameter: GirParameter): boolean => parameter.directi
86
130
 
87
131
  const returnValueFromNode = (node: RawNode | undefined, context: ParseContext): GirReturnValue => {
88
132
  if (node === undefined) {
89
- return { type: undefined, transferOwnership: "none", nullable: false, skip: false };
133
+ return { type: undefined, doc: undefined, transferOwnership: "none", nullable: false, skip: false };
90
134
  }
91
135
 
92
136
  return {
93
137
  type: typeRefFromNode(node, context),
138
+ doc: getDoc(node),
94
139
  transferOwnership: transferOwnership(node),
95
140
  nullable: hasNullableAttr(node),
96
141
  skip: isAttrTrue(node, "skip"),
@@ -102,8 +147,7 @@ const parseCallable = (node: RawNode, context: ParseContext): GirCallable => {
102
147
  const parameterNodes = getChildren(parametersNode, "parameter");
103
148
 
104
149
  return {
105
- name: nameAttr(node),
106
- doc: getDoc(node),
150
+ ...documentedFromNode(node),
107
151
  parameters: parameterNodes.map((parameter) => parameterFromNode(parameter, context)),
108
152
  returnValue: returnValueFromNode(getChild(node, "return-value"), context),
109
153
  throws: isAttrTrue(node, "throws"),