From 377a1e3d7b7f108c5feff24dc2adb5ef7c402989 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 9 Sep 2020 11:10:38 +0200 Subject: Cleanup: use bool instead of int --- source/blender/blenkernel/intern/dynamicpaint.c | 4 +-- source/blender/blenkernel/intern/seqprefetch.c | 2 +- .../blender/editors/gpencil/editaction_gpencil.c | 34 +++++++++++----------- source/blender/editors/include/ED_gpencil.h | 2 +- source/blender/editors/include/ED_mask.h | 4 +-- source/blender/editors/mask/mask_editaction.c | 18 ++++++------ source/blender/editors/mesh/meshtools.c | 9 +++--- source/blender/python/intern/bpy_rna_gizmo.c | 4 +-- source/blender/python/intern/bpy_rna_gizmo.h | 2 +- 9 files changed, 40 insertions(+), 39 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index dff7dca4d76..50c9ce4fb75 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -306,12 +306,12 @@ static Mesh *dynamicPaint_brush_mesh_get(DynamicPaintBrushSettings *brush) /***************************** General Utils ******************************/ /* Set canvas error string to display at the bake report */ -static int setError(DynamicPaintCanvasSettings *canvas, const char *string) +static bool setError(DynamicPaintCanvasSettings *canvas, const char *string) { /* Add error to canvas ui info label */ BLI_strncpy(canvas->error, string, sizeof(canvas->error)); CLOG_STR_ERROR(&LOG, string); - return 0; + return false; } /* Get number of surface points for cached types */ diff --git a/source/blender/blenkernel/intern/seqprefetch.c b/source/blender/blenkernel/intern/seqprefetch.c index 3a7e4af490a..013abb716d4 100644 --- a/source/blender/blenkernel/intern/seqprefetch.c +++ b/source/blender/blenkernel/intern/seqprefetch.c @@ -483,7 +483,7 @@ static void *seq_prefetch_frames(void *job) pfjob->running = false; pfjob->scene_eval->ed->prefetch_job = NULL; - return 0; + return NULL; } static PrefetchJob *seq_prefetch_start(const SeqRenderData *context, float cfra) diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index 752b8a74f4f..897a6e9653d 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -58,7 +58,7 @@ /* Loops over the gp-frames for a gp-layer, and applies the given callback */ bool ED_gpencil_layer_frames_looper(bGPDlayer *gpl, Scene *scene, - short (*gpf_cb)(bGPDframe *, Scene *)) + bool (*gpf_cb)(bGPDframe *, Scene *)) { /* error checker */ if (gpl == NULL) { @@ -511,40 +511,40 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode) /* -------------------------------------- */ /* Snap Tools */ -static short gpencil_frame_snap_nearest(bGPDframe *UNUSED(gpf), Scene *UNUSED(scene)) +static bool gpencil_frame_snap_nearest(bGPDframe *UNUSED(gpf), Scene *UNUSED(scene)) { #if 0 /* note: gpf->framenum is already an int! */ if (gpf->flag & GP_FRAME_SELECT) { gpf->framenum = (int)(floor(gpf->framenum + 0.5)); } #endif - return 0; + return false; } -static short gpencil_frame_snap_nearestsec(bGPDframe *gpf, Scene *scene) +static bool gpencil_frame_snap_nearestsec(bGPDframe *gpf, Scene *scene) { float secf = (float)FPS; if (gpf->flag & GP_FRAME_SELECT) { gpf->framenum = (int)(floorf(gpf->framenum / secf + 0.5f) * secf); } - return 0; + return false; } -static short gpencil_frame_snap_cframe(bGPDframe *gpf, Scene *scene) +static bool gpencil_frame_snap_cframe(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) { gpf->framenum = (int)CFRA; } - return 0; + return false; } -static short gpencil_frame_snap_nearmarker(bGPDframe *gpf, Scene *scene) +static bool gpencil_frame_snap_nearmarker(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) { gpf->framenum = (int)ED_markers_find_nearest_marker_time(&scene->markers, (float)gpf->framenum); } - return 0; + return false; } /* snap selected frames to ... */ @@ -571,7 +571,7 @@ void ED_gpencil_layer_snap_frames(bGPDlayer *gpl, Scene *scene, short mode) /* -------------------------------------- */ /* Mirror Tools */ -static short gpencil_frame_mirror_cframe(bGPDframe *gpf, Scene *scene) +static bool gpencil_frame_mirror_cframe(bGPDframe *gpf, Scene *scene) { int diff; @@ -580,10 +580,10 @@ static short gpencil_frame_mirror_cframe(bGPDframe *gpf, Scene *scene) gpf->framenum = CFRA + diff; } - return 0; + return false; } -static short gpencil_frame_mirror_yaxis(bGPDframe *gpf, Scene *UNUSED(scene)) +static bool gpencil_frame_mirror_yaxis(bGPDframe *gpf, Scene *UNUSED(scene)) { int diff; @@ -592,10 +592,10 @@ static short gpencil_frame_mirror_yaxis(bGPDframe *gpf, Scene *UNUSED(scene)) gpf->framenum = diff; } - return 0; + return false; } -static short gpencil_frame_mirror_xaxis(bGPDframe *gpf, Scene *UNUSED(scene)) +static bool gpencil_frame_mirror_xaxis(bGPDframe *gpf, Scene *UNUSED(scene)) { int diff; @@ -605,10 +605,10 @@ static short gpencil_frame_mirror_xaxis(bGPDframe *gpf, Scene *UNUSED(scene)) gpf->framenum = diff; } - return 0; + return false; } -static short gpencil_frame_mirror_marker(bGPDframe *gpf, Scene *scene) +static bool gpencil_frame_mirror_marker(bGPDframe *gpf, Scene *scene) { static TimeMarker *marker; static short initialized = 0; @@ -645,7 +645,7 @@ static short gpencil_frame_mirror_marker(bGPDframe *gpf, Scene *scene) } } - return 0; + return false; } /* mirror selected gp-frames on... */ diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 06839276027..398a1630cf6 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -176,7 +176,7 @@ void ED_annotation_draw_ex(struct Scene *scene, /* ----------- Grease-Pencil AnimEdit API ------------------ */ bool ED_gpencil_layer_frames_looper(struct bGPDlayer *gpl, struct Scene *scene, - short (*gpf_cb)(struct bGPDframe *, struct Scene *)); + bool (*gpf_cb)(struct bGPDframe *, struct Scene *)); void ED_gpencil_layer_make_cfra_list(struct bGPDlayer *gpl, ListBase *elems, bool onlysel); bool ED_gpencil_layer_frame_select_check(struct bGPDlayer *gpl); diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 80510d3afa1..f683495608a 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -91,8 +91,8 @@ bool ED_mask_layer_shape_auto_key_select(struct Mask *mask, const int frame); /* ----------- Mask AnimEdit API ------------------ */ bool ED_masklayer_frames_looper(struct MaskLayer *mask_layer, struct Scene *scene, - short (*mask_layer_shape_cb)(struct MaskLayerShape *, - struct Scene *)); + bool (*mask_layer_shape_cb)(struct MaskLayerShape *, + struct Scene *)); void ED_masklayer_make_cfra_list(struct MaskLayer *mask_layer, ListBase *elems, bool onlysel); bool ED_masklayer_frame_select_check(struct MaskLayer *mask_layer); diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index af99df4c5d8..1792f0e13bc 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -55,7 +55,7 @@ /* Loops over the mask-frames for a mask-layer, and applies the given callback */ bool ED_masklayer_frames_looper(MaskLayer *mask_layer, Scene *scene, - short (*mask_layer_shape_cb)(MaskLayerShape *, Scene *)) + bool (*mask_layer_shape_cb)(MaskLayerShape *, Scene *)) { MaskLayerShape *mask_layer_shape; @@ -310,38 +310,38 @@ void ED_masklayer_frames_duplicate(MaskLayer *mask_layer) /* -------------------------------------- */ /* Snap Tools */ -static short snap_mask_layer_nearest(MaskLayerShape *mask_layer_shape, Scene *UNUSED(scene)) +static bool snap_mask_layer_nearest(MaskLayerShape *mask_layer_shape, Scene *UNUSED(scene)) { if (mask_layer_shape->flag & MASK_SHAPE_SELECT) { mask_layer_shape->frame = (int)(floor(mask_layer_shape->frame + 0.5)); } - return 0; + return false; } -static short snap_mask_layer_nearestsec(MaskLayerShape *mask_layer_shape, Scene *scene) +static bool snap_mask_layer_nearestsec(MaskLayerShape *mask_layer_shape, Scene *scene) { float secf = (float)FPS; if (mask_layer_shape->flag & MASK_SHAPE_SELECT) { mask_layer_shape->frame = (int)(floorf(mask_layer_shape->frame / secf + 0.5f) * secf); } - return 0; + return false; } -static short snap_mask_layer_cframe(MaskLayerShape *mask_layer_shape, Scene *scene) +static bool snap_mask_layer_cframe(MaskLayerShape *mask_layer_shape, Scene *scene) { if (mask_layer_shape->flag & MASK_SHAPE_SELECT) { mask_layer_shape->frame = (int)CFRA; } - return 0; + return false; } -static short snap_mask_layer_nearmarker(MaskLayerShape *mask_layer_shape, Scene *scene) +static bool snap_mask_layer_nearmarker(MaskLayerShape *mask_layer_shape, Scene *scene) { if (mask_layer_shape->flag & MASK_SHAPE_SELECT) { mask_layer_shape->frame = (int)ED_markers_find_nearest_marker_time( &scene->markers, (float)mask_layer_shape->frame); } - return 0; + return false; } /* snap selected frames to ... */ diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index bd14919d1d7..471d4847af6 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -891,7 +891,8 @@ void ED_mesh_mirror_topo_table_end(Object *UNUSED(ob)) ED_mesh_mirrtopo_free(&mesh_topo_store); } -static int ed_mesh_mirror_topo_table_update(Object *ob, Mesh *me_eval) +/* Returns true on success. */ +static bool ed_mesh_mirror_topo_table_update(Object *ob, Mesh *me_eval) { Mesh *me_mirror; BMEditMesh *em_mirror; @@ -900,7 +901,7 @@ static int ed_mesh_mirror_topo_table_update(Object *ob, Mesh *me_eval) if (ED_mesh_mirrtopo_recalc_check(em_mirror, me_mirror, &mesh_topo_store)) { ED_mesh_mirror_topo_table_begin(ob, me_eval); } - return 0; + return true; } /** \} */ @@ -921,7 +922,7 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *me_eval, int index) static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index) { - if (ed_mesh_mirror_topo_table_update(ob, mesh) == -1) { + if (!ed_mesh_mirror_topo_table_update(ob, mesh)) { return -1; } @@ -963,7 +964,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, int index) { intptr_t poinval; - if (ed_mesh_mirror_topo_table_update(ob, NULL) == -1) { + if (!ed_mesh_mirror_topo_table_update(ob, NULL)) { return NULL; } diff --git a/source/blender/python/intern/bpy_rna_gizmo.c b/source/blender/python/intern/bpy_rna_gizmo.c index 575824e8a86..542d014f8b2 100644 --- a/source/blender/python/intern/bpy_rna_gizmo.c +++ b/source/blender/python/intern/bpy_rna_gizmo.c @@ -507,7 +507,7 @@ fail: /** \} */ -int BPY_rna_gizmo_module(PyObject *mod_par) +bool BPY_rna_gizmo_module(PyObject *mod_par) { static PyMethodDef method_def_array[] = { /* Gizmo Target Property Define API */ @@ -541,5 +541,5 @@ int BPY_rna_gizmo_module(PyObject *mod_par) PyModule_AddObject(mod_par, name_prefix, func_inst); } - return 0; + return false; } diff --git a/source/blender/python/intern/bpy_rna_gizmo.h b/source/blender/python/intern/bpy_rna_gizmo.h index 307b694338c..e4ac43bfe6c 100644 --- a/source/blender/python/intern/bpy_rna_gizmo.h +++ b/source/blender/python/intern/bpy_rna_gizmo.h @@ -24,7 +24,7 @@ extern "C" { #endif -int BPY_rna_gizmo_module(PyObject *); +bool BPY_rna_gizmo_module(PyObject *); #ifdef __cplusplus } -- cgit v1.2.3