Skip to content

Print every type as its asText and read and write every format - #36

Merged
estebanzimanyi merged 2 commits into
MobilityDB:mainfrom
estebanzimanyi:io/stringer-portable-io
Nov 1, 2026
Merged

estebanzimanyi merged 2 commits into
MobilityDB:mainfrom
estebanzimanyi:io/stringer-portable-io

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

A generated type's String writes the text the catalog's typeEncodings
names for its type, the function behind the SQL asText: AsText for a
spatial value, tspatial_as_text, spatialset_as_text, cbuffer_as_text and
their siblings, which write the points as WKT, and the type's Out for the
others; a type writing what it inherits states no String of its own, and
a MEOS error is written as fmt writes a failure, %!s(MEOS error: ...).

Every type reads and writes each format the catalog gives it under the
portable name: As and From for Text, EWKT, WKB,
HexWKB, EWKB, HexEWKB and MFJSON, each the function readers and writers
name for the type's SQL name, else the one decoders and encoders name
for its C type, the class or an ancestor having no method of that name.
Each forwards to the method or function the catalog function backs, and
a reader answers its own class, so TGeomPointFromEWKB is TemporalFromWKB
answering a *TGeomPoint: 285 methods over 150 classes, 59 of which print
through String. The classes are emitted parents first, so a class reaches
what its ancestors emit, as MEOS.NET's tools/objectgen.py does.

Measured: the root examples, 127 of them under TZ=UTC with
example_types_io_test.go reading a temporal point from its text, EWKT
and hex EWKB and printing it, a circular buffer and a span, pass; the
functions and types packages build with no go vet finding, and the
parity tests pass.

The flat functions and the object layer are those tools/codegen.py and
tools/objectgen.py write from the catalog of MobilityDB 91f8d676e7 and
MEOS-API 9069a08: 4702 wrappers and 150 classes with 1781 methods. Every
temporal and set type MEOS holds by pointer has its class:
TH3Index, TQuadbin and TS2Cell under TCellIndex, TPcpoint, TPcpatch and
TPoseChain under TSpatial, the cell, point cloud and pose chain sets
under SpatialSet, GeomSet and GeogSet under GeoSet, and JsonbSet under
Set; and each format method takes its portable spelling, AsHexWKB,
AsHexEWKB, FromHexWKB, FromHexEWKB, AsGeoJSON and FromGeoJSON.

A method may not share the name of the struct its class embeds, so a
method whose name is its parent's takes the name of its SQL function:
jsonbset_set, which reads set on JsonbSet, whose parent is Set, is
JsonbsetSet, as its SQL function jsonbsetSet.

Measured: the functions and types packages build with no go vet
finding, the parity tests pass, and the 122 examples of the root package
pass under TZ=UTC, as the workflow runs them.
A generated type's String writes the text the catalog's typeEncodings
names for its type, the function behind the SQL asText: AsText for a
spatial value, tspatial_as_text, spatialset_as_text, cbuffer_as_text and
their siblings, which write the points as WKT, and the type's Out for the
others; a type writing what it inherits states no String of its own, and
a MEOS error is written as fmt writes a failure, %!s(MEOS error: ...).

Every type reads and writes each format the catalog gives it under the
portable name: As<Format> and <Class>From<Format> for Text, EWKT, WKB,
HexWKB, EWKB, HexEWKB and MFJSON, each the function readers and writers
name for the type's SQL name, else the one decoders and encoders name
for its C type, the class or an ancestor having no method of that name.
Each forwards to the method or function the catalog function backs, and
a reader answers its own class, so TGeomPointFromEWKB is TemporalFromWKB
answering a *TGeomPoint: 285 methods over 150 classes, 59 of which print
through String. The classes are emitted parents first, so a class reaches
what its ancestors emit, as MEOS.NET's tools/objectgen.py does.

Measured: the root examples, 127 of them under TZ=UTC with
example_types_io_test.go reading a temporal point from its text, EWKT
and hex EWKB and printing it, a circular buffer and a span, pass; the
functions and types packages build with no go vet finding, and the
parity tests pass.
@estebanzimanyi
estebanzimanyi merged commit 75c1da1 into MobilityDB:main Nov 1, 2026
2 checks passed
@estebanzimanyi
estebanzimanyi deleted the io/stringer-portable-io branch November 1, 2026 17:41
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