From adff6aeb1c749183921c0facd373972bbeb874b4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 19 Apr 2009 13:37:59 +0000 Subject: 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). --- source/blender/blenkernel/intern/anim_sys.c | 8 ++++---- source/blender/blenkernel/intern/fcurve.c | 8 ++++---- source/blender/blenkernel/intern/screen.c | 21 ++++++--------------- 3 files changed, 14 insertions(+), 23 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 1d819b7de8b..5b10f921d7d 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -377,22 +377,22 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i /* set value - only for animatable numerical values */ if (RNA_property_animateable(&new_ptr, prop)) { - switch (RNA_property_type(&new_ptr, prop)) + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(&new_ptr, prop)) + if (RNA_property_array_length(prop)) RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_boolean_set(&new_ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(&new_ptr, prop)) + if (RNA_property_array_length(prop)) RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_int_set(&new_ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(&new_ptr, prop)) + if (RNA_property_array_length(prop)) RNA_property_float_set_index(&new_ptr, prop, array_index, value); else RNA_property_float_set(&new_ptr, prop, value); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index d7b1bdaeff3..cce4f3a1217 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -679,21 +679,21 @@ static float driver_get_target_value (ChannelDriver *driver, DriverTarget *dtar) /* get property to read from, and get value as appropriate */ if (RNA_path_resolve(&id_ptr, path, &ptr, &prop)) { - switch (RNA_property_type(&ptr, prop)) { + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(&ptr, prop)) + if (RNA_property_array_length(prop)) value= (float)RNA_property_boolean_get_index(&ptr, prop, index); else value= (float)RNA_property_boolean_get(&ptr, prop); break; case PROP_INT: - if (RNA_property_array_length(&ptr, prop)) + if (RNA_property_array_length(prop)) value= (float)RNA_property_int_get_index(&ptr, prop, index); else value= (float)RNA_property_int_get(&ptr, prop); break; case PROP_FLOAT: - if (RNA_property_array_length(&ptr, prop)) + if (RNA_property_array_length(prop)) value= RNA_property_float_get_index(&ptr, prop, index); else value= RNA_property_float_get(&ptr, prop); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 2f3ca52a09e..f43dc287062 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -53,25 +53,16 @@ static ListBase spacetypes= {NULL, NULL}; static void spacetype_free(SpaceType *st) { ARegionType *art; + PanelType *pt; for(art= st->regiontypes.first; art; art= art->next) { BLI_freelistN(&art->drawcalls); -#ifdef DISABLE_PYTHON + + for(pt= art->paneltypes.first; pt; pt= pt->next) + if(pt->py_free) + pt->py_free(pt->py_data); + BLI_freelistN(&art->paneltypes); -#else - { - PanelType *pnl, *pnl_next; - for(pnl= art->paneltypes.first; pnl; pnl= pnl_next) { - pnl_next= pnl->next; - - if(pnl->py_data) - BPY_DECREF(pnl->py_data); - - MEM_freeN(pnl); - } - art->paneltypes.first= art->paneltypes.last= NULL; - } -#endif BLI_freelistN(&art->headertypes); } -- cgit v1.2.3