diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-05-20 09:46:20 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-05-20 09:46:20 -0600 |
commit | f8507034753eca08c6f5dcab3e515a72d48e6aa0 (patch) | |
tree | fc665d6eb1a3d479b12545deec37988e0180c18f /libdimension-python/Vector.c | |
parent | 74722ac194ca76ecb54df9153b9f831e79b2bd22 (diff) | |
download | dimension-f8507034753eca08c6f5dcab3e515a72d48e6aa0.tar.xz |
Improve dmnsn_py_Vector_args() API.
Diffstat (limited to 'libdimension-python/Vector.c')
-rw-r--r-- | libdimension-python/Vector.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libdimension-python/Vector.c b/libdimension-python/Vector.c index 8cd7f05..3fdc90c 100644 --- a/libdimension-python/Vector.c +++ b/libdimension-python/Vector.c @@ -24,8 +24,22 @@ bool dmnsn_py_Vector_args(dmnsn_vector *v, PyObject *args, PyObject *kwds) { static char *kwlist[] = { "x", "y", "z", NULL }; - return PyArg_ParseTupleAndKeywords(args, kwds, "ddd", kwlist, - &v->x, &v->y, &v->z); + if (PyArg_ParseTupleAndKeywords(args, kwds, "ddd", kwlist, + &v->x, &v->y, &v->z)) { + return true; + } else { + if (kwds) + return false; + + PyErr_Clear(); + + dmnsn_py_Vector *vec; + if (!PyArg_ParseTuple(args, "O!", &dmnsn_py_VectorType, &vec)) + return false; + + *v = vec->v; + return true; + } } static int |