Skip to content

Generate function shape (output arrays + nullability) from the headers#16

Open
estebanzimanyi wants to merge 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/generate-shape-from-headers
Open

Generate function shape (output arrays + nullability) from the headers#16
estebanzimanyi wants to merge 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/generate-shape-from-headers

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Problem

The binding codegens (PyMEOS-CFFI, GoMEOS, JMEOS, …) read each function's shape from the IDL to decide which parameters are written-back output arrays and which accept NULL. That shape used to come from a hand-maintained meta/meos-meta.json, which has drifted to a 3-function stub that emits no shape for the other 2900+ functions. Downstream, this silently mis-handles:

  • the *_value_split / *_space_split / tpoint_as_mvtgeom / nsegmentarr_normalize families — their out-arrays get generated as input parameters
  • nullable srs / maxt / aggregate state — generated as non-nullable, so a None raises instead of converting to NULL

Fix — generate the shape from the headers (no hand table)

  • parser/shapeinfer.py — infer arrayReturn.lengthFrom + outputArrays from the parameter forms. The discriminator is the count parameter: a non-const TYPE ** paired with a by-pointer int *count is a written-back out-array; a by-value int count marks a read-only in-array (e.g. the *_make constructors).
  • parser/nullable.py — read parameter nullability from the C Doxygen @param … may be NULL source of truth (see MobilityDB#1121, which completes those annotations) and fold it into shape.nullable for the params present on each function.
  • run.py — wire both into the IDL build.

Independent of #15 (type recovery); both extend the same IDL-correctness pipeline and can land in either order. Adds unit tests for both modules (full suite green: 30 passed).

The binding codegens consume each function's `shape` (array-return length,
written-back output arrays, parameter nullability) from the IDL. Generate it
from the headers instead of the hand-maintained meta stub, which had drifted
to three functions and emitted no shape for the other 2900+ -- leaving every
codegen to mis-handle the split/space-split/mvtgeom out-arrays and the
nullable srs/maxt/state parameters.

- parser/shapeinfer.py: infer arrayReturn/outputArrays from the parameter
  forms. A non-const `TYPE **` paired with a by-pointer `int *count` is a
  written-back out-array; a by-value `int count` marks a read-only in-array.
- parser/nullable.py: read parameter nullability from the C Doxygen
  `@param ... may be NULL` source of truth and fold it into shape.nullable
  for the params present on each function.
- run.py: wire both into the IDL build.

Adds unit tests for both modules.
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