diff --git a/parser/header_types.py b/parser/header_types.py index 543f7e1..a0c5911 100644 --- a/parser/header_types.py +++ b/parser/header_types.py @@ -36,10 +36,10 @@ "uint64", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "TimestampTz", "TimeADT", "DateADT", "Timestamp", "Datum", "meosType", "interpType", - # H3Index / Quadbin are uint64 cell ids: typerecover resolves them to - # uint64_t, so treat them as scalars here and leave that recovery intact - # rather than restoring the opaque spelling from the header source. - "H3Index", "Quadbin", + # H3Index / Quadbin / S2CellId are uint64 cell ids: typerecover resolves + # them to uint64_t, so treat them as scalars here and leave that recovery + # intact rather than restoring the opaque spelling from the header source. + "H3Index", "Quadbin", "S2CellId", } diff --git a/parser/typerecover.py b/parser/typerecover.py index c22dab8..b374693 100644 --- a/parser/typerecover.py +++ b/parser/typerecover.py @@ -44,6 +44,7 @@ "TimestampTz": "TimestampTz", "H3Index": "uint64_t", "Quadbin": "uint64_t", + "S2CellId": "uint64_t", "text": "text", "GSERIALIZED": "GSERIALIZED", "Interval": "Interval", diff --git a/tests/test_typerecover.py b/tests/test_typerecover.py index 6c2c3e9..77c75c9 100644 --- a/tests/test_typerecover.py +++ b/tests/test_typerecover.py @@ -168,15 +168,23 @@ def test_uint32_canonical_normalized(self): def test_cell_id_canonical_normalized_uniform(self): # H3Index (libh3's typedef, whose fully-resolved canonical is the platform - # "unsigned long") and Quadbin (MobilityDB's typedef, recovered to "uint64_t") - # are BOTH uint64 cell ids; as Tcell subtypes they must be spelled identically. - # The ``canonical`` field must normalize to "uint64_t" for both, not leave H3Index - # at "unsigned long" — a guard on the _CANON_ALIAS canonical-normalization pass. + # "unsigned long"), Quadbin and S2CellId (MobilityDB's typedefs, recovered to + # "uint64_t") are ALL uint64 cell ids; as Tcell subtypes they must be spelled + # identically. The ``canonical`` field must normalize to "uint64_t" for each, not + # leave one at "unsigned long" — a guard on the _CANON_ALIAS canonical-normalization + # pass. for name in ("th3index_start_value", "th3index_end_value", - "tquadbin_start_value", "tquadbin_end_value", "h3index_in"): + "tquadbin_start_value", "tquadbin_end_value", "h3index_in", + "ts2cell_start_value", "ts2cell_end_value", "s2cell_in"): rt = self.by_name[name]["returnType"] self.assertEqual(rt["c"], "uint64_t", f"{name} c") self.assertEqual(rt["canonical"], "uint64_t", f"{name} canonical") + # An array of cell ids is an array of by-value uint64_t, whichever cell + # typedef the header spells it with. + for name in ("th3index_values", "tquadbin_values", "ts2cell_values"): + rt = self.by_name[name]["returnType"] + self.assertEqual(rt["c"], "uint64_t *", f"{name} c") + self.assertEqual(rt["canonical"], "uint64_t *", f"{name} canonical") def test_typedef_canonical_not_platform_resolved(self): # ``canonical`` is the MEOS typedef its ``cType`` names, never libclang's