[cairo-commit] pycairo/cairo pycairo-surface.c, 1.38, 1.39 cairosvgmodule.c, 1.5, 1.6

Steve Chaplin commit at pdx.freedesktop.org
Sun May 15 18:05:30 PDT 2005


Committed by: stevech1097

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

Modified Files:
	pycairo-surface.c cairosvgmodule.c 
Log Message:
SC

Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- pycairo-surface.c	14 May 2005 01:26:31 -0000	1.38
+++ pycairo-surface.c	16 May 2005 01:05:28 -0000	1.39
@@ -521,32 +521,22 @@
 pdf_surface_init(PycairoSurface *s, PyObject *args, PyObject *kwds)
 {
     PyObject *file_object;
-    int width_inches, height_inches, x_pixels_per_inch, y_pixels_per_inch;
+    double width, height;
     cairo_surface_t *surface;
 
-    if (!PyArg_ParseTuple(args, "O!iiii:pdf_surface_create",
-			  &PyFile_Type, &file_object, &width_inches, 
-			  &height_inches, &x_pixels_per_inch, 
-			  &y_pixels_per_inch))
-	return -1;
-    if (width_inches <= 0) {
-	PyErr_SetString(PyExc_ValueError, "width_inches must be positive");
-	return -1;
-    }
-    if (height_inches <= 0) {
-	PyErr_SetString(PyExc_ValueError, "height_inches must be positive");
+    if (!PyArg_ParseTuple(args, "O!dd:pdf_surface_create",
+			  &PyFile_Type, &file_object, &width, &height))
 	return -1;
-    }
-    if (x_pixels_per_inch <= 0) {
-	PyErr_SetString(PyExc_ValueError, "x_pixels_per_inch must be positive");
+    if (width <= 0) {
+	PyErr_SetString(PyExc_ValueError, "width must be positive");
 	return -1;
     }
-    if (y_pixels_per_inch <= 0) {
-	PyErr_SetString(PyExc_ValueError, "y_pixels_per_inch must be positive");
+    if (height <= 0) {
+	PyErr_SetString(PyExc_ValueError, "height must be positive");
 	return -1;
     }
     s->surface = cairo_pdf_surface_create(PyFile_AsFile(file_object), 
-	    width_inches, height_inches, x_pixels_per_inch, y_pixels_per_inch);
+					  width, height);
     if (!s->surface) {
 	Py_DECREF(s);
 	PyErr_NoMemory();

Index: cairosvgmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairosvgmodule.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairosvgmodule.c	14 May 2005 01:15:06 -0000	1.5
+++ cairosvgmodule.c	16 May 2005 01:05:28 -0000	1.6
@@ -62,39 +62,40 @@
 }
 
 
-
 /* if status reports an error, then return 1 (True) and set the exception */
 static int
-_status_error (svg_cairo_status_t status)
+Pycairosvg_check_status (svg_cairo_status_t status)
 {
     switch (status) {
     case SVG_CAIRO_STATUS_SUCCESS:
 	return 0;
     case SVG_CAIRO_STATUS_NO_MEMORY:
 	PyErr_NoMemory();
-	return 1;
+	break;
     case SVG_CAIRO_STATUS_IO_ERROR:
 	PyErr_SetString(PyExc_IOError, "IO Error");
-	return 1;
+	break;
     case SVG_CAIRO_STATUS_FILE_NOT_FOUND:
 	PyErr_SetString(PyExc_RuntimeError, "File not found");
-	return 1;
+	break;
     case SVG_CAIRO_STATUS_INVALID_VALUE:
 	PyErr_SetString(PyExc_RuntimeError, "Invalid value");
-	return 1;
+	break;
     case SVG_CAIRO_STATUS_INVALID_CALL:
 	PyErr_SetString(PyExc_RuntimeError, "Invalid call");
-	return 1;
+	break;
     case SVG_CAIRO_STATUS_PARSE_ERROR:
 	PyErr_SetString(PyExc_RuntimeError, "Parse error");
-	return 1;
+	break;
     default:
 	PyErr_SetString(PyExc_RuntimeError, "other cairo.svg error");
-	return 1;
     }
+    return 1;
 }
 
 
+/* class cairosvg.Context ------------------------------------------------- */
+
 static void
 pycairosvg_dealloc(PycairoSVGContext* self)                  
 {
@@ -110,16 +111,13 @@
 pycairosvg_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {               
     PycairoSVGContext *self = (PycairoSVGContext *)type->tp_alloc(type, 0);
-    if (self && _status_error (svg_cairo_create (&self->ctx))) {
+    if (self && Pycairosvg_check_status (svg_cairo_create (&self->ctx))) {
 	Py_DECREF(self);
 	return NULL;
     }
     return (PyObject *)self;
 }
 
-/* static int pycairosvg_init () not needed */
-
-
 static PyObject *
 pycairosvg_parse (PycairoSVGContext *self, PyObject *args)
 {
@@ -128,7 +126,7 @@
     if (!PyArg_ParseTuple(args, "s:Context.parse", &filename))
 	return NULL;
 
-    if (_status_error (svg_cairo_parse (self->ctx, filename)))
+    if (Pycairosvg_check_status (svg_cairo_parse (self->ctx, filename)))
 	return NULL;
     Py_RETURN_NONE;
 }
@@ -143,7 +141,7 @@
 	return NULL;
 
     //svg_cairo_status_t svg_cairo_parse_buffer (svg_cairo_t *svg_cairo, const char *buf, size_t count);
-    if (_status_error (svg_cairo_parse_buffer (self->ctx, buf, count)))
+    if (Pycairosvg_check_status (svg_cairo_parse_buffer (self->ctx, buf, count)))
     	return NULL;
     Py_RETURN_NONE;
 }
@@ -157,7 +155,7 @@
 			  &PycairoContext_Type, &xrs))
 	return NULL;
 
-    if (_status_error (svg_cairo_render (self->ctx, xrs->ctx)))
+    if (Pycairosvg_check_status (svg_cairo_render (self->ctx, xrs->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
@@ -228,7 +226,7 @@
     0,                         		/* tp_descr_get */
     0,                         		/* tp_descr_set */
     0,                         		/* tp_dictoffset */
-    (initproc)0,               		/* tp_init */
+    0,               		        /* tp_init */
     0,                         		/* tp_alloc */
-    pycairosvg_new,            		/* tp_new */
+    (newfunc)pycairosvg_new,   		/* tp_new */
 };




More information about the cairo-commit mailing list