Use python subtypes so bpy.types.Mesh is a subtype of bpy.types.ID
This means checks like this work. isinstance(bpy.data.meshes[0], bpy.types.ID) bpy.types.Mesh.__base__ == bpy.types.ID
This commit is contained in:
@@ -94,13 +94,14 @@ static int mathutils_rna_vector_set_index(BPy_PropertyRNA *self, int subtype, fl
|
||||
}
|
||||
|
||||
Mathutils_Callback mathutils_rna_array_cb = {
|
||||
mathutils_rna_generic_check,
|
||||
mathutils_rna_vector_get,
|
||||
mathutils_rna_vector_set,
|
||||
mathutils_rna_vector_get_index,
|
||||
mathutils_rna_vector_set_index
|
||||
(BaseMathCheckFunc) mathutils_rna_generic_check,
|
||||
(BaseMathGetFunc) mathutils_rna_vector_get,
|
||||
(BaseMathSetFunc) mathutils_rna_vector_set,
|
||||
(BaseMathGetIndexFunc) mathutils_rna_vector_get_index,
|
||||
(BaseMathSetIndexFunc) mathutils_rna_vector_set_index
|
||||
};
|
||||
|
||||
|
||||
/* bpyrna matrix callbacks */
|
||||
static int mathutils_rna_matrix_cb_index= -1; /* index for our callbacks */
|
||||
|
||||
@@ -123,11 +124,11 @@ static int mathutils_rna_matrix_set(BPy_PropertyRNA *self, int subtype, float *m
|
||||
}
|
||||
|
||||
Mathutils_Callback mathutils_rna_matrix_cb = {
|
||||
mathutils_rna_generic_check,
|
||||
mathutils_rna_matrix_get,
|
||||
mathutils_rna_matrix_set,
|
||||
NULL,
|
||||
NULL
|
||||
(BaseMathCheckFunc) mathutils_rna_generic_check,
|
||||
(BaseMathGetFunc) mathutils_rna_matrix_get,
|
||||
(BaseMathSetFunc) mathutils_rna_matrix_set,
|
||||
(BaseMathGetIndexFunc) NULL,
|
||||
(BaseMathSetIndexFunc) NULL
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -2172,21 +2173,17 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
|
||||
/* done with rna instance */
|
||||
}
|
||||
|
||||
PyObject* pyrna_struct_Subtype(PointerRNA *ptr)
|
||||
PyObject* pyrna_srna_Subtype(StructRNA *srna)
|
||||
{
|
||||
PyObject *newclass = NULL;
|
||||
StructRNA *srna, *base;
|
||||
|
||||
if(ptr->type == &RNA_Struct)
|
||||
srna= ptr->data;
|
||||
else
|
||||
srna= ptr->type;
|
||||
|
||||
if (srna == NULL) {
|
||||
newclass= NULL; /* Nothing to do */
|
||||
} else if ((newclass= RNA_struct_py_type_get(srna))) {
|
||||
Py_INCREF(newclass);
|
||||
} else {
|
||||
StructRNA *base;
|
||||
|
||||
/* for now, return the base RNA type rather then a real module */
|
||||
|
||||
/* Assume RNA_struct_py_type_get(srna) was alredy checked */
|
||||
@@ -2203,22 +2200,21 @@ PyObject* pyrna_struct_Subtype(PointerRNA *ptr)
|
||||
PyObject *py_base= NULL;
|
||||
PyObject *dict = PyDict_New();
|
||||
PyObject *item;
|
||||
|
||||
|
||||
|
||||
// arg 1
|
||||
//PyTuple_SET_ITEM(args, 0, PyUnicode_FromString(tp_name));
|
||||
PyTuple_SET_ITEM(args, 0, PyUnicode_FromString(RNA_struct_identifier(srna)));
|
||||
|
||||
// arg 2
|
||||
#if 0 // XXX - This should be possible but for some reason it does a recursive call for MirrorModifier
|
||||
base= RNA_struct_base(srna);
|
||||
if(base && base != srna) {
|
||||
// printf("debug subtype %s\n", RNA_struct_identifier(srna));
|
||||
py_base= pyrna_struct_Subtype(base);
|
||||
/*/printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna); */
|
||||
py_base= pyrna_srna_Subtype(base);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(py_base==NULL) {
|
||||
py_base= &pyrna_struct_Type;
|
||||
py_base= (PyObject *)&pyrna_struct_Type;
|
||||
Py_INCREF(py_base);
|
||||
}
|
||||
|
||||
@@ -2264,6 +2260,11 @@ PyObject* pyrna_struct_Subtype(PointerRNA *ptr)
|
||||
return newclass;
|
||||
}
|
||||
|
||||
PyObject* pyrna_struct_Subtype(PointerRNA *ptr)
|
||||
{
|
||||
return pyrna_srna_Subtype((ptr->type == &RNA_Struct) ? ptr->data : ptr->type);
|
||||
}
|
||||
|
||||
/*-----------------------CreatePyObject---------------------------------*/
|
||||
PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr )
|
||||
{
|
||||
|
Reference in New Issue
Block a user