Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Remove Python 2 code from C extensions#10507

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
anntzer merged 6 commits intomatplotlib:masterfromQuLogic:py3-c-ext
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes fromall 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: 2 additions & 2 deletionslib/matplotlib/tri/_tri.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,8 +60,8 @@
* points below or above (including the same as) the contour level) and 6 that
* do. See the function get_exit_edge for details.
*/
#ifndef_TRI_H
#define_TRI_H
#ifndefMPL_TRI_H
#defineMPL_TRI_H

#include "src/numpy_cpp.h"

Expand Down
24 changes: 4 additions & 20 deletionslib/matplotlib/tri/_tri_wrapper.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -494,7 +494,6 @@ static PyTypeObject* PyTrapezoidMapTriFinder_init_type(PyObject* m, PyTypeObject

extern "C" {

#if PY3K
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_tri",
Expand All@@ -507,44 +506,29 @@ static struct PyModuleDef moduledef = {
NULL
};

#define INITERROR return NULL

PyMODINIT_FUNC PyInit__tri(void)

#else
#define INITERROR return

PyMODINIT_FUNC init_tri(void)
#endif

{
PyObject *m;

#if PY3K
m = PyModule_Create(&moduledef);
#else
m = Py_InitModule3("_tri", NULL, NULL);
#endif

if (m == NULL) {
INITERROR;
return NULL;
}

if (!PyTriangulation_init_type(m, &PyTriangulationType)) {
INITERROR;
return NULL;
}
if (!PyTriContourGenerator_init_type(m, &PyTriContourGeneratorType)) {
INITERROR;
return NULL;
}
if (!PyTrapezoidMapTriFinder_init_type(m, &PyTrapezoidMapTriFinderType)) {
INITERROR;
return NULL;
}

import_array();

#if PY3K
return m;
#endif
}

} // extern "C"
4 changes: 2 additions & 2 deletionssrc/_backend_agg.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,8 +3,8 @@
/* _backend_agg.h
*/

#ifndef__BACKEND_AGG_H__
#define__BACKEND_AGG_H__
#ifndefMPL_BACKEND_AGG_H
#defineMPL_BACKEND_AGG_H

#include <cmath>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletionssrc/_backend_agg_basic_types.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
#ifndef__BACKEND_AGG_BASIC_TYPES_H__
#define__BACKEND_AGG_BASIC_TYPES_H__
#ifndefMPL_BACKEND_AGG_BASIC_TYPES_H
#defineMPL_BACKEND_AGG_BASIC_TYPES_H

/* Contains some simple types from the Agg backend that are also used
by other modules */
Expand Down
31 changes: 5 additions & 26 deletionssrc/_backend_agg_wrapper.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -134,7 +134,7 @@ static PyTypeObject *PyBufferRegion_init_type(PyObject *m, PyTypeObject *type)
type->tp_name = "matplotlib.backends._backend_agg.BufferRegion";
type->tp_basicsize = sizeof(PyBufferRegion);
type->tp_dealloc = (destructor)PyBufferRegion_dealloc;
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_NEWBUFFER;
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
type->tp_methods = methods;
type->tp_new = PyBufferRegion_new;
type->tp_as_buffer = &buffer_procs;
Expand DownExpand Up@@ -586,13 +586,8 @@ PyRendererAgg_get_content_extents(PyRendererAgg *self, PyObject *args, PyObject

static PyObject *PyRendererAgg_buffer_rgba(PyRendererAgg *self, PyObject *args, PyObject *kwds)
{
#if PY3K
return PyBytes_FromStringAndSize((const char *)self->x->pixBuffer,
self->x->get_width() * self->x->get_height() * 4);
#else
return PyBuffer_FromReadWriteMemory(self->x->pixBuffer,
self->x->get_width() * self->x->get_height() * 4);
#endif
}

int PyRendererAgg_get_buffer(PyRendererAgg *self, Py_buffer *buf, int flags)
Expand DownExpand Up@@ -705,7 +700,7 @@ static PyTypeObject *PyRendererAgg_init_type(PyObject *m, PyTypeObject *type)
type->tp_name = "matplotlib.backends._backend_agg.RendererAgg";
type->tp_basicsize = sizeof(PyRendererAgg);
type->tp_dealloc = (destructor)PyRendererAgg_dealloc;
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_NEWBUFFER;
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
type->tp_methods = methods;
type->tp_init = (initproc)PyRendererAgg_init;
type->tp_new = PyRendererAgg_new;
Expand All@@ -724,7 +719,6 @@ static PyTypeObject *PyRendererAgg_init_type(PyObject *m, PyTypeObject *type)

extern "C" {

#if PY3K
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_backend_agg",
Expand All@@ -737,42 +731,27 @@ static struct PyModuleDef moduledef = {
NULL
};

#define INITERROR return NULL

PyMODINIT_FUNC PyInit__backend_agg(void)

#else
#define INITERROR return

PyMODINIT_FUNC init_backend_agg(void)
#endif

{
PyObject *m;

#if PY3K
m = PyModule_Create(&moduledef);
#else
m = Py_InitModule3("_backend_agg", NULL, NULL);
#endif

if (m == NULL) {
INITERROR;
return NULL;
}

import_array();

if (!PyRendererAgg_init_type(m, &PyRendererAggType)) {
INITERROR;
return NULL;
}

if (!PyBufferRegion_init_type(m, &PyBufferRegionType)) {
INITERROR;
return NULL;
}

#if PY3K
return m;
#endif
}

} // extern "C"
4 changes: 2 additions & 2 deletionssrc/_contour.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -139,8 +139,8 @@
* different polygons. The S-most polygon must be started first, then the next
* S-most and so on until the N-most polygon is started in that quad.
*/
#ifndef_CONTOUR_H
#define_CONTOUR_H
#ifndefMPL_CONTOUR_H
#defineMPL_CONTOUR_H

#include "src/numpy_cpp.h"
#include <stdint.h>
Expand Down
20 changes: 2 additions & 18 deletionssrc/_contour_wrapper.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,6 @@ static PyTypeObject* PyQuadContourGenerator_init_type(PyObject* m, PyTypeObject*

extern "C" {

#if PY3K
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_contour",
Expand All@@ -167,38 +166,23 @@ static struct PyModuleDef moduledef = {
NULL
};

#define INITERROR return NULL

PyMODINIT_FUNC PyInit__contour(void)

#else
#define INITERROR return

PyMODINIT_FUNC init_contour(void)
#endif

{
PyObject *m;

#if PY3K
m = PyModule_Create(&moduledef);
#else
m = Py_InitModule3("_contour", NULL, NULL);
#endif

if (m == NULL) {
INITERROR;
return NULL;
}

if (!PyQuadContourGenerator_init_type(m, &PyQuadContourGeneratorType)) {
INITERROR;
return NULL;
}

import_array();

#if PY3K
return m;
#endif
}

} // extern "C"
4 changes: 2 additions & 2 deletionssrc/_image.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,8 +4,8 @@
*
*/

#ifndef_IMAGE_H
#define_IMAGE_H
#ifndefMPL_IMAGE_H
#defineMPL_IMAGE_H

#include <vector>

Expand Down
6 changes: 3 additions & 3 deletionssrc/_image_resample.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
/* -*- mode: c++; c-basic-offset: 4 -*- */

#ifndefRESAMPLE_H
#defineRESAMPLE_H
#ifndefMPL_RESAMPLE_H
#defineMPL_RESAMPLE_H

#include "agg_image_accessors.h"
#include "agg_path_storage.h"
Expand DownExpand Up@@ -1010,4 +1010,4 @@ void resample(
}
}

#endif /*RESAMPLE_H */
#endif /*MPL_RESAMPLE_H */
25 changes: 2 additions & 23 deletionssrc/_image_wrapper.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,11 +4,6 @@
#include "py_converters.h"


#ifndef NPY_1_7_API_VERSION
#define NPY_ARRAY_C_CONTIGUOUS NPY_C_CONTIGUOUS
#endif


/**********************************************************************
* Free functions
* */
Expand DownExpand Up@@ -442,7 +437,6 @@ static PyMethodDef module_functions[] = {

extern "C" {

#if PY3K
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_image",
Expand All@@ -455,27 +449,14 @@ static struct PyModuleDef moduledef = {
NULL
};

#define INITERROR return NULL

PyMODINIT_FUNC PyInit__image(void)

#else
#define INITERROR return

PyMODINIT_FUNC init_image(void)
#endif

{
PyObject *m;

#if PY3K
m = PyModule_Create(&moduledef);
#else
m = Py_InitModule3("_image", module_functions, NULL);
#endif

if (m == NULL) {
INITERROR;
return NULL;
}

if (PyModule_AddIntConstant(m, "NEAREST", NEAREST) ||
Expand All@@ -496,14 +477,12 @@ PyMODINIT_FUNC init_image(void)
PyModule_AddIntConstant(m, "LANCZOS", LANCZOS) ||
PyModule_AddIntConstant(m, "BLACKMAN", BLACKMAN) ||
PyModule_AddIntConstant(m, "_n_interpolation", _n_interpolation)) {
INITERROR;
return NULL;
}

import_array();

#if PY3K
return m;
#endif
}

} // extern "C"
Loading

[8]ページ先頭

©2009-2025 Movatter.jp