Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions builder/build_pymeos_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,16 @@ def build_function_string(function_name: str, return_type: ReturnType, parameter
function_return_type = "bytes"
result_manipulation = f" return bytes(_ffi.buffer(result, {size}[0])) if result != _ffi.NULL else None"
out_params = []
# A string MEOS returns with its length written through a size_t pointer (the
# hexadecimal WKB and EWKB of every type) is the string alone: the length is the
# string's own, as GoMEOS's tools/objectgen.py and MEOS.NET's method_for drop it.
elif (
result_param is None
and return_type.ctype.replace(" ", "") == "char*"
and len(out_params) == 1
and out_params[0].ctype.replace(" ", "") == "size_t*"
):
out_params = []
out_types = [p.get_ptype_without_pointers() for p in out_params]
out_values = [f"{p.name}[0]" for p in out_params]

Expand Down
10 changes: 9 additions & 1 deletion builder/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@
ann = inspect.signature(getattr(f, name)).return_annotation
assert ann in (bytes, "bytes"), f"{name} returns {ann}, not bytes"

# A function returning a string and its length through a size_t output parameter
# returns the string alone: the hexadecimal WKB and EWKB of every type.
for name in ("set_as_hexwkb", "temporal_as_hexwkb", "tspatial_as_hexewkb", "npoint_as_hexwkb", "pose_as_hexewkb"):
ann = inspect.signature(getattr(f, name)).return_annotation
assert "tuple" not in str(ann), f"{name} returns {ann}, not the string alone"

# Live initialisation check: the standard happy-path cycle works, and a WKB
# encoding comes back as bytes.
# encoding comes back as bytes and its hexadecimal form as their string.
meos_initialize("UTC")
wkb = f.set_as_wkb(f.intset_in("{1, 2, 3}"), 4)
assert isinstance(wkb, bytes) and len(wkb) > 0, f"set_as_wkb returned {type(wkb)}"
hexwkb = f.set_as_hexwkb(f.intset_in("{1, 2, 3}"), 4)
assert isinstance(hexwkb, str) and bytes.fromhex(hexwkb) == wkb, f"set_as_hexwkb returned {hexwkb!r}"
meos_finalize()
print(f"PyMEOS CFFI build + shape smoke test OK on {label}")
Loading
Loading