Skip to content

Map foreign Arrow C Data Interface struct pointers to void *#27

Open
estebanzimanyi wants to merge 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/arrow-foreign-opaque-codegen
Open

Map foreign Arrow C Data Interface struct pointers to void *#27
estebanzimanyi wants to merge 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/arrow-foreign-opaque-codegen

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

The Arrow C Data Interface structs (ArrowSchema, ArrowArray) appear in the MEOS public API only at the FFI boundary. They are forward-declared, layout-less foreign types with no MEOS semantics, so a pointer to one is ABI-identical to void *.

Currently the extractor emits them verbatim as struct ArrowSchema * / struct ArrowArray *, and the downstream generators diverge: a permissive generator (JMEOS) maps an unrecognised struct pointer to a raw Pointer and the Arrow functions bind, while a conservative one (GoMEOS) treats it as an unsupported shape and skips the function. So meos_*_to_arrow / meos_*_from_arrow reach some bindings but not others.

This normalises struct ArrowSchema * / struct ArrowArray * to void * in both the declared and canonical spellings — mirroring the existing _Bool -> bool normalisation in the same two spelling helpers — so every binding's existing opaque-pointer-family handling (Pointer, _ffi.CData, unsafe.Pointer, IntPtr, *mut c_void) wraps them uniformly, with no per-generator special case. The idiomatic Arrow bridge stays in each binding's hand-written layer, keyed off the *_to_arrow / *_from_arrow function name, as with any other opaque-pointer-family value.

It also adds a generation-time guard (find_unlisted_foreign_structs) that warns when a forward-declared foreign struct pointer appears in the API but is not listed in _EXTERNAL_OPAQUE_STRUCTS, so a future external type is classified explicitly instead of diverging silently per binding. The guard distinguishes foreign structs (only ever elaborated, struct X *) from typedef'd MEOS types (also appear bare, Pose *), so MEOS types are never flagged.

Verified with the GoMEOS generator: before, meos_temporal_to_arrow and siblings emit // TODO unsupported param struct ArrowSchema *; after the normalisation, they generate as func MeosTemporalToArrow(temp Temporal, out_schema unsafe.Pointer, out_array unsafe.Pointer) bool.

The Arrow C Data Interface structs (ArrowSchema, ArrowArray) are
forward-declared, layout-less foreign types with no MEOS semantics, so a
pointer to one is ABI-identical to void *. Emitting them as void * lets every
binding's existing opaque-pointer-family handling wrap them uniformly instead
of each generator needing an Arrow-specific case: a permissive generator maps
an unrecognised pointer to a raw pointer, while a conservative one skips it.

Normalise struct ArrowSchema * / ArrowArray * to void * in the declared and
canonical spellings, mirroring the existing _Bool -> bool normalisation. Add a
generation-time guard that warns when a forward-declared foreign struct pointer
appears in the API but is not listed, so it is classified explicitly rather
than diverging silently per binding.
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