Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some minor warnings in extensions #7514

Merged
merged 7 commits into from Nov 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions extern/agg24-svn/include/agg_span_gouraud_rgba.h
Expand Up @@ -198,10 +198,10 @@ namespace agg
vg = g.y();
vb = b.y();
va = a.y();
if(vr < 0) vr = 0; if(vr > lim) vr = lim;
if(vg < 0) vg = 0; if(vg > lim) vg = lim;
if(vb < 0) vb = 0; if(vb > lim) vb = lim;
if(va < 0) va = 0; if(va > lim) va = lim;
if(vr < 0) { vr = 0; }; if(vr > lim) { vr = lim; };
if(vg < 0) { vg = 0; }; if(vg > lim) { vg = lim; };
if(vb < 0) { vb = 0; }; if(vb > lim) { vb = lim; };
if(va < 0) { va = 0; }; if(va > lim) { va = lim; };
span->r = (value_type)vr;
span->g = (value_type)vg;
span->b = (value_type)vb;
Expand Down Expand Up @@ -245,10 +245,10 @@ namespace agg
vg = g.y();
vb = b.y();
va = a.y();
if(vr < 0) vr = 0; if(vr > lim) vr = lim;
if(vg < 0) vg = 0; if(vg > lim) vg = lim;
if(vb < 0) vb = 0; if(vb > lim) vb = lim;
if(va < 0) va = 0; if(va > lim) va = lim;
if(vr < 0) { vr = 0; }; if(vr > lim) { vr = lim; };
if(vg < 0) { vg = 0; }; if(vg > lim) { vg = lim; };
if(vb < 0) { vb = 0; }; if(vb > lim) { vb = lim; };
if(va < 0) { va = 0; }; if(va > lim) { va = lim; };
span->r = (value_type)vr;
span->g = (value_type)vg;
span->b = (value_type)vb;
Expand Down
10 changes: 7 additions & 3 deletions setupext.py
Expand Up @@ -3,6 +3,7 @@
from distutils import sysconfig
from distutils import version
from distutils.core import Extension
import distutils.command.build_ext
import glob
import multiprocessing
import os
Expand Down Expand Up @@ -228,8 +229,8 @@ def print_line(*args, **kwargs):
print_status = print_message = print_raw = print_line


# Remove the -Wstrict-prototypesoption, is it's not valid for C++
customize_compiler = sysconfig.customize_compiler
# Remove the -Wstrict-prototypes option, is it's not valid for C++
customize_compiler = distutils.command.build_ext.customize_compiler


def my_customize_compiler(compiler):
Expand All @@ -240,7 +241,7 @@ def my_customize_compiler(compiler):
pass
return retval

sysconfig.customize_compiler = my_customize_compiler
distutils.command.build_ext.customize_compiler = my_customize_compiler


def make_extension(name, files, *args, **kwargs):
Expand Down Expand Up @@ -897,6 +898,9 @@ def add_flags(self, ext):
ext.define_macros.append(('NPY_NO_DEPRECATED_API',
'NPY_1_7_API_VERSION'))

# Allow NumPy's printf format specifiers in C++.
ext.define_macros.append(('__STDC_FORMAT_MACROS', 1))

def get_setup_requires(self):
return ['numpy>=1.7.1']

Expand Down
10 changes: 5 additions & 5 deletions src/_backend_agg_wrapper.cpp
Expand Up @@ -459,14 +459,14 @@ PyRendererAgg_draw_gouraud_triangle(PyRendererAgg *self, PyObject *args, PyObjec

if (points.dim(0) != 3 || points.dim(1) != 2) {
PyErr_Format(PyExc_ValueError,
"points must be a 3x2 array, got %dx%d",
"points must be a 3x2 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT,
points.dim(0), points.dim(1));
return NULL;
}

if (colors.dim(0) != 3 || colors.dim(1) != 4) {
PyErr_Format(PyExc_ValueError,
"colors must be a 3x4 array, got %dx%d",
"colors must be a 3x4 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT,
colors.dim(0), colors.dim(1));
return NULL;
}
Expand Down Expand Up @@ -500,21 +500,21 @@ PyRendererAgg_draw_gouraud_triangles(PyRendererAgg *self, PyObject *args, PyObje

if (points.size() != 0 && (points.dim(1) != 3 || points.dim(2) != 2)) {
PyErr_Format(PyExc_ValueError,
"points must be a Nx3x2 array, got %dx%dx%d",
"points must be a Nx3x2 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT "x%" NPY_INTP_FMT,
points.dim(0), points.dim(1), points.dim(2));
return NULL;
}

if (colors.size() != 0 && (colors.dim(1) != 3 || colors.dim(2) != 4)) {
PyErr_Format(PyExc_ValueError,
"colors must be a Nx3x4 array, got %dx%dx%d",
"colors must be a Nx3x4 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT "x%" NPY_INTP_FMT,
colors.dim(0), colors.dim(1), colors.dim(2));
return NULL;
}

if (points.size() != colors.size()) {
PyErr_Format(PyExc_ValueError,
"points and colors arrays must be the same length, got %d and %d",
"points and colors arrays must be the same length, got %" NPY_INTP_FMT " and %" NPY_INTP_FMT,
points.dim(0), colors.dim(0));
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions src/_gtkagg.cpp
@@ -1,10 +1,10 @@
/* -*- mode: c++; c-basic-offset: 4 -*- */

#include <vector>

#include <pygobject.h>
#include <pygtk/pygtk.h>

#include <vector>

#include "agg_basics.h"
#include "agg_pixfmt_rgba.h"
#include "agg_renderer_base.h"
Expand Down
2 changes: 1 addition & 1 deletion src/_image_wrapper.cpp
Expand Up @@ -273,7 +273,7 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs)
} else {
PyErr_Format(
PyExc_ValueError,
"If 3-dimensional, array must be RGBA. Got %d planes.",
"If 3-dimensional, array must be RGBA. Got %" NPY_INTP_FMT " planes.",
PyArray_DIM(input_array, 2));
goto error;
}
Expand Down
3 changes: 1 addition & 2 deletions src/_path_wrapper.cpp
Expand Up @@ -8,7 +8,6 @@
PyObject *convert_polygon_vector(std::vector<Polygon> &polygons)
{
PyObject *pyresult = PyList_New(polygons.size());
bool fix_endpoints;

for (size_t i = 0; i < polygons.size(); ++i) {
Polygon poly = polygons[i];
Expand Down Expand Up @@ -202,7 +201,7 @@ static PyObject *Py_update_path_extents(PyObject *self, PyObject *args, PyObject

if (minpos.dim(0) != 2) {
PyErr_Format(PyExc_ValueError,
"minpos must be of length 2, got %d",
"minpos must be of length 2, got %" NPY_INTP_FMT,
minpos.dim(0));
return NULL;
}
Expand Down
8 changes: 4 additions & 4 deletions src/py_converters.cpp
Expand Up @@ -537,7 +537,7 @@ int convert_points(PyObject *obj, void *pointsp)

if (points->dim(1) != 2) {
PyErr_Format(PyExc_ValueError,
"Points must be Nx2 array, got %dx%d",
"Points must be Nx2 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT,
points->dim(0), points->dim(1));
return 0;
}
Expand All @@ -561,7 +561,7 @@ int convert_transforms(PyObject *obj, void *transp)

if (trans->dim(1) != 3 || trans->dim(2) != 3) {
PyErr_Format(PyExc_ValueError,
"Transforms must be Nx3x3 array, got %dx%dx%d",
"Transforms must be Nx3x3 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT "x%" NPY_INTP_FMT,
trans->dim(0), trans->dim(1), trans->dim(2));
return 0;
}
Expand All @@ -585,7 +585,7 @@ int convert_bboxes(PyObject *obj, void *bboxp)

if (bbox->dim(1) != 2 || bbox->dim(2) != 2) {
PyErr_Format(PyExc_ValueError,
"Bbox array must be Nx2x2 array, got %dx%dx%d",
"Bbox array must be Nx2x2 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT "x%" NPY_INTP_FMT,
bbox->dim(0), bbox->dim(1), bbox->dim(2));
return 0;
}
Expand All @@ -609,7 +609,7 @@ int convert_colors(PyObject *obj, void *colorsp)

if (colors->dim(1) != 4) {
PyErr_Format(PyExc_ValueError,
"Colors array must be Nx4 array, got %dx%d",
"Colors array must be Nx4 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT,
colors->dim(0), colors->dim(1));
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/qhull_wrap.c
Expand Up @@ -310,7 +310,7 @@ delaunay(PyObject *self, PyObject *args)

/* Return qhull version string for assistance in debugging. */
static PyObject*
version()
version(void)
{
return PyBytes_FromString(qh_version);
}
Expand Down