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

Skip to content

Commit 4e7360f

Browse files
authored
Some small extension cleanups (#16015)
Some small extension cleanups
2 parents 22ac460 + c7987f1 commit 4e7360f

9 files changed

Lines changed: 48 additions & 70 deletions

src/_backend_agg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ RendererAgg::draw_path(GCAgg &gc, PathIterator &path, agg::trans_affine &trans,
481481

482482
transformed_path_t tpath(path, trans);
483483
nan_removed_t nan_removed(tpath, true, path.has_curves());
484-
clipped_t clipped(nan_removed, clip && !path.has_curves(), width, height);
484+
clipped_t clipped(nan_removed, clip, width, height);
485485
snapped_t snapped(clipped, gc.snap_mode, path.total_vertices(), snapping_linewidth);
486486
simplify_t simplified(snapped, simplify, path.simplify_threshold());
487487
curve_t curve(simplified);
@@ -1006,7 +1006,7 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
10061006

10071007
transformed_path_t tpath(path, trans);
10081008
nan_removed_t nan_removed(tpath, true, has_curves);
1009-
clipped_t clipped(nan_removed, do_clip && !has_curves, width, height);
1009+
clipped_t clipped(nan_removed, do_clip, width, height);
10101010
snapped_t snapped(
10111011
clipped, gc.snap_mode, path.total_vertices(), points_to_pixels(gc.linewidth));
10121012
if (has_curves) {

src/_backend_agg_wrapper.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "mplutils.h"
2+
#include "numpy_cpp.h"
23
#include "py_converters.h"
34
#include "_backend_agg.h"
45

@@ -659,8 +660,6 @@ static PyTypeObject *PyRendererAgg_init_type(PyObject *m, PyTypeObject *type)
659660
return type;
660661
}
661662

662-
extern "C" {
663-
664663
static struct PyModuleDef moduledef = {
665664
PyModuleDef_HEAD_INIT,
666665
"_backend_agg",
@@ -695,5 +694,3 @@ PyMODINIT_FUNC PyInit__backend_agg(void)
695694

696695
return m;
697696
}
698-
699-
} // extern "C"

src/_contour_wrapper.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ static PyTypeObject* PyQuadContourGenerator_init_type(PyObject* m, PyTypeObject*
152152

153153
/* Module */
154154

155-
extern "C" {
156-
157155
static struct PyModuleDef moduledef = {
158156
PyModuleDef_HEAD_INIT,
159157
"_contour",
@@ -184,5 +182,3 @@ PyMODINIT_FUNC PyInit__contour(void)
184182

185183
return m;
186184
}
187-
188-
} // extern "C"

src/_image_wrapper.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "mplutils.h"
22
#include "_image_resample.h"
33
#include "_image.h"
4+
#include "numpy_cpp.h"
45
#include "py_converters.h"
56

67

@@ -433,8 +434,6 @@ static PyMethodDef module_functions[] = {
433434
{NULL}
434435
};
435436

436-
extern "C" {
437-
438437
static struct PyModuleDef moduledef = {
439438
PyModuleDef_HEAD_INIT,
440439
"_image",
@@ -482,5 +481,3 @@ PyMODINIT_FUNC PyInit__image(void)
482481

483482
return m;
484483
}
485-
486-
} // extern "C"

src/_path_wrapper.cpp

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -819,53 +819,50 @@ static PyObject *Py_is_sorted(PyObject *self, PyObject *obj)
819819
}
820820

821821

822-
extern "C" {
823-
824-
static PyMethodDef module_functions[] = {
825-
{"point_in_path", (PyCFunction)Py_point_in_path, METH_VARARGS, Py_point_in_path__doc__},
826-
{"points_in_path", (PyCFunction)Py_points_in_path, METH_VARARGS, Py_points_in_path__doc__},
827-
{"point_on_path", (PyCFunction)Py_point_on_path, METH_VARARGS, Py_point_on_path__doc__},
828-
{"points_on_path", (PyCFunction)Py_points_on_path, METH_VARARGS, Py_points_on_path__doc__},
829-
{"get_path_extents", (PyCFunction)Py_get_path_extents, METH_VARARGS, Py_get_path_extents__doc__},
830-
{"update_path_extents", (PyCFunction)Py_update_path_extents, METH_VARARGS, Py_update_path_extents__doc__},
831-
{"get_path_collection_extents", (PyCFunction)Py_get_path_collection_extents, METH_VARARGS, Py_get_path_collection_extents__doc__},
832-
{"point_in_path_collection", (PyCFunction)Py_point_in_path_collection, METH_VARARGS, Py_point_in_path_collection__doc__},
833-
{"path_in_path", (PyCFunction)Py_path_in_path, METH_VARARGS, Py_path_in_path__doc__},
834-
{"clip_path_to_rect", (PyCFunction)Py_clip_path_to_rect, METH_VARARGS, Py_clip_path_to_rect__doc__},
835-
{"affine_transform", (PyCFunction)Py_affine_transform, METH_VARARGS, Py_affine_transform__doc__},
836-
{"count_bboxes_overlapping_bbox", (PyCFunction)Py_count_bboxes_overlapping_bbox, METH_VARARGS, Py_count_bboxes_overlapping_bbox__doc__},
837-
{"path_intersects_path", (PyCFunction)Py_path_intersects_path, METH_VARARGS|METH_KEYWORDS, Py_path_intersects_path__doc__},
838-
{"path_intersects_rectangle", (PyCFunction)Py_path_intersects_rectangle, METH_VARARGS|METH_KEYWORDS, Py_path_intersects_rectangle__doc__},
839-
{"convert_path_to_polygons", (PyCFunction)Py_convert_path_to_polygons, METH_VARARGS|METH_KEYWORDS, Py_convert_path_to_polygons__doc__},
840-
{"cleanup_path", (PyCFunction)Py_cleanup_path, METH_VARARGS, Py_cleanup_path__doc__},
841-
{"convert_to_string", (PyCFunction)Py_convert_to_string, METH_VARARGS, Py_convert_to_string__doc__},
842-
{"is_sorted", (PyCFunction)Py_is_sorted, METH_O, Py_is_sorted__doc__},
843-
{NULL}
844-
};
845-
846-
static struct PyModuleDef moduledef = {
847-
PyModuleDef_HEAD_INIT,
848-
"_path",
849-
NULL,
850-
0,
851-
module_functions,
852-
NULL,
853-
NULL,
854-
NULL,
855-
NULL
856-
};
857-
858-
PyMODINIT_FUNC PyInit__path(void)
859-
{
860-
PyObject *m;
861-
m = PyModule_Create(&moduledef);
822+
static PyMethodDef module_functions[] = {
823+
{"point_in_path", (PyCFunction)Py_point_in_path, METH_VARARGS, Py_point_in_path__doc__},
824+
{"points_in_path", (PyCFunction)Py_points_in_path, METH_VARARGS, Py_points_in_path__doc__},
825+
{"point_on_path", (PyCFunction)Py_point_on_path, METH_VARARGS, Py_point_on_path__doc__},
826+
{"points_on_path", (PyCFunction)Py_points_on_path, METH_VARARGS, Py_points_on_path__doc__},
827+
{"get_path_extents", (PyCFunction)Py_get_path_extents, METH_VARARGS, Py_get_path_extents__doc__},
828+
{"update_path_extents", (PyCFunction)Py_update_path_extents, METH_VARARGS, Py_update_path_extents__doc__},
829+
{"get_path_collection_extents", (PyCFunction)Py_get_path_collection_extents, METH_VARARGS, Py_get_path_collection_extents__doc__},
830+
{"point_in_path_collection", (PyCFunction)Py_point_in_path_collection, METH_VARARGS, Py_point_in_path_collection__doc__},
831+
{"path_in_path", (PyCFunction)Py_path_in_path, METH_VARARGS, Py_path_in_path__doc__},
832+
{"clip_path_to_rect", (PyCFunction)Py_clip_path_to_rect, METH_VARARGS, Py_clip_path_to_rect__doc__},
833+
{"affine_transform", (PyCFunction)Py_affine_transform, METH_VARARGS, Py_affine_transform__doc__},
834+
{"count_bboxes_overlapping_bbox", (PyCFunction)Py_count_bboxes_overlapping_bbox, METH_VARARGS, Py_count_bboxes_overlapping_bbox__doc__},
835+
{"path_intersects_path", (PyCFunction)Py_path_intersects_path, METH_VARARGS|METH_KEYWORDS, Py_path_intersects_path__doc__},
836+
{"path_intersects_rectangle", (PyCFunction)Py_path_intersects_rectangle, METH_VARARGS|METH_KEYWORDS, Py_path_intersects_rectangle__doc__},
837+
{"convert_path_to_polygons", (PyCFunction)Py_convert_path_to_polygons, METH_VARARGS|METH_KEYWORDS, Py_convert_path_to_polygons__doc__},
838+
{"cleanup_path", (PyCFunction)Py_cleanup_path, METH_VARARGS, Py_cleanup_path__doc__},
839+
{"convert_to_string", (PyCFunction)Py_convert_to_string, METH_VARARGS, Py_convert_to_string__doc__},
840+
{"is_sorted", (PyCFunction)Py_is_sorted, METH_O, Py_is_sorted__doc__},
841+
{NULL}
842+
};
843+
844+
static struct PyModuleDef moduledef = {
845+
PyModuleDef_HEAD_INIT,
846+
"_path",
847+
NULL,
848+
0,
849+
module_functions,
850+
NULL,
851+
NULL,
852+
NULL,
853+
NULL
854+
};
855+
856+
PyMODINIT_FUNC PyInit__path(void)
857+
{
858+
PyObject *m;
859+
m = PyModule_Create(&moduledef);
862860

863-
if (m == NULL) {
864-
return NULL;
865-
}
861+
if (m == NULL) {
862+
return NULL;
863+
}
866864

867-
import_array();
865+
import_array();
868866

869-
return m;
870-
}
867+
return m;
871868
}

src/ft2font_wrapper.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,8 +1708,6 @@ static PyTypeObject *PyFT2Font_init_type(PyObject *m, PyTypeObject *type)
17081708
return type;
17091709
}
17101710

1711-
extern "C" {
1712-
17131711
static struct PyModuleDef moduledef = {
17141712
PyModuleDef_HEAD_INIT,
17151713
"ft2font",
@@ -1812,5 +1810,3 @@ PyMODINIT_FUNC PyInit_ft2font(void)
18121810

18131811
return m;
18141812
}
1815-
1816-
} // extern "C"

src/py_converters.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
#include <Python.h>
17-
#include "numpy_cpp.h"
1817
#include "_backend_agg_basic_types.h"
1918

2019
extern "C" {

src/tri/_tri.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ std::ostream& operator<<(std::ostream& os, const XYZ& xyz)
155155

156156

157157
BoundingBox::BoundingBox()
158-
: empty(true)
158+
: empty(true), lower(0.0, 0.0), upper(0.0, 0.0)
159159
{}
160160

161161
void BoundingBox::add(const XY& point)

src/tri/_tri_wrapper.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,6 @@ static PyTypeObject* PyTrapezoidMapTriFinder_init_type(PyObject* m, PyTypeObject
492492

493493
/* Module */
494494

495-
extern "C" {
496-
497495
static struct PyModuleDef moduledef = {
498496
PyModuleDef_HEAD_INIT,
499497
"_tri",
@@ -530,5 +528,3 @@ PyMODINIT_FUNC PyInit__tri(void)
530528

531529
return m;
532530
}
533-
534-
} // extern "C"

0 commit comments

Comments
 (0)