Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/python/mathutils/mathutils.c')
-rw-r--r--source/blender/python/mathutils/mathutils.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 5587028d812..a656b0ab3e5 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -35,6 +35,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_dynstr.h"
PyDoc_STRVAR(M_Mathutils_doc,
"This module provides access to matrices, eulers, quaternions and vectors."
@@ -267,6 +268,18 @@ int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps)
return 1;
}
+/* dynstr as python string utility funcions, frees 'ds'! */
+PyObject *mathutils_dynstr_to_py(struct DynStr *ds)
+{
+ const int ds_len = BLI_dynstr_get_len(ds); /* space for \0 */
+ char *ds_buf = PyMem_Malloc(ds_len + 1);
+ PyObject *ret;
+ BLI_dynstr_get_cstring_ex(ds, ds_buf);
+ BLI_dynstr_free(ds);
+ ret = PyUnicode_FromStringAndSize(ds_buf, ds_len);
+ PyMem_Free(ds_buf);
+ return ret;
+}
/* Mathutils Callbacks */