docs: park varargs constructor bindings analysis#128
Open
chris-armstrong wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (
_varray variants,_variantGVariant variants,_valuetyped-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_typeexternal for every class, and bind a genericg_object_newin 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-lineexternalper 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 @fmtfromocgtk/— cleanxvfb-run dune test ocgtk— all suites passdune test gir_genfrom workspace root — all 454 tests passchris-armstrong