- py/rna's path_resolve function was ignoring the index eg: obj.path_resolve("location[1]")
- corrected comment from previous commit
This commit is contained in:
@@ -400,7 +400,7 @@ int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, in
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject *pyrna_array_item(PointerRNA *ptr, PropertyRNA *prop, int index)
|
||||
PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index)
|
||||
{
|
||||
PyObject *item;
|
||||
|
||||
@@ -441,7 +441,7 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop
|
||||
if (dim + 1 < totdim)
|
||||
item= pyrna_py_from_array_internal(ptr, prop, dim + 1, index);
|
||||
else {
|
||||
item= pyrna_array_item(ptr, prop, *index);
|
||||
item= pyrna_array_index(ptr, prop, *index);
|
||||
*index= *index + 1;
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
|
||||
}
|
||||
else {
|
||||
index = arrayoffset + index;
|
||||
ret= (BPy_PropertyArrayRNA *)pyrna_array_item(ptr, prop, index);
|
||||
ret= (BPy_PropertyArrayRNA *)pyrna_array_index(ptr, prop, index);
|
||||
}
|
||||
|
||||
return (PyObject*)ret;
|
||||
|
||||
@@ -2262,17 +2262,29 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
|
||||
PyObject *coerce= Py_True;
|
||||
PointerRNA r_ptr;
|
||||
PropertyRNA *r_prop;
|
||||
int index= -1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|O!:path_resolve", &path, &PyBool_Type, &coerce))
|
||||
return NULL;
|
||||
|
||||
if (RNA_path_resolve(&self->ptr, path, &r_ptr, &r_prop)) {
|
||||
if (RNA_path_resolve_full(&self->ptr, path, &r_ptr, &r_prop, &index)) {
|
||||
if(r_prop) {
|
||||
if(coerce == Py_False) {
|
||||
return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
|
||||
if(index != -1) {
|
||||
if(index >= RNA_property_array_length(&r_ptr, r_prop) || index < 0) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s.path_resolve(\"%.200s\") index out of range", RNA_struct_identifier(self->ptr.type), path);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
return pyrna_array_index(&r_ptr, r_prop, index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return pyrna_prop_to_py(&r_ptr, r_prop);
|
||||
if(coerce == Py_False) {
|
||||
return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
|
||||
}
|
||||
else {
|
||||
return pyrna_prop_to_py(&r_ptr, r_prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -101,6 +101,7 @@ void pyrna_free_types(void);
|
||||
/* primitive type conversion */
|
||||
int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, char *param_data, PyObject *py, const char *error_prefix);
|
||||
int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix);
|
||||
PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index);
|
||||
|
||||
PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop);
|
||||
PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int index);
|
||||
|
||||
Reference in New Issue
Block a user