#pragma once #include // The 40250 Python API represents native handles as integers. Keep that API while allowing a // 64-bit pointer to survive the round trip on macOS and mobile builds. template PyObject* Py_BuildPointer(T* pointer) { return PyLong_FromVoidPtr(static_cast(pointer)); } template bool PyTuple_GetPointer(PyObject* args, int position, T** out) { if (position < 0 || position >= PyTuple_Size(args)) return false; PyObject* value = PyTuple_GetItem(args, position); if (!value) return false; void* pointer = PyLong_AsVoidPtr(value); if (PyErr_Occurred()) return false; *out = static_cast(pointer); return true; }