diff --git a/parser/altsqlfn.py b/parser/altsqlfn.py index 6798f25..f1e3e5e 100644 --- a/parser/altsqlfn.py +++ b/parser/altsqlfn.py @@ -52,9 +52,10 @@ from parser.sqlfn import _CSQLFN_END, _meos_to_mdb, _wrapper_sql_sigs from parser.typescope import SQL_ALIASES, TypeFacts -# A doxygen block closing right before the wrapper's `Datum Name(PG_FUNCTION_ARGS)`. -_WRAPPER_BLOCK = re.compile(r"/\*\*((?:(?!\*/).)*)\*/\s*Datum\s+(\w+)\s*\(\s*PG_FUNCTION_ARGS", - re.S) +# A doxygen block closing right before the wrapper's `Datum Name(PG_FUNCTION_ARGS)`, which the +# wrapper may declare `inline` or `static`, as #_DATUM of parser/sqlfn.py reads it. +_WRAPPER_BLOCK = re.compile(r"/\*\*((?:(?!\*/).)*)\*/\s*(?:(?:static|inline)\s+)*Datum\s+(\w+)" + r"\s*\(\s*PG_FUNCTION_ARGS", re.S) _NAME = re.compile(r"(\w+)\s*\(\)") # The MEOS spelling of a type PostgreSQL spells otherwise (`integer` is `int4`). _MEOS_SPELLING = {sql: meos for meos, sql in SQL_ALIASES.items()} diff --git a/tests/test_altsqlfn.py b/tests/test_altsqlfn.py index 43f53fe..b1be275 100644 --- a/tests/test_altsqlfn.py +++ b/tests/test_altsqlfn.py @@ -300,6 +300,36 @@ def test_unpaired_and_conflicting_names_are_errors(self): self.assertIn("Span_union_finalfn", errors[0]) self.assertIn("Tfloat_tmin_transfn", errors[1]) + def test_a_wrapper_declared_inline_states_its_names(self): + # The wrappers of #WRAPPERS, declared `inline` and `static inline` as MobilityDB + # declares many of its wrappers + text = """ +/** + * @sqlfn wAvgTransition() + * @sqlaggfn wAvg() + * @altsqlfn wAvgAgg() + */ +inline Datum +Tnumber_wavg_transfn(PG_FUNCTION_ARGS) +{ +} + +/** + * @sqlfn abs() + * @altsqlfn intAbs(), floatAbs() + */ +static inline Datum +Tnumber_abs(PG_FUNCTION_ARGS) +{ +} +""" + with tempfile.TemporaryDirectory() as tmp: + (Path(tmp) / "w.c").write_text(text) + names, errors = aggregate_alt_names(tmp) + wrappers = wrapper_names(tmp) + self.assertEqual((names, errors), ({"wAvg": "wAvgAgg"}, [])) + self.assertEqual(wrappers, {"Tnumber_abs": (["abs"], ["intAbs", "floatAbs"])}) + class AltSqlNameContractTests(unittest.TestCase): """Over the generated catalog."""