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).
This commit is contained in:
2009-04-19 13:37:59 +00:00
parent d880257d16
commit adff6aeb1c
39 changed files with 1220 additions and 756 deletions

View File

@@ -22,10 +22,12 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include "DNA_listBase.h"
#include "RNA_access.h"
#include "bpy_util.h"
#include "BLI_dynstr.h"
#include "MEM_guardedalloc.h"
#include "BKE_report.h"
PyObject *BPY_flag_to_list(struct BPY_flag_def *flagdef, int flag)
{
@@ -241,7 +243,6 @@ PyObject *PyObject_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...)
return item;
}
int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_class, BPY_class_attr_check* class_attrs, PyObject **py_class_attrs)
{
PyObject *item, *fitem;
@@ -333,3 +334,18 @@ char *BPy_enum_as_string(EnumPropertyItem *item)
BLI_dynstr_free(dynstr);
return cstring;
}
int BPy_reports_to_error(ReportList *reports)
{
char *report_str;
report_str= BKE_reports_string(reports, RPT_ERROR);
if(report_str) {
PyErr_SetString(PyExc_SystemError, report_str);
MEM_freeN(report_str);
}
return (report_str != NULL);
}