8000 Use convert_bool in more places. · matplotlib/matplotlib@abd5942 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit abd5942

Browse files
committed
Use convert_bool in more places.
This helps fix up some bool warnings.
1 parent 23a8b00 commit abd5942

File tree

6 files changed

+43
-33
lines changed

6 files changed

+43
-33
lines changed

setupext.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,11 +1265,13 @@ def get_extension(self):
12651265
sources = [
12661266
'src/ft2font.cpp',
12671267
'src/ft2font_wrapper.cpp',
1268-
'src/mplutils.cpp'
1268+
'src/mplutils.cpp',
1269+
'src/py_converters.cpp',
12691270
]
12701271
ext = make_extension('matplotlib.ft2font', sources)
12711272
FreeType().add_flags(ext)
12721273
Numpy().add_flags(ext)
1274+
LibAgg().add_flags(ext, add_sources=False)
12731275
return ext
12741276

12751277

@@ -1394,9 +1396,11 @@ def get_extension(self):
13941396
sources = [
13951397
"src/_contour.cpp",
13961398
"src/_contour_wrapper.cpp",
1399+
'src/py_converters.cpp',
13971400
]
13981401
ext = make_extension('matplotlib._contour', sources)
13991402
Numpy().add_flags(ext)
1403+
LibAgg().add_flags(ext, add_sources=False)
14001404
return ext
14011405

14021406

src/_backend_agg_wrapper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,11 @@ static PyObject *PyRendererAgg_draw_quad_mesh(PyRendererAgg *self, PyObject *arg
396396
numpy::array_view<const double, 2> offsets;
397397
agg::trans_affine offset_trans;
398398
numpy::array_view<const double, 2> facecolors;
399-
int antialiased;
399+
bool antialiased;
400400
numpy::array_view<const double, 2> edgecolors;
401401

402402
if (!PyArg_ParseTuple(args,
403-
"O&O&IIO&O&O&O&iO&:draw_quad_mesh",
403+
"O&O&IIO&O&O&O&O&O&:draw_quad_mesh",
404404
&convert_gcagg,
405405
&gc,
406406
&convert_trans_affine,
@@ -415,6 +415,7 @@ static PyObject *PyRendererAgg_draw_quad_mesh(PyRendererAgg *self, PyObject *arg
415415
&offset_trans,
416416
&convert_colors,
417417
&facecolors,
418+
&convert_bool,
418419
&antialiased,
419420
&convert_colors,
420421
&edgecolors)) {

src/_contour_wrapper.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "src/_contour.h"
22
#include "src/mplutils.h"
3+
#include "src/py_converters.h"
34
#include "src/py_exceptions.h"
45

56
/* QuadContourGenerator */
@@ -29,15 +30,15 @@ static int PyQuadContourGenerator_init(PyQuadContourGenerator* self, PyObject* a
2930
{
3031
QuadContourGenerator::CoordinateArray x, y, z;
3132
QuadContourGenerator::MaskArray mask;
32-
int corner_mask;
33+
bool corner_mask;
3334
long chunk_size;
3435

35-
if (!PyArg_ParseTuple(args, "O&O&O&O&il",
36+
if (!PyArg_ParseTuple(args, "O&O&O&O&O&l",
3637
&x.converter_contiguous, &x,
3738
&y.converter_contiguous, &y,
3839
&z.converter_contiguous, &z,
3940
&mask.converter_contiguous, &mask,
40-
&corner_mask,
41+
&convert_bool, &corner_mask,
4142
&chunk_size)) {
4243
return -1;
4344
}

src/_image_wrapper.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs)
119119
PyObject *py_output_array = NULL;
120120
PyObject *py_transform = NULL;
121121
resample_params_t params;
122-
int resample_;
123-
int norm_;
124122

125123
PyArrayObject *input_array = NULL;
126124
PyArrayObject *output_array = NULL;
@@ -133,10 +131,10 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs)
133131
"resample", "alpha", "norm", "radius", NULL };
134132

135133
if (!PyArg_ParseTupleAndKeywords(
136-
args, kwargs, "OOO|iidid:resample", (char **)kwlist,
134+
args, kwargs, "OOO|iO&dO&d:resample", (char **)kwlist,
137135
&py_input_array, &py_output_array, &py_transform,
138-
&params.interpolation, &resample_, &params.alpha, &norm_,
139-
&params.radius)) {
136+
&params.interpolation, &convert_bool, &params.resample,
137+
&params.alpha, &convert_bool, &params.norm, &params.radius)) {
140138
return NULL;
141139
}
142140

@@ -146,9 +144,6 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs)
146144
goto error;
147145
}
148146

149-
params.resample = (resample_ != 0);
150-
params.norm = (norm_ != 0);
151-
152147
input_array = (PyArrayObject *)PyArray_FromAny(
153148
py_input_array, NULL, 2, 3, NPY_ARRAY_C_CONTIGUOUS, NULL);
154149
if (input_array == NULL) {

src/_path_wrapper.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,12 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO
310310
numpy::array_view<const double, 3> transforms;
311311
numpy::array_view<const double, 2> offsets;
312312
agg::trans_affine offset_trans;
313-
int filled;
313+
bool filled;
314314
e_offset_position offset_position;
315315
std::vector<int> result;
316316

317317
if (!PyArg_ParseTuple(args,
318-
"dddO&OO&O&O&iO&:point_in_path_collection",
318+
"dddO&OO&O&O&O&O&:point_in_path_collection",
319319
&x,
320320
&y,
321321
&radius,
@@ -328,6 +328,7 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO
328328
&offsets,
329329
&convert_trans_affine,
330330
&offset_trans,
331+
&convert_bool,
331332
&filled,
332333
&convert_offset_position,
333334
&offset_position)) {
@@ -402,15 +403,16 @@ static PyObject *Py_clip_path_to_rect(PyObject *self, PyObject *args, PyObject *
402403
{
403404
py::PathIterator path;
404405
agg::rect_d rect;
405-
int inside;
406+
bool inside;
406407
std::vector<Polygon> result;
407408

408409
if (!PyArg_ParseTuple(args,
409-
"O&O&i:clip_path_to_rect",
410+
"O&O&O&:clip_path_to_rect",
410411
&convert_path,
411412
&path,
412413
&convert_rect,
413414
&rect,
415+
&convert_bool,
414416
&inside)) {
415417
return NULL;
416418
}
@@ -527,20 +529,21 @@ static PyObject *Py_path_intersects_rectangle(PyObject *self, PyObject *args, Py
527529
{
528530
py::PathIterator path;
529531
double rect_x1, rect_y1, rect_x2, rect_y2;
530-
int filled = 0;
532+
bool filled = false;
531533
const char *names[] = { "path", "rect_x1", "rect_y1", "rect_x2", "rect_y2", "filled", NULL };
532534
bool result;
533535

534536
if (!PyArg_ParseTupleAndKeywords(args,
535537
kwds,
536-
"O&dddd|i:path_intersects_rectangle",
538+
"O&dddd|O&:path_intersects_rectangle",
537539
(char **)names,
538540
&convert_path,
539541
&path,
540542
&rect_x1,
541543
&rect_y1,
542544
&rect_x2,
543545
&rect_y2,
546+
&convert_bool,
544547
&filled)) {
545548
return NULL;
546549
}
@@ -594,28 +597,30 @@ static PyObject *Py_cleanup_path(PyObject *self, PyObject *args, PyObject *kwds)
594597
{
595598
py::PathIterator path;
596599
agg::trans_affine trans;
597-
int remove_nans;
600+
bool remove_nans;
598601
agg::rect_d clip_rect;
599602
e_snap_mode snap_mode;
600603
double stroke_width;
601604
PyObject *simplifyobj;
602605
bool simplify = false;
603-
int return_curves;
606+
bool return_curves;
604607
SketchParams sketch;
605608

606609
if (!PyArg_ParseTuple(args,
607-
"O&O&iO&O&dOiO&:cleanup_path",
610+
"O&O&O&O&O&dOO&O&:cleanup_path",
608611
&convert_path,
609612
&path,
610613
&convert_trans_affine,
611614
&trans,
615+
&convert_bool,
612616
&remove_nans,
613617
&convert_rect,
614618
&clip_rect,
615619
&convert_snap,
616620
&snap_mode,
617621
&stroke_width,
618622
&simplifyobj,
623+
&convert_bool,
619624
&return_curves,
620625
&convert_sketch_params,
621626
&sketch)) {
@@ -675,14 +680,14 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
675680
int precision;
676681
PyObject *codesobj;
677682
char *codes[5];
678-
int postfix;
683+
bool postfix;
679684
char *buffer = NULL;
680685
size_t buffersize;
681686
PyObject *result;
682687
int status;
683688

684689
if (!PyArg_ParseTuple(args,
685-
"O&O&O&OO&iOi:convert_to_string",
690+
"O&O&O&OO&iOO&:convert_to_string",
686691
&convert_path,
687692
&path,
688693
&convert_trans_affine,
@@ -694,6 +699,7 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
694699
&sketch,
695700
&precision,
696701
&codesobj,
702+
&convert_bool,
697703
&postfix)) {
698704
return NULL;
699705
}
@@ -727,7 +733,7 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
727733
CALL_CPP("convert_to_string",
728734
(status = convert_to_string(
729735
path, trans, cliprect, simplify, sketch,
730-
precision, codes, (bool)postfix, &buffer,
736+
precision, codes, postfix, &buffer,
731737
&buffersize)));
732738

733739
if (status) {

src/ft2font_wrapper.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "mplutils.h"
22
#include "ft2font.h"
33
#include "file_compat.h"
4+
#include "py_converters.h"
45
#include "py_exceptions.h"
56
#include "numpy_cpp.h"
67

@@ -829,11 +830,11 @@ const char *PyFT2Font_draw_glyphs_to_bitmap__doc__ =
829830

830831
static PyObject *PyFT2Font_draw_glyphs_to_bitmap(PyFT2Font *self, PyObject *args, PyObject *kwds)
831832
{
832-
int antialiased = 1;
833+
bool antialiased = true;
833834
const char *names[] = { "antialiased", NULL };
834835

835-
if (!PyArg_ParseTupleAndKeywords(
836-
args, kwds, "|i:draw_glyphs_to_bitmap", (char **)names, &antialiased)) {
836+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&:draw_glyphs_to_bitmap",
837+
(char **)names, &convert_bool, &antialiased)) {
837838
return NULL;
838839
}
839840

@@ -849,11 +850,12 @@ const char *PyFT2Font_get_xys__doc__ =
849850

850851
static PyObject *PyFT2Font_get_xys(PyFT2Font *self, PyObject *args, PyObject *kwds)
851852
{
852-
int antialiased = 1;
853+
bool antialiased = true;
853854
std::vector<double> xys;
854855
const char *names[] = { "antialiased", NULL };
855856

856-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:get_xys", (char **)names, &antialiased)) {
857+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&:get_xys",
858+
(char **)names, &convert_bool, &antialiased)) {
857859
return NULL;
858860
}
859861

@@ -879,19 +881,20 @@ static PyObject *PyFT2Font_draw_glyph_to_bitmap(PyFT2Font *self, PyObject *args,
879881
PyFT2Image *image;
880882
double xd, yd;
881883
PyGlyph *glyph;
882-
int antialiased = 1;
884+
bool antialiased = true;
883885
const char *names[] = { "image", "x", "y", "glyph", "antialiased", NULL };
884886

885887
if (!PyArg_ParseTupleAndKeywords(args,
886888
kwds,
887-
"O!ddO!|i:draw_glyph_to_bitmap",
889+
"O!ddO!|O&:draw_glyph_to_bitmap",
888890
(char **)names,
889891
&PyFT2ImageType,
890892
&image,
891893
&xd,
892894
&yd,
893895
&PyGlyphType,
894896
&glyph,
897+
&convert_bool,
895898
&antialiased)) {
896899
return NULL;
897900
}

0 commit comments

Comments
 (0)
0