[cairo-commit] pycairo/cairo Makefile.am, 1.16, 1.17 cairomodule.c, 1.36, 1.37 pycairo.h, 1.35, 1.36 pycairo-private.h, 1.27, 1.28 pycairo-surface.c, 1.43, 1.44

Steve Chaplin commit at pdx.freedesktop.org
Sun May 29 04:11:50 PDT 2005


Committed by: stevech1097

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

Modified Files:
	Makefile.am cairomodule.c pycairo.h pycairo-private.h 
	pycairo-surface.c 
Log Message:
SC

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/Makefile.am,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Makefile.am	26 May 2005 08:26:21 -0000	1.16
+++ Makefile.am	29 May 2005 11:11:48 -0000	1.17
@@ -25,8 +25,8 @@
 if HAVE_LIBSVG_CAIRO
 pycairoexec_LTLIBRARIES += svg.la
 svg_la_LDFLAGS = -module -avoid-version -export-symbols-regex initsvg
-svg_la_LIBADD  = $(CAIRO_LIBS) $(LIBSVG_CAIRO_LIBS)
-svg_la_CPPFLAGS = $(PYTHON_INCLUDES) $(CAIRO_CFLAGS)
+svg_la_LIBADD  = $(LIBSVG_CAIRO_LIBS)
+svg_la_CPPFLAGS = $(PYTHON_INCLUDES) $(LIBSVG_CAIRO_CFLAGS)
 svg_la_SOURCES = \
   pycairosvg.h \
   pycairosvg-private.h \
@@ -36,8 +36,8 @@
 if WITH_PYGTK
 pycairoexec_LTLIBRARIES += gtk.la
 gtk_la_LDFLAGS = -module -avoid-version -export-symbols-regex initgtk
-gtk_la_LIBADD = $(CAIRO_LIBS) $(CAIRO_GTK_LIBS)
-gtk_la_CPPFLAGS = $(PYTHON_INCLUDES) $(CAIRO_CFLAGS) $(CAIRO_GTK_CFLAGS)
+gtk_la_LIBADD = $(CAIRO_LIBS) $(GTK_LIBS)
+gtk_la_CPPFLAGS = $(PYTHON_INCLUDES) $(CAIRO_CFLAGS) $(GTK_CFLAGS)
 gtk_la_SOURCES = \
   cairogtkmodule.c
 endif

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- cairomodule.c	20 May 2005 08:57:44 -0000	1.36
+++ cairomodule.c	29 May 2005 11:11:48 -0000	1.37
@@ -88,10 +88,6 @@
 	PyErr_SetString(CairoError, "the surface type is not appropriate for "
 			"the operation");
 	return 1;
-    case CAIRO_STATUS_BAD_NESTING:
-	PyErr_SetString(CairoError, "drawing operations interleaved for two "
-			"contexts for the same surface");
-	return 1;
     default:
 	PyErr_SetString(CairoError, "<unknown error status>");
 	return 1;
@@ -102,29 +98,30 @@
 /* C API.  Clients get at this via Pycairo_IMPORT, defined in pycairo.h.
  */
 static Pycairo_CAPI_t CAPI = {
-    &PycairoContext_Type,  
-    &PycairoFontFace_Type, 
-    &PycairoMatrix_Type,   
-    &PycairoPath_Type,  
-    &PycairoPattern_Type,  
-    &PycairoScaledFont_Type,  
-
-    &PycairoSurface_Type,  
-    &PycairoImageSurface_Type,  
-    &PycairoPDFSurface_Type,  
-    &PycairoPSSurface_Type,  
-
-    PycairoContext_FromContext,
-    PycairoFontFace_FromFontFace,
-    PycairoMatrix_FromMatrix,
-    PycairoPath_FromPath,
-    PycairoPattern_FromPattern,
-    PycairoScaledFont_FromScaledFont,
+    &PycairoContext_Type,      PycairoContext_FromContext,
+    &PycairoFontFace_Type,     PycairoFontFace_FromFontFace,
+    &PycairoMatrix_Type,       PycairoMatrix_FromMatrix,
+    &PycairoPath_Type,         PycairoPath_FromPath,
+    &PycairoPattern_Type,      PycairoPattern_FromPattern,
+    &PycairoScaledFont_Type,   PycairoScaledFont_FromScaledFont,
 
-    PycairoSurface_FromSurface,
-    PycairoImageSurface_FromImageSurface,
-    PycairoPDFSurface_FromPDFSurface,
-    PycairoPSSurface_FromPSSurface,
+    &PycairoSurface_Type,      PycairoSurface_FromSurface,
+    &PycairoImageSurface_Type, PycairoImageSurface_FromImageSurface,
+#ifdef CAIRO_HAS_PDF_SURFACE
+    &PycairoPDFSurface_Type,   PycairoPDFSurface_FromPDFSurface,
+#else
+    0, 0,
+#endif
+#ifdef CAIRO_HAS_PS_SURFACE
+    &PycairoPSSurface_Type,    PycairoPSSurface_FromPSSurface,
+#else
+    0, 0,
+#endif
+#ifdef CAIRO_HAS_WIN32_SURFACE
+    &PycairoWin32Surface_Type, PycairoWin32Surface_FromWin32Surface,
+#else
+    0, 0,
+#endif
 
     Pycairo_Check_Status,
 };
@@ -151,10 +148,18 @@
         return;
     if (PyType_Ready(&PycairoImageSurface_Type) < 0)
         return;
+#ifdef CAIRO_HAS_PDF_SURFACE
     if (PyType_Ready(&PycairoPDFSurface_Type) < 0)
         return;
+#endif
+#ifdef CAIRO_HAS_PS_SURFACE
     if (PyType_Ready(&PycairoPSSurface_Type) < 0)
         return;
+#endif
+#ifdef CAIRO_HAS_WIN32_SURFACE
+    if (PyType_Ready(&PycairoWin32Surface_Type) < 0)
+        return;
+#endif
 
     m = Py_InitModule("cairo._cairo", NULL);
 
@@ -178,10 +183,22 @@
     Py_INCREF(&PycairoImageSurface_Type);
     PyModule_AddObject(m, "ImageSurface", 
 		       (PyObject *)&PycairoImageSurface_Type);
+
+#ifdef CAIRO_HAS_PDF_SURFACE
     Py_INCREF(&PycairoPDFSurface_Type);
     PyModule_AddObject(m, "PDFSurface", (PyObject *)&PycairoPDFSurface_Type);
+#endif
+
+#ifdef CAIRO_HAS_PS_SURFACE
     Py_INCREF(&PycairoPSSurface_Type);
     PyModule_AddObject(m, "PSSurface", (PyObject *)&PycairoPSSurface_Type);
+#endif
+
+#ifdef CAIRO_HAS_WIN32_SURFACE
+    Py_INCREF(&PycairoWin32Surface_Type);
+    PyModule_AddObject(m, "Win32Surface", 
+		       (PyObject *)&PycairoWin32Surface_Type);
+#endif
 
     PyModule_AddObject(m, "CAPI", PyCObject_FromVoidPtr(&CAPI, NULL));
 

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- pycairo.h	24 May 2005 14:29:30 -0000	1.35
+++ pycairo.h	29 May 2005 11:11:48 -0000	1.36
@@ -76,37 +76,38 @@
 #define PycairoImageSurface PycairoSurface
 #define PycairoPDFSurface   PycairoSurface
 #define PycairoPSSurface    PycairoSurface
+#define PycairoWin32Surface PycairoSurface
 
 /* Define structure for C API. */
 typedef struct {
-    /* type objects */
+    /* (type object, constructor) pairs */
     PyTypeObject *Context_Type;
-    PyTypeObject *FontFace_Type;
-    PyTypeObject *Matrix_Type;
-    PyTypeObject *Path_Type;
-    PyTypeObject *Pattern_Type;
-    PyTypeObject *ScaledFont_Type;
-
-    PyTypeObject *Surface_Type;
-    PyTypeObject *ImageSurface_Type;
-    PyTypeObject *PDFSurface_Type;
-    PyTypeObject *PSSurface_Type;
-
-    /* constructors */
     PyObject *(*Context_FromContext)(cairo_t *ctx, PyObject *base);
+    PyTypeObject *FontFace_Type;
     PyObject *(*FontFace_FromFontFace)(cairo_font_face_t *font_face);
+    PyTypeObject *Matrix_Type;
     PyObject *(*Matrix_FromMatrix)(const cairo_matrix_t *matrix);
+    PyTypeObject *Path_Type;
     PyObject *(*Path_FromPath)(cairo_path_t *path);
+    PyTypeObject *Pattern_Type;
     PyObject *(*Pattern_FromPattern)(cairo_pattern_t *pattern);
+    PyTypeObject *ScaledFont_Type;
     PyObject *(*ScaledFont_FromScaledFont)(cairo_scaled_font_t *scaled_font);
 
+    PyTypeObject *Surface_Type;
     PyObject *(*Surface_FromSurface)(cairo_surface_t *surface, PyObject *base);
+    PyTypeObject *ImageSurface_Type;
     PyObject *(*ImageSurface_FromImageSurface)(cairo_surface_t *surface, 
 					       PyObject *base);
+    PyTypeObject *PDFSurface_Type;
     PyObject *(*PDFSurface_FromPDFSurface)(cairo_surface_t *surface, 
 					   PyObject *base);
+    PyTypeObject *PSSurface_Type;
     PyObject *(*PSSurface_FromPSSurface)(cairo_surface_t *surface, 
 					 PyObject *base);
+    PyTypeObject *Win32Surface_Type;
+    PyObject *(*Win32Surface_FromWin32Surface)(cairo_surface_t *surface, 
+					       PyObject *base);
 
     /* misc functions */
     int (*Check_Status)(cairo_status_t status);
@@ -117,31 +118,32 @@
 
 /* Macros for accessing the C API */
 #define PycairoContext_Type         *(Pycairo_CAPI->Context_Type)
-#define PycairoFontFace_Type        *(Pycairo_CAPI->Fontface_Type)
-#define PycairoMatrix_Type          *(Pycairo_CAPI->Matrix_Type)
-#define PycairoPath_Type            *(Pycairo_CAPI->Path_Type)
-#define PycairoPattern_Type         *(Pycairo_CAPI->Pattern_Type)
-#define PycairoScaledFont_Type      *(Pycairo_CAPI->ScaledFont_Type)
-
-#define PycairoSurface_Type         *(Pycairo_CAPI->Surface_Type)
-#define PycairoImageSurface_Type    *(Pycairo_CAPI->ImageSurface_Type)
-#define PycairoPDFSurface_Type      *(Pycairo_CAPI->PDFSurface_Type)
-#define PycairoPSSurface_Type       *(Pycairo_CAPI->PSSurface_Type)
-
 #define PycairoContext_FromContext   (Pycairo_CAPI->Context_FromContext)
+#define PycairoFontFace_Type        *(Pycairo_CAPI->Fontface_Type)
 #define PycairoFontFace_FromFontFace (Pycairo_CAPI->Fontface_FromFontFace)
+#define PycairoMatrix_Type          *(Pycairo_CAPI->Matrix_Type)
 #define PycairoMatrix_FromMatrix     (Pycairo_CAPI->Matrix_FromMatrix)
+#define PycairoPath_Type            *(Pycairo_CAPI->Path_Type)
 #define PycairoPath_FromPath         (Pycairo_CAPI->Path_FromPath)
+#define PycairoPattern_Type         *(Pycairo_CAPI->Pattern_Type)
 #define PycairoPattern_FromPattern   (Pycairo_CAPI->Pattern_FromPattern)
+#define PycairoScaledFont_Type      *(Pycairo_CAPI->ScaledFont_Type)
 #define PycairoScaledFont_FromScaledFont \
         (Pycairo_CAPI->ScaledFont_FromScaledFont)
 
+#define PycairoSurface_Type         *(Pycairo_CAPI->Surface_Type)
 #define PycairoSurface_FromSurface   (Pycairo_CAPI->Surface_FromSurface)
+#define PycairoImageSurface_Type    *(Pycairo_CAPI->ImageSurface_Type)
 #define PycairoImageSurface_FromImageSurface \
         (Pycairo_CAPI->ImageSurface_FromImageSurface)
+#define PycairoPDFSurface_Type      *(Pycairo_CAPI->PDFSurface_Type)
 #define PycairoPDFSurface_FromPDFSurface \
         (Pycairo_CAPI->PDFSurface_FromPDFSurface)
+#define PycairoPSSurface_Type       *(Pycairo_CAPI->PSSurface_Type)
 #define PycairoPSSurface_FromPSSurface (Pycairo_CAPI->PSSurface_FromPSSurface)
+#define PycairoWin32Surface_Type    *(Pycairo_CAPI->Win32Surface_Type)
+#define PycairoWin32Surface_FromPSSurface \
+        (Pycairo_CAPI->Win32Surface_FromWin32Surface)
 
 #define Pycairo_Check_Status         (Pycairo_CAPI->Check_Status)
 

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- pycairo-private.h	20 May 2005 08:57:44 -0000	1.27
+++ pycairo-private.h	29 May 2005 11:11:48 -0000	1.28
@@ -54,6 +54,7 @@
 extern PyTypeObject PycairoImageSurface_Type;
 extern PyTypeObject PycairoPDFSurface_Type;
 extern PyTypeObject PycairoPSSurface_Type;
+extern PyTypeObject PycairoWin32Surface_Type;
 
 PyObject *PycairoContext_FromContext (cairo_t *ctx, PyObject *base);
 PyObject *PycairoFontFace_FromFontFace (cairo_font_face_t *font_face);
@@ -70,6 +71,8 @@
 					    PyObject *base);
 PyObject *PycairoPSSurface_FromPSSurface (cairo_surface_t *surface, 
 					  PyObject *base);
+PyObject *PycairoWin32Surface_FromWin32Surface (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.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- pycairo-surface.c	20 May 2005 08:57:44 -0000	1.43
+++ pycairo-surface.c	29 May 2005 11:11:48 -0000	1.44
@@ -36,20 +36,13 @@
 
 #include "pycairo-private.h"
 
-#ifdef CAIRO_HAS_PDF_SURFACE
-#  include <cairo-pdf.h>
-#endif
-#ifdef CAIRO_HAS_PS_SURFACE
-#  include <cairo-ps.h>
-#endif
-
 
 #ifdef HAVE_NUMPY
 #  include <Numeric/arrayobject.h>
    static int load_numpy (void);
 #endif
 
-/* Class cairo.Surface ---------------------------------------------------- */
+/* Class Surface ---------------------------------------------------------- */
 
 /* PycairoSurface_FromSurface
  * Create a new PycairoSurface from a cairo_surface_t
@@ -231,7 +224,7 @@
 };
 
 
-/* Class cairo.ImageSurface ----------------------------------------------- */
+/* Class ImageSurface(Surface) -------------------------------------------- */
 
 PyObject *
 PycairoImageSurface_FromImageSurface (cairo_surface_t *surface, PyObject *base)
@@ -488,7 +481,9 @@
 };
 
 
-/* Class class.PDFSurface ------------------------------------------------- */
+/* Class PDFSurface(Surface) ---------------------------------------------- */
+#ifdef CAIRO_HAS_PDF_SURFACE
+#include <cairo-pdf.h>
 
 PyObject *
 PycairoPDFSurface_FromPDFSurface (cairo_surface_t *surface, PyObject *base)
@@ -591,9 +586,12 @@
     0,                                  /* tp_is_gc */
     0,                                  /* tp_bases */
 };
+#endif /* CAIRO_HAS_PDF_SURFACE */
 
 
-/* Class class.PSSurface -------------------------------------------------- */
+/* Class PSSurface(Surface) ----------------------------------------------- */
+#ifdef CAIRO_HAS_PS_SURFACE
+#include <cairo-ps.h>
 
 PyObject *
 PycairoPSSurface_FromPSSurface (cairo_surface_t *surface, PyObject *base)
@@ -696,6 +694,100 @@
     0,                                  /* tp_is_gc */
     0,                                  /* tp_bases */
 };
+#endif  /* CAIRO_HAS_PS_SURFACE */
+
+
+/* Class Win32Surface(Surface) -------------------------------------------- */
+#if CAIRO_HAS_WIN32_SURFACE
+#include <cairo-win32.h>
+
+PyObject *
+PycairoWin32Surface_FromWin32Surface (cairo_surface_t *surface, PyObject *base)
+{
+    PyObject *o;
+
+    assert (surface != NULL);
+    o = PycairoWin32Surface_Type.tp_alloc (&PycairoWin32Surface_Type, 0);
+    if (o) {
+	((PycairoWin32Surface *)o)->surface = surface;
+	Py_XINCREF(base);
+	((PycairoWin32Surface *)o)->base = base;
+    }
+    return o;
+}
+
+static PyObject *
+win32_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    int hdc;
+    cairo_surface_t *surface;
+    PyObject *o;
+
+    if (!PyArg_ParseTuple(args, "i:Win32Surface.__new__",  &hdc))
+	return NULL;
+
+    o = type->tp_alloc(type, 0);
+    if (o) {
+	surface = cairo_win32_surface_create ((HDC)hdc);
+	if (surface) {
+	    ((PycairoPSSurface *)o)->surface = surface;
+	} else {
+	    Py_DECREF(o);
+	    return PyErr_NoMemory();
+	}
+    }
+    return o;
+}
+
+static PyMethodDef win32surface_methods[] = {
+    {NULL, NULL, 0, NULL},
+};
+
+PyTypeObject PycairoWin32Surface_Type = {
+    PyObject_HEAD_INIT(&PyType_Type)
+    0,                                  /* ob_size */
+    "cairo.Win32Surface",               /* tp_name */
+    sizeof(PycairoWin32Surface),        /* 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 */
+    win32surface_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)win32_surface_new,         /* tp_new */
+    0,                                  /* tp_free */
+    0,                                  /* tp_is_gc */
+    0,                                  /* tp_bases */
+};
+#endif  /* CAIRO_HAS_WIN32_SURFACE */
 
 
 /* Numeric routines ------------------------------------------------------- */




More information about the cairo-commit mailing list