[Bf-blender-cvs] [98e62d459ac] blender2.8: py_capi_utils: add utilities for format string in `struct` module style syntax.

mano-wii noreply at git.blender.org
Sat Oct 6 05:15:09 CEST 2018


Commit: 98e62d459ac3918bde15d9e286c9bbd1ff34b190
Author: mano-wii
Date:   Sat Oct 6 00:13:40 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB98e62d459ac3918bde15d9e286c9bbd1ff34b190

py_capi_utils: add utilities for format string in `struct` module style syntax.

===================================================================

M	source/blender/python/generic/py_capi_utils.h

===================================================================

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__ */



More information about the Bf-blender-cvs mailing list