[cairo-commit] pycairo/cairo pycairo-private.h, 1.41, 1.42 pycairo-font.c, 1.33, 1.34 pycairo-matrix.c, 1.24, 1.25 pycairo-context.c, 1.77, 1.78

Steve Chaplin commit at pdx.freedesktop.org
Sun Jan 7 17:17:53 PST 2007


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory kemper:/tmp/cvs-serv25481/cairo

Modified Files:
	pycairo-private.h pycairo-font.c pycairo-matrix.c 
	pycairo-context.c 
Log Message:
'SC'

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- pycairo-private.h	28 Dec 2006 07:55:48 -0000	1.41
+++ pycairo-private.h	8 Jan 2007 01:17:49 -0000	1.42
@@ -154,5 +154,23 @@
 	}                                        \
     } while (0)
 
+#define RETURN_NULL_IF_CAIRO_SCALED_FONT_ERROR(sc_font) \
+    do {                                         \
+	cairo_status_t status = cairo_scaled_font_status (sc_font); \
+	if (status != CAIRO_STATUS_SUCCESS) {    \
+	    Pycairo_Check_Status (status);       \
+            return NULL;		         \
+	}                                        \
+    } while (0)
+
+#define RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(fo) \
+    do {                                         \
+	cairo_status_t status = cairo_font_options_status (fo); \
+	if (status != CAIRO_STATUS_SUCCESS) {    \
+	    Pycairo_Check_Status (status);       \
+            return NULL;		         \
+	}                                        \
+    } while (0)
+
 
 #endif /* _PYCAIRO_PRIVATE_H_ */

Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- pycairo-font.c	21 Dec 2006 04:44:22 -0000	1.33
+++ pycairo-font.c	8 Jan 2007 01:17:49 -0000	1.34
@@ -197,7 +197,6 @@
     PycairoFontFace *ff;
     PycairoFontOptions *fo;
     PycairoMatrix *mx1, *mx2;
-    PyObject *o;
 
     if (!PyArg_ParseTuple(args, "O!O!O!O!:ScaledFont.__new__",
 			  &PycairoFontFace_Type, &ff,
@@ -205,20 +204,9 @@
 			  &PycairoMatrix_Type, &mx2,
 			  &PycairoFontOptions_Type, &fo))
 	return NULL;
-
-    o = type->tp_alloc(type, 0);
-    if (o != NULL) {
-	cairo_scaled_font_t *scaled_font = cairo_scaled_font_create
-	    (ff->font_face, &mx1->matrix, &mx2->matrix, fo->font_options);
-
-	if (Pycairo_Check_Status (cairo_scaled_font_status (scaled_font))) {
-	    cairo_scaled_font_destroy (scaled_font);
-	    Py_DECREF(o);
-	    return NULL;
-	}
-	((PycairoScaledFont *)o)->scaled_font = scaled_font;
-    }
-    return o;
+    return PycairoScaledFont_FromScaledFont (
+               cairo_scaled_font_create (ff->font_face, &mx1->matrix,
+					 &mx2->matrix, fo->font_options));
 }
 
 static PyObject *
@@ -227,8 +215,7 @@
     cairo_font_extents_t e;
 
     cairo_scaled_font_extents (o->scaled_font, &e);
-    if (Pycairo_Check_Status (cairo_scaled_font_status(o->scaled_font)))
-	return NULL;
+    RETURN_NULL_IF_CAIRO_SCALED_FONT_ERROR(o->scaled_font);
     return Py_BuildValue ("(ddddd)", e.ascent, e.descent, e.height,
 			  e.max_x_advance, e.max_y_advance);
 }
@@ -254,8 +241,7 @@
     }
 
     cairo_scaled_font_text_extents (o->scaled_font, utf8, &extents);
-    if (Pycairo_Check_Status (cairo_scaled_font_status(o->scaled_font)))
-	return NULL;
+    RETURN_NULL_IF_CAIRO_SCALED_FONT_ERROR(sc_font);
     return Py_BuildValue("(dddddd)", extents.x_bearing, extents.y_bearing,
 			 extents.width, extents.height, extents.x_advance,
 			 extents.y_advance);
@@ -373,18 +359,7 @@
 static PyObject *
 font_options_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-    PyObject *o = type->tp_alloc(type, 0);
-    if (o != NULL) {
-	cairo_font_options_t *font_options = cairo_font_options_create();
-
-	if (Pycairo_Check_Status (cairo_font_options_status (font_options))) {
-	    cairo_font_options_destroy (font_options);
-	    Py_DECREF(o);
-	    return NULL;
-	}
-	((PycairoFontOptions *)o)->font_options = font_options;
-    }
-    return o;
+    return PycairoFontOptions_FromFontOptions (cairo_font_options_create());
 }
 
 static PyObject *
@@ -423,8 +398,7 @@
 	return NULL;
 
     cairo_font_options_set_antialias (o->font_options, aa);
-    if (Pycairo_Check_Status (cairo_font_options_status (o->font_options)))
-	return NULL;
+    RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options);
     Py_RETURN_NONE;
 }
 
@@ -437,8 +411,7 @@
 	return NULL;
 
     cairo_font_options_set_hint_metrics (o->font_options, hm);
-    if (Pycairo_Check_Status (cairo_font_options_status (o->font_options)))
-	return NULL;
+    RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options);
     Py_RETURN_NONE;
 }
 
@@ -451,8 +424,7 @@
 	return NULL;
 
     cairo_font_options_set_hint_style (o->font_options, hs);
-    if (Pycairo_Check_Status (cairo_font_options_status (o->font_options)))
-	return NULL;
+    RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options);
     Py_RETURN_NONE;
 }
 
@@ -465,8 +437,7 @@
 	return NULL;
 
     cairo_font_options_set_subpixel_order (o->font_options, so);
-    if (Pycairo_Check_Status (cairo_font_options_status (o->font_options)))
-	return NULL;
+    RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options);
     Py_RETURN_NONE;
 }
 

Index: pycairo-matrix.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-matrix.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- pycairo-matrix.c	3 Oct 2005 08:12:14 -0000	1.24
+++ pycairo-matrix.c	8 Jan 2007 01:17:49 -0000	1.25
@@ -40,17 +40,14 @@
  * Create a new PycairoMatrix from a cairo_matrix_t
  * matrix - a cairo_matrix_t to 'wrap' into a Python object
  * Return value: New reference or NULL on failure
- *
- * takes a copy of cairo_matrix_t
  */
 PyObject *
 PycairoMatrix_FromMatrix (const cairo_matrix_t *matrix)
 {
     PyObject *o;
-
     assert (matrix != NULL);
     o = PycairoMatrix_Type.tp_alloc (&PycairoMatrix_Type, 0);
-    if (o)
+    if (o != NULL)
 	((PycairoMatrix *)o)->matrix = *matrix;
     return o;
 }

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- pycairo-context.c	28 Dec 2006 07:55:48 -0000	1.77
+++ pycairo-context.c	8 Jan 2007 01:17:49 -0000	1.78
@@ -205,6 +205,7 @@
 {
     int i;
     PyObject *rv = NULL;
+    cairo_rectangle_t *r;
     cairo_rectangle_list_t *rlist = cairo_copy_clip_rectangles (o->ctx);
     if (rlist->status != CAIRO_STATUS_SUCCESS) {
 	Pycairo_Check_Status (rlist->status);
@@ -215,8 +216,7 @@
     if (rv == NULL)
 	goto exit;
 
-    for (i = 0; i < rlist->num_rectangles; i++) {
-	cairo_rectangle_t *r = &rlist->rectangles[i];
+    for (i = 0, r = rlist->rectangles; i < rlist->num_rectangles; i++, r++) {
 	PyObject *py_rect = Py_BuildValue("(dddd)", r->x, r->y,
 					  r->width, r->height);
 	if (py_rect == NULL) {



More information about the cairo-commit mailing list