diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-20 07:37:55 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-20 07:37:55 +0400 |
commit | 3d8ee287509f3a0dac535914a7193397217b006c (patch) | |
tree | 2a2fc72b6151fd21bef9c29248ee2b59da443044 /source/blender/python/mathutils/mathutils.c | |
parent | 32b23b9f746b9bec4023da1d2ef6085fbbde9ae7 (diff) |
__str__ functions for other mathutils types
Diffstat (limited to 'source/blender/python/mathutils/mathutils.c')
-rw-r--r-- | source/blender/python/mathutils/mathutils.c | 13 |
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 */ |