SOURCES: python-pycairo-new_API.patch (NEW) - API update for cairo...

freetz freetz at pld-linux.org
Wed Jun 21 20:13:40 CEST 2006


Author: freetz                       Date: Wed Jun 21 18:13:40 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- API update for cairo >= 1.1.8

---- Files affected:
SOURCES:
   python-pycairo-new_API.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/python-pycairo-new_API.patch
diff -u /dev/null SOURCES/python-pycairo-new_API.patch:1.1
--- /dev/null	Wed Jun 21 20:13:40 2006
+++ SOURCES/python-pycairo-new_API.patch	Wed Jun 21 20:13:35 2006
@@ -0,0 +1,239 @@
+diff -aurN pycairo-1.1.6.orig/cairo/pycairo-pattern.c pycairo-1.1.6/cairo/pycairo-pattern.c
+--- pycairo-1.1.6.orig/cairo/pycairo-pattern.c	2006-05-29 07:44:11.000000000 +0200
++++ pycairo-1.1.6/cairo/pycairo-pattern.c	2006-06-11 09:17:26.000000000 +0200
+@@ -73,7 +73,8 @@
+ 	type = &PycairoRadialGradient_Type;
+ 	break;
+     default:
+-	ASSERT_NOT_REACHED;
++	PyErr_SetString(CairoError, "Unsupported Pattern type");
++	return NULL;
+     }
+ 
+     o = type->tp_alloc(type, 0);
+diff -aurN pycairo-1.1.6.orig/cairo/pycairo-private.h pycairo-1.1.6/cairo/pycairo-private.h
+--- pycairo-1.1.6.orig/cairo/pycairo-private.h	2006-05-01 04:11:03.000000000 +0200
++++ pycairo-1.1.6/cairo/pycairo-private.h	2006-06-11 09:17:26.000000000 +0200
+@@ -116,10 +116,4 @@
+         } while (0)
+ #endif /* PY_MAJOR_VERSION */
+ 
+-#define ASSERT_NOT_REACHED		\
+-do {					\
+-    static const int NOT_REACHED = 0;	\
+-    assert (NOT_REACHED);		\
+-} while (0)
+-
+ #endif /* _PYCAIRO_PRIVATE_H_ */
+diff -aurN pycairo-1.1.6.orig/cairo/pycairo-surface.c pycairo-1.1.6/cairo/pycairo-surface.c
+--- pycairo-1.1.6.orig/cairo/pycairo-surface.c	2006-05-28 03:58:52.000000000 +0200
++++ pycairo-1.1.6/cairo/pycairo-surface.c	2006-06-11 09:17:26.000000000 +0200
+@@ -242,6 +242,18 @@
+     Py_RETURN_NONE;
+ }
+ 
++static PyObject *
++surface_set_fallback_resolution (PycairoSurface *o, PyObject *args)
++{
++    double x_ppi, y_ppi;
++
++    if (!PyArg_ParseTuple(args, "dd:Surface.set_fallback_resolution",
++			  &x_ppi, &y_ppi))
++	return NULL;
++    cairo_surface_set_fallback_resolution (o->surface, x_ppi, y_ppi);
++    Py_RETURN_NONE;
++}
++
+ #ifdef CAIRO_HAS_PNG_FUNCTIONS
+ /* METH_O */
+ static PyObject *
+@@ -291,6 +303,8 @@
+     {"mark_dirty",     (PyCFunction)surface_mark_dirty,        METH_KEYWORDS },
+     {"set_device_offset",(PyCFunction)surface_set_device_offset,
+                                                                 METH_VARARGS },
++    {"set_fallback_resolution",(PyCFunction)surface_set_fallback_resolution,
++                                                                METH_VARARGS },
+ #ifdef CAIRO_HAS_PNG_FUNCTIONS
+     {"write_to_png",   (PyCFunction)surface_write_to_png,      METH_O },
+ #endif
+@@ -459,7 +473,8 @@
+ 	    stride = (width + 1) / 8;
+ 	    break;
+ 	default:
+-	    ASSERT_NOT_REACHED;
++	    PyErr_SetString(CairoError, "Unknown format");
++	    return NULL;
+ 	}
+     }
+     if (height * stride > buffer_len) {
+@@ -707,34 +722,22 @@
+                   cairo_pdf_surface_create (PyString_AsString(file),
+                                      width_in_points, height_in_points),
+ 	       NULL);
+-
+-    } else {  /* file or file-like object argument */
+-	PyObject* writer = PyObject_GetAttrString (file, "write");
+-	if (writer == NULL || !PyCallable_Check (writer)) {
+-	    Py_XDECREF(writer);
+-	    PyErr_SetString(PyExc_TypeError,
++    }
++    /* file or file-like object argument */
++    PyObject* writer = PyObject_GetAttrString (file, "write");
++    if (writer == NULL || !PyCallable_Check (writer)) {
++	Py_XDECREF(writer);
++	PyErr_SetString(PyExc_TypeError,
+ "PDFSurface argument 1 must be a filename (str), file object, or an object "
+ "that has a \"write\" method (like StringIO)");
+-	    return NULL;
+-	}
+-	Py_DECREF(writer);
+-
+-	return PycairoSurface_FromSurface (
+-	           cairo_pdf_surface_create_for_stream (_write_func,
+-		       file, width_in_points, height_in_points),
+-	       file);
++	return NULL;
+     }
+-}
++    Py_DECREF(writer);
+ 
+-static PyObject *
+-pdf_surface_set_dpi (PycairoPDFSurface *o, PyObject *args)
+-{
+-    double x_dpi, y_dpi;
+-
+-    if (!PyArg_ParseTuple(args, "dd:PDFSurface.set_dpi", &x_dpi, &y_dpi))
+-	return NULL;
+-    cairo_pdf_surface_set_dpi (o->surface, x_dpi, y_dpi);
+-    Py_RETURN_NONE;
++    return PycairoSurface_FromSurface (
++	       cairo_pdf_surface_create_for_stream (_write_func, file,
++		   width_in_points, height_in_points),
++	   file);
+ }
+ 
+ static PyObject *
+@@ -751,7 +754,6 @@
+ }
+ 
+ static PyMethodDef pdf_surface_methods[] = {
+-    {"set_dpi",  (PyCFunction)pdf_surface_set_dpi,     METH_VARARGS },
+     {"set_size", (PyCFunction)pdf_surface_set_size,    METH_VARARGS },
+     {NULL, NULL, 0, NULL},
+ };
+@@ -824,22 +826,22 @@
+                                      width_in_points, height_in_points),
+ 	       NULL);
+ 
+-    } else {  /* file or file-like object argument */
+-	PyObject* writer = PyObject_GetAttrString (file, "write");
+-	if (writer == NULL || !PyCallable_Check (writer)) {
+-	    Py_XDECREF(writer);
+-	    PyErr_SetString(PyExc_TypeError,
++    }
++    /* else: file or file-like object argument */
++    PyObject* writer = PyObject_GetAttrString (file, "write");
++    if (writer == NULL || !PyCallable_Check (writer)) {
++	Py_XDECREF(writer);
++	PyErr_SetString(PyExc_TypeError,
+ "PSSurface argument 1 must be a filename (str), file object, or an object "
+ "that has a \"write\" method (like StringIO)");
+-	    return NULL;
+-	}
+-	Py_DECREF(writer);
++	return NULL;
++    }
++    Py_DECREF(writer);
+ 
+-	return PycairoSurface_FromSurface (
+-	           cairo_ps_surface_create_for_stream (_write_func,
+-		       file, width_in_points, height_in_points),
++    return PycairoSurface_FromSurface (
++	       cairo_ps_surface_create_for_stream (_write_func, file,
++                   width_in_points, height_in_points),
+ 	       file);
+-    }
+ }
+ 
+ static PyObject *
+@@ -875,17 +877,6 @@
+ }
+ 
+ static PyObject *
+-ps_surface_set_dpi (PycairoPSSurface *o, PyObject *args)
+-{
+-    double x_dpi, y_dpi;
+-
+-    if (!PyArg_ParseTuple(args, "dd:PSSurface.set_dpi", &x_dpi, &y_dpi))
+-	return NULL;
+-    cairo_ps_surface_set_dpi (o->surface, x_dpi, y_dpi);
+-    Py_RETURN_NONE;
+-}
+-
+-static PyObject *
+ ps_surface_set_size (PycairoPSSurface *o, PyObject *args)
+ {
+     double width_in_points, height_in_points;
+@@ -902,7 +893,6 @@
+                    (PyCFunction)ps_surface_dsc_begin_page_setup, METH_NOARGS },
+     {"dsc_begin_setup", (PyCFunction)ps_surface_dsc_begin_setup, METH_NOARGS },
+     {"dsc_comment", (PyCFunction)ps_surface_dsc_comment,        METH_VARARGS },
+-    {"set_dpi",  (PyCFunction)ps_surface_set_dpi,               METH_VARARGS },
+     {"set_size", (PyCFunction)ps_surface_set_size,              METH_VARARGS },
+     {NULL, NULL, 0, NULL},
+ };
+@@ -974,34 +964,22 @@
+                   cairo_svg_surface_create (PyString_AsString(file),
+                                      width_in_points, height_in_points),
+ 	       NULL);
+-
+-    } else {  /* file or file-like object argument */
+-	PyObject* writer = PyObject_GetAttrString (file, "write");
+-	if (writer == NULL || !PyCallable_Check (writer)) {
+-	    Py_XDECREF(writer);
+-	    PyErr_SetString(PyExc_TypeError,
++    }
++    /* else: file or file-like object argument */
++    PyObject* writer = PyObject_GetAttrString (file, "write");
++    if (writer == NULL || !PyCallable_Check (writer)) {
++	Py_XDECREF(writer);
++	PyErr_SetString(PyExc_TypeError,
+ "SVGSurface argument 1 must be a filename (str), file object, or an object "
+ "that has a \"write\" method (like StringIO)");
+-	    return NULL;
+-	}
+-	Py_DECREF(writer);
+-
+-	return PycairoSurface_FromSurface (
+-	           cairo_svg_surface_create_for_stream (_write_func,
+-		       file, width_in_points, height_in_points),
+-	       file);
++	return NULL;
+     }
+-}
+-
+-static PyObject *
+-svg_surface_set_dpi (PycairoSVGSurface *o, PyObject *args)
+-{
+-    double x_dpi, y_dpi;
++    Py_DECREF(writer);
+ 
+-    if (!PyArg_ParseTuple(args, "dd:SVGSurface.set_dpi", &x_dpi, &y_dpi))
+-	return NULL;
+-    cairo_svg_surface_set_dpi (o->surface, x_dpi, y_dpi);
+-    Py_RETURN_NONE;
++    return PycairoSurface_FromSurface (
++	       cairo_svg_surface_create_for_stream (_write_func, file,
++	           width_in_points, height_in_points),
++	       file);
+ }
+ 
+ static PyMethodDef svg_surface_methods[] = {
+@@ -1010,7 +988,6 @@
+      * cairo_svg_get_versions
+      * cairo_svg_version_to_string
+      */
+-    {"set_dpi", (PyCFunction)svg_surface_set_dpi,    METH_VARARGS },
+     {NULL, NULL, 0, NULL},
+ };
+ 
================================================================


More information about the pld-cvs-commit mailing list