PyAPI: move deep-copy args check to py_capi_utils
This commit is contained in:
parent
87f598fd3f
commit
a69f985f40
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -419,13 +419,6 @@ PyObject *mathutils_dynstr_to_py(struct DynStr *ds)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* silly function, we dont use arg. just check its compatible with __deepcopy__ */
|
||||
int mathutils_deepcopy_args_check(PyObject *args)
|
||||
{
|
||||
PyObject *dummy_pydict;
|
||||
return PyArg_ParseTuple(args, "|O!:__deepcopy__", &PyDict_Type, &dummy_pydict) != 0;
|
||||
}
|
||||
|
||||
/* Mathutils Callbacks */
|
||||
|
||||
/* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */
|
||||
|
|
|
@ -174,6 +174,4 @@ int column_vector_multiplication(float rvec[4], VectorObject *vec, MatrixObject
|
|||
PyObject *mathutils_dynstr_to_py(struct DynStr *ds);
|
||||
#endif
|
||||
|
||||
int mathutils_deepcopy_args_check(PyObject *args);
|
||||
|
||||
#endif /* __MATHUTILS_H__ */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "../generic/python_utildefines.h"
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
#ifndef MATH_STANDALONE
|
||||
# include "BLI_dynstr.h"
|
||||
|
@ -113,8 +114,9 @@ static PyObject *Color_copy(ColorObject *self)
|
|||
}
|
||||
static PyObject *Color_deepcopy(ColorObject *self, PyObject *args)
|
||||
{
|
||||
if (!mathutils_deepcopy_args_check(args))
|
||||
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||
return NULL;
|
||||
}
|
||||
return Color_copy(self);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "BLI_math.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "../generic/python_utildefines.h"
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
#ifndef MATH_STANDALONE
|
||||
# include "BLI_dynstr.h"
|
||||
|
@ -312,8 +313,9 @@ static PyObject *Euler_copy(EulerObject *self)
|
|||
}
|
||||
static PyObject *Euler_deepcopy(EulerObject *self, PyObject *args)
|
||||
{
|
||||
if (!mathutils_deepcopy_args_check(args))
|
||||
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||
return NULL;
|
||||
}
|
||||
return Euler_copy(self);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "../generic/python_utildefines.h"
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
#ifndef MATH_STANDALONE
|
||||
# include "BLI_string.h"
|
||||
|
@ -1945,8 +1946,9 @@ static PyObject *Matrix_copy(MatrixObject *self)
|
|||
}
|
||||
static PyObject *Matrix_deepcopy(MatrixObject *self, PyObject *args)
|
||||
{
|
||||
if (!mathutils_deepcopy_args_check(args))
|
||||
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||
return NULL;
|
||||
}
|
||||
return Matrix_copy(self);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "../generic/python_utildefines.h"
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
#ifndef MATH_STANDALONE
|
||||
# include "BLI_dynstr.h"
|
||||
|
@ -496,8 +497,9 @@ static PyObject *Quaternion_copy(QuaternionObject *self)
|
|||
}
|
||||
static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args)
|
||||
{
|
||||
if (!mathutils_deepcopy_args_check(args))
|
||||
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||
return NULL;
|
||||
}
|
||||
return Quaternion_copy(self);
|
||||
}
|
||||
|
||||
|
@ -1393,4 +1395,3 @@ PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user,
|
|||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
|
|
|
@ -1331,8 +1331,9 @@ static PyObject *Vector_copy(VectorObject *self)
|
|||
}
|
||||
static PyObject *Vector_deepcopy(VectorObject *self, PyObject *args)
|
||||
{
|
||||
if (!mathutils_deepcopy_args_check(args))
|
||||
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||
return NULL;
|
||||
}
|
||||
return Vector_copy(self);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue