| 1 |
#define NULLABLE(x) do { \ |
| 2 |
if (x == Py_None) { \ |
| 3 |
x = NULL; \ |
| 4 |
} \ |
| 5 |
} while (0); |
| 6 |
|
| 7 |
#define RETURN_INT(value) do { \ |
| 8 |
int _ret = (value); \ |
| 9 |
if (_ret == -1) { \ |
| 10 |
assert(PyErr_Occurred()); \ |
| 11 |
return NULL; \ |
| 12 |
} \ |
| 13 |
assert(!PyErr_Occurred()); \ |
| 14 |
return PyLong_FromLong(_ret); \ |
| 15 |
} while (0) |
| 16 |
|
| 17 |
#define RETURN_SIZE(value) do { \ |
| 18 |
Py_ssize_t _ret = (value); \ |
| 19 |
if (_ret == -1) { \ |
| 20 |
assert(PyErr_Occurred()); \ |
| 21 |
return NULL; \ |
| 22 |
} \ |
| 23 |
assert(!PyErr_Occurred()); \ |
| 24 |
return PyLong_FromSsize_t(_ret); \ |
| 25 |
} while (0) |
| 26 |
|
| 27 |
/* Marker to check that pointer value was set. */ |
| 28 |
static const char uninitialized[] = "uninitialized"; |
| 29 |
#define UNINITIALIZED_PTR ((void *)uninitialized) |
| 30 |
/* Marker to check that Py_ssize_t value was set. */ |
| 31 |
#define UNINITIALIZED_SIZE ((Py_ssize_t)236892191) |
| 32 |
/* Marker to check that integer value was set. */ |
| 33 |
#define UNINITIALIZED_INT (63256717) |
| 34 |
/* |
| 35 |
* Marker to indicate that a NULL parameter would not be allowed |
| 36 |
* at runtime but that the test interface will check that it is |
| 37 |
* indeed the case. |
| 38 |
* |
| 39 |
* Use this macro only if passing NULL to the C API would raise |
| 40 |
* a catchable exception (and not a fatal exception that would |
| 41 |
* crash the interpreter). |
| 42 |
*/ |
| 43 |
#define NULL_WOULD_RAISE(NAME) NAME |