|
@@ -37,7 +37,7 @@ __setitem__, int i, FLOATTYPE v) {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase4),
|
|
INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase4),
|
|
|
python_repr, ostream &out, const string &class_name) {
|
|
python_repr, ostream &out, const string &class_name) {
|
|
|
- out << class_name << "("
|
|
|
|
|
|
|
+ out << class_name << "("
|
|
|
<< MAYBE_ZERO(this->_v.v._0) << ", "
|
|
<< MAYBE_ZERO(this->_v.v._0) << ", "
|
|
|
<< MAYBE_ZERO(this->_v.v._1) << ", "
|
|
<< MAYBE_ZERO(this->_v.v._1) << ", "
|
|
|
<< MAYBE_ZERO(this->_v.v._2) << ", "
|
|
<< MAYBE_ZERO(this->_v.v._2) << ", "
|
|
@@ -61,7 +61,7 @@ __reduce__, PyObject *self) {
|
|
|
return NULL;
|
|
return NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- PyObject *result = Py_BuildValue("(O(ffff))", this_class,
|
|
|
|
|
|
|
+ PyObject *result = Py_BuildValue("(O(ffff))", this_class,
|
|
|
(*this)[0], (*this)[1], (*this)[2], (*this)[3]);
|
|
(*this)[0], (*this)[1], (*this)[2], (*this)[3]);
|
|
|
Py_DECREF(this_class);
|
|
Py_DECREF(this_class);
|
|
|
return result;
|
|
return result;
|
|
@@ -74,14 +74,12 @@ __reduce__, PyObject *self) {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase4),
|
|
PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase4),
|
|
|
__getattr__, const string &attr_name) {
|
|
__getattr__, const string &attr_name) {
|
|
|
-#ifndef NDEBUG
|
|
|
|
|
// Validate the attribute name.
|
|
// Validate the attribute name.
|
|
|
for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
|
|
for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
|
|
|
if (*it < 'w' || *it > 'z') {
|
|
if (*it < 'w' || *it > 'z') {
|
|
|
return NULL;
|
|
return NULL;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
|
|
|
|
if (attr_name.size() == 1) {
|
|
if (attr_name.size() == 1) {
|
|
|
if (attr_name[0] == 'w') {
|
|
if (attr_name[0] == 'w') {
|
|
@@ -137,14 +135,14 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
|
|
|
// Whoosh.
|
|
// Whoosh.
|
|
|
PyObject* fast = PySequence_Fast(assign, "");
|
|
PyObject* fast = PySequence_Fast(assign, "");
|
|
|
nassertr(fast != NULL, -1);
|
|
nassertr(fast != NULL, -1);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Let's be strict about size mismatches, to prevent user error.
|
|
// Let's be strict about size mismatches, to prevent user error.
|
|
|
if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
|
|
if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
|
|
|
PyErr_SetString(PyExc_ValueError, "length mismatch");
|
|
PyErr_SetString(PyExc_ValueError, "length mismatch");
|
|
|
Py_DECREF(fast);
|
|
Py_DECREF(fast);
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Get a pointer to the items, iterate over it and
|
|
// Get a pointer to the items, iterate over it and
|
|
|
// perform our magic assignment. Fast fast. Oh yeah.
|
|
// perform our magic assignment. Fast fast. Oh yeah.
|
|
|
PyObject** items = PySequence_Fast_ITEMS(fast);
|
|
PyObject** items = PySequence_Fast_ITEMS(fast);
|
|
@@ -186,7 +184,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
|
|
|
// and assign the floating-point value to every one of them.
|
|
// and assign the floating-point value to every one of them.
|
|
|
for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
|
|
for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
|
|
|
this->_v.data[((*it) == 'w') ? 3 : (*it) - 'x'] = value;
|
|
this->_v.data[((*it) == 'w') ? 3 : (*it) - 'x'] = value;
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|