Walk an array of struct values at the struct's own stride - #13
Merged
estebanzimanyi merged 2 commits intoSep 2, 2026
Merged
Conversation
A C type the mapping table does not name falls through to IntPtr, the pointer-width opaque handle. The `_t` spellings libclang leaves unreduced — int8_t through uint64_t — and `unsigned char` are absent from that table, so 530 of the 4825 bound functions declared a scalar at pointer width: 246 int64_t, 140 uint64_t, 38 uint32_t and 24 unsigned char arguments, and 72 int64_t, 58 uint64_t, 56 uint32_t and one unsigned char returns. A uint32_t returned as IntPtr reads eight bytes of a register the ABI defines four of, so the value carries whatever the upper half held. The enum types come from the catalog's own `enums` rather than from names listed one at a time. The five listed names covered MeosType, interpType and tempSubtype, missed IndexSearchOp, SPTreeKind, MeosPixType, MeosOper, SkipListType and nullHandleType across 43 further parameters and returns, and one of them — spanType — names no catalog enum at all. Reading the set from the catalog is what keeps the next enum from arriving as a pointer.
An array return whose element is a catalog struct — Span, TBox, STBox,
Match, GeoPoseFrame — is unpacked as an array of pointers: element i is
read as the eight bytes at i * IntPtr.Size and used as an address, which
for a 24-byte Span is that Span's own spantype, basetype and bound flags.
68 wrappers return such an array, `spanset_spans`, `set_spans`,
`geo_stboxes` and `tnumber_tboxes` among them.
The stride is the struct's size, taken from the field layout the catalog
records: every field at the offset the catalog gives it, the whole padded
to a multiple of its widest field — Span 24, TBox 56, STBox 80, Match 8.
Element i is the address i strides into the block, so `spanset_spans` over
`{[8, 10], [11, 12]}` answers those two spans instead of two addresses
that happened never to be dereferenced.
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.
An array return whose element is a catalog struct — Span, TBox, STBox,
Match, GeoPoseFrame — is unpacked as an array of pointers: element i is
read as the eight bytes at i * IntPtr.Size and used as an address, which
for a 24-byte Span is that Span's own spantype, basetype and bound flags.
68 wrappers return such an array,
spanset_spans,set_spans,geo_stboxesandtnumber_tboxesamong them.The stride is the struct's size, taken from the field layout the catalog
records: every field at the offset the catalog gives it, the whole padded
to a multiple of its widest field — Span 24, TBox 56, STBox 80, Match 8.
Element i is the address i strides into the block, so
spanset_spansover{[8, 10], [11, 12]}answers those two spans instead of two addressesthat happened never to be dereferenced.