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:
authorCampbell Barton <ideasman42@gmail.com>2018-06-26 10:34:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-26 10:34:13 +0300
commitea339dc62c37b891b8b0c0a8e56f7848b3de5fe9 (patch)
treeb4465742e8e0aad531ab387eb5da950fc51d2c91 /source/blender/python/generic
parente6825946d057f077f5473366b4fa4d383484a81c (diff)
parentdf237b964b9c24c9ab315f6f31bf67990f1c2f7e (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/python/generic')
-rw-r--r--source/blender/python/generic/imbuf_py_api.c26
-rw-r--r--source/blender/python/generic/py_capi_utils.c6
-rw-r--r--source/blender/python/generic/py_capi_utils.h1
3 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c
index 2e32829bf6c..dfe4007e404 100644
--- a/source/blender/python/generic/imbuf_py_api.c
+++ b/source/blender/python/generic/imbuf_py_api.c
@@ -45,6 +45,8 @@
#include <errno.h>
#include "BLI_fileops.h"
+static PyObject *Py_ImBuf_CreatePyObject(ImBuf *ibuf);
+
/* -------------------------------------------------------------------- */
/** \name Type & Utilities
* \{ */
@@ -109,6 +111,27 @@ static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
Py_RETURN_NONE;
}
+PyDoc_STRVAR(py_imbuf_copy_doc,
+".. method:: copy()\n"
+"\n"
+" :return: A copy of the image.\n"
+" :rtype: :class:`ImBuf`\n"
+);
+static PyObject *py_imbuf_copy(Py_ImBuf *self)
+{
+ PY_IMBUF_CHECK_OBJ(self);
+ return Py_ImBuf_CreatePyObject(self->ibuf);
+}
+
+static PyObject *py_imbuf_deepcopy(Py_ImBuf *self, PyObject *args)
+{
+ if (!PyC_CheckArgs_DeepCopy(args)) {
+ return NULL;
+ }
+ return py_imbuf_copy(self);
+}
+
+
PyDoc_STRVAR(py_imbuf_free_doc,
".. method:: free()\n"
"\n"
@@ -126,6 +149,9 @@ static PyObject *py_imbuf_free(Py_ImBuf *self)
static struct PyMethodDef Py_ImBuf_methods[] = {
{"resize", (PyCFunction)py_imbuf_resize, METH_VARARGS | METH_KEYWORDS, (char *)py_imbuf_resize_doc},
{"free", (PyCFunction)py_imbuf_free, METH_NOARGS, (char *)py_imbuf_free_doc},
+ {"copy", (PyCFunction)py_imbuf_copy, METH_NOARGS, (char *)py_imbuf_copy_doc},
+ {"__copy__", (PyCFunction)py_imbuf_copy, METH_NOARGS, (char *)py_imbuf_copy_doc},
+ {"__deepcopy__", (PyCFunction)py_imbuf_deepcopy, METH_VARARGS, (char *)py_imbuf_copy_doc},
{NULL, NULL, 0, NULL}
};
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 22646462163..cee9ad3b477 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -230,6 +230,12 @@ int PyC_ParseBool(PyObject *o, void *p)
return 1;
}
+/* silly function, we dont use arg. just check its compatible with __deepcopy__ */
+int PyC_CheckArgs_DeepCopy(PyObject *args)
+{
+ PyObject *dummy_pydict;
+ return PyArg_ParseTuple(args, "|O!:__deepcopy__", &PyDict_Type, &dummy_pydict) != 0;
+}
#ifndef MATH_STANDALONE
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index 9f3c10bfd67..fef9171b4d4 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -106,6 +106,7 @@ bool PyC_RunString_AsString(const char *expr, const char *filename, char **r_val
int PyC_ParseBool(PyObject *o, void *p);
+int PyC_CheckArgs_DeepCopy(PyObject *args);
/* Integer parsing (with overflow checks), -1 on error. */
int PyC_Long_AsBool(PyObject *value);