diff options
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index da127e213b7..8ceb4a76a53 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -131,4 +131,11 @@ Py_LOCAL_INLINE(int32_t) PyC_Long_AsI32(PyObject *value) { return (int32_t)_PyL Py_LOCAL_INLINE(int64_t) PyC_Long_AsI64(PyObject *value) { return (int64_t)PyLong_AsLongLong(value); } Py_LOCAL_INLINE(uint64_t) PyC_Long_AsU64(PyObject *value) { return (uint64_t)PyLong_AsUnsignedLongLong(value); } +/* utils for format string in `struct` module style syntax */ +#define FORMAT_STR_GET(typestr) ELEM(typestr[0], '!', '<', '=', '>', '@') ? typestr[1] : typestr[0] +#define FORMAT_STR_IS_FLOAT(format) ELEM(format, 'f', 'd', 'e') +#define FORMAT_STR_IS_INT(format) ELEM(format, 'i', 'I', 'l', 'L', 'h', 'H', 'b', 'B', 'q', 'Q', 'n', 'N', 'P') +#define FORMAT_STR_IS_BYTE(format) ELEM(format, 'c', 's', 'p') +#define FORMAT_STR_IS_BOOL(format) ELEM(format, '?') + #endif /* __PY_CAPI_UTILS_H__ */ |