Bump bindings to MEOS 1.3 via meos-idl.json codegen#3
Open
estebanzimanyi wants to merge 3 commits into
Open
Conversation
Adds tools/codegen.py: consumes MEOS-API's meos-idl.json (github.com/MobilityDB/MEOS-API) and emits MEOSExternalFunctions.cs and MEOSExposedFunctions.cs. Replaces the regex-based MEOS.NET.Builder which had known defects: `int32_t srid` rendered as `int_t srid`, throws on empty argument lists, hardcoded developer DllPath, single-line-only regex. The regenerated bindings cover the full MEOS 1.3 public surface: 2397 functions (was 1281, +1116). DllPath is the bare name "meos" so the OS loader resolves via LD_LIBRARY_PATH / DYLD_LIBRARY_PATH / PATH — no hardcoded developer paths. The high-level C# wrappers under MEOS.NET/Types/ are hand-written and call into these bindings; the MEOS 1.3 surface adds, renames, and re-types ~1100 names. `dotnet build MEOS.NET/MEOS.NET.csproj` against the new bindings surfaces every adaptation site as a compiler error: 137 to work through (predicates that flipped from bool to int, renamed helpers like tfloat_round / tfloat_derivative that now live under tnumber_* or have type-suffixed names). Those follow-ups stay outside this commit so the binding refresh is mechanically reviewable on its own. CFunctionDeclaration.HasUndefinedElements no longer rejects declarations with empty argument lists (valid C, e.g. `int foo()`) so the legacy Builder still runs if needed.
MEOS 1.3 makes three sweeping shape changes that the regenerated bindings expose: 1. Every predicate that used to return `bool` now returns `int` (0/1). 86 call sites under MEOS.NET/Types/ wrapped with `!= 0` so each caller's domain bool semantics stays explicit instead of hidden under a generated wrapper. 2. Every `bool` parameter (span_make's lower_inc/upper_inc, asMfJson's bounding-box flag, temporal_duration's ignoreGaps, ...) flipped to `int`. 29 call sites cast `b ? 1 : 0` at the boundary. 3. Several helpers renamed (`tfloat_round` -> `temporal_round`, `tfloat_derivative` -> `temporal_derivative`, `tfloat_ever_eq` -> `ever_eq_tfloat_float` and family, `span_width` -> `numspan_width`, `spanset_width` -> `numspanset_width`, `distance_tnumber_tnumber` -> `tdistance_tnumber_tnumber`, `distance_tfloat_float` -> `tdistance_tfloat_float`, `tstzspan_to_tbox` -> `span_to_tbox`, `tstzset_to_tbox` -> `set_to_tbox`, `tstzspanset_to_tbox` -> `spanset_to_tbox`). Call sites updated directly; no compat aliases in the codegen layer. Also: - `meos_initialize` is now zero-argument. `MEOSLifecycle.Initialize` splits into three calls (`meos_initialize`, `meos_initialize_timezone`, `meos_initialize_error_handler`) and marshals the C# error-handler delegate to a function pointer via `Marshal.GetFunctionPointerForDelegate`, keeping a static reference alive to prevent GC collection while MEOS holds the pointer. - `temporal_from_mfjson` now requires a `meosType` enum; the generic `Temporal.FromMFJson(string)` factory cannot pick a subtype from JSON content alone, so it was removed. Subtype- specific factories live on subclasses (TemporalBoolean.FromMFJson via `tbool_from_mfjson`, TemporalFloat.FromMFJson via `tfloat_from_mfjson`). - `*_from_wkb` size argument is `int` (was `ulong`). Four call sites drop the `(ulong)` cast. - `tfloatseq_from_base_tstzspan` and the sequence-set form take an `interpType` enum; `MEOS.NET.Enums.InterpolationType` casts explicitly with `(int)`. Solution builds 0-error / 0-warning across MEOS.NET, MEOS.NET.Builder, MEOS.NET.NpgSql, ExampleApp, MEOS.NET.Tests.
build_pymeos_functions.py-style consolidation for the .NET side: when meos-idl.json carries a shape.arrayReturn with an accessor-style length, the regenerated wrapper now calls the sibling on the wrapped input and Marshal.Copy's the result into a managed array (long[] for *set_values, double[] for floatset_values, int[] for intset_values, IntPtr[] for *_insts_p / *_sequences_p / spanset_spanarr family). When shape carries outputArrays the wrapper allocates one IntPtr buffer per declared output, calls the external entry, and returns a value-tuple of typed arrays (e.g. temporal_time_split now returns (IntPtr[], long[]) for the result + time_bins pair, and tgeo_space_time_split returns (IntPtr[], IntPtr[], long[])). All bool returns and bool parameters gain [MarshalAs(UnmanagedType.U1)] so the LibraryImport source generator does not promote them to the 4-byte Windows BOOL: MEOS emits C _Bool (1 byte) on every platform the .NET binding targets. FloatSet.Values is rewritten to consume the new typed return.
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.
Replaces the regex-based MEOS.NET.Builder with a JSON-driven tools/codegen.py that consumes MobilityDB/MEOS-API's unified meos-idl.json catalog and emits MEOSExternalFunctions.cs + MEOSExposedFunctions.cs. Picks up the full MEOS 1.3 surface: 2397 functions (was 1281, plus 1116) including the rtree builders, type-specific tfloatbox/tintbox helpers, span_to_tbox / set_to_tbox / spanset_to_tbox replacing tstzspan_to_tbox / tstzset_to_tbox / tstzspanset_to_tbox, tdistance_tfloat_float / tdistance_tnumber_tnumber replacing distance_tfloat_float / distance_tnumber_tnumber, ever_eq_tfloat_float and the rest of the ever/always family replacing tfloat_ever_eq and friends, temporal_round / temporal_derivative replacing tfloat_round / tfloat_derivative, numspan_width / numspanset_width replacing span_width / spanset_width, plus geo helpers (box3d_make/out, gbox_make, geo_points, geo_pointarr, geom_intersection2d_coll, geom_min_bounding_radius) and the new rtree API. DllPath is the bare name "meos" so the OS loader resolves it via LD_LIBRARY_PATH / DYLD_LIBRARY_PATH / PATH rather than a hardcoded developer path. The hand-written wrappers under MEOS.NET/Types/ adapt to the 1.3 shape directly at call sites (no compat aliases or generated shims): 86 predicates wrapped with
!= 0for the int->bool boundary, 29 bool->int casts on the lower_inc / upper_inc / bounding-box / ignoreGaps flags, 13 mechanical renames, ulong->int trimmed on *_from_wkb size args, (int)InterpolationType casts on the sequence factories, meos_initialize split into meos_initialize + meos_initialize_timezone + meos_initialize_error_handler with the C# error-handler delegate marshaled via Marshal.GetFunctionPointerForDelegate and held in a static field so GC does not collect it under MEOS, and the generic Temporal.FromMFJson(string) removed in favour of typed factories on TemporalBoolean / TemporalFloat that call tbool_from_mfjson / tfloat_from_mfjson directly. Solution builds 0-error / 0-warning across MEOS.NET, MEOS.NET.Builder, MEOS.NET.NpgSql, ExampleApp, MEOS.NET.Tests. MEOS.NET has no active maintainer at present so this is open for any ecosystem committer to review and land.