PyAPI: move deep-copy args check to py_capi_utils
This commit is contained in:
@@ -230,6 +230,12 @@ int PyC_ParseBool(PyObject *o, void *p)
|
|||||||
return 1;
|
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
|
#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_ParseBool(PyObject *o, void *p);
|
||||||
|
|
||||||
|
int PyC_CheckArgs_DeepCopy(PyObject *args);
|
||||||
|
|
||||||
/* Integer parsing (with overflow checks), -1 on error. */
|
/* Integer parsing (with overflow checks), -1 on error. */
|
||||||
int PyC_Long_AsBool(PyObject *value);
|
int PyC_Long_AsBool(PyObject *value);
|
||||||
|
|||||||
@@ -419,13 +419,6 @@ PyObject *mathutils_dynstr_to_py(struct DynStr *ds)
|
|||||||
}
|
}
|
||||||
#endif
|
#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 */
|
/* Mathutils Callbacks */
|
||||||
|
|
||||||
/* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */
|
/* 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);
|
PyObject *mathutils_dynstr_to_py(struct DynStr *ds);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int mathutils_deepcopy_args_check(PyObject *args);
|
|
||||||
|
|
||||||
#endif /* __MATHUTILS_H__ */
|
#endif /* __MATHUTILS_H__ */
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
#include "../generic/python_utildefines.h"
|
#include "../generic/python_utildefines.h"
|
||||||
|
#include "../generic/py_capi_utils.h"
|
||||||
|
|
||||||
#ifndef MATH_STANDALONE
|
#ifndef MATH_STANDALONE
|
||||||
# include "BLI_dynstr.h"
|
# include "BLI_dynstr.h"
|
||||||
@@ -113,8 +114,9 @@ static PyObject *Color_copy(ColorObject *self)
|
|||||||
}
|
}
|
||||||
static PyObject *Color_deepcopy(ColorObject *self, PyObject *args)
|
static PyObject *Color_deepcopy(ColorObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (!mathutils_deepcopy_args_check(args))
|
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
return Color_copy(self);
|
return Color_copy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
#include "../generic/python_utildefines.h"
|
#include "../generic/python_utildefines.h"
|
||||||
|
#include "../generic/py_capi_utils.h"
|
||||||
|
|
||||||
#ifndef MATH_STANDALONE
|
#ifndef MATH_STANDALONE
|
||||||
# include "BLI_dynstr.h"
|
# include "BLI_dynstr.h"
|
||||||
@@ -312,8 +313,9 @@ static PyObject *Euler_copy(EulerObject *self)
|
|||||||
}
|
}
|
||||||
static PyObject *Euler_deepcopy(EulerObject *self, PyObject *args)
|
static PyObject *Euler_deepcopy(EulerObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (!mathutils_deepcopy_args_check(args))
|
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
return Euler_copy(self);
|
return Euler_copy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
#include "../generic/python_utildefines.h"
|
#include "../generic/python_utildefines.h"
|
||||||
|
#include "../generic/py_capi_utils.h"
|
||||||
|
|
||||||
#ifndef MATH_STANDALONE
|
#ifndef MATH_STANDALONE
|
||||||
# include "BLI_string.h"
|
# include "BLI_string.h"
|
||||||
@@ -1945,8 +1946,9 @@ static PyObject *Matrix_copy(MatrixObject *self)
|
|||||||
}
|
}
|
||||||
static PyObject *Matrix_deepcopy(MatrixObject *self, PyObject *args)
|
static PyObject *Matrix_deepcopy(MatrixObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (!mathutils_deepcopy_args_check(args))
|
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
return Matrix_copy(self);
|
return Matrix_copy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
#include "../generic/python_utildefines.h"
|
#include "../generic/python_utildefines.h"
|
||||||
|
#include "../generic/py_capi_utils.h"
|
||||||
|
|
||||||
#ifndef MATH_STANDALONE
|
#ifndef MATH_STANDALONE
|
||||||
# include "BLI_dynstr.h"
|
# include "BLI_dynstr.h"
|
||||||
@@ -496,8 +497,9 @@ static PyObject *Quaternion_copy(QuaternionObject *self)
|
|||||||
}
|
}
|
||||||
static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args)
|
static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (!mathutils_deepcopy_args_check(args))
|
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
return Quaternion_copy(self);
|
return Quaternion_copy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1393,4 +1395,3 @@ PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user,
|
|||||||
|
|
||||||
return (PyObject *)self;
|
return (PyObject *)self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1331,8 +1331,9 @@ static PyObject *Vector_copy(VectorObject *self)
|
|||||||
}
|
}
|
||||||
static PyObject *Vector_deepcopy(VectorObject *self, PyObject *args)
|
static PyObject *Vector_deepcopy(VectorObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (!mathutils_deepcopy_args_check(args))
|
if (!PyC_CheckArgs_DeepCopy(args)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
return Vector_copy(self);
|
return Vector_copy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user