[Bf-blender-cvs] [31f2a6755db] master: PyAPI: Add PyC_Tuple_Pack_F64 utility

Campbell Barton noreply at git.blender.org
Mon Apr 2 19:49:45 CEST 2018


Commit: 31f2a6755db5bf9439e51701eddcadfca773459a
Author: Campbell Barton
Date:   Mon Apr 2 19:48:34 2018 +0200
Branches: master
https://developer.blender.org/rB31f2a6755db5bf9439e51701eddcadfca773459a

PyAPI: Add PyC_Tuple_Pack_F64 utility

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

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

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

diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 62ef1b773c7..6f265b2ae87 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -146,6 +146,15 @@ PyObject *PyC_Tuple_PackArray_F32(const float *array, uint len)
 	return tuple;
 }
 
+PyObject *PyC_Tuple_PackArray_F64(const double *array, uint len)
+{
+	PyObject *tuple = PyTuple_New(len);
+	for (uint i = 0; i < len; i++) {
+		PyTuple_SET_ITEM(tuple, i, PyFloat_FromDouble(array[i]));
+	}
+	return tuple;
+}
+
 PyObject *PyC_Tuple_PackArray_I32(const int *array, uint len)
 {
 	PyObject *tuple = PyTuple_New(len);
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index e4d6d3fe557..fe7a046d99c 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -51,12 +51,15 @@ int             PyC_AsArray(
         const PyTypeObject *type, const bool is_double, const char *error_prefix);
 
 PyObject       *PyC_Tuple_PackArray_F32(const float *array, uint len);
+PyObject       *PyC_Tuple_PackArray_F64(const double *array, uint len);
 PyObject       *PyC_Tuple_PackArray_I32(const int *array, uint len);
 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__}), VA_NARGS_COUNT(__VA_ARGS__))
+#define PyC_Tuple_Pack_F64(...) \
+	PyC_Tuple_PackArray_F64(((const double []){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
 #define PyC_Tuple_Pack_I32(...) \
 	PyC_Tuple_PackArray_I32(((const int []){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__))
 #define PyC_Tuple_Pack_I32FromBool(...) \



More information about the Bf-blender-cvs mailing list