static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix) { StructRNA *srna; srna= srna_from_self(value, ""); if(!srna) { if(PyErr_Occurred()) { PyObject *msg= PyC_ExceptionBuffer(); char *msg_char= _PyUnicode_AsString(msg); PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup, failed with: %s", error_prefix, msg_char); Py_DECREF(msg); } else { PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup, failed with type '%s'", error_prefix, Py_TYPE(value)->tp_name); } return NULL; } if(!RNA_struct_is_a(srna, &RNA_PropertyGroup)) { PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup", error_prefix); return NULL; } return srna; }
static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw) { StructRNA *srna; if(PyTuple_GET_SIZE(args) == 1) { PyObject *ret; self= PyTuple_GET_ITEM(args, 0); args= PyTuple_New(0); ret= BPy_RemoveProperty(self, args, kw); Py_DECREF(args); return ret; } else if (PyTuple_GET_SIZE(args) > 1) { PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ return NULL; } srna= srna_from_self(self, "RemoveProperty(...):"); if(srna==NULL && PyErr_Occurred()) { return NULL; /* self's type was compatible but error getting the srna */ } else if(srna==NULL) { PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type"); return NULL; } else { static const char *kwlist[]= {"attr", NULL}; char *id=NULL; if (!PyArg_ParseTupleAndKeywords(args, kw, "s:RemoveProperty", (char **)kwlist, &id)) { return NULL; } if(RNA_def_property_free_identifier(srna, id) != 1) { PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id); return NULL; } } Py_RETURN_NONE; }
PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; PyObject *macro; PointerRNA ptr_otmacro; StructRNA *srna; char *opname; const char *macroname; if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", ¯o, &opname)) return NULL; if (WM_operatortype_find(opname, TRUE) == NULL) { PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid operator id", opname); return NULL; } /* identifiers */ srna = srna_from_self(macro, "Macro Define:"); macroname = RNA_struct_identifier(srna); ot = WM_operatortype_find(macroname, TRUE); if (!ot) { PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid macro or hasn't been registered yet", macroname); return NULL; } otmacro = WM_operatortype_macro_define(ot, opname); RNA_pointer_create(NULL, &RNA_OperatorMacro, otmacro, &ptr_otmacro); return pyrna_struct_CreatePyObject(&ptr_otmacro); }