Skip to content

Commit c499de9

Browse files
committed
Remove a bunch of compiler warnings.
svn path=/trunk/matplotlib/; revision=5071
1 parent 5cceb32 commit c499de9

File tree

10 files changed

+213
-206
lines changed

10 files changed

+213
-206
lines changed

CXX/WrapPython.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@
3838
#ifndef __PyCXX_wrap_python_hxx__
3939
#define __PyCXX_wrap_python_hxx__
4040

41+
// pull in python definitions
42+
#include <Python.h>
43+
4144
// On some platforms we have to include time.h to get select defined
4245
#if !defined(__WIN32__) && !defined(WIN32) && !defined(_WIN32) && !defined(_WIN64)
4346
#include <sys/time.h>
4447
#endif
4548

46-
// pull in python definitions
47-
#include <Python.h>
4849

4950
#endif

agg24/src/agg_curves.cpp

+54-52
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Anti-Grain Geometry - Version 2.4
33
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
44
//
5-
// Permission to copy, use, modify, sell and distribute this software
6-
// is granted provided this copyright notice appears in all copies.
5+
// Permission to copy, use, modify, sell and distribute this software
6+
// is granted provided this copyright notice appears in all copies.
77
// This software is provided "as is" without express or implied
88
// warranty, and with no claim as to its suitability for any purpose.
99
//
@@ -29,20 +29,20 @@ namespace agg
2929

3030

3131
//------------------------------------------------------------------------
32-
void curve3_inc::approximation_scale(double s)
33-
{
32+
void curve3_inc::approximation_scale(double s)
33+
{
3434
m_scale = s;
3535
}
3636

3737
//------------------------------------------------------------------------
38-
double curve3_inc::approximation_scale() const
39-
{
38+
double curve3_inc::approximation_scale() const
39+
{
4040
return m_scale;
4141
}
4242

4343
//------------------------------------------------------------------------
44-
void curve3_inc::init(double x1, double y1,
45-
double x2, double y2,
44+
void curve3_inc::init(double x1, double y1,
45+
double x2, double y2,
4646
double x3, double y3)
4747
{
4848
m_start_x = x1;
@@ -55,13 +55,13 @@ namespace agg
5555
double dx2 = x3 - x2;
5656
double dy2 = y3 - y2;
5757

58-
double len = sqrt(dx1 * dx1 + dy1 * dy1) + sqrt(dx2 * dx2 + dy2 * dy2);
58+
double len = sqrt(dx1 * dx1 + dy1 * dy1) + sqrt(dx2 * dx2 + dy2 * dy2);
5959

6060
m_num_steps = uround(len * 0.25 * m_scale);
6161

6262
if(m_num_steps < 4)
6363
{
64-
m_num_steps = 4;
64+
m_num_steps = 4;
6565
}
6666

6767
double subdivide_step = 1.0 / m_num_steps;
@@ -72,7 +72,7 @@ namespace agg
7272

7373
m_saved_fx = m_fx = x1;
7474
m_saved_fy = m_fy = y1;
75-
75+
7676
m_saved_dfx = m_dfx = tmpx + (x2 - x1) * (2.0 * subdivide_step);
7777
m_saved_dfy = m_dfy = tmpy + (y2 - y1) * (2.0 * subdivide_step);
7878

@@ -115,19 +115,19 @@ namespace agg
115115
--m_step;
116116
return path_cmd_line_to;
117117
}
118-
m_fx += m_dfx;
118+
m_fx += m_dfx;
119119
m_fy += m_dfy;
120-
m_dfx += m_ddfx;
121-
m_dfy += m_ddfy;
120+
m_dfx += m_ddfx;
121+
m_dfy += m_ddfy;
122122
*x = m_fx;
123123
*y = m_fy;
124124
--m_step;
125125
return path_cmd_line_to;
126126
}
127127

128128
//------------------------------------------------------------------------
129-
void curve3_div::init(double x1, double y1,
130-
double x2, double y2,
129+
void curve3_div::init(double x1, double y1,
130+
double x2, double y2,
131131
double x3, double y3)
132132
{
133133
m_points.remove_all();
@@ -138,19 +138,19 @@ namespace agg
138138
}
139139

140140
//------------------------------------------------------------------------
141-
void curve3_div::recursive_bezier(double x1, double y1,
142-
double x2, double y2,
141+
void curve3_div::recursive_bezier(double x1, double y1,
142+
double x2, double y2,
143143
double x3, double y3,
144144
unsigned level)
145145
{
146-
if(level > curve_recursion_limit)
146+
if(level > curve_recursion_limit)
147147
{
148148
return;
149149
}
150150

151151
// Calculate all the mid-points of the line segments
152152
//----------------------
153-
double x12 = (x1 + x2) / 2;
153+
double x12 = (x1 + x2) / 2;
154154
double y12 = (y1 + y2) / 2;
155155
double x23 = (x2 + x3) / 2;
156156
double y23 = (y2 + y3) / 2;
@@ -163,7 +163,7 @@ namespace agg
163163
double da;
164164

165165
if(d > curve_collinearity_epsilon)
166-
{
166+
{
167167
// Regular case
168168
//-----------------
169169
if(d * d <= m_distance_tolerance_square * (dx*dx + dy*dy))
@@ -187,7 +187,7 @@ namespace agg
187187
// Finally we can stop the recursion
188188
//----------------------
189189
m_points.add(point_d(x123, y123));
190-
return;
190+
return;
191191
}
192192
}
193193
}
@@ -222,13 +222,13 @@ namespace agg
222222

223223
// Continue subdivision
224224
//----------------------
225-
recursive_bezier(x1, y1, x12, y12, x123, y123, level + 1);
226-
recursive_bezier(x123, y123, x23, y23, x3, y3, level + 1);
225+
recursive_bezier(x1, y1, x12, y12, x123, y123, level + 1);
226+
recursive_bezier(x123, y123, x23, y23, x3, y3, level + 1);
227227
}
228228

229229
//------------------------------------------------------------------------
230-
void curve3_div::bezier(double x1, double y1,
231-
double x2, double y2,
230+
void curve3_div::bezier(double x1, double y1,
231+
double x2, double y2,
232232
double x3, double y3)
233233
{
234234
m_points.add(point_d(x1, y1));
@@ -241,23 +241,25 @@ namespace agg
241241

242242

243243
//------------------------------------------------------------------------
244-
void curve4_inc::approximation_scale(double s)
245-
{
244+
void curve4_inc::approximation_scale(double s)
245+
{
246246
m_scale = s;
247247
}
248248

249249
//------------------------------------------------------------------------
250-
double curve4_inc::approximation_scale() const
251-
{
250+
double curve4_inc::approximation_scale() const
251+
{
252252
return m_scale;
253253
}
254254

255255
//------------------------------------------------------------------------
256+
#if defined(_MSC_VER) && _MSC_VER <= 1200
256257
static double MSC60_fix_ICE(double v) { return v; }
258+
#endif
257259

258260
//------------------------------------------------------------------------
259-
void curve4_inc::init(double x1, double y1,
260-
double x2, double y2,
261+
void curve4_inc::init(double x1, double y1,
262+
double x2, double y2,
261263
double x3, double y3,
262264
double x4, double y4)
263265
{
@@ -273,8 +275,8 @@ namespace agg
273275
double dx3 = x4 - x3;
274276
double dy3 = y4 - y3;
275277

276-
double len = (sqrt(dx1 * dx1 + dy1 * dy1) +
277-
sqrt(dx2 * dx2 + dy2 * dy2) +
278+
double len = (sqrt(dx1 * dx1 + dy1 * dy1) +
279+
sqrt(dx2 * dx2 + dy2 * dy2) +
278280
sqrt(dx3 * dx3 + dy3 * dy3)) * 0.25 * m_scale;
279281

280282
#if defined(_MSC_VER) && _MSC_VER <= 1200
@@ -285,7 +287,7 @@ namespace agg
285287

286288
if(m_num_steps < 4)
287289
{
288-
m_num_steps = 4;
290+
m_num_steps = 4;
289291
}
290292

291293
double subdivide_step = 1.0 / m_num_steps;
@@ -296,7 +298,7 @@ namespace agg
296298
double pre2 = 3.0 * subdivide_step2;
297299
double pre4 = 6.0 * subdivide_step2;
298300
double pre5 = 6.0 * subdivide_step3;
299-
301+
300302
double tmp1x = x1 - x2 * 2.0 + x3;
301303
double tmp1y = y1 - y2 * 2.0 + y3;
302304

@@ -357,10 +359,10 @@ namespace agg
357359

358360
m_fx += m_dfx;
359361
m_fy += m_dfy;
360-
m_dfx += m_ddfx;
361-
m_dfy += m_ddfy;
362-
m_ddfx += m_dddfx;
363-
m_ddfy += m_dddfy;
362+
m_dfx += m_ddfx;
363+
m_dfy += m_ddfy;
364+
m_ddfx += m_dddfx;
365+
m_ddfy += m_dddfy;
364366

365367
*x = m_fx;
366368
*y = m_fy;
@@ -372,8 +374,8 @@ namespace agg
372374

373375

374376
//------------------------------------------------------------------------
375-
void curve4_div::init(double x1, double y1,
376-
double x2, double y2,
377+
void curve4_div::init(double x1, double y1,
378+
double x2, double y2,
377379
double x3, double y3,
378380
double x4, double y4)
379381
{
@@ -385,13 +387,13 @@ namespace agg
385387
}
386388

387389
//------------------------------------------------------------------------
388-
void curve4_div::recursive_bezier(double x1, double y1,
389-
double x2, double y2,
390-
double x3, double y3,
390+
void curve4_div::recursive_bezier(double x1, double y1,
391+
double x2, double y2,
392+
double x3, double y3,
391393
double x4, double y4,
392394
unsigned level)
393395
{
394-
if(level > curve_recursion_limit)
396+
if(level > curve_recursion_limit)
395397
{
396398
return;
397399
}
@@ -542,7 +544,7 @@ namespace agg
542544
}
543545
break;
544546

545-
case 3:
547+
case 3:
546548
// Regular case
547549
//-----------------
548550
if((d2 + d3)*(d2 + d3) <= m_distance_tolerance_square * (dx*dx + dy*dy))
@@ -592,14 +594,14 @@ namespace agg
592594

593595
// Continue subdivision
594596
//----------------------
595-
recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1);
596-
recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1);
597+
recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1);
598+
recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1);
597599
}
598600

599601
//------------------------------------------------------------------------
600-
void curve4_div::bezier(double x1, double y1,
601-
double x2, double y2,
602-
double x3, double y3,
602+
void curve4_div::bezier(double x1, double y1,
603+
double x2, double y2,
604+
double x3, double y3,
603605
double x4, double y4)
604606
{
605607
m_points.add(point_d(x1, y1));

src/_backend_agg.cpp

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
/* A rewrite of _backend_agg using PyCXX to handle ref counting, etc..
22
*/
3+
#include <png.h>
4+
5+
// To remove a gcc warning
6+
#ifdef _POSIX_C_SOURCE
7+
#undef _POSIX_C_SOURCE
8+
#endif
9+
10+
#include "ft2font.h"
11+
#include "_image.h"
12+
#include "_backend_agg.h"
13+
#include "mplutils.h"
314

415
#include <iostream>
516
#include <fstream>
617
#include <cmath>
718
#include <cstdio>
819
#include <stdexcept>
9-
#include <png.h>
1020
#include <time.h>
1121
#include <algorithm>
1222

@@ -23,11 +33,6 @@
2333
#include "agg_conv_shorten_path.h"
2434
#include "util/agg_color_conv_rgb8.h"
2535

26-
#include "ft2font.h"
27-
#include "_image.h"
28-
#include "_backend_agg.h"
29-
#include "mplutils.h"
30-
3136
#include "swig_runtime.h"
3237
#include "MPL_isnan.h"
3338

@@ -295,8 +300,8 @@ RendererAgg::_get_rgba_face(const Py::Object& rgbFace, double alpha) {
295300

296301
SnapData
297302
SafeSnap::snap (const float& x, const float& y) {
298-
xsnap = (int)x + 0.5;
299-
ysnap = (int)y + 0.5;
303+
xsnap = (int)(x + 0.5f);
304+
ysnap = (int)(y + 0.5f);
300305

301306
if ( first || ( (xsnap!=lastxsnap) || (ysnap!=lastysnap) ) ) {
302307
lastxsnap = xsnap;
@@ -737,8 +742,8 @@ RendererAgg::draw_image(const Py::Tuple& args) {
737742

738743
args.verify_length(4, 6);
739744

740-
float x = Py::Float(args[0]);
741-
float y = Py::Float(args[1]);
745+
double x = Py::Float(args[0]);
746+
double y = Py::Float(args[1]);
742747
Image *image = static_cast<Image*>(args[2].ptr());
743748
Py::Object box_obj = args[3];
744749
Py::Object clippath;

src/_gtkagg.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#include <pygobject.h>
2+
#include <pygtk/pygtk.h>
3+
14
#include <cstring>
25
#include <cerrno>
36
#include <cstdio>
@@ -6,10 +9,6 @@
69
#include <utility>
710
#include <fstream>
811

9-
10-
#include <pygobject.h>
11-
#include <pygtk/pygtk.h>
12-
1312
#include "agg_basics.h"
1413
#include "_backend_agg.h"
1514
#define PY_ARRAY_TYPES_PREFIX NumPy

0 commit comments

Comments
 (0)