diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-08-23 11:44:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-08-23 11:48:32 +0300 |
commit | 55861cb2346bdb4b1346c6999b99ff00f27e7d4b (patch) | |
tree | f64ba931e125a93bed56df486d72b0514edf1683 | |
parent | b8d77c44f112cae1e98308ff33ce055ea4fb46ff (diff) |
PyAPI: avoid instantiating args twice in macro
Would cause problems if args included function calls.
-rw-r--r-- | source/blender/python/generic/py_capi_utils.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index 9f500f4c76b..95d3f1d3775 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -28,6 +28,7 @@ #define __PY_CAPI_UTILS_H__ #include "BLI_sys_types.h" +#include "BLI_utildefines.h" /* only for _VA_NARGS_COUNT */ void PyC_ObSpit(const char *name, PyObject *var); void PyC_LineSpit(void); @@ -52,13 +53,13 @@ PyObject *PyC_Tuple_PackArray_I32FromBool(const int *array, uint len); PyObject *PyC_Tuple_PackArray_Bool(const bool *array, uint len); #define PyC_Tuple_Pack_F32(...) \ - PyC_Tuple_PackArray_F32(((const float []){__VA_ARGS__}), (sizeof((const float []){__VA_ARGS__}) / sizeof(float))) + PyC_Tuple_PackArray_F32(((const float []){__VA_ARGS__}), _VA_NARGS_COUNT(__VA_ARGS__)) #define PyC_Tuple_Pack_I32(...) \ - PyC_Tuple_PackArray_I32(((const int []){__VA_ARGS__}), (sizeof((const int []){__VA_ARGS__}) / sizeof(int))) + PyC_Tuple_PackArray_I32(((const int []){__VA_ARGS__}), _VA_NARGS_COUNT(__VA_ARGS__)) #define PyC_Tuple_Pack_I32FromBool(...) \ - PyC_Tuple_PackArray_I32FromBool(((const int []){__VA_ARGS__}), (sizeof((const int []){__VA_ARGS__}) / sizeof(int))) + PyC_Tuple_PackArray_I32FromBool(((const int []){__VA_ARGS__}), _VA_NARGS_COUNT(__VA_ARGS__)) #define PyC_Tuple_Pack_Bool(...) \ - PyC_Tuple_PackArray_Bool(((const bool []){__VA_ARGS__}), (sizeof((const bool []){__VA_ARGS__}) / sizeof(bool))) + PyC_Tuple_PackArray_Bool(((const bool []){__VA_ARGS__}), _VA_NARGS_COUNT(__VA_ARGS__)) void PyC_Tuple_Fill(PyObject *tuple, PyObject *value); void PyC_List_Fill(PyObject *list, PyObject *value); |