Skip to content
Snippets Groups Projects
Commit c285b16f authored by Campbell Barton's avatar Campbell Barton
Browse files

svn merge ^/trunk/blender -c56867

parent 9711a003
No related merge requests found
...@@ -263,41 +263,34 @@ int Nature_Init(PyObject *module) ...@@ -263,41 +263,34 @@ int Nature_Init(PyObject *module)
static PyObject *BPy_Nature_bitwise(PyObject *a, int op, PyObject *b) static PyObject *BPy_Nature_bitwise(PyObject *a, int op, PyObject *b)
{ {
BPy_Nature *result; BPy_Nature *result;
long op1, op2;
if (!BPy_Nature_Check(a) || !BPy_Nature_Check(b)) { if (!BPy_Nature_Check(a) || !BPy_Nature_Check(b)) {
PyErr_SetString(PyExc_TypeError, "operands must be a Nature object"); PyErr_SetString(PyExc_TypeError, "operands must be a Nature object");
return NULL; return NULL;
} }
if (Py_SIZE(a) != 1) { op1 = PyLong_AsLong(a);
stringstream msg; if (PyErr_Occurred()) {
msg << "operand 1: unexpected Nature byte length: " << Py_SIZE(a); PyErr_SetString(PyExc_ValueError, "operand 1: unexpected Nature value");
PyErr_SetString(PyExc_TypeError, msg.str().c_str());
return NULL; return NULL;
} }
if (Py_SIZE(b) != 1) { op2 = PyLong_AsLong(b);
stringstream msg; if (PyErr_Occurred()) {
msg << "operand 2: unexpected Nature byte length: " << Py_SIZE(b); PyErr_SetString(PyExc_ValueError, "operand 2: unexpected Nature value");
PyErr_SetString(PyExc_TypeError, msg.str().c_str());
return NULL; return NULL;
} }
result = PyObject_NewVar(BPy_Nature, &Nature_Type, 1); result = PyObject_NewVar(BPy_Nature, &Nature_Type, 1);
if (!result) if (!result)
return NULL; return NULL;
if (Py_SIZE(result) != 1) {
stringstream msg;
msg << "unexpected Nature byte length: " << Py_SIZE(result);
PyErr_SetString(PyExc_TypeError, msg.str().c_str());
return NULL;
}
switch (op) { switch (op) {
case '&': case '&':
result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) & (((PyLongObject *)b)->ob_digit)[0]; result->i.ob_digit[0] = op1 & op2;
break; break;
case '^': case '^':
result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) ^ (((PyLongObject *)b)->ob_digit)[0]; result->i.ob_digit[0] = op1 ^ op2;
break; break;
case '|': case '|':
result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) | (((PyLongObject *)b)->ob_digit)[0]; result->i.ob_digit[0] = op1 | op2;
break; break;
} }
return (PyObject *)result; return (PyObject *)result;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment