diff options
author | mano-wii <germano.costa@ig.com.br> | 2018-10-06 06:13:40 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2018-10-06 06:13:40 +0300 |
commit | 98e62d459ac3918bde15d9e286c9bbd1ff34b190 (patch) | |
tree | 44efb0a23fa35bbc462786aa18fb50dc6c3b0dfc /source/blender/python/generic | |
parent | bb0b4b008edb59dc5ff0902b0f132cbd72cadf56 (diff) |
py_capi_utils: add utilities for format string in `struct` module style syntax.
Diffstat (limited to 'source/blender/python/generic')
-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__ */ |