@gtkx/codegen 1.0.0-rc.4 → 1.1.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 (523) hide show
  1. package/README.md +5 -5
  2. package/dist/analysis/descriptor-render.d.ts +13 -9
  3. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  4. package/dist/analysis/descriptor-render.js +80 -50
  5. package/dist/analysis/descriptor-render.js.map +1 -1
  6. package/dist/analysis/descriptor.d.ts +16 -7
  7. package/dist/analysis/descriptor.d.ts.map +1 -1
  8. package/dist/analysis/descriptor.js +15 -3
  9. package/dist/analysis/descriptor.js.map +1 -1
  10. package/dist/analysis/inheritance.d.ts +4 -3
  11. package/dist/analysis/inheritance.d.ts.map +1 -1
  12. package/dist/analysis/inheritance.js +103 -58
  13. package/dist/analysis/inheritance.js.map +1 -1
  14. package/dist/analysis/interface-conflicts.d.ts +23 -0
  15. package/dist/analysis/interface-conflicts.d.ts.map +1 -0
  16. package/dist/analysis/interface-conflicts.js +144 -0
  17. package/dist/analysis/interface-conflicts.js.map +1 -0
  18. package/dist/analysis/nul-terminated-bytes.d.ts +5 -0
  19. package/dist/analysis/nul-terminated-bytes.d.ts.map +1 -0
  20. package/dist/analysis/nul-terminated-bytes.js +18 -0
  21. package/dist/analysis/nul-terminated-bytes.js.map +1 -0
  22. package/dist/analysis/param-capability.d.ts +5 -0
  23. package/dist/analysis/param-capability.d.ts.map +1 -0
  24. package/dist/analysis/param-capability.js +129 -0
  25. package/dist/analysis/param-capability.js.map +1 -0
  26. package/dist/analysis/param-structure.d.ts +11 -4
  27. package/dist/analysis/param-structure.d.ts.map +1 -1
  28. package/dist/analysis/param-structure.js +42 -16
  29. package/dist/analysis/param-structure.js.map +1 -1
  30. package/dist/analysis/ts-type.d.ts.map +1 -1
  31. package/dist/analysis/ts-type.js +10 -17
  32. package/dist/analysis/ts-type.js.map +1 -1
  33. package/dist/analysis/type-key.d.ts +5 -0
  34. package/dist/analysis/type-key.d.ts.map +1 -0
  35. package/dist/analysis/type-key.js +9 -0
  36. package/dist/analysis/type-key.js.map +1 -0
  37. package/dist/analysis/type-shape.d.ts +8 -0
  38. package/dist/analysis/type-shape.d.ts.map +1 -0
  39. package/dist/analysis/type-shape.js +12 -0
  40. package/dist/analysis/type-shape.js.map +1 -0
  41. package/dist/compile.d.ts +12 -3
  42. package/dist/compile.d.ts.map +1 -1
  43. package/dist/compile.js +73 -24
  44. package/dist/compile.js.map +1 -1
  45. package/dist/docs/api-reference.d.ts +2 -2
  46. package/dist/docs/api-reference.d.ts.map +1 -1
  47. package/dist/docs/api-reference.js +17 -23
  48. package/dist/docs/api-reference.js.map +1 -1
  49. package/dist/docs/element-page.d.ts +4 -4
  50. package/dist/docs/element-page.d.ts.map +1 -1
  51. package/dist/docs/element-page.js +36 -22
  52. package/dist/docs/element-page.js.map +1 -1
  53. package/dist/docs/handwritten-props.d.ts +9 -0
  54. package/dist/docs/handwritten-props.d.ts.map +1 -0
  55. package/dist/docs/handwritten-props.js +149 -0
  56. package/dist/docs/handwritten-props.js.map +1 -0
  57. package/dist/docs/pipeline.d.ts.map +1 -1
  58. package/dist/docs/pipeline.js +87 -20
  59. package/dist/docs/pipeline.js.map +1 -1
  60. package/dist/docs/render.d.ts +26 -5
  61. package/dist/docs/render.d.ts.map +1 -1
  62. package/dist/docs/render.js +88 -25
  63. package/dist/docs/render.js.map +1 -1
  64. package/dist/docs/symbol-page.d.ts +17 -0
  65. package/dist/docs/symbol-page.d.ts.map +1 -1
  66. package/dist/docs/symbol-page.js +132 -44
  67. package/dist/docs/symbol-page.js.map +1 -1
  68. package/dist/fingerprint.d.ts +12 -1
  69. package/dist/fingerprint.d.ts.map +1 -1
  70. package/dist/fingerprint.js +44 -28
  71. package/dist/fingerprint.js.map +1 -1
  72. package/dist/gi.d.ts.map +1 -1
  73. package/dist/gi.js +1 -0
  74. package/dist/gi.js.map +1 -1
  75. package/dist/gir/ancestry.d.ts +8 -2
  76. package/dist/gir/ancestry.d.ts.map +1 -1
  77. package/dist/gir/ancestry.js +19 -1
  78. package/dist/gir/ancestry.js.map +1 -1
  79. package/dist/gir/annotations.d.ts +21 -0
  80. package/dist/gir/annotations.d.ts.map +1 -0
  81. package/dist/gir/annotations.js +15 -0
  82. package/dist/gir/annotations.js.map +1 -0
  83. package/dist/gir/callback.d.ts +1 -0
  84. package/dist/gir/callback.d.ts.map +1 -1
  85. package/dist/gir/callback.js +1 -0
  86. package/dist/gir/callback.js.map +1 -1
  87. package/dist/gir/class.d.ts +32 -1
  88. package/dist/gir/class.d.ts.map +1 -1
  89. package/dist/gir/class.js +8 -3
  90. package/dist/gir/class.js.map +1 -1
  91. package/dist/gir/cursor-overrides.d.ts +8 -0
  92. package/dist/gir/cursor-overrides.d.ts.map +1 -0
  93. package/dist/gir/cursor-overrides.js +6 -0
  94. package/dist/gir/cursor-overrides.js.map +1 -0
  95. package/dist/gir/emittable.d.ts +7 -0
  96. package/dist/gir/emittable.d.ts.map +1 -0
  97. package/dist/gir/emittable.js +3 -0
  98. package/dist/gir/emittable.js.map +1 -0
  99. package/dist/gir/enum.d.ts +21 -1
  100. package/dist/gir/enum.d.ts.map +1 -1
  101. package/dist/gir/enum.js +9 -9
  102. package/dist/gir/enum.js.map +1 -1
  103. package/dist/gir/field.d.ts +19 -3
  104. package/dist/gir/field.d.ts.map +1 -1
  105. package/dist/gir/field.js +7 -8
  106. package/dist/gir/field.js.map +1 -1
  107. package/dist/gir/function.d.ts +15 -0
  108. package/dist/gir/function.d.ts.map +1 -1
  109. package/dist/gir/function.js +28 -2
  110. package/dist/gir/function.js.map +1 -1
  111. package/dist/gir/libraries.d.ts +1 -3
  112. package/dist/gir/libraries.d.ts.map +1 -1
  113. package/dist/gir/libraries.js +0 -1
  114. package/dist/gir/libraries.js.map +1 -1
  115. package/dist/gir/library.d.ts +36 -0
  116. package/dist/gir/library.d.ts.map +1 -1
  117. package/dist/gir/library.js +35 -1
  118. package/dist/gir/library.js.map +1 -1
  119. package/dist/gir/namespace.d.ts +43 -1
  120. package/dist/gir/namespace.d.ts.map +1 -1
  121. package/dist/gir/namespace.js +8 -7
  122. package/dist/gir/namespace.js.map +1 -1
  123. package/dist/gir/parameter.d.ts +52 -1
  124. package/dist/gir/parameter.d.ts.map +1 -1
  125. package/dist/gir/parameter.js +8 -3
  126. package/dist/gir/parameter.js.map +1 -1
  127. package/dist/gir/parse.d.ts +3 -1
  128. package/dist/gir/parse.d.ts.map +1 -1
  129. package/dist/gir/parse.js +9 -9
  130. package/dist/gir/parse.js.map +1 -1
  131. package/dist/gir/primitives.d.ts +1 -0
  132. package/dist/gir/primitives.d.ts.map +1 -1
  133. package/dist/gir/primitives.js.map +1 -1
  134. package/dist/gir/property.d.ts +16 -0
  135. package/dist/gir/property.d.ts.map +1 -1
  136. package/dist/gir/property.js +3 -3
  137. package/dist/gir/property.js.map +1 -1
  138. package/dist/gir/record.d.ts +22 -0
  139. package/dist/gir/record.d.ts.map +1 -1
  140. package/dist/gir/record.js +3 -2
  141. package/dist/gir/record.js.map +1 -1
  142. package/dist/gir/size.d.ts +5 -4
  143. package/dist/gir/size.d.ts.map +1 -1
  144. package/dist/gir/size.js.map +1 -1
  145. package/dist/gir/type-id.d.ts +35 -0
  146. package/dist/gir/type-id.d.ts.map +1 -1
  147. package/dist/gir/type-id.js +1 -0
  148. package/dist/gir/type-id.js.map +1 -1
  149. package/dist/gir/type-ref.d.ts.map +1 -1
  150. package/dist/gir/type-ref.js +1 -0
  151. package/dist/gir/type-ref.js.map +1 -1
  152. package/dist/gir/type.d.ts +20 -0
  153. package/dist/gir/type.d.ts.map +1 -1
  154. package/dist/gir/type.js.map +1 -1
  155. package/dist/guards.d.ts +16 -0
  156. package/dist/guards.d.ts.map +1 -0
  157. package/dist/guards.js +11 -0
  158. package/dist/guards.js.map +1 -0
  159. package/dist/internal.d.ts +2 -0
  160. package/dist/internal.d.ts.map +1 -1
  161. package/dist/internal.js +2 -0
  162. package/dist/internal.js.map +1 -1
  163. package/dist/json.d.ts +3 -0
  164. package/dist/json.d.ts.map +1 -0
  165. package/dist/json.js +11 -0
  166. package/dist/json.js.map +1 -0
  167. package/dist/khronos/args.d.ts +7 -6
  168. package/dist/khronos/args.d.ts.map +1 -1
  169. package/dist/khronos/args.js +28 -6
  170. package/dist/khronos/args.js.map +1 -1
  171. package/dist/khronos/doc-context.d.ts +29 -0
  172. package/dist/khronos/doc-context.d.ts.map +1 -0
  173. package/dist/khronos/doc-context.js +29 -0
  174. package/dist/khronos/doc-context.js.map +1 -0
  175. package/dist/khronos/extensions.d.ts +13 -0
  176. package/dist/khronos/extensions.d.ts.map +1 -0
  177. package/dist/khronos/extensions.js +49 -0
  178. package/dist/khronos/extensions.js.map +1 -0
  179. package/dist/khronos/jsdoc.d.ts +17 -11
  180. package/dist/khronos/jsdoc.d.ts.map +1 -1
  181. package/dist/khronos/jsdoc.js +104 -46
  182. package/dist/khronos/jsdoc.js.map +1 -1
  183. package/dist/khronos/model.d.ts +42 -3
  184. package/dist/khronos/model.d.ts.map +1 -1
  185. package/dist/khronos/model.js +218 -63
  186. package/dist/khronos/model.js.map +1 -1
  187. package/dist/khronos/modules.d.ts +9 -6
  188. package/dist/khronos/modules.d.ts.map +1 -1
  189. package/dist/khronos/modules.js +112 -27
  190. package/dist/khronos/modules.js.map +1 -1
  191. package/dist/khronos/notes.d.ts +19 -0
  192. package/dist/khronos/notes.d.ts.map +1 -0
  193. package/dist/khronos/notes.js +35 -0
  194. package/dist/khronos/notes.js.map +1 -0
  195. package/dist/khronos/param-pair.d.ts +1 -1
  196. package/dist/khronos/param-pair.d.ts.map +1 -1
  197. package/dist/khronos/param-pair.js.map +1 -1
  198. package/dist/khronos/parse.d.ts.map +1 -1
  199. package/dist/khronos/parse.js +3 -4
  200. package/dist/khronos/parse.js.map +1 -1
  201. package/dist/khronos/pipeline.d.ts +4 -2
  202. package/dist/khronos/pipeline.d.ts.map +1 -1
  203. package/dist/khronos/pipeline.js +58 -27
  204. package/dist/khronos/pipeline.js.map +1 -1
  205. package/dist/khronos/plan.d.ts +3 -9
  206. package/dist/khronos/plan.d.ts.map +1 -1
  207. package/dist/khronos/plan.js +3 -3
  208. package/dist/khronos/plan.js.map +1 -1
  209. package/dist/khronos/render.d.ts +8 -6
  210. package/dist/khronos/render.d.ts.map +1 -1
  211. package/dist/khronos/render.js +35 -26
  212. package/dist/khronos/render.js.map +1 -1
  213. package/dist/khronos/select.d.ts +21 -4
  214. package/dist/khronos/select.d.ts.map +1 -1
  215. package/dist/khronos/select.js +47 -34
  216. package/dist/khronos/select.js.map +1 -1
  217. package/dist/react/element-config.d.ts +2 -2
  218. package/dist/react/element-config.d.ts.map +1 -1
  219. package/dist/react/element-config.js.map +1 -1
  220. package/dist/runner.d.ts +6 -8
  221. package/dist/runner.d.ts.map +1 -1
  222. package/dist/runner.js +16 -0
  223. package/dist/runner.js.map +1 -1
  224. package/dist/staging.d.ts +5 -0
  225. package/dist/staging.d.ts.map +1 -0
  226. package/dist/staging.js +57 -0
  227. package/dist/staging.js.map +1 -0
  228. package/dist/store/compile-store.d.ts +1 -1
  229. package/dist/store/compile-store.d.ts.map +1 -1
  230. package/dist/store/compile-store.js +4 -2
  231. package/dist/store/compile-store.js.map +1 -1
  232. package/dist/store/gi/callable-doc.d.ts +11 -0
  233. package/dist/store/gi/callable-doc.d.ts.map +1 -0
  234. package/dist/store/gi/callable-doc.js +62 -0
  235. package/dist/store/gi/callable-doc.js.map +1 -0
  236. package/dist/store/gi/callables.d.ts +9 -2
  237. package/dist/store/gi/callables.d.ts.map +1 -1
  238. package/dist/store/gi/callables.js +35 -40
  239. package/dist/store/gi/callables.js.map +1 -1
  240. package/dist/store/gi/callback.d.ts.map +1 -1
  241. package/dist/store/gi/callback.js +10 -6
  242. package/dist/store/gi/callback.js.map +1 -1
  243. package/dist/store/gi/class.d.ts.map +1 -1
  244. package/dist/store/gi/class.js +63 -40
  245. package/dist/store/gi/class.js.map +1 -1
  246. package/dist/store/gi/closure-invocation.d.ts +4 -0
  247. package/dist/store/gi/closure-invocation.d.ts.map +1 -0
  248. package/dist/store/gi/closure-invocation.js +22 -0
  249. package/dist/store/gi/closure-invocation.js.map +1 -0
  250. package/dist/store/gi/companion.d.ts.map +1 -1
  251. package/dist/store/gi/companion.js +6 -6
  252. package/dist/store/gi/companion.js.map +1 -1
  253. package/dist/store/gi/constant.d.ts.map +1 -1
  254. package/dist/store/gi/constant.js +12 -3
  255. package/dist/store/gi/constant.js.map +1 -1
  256. package/dist/store/gi/constructor-props.d.ts.map +1 -1
  257. package/dist/store/gi/constructor-props.js +18 -20
  258. package/dist/store/gi/constructor-props.js.map +1 -1
  259. package/dist/store/gi/doc-spec.d.ts +14 -0
  260. package/dist/store/gi/doc-spec.d.ts.map +1 -0
  261. package/dist/store/gi/doc-spec.js +23 -0
  262. package/dist/store/gi/doc-spec.js.map +1 -0
  263. package/dist/store/gi/enum.d.ts.map +1 -1
  264. package/dist/store/gi/enum.js +52 -19
  265. package/dist/store/gi/enum.js.map +1 -1
  266. package/dist/store/gi/function.d.ts +1 -3
  267. package/dist/store/gi/function.d.ts.map +1 -1
  268. package/dist/store/gi/function.js +50 -29
  269. package/dist/store/gi/function.js.map +1 -1
  270. package/dist/store/gi/gtype-binding.d.ts.map +1 -1
  271. package/dist/store/gi/gtype-binding.js +4 -1
  272. package/dist/store/gi/gtype-binding.js.map +1 -1
  273. package/dist/store/gi/interface.d.ts.map +1 -1
  274. package/dist/store/gi/interface.js +155 -26
  275. package/dist/store/gi/interface.js.map +1 -1
  276. package/dist/store/gi/item-comparators.d.ts.map +1 -1
  277. package/dist/store/gi/item-comparators.js +3 -5
  278. package/dist/store/gi/item-comparators.js.map +1 -1
  279. package/dist/store/gi/method.d.ts +11 -2
  280. package/dist/store/gi/method.d.ts.map +1 -1
  281. package/dist/store/gi/method.js +80 -45
  282. package/dist/store/gi/method.js.map +1 -1
  283. package/dist/store/gi/param-marshal.d.ts +6 -2
  284. package/dist/store/gi/param-marshal.d.ts.map +1 -1
  285. package/dist/store/gi/param-marshal.js +54 -5
  286. package/dist/store/gi/param-marshal.js.map +1 -1
  287. package/dist/store/gi/pipeline.d.ts.map +1 -1
  288. package/dist/store/gi/pipeline.js +23 -11
  289. package/dist/store/gi/pipeline.js.map +1 -1
  290. package/dist/store/gi/properties.d.ts +2 -1
  291. package/dist/store/gi/properties.d.ts.map +1 -1
  292. package/dist/store/gi/properties.js +7 -4
  293. package/dist/store/gi/properties.js.map +1 -1
  294. package/dist/store/gi/property-accessor.d.ts +12 -5
  295. package/dist/store/gi/property-accessor.d.ts.map +1 -1
  296. package/dist/store/gi/property-accessor.js +98 -46
  297. package/dist/store/gi/property-accessor.js.map +1 -1
  298. package/dist/store/gi/record-constructor.d.ts +8 -1
  299. package/dist/store/gi/record-constructor.d.ts.map +1 -1
  300. package/dist/store/gi/record-constructor.js +34 -11
  301. package/dist/store/gi/record-constructor.js.map +1 -1
  302. package/dist/store/gi/record-field-accessor.d.ts +3 -1
  303. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  304. package/dist/store/gi/record-field-accessor.js +8 -3
  305. package/dist/store/gi/record-field-accessor.js.map +1 -1
  306. package/dist/store/gi/record-layout.d.ts +6 -1
  307. package/dist/store/gi/record-layout.d.ts.map +1 -1
  308. package/dist/store/gi/record-layout.js +9 -2
  309. package/dist/store/gi/record-layout.js.map +1 -1
  310. package/dist/store/gi/record.d.ts.map +1 -1
  311. package/dist/store/gi/record.js +21 -9
  312. package/dist/store/gi/record.js.map +1 -1
  313. package/dist/store/gi/registration.d.ts +1 -1
  314. package/dist/store/gi/registration.js +4 -4
  315. package/dist/store/gi/registration.js.map +1 -1
  316. package/dist/store/gi/runtime-override.d.ts +2 -1
  317. package/dist/store/gi/runtime-override.d.ts.map +1 -1
  318. package/dist/store/gi/runtime-override.js +8 -5
  319. package/dist/store/gi/runtime-override.js.map +1 -1
  320. package/dist/store/gi/signal.d.ts +2 -1
  321. package/dist/store/gi/signal.d.ts.map +1 -1
  322. package/dist/store/gi/signal.js +42 -37
  323. package/dist/store/gi/signal.js.map +1 -1
  324. package/dist/store/gi/value-marshalable.d.ts +1 -2
  325. package/dist/store/gi/value-marshalable.d.ts.map +1 -1
  326. package/dist/store/gi/value-marshalable.js +3 -2
  327. package/dist/store/gi/value-marshalable.js.map +1 -1
  328. package/dist/store/gi/vtable.d.ts +19 -1
  329. package/dist/store/gi/vtable.d.ts.map +1 -1
  330. package/dist/store/gi/vtable.js +257 -51
  331. package/dist/store/gi/vtable.js.map +1 -1
  332. package/dist/store/gi-store.d.ts +1 -0
  333. package/dist/store/gi-store.d.ts.map +1 -1
  334. package/dist/store/gi-store.js +15 -20
  335. package/dist/store/gi-store.js.map +1 -1
  336. package/dist/store/jsx/element-components.d.ts +1 -1
  337. package/dist/store/jsx/element-components.d.ts.map +1 -1
  338. package/dist/store/jsx/element-components.js +6 -4
  339. package/dist/store/jsx/element-components.js.map +1 -1
  340. package/dist/store/jsx/element-prop-imports.d.ts +1 -3
  341. package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
  342. package/dist/store/jsx/element-prop-imports.js.map +1 -1
  343. package/dist/store/jsx/element-prop-types.d.ts +3 -0
  344. package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
  345. package/dist/store/jsx/element-prop-types.js +7 -1
  346. package/dist/store/jsx/element-prop-types.js.map +1 -1
  347. package/dist/store/jsx/generated-elements.d.ts +2 -1
  348. package/dist/store/jsx/generated-elements.d.ts.map +1 -1
  349. package/dist/store/jsx/generated-elements.js +13 -7
  350. package/dist/store/jsx/generated-elements.js.map +1 -1
  351. package/dist/store/jsx/intrinsic-elements.d.ts +4 -0
  352. package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -1
  353. package/dist/store/jsx/intrinsic-elements.js.map +1 -1
  354. package/dist/store/jsx/jsx.d.ts.map +1 -1
  355. package/dist/store/jsx/jsx.js +10 -9
  356. package/dist/store/jsx/jsx.js.map +1 -1
  357. package/dist/store/jsx/metadata.d.ts.map +1 -1
  358. package/dist/store/jsx/metadata.js +5 -3
  359. package/dist/store/jsx/metadata.js.map +1 -1
  360. package/dist/store/jsx/pipeline.d.ts +1 -1
  361. package/dist/store/jsx/pipeline.d.ts.map +1 -1
  362. package/dist/store/jsx/pipeline.js.map +1 -1
  363. package/dist/store/jsx/props.d.ts +1 -7
  364. package/dist/store/jsx/props.d.ts.map +1 -1
  365. package/dist/store/jsx/props.js +14 -6
  366. package/dist/store/jsx/props.js.map +1 -1
  367. package/dist/store/jsx-store.d.ts.map +1 -1
  368. package/dist/store/jsx-store.js +3 -3
  369. package/dist/store/jsx-store.js.map +1 -1
  370. package/dist/store/resolve-store.d.ts +14 -3
  371. package/dist/store/resolve-store.d.ts.map +1 -1
  372. package/dist/store/resolve-store.js +98 -15
  373. package/dist/store/resolve-store.js.map +1 -1
  374. package/dist/store/store-fs.d.ts +9 -6
  375. package/dist/store/store-fs.d.ts.map +1 -1
  376. package/dist/store/store-fs.js +59 -25
  377. package/dist/store/store-fs.js.map +1 -1
  378. package/dist/store/store-links.d.ts +3 -0
  379. package/dist/store/store-links.d.ts.map +1 -0
  380. package/dist/store/store-links.js +39 -0
  381. package/dist/store/store-links.js.map +1 -0
  382. package/dist/writer/comparison-context.d.ts +4 -0
  383. package/dist/writer/comparison-context.d.ts.map +1 -0
  384. package/dist/writer/comparison-context.js +13 -0
  385. package/dist/writer/comparison-context.js.map +1 -0
  386. package/dist/writer/context.d.ts +3 -2
  387. package/dist/writer/context.d.ts.map +1 -1
  388. package/dist/writer/context.js +11 -3
  389. package/dist/writer/context.js.map +1 -1
  390. package/dist/writer/doc-tags.d.ts +21 -0
  391. package/dist/writer/doc-tags.d.ts.map +1 -0
  392. package/dist/writer/doc-tags.js +38 -0
  393. package/dist/writer/doc-tags.js.map +1 -0
  394. package/dist/writer/doc.d.ts +3 -1
  395. package/dist/writer/doc.d.ts.map +1 -1
  396. package/dist/writer/doc.js +19 -6
  397. package/dist/writer/doc.js.map +1 -1
  398. package/dist/writer/gtk-doc.d.ts +1 -1
  399. package/dist/writer/gtk-doc.d.ts.map +1 -1
  400. package/dist/writer/gtk-doc.js +64 -15
  401. package/dist/writer/gtk-doc.js.map +1 -1
  402. package/dist/writer/module.d.ts +17 -3
  403. package/dist/writer/module.d.ts.map +1 -1
  404. package/dist/writer/module.js +72 -3
  405. package/dist/writer/module.js.map +1 -1
  406. package/dist/xml.d.ts +7 -1
  407. package/dist/xml.d.ts.map +1 -1
  408. package/dist/xml.js +43 -1
  409. package/dist/xml.js.map +1 -1
  410. package/overrides/gdk/rgba.ts.ejs +26 -0
  411. package/overrides/gobject/object.ts.ejs +48 -3
  412. package/overrides/gobject/value.ts.ejs +7 -0
  413. package/overrides/graphene/structs.ts.ejs +55 -0
  414. package/package.json +15 -4
  415. package/src/analysis/descriptor-render.ts +130 -66
  416. package/src/analysis/descriptor.ts +35 -11
  417. package/src/analysis/inheritance.ts +166 -75
  418. package/src/analysis/interface-conflicts.ts +237 -0
  419. package/src/analysis/nul-terminated-bytes.ts +31 -0
  420. package/src/analysis/param-capability.ts +169 -0
  421. package/src/analysis/param-structure.ts +85 -25
  422. package/src/analysis/ts-type.ts +13 -17
  423. package/src/analysis/type-key.ts +14 -0
  424. package/src/analysis/type-shape.ts +24 -0
  425. package/src/compile.ts +110 -26
  426. package/src/docs/api-reference.ts +46 -34
  427. package/src/docs/element-page.ts +58 -49
  428. package/src/docs/handwritten-props.ts +230 -0
  429. package/src/docs/pipeline.ts +131 -21
  430. package/src/docs/render.ts +153 -35
  431. package/src/docs/symbol-page.ts +230 -80
  432. package/src/fingerprint.ts +86 -32
  433. package/src/gi.ts +1 -0
  434. package/src/gir/ancestry.ts +31 -1
  435. package/src/gir/annotations.ts +37 -0
  436. package/src/gir/callback.ts +2 -0
  437. package/src/gir/class.ts +42 -4
  438. package/src/gir/cursor-overrides.ts +12 -0
  439. package/src/gir/emittable.ts +8 -0
  440. package/src/gir/enum.ts +30 -10
  441. package/src/gir/field.ts +24 -9
  442. package/src/gir/function.ts +60 -9
  443. package/src/gir/libraries.ts +11 -3
  444. package/src/gir/library.ts +52 -3
  445. package/src/gir/namespace.ts +49 -7
  446. package/src/gir/parameter.ts +62 -3
  447. package/src/gir/parse.ts +13 -9
  448. package/src/gir/primitives.ts +1 -0
  449. package/src/gir/property.ts +18 -3
  450. package/src/gir/record.ts +24 -2
  451. package/src/gir/size.ts +8 -3
  452. package/src/gir/type-id.ts +49 -3
  453. package/src/gir/type-ref.ts +1 -0
  454. package/src/gir/type.ts +50 -6
  455. package/src/guards.ts +23 -0
  456. package/src/internal.ts +2 -0
  457. package/src/json.ts +11 -0
  458. package/src/khronos/args.ts +36 -13
  459. package/src/khronos/doc-context.ts +62 -0
  460. package/src/khronos/extensions.ts +85 -0
  461. package/src/khronos/jsdoc.ts +152 -56
  462. package/src/khronos/model.ts +314 -69
  463. package/src/khronos/modules.ts +150 -40
  464. package/src/khronos/notes.ts +74 -0
  465. package/src/khronos/param-pair.ts +1 -1
  466. package/src/khronos/parse.ts +3 -4
  467. package/src/khronos/pipeline.ts +95 -42
  468. package/src/khronos/plan.ts +4 -6
  469. package/src/khronos/render.ts +62 -50
  470. package/src/khronos/select.ts +91 -50
  471. package/src/react/element-config.ts +2 -2
  472. package/src/runner.ts +20 -9
  473. package/src/staging.ts +69 -0
  474. package/src/store/compile-store.ts +7 -5
  475. package/src/store/gi/callable-doc.ts +102 -0
  476. package/src/store/gi/callables.ts +58 -44
  477. package/src/store/gi/callback.ts +10 -9
  478. package/src/store/gi/class.ts +83 -49
  479. package/src/store/gi/closure-invocation.ts +26 -0
  480. package/src/store/gi/companion.ts +7 -6
  481. package/src/store/gi/constant.ts +14 -5
  482. package/src/store/gi/constructor-props.ts +19 -23
  483. package/src/store/gi/doc-spec.ts +38 -0
  484. package/src/store/gi/enum.ts +75 -26
  485. package/src/store/gi/function.ts +72 -44
  486. package/src/store/gi/gtype-binding.ts +7 -2
  487. package/src/store/gi/interface.ts +244 -37
  488. package/src/store/gi/item-comparators.ts +3 -5
  489. package/src/store/gi/method.ts +124 -69
  490. package/src/store/gi/param-marshal.ts +91 -6
  491. package/src/store/gi/pipeline.ts +28 -13
  492. package/src/store/gi/properties.ts +10 -5
  493. package/src/store/gi/property-accessor.ts +163 -75
  494. package/src/store/gi/record-constructor.ts +56 -19
  495. package/src/store/gi/record-field-accessor.ts +13 -4
  496. package/src/store/gi/record-layout.ts +12 -2
  497. package/src/store/gi/record.ts +24 -10
  498. package/src/store/gi/registration.ts +5 -5
  499. package/src/store/gi/runtime-override.ts +13 -6
  500. package/src/store/gi/signal.ts +54 -57
  501. package/src/store/gi/value-marshalable.ts +4 -2
  502. package/src/store/gi/vtable.ts +439 -61
  503. package/src/store/gi-store.ts +26 -31
  504. package/src/store/jsx/element-components.ts +8 -5
  505. package/src/store/jsx/element-prop-imports.ts +1 -3
  506. package/src/store/jsx/element-prop-types.ts +10 -1
  507. package/src/store/jsx/generated-elements.ts +17 -8
  508. package/src/store/jsx/intrinsic-elements.ts +4 -0
  509. package/src/store/jsx/jsx.ts +11 -9
  510. package/src/store/jsx/metadata.ts +6 -3
  511. package/src/store/jsx/pipeline.ts +1 -1
  512. package/src/store/jsx/props.ts +20 -7
  513. package/src/store/jsx-store.ts +3 -3
  514. package/src/store/resolve-store.ts +133 -18
  515. package/src/store/store-fs.ts +87 -34
  516. package/src/store/store-links.ts +49 -0
  517. package/src/writer/comparison-context.ts +18 -0
  518. package/src/writer/context.ts +14 -4
  519. package/src/writer/doc-tags.ts +70 -0
  520. package/src/writer/doc.ts +29 -6
  521. package/src/writer/gtk-doc.ts +82 -15
  522. package/src/writer/module.ts +114 -4
  523. package/src/xml.ts +61 -1
@@ -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;
@@ -272,7 +294,7 @@ class Library {
272
294
  seen.add(namespaceName);
273
295
  const path = locateGirFile(identifier, girPath);
274
296
  girFiles.push(path);
275
- const header = parseNamespaceHeader(readRepositoryNode(path));
297
+ const header = parseNamespaceHeader(readRepositoryNode(path), path);
276
298
  const shell = this.registerNamespace(header);
277
299
  discovered.push({ header, shell });
278
300
 
@@ -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,58 +1,100 @@
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
+ /** Path of the `.gir` file the namespace was parsed from, named by every diagnostic the namespace causes. */
48
+ girFile: string;
49
+ /** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
28
50
  sharedLibrary: string | undefined;
51
+ /** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
29
52
  cSymbolPrefixes: string[];
53
+ /** GObject classes declared by the namespace. */
30
54
  classes: GirClass[];
55
+ /** GObject interfaces declared by the namespace. */
31
56
  interfaces: GirClass[];
57
+ /** Structs and unions declared by the namespace. */
32
58
  records: GirRecord[];
59
+ /** Enumerations and bitfields declared by the namespace. */
33
60
  enums: GirEnum[];
61
+ /** Callback types declared by the namespace. */
34
62
  callbacks: GirCallback[];
63
+ /** Free functions declared by the namespace. */
35
64
  functions: GirFunction[];
65
+ /** Compile-time values, emitted as module-level `const` bindings. */
36
66
  constants: GirConstant[];
67
+ /** Typedefs, emitted as TypeScript type aliases and resolvable as types themselves. */
37
68
  aliases: GirAlias[];
38
69
  };
39
70
 
71
+ /** Another namespace a GIR repository depends on. */
40
72
  type NamespaceInclude = {
73
+ /** Name of the included namespace, such as `Gio`. */
41
74
  name: string;
75
+ /** Version of the included namespace, such as `2.0`. */
42
76
  version: string;
43
77
  };
44
78
 
79
+ /** A namespace's declaration and dependencies, read before its body is parsed. */
45
80
  type NamespaceHeader = {
81
+ /** Namespace name as it appears in the GIR, such as `Gtk`. */
46
82
  name: string;
83
+ /** Path of the `.gir` file the header was read from. */
84
+ girFile: string;
85
+ /** The `shared-library` attribute verbatim: the objects to load symbols from, separated by commas. */
47
86
  sharedLibrary: string | undefined;
87
+ /** Prefixes stripped off C identifiers to derive export names, such as `gtk`. */
48
88
  cSymbolPrefixes: string[];
89
+ /** Namespaces this repository includes, each of which is parsed in turn. */
49
90
  includes: NamespaceInclude[];
91
+ /** The `<namespace>` node whose children hold the declarations. */
50
92
  namespaceNode: RawNode;
51
93
  };
52
94
 
53
95
  const namespaceDirectory = (namespace: Pick<GirNamespace, "name">): string => namespace.name.toLowerCase();
54
96
 
55
- const parseNamespaceHeader = (repositoryNode: RawNode): NamespaceHeader => {
97
+ const parseNamespaceHeader = (repositoryNode: RawNode, path: string): NamespaceHeader => {
56
98
  const includes = getChildren(repositoryNode, "include").map<NamespaceInclude>((include) => ({
57
99
  name: nameAttr(include),
58
100
  version: attr(include, "version") ?? "",
@@ -61,11 +103,12 @@ const parseNamespaceHeader = (repositoryNode: RawNode): NamespaceHeader => {
61
103
  const namespaceNode = getChildren(repositoryNode, "namespace")[0];
62
104
 
63
105
  if (namespaceNode === undefined) {
64
- throw new Error("GIR repository has no <namespace> child");
106
+ throw new Error(`GIR file at ${path} has no <namespace> child in its <repository>`);
65
107
  }
66
108
 
67
109
  return {
68
110
  name: nameAttr(namespaceNode),
111
+ girFile: path,
69
112
  sharedLibrary: attr(namespaceNode, "shared-library"),
70
113
  cSymbolPrefixes: splitPrefixes(attr(namespaceNode, "c:symbol-prefixes")),
71
114
  includes,
@@ -76,6 +119,7 @@ const parseNamespaceHeader = (repositoryNode: RawNode): NamespaceHeader => {
76
119
  const createNamespaceShell = (header: NamespaceHeader, id: number): GirNamespace => ({
77
120
  id,
78
121
  name: header.name,
122
+ girFile: header.girFile,
79
123
  sharedLibrary: header.sharedLibrary,
80
124
  cSymbolPrefixes: header.cSymbolPrefixes,
81
125
  classes: [],
@@ -97,15 +141,13 @@ const populateNamespaceBody = (shell: GirNamespace, namespaceNode: RawNode, cont
97
141
  shell.functions = getChildren(namespaceNode, "function").map((fn) => functionFromNode(fn, context));
98
142
 
99
143
  shell.constants = getChildren(namespaceNode, "constant").map((constant) => ({
100
- name: nameAttr(constant),
101
- doc: getDoc(constant),
144
+ ...documentedFromNode(constant),
102
145
  value: attr(constant, "value") ?? "",
103
146
  type: typeRefFromNode(constant, context),
104
147
  }));
105
148
 
106
149
  shell.aliases = getChildren(namespaceNode, "alias").map((alias) => ({
107
- name: nameAttr(alias),
108
- doc: getDoc(alias),
150
+ ...documentedFromNode(alias),
109
151
  cType: attr(alias, "c:type"),
110
152
  target: typeRefFromNode(alias, context),
111
153
  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,88 @@ 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
+ /**
27
+ * Bounds of an out parameter that points into the buffer of a sibling parameter instead of to an
28
+ * array of its own, which GIR describes as an array with no extent of any kind.
29
+ */
30
+ type GirCursorBounds = {
31
+ /** Position of the parameter holding the buffer the pointer points into. */
32
+ baseIndex: number;
33
+ /** Position of the parameter carrying that buffer's element count. */
34
+ lengthIndex: number;
35
+ };
36
+
37
+ /** A parameter of a {@link GirCallable}, with the annotations that decide how it is marshalled. */
19
38
  type GirParameter = {
39
+ /** The name GIR gives the parameter. */
20
40
  name: string;
41
+ /** What the parameter holds, absent when the GIR node declares no type. */
21
42
  type: TypeId | undefined;
43
+ /** The C spelling of the parameter's type, taken from its `type` or `array` child. */
44
+ cType: string | undefined;
45
+ /** Documentation prose from GIR, emitted as the parameter's `@param` text. */
46
+ doc: string | undefined;
47
+ /** Decides whether the parameter is an argument, part of the returned tuple, or both. */
22
48
  direction: ParameterDirection;
49
+ /** Ownership the marshalling descriptor is generated with, deciding whether the receiver frees the value. */
23
50
  transferOwnership: ParameterTransfer;
51
+ /** Whether the value may be null. */
24
52
  nullable: boolean;
53
+ /** Whether the caller may leave the parameter out entirely. */
25
54
  optional: boolean;
55
+ /** Whether the caller supplies the storage an out parameter writes into. */
26
56
  callerAllocates: boolean;
57
+ /** How long a callback parameter stays valid, absent when GIR carries no scope annotation. */
27
58
  scope: CallbackScope | undefined;
59
+ /** Position of the parameter carrying the callback's user data. */
28
60
  closureIndex: number | undefined;
61
+ /** Position of the parameter carrying the callback's destroy notify. */
29
62
  destroyIndex: number | undefined;
63
+ /** Whether the parameter is the `...` varargs marker. */
30
64
  isVarargs: boolean;
65
+ /** Where the buffer is that the parameter points into, when it carries a cursor rather than an array. */
66
+ cursor: GirCursorBounds | undefined;
31
67
  };
32
68
 
69
+ /** What a {@link GirCallable} hands back, with the annotations that decide how it is marshalled. */
33
70
  type GirReturnValue = {
71
+ /** What the callable returns, absent when the GIR node declares no type. */
34
72
  type: TypeId | undefined;
73
+ /** Documentation prose from GIR, emitted as the callable's `@returns` text. */
74
+ doc: string | undefined;
75
+ /** How much ownership the caller takes of the returned value. */
35
76
  transferOwnership: ParameterTransfer;
77
+ /** Whether the returned value may be null. */
36
78
  nullable: boolean;
79
+ /** Whether GIR marks the value as skipped, keeping it out of the generated signature. */
37
80
  skip: boolean;
38
81
  };
39
82
 
83
+ /** Anything GIR describes with parameters and a return value: functions, methods, signals, and callbacks. */
40
84
  type GirCallable = {
85
+ /** The name GIR gives the callable. */
41
86
  name: string;
87
+ /** The callable's documentation text, absent when GIR carries none. */
42
88
  doc: string | undefined;
89
+ /** Release and deprecation annotations GIR carries on the callable. */
90
+ annotations: GirAnnotations;
91
+ /** The parameters the callable takes, in declaration order. */
43
92
  parameters: GirParameter[];
93
+ /** What the callable hands back. */
44
94
  returnValue: GirReturnValue;
95
+ /** Whether the callable reports failure through a trailing `GError`. */
45
96
  throws: boolean;
97
+ /** Whether GIR exposes the callable to bindings. */
46
98
  introspectable: boolean;
47
99
  };
48
100
 
@@ -62,9 +114,14 @@ const hasNullableAttr = (node: RawNode): boolean =>
62
114
  const hasOptionalAttr = (node: RawNode): boolean =>
63
115
  isAttrTrue(node, "optional") || (!isInDirection(node) && isAttrTrue(node, "allow-none"));
64
116
 
117
+ const parameterCType = (node: RawNode): string | undefined =>
118
+ attr(getChild(node, "type"), "c:type") ?? attr(getChild(node, "array"), "c:type");
119
+
65
120
  const parameterFromNode = (node: RawNode, context: ParseContext): GirParameter => ({
66
121
  name: nameAttr(node),
67
122
  type: typeRefFromNode(node, context),
123
+ cType: parameterCType(node),
124
+ doc: getDoc(node),
68
125
  direction: parseEnumAttr(attr(node, "direction"), DIRECTIONS, "in", "direction"),
69
126
  transferOwnership: transferOwnership(node),
70
127
  nullable: hasNullableAttr(node),
@@ -74,6 +131,7 @@ const parameterFromNode = (node: RawNode, context: ParseContext): GirParameter =
74
131
  closureIndex: intAttr(node, "closure"),
75
132
  destroyIndex: intAttr(node, "destroy"),
76
133
  isVarargs: getChild(node, "varargs") !== undefined,
134
+ cursor: undefined,
77
135
  });
78
136
 
79
137
  const isOutParameter = (parameter: GirParameter): boolean =>
@@ -86,11 +144,12 @@ const isInoutParameter = (parameter: GirParameter): boolean => parameter.directi
86
144
 
87
145
  const returnValueFromNode = (node: RawNode | undefined, context: ParseContext): GirReturnValue => {
88
146
  if (node === undefined) {
89
- return { type: undefined, transferOwnership: "none", nullable: false, skip: false };
147
+ return { type: undefined, doc: undefined, transferOwnership: "none", nullable: false, skip: false };
90
148
  }
91
149
 
92
150
  return {
93
151
  type: typeRefFromNode(node, context),
152
+ doc: getDoc(node),
94
153
  transferOwnership: transferOwnership(node),
95
154
  nullable: hasNullableAttr(node),
96
155
  skip: isAttrTrue(node, "skip"),
@@ -102,8 +161,7 @@ const parseCallable = (node: RawNode, context: ParseContext): GirCallable => {
102
161
  const parameterNodes = getChildren(parametersNode, "parameter");
103
162
 
104
163
  return {
105
- name: nameAttr(node),
106
- doc: getDoc(node),
164
+ ...documentedFromNode(node),
107
165
  parameters: parameterNodes.map((parameter) => parameterFromNode(parameter, context)),
108
166
  returnValue: returnValueFromNode(getChild(node, "return-value"), context),
109
167
  throws: isAttrTrue(node, "throws"),
@@ -119,6 +177,7 @@ export {
119
177
  isInoutParameter,
120
178
  parseCallable,
121
179
  type ParameterTransfer,
180
+ type GirCursorBounds,
122
181
  type GirParameter,
123
182
  type GirReturnValue,
124
183
  type GirCallable,
package/src/gir/parse.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { readFileSync } from "node:fs";
2
- import { createXmlParser } from "../xml.js";
1
+ import { createXmlParser, parseXmlFile } from "../xml.js";
3
2
 
3
+ /** An element of the parsed GIR XML: attributes under `@_`-prefixed keys, children under their tag names. */
4
4
  type RawNode = Record<string, unknown>;
5
5
 
6
+ const GIR_LABEL = "GIR file";
7
+
6
8
  const MULTI_TAGS: Set<string> = new Set([
7
9
  "include",
8
10
  "class",
@@ -16,6 +18,7 @@ const MULTI_TAGS: Set<string> = new Set([
16
18
  "alias",
17
19
  "union",
18
20
  "method",
21
+ "virtual-method",
19
22
  "constructor",
20
23
  "property",
21
24
  "field",
@@ -40,11 +43,8 @@ function renameReservedTag(tag: string): string {
40
43
  return RESERVED_TAG_RENAMES.get(tag) ?? tag;
41
44
  }
42
45
 
43
- const parseGirFile = (path: string): RawNode => {
44
- const xml = readFileSync(path, "utf8");
45
-
46
- return PARSER.parse(xml) as RawNode;
47
- };
46
+ const parseGirFile = (path: string): RawNode =>
47
+ parseXmlFile({ parser: PARSER, label: GIR_LABEL, path }) as RawNode;
48
48
 
49
49
  const attr = (node: RawNode | undefined, name: string): string | undefined => {
50
50
  if (node === undefined) {
@@ -141,12 +141,12 @@ const docTextFromObject = (value: object): string | undefined => {
141
141
  return typeof text === "string" ? normalizeDoc(text) : undefined;
142
142
  };
143
143
 
144
- const getDoc = (node: RawNode | undefined): string | undefined => {
144
+ const docElementText = (node: RawNode | undefined, tag: string): string | undefined => {
145
145
  if (node === undefined) {
146
146
  return undefined;
147
147
  }
148
148
 
149
- const value = firstDocValue(node.doc);
149
+ const value = firstDocValue(node[tag]);
150
150
 
151
151
  if (typeof value === "string") {
152
152
  return normalizeDoc(value);
@@ -159,6 +159,9 @@ const getDoc = (node: RawNode | undefined): string | undefined => {
159
159
  return docTextFromObject(value);
160
160
  };
161
161
 
162
+ const getDoc = (node: RawNode | undefined): string | undefined => docElementText(node, "doc");
163
+ const getDocDeprecated = (node: RawNode | undefined): string | undefined => docElementText(node, "doc-deprecated");
164
+
162
165
  export {
163
166
  GIR_CONSTRUCTOR_TAG,
164
167
  parseGirFile,
@@ -170,5 +173,6 @@ export {
170
173
  getChildren,
171
174
  getChild,
172
175
  getDoc,
176
+ getDocDeprecated,
173
177
  type RawNode,
174
178
  };
@@ -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 };