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

Skip to content

Commit 7327d13

Browse files
Neilmdboom
Neil
authored andcommitted
Add explicit casts so converting from Py::Long to size_t works on 32bit machines
1 parent 6a7a7e5 commit 7327d13

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/_backend_agg.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Py::Object
108108
BufferRegion::set_x(const Py::Tuple &args)
109109
{
110110
args.verify_length(1);
111-
size_t x = Py::Int(args[0]);
111+
size_t x = (long) Py::Int(args[0]);
112112
rect.x1 = x;
113113
return Py::Object();
114114
}
@@ -118,7 +118,7 @@ Py::Object
118118
BufferRegion::set_y(const Py::Tuple &args)
119119
{
120120
args.verify_length(1);
121-
size_t y = Py::Int(args[0]);
121+
size_t y = (long)Py::Int(args[0]);
122122
rect.y1 = y;
123123
return Py::Object();
124124
}
@@ -1732,16 +1732,16 @@ RendererAgg::draw_quad_mesh(const Py::Tuple& args)
17321732

17331733
//segments, trans, clipbox, colors, linewidths, antialiaseds
17341734
GCAgg gc(args[0], dpi);
1735-
agg::trans_affine master_transform = py_to_agg_transformation_matrix(args[1].ptr());
1736-
size_t mesh_width = Py::Int(args[2]);
1737-
size_t mesh_height = Py::Int(args[3]);
1738-
Py::Object coordinates = args[4];
1739-
Py::Object offsets_obj = args[5];
1740-
agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[6].ptr());
1741-
Py::Object facecolors_obj = args[7];
1742-
bool antialiased = (bool)Py::Int(args[8]);
1743-
bool showedges = (bool)Py::Int(args[9]);
1744-
bool free_edgecolors = false;
1735+
agg::trans_affine master_transform = py_to_agg_transformation_matrix(args[1].ptr());
1736+
size_t mesh_width = (long)Py::Int(args[2]);
1737+
size_t mesh_height = (long)Py::Int(args[3]);
1738+
Py::Object coordinates = args[4];
1739+
Py::Object offsets_obj = args[5];
1740+
agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[6].ptr());
1741+
Py::Object facecolors_obj = args[7];
1742+
bool antialiased = (bool)Py::Boolean(args[8]);
1743+
bool showedges = (bool)Py::Boolean(args[9]);
1744+
bool free_edgecolors = false;
17451745

17461746
QuadMeshGenerator path_generator(mesh_width, mesh_height, coordinates.ptr());
17471747

src/_image.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ Image::set_interpolation(const Py::Tuple& args)
668668

669669
args.verify_length(1);
670670

671-
size_t method = Py::Int(args[0]);
671+
size_t method = (long)Py::Int(args[0]);
672672
interpolation = (unsigned)method;
673673
return Py::Object();
674674
}
@@ -702,7 +702,7 @@ Image::set_aspect(const Py::Tuple& args)
702702
_VERBOSE("Image::set_aspect");
703703

704704
args.verify_length(1);
705-
size_t method = Py::Int(args[0]);
705+
size_t method = (long)Py::Int(args[0]);
706706
aspect = (unsigned)method;
707707
return Py::Object();
708708

@@ -756,8 +756,8 @@ _image_module::from_images(const Py::Tuple& args)
756756

757757
args.verify_length(3);
758758

759-
size_t numrows = (size_t)Py::Int(args[0]);
760-
size_t numcols = (size_t)Py::Int(args[1]);
759+
size_t numrows = (long)Py::Int(args[0]);
760+
size_t numcols = (long)Py::Int(args[1]);
761761

762762
if (numrows >= 32768 || numcols >= 32768)
763763
{
@@ -800,8 +800,8 @@ _image_module::from_images(const Py::Tuple& args)
800800
{
801801
tup = Py::Tuple(tups[imnum]);
802802
Image* thisim = static_cast<Image*>(tup[0].ptr());
803-
ox = Py::Int(tup[1]);
804-
oy = Py::Int(tup[2]);
803+
ox = (long)Py::Int(tup[1]);
804+
oy = (long)Py::Int(tup[2]);
805805
bool isflip = (thisim->rbufOut->stride()) < 0;
806806
//std::cout << "from images " << isflip << "; stride=" << thisim->rbufOut->stride() << std::endl;
807807
size_t ind = 0;
@@ -1171,8 +1171,8 @@ _image_module::frombuffer(const Py::Tuple& args)
11711171
args.verify_length(4);
11721172

11731173
PyObject *bufin = new_reference_to(args[0]);
1174-
size_t x = Py::Int(args[1]);
1175-
size_t y = Py::Int(args[2]);
1174+
size_t x = (long)Py::Int(args[1]);
1175+
size_t y = (long)Py::Int(args[2]);
11761176

11771177
if (x >= 32768 || y >= 32768)
11781178
{

0 commit comments

Comments
 (0)