Skip to content

Name a record declared without a tag by its typedef - #281

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:parser/anonymous-record-typedef-name
Nov 19, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:parser/anonymous-record-typedef-name

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

MEOS declares four structures without a tag, typedef struct {...} GeomVal; and Pixel,
ways_record and SERIALIZED_PATCH the same way. C names such a record by its typedef alone, while
libclang spells it struct (unnamed at meos_raster.h:130:9). _canonical_spelling replaces the
(unnamed at ...) part by the typedef and keeps the keyword before it, so a slot reads
struct GeomVal *, a tag no header declares, which a binding spelling the type as C does cannot
compile (GoMEOS's cgo C.struct_GeomVal). And parse_meos takes as a record's typedef any typedef
whose type contains the record, so a callback taking a ways_record * (ways_fetch_fn) can stand
for the layout of ways_record.

_canonical_spelling replaces the keyword with the (unnamed ...) part, in every form libclang
writes it, and parse_meos takes as a record's typedef only a typedef whose type is that record.

Witness: the catalog of MobilityDB 87c8d33e4d, generated by master's parser, spells those four
records by a tag 13 times (struct GeomVal, struct Pixel, struct ways_record,
struct SERIALIZED_PATCH, with and without a pointer).

Measured: the same catalog generated by this branch spells them by a tag 0 times and by their
typedef 30 times, the STBox control unchanged at 2469. tests/test_anonymous_records.py (4 tests)
checks the spellings libclang gives and the catalog's slots and structures. The suite runs 700
passed against master's 696 on that catalog, and the 6 tests that fail on master (test_family,
test_struct_layout, test_typerecover) fail the same with this branch and none other.

Why: the owner's ruling of 2026-11-19 ("as you recommend") that this fix, kept from a worktree
sweep, becomes a pull request.

MEOS declares four structures without a tag, `typedef struct {...} GeomVal;` and `Pixel`,
`ways_record` and `SERIALIZED_PATCH` the same way. C names such a record by its typedef alone, while
libclang spells it `struct (unnamed at meos_raster.h:130:9)`. _canonical_spelling replaces the
`(unnamed at ...)` part by the typedef and keeps the keyword before it, so a slot reads
`struct GeomVal *`, a tag no header declares, which a binding spelling the type as C does cannot
compile (GoMEOS's cgo `C.struct_GeomVal`). And parse_meos takes as a record's typedef any typedef
whose type contains the record, so a callback taking a `ways_record *` (`ways_fetch_fn`) can stand
for the layout of `ways_record`.

_canonical_spelling replaces the keyword with the `(unnamed ...)` part, in every form libclang
writes it, and parse_meos takes as a record's typedef only a typedef whose type is that record.

Witness: the catalog of MobilityDB 87c8d33e4d, generated by master's parser, spells those four
records by a tag 13 times (`struct GeomVal`, `struct Pixel`, `struct ways_record`,
`struct SERIALIZED_PATCH`, with and without a pointer).

Measured: the same catalog generated by this branch spells them by a tag 0 times and by their
typedef 30 times, the `STBox` control unchanged at 2469. tests/test_anonymous_records.py (4 tests)
checks the spellings libclang gives and the catalog's slots and structures. The suite runs 700
passed against master's 696 on that catalog, and the 6 tests that fail on master (test_family,
test_struct_layout, test_typerecover) fail the same with this branch and none other.

Why: the owner's ruling of 2026-11-19 ("as you recommend") that this fix, kept from a worktree
sweep, becomes a pull request.
@estebanzimanyi
estebanzimanyi merged commit 047a0bf into MobilityDB:master Nov 19, 2026
3 checks passed
@estebanzimanyi
estebanzimanyi deleted the parser/anonymous-record-typedef-name branch November 19, 2026 18:43
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