Return a MEOS struct as the struct, not as a pointer - #20
Merged
estebanzimanyi merged 1 commit intoSep 2, 2026
Merged
Conversation
Three MEOS functions hand a struct back by value — `tpoint_as_mvtgeom` answers `MvtGeom`, `tgeo_space_split` answers `SpaceSplit`, `tgeo_space_time_split` answers `SpaceTimeSplit` — and a struct return is not a pointer. On the ABI these bindings ship for, a 24-byte struct comes back through a hidden first argument the caller supplies, so a binding that declares the return as a pointer shifts every real argument by one register and the callee reads the second argument where the first belongs. Measured on `tpoint_as_mvtgeom` over a temporal point and an STBox: with the return declared `void *` the call answers `The temporal value must be a temporal point`, MEOS validating the STBox it receives in place of the temporal value, and with the return declared `MvtGeom` the same call answers `count=2` and two live pointers. The C# form of such a struct comes from the catalog's own `structs` entry: field for field, a pointer as `IntPtr` and a scalar through the same map the parameters use, under `[StructLayout(LayoutKind.Sequential)]`. Only a struct a function actually returns or takes by value gets one, which the generator reads off the signatures rather than a list — every other MEOS struct crosses the boundary as a pointer and stays opaque. Two tests read every field of one. The MvtGeom test reads its geometry back through `geo_as_text` and walks its `times` array for exactly `count` increasing timestamps; the SpaceSplit test reads each fragment through `tspatial_as_text` and each bin through `geo_as_text`. A field at the wrong offset, or a call whose arguments shifted, answers neither.
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.
Three MEOS functions hand a struct back by value —
tpoint_as_mvtgeomanswers
MvtGeom,tgeo_space_splitanswersSpaceSplit,tgeo_space_time_splitanswersSpaceTimeSplit— and a struct return is nota pointer. On the ABI these bindings ship for, a 24-byte struct comes back
through a hidden first argument the caller supplies, so a binding that
declares the return as a pointer shifts every real argument by one register
and the callee reads the second argument where the first belongs. Measured on
tpoint_as_mvtgeomover a temporal point and an STBox: with the returndeclared
void *the call answersThe temporal value must be a temporal point, MEOS validating the STBox itreceives in place of the temporal value, and with the return declared
MvtGeomthe same call answerscount=2and two live pointers.The C# form of such a struct comes from the catalog's own
structsentry:field for field, a pointer as
IntPtrand a scalar through the same map theparameters use, under
[StructLayout(LayoutKind.Sequential)]. Only a struct afunction actually returns or takes by value gets one, which the generator
reads off the signatures rather than a list — every other MEOS struct crosses
the boundary as a pointer and stays opaque.
Two tests read every field of one. The MvtGeom test reads its geometry back
through
geo_as_textand walks itstimesarray for exactlycountincreasing timestamps; the SpaceSplit test reads each fragment through
tspatial_as_textand each bin throughgeo_as_text. A field at the wrongoffset, or a call whose arguments shifted, answers neither.