Skip to content

docs: park varargs constructor bindings analysis#128

Open
chris-armstrong wants to merge 1 commit into
mainfrom
docs/varargs-bindings-plan
Open

docs: park varargs constructor bindings analysis#128
chris-armstrong wants to merge 1 commit into
mainfrom
docs/varargs-bindings-plan

Conversation

@chris-armstrong
Copy link
Copy Markdown
Owner

Summary

Adds a single design note at gir_gen/docs/plans/varargs-bindings.md. No code changes.

The binding generator skips C functions marked variadic (printf-style or property-list constructors), because the variable arguments carry no type information and can't be mapped to a typed OCaml signature. This document surveys what's in that gap across the nine bound libraries, sorts the variadic functions into seven structural shapes, and asks which ones are actually worth supporting.

The headline finding: most variadic functions in GTK/GLib have a non-variadic counterpart that the generator already binds (_v array variants, _variant GVariant variants, _value typed-value variants — all confirmed present in the GIR XML). After accounting for those, only five constructors are genuinely uncovered, all sharing the same shape: a GObject type plus a list of property/value pairs.

For those five, the document recommends two small changes — generate a get_type external for every class, and bind a generic g_object_new in the common runtime — instead of building a new override directive. The result is that callers can construct any GObject manually using the existing setter methods, with no new generator code paths beyond a one-line external per class.

The document is intentionally a discussion starter, not a queued work item. Open questions about layout, eager vs. lazy registration, and whether any examples actually need this are listed at the end.

Test plan

  • dune build — clean (markdown-only change)
  • dune build @fmt from ocgtk/ — clean
  • xvfb-run dune test ocgtk — all suites pass
  • dune test gir_gen from workspace root — all 454 tests pass

chris-armstrong

Markdown-only design note in gir_gen/docs/plans/varargs-bindings.md
covering the seven shapes of varargs functions across the bound GIR
namespaces, which ones are already covered by introspectable _v / _variant
/ _value counterparts, and what would be needed to bind the residual
five GObject-property-style constructors (gtk_alert_dialog_new,
gtk_message_dialog_new, gtk_about_dialog_new, gtk_show_about_dialog,
gtk_app_chooser_dialog_new).

Recommendation in the document: do not build the override-system
extension. Two small generator changes (per-class get_type external,
common Gobject.Object.create) plus one optional per-class create_empty
emitter cover all five with idiomatic OCaml at lower complexity than
a new override directive. Open questions included; intended as a
discussion starter, not a queued work item.

No code changes.

Chris Armstrong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant