Return the MEOS error alongside every generated Go value - #14
Merged
estebanzimanyi merged 2 commits intoAug 15, 2026
Merged
Conversation
The cgo preamble hardcoded /usr/local (and /opt/homebrew) as the place to find libmeos, plus a hand-kept list of ten -D family macros mirroring the if(ALL) loop in MobilityDB's CMakeLists. Both are assumptions about a machine rather than facts about the library, and the -D list is the one that bites: the public headers gate declarations on those macros, so a list that disagrees with the installed library either declares a symbol that cannot link or hides a family the library provides. The macros are not derivable from -DALL either, which selects families at configure time and never reaches a compiler. The installed meos.pc now reports both, so the preamble asks for them. This also makes the binding relocatable: PKG_CONFIG_PATH selects which libmeos to build against, which is what lets a build target a private prefix instead of inheriting a machine-wide directory shared with everything else on the host. H3 ships no pkg-config file, so meos_h3.h's <h3api.h> keeps its include dir named here; GEOS and GSL resolve from the default include path.
A MEOS call reports failure out of band, and returns a sentinel that is the maximum of its own return type. The generated wrappers dropped that channel: TemporalNumInstants returned a bare int, so a rejected argument reached the caller as INT_MAX, a plausible count. No sentinel can carry the answer by itself -- INT_MAX is a count, DBL_MAX is a distance, and a bool has no spare value at all, so its failure is indistinguishable from a definite false. Each wrapper resets the errno, calls, and returns the error alongside its value, which is Go's idiom for the channel. The results are named so one guard shape serves every signature rather than a per-type zero value. All 3314 emitted wrappers carry it, with no per-function exception: an exception would need a hand-maintained list and the property would stop being checkable. The 30 Inner() accessors and the two error helpers touch no MEOS call and keep their signatures. The errno accessors join the skip list, being the plumbing this is built on: a generated MeosErrno() would reset the errno immediately before reading it and so always report success.
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.
The branch carries the pkg-config preamble commit beneath it; the second commit is the one to review.
Every generated wrapper resets the MEOS errno, calls, and returns the error alongside its value, which is Go idiom for an out-of-band failure channel.
A MEOS call reports failure out of band and returns a sentinel that is the maximum of its own return type. The generated surface drops that channel:
TemporalNumInstantsreturns a bareint, so a rejected argument reaches the caller asINT_MAX, a plausible count that arithmetic carries onward. No sentinel answers this by itself —INT_MAXis a count,DBL_MAXis a distance, and aboolhas no spare value at all, so its failure is indistinguishable from a definite false. The error state is the only discriminator.The results are named so one guard shape serves every signature rather than a per-type zero-value expression. All 3314 emitted wrappers carry the error, with no per-function exception: an exception needs a hand-maintained list, and the property stops being checkable. The 30
Inner()accessors and the two error helpers reach no MEOS call and keep their signatures, which is the whole of the difference between the 3346 functions in the package and the 3314 wrappers the generator reports.The errno accessors join the skip list as the plumbing this is built on: a generated
MeosErrno()resets the errno immediately before reading it, and so always reports success.meos_initialize_noexit_error_handlerstays exposed, and a caller installs it once per process, on every thread that calls MEOS.go build ./functions/against a private prefix exits 0.