Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,11 +1363,13 @@ def check(self):

def get_extension(self):
sources = [
'src/_tkagg.cpp'
'src/_tkagg.cpp',
'src/py_converters.cpp',
]

ext = make_extension('matplotlib.backends._tkagg', sources)
self.add_flags(ext)
Numpy().add_flags(ext)
LibAgg().add_flags(ext, add_sources=False)
return ext

Expand Down
8 changes: 5 additions & 3 deletions src/_tkagg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// Include our own excerpts from the Tcl / Tk headers
#include "_tkmini.h"

#include "py_converters.h"

#if defined(_MSC_VER)
# define IMG_FORMAT "%d %d %Iu"
#else
Expand Down Expand Up @@ -213,9 +215,9 @@ static PyObject *mpl_tk_blit(PyObject *self, PyObject *args)
int x1, x2, y1, y2;
Tk_PhotoHandle photo;
Tk_PhotoImageBlock block;
if (!PyArg_ParseTuple(args, "ns(iin)(iiii)(iiii):blit",
&interp, &photo_name,
&height, &width, &data_ptr,
if (!PyArg_ParseTuple(args, "O&s(iiO&)(iiii)(iiii):blit",
convert_voidptr, &interp, &photo_name,
&height, &width, convert_voidptr, &data_ptr,
&o0, &o1, &o2, &o3,
&x1, &x2, &y1, &y2)) {
goto exit;
Expand Down
7 changes: 7 additions & 0 deletions src/py_converters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ int convert_from_attr(PyObject *obj, const char *name, converter func, void *p)
return 1;
}

int convert_voidptr(PyObject *obj, void *p)
{
void **val = (void **)p;
*val = PyLong_AsVoidPtr(obj);
return *val != NULL ? 1 : !PyErr_Occurred();
}

int convert_double(PyObject *obj, void *p)
{
double *val = (double *)p;
Expand Down
1 change: 1 addition & 0 deletions src/py_converters.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ typedef int (*converter)(PyObject *, void *);
int convert_from_attr(PyObject *obj, const char *name, converter func, void *p);
int convert_from_method(PyObject *obj, const char *name, converter func, void *p);

int convert_voidptr(PyObject *obj, void *p);
int convert_double(PyObject *obj, void *p);
int convert_bool(PyObject *obj, void *p);
int convert_cap(PyObject *capobj, void *capp);
Expand Down