diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-05-18 14:56:26 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-05-18 14:56:26 +0400 |
commit | 178ba76b09fc923213a26257bbd5b82d0ad26bf0 (patch) | |
tree | 61b594404c29b920eeb25499180c2079f68d436a /source/blender/makesrna | |
parent | 304ce06a5a026041fb0d0410c6a4600e995e1534 (diff) |
RNA: pass Main rather than Context to register/unregister callbacks.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_animation.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_render.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 36 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 25 |
7 files changed, 41 insertions, 47 deletions
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 3a15146770f..86d1e12a198 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -43,6 +43,7 @@ struct StructRNA; struct BlenderRNA; struct IDProperty; struct bContext; +struct Main; struct ReportList; /** Pointer @@ -329,9 +330,9 @@ typedef enum StructFlag { typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function); typedef int (*StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list); typedef void (*StructFreeFunc)(void *data); -typedef struct StructRNA *(*StructRegisterFunc)(struct bContext *C, struct ReportList *reports, void *data, +typedef struct StructRNA *(*StructRegisterFunc)(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); -typedef void (*StructUnregisterFunc)(const struct bContext *C, struct StructRNA *type); +typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type); typedef struct StructRNA StructRNA; diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index bde7c99c7df..90edbaaadf0 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -210,12 +210,12 @@ IDProperty *rna_PropertyGroup_idprops(PointerRNA *ptr, int create) return ptr->data; } -void rna_PropertyGroup_unregister(const bContext *C, StructRNA *type) +void rna_PropertyGroup_unregister(Main *bmain, StructRNA *type) { RNA_struct_free(&BLENDER_RNA, type); } -StructRNA *rna_PropertyGroup_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +StructRNA *rna_PropertyGroup_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { PointerRNA dummyptr; diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 106c51865fd..d60dc34fea2 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -188,7 +188,7 @@ static StructRNA *rna_KeyingSetInfo_refine(PointerRNA *ptr) return (ksi->ext.srna)? ksi->ext.srna: &RNA_KeyingSetInfo; } -static void rna_KeyingSetInfo_unregister(const bContext *C, StructRNA *type) +static void rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type) { KeyingSetInfo *ksi= RNA_struct_blender_type_get(type); @@ -200,10 +200,10 @@ static void rna_KeyingSetInfo_unregister(const bContext *C, StructRNA *type) RNA_struct_free(&BLENDER_RNA, type); /* unlink Blender-side data */ - ANIM_keyingset_info_unregister(C, ksi); + ANIM_keyingset_info_unregister(bmain, ksi); } -static StructRNA *rna_KeyingSetInfo_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { KeyingSetInfo dummyksi = {NULL}; KeyingSetInfo *ksi; @@ -226,7 +226,7 @@ static StructRNA *rna_KeyingSetInfo_register(bContext *C, ReportList *reports, v /* check if we have registered this info before, and remove it */ ksi = ANIM_keyingset_info_find_named(dummyksi.idname); if (ksi && ksi->ext.srna) - rna_KeyingSetInfo_unregister(C, ksi->ext.srna); + rna_KeyingSetInfo_unregister(bmain, ksi->ext.srna); /* create a new KeyingSetInfo type */ ksi= MEM_callocN(sizeof(KeyingSetInfo), "python keying set info"); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 1d060c8a362..a9fb545ec3f 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -197,8 +197,8 @@ struct StructRNA *rna_ID_refine(struct PointerRNA *ptr); struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, int create); void rna_ID_fake_user_set(struct PointerRNA *ptr, int value); struct IDProperty *rna_PropertyGroup_idprops(struct PointerRNA *ptr, int create); -void rna_PropertyGroup_unregister(const struct bContext *C, struct StructRNA *type); -struct StructRNA *rna_PropertyGroup_register(struct bContext *C, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); +void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type); +struct StructRNA *rna_PropertyGroup_register(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); struct StructRNA* rna_PropertyGroup_refine(struct PointerRNA *ptr); void rna_object_vgroup_name_index_get(struct PointerRNA *ptr, char *value, int index); diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index f87eb4ca4aa..88722a1d305 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -101,7 +101,7 @@ static void engine_render(RenderEngine *engine, struct Scene *scene) RNA_parameter_list_free(&list); } -static void rna_RenderEngine_unregister(const bContext *C, StructRNA *type) +static void rna_RenderEngine_unregister(Main *bmain, StructRNA *type) { RenderEngineType *et= RNA_struct_blender_type_get(type); @@ -113,7 +113,7 @@ static void rna_RenderEngine_unregister(const bContext *C, StructRNA *type) RNA_struct_free(&BLENDER_RNA, type); } -static StructRNA *rna_RenderEngine_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { RenderEngineType *et, dummyet = {NULL}; RenderEngine dummyengine= {NULL}; @@ -137,7 +137,7 @@ static StructRNA *rna_RenderEngine_register(bContext *C, ReportList *reports, vo for(et=R_engines.first; et; et=et->next) { if(strcmp(et->idname, dummyet.idname) == 0) { if(et->ext.srna) - rna_RenderEngine_unregister(C, et->ext.srna); + rna_RenderEngine_unregister(bmain, et->ext.srna); break; } } diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index b5c6de679b2..5fe4d21c1ae 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -148,7 +148,7 @@ static void panel_draw_header(const bContext *C, Panel *pnl) RNA_parameter_list_free(&list); } -static void rna_Panel_unregister(const bContext *C, StructRNA *type) +static void rna_Panel_unregister(Main *bmain, StructRNA *type) { ARegionType *art; PanelType *pt= RNA_struct_blender_type_get(type); @@ -164,11 +164,10 @@ static void rna_Panel_unregister(const bContext *C, StructRNA *type) RNA_struct_free(&BLENDER_RNA, type); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Panel_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; PanelType *pt, dummypt = {NULL}; @@ -196,7 +195,7 @@ static StructRNA *rna_Panel_register(bContext *C, ReportList *reports, void *dat for(pt=art->paneltypes.first; pt; pt=pt->next) { if(strcmp(pt->idname, dummypt.idname) == 0) { if(pt->ext.srna) - rna_Panel_unregister(C, pt->ext.srna); + rna_Panel_unregister(bmain, pt->ext.srna); else BLI_freelinkN(&art->paneltypes, pt); break; @@ -233,8 +232,7 @@ static StructRNA *rna_Panel_register(bContext *C, ReportList *reports, void *dat BLI_addtail(&art->paneltypes, pt); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return pt->ext.srna; } @@ -263,7 +261,7 @@ static void header_draw(const bContext *C, Header *hdr) RNA_parameter_list_free(&list); } -static void rna_Header_unregister(const bContext *C, StructRNA *type) +static void rna_Header_unregister(Main *bmain, StructRNA *type) { ARegionType *art; HeaderType *ht= RNA_struct_blender_type_get(type); @@ -279,11 +277,10 @@ static void rna_Header_unregister(const bContext *C, StructRNA *type) RNA_struct_free(&BLENDER_RNA, type); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Header_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; HeaderType *ht, dummyht = {NULL}; @@ -311,7 +308,7 @@ static StructRNA *rna_Header_register(bContext *C, ReportList *reports, void *da for(ht=art->headertypes.first; ht; ht=ht->next) { if(strcmp(ht->idname, dummyht.idname) == 0) { if(ht->ext.srna) - rna_Header_unregister(C, ht->ext.srna); + rna_Header_unregister(bmain, ht->ext.srna); break; } } @@ -331,8 +328,7 @@ static StructRNA *rna_Header_register(bContext *C, ReportList *reports, void *da BLI_addtail(&art->headertypes, ht); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return ht->ext.srna; } @@ -384,7 +380,7 @@ static void menu_draw(const bContext *C, Menu *hdr) RNA_parameter_list_free(&list); } -static void rna_Menu_unregister(const bContext *C, StructRNA *type) +static void rna_Menu_unregister(Main *bmain, StructRNA *type) { MenuType *mt= RNA_struct_blender_type_get(type); @@ -398,11 +394,10 @@ static void rna_Menu_unregister(const bContext *C, StructRNA *type) RNA_struct_free(&BLENDER_RNA, type); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Menu_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { MenuType *mt, dummymt = {NULL}; Menu dummymenu= {NULL}; @@ -425,7 +420,7 @@ static StructRNA *rna_Menu_register(bContext *C, ReportList *reports, void *data /* check if we have registered this menu type before, and remove it */ mt= WM_menutype_find(dummymt.idname, TRUE); if(mt && mt->ext.srna) - rna_Menu_unregister(C, mt->ext.srna); + rna_Menu_unregister(bmain, mt->ext.srna); /* create a new menu type */ mt= MEM_callocN(sizeof(MenuType), "python buttons menu"); @@ -444,8 +439,7 @@ static StructRNA *rna_Menu_register(bContext *C, ReportList *reports, void *data WM_menutype_add(mt); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return mt->ext.srna; } diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 4c79c27e0de..b6d22def81e 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -669,19 +669,20 @@ static void rna_wmClipboard_set(PointerRNA *ptr, const char *value) } #ifdef WITH_PYTHON -static void rna_Operator_unregister(const bContext *C, StructRNA *type) +static void rna_Operator_unregister(struct Main *bmain, StructRNA *type) { const char *idname; wmOperatorType *ot= RNA_struct_blender_type_get(type); + wmWindowManager *wm; if(!ot) return; /* update while blender is running */ - if(C) { - WM_operator_stack_clear((bContext*)C); - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); - } + wm= bmain->wm.first; + if(wm) + WM_operator_stack_clear(wm); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); RNA_struct_free_extension(type, &ot->ext); @@ -858,7 +859,7 @@ void macro_wrapper(wmOperatorType *ot, void *userdata); static char _operator_idname[OP_MAX_TYPENAME]; static char _operator_name[OP_MAX_TYPENAME]; static char _operator_descr[1024]; -static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { wmOperatorType dummyot = {NULL}; wmOperator dummyop= {NULL}; @@ -935,7 +936,7 @@ static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void * { wmOperatorType *ot= WM_operatortype_find(dummyot.idname, TRUE); if(ot && ot->ext.srna) - rna_Operator_unregister(C, ot->ext.srna); + rna_Operator_unregister(bmain, ot->ext.srna); } /* create a new menu type */ @@ -955,14 +956,13 @@ static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void * WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return dummyot.ext.srna; } -static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { wmOperatorType dummyot = {NULL}; wmOperator dummyop= {NULL}; @@ -1006,7 +1006,7 @@ static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, v { wmOperatorType *ot= WM_operatortype_find(dummyot.idname, TRUE); if(ot && ot->ext.srna) - rna_Operator_unregister(C, ot->ext.srna); + rna_Operator_unregister(bmain, ot->ext.srna); } /* create a new menu type */ @@ -1021,8 +1021,7 @@ static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, v WM_operatortype_append_macro_ptr(macro_wrapper, (void *)&dummyot); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return dummyot.ext.srna; } |