[cairo-commit] pycairo/cairo cairomodule.c, 1.51,
1.52 pycairo-private.h, 1.37, 1.38 pycairo.h, 1.46,
1.47 pycairo-surface.c, 1.65, 1.66
Steve Chaplin
commit at pdx.freedesktop.org
Sun Apr 30 19:20:17 PDT 2006
Committed by: stevech1097
Update of /cvs/cairo/pycairo/cairo
In directory kemper:/tmp/cvs-serv4048/cairo
Modified Files:
cairomodule.c pycairo-private.h pycairo.h pycairo-surface.c
Log Message:
'SC'
Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- cairomodule.c 23 Jan 2006 03:59:18 -0000 1.51
+++ cairomodule.c 1 May 2006 02:20:15 -0000 1.52
@@ -37,7 +37,7 @@
/* A module specific exception */
-static PyObject *CairoError = NULL;
+PyObject *CairoError = NULL;
int
Pycairo_Check_Status (cairo_status_t status)
@@ -111,6 +111,11 @@
#else
0,
#endif
+#ifdef CAIRO_HAS_XLIB_SURFACE
+ &PycairoXlibSurface_Type,
+#else
+ 0,
+#endif
PycairoSurface_FromSurface,
Pycairo_Check_Status,
@@ -206,6 +211,11 @@
if (PyType_Ready(&PycairoWin32Surface_Type) < 0)
return;
#endif
+#ifdef CAIRO_HAS_XLIB_SURFACE
+ PycairoXlibSurface_Type.tp_base = &PycairoSurface_Type;
+ if (PyType_Ready(&PycairoXlibSurface_Type) < 0)
+ return;
+#endif
m = Py_InitModule("cairo._cairo", cairo_functions);
@@ -268,6 +278,12 @@
(PyObject *)&PycairoWin32Surface_Type);
#endif
+#ifdef CAIRO_HAS_XLIB_SURFACE
+ Py_INCREF(&PycairoXlibSurface_Type);
+ PyModule_AddObject(m, "XlibSurface",
+ (PyObject *)&PycairoXlibSurface_Type);
+#endif
+
PyModule_AddObject(m, "CAPI", PyCObject_FromVoidPtr(&CAPI, NULL));
/* Add 'cairo.Error' to the module */
Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- pycairo-private.h 29 Apr 2006 10:32:44 -0000 1.37
+++ pycairo-private.h 1 May 2006 02:20:15 -0000 1.38
@@ -41,6 +41,8 @@
#include "pycairo.h"
+extern PyObject *CairoError;
+
char * __PyBaseString_AsUTF8 (PyObject *o);
extern PyTypeObject PycairoContext_Type;
@@ -90,8 +92,12 @@
extern PyTypeObject PycairoWin32Surface_Type;
#endif
+#if CAIRO_HAS_XLIB_SURFACE
+extern PyTypeObject PycairoXlibSurface_Type;
+#endif
+
PyObject *PycairoSurface_FromSurface (cairo_surface_t *surface,
- PyObject *base);
+ PyObject *base);
int Pycairo_Check_Status (cairo_status_t status);
Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- pycairo.h 25 Apr 2006 02:45:59 -0000 1.46
+++ pycairo.h 1 May 2006 02:20:15 -0000 1.47
@@ -89,6 +89,7 @@
#define PycairoPSSurface PycairoSurface
#define PycairoSVGSurface PycairoSurface
#define PycairoWin32Surface PycairoSurface
+#define PycairoXlibSurface PycairoSurface
/* get C object out of the Python wrapper */
#define PycairoContext_GET(obj) (((PycairoContext *)(obj))->ctx)
@@ -126,8 +127,8 @@
PyTypeObject *PSSurface_Type;
PyTypeObject *SVGSurface_Type;
PyTypeObject *Win32Surface_Type;
- PyObject *(*Surface_FromSurface)(cairo_surface_t *surface,
- PyObject *base);
+ PyTypeObject *XlibSurface_Type;
+ PyObject *(*Surface_FromSurface)(cairo_surface_t *surface, PyObject *base);
/* misc functions */
int (*Check_Status)(cairo_status_t status);
@@ -180,6 +181,10 @@
#define PycairoWin32Surface_Type *(Pycairo_CAPI->Win32Surface_Type)
#endif
+#if CAIRO_HAS_XLIB_SURFACE
+#define PycairoXlibSurface_Type *(Pycairo_CAPI->XlibSurface_Type)
+#endif
+
#define PycairoSurface_FromSurface (Pycairo_CAPI->Surface_FromSurface)
#define Pycairo_Check_Status (Pycairo_CAPI->Check_Status)
Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- pycairo-surface.c 29 Apr 2006 07:26:08 -0000 1.65
+++ pycairo-surface.c 1 May 2006 02:20:15 -0000 1.66
@@ -82,18 +82,24 @@
type = &PycairoPSSurface_Type;
break;
#endif
+#if CAIRO_HAS_SVG_SURFACE
+ case CAIRO_SURFACE_TYPE_SVG:
+ type = &PycairoSVGSurface_Type;
+ break;
+#endif
#if CAIRO_HAS_WIN32_SURFACE
case CAIRO_SURFACE_TYPE_WIN32:
type = &PycairoWin32Surface_Type;
break;
#endif
-#if CAIRO_HAS_SVG_SURFACE
- case CAIRO_SURFACE_TYPE_SVG:
- type = &PycairoSVGSurface_Type;
+#if CAIRO_HAS_XLIB_SURFACE
+ case CAIRO_SURFACE_TYPE_XLIB:
+ type = &PycairoXlibSurface_Type;
break;
#endif
default:
- ASSERT_NOT_REACHED;
+ PyErr_SetString(CairoError, "Unsupported Surface type");
+ return NULL;
}
o = type->tp_alloc (type, 0);
@@ -1059,6 +1065,69 @@
#endif /* CAIRO_HAS_WIN32_SURFACE */
+/* Class XlibSurface(Surface) --------------------------------------------- */
+#ifdef CAIRO_HAS_XLIB_SURFACE
+#include <cairo-xlib.h>
+
+static PyObject *
+xlib_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PyErr_SetString(PyExc_TypeError,
+ "The XlibSurface type cannot be directly instantiated");
+ return NULL;
+}
+
+static PyMethodDef xlib_surface_methods[] = {
+ {NULL, NULL, 0, NULL},
+};
+
+PyTypeObject PycairoXlibSurface_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "cairo.XlibSurface", /* tp_name */
+ sizeof(PycairoXlibSurface), /* 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 */
+ xlib_surface_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* &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)xlib_surface_new, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+};
+#endif /* CAIRO_HAS_XLIB_SURFACE */
+
+
/* Numeric routines ------------------------------------------------------- */
#ifdef HAVE_NUMPY
More information about the cairo-commit
mailing list