Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80b648e

Browse files
committed
Make some C++ bool conversions explicit.
1 parent 1732ded commit 80b648e

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

src/_backend_agg.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ class RendererAgg
281281
DashesVector &linestyles,
282282
AntialiasedArray &antialiaseds,
283283
e_offset_position offset_position,
284-
int check_snap,
285-
int has_curves);
284+
bool check_snap,
285+
bool has_curves);
286286

287287
template <class PointArray, class ColorArray>
288288
void _draw_gouraud_triangle(PointArray &points,
@@ -915,8 +915,8 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
915915
DashesVector &linestyles,
916916
AntialiasedArray &antialiaseds,
917917
e_offset_position offset_position,
918-
int check_snap,
919-
int has_curves)
918+
bool check_snap,
919+
bool has_curves)
920920
{
921921
typedef agg::conv_transform<typename PathGenerator::path_iterator> transformed_path_t;
922922
typedef PathNanRemover<transformed_path_t> nan_removed_t;
@@ -1068,8 +1068,8 @@ inline void RendererAgg::draw_path_collection(GCAgg &gc,
10681068
linestyles,
10691069
antialiaseds,
10701070
offset_position,
1071-
1,
1072-
1);
1071+
true,
1072+
true);
10731073
}
10741074

10751075
template <class CoordinateArray>
@@ -1186,8 +1186,8 @@ inline void RendererAgg::draw_quad_mesh(GCAgg &gc,
11861186
linestyles,
11871187
antialiaseds,
11881188
OFFSET_POSITION_FIGURE,
1189-
0,
1190-
0);
1189+
false,
1190+
false);
11911191
}
11921192

11931193
template <class PointArray, class ColorArray>

src/_contour.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,10 +1360,10 @@ bool QuadContourGenerator::is_edge_a_boundary(const QuadEdge& quad_edge) const
13601360
assert(quad_edge.edge != Edge_None && "Invalid edge");
13611361

13621362
switch (quad_edge.edge) {
1363-
case Edge_E: return BOUNDARY_E(quad_edge.quad);
1364-
case Edge_N: return BOUNDARY_N(quad_edge.quad);
1365-
case Edge_W: return BOUNDARY_W(quad_edge.quad);
1366-
case Edge_S: return BOUNDARY_S(quad_edge.quad);
1363+
case Edge_E: return BOUNDARY_E(quad_edge.quad) != 0;
1364+
case Edge_N: return BOUNDARY_N(quad_edge.quad) != 0;
1365+
case Edge_W: return BOUNDARY_W(quad_edge.quad) != 0;
1366+
case Edge_S: return BOUNDARY_S(quad_edge.quad) != 0;
13671367
case Edge_NE: return EXISTS_SW_CORNER(quad_edge.quad);
13681368
case Edge_NW: return EXISTS_SE_CORNER(quad_edge.quad);
13691369
case Edge_SW: return EXISTS_NE_CORNER(quad_edge.quad);
@@ -1750,7 +1750,7 @@ bool QuadContourGenerator::start_line(
17501750
ContourLine contour_line(false);
17511751
follow_interior(contour_line, quad_edge, 1, level, true, 0, 1, false);
17521752
append_contour_line_to_vertices(contour_line, vertices_list);
1753-
return VISITED(quad,1);
1753+
return VISITED(quad,1) != 0;
17541754
}
17551755

17561756
void QuadContourGenerator::write_cache(bool grid_only) const

src/_path.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ inline bool point_in_path(
278278

279279
points_in_path(points, r, path, trans, result);
280280

281-
return (bool)result[0];
281+
return result[0] != 0;
282282
}
283283

284284
template <class PathIterator, class PointArray, class ResultArray>
@@ -320,7 +320,7 @@ inline bool point_on_path(
320320

321321
points_on_path(points, r, path, trans, result);
322322

323-
return (bool)result[0];
323+
return result[0] != 0;
324324
}
325325

326326
struct extent_limits

src/ft2font_wrapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ static PyObject *PyFT2Font_draw_glyphs_to_bitmap(PyFT2Font *self, PyObject *args
837837
return NULL;
838838
}
839839

840-
CALL_CPP("draw_glyphs_to_bitmap", (self->x->draw_glyphs_to_bitmap(antialiased)));
840+
CALL_CPP("draw_glyphs_to_bitmap", (self->x->draw_glyphs_to_bitmap(antialiased != 0)));
841841

842842
Py_RETURN_NONE;
843843
}
@@ -857,7 +857,7 @@ static PyObject *PyFT2Font_get_xys(PyFT2Font *self, PyObject *args, PyObject *kw
857857
return NULL;
858858
}
859859

860-
CALL_CPP("get_xys", (self->x->get_xys(antialiased, xys)));
860+
CALL_CPP("get_xys", (self->x->get_xys(antialiased != 0, xys)));
861861

862862
return convert_xys_to_array(xys);
863863
}
@@ -897,7 +897,7 @@ static PyObject *PyFT2Font_draw_glyph_to_bitmap(PyFT2Font *self, PyObject *args,
897897
}
898898

899899
CALL_CPP("draw_glyph_to_bitmap",
900-
self->x->draw_glyph_to_bitmap(*(image->x), xd, yd, glyph->glyphInd, antialiased));
900+
self->x->draw_glyph_to_bitmap(*(image->x), xd, yd, glyph->glyphInd, antialiased != 0));
901901

902902
Py_RETURN_NONE;
903903
}

src/py_converters.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,13 @@ int convert_double(PyObject *obj, void *p)
109109
int convert_bool(PyObject *obj, void *p)
110110
{
111111
bool *val = (bool *)p;
112+
int ret;
112113

113-
*val = PyObject_IsTrue(obj);
114+
ret = PyObject_IsTrue(obj);
115+
if (ret == -1) {
116+
return 0;
117+
}
118+
*val = ret != 0;
114119

115120
return 1;
116121
}
@@ -387,7 +392,7 @@ int convert_path(PyObject *obj, void *pathp)
387392
if (should_simplify_obj == NULL) {
388393
goto exit;
389394
}
390-
should_simplify = PyObject_IsTrue(should_simplify_obj);
395+
should_simplify = PyObject_IsTrue(should_simplify_obj) != 0;
391396

392397
simplify_threshold_obj = PyObject_GetAttrString(obj, "simplify_threshold");
393398
if (simplify_threshold_obj == NULL) {

0 commit comments

Comments
 (0)