[Bf-blender-cvs] [266e7b67fd3] master: Cleanup: use boolean

Campbell Barton noreply at git.blender.org
Thu Aug 15 23:08:07 CEST 2019


Commit: 266e7b67fd3e2c219d8646e37a2fb3e393df4bda
Author: Campbell Barton
Date:   Fri Aug 16 04:54:10 2019 +1000
Branches: master
https://developer.blender.org/rB266e7b67fd3e2c219d8646e37a2fb3e393df4bda

Cleanup: use boolean

===================================================================

M	source/blender/blenkernel/BKE_context.h
M	source/blender/blenkernel/intern/context.c
M	source/blender/blenkernel/intern/image.c
M	source/blender/editors/object/object_vgroup.c
M	source/blender/editors/sculpt_paint/paint_image_undo.c
M	source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
M	source/creator/creator.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 53976b4c1ad..755a155653b 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -137,8 +137,8 @@ void CTX_store_free(bContextStore *store);
 void CTX_store_free_list(ListBase *contexts);
 
 /* need to store if python is initialized or not */
-int CTX_py_init_get(bContext *C);
-void CTX_py_init_set(bContext *C, int value);
+bool CTX_py_init_get(bContext *C);
+void CTX_py_init_set(bContext *C, bool value);
 
 void *CTX_py_dict_get(const bContext *C);
 void CTX_py_dict_set(bContext *C, void *value);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 2cb98d8d90b..f536f21c3e5 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -89,7 +89,8 @@ struct bContext {
     struct Scene *scene;
 
     int recursion;
-    int py_init; /* true if python is initialized */
+    /** True if python is initialized. */
+    bool py_init;
     void *py_context;
   } data;
 };
@@ -212,11 +213,11 @@ void CTX_store_free_list(ListBase *contexts)
 
 /* is python initialized? */
 
-int CTX_py_init_get(bContext *C)
+bool CTX_py_init_get(bContext *C)
 {
   return C->data.py_init;
 }
-void CTX_py_init_set(bContext *C, int value)
+void CTX_py_init_set(bContext *C, bool value)
 {
   C->data.py_init = value;
 }
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 8e04ef2d3ca..a99407b9bf9 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2766,8 +2766,8 @@ static void do_makepicstring(char *string,
                              int frame,
                              const char imtype,
                              const ImageFormatData *im_format,
-                             const short use_ext,
-                             const short use_frames,
+                             const bool use_ext,
+                             const bool use_frames,
                              const char *suffix)
 {
   if (string == NULL) {
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index a43ac59c9b8..08fe5e818b2 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -1139,7 +1139,7 @@ static bool vgroup_normalize(Object *ob)
   int i, dvert_tot = 0;
   const int def_nr = ob->actdef - 1;
 
-  const int use_vert_sel = vertex_group_use_vert_sel(ob);
+  const bool use_vert_sel = vertex_group_use_vert_sel(ob);
 
   if (!BLI_findlink(&ob->defbase, def_nr)) {
     return false;
@@ -1623,7 +1623,7 @@ static bool vgroup_normalize_all(Object *ob,
   int i, dvert_tot = 0;
   const int def_nr = ob->actdef - 1;
 
-  const int use_vert_sel = vertex_group_use_vert_sel(ob);
+  const bool use_vert_sel = vertex_group_use_vert_sel(ob);
 
   if (subset_count == 0) {
     BKE_report(reports, RPT_ERROR, "No vertex groups to operate on");
@@ -2047,7 +2047,7 @@ static int vgroup_limit_total_subset(Object *ob,
 {
   MDeformVert *dv, **dvert_array = NULL;
   int i, dvert_tot = 0;
-  const int use_vert_sel = vertex_group_use_vert_sel(ob);
+  const bool use_vert_sel = vertex_group_use_vert_sel(ob);
   int remove_tot = 0;
 
   ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
diff --git a/source/blender/editors/sculpt_paint/paint_image_undo.c b/source/blender/editors/sculpt_paint/paint_image_undo.c
index c7ec4f3f2b9..93dcd3ad0f6 100644
--- a/source/blender/editors/sculpt_paint/paint_image_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_image_undo.c
@@ -75,7 +75,8 @@ typedef struct UndoImageTile {
    * adds unnecessary overhead restoring undo steps when most tiles share the same image. */
   UndoRefID_Image image_ref;
 
-  short source, use_float;
+  short source;
+  bool use_float;
   char gen_type;
   bool valid;
 
@@ -172,7 +173,7 @@ void *image_undo_find_tile(ListBase *undo_tiles,
                            bool validate)
 {
   UndoImageTile *tile;
-  short use_float = ibuf->rect_float ? 1 : 0;
+  const bool use_float = (ibuf->rect_float != NULL);
 
   for (tile = undo_tiles->first; tile; tile = tile->next) {
     if (tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type &&
@@ -214,7 +215,7 @@ void *image_undo_push_tile(ListBase *undo_tiles,
 {
   UndoImageTile *tile;
   int allocsize;
-  short use_float = ibuf->rect_float ? 1 : 0;
+  const bool use_float = (ibuf->rect_float != NULL);
   void *data;
 
   /* check if tile is already pushed */
@@ -315,7 +316,6 @@ static void image_undo_restore_list(ListBase *lb)
       IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat | IB_rect);
 
   for (UndoImageTile *tile = lb->first; tile; tile = tile->next) {
-    short use_float;
 
     Image *ima = tile->image_ref.ptr;
     ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
@@ -341,7 +341,7 @@ static void image_undo_restore_list(ListBase *lb)
       continue;
     }
 
-    use_float = ibuf->rect_float ? 1 : 0;
+    const bool use_float = (ibuf->rect_float != NULL);
 
     if (use_float != tile->use_float) {
       BKE_image_release_ibuf(ima, ibuf, NULL);
@@ -450,7 +450,7 @@ static bool image_undosys_step_encode(struct bContext *C,
         tile = tmp_tile;
       }
       else {
-        us->step.data_size += allocsize * ((tile->use_float) ? sizeof(float) : sizeof(char));
+        us->step.data_size += allocsize * (tile->use_float ? sizeof(float) : sizeof(char));
         tile = tile->next;
       }
     }
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 72fc08cc38d..4aa9dc8a295 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -580,7 +580,7 @@ typedef struct WPGradient_userData {
   BLI_bitmap *vert_visit;
 
   /* options */
-  short use_select;
+  bool use_select;
   short type;
   float weightpaint;
 } WPGradient_userData;
@@ -786,7 +786,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
   data.sco_end = sco_end;
   data.sco_line_div = 1.0f / len_v2v2(sco_start, sco_end);
   data.def_nr = ob->actdef - 1;
-  data.use_select = (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL));
+  data.use_select = (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
   data.vert_cache = vert_cache;
   data.vert_visit = NULL;
   data.type = RNA_enum_get(op->ptr, "type");
diff --git a/source/creator/creator.c b/source/creator/creator.c
index d6e1d7e7f5f..9eb1578001c 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -442,7 +442,7 @@ int main(int argc,
       "this is not intended for typical usage\n\n");
 #endif
 
-  CTX_py_init_set(C, 1);
+  CTX_py_init_set(C, true);
   WM_keyconfig_init(C);
 
 #ifdef WITH_FREESTYLE



More information about the Bf-blender-cvs mailing list