Spell canonical as the MEOS typedef its cType names, not the platform type#59
Merged
estebanzimanyi merged 1 commit intoJul 16, 2026
Conversation
… type On the self-contained (installed-header) parse libclang fully resolves the public MEOS/PG typedefs to their platform types -- TimestampTz to long, Jsonb * / JsonPath * to varlena * -- while cType keeps the faithful typedef. A binding generator keys on canonical, so an over-resolved slot loses its semantic type: it marshals a timestamp as a bare long, or drops the function entirely when the platform type is unmarshallable (varlena). The temporal value-accessors (e.g. tint_value_at_timestamptz) and the jsonb path surface (jsonb_path_exists) then go missing from every generated binding. Re-derive canonical from the faithful cType through the existing _TYPE_MAP, so source and installed parses agree on the MEOS type. The pass is idempotent, a no-op on non-typedef slots (Temporal *, int *), and complements recover_collapsed_types: that recovers a cType the preprocessor erased to int; this trusts a faithful cType and only re-spells canonical. Struct byte-offsets from the installed parse are untouched. Guarded by test_typedef_canonical_not_platform_resolved.
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.
What this changes
On the
build-libmeos: truepathprovision-meosderives the catalog from the self-contained installed headers so struct field types and byte offsets resolve (#45). Parsing those headers, libclang fully resolves the public MEOS/PG typedefs to their platform types whilecTypekeeps the faithful typedef:cType(faithful)canonical(over-resolved)tint_value_at_timestamptz(…, TimestampTz t, …)TimestampTzlongjsonb_path_exists(const Jsonb *jb, const JsonPath *jp, …)const Jsonb */const JsonPath *const struct varlena *A binding generator keys on
canonical, so an over-resolved slot loses its semantic type — it marshals a timestamp as a barelong, or drops the function entirely when the platform type is unmarshallable (varlena). The temporal value-accessors and the jsonb path surface then go missing from every generated binding. The source-header parse does not exhibit this because libclang cannot resolve those typedefs there.This is the canonical-type sibling of #54 (installed headers lose the Doxygen out-param info): the installed-header signatures stay, and the degraded field is re-derived from a faithful source.
The rule
normalize_canonical(parser/typerecover.py, run afterreconcile) re-derives each slot'scanonicalfrom its faithfulcTypethrough the existing_TYPE_MAP— already the single source of truth for how each MEOS/PG typedef is spelled in the IDL. One invariant, applied uniformly to every param, return and struct field:Temporal *,int *) and on the source parse (wherecanonicalalready equals the typedef).recover_collapsed_types, which recovers acTypethe preprocessor erased toint; this trusts a faithfulcTypeand only re-spellscanonical.cTypeandoffset_bitsuntouched, so the installed-parse struct byte-offsets stand.Coverage
tests/test_typerecover.py::test_typedef_canonical_not_platform_resolvedassertstint_value_at_timestamptz.tisTimestampTzandjsonb_path_exists.jb/jpareJsonb/JsonPath, not their platform resolution.