Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-04-19 17:37:59 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-04-19 17:37:59 +0400
commitadff6aeb1c749183921c0facd373972bbeb874b4 (patch)
tree07987d408713eee8a3dd8bb5cb4ecf3c112de654 /source/blender/python/intern/bpy_operator.c
parentd880257d165888638b7c924fb6ef7071343b783e (diff)
RNA: Generic Type Registration
The Python API to define Panels and Operators is based on subclassing, this makes that system more generic, and based on RNA. Hopefully that will make it easy to make various parts of Blender more extensible. * The system simply uses RNA properties and functions and marks them with REGISTER to make them part of the type registration process. Additionally, the struct must provide a register/unregister callback to create/free the PanelType or similar. * From the python side there were some small changes, mainly that registration now goes trough bpy.types.register instead of bpy.ui.addPanel. * Only Panels have been wrapped this way now. Check rna_ui.c to see how this code works. There's still some rough edges and possibilities to make it cleaner, though it works without any manual python code. * Started some docs here: http://wiki.blender.org/index.php/BlenderDev/Blender2.5/RNATypeRegistration * Also changed some RNA_property and RNA_struct functions to not require a PointerRNA anymore, where they were not required (which is actually the cause of most changed files).
Diffstat (limited to 'source/blender/python/intern/bpy_operator.c')
-rw-r--r--source/blender/python/intern/bpy_operator.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 660e1d01b6c..f8dcb1f43a1 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -27,6 +27,7 @@
#include "bpy_operator_wrap.h"
#include "bpy_rna.h" /* for setting arg props only - pyrna_py_to_prop() */
#include "bpy_compat.h"
+#include "bpy_util.h"
//#include "blendef.h"
#include "BLI_dynstr.h"
@@ -54,7 +55,7 @@ int PYOP_props_from_dict(PointerRNA *ptr, PyObject *kw)
PropertyRNA *prop, *iterprop;
CollectionPropertyIterator iter;
- iterprop= RNA_struct_iterator_property(ptr);
+ iterprop= RNA_struct_iterator_property(ptr->type);
RNA_property_collection_begin(ptr, iterprop, &iter);
totkw = kw ? PyDict_Size(kw):0;
@@ -62,7 +63,7 @@ int PYOP_props_from_dict(PointerRNA *ptr, PyObject *kw)
for(; iter.valid; RNA_property_collection_next(&iter)) {
prop= iter.ptr.data;
- arg_name= RNA_property_identifier(&iter.ptr, prop);
+ arg_name= RNA_property_identifier(prop);
if (strcmp(arg_name, "rna_type")==0) continue;
@@ -128,7 +129,6 @@ static PyObject *pyop_base_call( PyObject * self, PyObject * args, PyObject * k
bContext *C = (bContext *)PyCObject_AsVoidPtr(PyDict_GetItemString(PyEval_GetGlobals(), "__bpy_context__"));
char *opname = _PyUnicode_AsString(self);
- char *report_str= NULL;
if (PyTuple_Size(args)) {
PyErr_SetString( PyExc_AttributeError, "All operator args must be keywords");
@@ -157,16 +157,10 @@ static PyObject *pyop_base_call( PyObject * self, PyObject * args, PyObject * k
WM_operator_call_py(C, ot, &ptr, &reports);
- report_str= BKE_reports_string(&reports, RPT_ERROR);
-
- if (report_str) {
- PyErr_SetString(PyExc_SystemError, report_str);
- MEM_freeN(report_str);
+ if(BPy_reports_to_error(&reports))
error_val = -1;
- }
- if (reports.list.first)
- BKE_reports_clear(&reports);
+ BKE_reports_clear(&reports);
}
WM_operator_properties_free(&ptr);