Skip to content

Commit

Permalink
Remove compat.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lazka committed Apr 1, 2020
1 parent 7d5c992 commit f0c0e5a
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 195 deletions.
90 changes: 45 additions & 45 deletions cairo/cairomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ static Pycairo_CAPI_t CAPI = {

static PyObject *
pycairo_cairo_version (PyObject *self, PyObject *ignored) {
return PYCAIRO_PyLong_FromLong (cairo_version());
return PyLong_FromLong (cairo_version());
}

static PyObject *
pycairo_cairo_version_string (PyObject *self, PyObject *ignored) {
return PYCAIRO_PyUnicode_FromString (cairo_version_string());
return PyUnicode_FromString (cairo_version_string());
}

static PyMethodDef cairo_functions[] = {
Expand All @@ -157,134 +157,134 @@ static struct PyModuleDef cairomoduledef = {
0,
};

PYCAIRO_MOD_INIT(_cairo)
PYCAIRO_MODINIT_FUNC PyInit__cairo(void)
{
PyObject *m, *capi;

if (PyType_Ready(&PycairoContext_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoFontFace_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoToyFontFace_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoFontOptions_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoMatrix_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoPath_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
PycairoPathiter_Type.tp_iter=&PyObject_SelfIter;
if (PyType_Ready(&PycairoPathiter_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

if (PyType_Ready(&PycairoPattern_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoSolidPattern_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoSurfacePattern_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoGradient_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoLinearGradient_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoRadialGradient_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoMeshPattern_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoRasterSourcePattern_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

if (PyType_Ready(&PycairoRectangleInt_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

if (PyType_Ready(&PycairoDevice_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

PycairoGlyph_Type.tp_base = &PyTuple_Type;
if (PyType_Ready(&PycairoGlyph_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

PycairoRectangle_Type.tp_base = &PyTuple_Type;
if (PyType_Ready(&PycairoRectangle_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

PycairoTextCluster_Type.tp_base = &PyTuple_Type;
if (PyType_Ready(&PycairoTextCluster_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

PycairoTextExtents_Type.tp_base = &PyTuple_Type;
if (PyType_Ready(&PycairoTextExtents_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

#ifdef CAIRO_HAS_SCRIPT_SURFACE
if (PyType_Ready(&PycairoScriptDevice_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoScriptSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif

if (PyType_Ready(&PycairoRegion_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

if (PyType_Ready(&PycairoScaledFont_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

if (PyType_Ready(&PycairoSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#ifdef CAIRO_HAS_IMAGE_SURFACE
if (PyType_Ready(&PycairoImageSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoMappedImageSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif
#ifdef CAIRO_HAS_PDF_SURFACE
if (PyType_Ready(&PycairoPDFSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif
#ifdef CAIRO_HAS_PS_SURFACE
if (PyType_Ready(&PycairoPSSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif
#ifdef CAIRO_HAS_RECORDING_SURFACE
if (PyType_Ready(&PycairoRecordingSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif
#ifdef CAIRO_HAS_SVG_SURFACE
if (PyType_Ready(&PycairoSVGSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif
#ifdef CAIRO_HAS_WIN32_SURFACE
if (PyType_Ready(&PycairoWin32Surface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
if (PyType_Ready(&PycairoWin32PrintingSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif
#ifdef CAIRO_HAS_XCB_SURFACE
if (PyType_Ready(&PycairoXCBSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif
#ifdef CAIRO_HAS_XLIB_SURFACE
if (PyType_Ready(&PycairoXlibSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif
#ifdef CAIRO_HAS_TEE_SURFACE
if (PyType_Ready(&PycairoTeeSurface_Type) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;
#endif

m = PyModule_Create(&cairomoduledef);

if (m == NULL)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

if(init_error(m) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

if(init_buffer_proxy() < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

if(init_enums(m) < 0)
return PYCAIRO_MOD_ERROR_VAL;
return NULL;

PyModule_AddStringConstant(m, "version",
PYCAIRO_STRINGIFY(PYCAIRO_VERSION_MAJOR) "."
Expand Down Expand Up @@ -554,5 +554,5 @@ PYCAIRO_MOD_INIT(_cairo)
PyModule_AddObject(m, "CAPI", capi);
}

return PYCAIRO_MOD_SUCCESS_VAL(m);
return m;
}
72 changes: 0 additions & 72 deletions cairo/compat.h

This file was deleted.

19 changes: 9 additions & 10 deletions cairo/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ pycairo_tag_begin (PycairoContext *o, PyObject *args) {
const char *attributes;

if (!PyArg_ParseTuple (args,
PYCAIRO_ENC_TEXT_FORMAT PYCAIRO_ENC_TEXT_FORMAT
":Context.tag_begin", "utf-8",
"eses:Context.tag_begin", "utf-8",
&tag_name, "utf-8", &attributes))
return NULL;

Expand All @@ -102,7 +101,7 @@ pycairo_tag_end (PycairoContext *o, PyObject *args) {
const char *tag_name;

if (!PyArg_ParseTuple (args,
PYCAIRO_ENC_TEXT_FORMAT ":Context.tag_end", "utf-8",
"es:Context.tag_end", "utf-8",
&tag_name))
return NULL;

Expand Down Expand Up @@ -394,7 +393,7 @@ pycairo_get_dash (PycairoContext *o, PyObject *ignored) {

static PyObject *
pycairo_get_dash_count (PycairoContext *o, PyObject *ignored) {
return PYCAIRO_PyLong_FromLong (cairo_get_dash_count (o->ctx));
return PyLong_FromLong (cairo_get_dash_count (o->ctx));
}

static PyObject *
Expand Down Expand Up @@ -808,7 +807,7 @@ pycairo_select_font_face (PycairoContext *o, PyObject *args) {
int slant_arg = CAIRO_FONT_SLANT_NORMAL;
int weight_arg = CAIRO_FONT_WEIGHT_NORMAL;

if (!PyArg_ParseTuple (args, PYCAIRO_ENC_TEXT_FORMAT "|ii:Context.select_font_face",
if (!PyArg_ParseTuple (args, "es|ii:Context.select_font_face",
"utf-8", &utf8, &slant_arg, &weight_arg))
return NULL;

Expand Down Expand Up @@ -1138,7 +1137,7 @@ static PyObject *
pycairo_show_text (PycairoContext *o, PyObject *args) {
const char *utf8;

if (!PyArg_ParseTuple (args, PYCAIRO_ENC_TEXT_FORMAT ":Context.show_text", "utf-8", &utf8))
if (!PyArg_ParseTuple (args, "es:Context.show_text", "utf-8", &utf8))
return NULL;

Py_BEGIN_ALLOW_THREADS;
Expand Down Expand Up @@ -1182,7 +1181,7 @@ pycairo_text_extents (PycairoContext *o, PyObject *args) {
const char *utf8;
PyObject *ext_args, *res;

if (!PyArg_ParseTuple (args, PYCAIRO_ENC_TEXT_FORMAT ":Context.text_extents", "utf-8", &utf8))
if (!PyArg_ParseTuple (args, "es:Context.text_extents", "utf-8", &utf8))
return NULL;

cairo_text_extents (o->ctx, utf8, &extents);
Expand All @@ -1200,7 +1199,7 @@ static PyObject *
pycairo_text_path (PycairoContext *o, PyObject *args) {
const char *utf8;

if (!PyArg_ParseTuple (args, PYCAIRO_ENC_TEXT_FORMAT ":Context.text_path", "utf-8", &utf8))
if (!PyArg_ParseTuple (args, "es:Context.text_path", "utf-8", &utf8))
return NULL;

cairo_text_path (o->ctx, utf8);
Expand Down Expand Up @@ -1272,7 +1271,7 @@ pycairo_show_text_glyphs (PycairoContext *o, PyObject *args) {
Py_ssize_t i, clusters_size, glyphs_size;

if (!PyArg_ParseTuple (args,
PYCAIRO_ENC_TEXT_FORMAT "OOi:Context.show_text_glyphs",
"esOOi:Context.show_text_glyphs",
"utf-8", &utf8, &glyphs_arg, &clusters_arg, &cluster_flags_arg))
return NULL;

Expand Down Expand Up @@ -1477,7 +1476,7 @@ pycairo_richcompare (PyObject *self, PyObject *other, int op)
}
}

static PYCAIRO_Py_hash_t
static Py_hash_t
pycairo_hash (PyObject *self)
{
return PYCAIRO_Py_hash_t_FromVoidPtr (((PycairoContext *)self)->ctx);
Expand Down
4 changes: 2 additions & 2 deletions cairo/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ device_richcompare (PyObject *self, PyObject *other, int op)
}
}

static PYCAIRO_Py_hash_t
static Py_hash_t
device_hash (PyObject *self)
{
return PYCAIRO_Py_hash_t_FromVoidPtr (((PycairoDevice *)self)->device);
Expand Down Expand Up @@ -202,7 +202,7 @@ static cairo_status_t
_write_func (void *closure, const unsigned char *data, unsigned int length) {
PyGILState_STATE gstate = PyGILState_Ensure();
PyObject *res = PyObject_CallMethod (
(PyObject *)closure, "write", "(" PYCAIRO_DATA_FORMAT "#)",
(PyObject *)closure, "write", "(y#)",
data, (Py_ssize_t)length);

if (res == NULL) {
Expand Down
Loading

0 comments on commit f0c0e5a

Please sign in to comment.