From 252b0cf5d28c5ce6397a64cb4bb399a6c5a438fa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Apr 2015 15:41:12 +0200 Subject: Cleanup: API naming use BKE_undo_ prefix --- source/blender/blenkernel/BKE_blender.h | 18 +++++++++--------- source/blender/blenkernel/intern/blender.c | 22 ++++++++++++---------- source/blender/editors/include/ED_paint.h | 4 ++-- source/blender/editors/include/ED_particle.h | 4 ++-- source/blender/editors/include/ED_util.h | 2 +- source/blender/editors/physics/particle_edit.c | 11 ++++++----- source/blender/editors/sculpt_paint/paint_undo.c | 17 +++++++++-------- source/blender/editors/util/editmode_undo.c | 11 ++++++----- source/blender/editors/util/undo.c | 17 +++++++++-------- source/blender/editors/util/util_intern.h | 12 ++++++------ source/blender/windowmanager/intern/wm_files.c | 10 +++++----- source/blender/windowmanager/intern/wm_init_exit.c | 4 ++-- source/blender/windowmanager/intern/wm_operators.c | 2 +- source/creator/creator.c | 4 ++-- 14 files changed, 72 insertions(+), 66 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 86576f9a11b..0789335de6a 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -93,15 +93,15 @@ int blender_test_break(void); #define BKE_UNDO_STR_MAX 64 /* global undo */ -extern void BKE_write_undo(struct bContext *C, const char *name); -extern void BKE_undo_step(struct bContext *C, int step); -extern void BKE_undo_name(struct bContext *C, const char *name); -extern int BKE_undo_valid(const char *name); -extern void BKE_reset_undo(void); -extern void BKE_undo_number(struct bContext *C, int nr); -extern const char *BKE_undo_get_name(int nr, int *active); -extern bool BKE_undo_save_file(const char *filename); -extern struct Main *BKE_undo_get_main(struct Scene **scene); +extern void BKE_undo_write(struct bContext *C, const char *name); +extern void BKE_undo_step(struct bContext *C, int step); +extern void BKE_undo_name(struct bContext *C, const char *name); +extern bool BKE_undo_is_valid(const char *name); +extern void BKE_undo_reset(void); +extern void BKE_undo_number(struct bContext *C, int nr); +extern const char *BKE_undo_get_name(int nr, bool *r_active); +extern bool BKE_undo_save_file(const char *filename); +extern struct Main *BKE_undo_get_main(struct Scene **r_scene); /* copybuffer */ void BKE_copybuffer_begin(struct Main *bmain); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 791fa3df3b9..2085fefdb93 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -687,7 +687,7 @@ static int read_undosave(bContext *C, UndoElem *uel) } /* name can be a dynamic string */ -void BKE_write_undo(bContext *C, const char *name) +void BKE_undo_write(bContext *C, const char *name) { uintptr_t maxmem, totmem, memused; int nr /*, success */ /* UNUSED */; @@ -821,7 +821,7 @@ void BKE_undo_step(bContext *C, int step) } } -void BKE_reset_undo(void) +void BKE_undo_reset(void) { UndoElem *uel; @@ -854,7 +854,7 @@ void BKE_undo_name(bContext *C, const char *name) } /* name optional */ -int BKE_undo_valid(const char *name) +bool BKE_undo_is_valid(const char *name) { if (name) { UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); @@ -866,15 +866,16 @@ int BKE_undo_valid(const char *name) /* get name of undo item, return null if no item with this index */ /* if active pointer, set it to 1 if true */ -const char *BKE_undo_get_name(int nr, int *active) +const char *BKE_undo_get_name(int nr, bool *r_active) { UndoElem *uel = BLI_findlink(&undobase, nr); - if (active) *active = 0; + if (r_active) *r_active = false; if (uel) { - if (active && uel == curundo) - *active = 1; + if (r_active && (uel == curundo)) { + *r_active = true; + } return uel->name; } return NULL; @@ -940,15 +941,16 @@ bool BKE_undo_save_file(const char *filename) } /* sets curscene */ -Main *BKE_undo_get_main(Scene **scene) +Main *BKE_undo_get_main(Scene **r_scene) { Main *mainp = NULL; BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL); if (bfd) { mainp = bfd->main; - if (scene) - *scene = bfd->curscene; + if (r_scene) { + *r_scene = bfd->curscene; + } MEM_freeN(bfd); } diff --git a/source/blender/editors/include/ED_paint.h b/source/blender/editors/include/ED_paint.h index c3a411a2b97..822dab61a06 100644 --- a/source/blender/editors/include/ED_paint.h +++ b/source/blender/editors/include/ED_paint.h @@ -46,9 +46,9 @@ typedef bool (*UndoCleanupCb)(struct bContext *C, struct ListBase *lb); int ED_undo_paint_step(struct bContext *C, int type, int step, const char *name); void ED_undo_paint_step_num(struct bContext *C, int type, int num); -const char *ED_undo_paint_get_name(struct bContext *C, int type, int nr, int *active); +const char *ED_undo_paint_get_name(struct bContext *C, int type, int nr, bool *r_active); void ED_undo_paint_free(void); -int ED_undo_paint_valid(int type, const char *name); +bool ED_undo_paint_is_valid(int type, const char *name); bool ED_undo_paint_empty(int type); void ED_undo_paint_push_begin(int type, const char *name, UndoRestoreCb restore, UndoFreeCb free, UndoCleanupCb cleanup); void ED_undo_paint_push_end(int type); diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index 56a4bfa7e21..6cb8c0cfb19 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -66,9 +66,9 @@ void PE_undo_push(struct Scene *scene, const char *str); void PE_undo_step(struct Scene *scene, int step); void PE_undo(struct Scene *scene); void PE_redo(struct Scene *scene); -int PE_undo_valid(struct Scene *scene); +bool PE_undo_is_valid(struct Scene *scene); void PE_undo_number(struct Scene *scene, int nr); -const char *PE_undo_get_name(struct Scene *scene, int nr, int *active); +const char *PE_undo_get_name(struct Scene *scene, int nr, bool *r_active); #endif /* __ED_PARTICLE_H__ */ diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 6fa92e1953d..9556c601d1f 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -60,7 +60,7 @@ int ED_undo_operator_repeat(struct bContext *C, struct wmOperator *op); void ED_undo_operator_repeat_cb(struct bContext *C, void *arg_op, void *arg_unused); void ED_undo_operator_repeat_cb_evt(struct bContext *C, void *arg_op, int arg_unused); -int ED_undo_valid(const struct bContext *C, const char *undoname); +bool ED_undo_is_valid(const struct bContext *C, const char *undoname); /* undo_editmode.c */ void undo_editmode_push(struct bContext *C, const char *name, diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 6c90e319bc6..a0420dfa46e 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4445,7 +4445,7 @@ void PE_undo_step(Scene *scene, int step) DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA); } -int PE_undo_valid(Scene *scene) +bool PE_undo_is_valid(Scene *scene) { PTCacheEdit *edit= PE_get_current(scene, OBACT); @@ -4496,18 +4496,19 @@ void PE_undo_number(Scene *scene, int nr) /* get name of undo item, return null if no item with this index */ /* if active pointer, set it to 1 if true */ -const char *PE_undo_get_name(Scene *scene, int nr, int *active) +const char *PE_undo_get_name(Scene *scene, int nr, bool *r_active) { PTCacheEdit *edit= PE_get_current(scene, OBACT); PTCacheUndo *undo; - if (active) *active= 0; + if (r_active) *r_active = false; if (edit) { undo= BLI_findlink(&edit->undo, nr); if (undo) { - if (active && undo==edit->curundo) - *active= 1; + if (r_active && (undo == edit->curundo)) { + *r_active = true; + } return undo->name; } } diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c index 0293a0bfc00..42f0aaab173 100644 --- a/source/blender/editors/sculpt_paint/paint_undo.c +++ b/source/blender/editors/sculpt_paint/paint_undo.c @@ -331,32 +331,33 @@ void ED_undo_paint_step_num(bContext *C, int type, int step) undo_step_num(C, &MeshUndoStack, step); } -static char *undo_stack_get_name(UndoStack *stack, int nr, int *active) +static char *undo_stack_get_name(UndoStack *stack, int nr, bool *r_active) { UndoElem *uel; - if (active) *active = 0; + if (r_active) *r_active = false; uel = BLI_findlink(&stack->elems, nr); if (uel) { - if (active && uel == stack->current) - *active = 1; + if (r_active && (uel == stack->current)) { + *r_active = true; + } return uel->name; } return NULL; } -const char *ED_undo_paint_get_name(bContext *C, int type, int nr, int *active) +const char *ED_undo_paint_get_name(bContext *C, int type, int nr, bool *r_active) { if (type == UNDO_PAINT_IMAGE) { undo_stack_cleanup(&ImageUndoStack, C); - return undo_stack_get_name(&ImageUndoStack, nr, active); + return undo_stack_get_name(&ImageUndoStack, nr, r_active); } else if (type == UNDO_PAINT_MESH) { undo_stack_cleanup(&MeshUndoStack, C); - return undo_stack_get_name(&MeshUndoStack, nr, active); + return undo_stack_get_name(&MeshUndoStack, nr, r_active); } return NULL; } @@ -379,7 +380,7 @@ bool ED_undo_paint_empty(int type) return false; } -int ED_undo_paint_valid(int type, const char *name) +bool ED_undo_paint_is_valid(int type, const char *name) { UndoStack *stack; diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 7f5edb5ea9e..bc7a8374c73 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -315,7 +315,7 @@ void undo_editmode_name(bContext *C, const char *undoname) } /* undoname optionally, if NULL it just checks for existing undo steps */ -int undo_editmode_valid(const char *undoname) +bool undo_editmode_is_valid(const char *undoname) { if (undoname) { UndoElem *uel; @@ -332,19 +332,20 @@ int undo_editmode_valid(const char *undoname) /* get name of undo item, return null if no item with this index */ /* if active pointer, set it to 1 if true */ -const char *undo_editmode_get_name(bContext *C, int nr, int *active) +const char *undo_editmode_get_name(bContext *C, int nr, bool *r_active) { UndoElem *uel; /* prevent wrong numbers to be returned */ undo_clean_stack(C); - if (active) *active = 0; + if (r_active) *r_active = false; uel = BLI_findlink(&undobase, nr); if (uel) { - if (active && uel == curundo) - *active = 1; + if (r_active && (uel == curundo)) { + *r_active = true; + } return uel->name; } return NULL; diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index ab882a388ad..ee6101d2952 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -108,7 +108,7 @@ void ED_undo_push(bContext *C, const char *str) /* do nothing for now */ } else { - BKE_write_undo(C, str); + BKE_undo_write(C, str); } if (wm->file_saved) { @@ -244,7 +244,7 @@ void ED_undo_pop_op(bContext *C, wmOperator *op) } /* name optionally, function used to check for operator redo panel */ -int ED_undo_valid(const bContext *C, const char *undoname) +bool ED_undo_is_valid(const bContext *C, const char *undoname) { Object *obedit = CTX_data_edit_object(C); Object *obact = CTX_data_active_object(C); @@ -263,7 +263,7 @@ int ED_undo_valid(const bContext *C, const char *undoname) } else if (obedit) { if (OB_TYPE_SUPPORT_EDITMODE(obedit->type)) { - return undo_editmode_valid(undoname); + return undo_editmode_is_valid(undoname); } } else { @@ -271,19 +271,19 @@ int ED_undo_valid(const bContext *C, const char *undoname) /* if below tests fail, global undo gets executed */ if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { - if (ED_undo_paint_valid(UNDO_PAINT_IMAGE, undoname)) + if (ED_undo_paint_is_valid(UNDO_PAINT_IMAGE, undoname)) return 1; } else if (obact && obact->mode & OB_MODE_SCULPT) { - if (ED_undo_paint_valid(UNDO_PAINT_MESH, undoname)) + if (ED_undo_paint_is_valid(UNDO_PAINT_MESH, undoname)) return 1; } else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) { - return PE_undo_valid(CTX_data_scene(C)); + return PE_undo_is_valid(CTX_data_scene(C)); } if (U.uiflag & USER_GLOBALUNDO) { - return BKE_undo_valid(undoname); + return BKE_undo_is_valid(undoname); } } return 0; @@ -487,7 +487,8 @@ static int get_undo_system(bContext *C) static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem) { EnumPropertyItem item_tmp = {0}, *item = NULL; - int active, i = 0; + int i = 0; + bool active; while (true) { const char *name = NULL; diff --git a/source/blender/editors/util/util_intern.h b/source/blender/editors/util/util_intern.h index d366ad7997f..0f650330951 100644 --- a/source/blender/editors/util/util_intern.h +++ b/source/blender/editors/util/util_intern.h @@ -35,12 +35,12 @@ /* internal exports only */ /* editmode_undo.c */ -void undo_editmode_name (struct bContext *C, const char *undoname); -int undo_editmode_valid (const char *undoname); -const char *undo_editmode_get_name (struct bContext *C, int nr, int *active); -void *undo_editmode_get_prev (struct Object *ob); -void undo_editmode_step (struct bContext *C, int step); -void undo_editmode_number (struct bContext *C, int nr); +void undo_editmode_name(struct bContext *C, const char *undoname); +bool undo_editmode_is_valid(const char *undoname); +const char *undo_editmode_get_name(struct bContext *C, int nr, bool *r_active); +void *undo_editmode_get_prev(struct Object *ob); +void undo_editmode_step(struct bContext *C, int step); +void undo_editmode_number(struct bContext *C, int nr); #endif /* __UTIL_INTERN_H__ */ diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index e80f789d3ab..df0d27bc43e 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -506,13 +506,13 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) } #endif - BKE_reset_undo(); - BKE_write_undo(C, "original"); /* save current state */ + BKE_undo_reset(); + BKE_undo_write(C, "original"); /* save current state */ success = true; } else if (retval == BKE_READ_EXOTIC_OK_OTHER) - BKE_write_undo(C, "Import file"); + BKE_undo_write(C, "Import file"); else if (retval == BKE_READ_EXOTIC_FAIL_OPEN) { BKE_reportf(reports, RPT_ERROR, "Cannot read file '%s': %s", filepath, errno ? strerror(errno) : TIP_("unable to open the file")); @@ -660,8 +660,8 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c // refresh_interface_font(); // undo_editmode_clear(); - BKE_reset_undo(); - BKE_write_undo(C, "original"); /* save current state */ + BKE_undo_reset(); + BKE_undo_write(C, "original"); /* save current state */ ED_editors_init(C); DAG_on_visible_update(CTX_data_main(C), true); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 4f019c0a913..71a025f3660 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -407,7 +407,7 @@ void WM_exit_ext(bContext *C, const bool do_python) wmWindow *win; if (!G.background) { - if ((U.uiflag2 & USER_KEEP_SESSION) || BKE_undo_valid(NULL)) { + if ((U.uiflag2 & USER_KEEP_SESSION) || BKE_undo_is_valid(NULL)) { /* save the undo state as quit.blend */ char filename[FILE_MAX]; bool has_edited; @@ -517,7 +517,7 @@ void WM_exit_ext(bContext *C, const bool do_python) GPU_exit(); } - BKE_reset_undo(); + BKE_undo_reset(); ED_file_exit(); /* for fsmenu */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 19a6b86db90..cb2db94f609 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1404,7 +1404,7 @@ bool WM_operator_check_ui_enabled(const bContext *C, const char *idname) wmWindowManager *wm = CTX_wm_manager(C); Scene *scene = CTX_data_scene(C); - return !(ED_undo_valid(C, idname) == 0 || WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)); + return !((ED_undo_is_valid(C, idname) == false) || WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)); } wmOperator *WM_operator_last_redo(const bContext *C) diff --git a/source/creator/creator.c b/source/creator/creator.c index 5b4f828842e..440710f0572 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1369,8 +1369,8 @@ static int load_file(int UNUSED(argc), const char **argv, void *data) BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); /* happens for the UI on file reading too (huh? (ton))*/ - // XXX BKE_reset_undo(); - // BKE_write_undo("original"); /* save current state */ + // XXX BKE_undo_reset(); + // BKE_undo_write("original"); /* save current state */ } else { /* we are not running in background mode here, but start blender in UI mode with -- cgit v1.2.3