Skip to content

Add a codegen for GoMEOS wrappers driven by meos-idl.json#2

Draft
estebanzimanyi wants to merge 6 commits into
mainfrom
refactor/codegen-meos-idl
Draft

Add a codegen for GoMEOS wrappers driven by meos-idl.json#2
estebanzimanyi wants to merge 6 commits into
mainfrom
refactor/codegen-meos-idl

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

tools/codegen.py reads tools/meos-idl.json produced by the MEOS-API parser and emits idiomatic Go wrappers into tools/_preview/, prefixed with an underscore so the existing hand-written surface is unaffected (go build ./... ignores _-prefixed directories). The first cut covers 1967 of the 2369 candidate functions across the six public headers: scalar inputs, opaque-pointer wrappers (Temporal, STBox, TBox, Span, SpanSet, Set, GSERIALIZED, TInstant, TSequence, TSequenceSet, Npoint, Nsegment, SkipList, RTree, Interval), C and PostgreSQL text strings. 170 Datum-bearing helpers are skipped as MEOS-internal (the hand-written surface exposes them through typed overloads that the codegen cannot synthesise from the IDL). 232 functions remain as TODO until a per-function metadata catalog mirrors the result / output / nullable sets that PyMEOS-CFFI keeps in build_pymeos_functions.py.

Adopts the unified spatial nomenclature (tpoint_* renamed to tspatial_*
/ tgeo_* depending on signature), the meos_initialize() split that
moves the timezone to a separate call, and the temporal_append_tinstant
interpType parameter.  cast.h gains stddef.h so size_t resolves on
hosts that do not transitively include it via meos.h.
tools/codegen.py reads tools/meos-idl.json produced by the MEOS-API
parser and emits idiomatic Go wrappers into tools/_preview/, prefixed
with an underscore so the existing hand-written surface is unaffected
(go build ./... ignores _-prefixed directories).  The first cut covers
1967 of the 2369 candidate functions across the six public headers:
scalar inputs, opaque-pointer wrappers (Temporal, STBox, TBox, Span,
SpanSet, Set, GSERIALIZED, TInstant, TSequence, TSequenceSet, Npoint,
Nsegment, SkipList, RTree, Interval), C and PostgreSQL text strings.
170 Datum-bearing helpers are skipped as MEOS-internal (the hand-written
surface exposes them through typed overloads that the codegen cannot
synthesise from the IDL).  232 functions remain as TODO until a per-
function metadata catalog mirrors the result / output / nullable sets
that PyMEOS-CFFI keeps in build_pymeos_functions.py.
Extends the codegen with name-driven classification so the bulk of the
remaining unsupported shapes emit cleanly: output parameters named
result / value lower to extra Go return values for scalar, wrapped
opaque, and text **; counted-array inputs (T ** / const T * / text **
paired with int count or size_t size) lower to Go slices; counted-array
returns (T ** paired with int *count or matching the length of an
input slice) and uint8_t * byte buffers lower to Go slices via
unsafe.Slice plus per-element conversion.  char ** array returns,
unsafe.Pointer for void * arguments, and additional opaque wrappers
(Match, BOX3D, GBOX, AFFINE, PJ_CONTEXT, gsl_rng, TimeADT) round out
the surface.  Coverage rises from 1967 to 2167 idiomatic wrappers; the
remaining 32 TODOs need a per-function metadata catalog (sibling-
accessor lookups for length, parallel output arrays sharing a count,
triple-pointer outputs, function-pointer hooks) that mirrors the
output_parameters / result_parameters sets PyMEOS-CFFI carries.
Consumes the shape metadata MEOS-API now ships in meos-idl.json so the
codegen no longer needs to second-guess every signature.  arrayReturn
with kind=accessor calls the named sibling on a wrapper input to
recover the slice length (set_num_values, spanset_num_spans, with an
optional castTo for the Temporal upcast used by tsequence_insts_p and
friends).  outputArrays declares parallel out-parameters and the body
pass unpacks each as a Go slice sharing the primary length, covering
the *_split family, the GSERIALIZED *** triple-pointer outputs of
tgeo_space_split / tgeo_space_time_split, and tpoint_as_mvtgeom.
arrayInputGroup folds the four parallel coordinate arrays of
tpointseq_make_coords into Go slices with nullable handling for the
optional ones.  namedOutputs surfaces tempsubtype_from_string's subtype
and geom_min_bounding_radius's radius as second Go return values.
shape.skip excludes the skiplist function-pointer helpers.  Coverage
goes from 2167 emitted / 32 TODO to 2194 emitted / 0 TODO / 5
explicit-skip; uint32_t is now in the type map and text ** array
returns lower to []string via text2cstring per element.
Aggregation depends on the skiplist API and the other bindings that
consume meos-idl.json all expose its function-pointer and void **
arguments as raw pointers (PyMEOS-CFFI as _ffi.CData, MEOS.NET as
IntPtr).  GoMEOS now does the same: void **, const void **,
datum_func2, error_handler_fn, and the two anonymous function-pointer
typedefs (int (*)(void *, void *) and void *(*)(void *, void *)) map
to unsafe.Pointer; SkipListType joins the enum group.  The classifier
no longer treats a count following void ** as ARRAY_LENGTH, so the
count parameter of skiplist_splice / temporal_skiplist_splice stays a
real Go input instead of being derived from a non-existent slice
length.  The five shape.skip entries the previous commit added are
removed from meta/meos-meta.json; coverage rises to 2199 emitted /
0 TODO / 0 explicit-skip across 2369 candidates.
The metadata extension on MEOS-API #2 added shape.nullable across 38
functions and shape.outputArrays on tpoint_as_mvtgeom / *_hexwkb /
*_time_tiles.  Re-vendoring keeps GoMEOS in sync with the ecosystem
catalog; the generated wrappers in tools/_preview/ are byte-identical
because the GoMEOS codegen does not yet consume shape.nullable
(nullability in Go is expressed via type rather than at the call site).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant