Skip to content

Commit 24518d6

Browse files
committed
Change internal utility extension to C++
This requires a minor bit of typecasting as in the `_tkagg.cpp` file. This is a separate commit from the pybind11 change to improve rename detection.
1 parent 7ea11b7 commit 24518d6

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/_c_internal_utils.c renamed to src/_c_internal_utils.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ mpl_display_is_valid(PyObject* module)
2424
// than dlopen().
2525
if (getenv("DISPLAY")
2626
&& (libX11 = dlopen("libX11.so.6", RTLD_LAZY))) {
27+
typedef struct Display* (*XOpenDisplay_t)(char const*);
28+
typedef int (*XCloseDisplay_t)(struct Display*);
2729
struct Display* display = NULL;
28-
struct Display* (* XOpenDisplay)(char const*) =
29-
dlsym(libX11, "XOpenDisplay");
30-
int (* XCloseDisplay)(struct Display*) =
31-
dlsym(libX11, "XCloseDisplay");
30+
XOpenDisplay_t XOpenDisplay = (XOpenDisplay_t)dlsym(libX11, "XOpenDisplay");
31+
XCloseDisplay_t XCloseDisplay = (XCloseDisplay_t)dlsym(libX11, "XCloseDisplay");
3232
if (XOpenDisplay && XCloseDisplay
3333
&& (display = XOpenDisplay(NULL))) {
3434
XCloseDisplay(display);
@@ -44,11 +44,13 @@ mpl_display_is_valid(PyObject* module)
4444
void* libwayland_client;
4545
if (getenv("WAYLAND_DISPLAY")
4646
&& (libwayland_client = dlopen("libwayland-client.so.0", RTLD_LAZY))) {
47+
typedef struct wl_display* (*wl_display_connect_t)(char const*);
48+
typedef void (*wl_display_disconnect_t)(struct wl_display*);
4749
struct wl_display* display = NULL;
48-
struct wl_display* (* wl_display_connect)(char const*) =
49-
dlsym(libwayland_client, "wl_display_connect");
50-
void (* wl_display_disconnect)(struct wl_display*) =
51-
dlsym(libwayland_client, "wl_display_disconnect");
50+
wl_display_connect_t wl_display_connect =
51+
(wl_display_connect_t)dlsym(libwayland_client, "wl_display_connect");
52+
wl_display_disconnect_t wl_display_disconnect =
53+
(wl_display_disconnect_t)dlsym(libwayland_client, "wl_display_disconnect");
5254
if (wl_display_connect && wl_display_disconnect
5355
&& (display = wl_display_connect(NULL))) {
5456
wl_display_disconnect(display);

src/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ extension_data = {
8282
'_c_internal_utils': {
8383
'subdir': 'matplotlib',
8484
'sources': files(
85-
'_c_internal_utils.c',
85+
'_c_internal_utils.cpp',
8686
),
8787
'dependencies': [py3_dep, dl, ole32, shell32, user32],
8888
},

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy