Skip to content

Navigation Menu

Sign in
Appearance settings

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 fb3e899

Browse filesBrowse files
committed
Modifications for work on iOS: don't depend on static function members
1 parent 5ba3911 commit fb3e899
Copy full SHA for fb3e899

8 files changed

+243-1Lines changed: 243 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎setup.cfg‎

Copy file name to clipboard
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Rename this file to setup.cfg to modify Matplotlib's build options.
2+
3+
[metadata]
4+
license_files = LICENSE/*
5+
6+
[egg_info]
7+
8+
[libs]
9+
# By default, Matplotlib builds with LTO, which may be slow if you re-compile
10+
# often, and don't need the space saving/speedup.
11+
#enable_lto = True
12+
# By default, Matplotlib downloads and builds its own copy of FreeType, and
13+
# builds its own copy of Qhull. You may set the following to True to instead
14+
# link against a system FreeType/Qhull.
15+
system_freetype = True
16+
#system_qhull = False
17+
18+
[packages]
19+
# There are a number of data subpackages from Matplotlib that are
20+
# considered optional. All except 'tests' data (meaning the baseline
21+
# image files) are installed by default, but that can be changed here.
22+
tests = False
23+
sample_data = False
24+
25+
[gui_support]
26+
# Matplotlib supports multiple GUI toolkits, known as backends.
27+
# The MacOSX backend requires the Cocoa headers included with XCode.
28+
# You can select whether to build it by uncommenting the following line.
29+
# It is never built on Linux or Windows, regardless of the config value.
30+
#
31+
macosx = False
32+
33+
[rc_options]
34+
# User-configurable options
35+
#
36+
# Default backend, one of: Agg, Cairo, GTK3Agg, GTK3Cairo, MacOSX, Pdf, Ps,
37+
# Qt4Agg, Qt5Agg, SVG, TkAgg, WX, WXAgg.
38+
#
39+
# The Agg, Ps, Pdf and SVG backends do not require external dependencies. Do
40+
# not choose MacOSX if you have disabled the relevant extension modules. The
41+
# default is determined by fallback.
42+
#
43+
#backend = Agg
Collapse file

‎setupext.py‎

Copy file name to clipboardExpand all lines: setupext.py
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,19 @@ class FreeType(SetupPackage):
531531
def add_flags(self, ext):
532532
ext.sources.insert(0, 'src/checkdep_freetype2.c')
533533
if options.get('system_freetype'):
534-
pkg_config_setup_extension(
534+
# iOS: we need to use freetype as a framework, not as a library.
535+
platform = os.getenv('PLATFORM') or 'macosx'
536+
if platform.startswith('iphone'):
537+
pkg_config_setup_extension(
538+
# FreeType 2.3 has libtool version 9.11.3 as can be checked
539+
# from the tarball. For FreeType>=2.4, there is a conversion
540+
# table in docs/VERSIONS.txt in the FreeType source tree.
541+
ext, 'freetype2',
542+
atleast_version='9.11.3',
543+
alt_exec=['freetype-config'],
544+
default_libraries=[])
545+
else:
546+
pkg_config_setup_extension(
535547
# FreeType 2.3 has libtool version 9.11.3 as can be checked
536548
# from the tarball. For FreeType>=2.4, there is a conversion
537549
# table in docs/VERSIONS.txt in the FreeType source tree.
Collapse file

‎src/_backend_agg_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_backend_agg_wrapper.cpp
+66Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ static PyObject *PyRendererAgg_draw_path(PyRendererAgg *self, PyObject *args, Py
227227
Py_RETURN_NONE;
228228
}
229229

230+
#if TARGET_OS_IPHONE
231+
// iOS: need non static member functions. This replaces image.converter_contiguous:
232+
static int (*image2_converter_contiguous)(PyObject *obj, void *arrp) = numpy::numpy_converter_contiguous<agg::int8u, 2>;
233+
#endif
234+
230235
static PyObject *PyRendererAgg_draw_text_image(PyRendererAgg *self, PyObject *args, PyObject *kwds)
231236
{
232237
numpy::array_view<agg::int8u, 2> image;
@@ -237,7 +242,11 @@ static PyObject *PyRendererAgg_draw_text_image(PyRendererAgg *self, PyObject *ar
237242

238243
if (!PyArg_ParseTuple(args,
239244
"O&dddO&:draw_text_image",
245+
#if !TARGET_OS_IPHONE
240246
&image.converter_contiguous,
247+
#else
248+
image2_converter_contiguous,
249+
#endif
241250
&image,
242251
&x,
243252
&y,
@@ -288,6 +297,11 @@ PyObject *PyRendererAgg_draw_markers(PyRendererAgg *self, PyObject *args, PyObje
288297
Py_RETURN_NONE;
289298
}
290299

300+
#if TARGET_OS_IPHONE
301+
// iOS: need non static member functions. This replaces image.converter_contiguous:
302+
static int (*image3_converter_contiguous)(PyObject *obj, void *arrp) = numpy::numpy_converter_contiguous<agg::int8u, 3>;
303+
#endif
304+
291305
static PyObject *PyRendererAgg_draw_image(PyRendererAgg *self, PyObject *args, PyObject *kwds)
292306
{
293307
GCAgg gc;
@@ -301,7 +315,11 @@ static PyObject *PyRendererAgg_draw_image(PyRendererAgg *self, PyObject *args, P
301315
&gc,
302316
&x,
303317
&y,
318+
#if !TARGET_OS_IPHONE
304319
&image.converter_contiguous,
320+
#else
321+
image3_converter_contiguous,
322+
#endif
305323
&image)) {
306324
return NULL;
307325
}
@@ -315,6 +333,12 @@ static PyObject *PyRendererAgg_draw_image(PyRendererAgg *self, PyObject *args, P
315333
Py_RETURN_NONE;
316334
}
317335

336+
#if TARGET_OS_IPHONE
337+
// iOS: need non static member functions. This replaces linewidths.converter and antialiaseds.converter:
338+
static int (*linewidths_converter)(PyObject *, void *) = numpy::numpy_converter<const double, 1>;
339+
static int (*antialiaseds_converter)(PyObject *, void *) = numpy::numpy_converter<const uint8_t, 1>;
340+
#endif
341+
318342
static PyObject *
319343
PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject *kwds)
320344
{
@@ -349,11 +373,19 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject
349373
&facecolors,
350374
&convert_colors,
351375
&edgecolors,
376+
#if !TARGET_OS_IPHONE
352377
&linewidths.converter,
378+
#else
379+
linewidths_converter,
380+
#endif
353381
&linewidths,
354382
&convert_dashes_vector,
355383
&dashes,
384+
#if !TARGET_OS_IPHONE
356385
&antialiaseds.converter,
386+
#else
387+
antialiaseds_converter,
388+
#endif
357389
&antialiaseds,
358390
&ignored,
359391
&convert_offset_position,
@@ -387,6 +419,12 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject
387419
Py_RETURN_NONE;
388420
}
389421

422+
423+
#if TARGET_OS_IPHONE
424+
// iOS: need non static member functions. This replaces coordinates.converter:
425+
int (*coordinates_converter)(PyObject *, void *) = numpy::numpy_converter<const double, 3>;
426+
#endif
427+
390428
static PyObject *PyRendererAgg_draw_quad_mesh(PyRendererAgg *self, PyObject *args, PyObject *kwds)
391429
{
392430
GCAgg gc;
@@ -408,7 +446,11 @@ static PyObject *PyRendererAgg_draw_quad_mesh(PyRendererAgg *self, PyObject *arg
408446
&master_transform,
409447
&mesh_width,
410448
&mesh_height,
449+
#if !TARGET_OS_IPHONE
411450
&coordinates.converter,
451+
#else
452+
coordinates_converter,
453+
#endif
412454
&coordinates,
413455
&convert_points,
414456
&offsets,
@@ -438,6 +480,12 @@ static PyObject *PyRendererAgg_draw_quad_mesh(PyRendererAgg *self, PyObject *arg
438480
Py_RETURN_NONE;
439481
}
440482

483+
#if TARGET_OS_IPHONE
484+
// iOS: need non static member functions. This replaces points.converter and colors.converter:
485+
static int (*points2_converter)(PyObject *, void *) = numpy::numpy_converter<const double, 2>;
486+
static int (*colors2_converter)(PyObject *, void *) = numpy::numpy_converter<const double, 2>;
487+
#endif
488+
441489
static PyObject *
442490
PyRendererAgg_draw_gouraud_triangle(PyRendererAgg *self, PyObject *args, PyObject *kwds)
443491
{
@@ -450,9 +498,15 @@ PyRendererAgg_draw_gouraud_triangle(PyRendererAgg *self, PyObject *args, PyObjec
450498
"O&O&O&O&|O:draw_gouraud_triangle",
451499
&convert_gcagg,
452500
&gc,
501+
#if !TARGET_OS_IPHONE
453502
&points.converter,
454503
&points,
455504
&colors.converter,
505+
#else
506+
points2_converter,
507+
&points,
508+
colors2_converter,
509+
#endif
456510
&colors,
457511
&convert_trans_affine,
458512
&trans)) {
@@ -479,6 +533,12 @@ PyRendererAgg_draw_gouraud_triangle(PyRendererAgg *self, PyObject *args, PyObjec
479533
Py_RETURN_NONE;
480534
}
481535

536+
#if TARGET_OS_IPHONE
537+
// iOS: need non static member functions. This replaces points.converter and colors.converter:
538+
static int (*points3_converter)(PyObject *, void *) = numpy::numpy_converter<const double, 3>;
539+
static int (*colors3_converter)(PyObject *, void *) = numpy::numpy_converter<const double, 3>;
540+
#endif
541+
482542
static PyObject *
483543
PyRendererAgg_draw_gouraud_triangles(PyRendererAgg *self, PyObject *args, PyObject *kwds)
484544
{
@@ -491,9 +551,15 @@ PyRendererAgg_draw_gouraud_triangles(PyRendererAgg *self, PyObject *args, PyObje
491551
"O&O&O&O&|O:draw_gouraud_triangles",
492552
&convert_gcagg,
493553
&gc,
554+
#if !TARGET_OS_IPHONE
494555
&points.converter,
495556
&points,
496557
&colors.converter,
558+
#else
559+
points3_converter,
560+
&points,
561+
colors3_converter,
562+
#endif
497563
&colors,
498564
&convert_trans_affine,
499565
&trans)) {
Collapse file

‎src/_contour_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_contour_wrapper.cpp
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ const char* PyQuadContourGenerator_init__doc__ =
2626
"--\n\n"
2727
"Create a new C++ QuadContourGenerator object\n";
2828

29+
#if TARGET_OS_IPHONE
30+
// iOS: need non static member functions. This replaces x.converter and d.converter_contiguous:
31+
static int (*x_converter_contiguous)(PyObject *, void *) = numpy::numpy_converter_contiguous<const double, 2>;
32+
static int (*mask_converter_contiguous)(PyObject *, void *) = numpy::numpy_converter_contiguous<const bool, 2> ;
33+
#endif
34+
2935
static int PyQuadContourGenerator_init(PyQuadContourGenerator* self, PyObject* args, PyObject* kwds)
3036
{
3137
QuadContourGenerator::CoordinateArray x, y, z;
@@ -34,10 +40,17 @@ static int PyQuadContourGenerator_init(PyQuadContourGenerator* self, PyObject* a
3440
long chunk_size;
3541

3642
if (!PyArg_ParseTuple(args, "O&O&O&O&O&l",
43+
#if !TARGET_OS_IPHONE
3744
&x.converter_contiguous, &x,
3845
&y.converter_contiguous, &y,
3946
&z.converter_contiguous, &z,
4047
&mask.converter_contiguous, &mask,
48+
#else
49+
x_converter_contiguous, &x,
50+
x_converter_contiguous, &y,
51+
x_converter_contiguous, &z,
52+
mask_converter_contiguous, &mask,
53+
#endif
4154
&convert_bool, &corner_mask,
4255
&chunk_size)) {
4356
return -1;
Collapse file

‎src/_image_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_image_wrapper.cpp
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ const char *image_pcolor__doc__ =
299299
"bounds = (x_min, x_max, y_min, y_max)\n"
300300
"interpolation = NEAREST or BILINEAR \n";
301301

302+
#if TARGET_OS_IPHONE
303+
// iOS: need non static member functions. This replaces x.converter and d.converter_contiguous:
304+
static int (*xf_converter)(PyObject *, void *) = numpy::numpy_converter<const float, 1>;
305+
static int (*d_converter_contiguous)(PyObject *, void *) = numpy::numpy_converter_contiguous<const agg::int8u, 3>;
306+
#endif
307+
302308
static PyObject *image_pcolor(PyObject *self, PyObject *args, PyObject *kwds)
303309
{
304310
numpy::array_view<const float, 1> x;
@@ -310,11 +316,19 @@ static PyObject *image_pcolor(PyObject *self, PyObject *args, PyObject *kwds)
310316

311317
if (!PyArg_ParseTuple(args,
312318
"O&O&O&nn(ffff)i:pcolor",
319+
#if !TARGET_OS_IPHONE
313320
&x.converter,
314321
&x,
315322
&y.converter,
316323
&y,
317324
&d.converter_contiguous,
325+
#else
326+
xf_converter,
327+
&x,
328+
xf_converter,
329+
&y,
330+
d_converter_contiguous,
331+
#endif
318332
&d,
319333
&rows,
320334
&cols,
@@ -342,6 +356,12 @@ const char *image_pcolor2__doc__ =
342356
"bounds = (x_left, x_right, y_bot, y_top)\n"
343357
"bg = ndarray of 4 uint8 representing background rgba\n";
344358

359+
#if TARGET_OS_IPHONE
360+
// iOS: need non static member functions. This replaces x.converter_contiguous:
361+
static int (*xd_converter_contiguous)(PyObject *, void *) = numpy::numpy_converter_contiguous<const double, 1>;
362+
static int (*bg_converter)(PyObject *, void *) = numpy::numpy_converter<const agg::int8u, 1>;
363+
#endif
364+
345365
static PyObject *image_pcolor2(PyObject *self, PyObject *args, PyObject *kwds)
346366
{
347367
numpy::array_view<const double, 1> x;
@@ -353,19 +373,31 @@ static PyObject *image_pcolor2(PyObject *self, PyObject *args, PyObject *kwds)
353373

354374
if (!PyArg_ParseTuple(args,
355375
"O&O&O&nn(ffff)O&:pcolor2",
376+
#if !TARGET_OS_IPHONE
356377
&x.converter_contiguous,
357378
&x,
358379
&y.converter_contiguous,
359380
&y,
360381
&d.converter_contiguous,
382+
#else
383+
xd_converter_contiguous,
384+
&x,
385+
xd_converter_contiguous,
386+
&y,
387+
d_converter_contiguous,
388+
#endif
361389
&d,
362390
&rows,
363391
&cols,
364392
&bounds[0],
365393
&bounds[1],
366394
&bounds[2],
367395
&bounds[3],
396+
#if !TARGET_OS_IPHONE
368397
&bg.converter,
398+
#else
399+
bg_converter,
400+
#endif
369401
&bg)) {
370402
return NULL;
371403
}
Collapse file

‎src/_path_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_path_wrapper.cpp
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ static PyObject *Py_get_path_extents(PyObject *self, PyObject *args, PyObject *k
176176
const char *Py_update_path_extents__doc__ =
177177
"update_path_extents(path, trans, rect, minpos, ignore)";
178178

179+
#if TARGET_OS_IPHONE
180+
// iOS: need non static member functions. This replaces minpos.converter:
181+
static int (*minpos_converter)(PyObject *obj, void *arrp) = numpy::numpy_converter<double, 1>;
182+
#endif
183+
179184
static PyObject *Py_update_path_extents(PyObject *self, PyObject *args, PyObject *kwds)
180185
{
181186
py::PathIterator path;
@@ -193,7 +198,11 @@ static PyObject *Py_update_path_extents(PyObject *self, PyObject *args, PyObject
193198
&trans,
194199
&convert_rect,
195200
&rect,
201+
#if !TARGET_OS_IPHONE
196202
&minpos.converter,
203+
#else
204+
minpos_converter,
205+
#endif
197206
&minpos,
198207
&ignore)) {
199208
return NULL;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.