[cairo-commit] pycairo/cairo cairomodule.c, 1.35, 1.36 pycairo.h, 1.33, 1.34 cairosvgmodule.c, 1.7, 1.8 pycairo-font.c, 1.21, 1.22 pycairo-matrix.c, 1.20, 1.21 pycairo-pattern.c, 1.23, 1.24 pycairo-private.h, 1.26, 1.27 pycairo-surface.c, 1.42, 1.43

Steve Chaplin commit at pdx.freedesktop.org
Fri May 20 01:57:47 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv17784/cairo

Modified Files:
	cairomodule.c pycairo.h cairosvgmodule.c pycairo-font.c 
	pycairo-matrix.c pycairo-pattern.c pycairo-private.h 
	pycairo-surface.c 
Log Message:
SC

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- cairomodule.c	19 May 2005 04:47:56 -0000	1.35
+++ cairomodule.c	20 May 2005 08:57:44 -0000	1.36
@@ -112,6 +112,7 @@
     &PycairoSurface_Type,  
     &PycairoImageSurface_Type,  
     &PycairoPDFSurface_Type,  
+    &PycairoPSSurface_Type,  
 
     PycairoContext_FromContext,
     PycairoFontFace_FromFontFace,
@@ -123,6 +124,7 @@
     PycairoSurface_FromSurface,
     PycairoImageSurface_FromImageSurface,
     PycairoPDFSurface_FromPDFSurface,
+    PycairoPSSurface_FromPSSurface,
 
     Pycairo_Check_Status,
 };
@@ -151,6 +153,8 @@
         return;
     if (PyType_Ready(&PycairoPDFSurface_Type) < 0)
         return;
+    if (PyType_Ready(&PycairoPSSurface_Type) < 0)
+        return;
 
     m = Py_InitModule("cairo._cairo", NULL);
 
@@ -176,8 +180,10 @@
 		       (PyObject *)&PycairoImageSurface_Type);
     Py_INCREF(&PycairoPDFSurface_Type);
     PyModule_AddObject(m, "PDFSurface", (PyObject *)&PycairoPDFSurface_Type);
+    Py_INCREF(&PycairoPSSurface_Type);
+    PyModule_AddObject(m, "PSSurface", (PyObject *)&PycairoPSSurface_Type);
 
-    PyModule_AddObject(m, "pycairo_CAPI", PyCObject_FromVoidPtr(&CAPI, NULL));
+    PyModule_AddObject(m, "CAPI", PyCObject_FromVoidPtr(&CAPI, NULL));
 
     /* Add 'cairo.Error' to the module */
     if (CairoError == NULL) {

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- pycairo.h	19 May 2005 04:47:56 -0000	1.33
+++ pycairo.h	20 May 2005 08:57:44 -0000	1.34
@@ -75,6 +75,7 @@
 
 #define PycairoImageSurface PycairoSurface
 #define PycairoPDFSurface   PycairoSurface
+#define PycairoPSSurface    PycairoSurface
 
 /* Define structure for C API. */
 typedef struct {
@@ -89,6 +90,7 @@
     PyTypeObject *Surface_Type;
     PyTypeObject *ImageSurface_Type;
     PyTypeObject *PDFSurface_Type;
+    PyTypeObject *PSSurface_Type;
 
     /* constructors */
     PyObject *(*Context_FromContext)(cairo_t *ctx, PyObject *base);
@@ -103,6 +105,8 @@
 					       PyObject *base);
     PyObject *(*PDFSurface_FromPDFSurface)(cairo_surface_t *surface, 
 					   PyObject *base);
+    PyObject *(*PSSurface_FromPSSurface)(cairo_surface_t *surface, 
+					 PyObject *base);
 
     /* misc functions */
     int (* check_status)(cairo_status_t status);
@@ -144,8 +148,7 @@
  * 2) Add 'Pycairo_IMPORT;' to the init<module> function
  */
 #define Pycairo_IMPORT \
-        Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import("cairo", \
-                                                          "pycairo_CAPI")
+        Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import("cairo", "CAPI")
 
 #endif /* ifndef _INSIDE_PYCAIRO_ */
 

Index: cairosvgmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairosvgmodule.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cairosvgmodule.c	17 May 2005 02:44:20 -0000	1.7
+++ cairosvgmodule.c	20 May 2005 08:57:44 -0000	1.8
@@ -29,7 +29,6 @@
  */
 
 #include <Python.h>
-#include "structmember.h"
 
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
@@ -38,33 +37,47 @@
 #include "pycairosvg-private.h"
 
 
+/* A module specific exception */
+static PyObject *CairoSVGError = NULL;
+
 static Pycairo_CAPI_t *Pycairo_CAPI;
 
+
 #ifndef PyMODINIT_FUNC	/* declarations for DLL import/export */
 #define PyMODINIT_FUNC void
 #endif
 PyMODINIT_FUNC
 initsvg (void)
 {
-    PyObject* mod;
+    PyObject* m;
 
     if (PyType_Ready(&PycairoSVGContext_Type) < 0)
         return;
 
-    mod = Py_InitModule ("cairo.svg", NULL);
-    if (mod == NULL)
+    m = Py_InitModule ("cairo.svg", NULL);
+    if (m == NULL)
 	return;
 
     Pycairo_IMPORT;
 
     Py_INCREF(&PycairoSVGContext_Type);
-    PyModule_AddObject(mod, "Context", (PyObject *)&PycairoSVGContext_Type);
+    PyModule_AddObject(m, "Context", (PyObject *)&PycairoSVGContext_Type);
+
+    /* Add 'cairo.svg.Error' to the module */
+    if (CairoSVGError == NULL) {
+	CairoSVGError = PyErr_NewException("cairo.svg.Error", NULL, NULL);
+	if (CairoSVGError == NULL)
+	    return;
+    }
+    Py_INCREF(CairoSVGError);
+    if (PyModule_AddObject(m, "Error", CairoSVGError) < 0)
+	return;
 }
 
 
 /* if status reports an error, then return 1 (True) and set the exception */
-static int
-Pycairosvg_check_status (svg_cairo_status_t status)
+int
+Pycairosvg_Check_Status (svg_cairo_status_t status)
 {
     switch (status) {
     case SVG_CAIRO_STATUS_SUCCESS:
@@ -73,66 +86,71 @@
 	PyErr_NoMemory();
 	break;
     case SVG_CAIRO_STATUS_IO_ERROR:
-	PyErr_SetString(PyExc_IOError, "IO Error");
+	PyErr_SetString(CairoSVGError, "IO Error");
 	break;
     case SVG_CAIRO_STATUS_FILE_NOT_FOUND:
-	PyErr_SetString(PyExc_RuntimeError, "File not found");
+	PyErr_SetString(CairoSVGError, "File not found");
 	break;
     case SVG_CAIRO_STATUS_INVALID_VALUE:
-	PyErr_SetString(PyExc_RuntimeError, "Invalid value");
+	PyErr_SetString(CairoSVGError, "Invalid value");
 	break;
     case SVG_CAIRO_STATUS_INVALID_CALL:
-	PyErr_SetString(PyExc_RuntimeError, "Invalid call");
+	PyErr_SetString(CairoSVGError, "Invalid call");
 	break;
     case SVG_CAIRO_STATUS_PARSE_ERROR:
-	PyErr_SetString(PyExc_RuntimeError, "Parse error");
+	PyErr_SetString(CairoSVGError, "Parse error");
 	break;
     default:
-	PyErr_SetString(PyExc_RuntimeError, "other cairo.svg error");
+	PyErr_SetString(CairoSVGError, "other cairo.svg error");
     }
     return 1;
 }
 
 
-/* class cairosvg.Context ------------------------------------------------- */
+/* class cairo.svg.Context ------------------------------------------------ */
 
 static void
-pycairosvg_dealloc(PycairoSVGContext* self)                  
+pycairosvg_dealloc (PycairoSVGContext *o)                  
 {
-    if (self->ctx) {
-	svg_cairo_destroy(self->ctx);
-	self->ctx = NULL;
+    if (o->ctx) {
+	svg_cairo_destroy (o->ctx);
+	o->ctx = NULL;
     }
-    self->ob_type->tp_free((PyObject*)self);
+    o->ob_type->tp_free((PyObject*)o);
 }
 
 
 static PyObject *
 pycairosvg_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {               
-    PycairoSVGContext *self = (PycairoSVGContext *)type->tp_alloc(type, 0);
-    if (self && Pycairosvg_check_status (svg_cairo_create (&self->ctx))) {
-	Py_DECREF(self);
-	return NULL;
+    PyObject *o = type->tp_alloc(type, 0);
+
+    if (o) {
+	PycairoSVGContext *svg = ((PycairoSVGContext *)o);
+	svg_cairo_status_t status = svg_cairo_create (&svg->ctx);
+	if (Pycairosvg_Check_Status (status)) {
+	    Py_DECREF(o);
+	    return NULL;
+	}
     }
-    return (PyObject *)self;
+    return o;
 }
 
 static PyObject *
-pycairosvg_parse (PycairoSVGContext *self, PyObject *args)
+pycairosvg_parse (PycairoSVGContext *o, PyObject *args)
 {
     const char *filename;
 
     if (!PyArg_ParseTuple(args, "s:Context.parse", &filename))
 	return NULL;
 
-    if (Pycairosvg_check_status (svg_cairo_parse (self->ctx, filename)))
+    if (Pycairosvg_Check_Status (svg_cairo_parse (o->ctx, filename)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairosvg_parse_buffer (PycairoSVGContext *self, PyObject *args)
+pycairosvg_parse_buffer (PycairoSVGContext *o, PyObject *args)
 {
     const char *buf;
     size_t count;
@@ -142,14 +160,14 @@
 
     /*svg_cairo_status_t svg_cairo_parse_buffer (svg_cairo_t *svg_cairo, 
       const char *buf, size_t count);*/
-    if (Pycairosvg_check_status (svg_cairo_parse_buffer (self->ctx, buf, 
+    if (Pycairosvg_Check_Status (svg_cairo_parse_buffer (o->ctx, buf, 
 							 count)))
     	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairosvg_render (PycairoSVGContext *self, PyObject *args)
+pycairosvg_render (PycairoSVGContext *o, PyObject *args)
 {
     PycairoContext *xrs;
 
@@ -157,18 +175,17 @@
 			  &PycairoContext_Type, &xrs))
 	return NULL;
 
-    if (Pycairosvg_check_status (svg_cairo_render (self->ctx, xrs->ctx)))
+    if (Pycairosvg_Check_Status (svg_cairo_render (o->ctx, xrs->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
 
 static PyObject *
-pycairosvg_get_size (PycairoSVGContext *self, void *closure)
+pycairosvg_get_size (PycairoSVGContext *o, void *closure)
 {
     int width, height;
-
-    svg_cairo_get_size (self->ctx, &width, &height);
+    svg_cairo_get_size (o->ctx, &width, &height);
     return Py_BuildValue("ii", width, height);
 }
 
@@ -182,14 +199,10 @@
     /* parse_file_chunk_end */
     {"render",       (PyCFunction)pycairosvg_render,        METH_VARARGS },
     /* set_viewport_dimension */
+    {"get_size",     (PyCFunction)pycairosvg_get_size,      METH_NOARGS},
     {NULL, NULL, 0, NULL},
 };
 
-static PyGetSetDef pycairosvg_getsets[] = {
-    {"size",  (getter)pycairosvg_get_size},
-    {NULL, (getter)0, (setter)0, NULL, NULL},
-};
-
 
 PyTypeObject PycairoSVGContext_Type = {
     PyObject_HEAD_INIT(&PyType_Type)
@@ -212,7 +225,7 @@
     0,                         		/*tp_getattro*/
     0,                         		/*tp_setattro*/
     0,                         		/*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,/*tp_flags*/
     0,                                  /* tp_doc */
     0,		               		/* tp_traverse */
     0,		               		/* tp_clear */
@@ -222,7 +235,7 @@
     0,		               		/* tp_iternext */
     pycairosvg_methods,        		/* tp_methods */
     0,                         		/* tp_members */
-    pycairosvg_getsets,        		/* tp_getset */
+    0,        		                /* tp_getset */
     0,                         		/* tp_base */
     0,                         		/* tp_dict */
     0,                         		/* tp_descr_get */

Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- pycairo-font.c	19 May 2005 04:47:56 -0000	1.21
+++ pycairo-font.c	20 May 2005 08:57:44 -0000	1.22
@@ -77,15 +77,9 @@
 static PyObject *
 font_face_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-    return type->tp_alloc(type, 0);
-}
-
-static int
-font_face_init (PycairoFontFace *o, PyObject *args, PyObject *kwds)
-{
     PyErr_SetString (PyExc_TypeError, "The FontFace type cannot be "
-		     "instantiated, use Context.get_font_face()");
-    return -1;
+		     "instantiated directly, use Context.get_font_face()");
+    return NULL;
 }
 
 /*
@@ -137,7 +131,7 @@
     0,                                  /* tp_descr_get */
     0,                                  /* tp_descr_set */
     0,                                  /* tp_dictoffset */
-    (initproc)font_face_init,           /* tp_init */
+    0,                                  /* tp_init */
     0,                                  /* tp_alloc */
     (newfunc)font_face_new,             /* tp_new */
     0,                                  /* tp_free */
@@ -228,14 +222,10 @@
      * cairo_scaled_font_reference()
      */
     /* glyph_extents - undocumented */
+    {"extents", (PyCFunction)scaled_font_extents, METH_NOARGS},
     {NULL, NULL, 0, NULL},
 };
 
-static PyGetSetDef scaled_font_getsets[] = {
-    {"extents", (getter)scaled_font_extents},
-    {NULL, (getter)0, (setter)0, NULL, NULL},
-};
-
 
 PyTypeObject PycairoScaledFont_Type = {
     PyObject_HEAD_INIT(&PyType_Type)
@@ -268,7 +258,7 @@
     0,                                  /* tp_iternext */
     scaled_font_methods,                /* tp_methods */
     0,                                  /* tp_members */
-    scaled_font_getsets,                /* tp_getset */
+    0,                                  /* tp_getset */
     &PyBaseObject_Type,                 /* tp_base */
     0,                                  /* tp_dict */
     0,                                  /* tp_descr_get */

Index: pycairo-matrix.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-matrix.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- pycairo-matrix.c	19 May 2005 04:47:56 -0000	1.20
+++ pycairo-matrix.c	20 May 2005 08:57:44 -0000	1.21
@@ -44,47 +44,44 @@
  * takes a copy of cairo_matrix_t
  */
 PyObject *
-PycairoMatrix_FromMatrix(const cairo_matrix_t *matrix)
+PycairoMatrix_FromMatrix (const cairo_matrix_t *matrix)
 {
-    PyObject *m;
+    PyObject *o;
 
     assert (matrix != NULL);
-    m = PycairoMatrix_Type.tp_alloc (&PycairoMatrix_Type, 0);
-    if (m)
-	((PycairoMatrix *)m)->matrix = *matrix;
-    return m;
+    o = PycairoMatrix_Type.tp_alloc (&PycairoMatrix_Type, 0);
+    if (o)
+	((PycairoMatrix *)o)->matrix = *matrix;
+    return o;
 }
 
 static void
-matrix_dealloc(PycairoMatrix *m)
+matrix_dealloc (PycairoMatrix *o)
 {
-    m->ob_type->tp_free((PyObject *)m);
+    o->ob_type->tp_free((PyObject *)o);
 }
 
 static PyObject *
-matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    return type->tp_alloc(type, 0);
-}
-
-static int
-matrix_init(PycairoMatrix *m, PyObject *args, PyObject *kwargs)
+matrix_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
+    PyObject *o;
     static char *kwlist[] = { "xx", "yx", "xy", "yy", "x0", "y0", NULL };
     double xx = 1.0, yx = 0.0, xy = 0.0, yy = 1.0, x0 = 0.0, y0 = 0.0;
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+    if (!PyArg_ParseTupleAndKeywords(args, kwds,
 				     "|dddddd:Matrix.__init__", kwlist,
 				     &xx, &yx, &xy, &yy, &x0, &y0))
-	return -1;
+	return NULL;
 
-    cairo_matrix_init(&m->matrix, xx, yx, xy, yy, x0, y0);
-    return 0;
+    o = type->tp_alloc(type, 0);
+    if (o)
+	cairo_matrix_init (&((PycairoMatrix *)o)->matrix, 
+			   xx, yx, xy, yy, x0, y0);
+    return o;
 }
 
-/* constructor */
 static PyObject *
-matrix_init_rotate(PyTypeObject *type, PyObject *args)
+matrix_init_rotate (PyTypeObject *type, PyObject *args)
 {
     cairo_matrix_t matrix;
     double radians;
@@ -97,65 +94,65 @@
 }
 
 static PyObject *
-matrix_get_xx(PycairoMatrix *m)
+matrix_get_xx (PycairoMatrix *o)
 {
-    return Py_BuildValue("d", m->matrix.xx);
+    return Py_BuildValue("d", o->matrix.xx);
 }
 
 static PyObject *
-matrix_get_yx(PycairoMatrix *m)
+matrix_get_yx (PycairoMatrix *o)
 {
-    return Py_BuildValue("d", m->matrix.yx);
+    return Py_BuildValue("d", o->matrix.yx);
 }
 
 static PyObject *
-matrix_get_xy(PycairoMatrix *m)
+matrix_get_xy (PycairoMatrix *o)
 {
-    return Py_BuildValue("d", m->matrix.xy);
+    return Py_BuildValue("d", o->matrix.xy);
 }
 
 static PyObject *
-matrix_get_yy(PycairoMatrix *m)
+matrix_get_yy (PycairoMatrix *o)
 {
-    return Py_BuildValue("d", m->matrix.yy);
+    return Py_BuildValue("d", o->matrix.yy);
 }
 
 static PyObject *
-matrix_get_x0(PycairoMatrix *m)
+matrix_get_x0 (PycairoMatrix *o)
 {
-    return Py_BuildValue("d", m->matrix.x0);
+    return Py_BuildValue("d", o->matrix.x0);
 }
 
 static PyObject *
-matrix_get_y0(PycairoMatrix *m)
+matrix_get_y0 (PycairoMatrix *o)
 {
-    return Py_BuildValue("d", m->matrix.y0);
+    return Py_BuildValue("d", o->matrix.y0);
 }
 
 /* return cairo_matrix_t data as a 6-tuple */
 static PyObject *
-matrix_get_value(PycairoMatrix *m)
+matrix_get_value (PycairoMatrix *o)
 {
     return Py_BuildValue("(dddddd)",
-			 m->matrix.xx, m->matrix.yx, 
-			 m->matrix.xy, m->matrix.yy, 
-			 m->matrix.x0, m->matrix.y0);
+			 o->matrix.xx, o->matrix.yx, 
+			 o->matrix.xy, o->matrix.yy, 
+			 o->matrix.x0, o->matrix.y0);
 }
 
 static PyObject *
-matrix_invert(PycairoMatrix *m)
+matrix_invert (PycairoMatrix *o)
 {
-    if (Pycairo_Check_Status(cairo_matrix_invert(&m->matrix)))
+    if (Pycairo_Check_Status (cairo_matrix_invert (&o->matrix)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-matrix_multiply(PycairoMatrix *m, PycairoMatrix *m2)
+matrix_multiply (PycairoMatrix *o, PycairoMatrix *o2)
 {
     cairo_matrix_t result;
-    cairo_matrix_multiply(&result, &m->matrix, &m2->matrix);
-    return PycairoMatrix_FromMatrix(&result);
+    cairo_matrix_multiply (&result, &o->matrix, &o2->matrix);
+    return PycairoMatrix_FromMatrix (&result);
 }
 
 static PyNumberMethods matrix_as_number = {
@@ -185,19 +182,19 @@
 };
 
 static PyObject *
-matrix_repr(PycairoMatrix *m)
+matrix_repr (PycairoMatrix *o)
 {
     char buf[256];
 
     PyOS_snprintf(buf, sizeof(buf), "cairo.Matrix(%g, %g, %g, %g, %g, %g)",
-		  m->matrix.xx, m->matrix.yx, 
-		  m->matrix.xy, m->matrix.yy, 
-		  m->matrix.x0, m->matrix.y0);
+		  o->matrix.xx, o->matrix.yx, 
+		  o->matrix.xy, o->matrix.yy, 
+		  o->matrix.x0, o->matrix.y0);
     return PyString_FromString(buf);
 }
 
 static PyObject *
-matrix_richcmp(PycairoMatrix *m1, PycairoMatrix *m2, int op)
+matrix_richcmp (PycairoMatrix *m1, PycairoMatrix *m2, int op)
 {
     int equal;
     PyObject *ret;
@@ -223,62 +220,62 @@
 }
 
 static PyObject *
-matrix_rotate(PycairoMatrix *m, PyObject *args)
+matrix_rotate (PycairoMatrix *o, PyObject *args)
 {
     double radians;
 
     if (!PyArg_ParseTuple(args, "d:Matrix.rotate", &radians))
 	return NULL;
     
-    cairo_matrix_rotate(&m->matrix, radians);
+    cairo_matrix_rotate (&o->matrix, radians);
     Py_RETURN_NONE;
 }
 
 static PyObject *
-matrix_scale(PycairoMatrix *m, PyObject *args)
+matrix_scale (PycairoMatrix *o, PyObject *args)
 {
     double sx, sy;
 
     if (!PyArg_ParseTuple(args, "dd:Matrix.scale", &sx, &sy))
 	return NULL;
     
-    cairo_matrix_scale(&m->matrix, sx, sy);
+    cairo_matrix_scale (&o->matrix, sx, sy);
     Py_RETURN_NONE;
 }
 
 static PyObject *
-matrix_translate(PycairoMatrix *m, PyObject *args)
+matrix_translate (PycairoMatrix *o, PyObject *args)
 {
     double tx, ty;
 
     if (!PyArg_ParseTuple(args, "dd:Matrix.translate", &tx, &ty))
 	return NULL;
     
-    cairo_matrix_translate(&m->matrix, tx, ty);
+    cairo_matrix_translate (&o->matrix, tx, ty);
     Py_RETURN_NONE;
 }
 
 static PyObject *
-matrix_transform_distance(PycairoMatrix *m, PyObject *args)
+matrix_transform_distance (PycairoMatrix *o, PyObject *args)
 {
     double dx, dy;
 
     if (!PyArg_ParseTuple(args, "dd:Matrix.transform_distance", &dx, &dy))
 	return NULL;
 
-    cairo_matrix_transform_distance(&m->matrix, &dx, &dy);
+    cairo_matrix_transform_distance (&o->matrix, &dx, &dy);
     return Py_BuildValue("(dd)", dx, dy);
 }
 
 static PyObject *
-matrix_transform_point(PycairoMatrix *m, PyObject *args)
+matrix_transform_point (PycairoMatrix *o, PyObject *args)
 {
     double x, y;
 
     if (!PyArg_ParseTuple(args, "dd:Matrix.transform_point", &x, &y))
 	return NULL;
 
-    cairo_matrix_transform_point(&m->matrix, &x, &y);
+    cairo_matrix_transform_point (&o->matrix, &x, &y);
     return Py_BuildValue("(dd)", x, y);
 }
 
@@ -352,7 +349,7 @@
     0,                                  /* tp_descr_get */
     0,                                  /* tp_descr_set */
     0,                                  /* tp_dictoffset */
-    (initproc)matrix_init,              /* tp_init */
+    0,                                  /* tp_init */
     0,                                  /* tp_alloc */
     (newfunc)matrix_new,                /* tp_new */
     0,                                  /* tp_free */

Index: pycairo-pattern.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-pattern.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- pycairo-pattern.c	19 May 2005 04:47:56 -0000	1.23
+++ pycairo-pattern.c	20 May 2005 08:57:44 -0000	1.24
@@ -43,52 +43,52 @@
  * Return value: New reference or NULL on failure
  */
 PyObject *
-PycairoPattern_FromPattern(cairo_pattern_t *pattern)
+PycairoPattern_FromPattern (cairo_pattern_t *pattern)
 {
-    PyObject *p;
+    PyObject *o;
 
     assert (pattern != NULL);
-    p = PycairoPattern_Type.tp_alloc (&PycairoPattern_Type, 0);
-    if (p)
-	((PycairoPattern *)p)->pattern = pattern;
+    o = PycairoPattern_Type.tp_alloc (&PycairoPattern_Type, 0);
+    if (o)
+	((PycairoPattern *)o)->pattern = pattern;
     else
 	cairo_pattern_destroy (pattern);
-    return p;
+    return o;
 }
 
 static void
-pattern_dealloc(PycairoPattern *p)
+pattern_dealloc (PycairoPattern *o)
 {
 #ifdef DEBUG
     printf("pattern_dealloc start\n");
 #endif
-    if (p->pattern) {
-	cairo_pattern_destroy(p->pattern);
-	p->pattern = NULL;
+    if (o->pattern) {
+	cairo_pattern_destroy (o->pattern);
+	o->pattern = NULL;
     }
-    p->ob_type->tp_free((PyObject *)p);
+    o->ob_type->tp_free((PyObject *)o);
 #ifdef DEBUG
     printf("pattern_dealloc end\n");
 #endif
 }
 
 static PyObject *
-pattern_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+pattern_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-    return type->tp_alloc(type, 0);
-}
+    PyErr_SetString(PyExc_TypeError,
+		    "The Pattern type cannot be instantiated");
+    return NULL;
 
-/* pattern_init() - not used, use alternative constructors instead */
+}
 
-/* alternative constructor */
 static PyObject *
-pattern_create_for_surface(PyTypeObject *type, PyObject *args)
+pattern_create_for_surface (PyTypeObject *type, PyObject *args)
 {
     PycairoSurface *s;
     cairo_pattern_t *pattern;
 
-    if (!PyArg_ParseTuple(args, "O!:Pattern.create_for_surface", 
-			  &PycairoSurface_Type, &s))
+    if (!PyArg_ParseTuple (args, "O!:Pattern.create_for_surface", 
+			   &PycairoSurface_Type, &s))
 	return NULL;
 
     pattern = cairo_pattern_create_for_surface (s->surface);
@@ -97,9 +97,8 @@
     return PycairoPattern_FromPattern (pattern);
 }
 
-/* alternative constructor */
 static PyObject *
-pattern_create_linear(PyTypeObject *type, PyObject *args)
+pattern_create_linear (PyTypeObject *type, PyObject *args)
 {
     double x0, y0, x1, y1;
     cairo_pattern_t *pattern;
@@ -114,9 +113,8 @@
     return PycairoPattern_FromPattern (pattern);
 }
 
-/* alternative constructor */
 static PyObject *
-pattern_create_radial(PyTypeObject *type, PyObject *args)
+pattern_create_radial (PyTypeObject *type, PyObject *args)
 {
     cairo_pattern_t *pattern;
     double cx0, cy0, radius0, cx1, cy1, radius1;
@@ -133,16 +131,16 @@
 }
 
 static PyObject *
-pattern_add_color_stop_rgb(PycairoPattern *p, PyObject *args)
+pattern_add_color_stop_rgb (PycairoPattern *o, PyObject *args)
 {
     double offset, red, green, blue;
     cairo_status_t status;
 
-    if (!PyArg_ParseTuple(args, "ddddd:Pattern.add_color_stop_rgb",
+    if (!PyArg_ParseTuple(args, "dddd:Pattern.add_color_stop_rgb",
 			  &offset, &red, &green, &blue))
 	return NULL;
 
-    status = cairo_pattern_add_color_stop_rgb (p->pattern, offset, red, green, 
+    status = cairo_pattern_add_color_stop_rgb (o->pattern, offset, red, green, 
 					       blue);
     if (Pycairo_Check_Status(status))
 	return NULL;
@@ -150,7 +148,7 @@
 }
 
 static PyObject *
-pattern_add_color_stop_rgba(PycairoPattern *p, PyObject *args)
+pattern_add_color_stop_rgba (PycairoPattern *o, PyObject *args)
 {
     double offset, red, green, blue, alpha;
     cairo_status_t status;
@@ -159,7 +157,7 @@
 			  &offset, &red, &green, &blue, &alpha))
 	return NULL;
 
-    status = cairo_pattern_add_color_stop_rgba (p->pattern, offset, red, 
+    status = cairo_pattern_add_color_stop_rgba (o->pattern, offset, red, 
 						green, blue, alpha);
     if (Pycairo_Check_Status(status))
 	return NULL;
@@ -167,27 +165,27 @@
 }
 
 static PyObject *
-pattern_get_extend(PycairoPattern *p)
+pattern_get_extend (PycairoPattern *o)
 {
-    return PyInt_FromLong(cairo_pattern_get_extend(p->pattern));
+    return PyInt_FromLong(cairo_pattern_get_extend (o->pattern));
 }
 
 static PyObject *
-pattern_get_filter(PycairoPattern *p)
+pattern_get_filter (PycairoPattern *o)
 {
-    return PyInt_FromLong(cairo_pattern_get_filter(p->pattern));
+    return PyInt_FromLong(cairo_pattern_get_filter (o->pattern));
 }
 
 static PyObject *
-pattern_get_matrix(PycairoPattern *p)
+pattern_get_matrix (PycairoPattern *o)
 {
     cairo_matrix_t matrix;
-    cairo_pattern_get_matrix(p->pattern, &matrix);
-    return PycairoMatrix_FromMatrix(&matrix);
+    cairo_pattern_get_matrix (o->pattern, &matrix);
+    return PycairoMatrix_FromMatrix (&matrix);
 }
 
 static PyObject *
-pattern_set_extend(PycairoPattern *p, PyObject *args)
+pattern_set_extend (PycairoPattern *o, PyObject *args)
 {
     int extend;
 
@@ -195,34 +193,34 @@
  	return NULL;
  
     /* always returns status = success */
-    cairo_pattern_set_extend(p->pattern, extend);
+    cairo_pattern_set_extend (o->pattern, extend);
     Py_RETURN_NONE;
 }
  
 static PyObject *
-pattern_set_filter(PycairoPattern *p, PyObject *args)
+pattern_set_filter (PycairoPattern *o, PyObject *args)
 {
     int filter;
 
-    if (!PyArg_ParseTuple(args, "i:Pattern.set_filter", &filter))
+    if (!PyArg_ParseTuple (args, "i:Pattern.set_filter", &filter))
 	return NULL;
 
     /* always returns status = success */
-    cairo_pattern_set_filter(p->pattern, filter);
+    cairo_pattern_set_filter (o->pattern, filter);
     Py_RETURN_NONE;
 }
   
 static PyObject *
-pattern_set_matrix(PycairoPattern *p, PyObject *args)
+pattern_set_matrix (PycairoPattern *o, PyObject *args)
 {
-    PycairoMatrix *matrix;
+    PycairoMatrix *m;
 
-    if (!PyArg_ParseTuple(args, "O!:Pattern.set_matrix",
-			  &PycairoMatrix_Type, &matrix))
+    if (!PyArg_ParseTuple (args, "O!:Pattern.set_matrix",
+			   &PycairoMatrix_Type, &m))
 	return NULL;
 
     /* always returns status = success */
-    cairo_pattern_set_matrix(p->pattern, &matrix->matrix);
+    cairo_pattern_set_matrix (o->pattern, &m->matrix);
     Py_RETURN_NONE;
 }
 

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- pycairo-private.h	19 May 2005 04:47:56 -0000	1.26
+++ pycairo-private.h	20 May 2005 08:57:44 -0000	1.27
@@ -53,6 +53,7 @@
 extern PyTypeObject PycairoSurface_Type;
 extern PyTypeObject PycairoImageSurface_Type;
 extern PyTypeObject PycairoPDFSurface_Type;
+extern PyTypeObject PycairoPSSurface_Type;
 
 PyObject *PycairoContext_FromContext (cairo_t *ctx, PyObject *base);
 PyObject *PycairoFontFace_FromFontFace (cairo_font_face_t *font_face);
@@ -67,6 +68,8 @@
 						PyObject *base);
 PyObject *PycairoPDFSurface_FromPDFSurface (cairo_surface_t *surface, 
 					    PyObject *base);
+PyObject *PycairoPSSurface_FromPSSurface (cairo_surface_t *surface, 
+					  PyObject *base);
 
 int Pycairo_Check_Status (cairo_status_t status);
 

Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- pycairo-surface.c	19 May 2005 04:47:56 -0000	1.42
+++ pycairo-surface.c	20 May 2005 08:57:44 -0000	1.43
@@ -39,16 +39,14 @@
 #ifdef CAIRO_HAS_PDF_SURFACE
 #  include <cairo-pdf.h>
 #endif
-/* PS backend support has been removed - the C API is broken
 #ifdef CAIRO_HAS_PS_SURFACE
-# include <cairo-ps.h>
+#  include <cairo-ps.h>
 #endif
-*/
 
 
 #ifdef HAVE_NUMPY
 #  include <Numeric/arrayobject.h>
-   static int load_numpy(void);
+   static int load_numpy (void);
 #endif
 
 /* Class cairo.Surface ---------------------------------------------------- */
@@ -63,113 +61,105 @@
  * Return value: New reference or NULL on failure
  */
 PyObject *
-PycairoSurface_FromSurface(cairo_surface_t *surface, PyObject *base)
+PycairoSurface_FromSurface (cairo_surface_t *surface, PyObject *base)
 {
-    PyObject *s;
+    PyObject *o;
 
     assert (surface != NULL);
-    s = PycairoSurface_Type.tp_alloc (&PycairoSurface_Type, 0);
-    if (s) {
-	((PycairoSurface *)s)->surface = surface;
+    o = PycairoSurface_Type.tp_alloc (&PycairoSurface_Type, 0);
+    if (o) {
+	((PycairoSurface *)o)->surface = surface;
 	Py_XINCREF(base);
-	((PycairoSurface *)s)->base = base;
+	((PycairoSurface *)o)->base = base;
     } else {
 	cairo_surface_destroy (surface);
     }
-    return s;
+    return o;
 }
 
 static void
-surface_dealloc(PycairoSurface *s)
+surface_dealloc (PycairoSurface *o)
 {
 #ifdef DEBUG
     printf("surface_dealloc start\n");
 #endif
-    if (s->surface) {
-	cairo_surface_destroy(s->surface);
-	s->surface = NULL;
+    if (o->surface) {
+	cairo_surface_destroy(o->surface);
+	o->surface = NULL;
     }
-    Py_CLEAR(s->base);
+    Py_CLEAR(o->base);
 
-    s->ob_type->tp_free((PyObject *)s);
+    o->ob_type->tp_free((PyObject *)o);
 #ifdef DEBUG
     printf("surface_dealloc end\n");
 #endif
 }
 
 static PyObject *
-surface_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    return type->tp_alloc(type, 0);
-    /* initializes memory to zeros */
-}
-
-static int
-surface_init(PycairoSurface *s, PyObject *args, PyObject *kwds)
+surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
     PyErr_SetString(PyExc_TypeError,
-		    "The BaseSurface type cannot be instantiated");
-    return -1;
+		    "The Surface type cannot be instantiated");
+    return NULL;
 }
 
 static PyObject *
-surface_create_similar(PycairoSurface *s, PyObject *args)
+surface_create_similar (PycairoSurface *o, PyObject *args)
 {
     cairo_surface_t *surface;
     cairo_format_t format;
     int width, height;
 
-    if (!PyArg_ParseTuple(args, "iii:Surface.create_similar",
-			  &format, &width, &height))
+    if (!PyArg_ParseTuple (args, "iii:Surface.create_similar",
+			   &format, &width, &height))
 	return NULL;
 
-    surface = cairo_surface_create_similar(s->surface, format, width, height);
+    surface = cairo_surface_create_similar (o->surface, format, width, height);
     if (!surface)
 	return PyErr_NoMemory();
-
     /* bug #2765 - "How do we identify surface types?"
      * determine surface type and use PycairoImageSurface_FromImageSurface() 
-     * etc
+     * etc to create the correct Pycairo object
      */
     return PycairoSurface_FromSurface (surface, NULL);
 }
 
 static PyObject *
-surface_finish(PycairoSurface *s)
+surface_finish (PycairoSurface *o)
 {
-    cairo_status_t status = cairo_surface_finish(s->surface);
-    Py_CLEAR(s->base);
+    cairo_status_t status = cairo_surface_finish (o->surface);
+    Py_CLEAR(o->base);
 
-    if (Pycairo_Check_Status(status))
+    if (Pycairo_Check_Status (status))
 	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-surface_set_device_offset(PycairoSurface *s, PyObject *args)
+surface_set_device_offset (PycairoSurface *o, PyObject *args)
 {
     double x_offset, y_offset;
 
-    if (!PyArg_ParseTuple(args, "dd:Surface.set_device_offset", 
-			  &x_offset, &y_offset))
+    if (!PyArg_ParseTuple (args, "dd:Surface.set_device_offset", 
+			   &x_offset, &y_offset))
 	return NULL;
 
-    cairo_surface_set_device_offset (s->surface, x_offset, y_offset);
+    cairo_surface_set_device_offset (o->surface, x_offset, y_offset);
     Py_RETURN_NONE;
 }
 
 #ifdef CAIRO_HAS_PNG_FUNCTIONS
 static PyObject *
-surface_write_to_png(PycairoSurface *s, PyObject *args)
+surface_write_to_png (PycairoSurface *o, PyObject *args)
 {
     const char *filename;
     cairo_status_t status;
 
-    if (!PyArg_ParseTuple(args, "s:Surface.write_to_png", &filename))
+    if (!PyArg_ParseTuple (args, "s:Surface.write_to_png", &filename))
 	return NULL;
 
-    status = cairo_surface_write_to_png(s->surface, filename);
-    if (Pycairo_Check_Status(status))
+    status = cairo_surface_write_to_png (o->surface, filename);
+    if (Pycairo_Check_Status (status))
 	return NULL;
     Py_RETURN_NONE;
 }
@@ -216,7 +206,7 @@
     0,                                  /* tp_getattro */
     0,                                  /* tp_setattro */
     0,                                  /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT  | Py_TPFLAGS_BASETYPE, /* tp_flags */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,/* tp_flags */
     0,                                  /* tp_doc */
     0,                                  /* tp_traverse */
     0,                                  /* tp_clear */
@@ -232,7 +222,7 @@
     0,                                  /* tp_descr_get */
     0,                                  /* tp_descr_set */
     0,                                  /* tp_dictoffset */
-    (initproc)surface_init,             /* tp_init */
+    0,                                  /* tp_init */
     0,                                  /* tp_alloc */
     (newfunc)surface_new,               /* tp_new */
     0,                                  /* tp_free */
@@ -244,44 +234,50 @@
 /* Class cairo.ImageSurface ----------------------------------------------- */
 
 PyObject *
-PycairoImageSurface_FromImageSurface(cairo_surface_t *surface, PyObject *base)
+PycairoImageSurface_FromImageSurface (cairo_surface_t *surface, PyObject *base)
 {
-    PyObject *s;
+    PyObject *o;
 
     assert (surface != NULL);
-    s = PycairoImageSurface_Type.tp_alloc (&PycairoImageSurface_Type, 0);
-    if (s) {
-	((PycairoImageSurface *)s)->surface = surface;
+    o = PycairoImageSurface_Type.tp_alloc (&PycairoImageSurface_Type, 0);
+    if (o) {
+	((PycairoImageSurface *)o)->surface = surface;
 	Py_XINCREF(base);
-	((PycairoImageSurface *)s)->base = base;
+	((PycairoImageSurface *)o)->base = base;
     } else {
 	cairo_surface_destroy (surface);
     }
-    return s;
+    return o;
 }
 
-static int
-image_surface_init(PycairoSurface *s, PyObject *args, PyObject *kwds)
+static PyObject *
+image_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
     cairo_format_t format;
     int width, height;
+    cairo_surface_t *surface;
+    PyObject *o;
 
-    if (!PyArg_ParseTuple(args, "iii:ImageSurface.__init__",
-			  &format, &width, &height))
-	return -1;
+    if (!PyArg_ParseTuple (args, "iii:ImageSurface.__new__",
+			   &format, &width, &height))
+	return NULL;
 
-    s->surface = cairo_image_surface_create (format, width, height);
-    if (!s->surface){
-	Py_DECREF(s);
-	PyErr_NoMemory();
-	return -1;
+    o = type->tp_alloc(type, 0);
+    if (o) {
+	surface = cairo_image_surface_create (format, width, height);
+	if (surface) {
+	    ((PycairoImageSurface *)o)->surface = surface;
+	} else {
+	    Py_DECREF(o);
+	    return PyErr_NoMemory();
+	}
     }
-    return 0;
+    return o;
 }
 
 #ifdef HAVE_NUMPY
 static PyObject *
-image_surface_create_for_array(PyTypeObject *type, PyObject *args)
+image_surface_create_for_array (PyTypeObject *type, PyObject *args)
 {
     PyArrayObject *array;
     cairo_format_t format;
@@ -343,11 +339,11 @@
 #if 0 /* disable until a reference to the buffer is added to the surface */
 /* alternative constructor */
 static PyObject *
-image_surface_create_for_data(PyTypeObject *type, PyObject *args)
+image_surface_create_for_data (PyTypeObject *type, PyObject *args)
 {
     cairo_surface_t *surface;
-    char *data;
     cairo_format_t format;
+    char *data;
     int length, width, height, stride = -1;
 
     if (!PyArg_ParseTuple(args, "w#iii|i:Surface.create_for_data",
@@ -394,9 +390,8 @@
 #endif
 
 #ifdef CAIRO_HAS_PNG_FUNCTIONS
-/* alternative constructor */
 static PyObject *
-image_surface_create_from_png(PyTypeObject *type, PyObject *args)
+image_surface_create_from_png (PyTypeObject *type, PyObject *args)
 {
     const char *filename;
     cairo_surface_t *surface;
@@ -404,7 +399,7 @@
     if (!PyArg_ParseTuple(args, "s:Surface.create_from_png", &filename))
 	return NULL;
 
-    surface = cairo_image_surface_create_from_png(filename);
+    surface = cairo_image_surface_create_from_png (filename);
     if (!surface) {
 	PyErr_SetString(PyExc_ValueError, "invalid PNG file or memory could "
 			"not be allocated for operation");
@@ -484,9 +479,9 @@
     0,                                  /* tp_descr_get */
     0,                                  /* tp_descr_set */
     0,                                  /* tp_dictoffset */
-    (initproc)image_surface_init,       /* tp_init */
+    0,                                  /* tp_init */
     0,                                  /* tp_alloc */
-    0,                                  /* tp_new */
+    (newfunc)image_surface_new,         /* tp_new */
     0,                                  /* tp_free */
     0,                                  /* tp_is_gc */
     0,                                  /* tp_bases */
@@ -496,55 +491,54 @@
 /* Class class.PDFSurface ------------------------------------------------- */
 
 PyObject *
-PycairoPDFSurface_FromPDFSurface(cairo_surface_t *surface, PyObject *base)
+PycairoPDFSurface_FromPDFSurface (cairo_surface_t *surface, PyObject *base)
 {
-    PyObject *s;
+    PyObject *o;
 
     assert (surface != NULL);
-    s = PycairoPDFSurface_Type.tp_alloc (&PycairoPDFSurface_Type, 0);
-    if (s) {
-	((PycairoPDFSurface *)s)->surface = surface;
+    o = PycairoPDFSurface_Type.tp_alloc (&PycairoPDFSurface_Type, 0);
+    if (o) {
+	((PycairoPDFSurface *)o)->surface = surface;
 	Py_XINCREF(base);
-	((PycairoPDFSurface *)s)->base = base;
+	((PycairoPDFSurface *)o)->base = base;
     }
-    return s;
+    return o;
 }
 
-static int
-pdf_surface_init(PycairoSurface *s, PyObject *args, PyObject *kwds)
+static PyObject *
+pdf_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
     const char *filename;
-    double width, height;
+    double width_in_points, height_in_points;
     cairo_surface_t *surface;
+    PyObject *o;
 
-    if (!PyArg_ParseTuple(args, "sdd:pdf_surface_create",
-			  &filename, &width, &height))
-	return -1;
-    if (width <= 0) {
-	PyErr_SetString(PyExc_ValueError, "width must be positive");
-	return -1;
-    }
-    if (height <= 0) {
-	PyErr_SetString(PyExc_ValueError, "height must be positive");
-	return -1;
-    }
-    s->surface = cairo_pdf_surface_create (filename, width, height);
-    if (!s->surface) {
-	Py_DECREF(s);
-	PyErr_NoMemory();
-	return -1;
+    if (!PyArg_ParseTuple(args, "sdd:PDFSurface.__new__",
+			  &filename, &width_in_points, &height_in_points))
+	return NULL;
+
+    o = type->tp_alloc(type, 0);
+    if (o) {
+	surface = cairo_pdf_surface_create (filename, width_in_points, 
+					    height_in_points);
+	if (surface) {
+	    ((PycairoPDFSurface *)o)->surface = surface;
+	} else {
+	    Py_DECREF(o);
+	    return PyErr_NoMemory();
+	}
     }
-    return 0;
+    return o;
 }
 
 static PyObject *
-pdf_surface_set_dpi (PycairoPDFSurface *s, PyObject *args)
+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 (s->surface, x_dpi, y_dpi);
+    cairo_pdf_surface_set_dpi (o->surface, x_dpi, y_dpi);
     Py_RETURN_NONE;
 }
 
@@ -590,9 +584,114 @@
     0,                                  /* tp_descr_get */
     0,                                  /* tp_descr_set */
     0,                                  /* tp_dictoffset */
-    (initproc)pdf_surface_init,         /* tp_init */
+    0,                                  /* tp_init */
     0,                                  /* tp_alloc */
-    0,                                  /* tp_new */
+    (newfunc)pdf_surface_new,           /* tp_new */
+    0,                                  /* tp_free */
+    0,                                  /* tp_is_gc */
+    0,                                  /* tp_bases */
+};
+
+
+/* Class class.PSSurface -------------------------------------------------- */
+
+PyObject *
+PycairoPSSurface_FromPSSurface (cairo_surface_t *surface, PyObject *base)
+{
+    PyObject *o;
+
+    assert (surface != NULL);
+    o = PycairoPSSurface_Type.tp_alloc (&PycairoPSSurface_Type, 0);
+    if (o) {
+	((PycairoPSSurface *)o)->surface = surface;
+	Py_XINCREF(base);
+	((PycairoPSSurface *)o)->base = base;
+    }
+    return o;
+}
+
+static PyObject *
+ps_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    const char *filename;
+    double width_in_points, height_in_points;
+    cairo_surface_t *surface;
+    PyObject *o;
+
+    if (!PyArg_ParseTuple(args, "sdd:PSSurface.__new__",
+			  &filename, &width_in_points, &height_in_points))
+	return NULL;
+
+    o = type->tp_alloc(type, 0);
+    if (o) {
+	surface = cairo_ps_surface_create (filename, width_in_points, 
+					   height_in_points);
+	if (surface) {
+	    ((PycairoPSSurface *)o)->surface = surface;
+	} else {
+	    Py_DECREF(o);
+	    return PyErr_NoMemory();
+	}
+    }
+    return o;
+}
+/* declared in cairo-ps.h but function does not exist!
+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 PyMethodDef pssurface_methods[] = {
+    /*{"set_dpi", (PyCFunction)ps_surface_set_dpi,    METH_VARARGS },*/
+    {NULL, NULL, 0, NULL},
+};
+
+PyTypeObject PycairoPSSurface_Type = {
+    PyObject_HEAD_INIT(&PyType_Type)
+    0,                                  /* ob_size */
+    "cairo.PSSurface",                  /* tp_name */
+    sizeof(PycairoPSSurface),           /* tp_basicsize */
+    0,                                  /* tp_itemsize */
+    0,                                  /* tp_dealloc */
+    0,                                  /* tp_print */
+    0,                                  /* tp_getattr */
+    0,                                  /* tp_setattr */
+    0,                                  /* tp_compare */
+    0,                                  /* tp_repr */
+    0,                                  /* tp_as_number */
+    0,                                  /* tp_as_sequence */
+    0,                                  /* tp_as_mapping */
+    0,                                  /* tp_hash */
+    0,                                  /* tp_call */
+    0,                                  /* tp_str */
+    0,                                  /* tp_getattro */
+    0,                                  /* tp_setattro */
+    0,                                  /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
+    0,                                  /* tp_doc */
+    0,                                  /* tp_traverse */
+    0,                                  /* tp_clear */
+    0,                                  /* tp_richcompare */
+    0,                                  /* tp_weaklistoffset */
+    0,                                  /* tp_iter */
+    0,                                  /* tp_iternext */
+    pssurface_methods,                  /* tp_methods */
+    0,                                  /* tp_members */
+    0,                                  /* tp_getset */
+    &PycairoSurface_Type,               /* tp_base */
+    0,                                  /* tp_dict */
+    0,                                  /* tp_descr_get */
+    0,                                  /* tp_descr_set */
+    0,                                  /* tp_dictoffset */
+    0,                                  /* tp_init */
+    0,                                  /* tp_alloc */
+    (newfunc)ps_surface_new,            /* tp_new */
     0,                                  /* tp_free */
     0,                                  /* tp_is_gc */
     0,                                  /* tp_bases */




More information about the cairo-commit mailing list