Code Cleanup: use bool for return values and correct comments

also remove CDDM_Check, theres no need for it.
This commit is contained in:
Campbell Barton
2014-01-22 02:48:11 +11:00
parent 70ce11d640
commit 4ae7ae6f2e
27 changed files with 66 additions and 72 deletions

View File

@@ -46,9 +46,6 @@ struct Object;
struct DerivedMesh *CDDM_new(int numVerts, int numEdges, int numFaces,
int numLoops, int numPolys);
/*tests if a given DerivedMesh is a CDDM*/
int CDDM_Check(struct DerivedMesh *dm);
/* creates a CDDerivedMesh from the given Mesh, this will reference the
* original data in Mesh, but it is safe to apply vertex coordinates or
* calculate normals as those functions will automatically create new

View File

@@ -57,7 +57,7 @@ void BKE_image_free(struct Image *me);
void BKE_imbuf_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf);
void BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels);
int BKE_imbuf_alpha_test(struct ImBuf *ibuf);
bool BKE_imbuf_alpha_test(struct ImBuf *ibuf);
int BKE_imbuf_write_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf);
int BKE_imbuf_write(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf);
int BKE_imbuf_write_as(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf, const short is_copy);

View File

@@ -103,14 +103,14 @@ void BKE_paint_brush_set(struct Paint *paint, struct Brush *br);
/* testing face select mode
* Texture paint could be removed since selected faces are not used
* however hiding faces is useful */
int paint_facesel_test(struct Object *ob);
int paint_vertsel_test(struct Object *ob);
bool paint_facesel_test(struct Object *ob);
bool paint_vertsel_test(struct Object *ob);
/* partial visibility */
int paint_is_face_hidden(const struct MFace *f, const struct MVert *mvert);
int paint_is_grid_face_hidden(const unsigned int *grid_hidden,
int gridsize, int x, int y);
int paint_is_bmesh_face_hidden(struct BMFace *f);
bool paint_is_face_hidden(const struct MFace *f, const struct MVert *mvert);
bool paint_is_grid_face_hidden(const unsigned int *grid_hidden,
int gridsize, int x, int y);
bool paint_is_bmesh_face_hidden(struct BMFace *f);
/* paint masks */
float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level,

View File

@@ -1702,11 +1702,6 @@ static void cdDM_release(DerivedMesh *dm)
}
}
int CDDM_Check(DerivedMesh *dm)
{
return dm && dm->getMinMax == cdDM_getMinMax;
}
/**************** CDDM interface functions ****************/
static CDDerivedMesh *cdDM_create(const char *desc)
{

View File

@@ -1912,7 +1912,7 @@ void BKE_imbuf_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf)
if (stamp_data.rendertime[0]) IMB_metadata_change_field(ibuf, "RenderTime", stamp_data.rendertime);
}
int BKE_imbuf_alpha_test(ImBuf *ibuf)
bool BKE_imbuf_alpha_test(ImBuf *ibuf)
{
int tot;
if (ibuf->rect_float) {
@@ -3025,7 +3025,7 @@ static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *frame_r,
return ibuf;
}
BLI_INLINE int image_quick_test(Image *ima, ImageUser *iuser)
BLI_INLINE bool image_quick_test(Image *ima, ImageUser *iuser)
{
if (ima == NULL)
return FALSE;

View File

@@ -324,10 +324,11 @@ static void maskrasterize_spline_differentiate_point_outset(float (*diff_feather
* - if not get the max radius to a corner of the bucket and see how close we
* are to any of the triangle edges.
*/
static int layer_bucket_isect_test(MaskRasterLayer *layer, unsigned int face_index,
const unsigned int bucket_x, const unsigned int bucket_y,
const float bucket_size_x, const float bucket_size_y,
const float bucket_max_rad_squared)
static bool layer_bucket_isect_test(
MaskRasterLayer *layer, unsigned int face_index,
const unsigned int bucket_x, const unsigned int bucket_y,
const float bucket_size_x, const float bucket_size_y,
const float bucket_max_rad_squared)
{
unsigned int *face = layer->face_array[face_index];
float (*cos)[3] = layer->face_coords;

View File

@@ -3504,7 +3504,7 @@ static Object *obrel_armature_find(Object *ob)
return ob_arm;
}
static int obrel_list_test(Object *ob)
static bool obrel_list_test(Object *ob)
{
return ob && !(ob->id.flag & LIB_DOIT);
}

View File

@@ -265,7 +265,7 @@ void BKE_paint_brush_set(Paint *p, Brush *br)
}
/* are we in vertex paint or weight pain face select mode? */
int paint_facesel_test(Object *ob)
bool paint_facesel_test(Object *ob)
{
return ( (ob != NULL) &&
(ob->type == OB_MESH) &&
@@ -276,7 +276,7 @@ int paint_facesel_test(Object *ob)
}
/* are we in weight paint vertex select mode? */
int paint_vertsel_test(Object *ob)
bool paint_vertsel_test(Object *ob)
{
return ( (ob != NULL) &&
(ob->type == OB_MESH) &&
@@ -319,7 +319,7 @@ void BKE_paint_copy(Paint *src, Paint *tar)
/* returns non-zero if any of the face's vertices
* are hidden, zero otherwise */
int paint_is_face_hidden(const MFace *f, const MVert *mvert)
bool paint_is_face_hidden(const MFace *f, const MVert *mvert)
{
return ((mvert[f->v1].flag & ME_HIDE) ||
(mvert[f->v2].flag & ME_HIDE) ||
@@ -330,7 +330,7 @@ int paint_is_face_hidden(const MFace *f, const MVert *mvert)
/* returns non-zero if any of the corners of the grid
* face whose inner corner is at (x, y) are hidden,
* zero otherwise */
int paint_is_grid_face_hidden(const unsigned int *grid_hidden,
bool paint_is_grid_face_hidden(const unsigned int *grid_hidden,
int gridsize, int x, int y)
{
/* skip face if any of its corners are hidden */
@@ -341,7 +341,7 @@ int paint_is_grid_face_hidden(const unsigned int *grid_hidden,
}
/* Return TRUE if all vertices in the face are visible, FALSE otherwise */
int paint_is_bmesh_face_hidden(BMFace *f)
bool paint_is_bmesh_face_hidden(BMFace *f)
{
BMLoop *l_iter;
BMLoop *l_first;

View File

@@ -32,11 +32,6 @@
* \ingroup bli
*/
/* a light stack-friendly hash library,
* (it uses stack space for smallish hash tables) */
/* based on a doubling non-chaining approach */
#include "BLI_compiler_attrs.h"
typedef struct {
@@ -66,7 +61,7 @@ void BLI_smallhash_release(SmallHash *hash) ATTR_NONNULL(1);
void BLI_smallhash_insert(SmallHash *hash, uintptr_t key, void *item) ATTR_NONNULL(1);
void BLI_smallhash_remove(SmallHash *hash, uintptr_t key) ATTR_NONNULL(1);
void *BLI_smallhash_lookup(SmallHash *hash, uintptr_t key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
int BLI_smallhash_haskey(SmallHash *hash, uintptr_t key) ATTR_NONNULL(1);
bool BLI_smallhash_haskey(SmallHash *hash, uintptr_t key) ATTR_NONNULL(1);
int BLI_smallhash_count(SmallHash *hash) ATTR_NONNULL(1);
void *BLI_smallhash_iternext(SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
void *BLI_smallhash_iternew(SmallHash *hash, SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;

View File

@@ -27,6 +27,11 @@
/** \file blender/blenlib/intern/smallhash.c
* \ingroup bli
*
* A light stack-friendly hash library, it uses stack space for smallish hash tables
* but falls back to heap memory once the stack limits reached.
*
* based on a doubling non-chaining approach
*/
#include <string.h>
@@ -35,6 +40,7 @@
#include "BLI_utildefines.h"
#include "BLI_smallhash.h"
#include "BLI_strict_flags.h"
/* SMHASH_CELL_UNUSED means this cell is inside a key series,
@@ -43,7 +49,7 @@
* no chance of anyone shoving INT32_MAX-2 into a *val pointer, I
* imagine. hopefully.
*
* note: these have the SMHASH suffix because we may want to make them public.
* note: these have the SMHASH prefix because we may want to make them public.
*/
#define SMHASH_CELL_UNUSED ((void *)0x7FFFFFFF)
#define SMHASH_CELL_FREE ((void *)0x7FFFFFFD)
@@ -191,7 +197,7 @@ void *BLI_smallhash_lookup(SmallHash *hash, uintptr_t key)
}
int BLI_smallhash_haskey(SmallHash *hash, uintptr_t key)
bool BLI_smallhash_haskey(SmallHash *hash, uintptr_t key)
{
unsigned int h = (unsigned int)(key);
unsigned int hoff = 1;
@@ -200,7 +206,7 @@ int BLI_smallhash_haskey(SmallHash *hash, uintptr_t key)
(hash->table[h % hash->size].val == SMHASH_CELL_UNUSED))
{
if (hash->table[h % hash->size].val == SMHASH_CELL_FREE) {
return 0;
return false;
}
h = SMHASH_NEXT(h, hoff);

View File

@@ -578,7 +578,7 @@ static void bm_edge_tag_disable(BMEdge *e)
}
}
static int bm_edge_tag_test(BMEdge *e)
static bool bm_edge_tag_test(BMEdge *e)
{
/* is the edge or one of its faces tagged? */
return (BM_elem_flag_test(e->v1, BM_ELEM_TAG) ||

View File

@@ -149,9 +149,9 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale
}
/* helper method to test if group colors should be drawn */
static short acf_show_channel_colors(bAnimContext *ac)
static bool acf_show_channel_colors(bAnimContext *ac)
{
short showGroupColors = 0;
bool showGroupColors = false;
if (ac->sl) {
switch (ac->spacetype) {
@@ -179,7 +179,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
bActionGroup *grp = NULL;
short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
short showGroupColors = acf_show_channel_colors(ac);
bool showGroupColors = acf_show_channel_colors(ac);
if (ale->type == ANIMTYPE_FCURVE) {
FCurve *fcu = (FCurve *)ale->data;
@@ -751,7 +751,7 @@ static bAnimChannelType ACF_OBJECT =
static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3])
{
bActionGroup *agrp = (bActionGroup *)ale->data;
short showGroupColors = acf_show_channel_colors(ac);
bool showGroupColors = acf_show_channel_colors(ac);
if (showGroupColors && agrp->customCol) {
unsigned char cp[3];

View File

@@ -153,7 +153,7 @@ enum {
/* minimum length of new segment before new point can be added */
#define MIN_EUCLIDEAN_PX (U.gp_euclideandist)
static int gp_stroke_added_check(tGPsdata *p)
static bool gp_stroke_added_check(tGPsdata *p)
{
return (p->gpf && p->gpf->strokes.last && p->flags & GP_PAINTFLAG_STROKEADDED);
}
@@ -196,7 +196,7 @@ static int gpencil_draw_poll(bContext *C)
}
/* check if projecting strokes into 3d-geometry in the 3D-View */
static int gpencil_project_check(tGPsdata *p)
static bool gpencil_project_check(tGPsdata *p)
{
bGPdata *gpd = p->gpd;
return ((gpd->sbuffer_sflag & GP_STROKE_3DSPACE) && (p->gpd->flag & (GP_DATA_DEPTH_VIEW | GP_DATA_DEPTH_STROKE)));
@@ -1791,7 +1791,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
static int gpencil_area_exists(bContext *C, ScrArea *sa_test)
static bool gpencil_area_exists(bContext *C, ScrArea *sa_test)
{
bScreen *sc = CTX_wm_screen(C);
return (BLI_findindex(&sc->areabase, sa_test) != -1);

View File

@@ -98,7 +98,7 @@ int ED_node_is_texture(struct SpaceNode *snode);
void ED_node_shader_default(const struct bContext *C, struct ID *id);
void ED_node_composit_default(const struct bContext *C, struct Scene *scene);
void ED_node_texture_default(const struct bContext *C, struct Tex *tex);
int ED_node_select_check(ListBase *lb);
bool ED_node_select_check(ListBase *lb);
void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree);
void ED_node_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node);

View File

@@ -53,10 +53,10 @@ void ED_keymap_uvedit(struct wmKeyConfig *keyconf);
void ED_uvedit_assign_image(struct Main *bmain, struct Scene *scene, struct Object *obedit, struct Image *ima, struct Image *previma);
bool ED_uvedit_minmax(struct Scene *scene, struct Image *ima, struct Object *obedit, float min[2], float max[2]);
int ED_object_get_active_image(struct Object *ob, int mat_nr, struct Image **ima, struct ImageUser **iuser, struct bNode **node);
bool ED_object_get_active_image(struct Object *ob, int mat_nr, struct Image **ima, struct ImageUser **iuser, struct bNode **node);
void ED_object_assign_active_image(struct Main *bmain, struct Object *ob, int mat_nr, struct Image *ima);
int ED_uvedit_test(struct Object *obedit);
bool ED_uvedit_test(struct Object *obedit);
/* visibility and selection */
bool uvedit_face_visible_test(struct Scene *scene, struct Image *ima, struct BMFace *efa, struct MTexPoly *tf);
@@ -88,8 +88,8 @@ void uvedit_uv_select_enable(struct BMEditMesh *em, struct Scene *scene, struct
void uvedit_uv_select_disable(struct BMEditMesh *em, struct Scene *scene, struct BMLoop *l,
const int cd_loop_uv_offset);
int ED_uvedit_nearest_uv(struct Scene *scene, struct Object *obedit, struct Image *ima,
const float co[2], float r_uv[2]);
bool ED_uvedit_nearest_uv(struct Scene *scene, struct Object *obedit, struct Image *ima,
const float co[2], float r_uv[2]);
/* uvedit_unwrap_ops.c */
void ED_uvedit_live_unwrap_begin(struct Scene *scene, struct Object *obedit);

View File

@@ -1188,7 +1188,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
/**
* Check if the button is pushed, this is only meaningful for some button types.
*
* \return (0 == UNSELECT), (1 == SELECT), (-1 == DO-NOHING)
* \return (0 == UNSELECT), (1 == SELECT), (-1 == DO-NOTHING)
*/
int ui_is_but_push_ex(uiBut *but, double *value)
{

View File

@@ -96,9 +96,9 @@ void MASK_OT_select_linked(struct wmOperatorType *ot);
void MASK_OT_select_more(struct wmOperatorType *ot);
void MASK_OT_select_less(struct wmOperatorType *ot);
int ED_mask_spline_select_check(struct MaskSpline *spline);
int ED_mask_layer_select_check(struct MaskLayer *masklay);
int ED_mask_select_check(struct Mask *mask);
bool ED_mask_spline_select_check(struct MaskSpline *spline);
bool ED_mask_layer_select_check(struct MaskLayer *masklay);
bool ED_mask_select_check(struct Mask *mask);
void ED_mask_spline_select_set(struct MaskSpline *spline, const short do_select);
void ED_mask_layer_select_set(struct MaskLayer *masklay, const short do_select);

View File

@@ -55,7 +55,7 @@
#include "mask_intern.h" /* own include */
/* 'check' select */
int ED_mask_spline_select_check(MaskSpline *spline)
bool ED_mask_spline_select_check(MaskSpline *spline)
{
int i;
@@ -69,7 +69,7 @@ int ED_mask_spline_select_check(MaskSpline *spline)
return FALSE;
}
int ED_mask_layer_select_check(MaskLayer *masklay)
bool ED_mask_layer_select_check(MaskLayer *masklay)
{
MaskSpline *spline;
@@ -86,7 +86,7 @@ int ED_mask_layer_select_check(MaskLayer *masklay)
return FALSE;
}
int ED_mask_select_check(Mask *mask)
bool ED_mask_select_check(Mask *mask)
{
MaskLayer *masklay;

View File

@@ -176,7 +176,7 @@ int ED_operator_objectmode(bContext *C)
}
static int ed_spacetype_test(bContext *C, int type)
static bool ed_spacetype_test(bContext *C, int type)
{
if (ED_operator_areaactive(C)) {
SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C);

View File

@@ -80,7 +80,7 @@
/* check if we can do partial updates and have them draw realtime
* (without rebuilding the 'derivedFinal') */
static int vertex_paint_use_fast_update_check(Object *ob)
static bool vertex_paint_use_fast_update_check(Object *ob)
{
DerivedMesh *dm = ob->derivedFinal;
@@ -97,7 +97,7 @@ static int vertex_paint_use_fast_update_check(Object *ob)
/* if the polygons from the mesh and the 'derivedFinal' match
* we can assume that no modifiers are applied and that its worth adding tessellated faces
* so 'vertex_paint_use_fast_update_check()' returns TRUE */
static int vertex_paint_use_tessface_check(Object *ob, Mesh *me)
static bool vertex_paint_use_tessface_check(Object *ob, Mesh *me)
{
DerivedMesh *dm = ob->derivedFinal;

View File

@@ -308,7 +308,7 @@ static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short
/* Handles ---------------- */
static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu)
static bool draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu)
{
/* don't draw handle lines if handles are not to be shown */
if ( (sipo->flag & SIPO_NOHANDLES) || /* handles shouldn't be shown anywhere */

View File

@@ -929,7 +929,7 @@ typedef enum eGraphVertIndex {
/* check if its ok to select a handle */
// XXX also need to check for int-values only?
static int fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt)
static bool fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt)
{
if (sipo->flag & SIPO_NOHANDLES) return 0;
if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZSELECTED(bezt) == 0) return 0;

View File

@@ -2103,7 +2103,7 @@ void IMAGE_OT_invert(wmOperatorType *ot)
/********************* pack operator *********************/
static int image_pack_test(bContext *C, wmOperator *op)
static bool image_pack_test(bContext *C, wmOperator *op)
{
Image *ima = CTX_data_edit_image(C);
int as_png = RNA_boolean_get(op->ptr, "as_png");

View File

@@ -100,7 +100,7 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx
}
/* ********************** Add reroute operator ***************** */
static int add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int tot, float result[2])
static bool add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int tot, float result[2])
{
float coord_array[NODE_LINK_RESOL + 1][2];
int i, b;

View File

@@ -1255,7 +1255,7 @@ void NODE_OT_duplicate(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes");
}
int ED_node_select_check(ListBase *lb)
bool ED_node_select_check(ListBase *lb)
{

View File

@@ -91,7 +91,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object
/************************* state testing ************************/
int ED_uvedit_test(Object *obedit)
bool ED_uvedit_test(Object *obedit)
{
BMEditMesh *em;
int ret;
@@ -132,12 +132,12 @@ static int UNUSED_FUNCTION(ED_operator_uvmap_mesh) (bContext *C)
}
/**************************** object active image *****************************/
static int is_image_texture_node(bNode *node)
static bool is_image_texture_node(bNode *node)
{
return ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT);
}
int ED_object_get_active_image(Object *ob, int mat_nr, Image **ima, ImageUser **iuser, bNode **node_r)
bool ED_object_get_active_image(Object *ob, int mat_nr, Image **ima, ImageUser **iuser, bNode **node_r)
{
Material *ma = give_current_material(ob, mat_nr);
bNode *node = (ma && ma->use_nodes) ? nodeGetActiveTexture(ma->nodetree) : NULL;
@@ -866,7 +866,7 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em,
}
}
int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float co[2], float r_uv[2])
bool ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float co[2], float r_uv[2])
{
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMFace *efa;
@@ -875,7 +875,7 @@ int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float c
MTexPoly *tf;
MLoopUV *luv;
float mindist, dist;
int found = FALSE;
bool found = false;
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY);
@@ -896,7 +896,7 @@ int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float c
mindist = dist;
copy_v2_v2(r_uv, luv->uv);
found = TRUE;
found = true;
}
}
}

View File

@@ -644,7 +644,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal
/* this function is mainly to check that the rules for freeing
* an operator are kept in sync.
*/
static int wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot)
static bool wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot)
{
return wm && (wm->op_undo_depth == 0) && (ot->flag & OPTYPE_REGISTER);
}
@@ -1745,7 +1745,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
return action;
}
static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event)
static bool handler_boundbox_test(wmEventHandler *handler, wmEvent *event)
{
if (handler->bbwin) {
if (handler->bblocal) {