[cairo-commit] pycairo/cairo pycairo-context.c,1.71,1.72
Steve Chaplin
commit at pdx.freedesktop.org
Sun Apr 30 01:43:08 PDT 2006
Committed by: stevech1097
Update of /cvs/cairo/pycairo/cairo
In directory kemper:/tmp/cvs-serv3651/cairo
Modified Files:
pycairo-context.c
Log Message:
'SC'
Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- pycairo-context.c 29 Apr 2006 10:32:44 -0000 1.71
+++ pycairo-context.c 30 Apr 2006 08:43:06 -0000 1.72
@@ -35,6 +35,16 @@
#endif
#include "pycairo-private.h"
+#define RETURN_NULL_IF_CONTEXT_STATUS_ERROR(obj) \
+ do { \
+ cairo_status_t status = cairo_status (obj->ctx); \
+ if (status != CAIRO_STATUS_SUCCESS) { \
+ Pycairo_Check_Status (status); \
+ return NULL; \
+ } \
+ } while (0)
+
+
/* Take a PyBaseString (str or unicode) object and return a pointer to the
* UTF-8 encoded string.
*/
@@ -122,7 +132,7 @@
return NULL;
o = type->tp_alloc(type, 0);
- if (o) {
+ if (o != NULL) {
cairo_t *ctx = cairo_create (s->surface);
if (Pycairo_Check_Status (cairo_status (ctx))) {
cairo_destroy (ctx);
@@ -144,8 +154,7 @@
return NULL;
cairo_append_path (o->ctx, p->path);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -159,8 +168,7 @@
return NULL;
cairo_arc (o->ctx, xc, yc, radius, angle1, angle2);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -174,8 +182,7 @@
return NULL;
cairo_arc_negative (o->ctx, xc, yc, radius, angle1, angle2);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -183,8 +190,7 @@
pycairo_clip (PycairoContext *o)
{
cairo_clip (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -192,8 +198,7 @@
pycairo_clip_preserve (PycairoContext *o)
{
cairo_clip_preserve (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -201,8 +206,7 @@
pycairo_close_path (PycairoContext *o)
{
cairo_close_path (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -210,8 +214,7 @@
pycairo_copy_page (PycairoContext *o)
{
cairo_copy_page (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -237,8 +240,7 @@
return NULL;
cairo_curve_to (o->ctx, x1, y1, x2, y2, x3, y3);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -251,8 +253,7 @@
return NULL;
cairo_device_to_user(o->ctx, &x, &y);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
return Py_BuildValue("(dd)", x, y);
}
@@ -266,8 +267,7 @@
return NULL;
cairo_device_to_user_distance (o->ctx, &dx, &dy);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
return Py_BuildValue("(dd)", dx, dy);
}
@@ -275,8 +275,7 @@
pycairo_fill (PycairoContext *o)
{
cairo_fill (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -285,8 +284,7 @@
{
double x1, y1, x2, y2;
cairo_fill_extents (o->ctx, &x1, &y1, &x2, &y2);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
return Py_BuildValue("(dddd)", x1, y1, x2, y2);
}
@@ -294,8 +292,7 @@
pycairo_fill_preserve (PycairoContext *o)
{
cairo_fill_preserve (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -305,8 +302,7 @@
cairo_font_extents_t e;
cairo_font_extents (o->ctx, &e);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
return Py_BuildValue("(ddddd)", e.ascent, e.descent, e.height,
e.max_x_advance, e.max_y_advance);
}
@@ -335,8 +331,7 @@
pycairo_get_font_face (PycairoContext *o)
{
return PycairoFontFace_FromFontFace (
- cairo_font_face_reference (
- cairo_get_font_face (o->ctx)));
+ cairo_font_face_reference (cairo_get_font_face (o->ctx)));
}
static PyObject *
@@ -386,29 +381,28 @@
static PyObject *
pycairo_get_miter_limit (PycairoContext *o)
{
- return PyFloat_FromDouble(cairo_get_miter_limit(o->ctx));
+ return PyFloat_FromDouble (cairo_get_miter_limit (o->ctx));
}
static PyObject *
pycairo_get_operator (PycairoContext *o)
{
- return PyInt_FromLong(cairo_get_operator (o->ctx));
+ return PyInt_FromLong (cairo_get_operator (o->ctx));
}
static PyObject *
pycairo_get_source (PycairoContext *o)
{
- cairo_pattern_t *pattern = cairo_get_source (o->ctx);
- cairo_pattern_reference (pattern);
- return PycairoPattern_FromPattern (pattern);
+ return PycairoPattern_FromPattern (
+ cairo_pattern_reference (cairo_get_source (o->ctx)));
}
static PyObject *
pycairo_get_target (PycairoContext *o)
{
- cairo_surface_t *surface = cairo_get_target (o->ctx);
- cairo_surface_reference (surface);
- return PycairoSurface_FromSurface (surface, NULL);
+ return PycairoSurface_FromSurface (
+ cairo_surface_reference (cairo_get_target (o->ctx)),
+ NULL);
}
static PyObject *
@@ -421,8 +415,7 @@
pycairo_identity_matrix (PycairoContext *o)
{
cairo_identity_matrix (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -436,8 +429,7 @@
return NULL;
result = cairo_in_fill (o->ctx, x, y) ? Py_True : Py_False;
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_INCREF(result);
return result;
}
@@ -452,8 +444,7 @@
return NULL;
result = cairo_in_stroke (o->ctx, x, y) ? Py_True : Py_False;
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_INCREF(result);
return result;
}
@@ -467,8 +458,7 @@
return NULL;
cairo_line_to (o->ctx, x, y);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -481,8 +471,7 @@
return NULL;
cairo_mask (o->ctx, p->pattern);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -497,8 +486,7 @@
return NULL;
cairo_mask_surface (o->ctx, s->surface, surface_x, surface_y);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -511,8 +499,7 @@
return NULL;
cairo_move_to (o->ctx, x, y);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -520,8 +507,7 @@
pycairo_new_path (PycairoContext *o)
{
cairo_new_path (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -529,8 +515,7 @@
pycairo_new_sub_path (PycairoContext *o)
{
cairo_new_sub_path (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -538,8 +523,7 @@
pycairo_paint (PycairoContext *o)
{
cairo_paint (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -552,8 +536,7 @@
return NULL;
cairo_paint_with_alpha (o->ctx, alpha);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -567,8 +550,7 @@
return NULL;
cairo_rectangle (o->ctx, x, y, width, height);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -582,8 +564,7 @@
return NULL;
cairo_rel_curve_to (o->ctx, dx1, dy1, dx2, dy2, dx3, dy3);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -596,8 +577,7 @@
return NULL;
cairo_rel_line_to (o->ctx, dx, dy);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -610,8 +590,7 @@
return NULL;
cairo_rel_move_to (o->ctx, dx, dy);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -619,8 +598,7 @@
pycairo_reset_clip (PycairoContext *o)
{
cairo_reset_clip (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -628,8 +606,7 @@
pycairo_restore (PycairoContext *o)
{
cairo_restore (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -642,8 +619,7 @@
return NULL;
cairo_rotate (o->ctx, angle);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -651,8 +627,7 @@
pycairo_save (PycairoContext *o)
{
cairo_save (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -665,8 +640,7 @@
return NULL;
cairo_scale (o->ctx, sx, sy);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -683,12 +657,11 @@
return NULL;
family = __PyBaseString_AsUTF8 (obj);
- if (family==NULL)
+ if (family == NULL)
return NULL;
cairo_select_font_face (o->ctx, family, slant, weight);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -701,8 +674,7 @@
return NULL;
cairo_set_antialias (o->ctx, antialias);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -737,8 +709,7 @@
cairo_set_dash (o->ctx, dashes, ndash, offset);
free (dashes);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -751,8 +722,7 @@
return NULL;
cairo_set_fill_rule (o->ctx, fill_rule);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -766,8 +736,7 @@
return NULL;
cairo_set_font_matrix (o->ctx, &matrix->matrix);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -784,9 +753,7 @@
"cairo.FontFace or None");
return NULL;
}
-
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -800,8 +767,7 @@
return NULL;
cairo_set_font_options (o->ctx, options->font_options);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -814,8 +780,7 @@
return NULL;
cairo_set_font_size (o->ctx, size);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -828,8 +793,7 @@
return NULL;
cairo_set_line_cap (o->ctx, line_cap);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -842,8 +806,7 @@
return NULL;
cairo_set_line_join (o->ctx, line_join);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -856,8 +819,7 @@
return NULL;
cairo_set_line_width (o->ctx, width);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -871,8 +833,7 @@
return NULL;
cairo_set_matrix (o->ctx, &matrix->matrix);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -885,8 +846,7 @@
return NULL;
cairo_set_miter_limit (o->ctx, limit);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -899,8 +859,7 @@
return NULL;
cairo_set_operator(o->ctx, op);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -914,8 +873,7 @@
return NULL;
cairo_set_source (o->ctx, p->pattern);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -929,8 +887,7 @@
return NULL;
cairo_set_source_rgb (o->ctx, red, green, blue);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -945,8 +902,7 @@
return NULL;
cairo_set_source_rgba (o->ctx, red, green, blue, alpha);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -961,8 +917,7 @@
return NULL;
cairo_set_source_surface (o->ctx, surface->surface, x, y);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -975,8 +930,7 @@
return NULL;
cairo_set_tolerance (o->ctx, tolerance);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -984,8 +938,7 @@
pycairo_show_page (PycairoContext *o)
{
cairo_show_page (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -1001,8 +954,7 @@
}
cairo_show_text (o->ctx, utf8);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -1010,8 +962,7 @@
pycairo_stroke (PycairoContext *o)
{
cairo_stroke (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -1020,8 +971,7 @@
{
double x1, y1, x2, y2;
cairo_stroke_extents (o->ctx, &x1, &y1, &x2, &y2);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
return Py_BuildValue("(dddd)", x1, y1, x2, y2);
}
@@ -1029,8 +979,7 @@
pycairo_stroke_preserve (PycairoContext *o)
{
cairo_stroke_preserve (o->ctx);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -1047,8 +996,7 @@
}
cairo_text_extents (o->ctx, utf8, &extents);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
return Py_BuildValue("(dddddd)", extents.x_bearing, extents.y_bearing,
extents.width, extents.height, extents.x_advance,
extents.y_advance);
@@ -1066,8 +1014,7 @@
}
cairo_text_path (o->ctx, utf8);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -1080,8 +1027,7 @@
return NULL;
cairo_translate (o->ctx, tx, ty);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -1095,8 +1041,7 @@
return NULL;
cairo_transform (o->ctx, &matrix->matrix);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
Py_RETURN_NONE;
}
@@ -1109,8 +1054,7 @@
return NULL;
cairo_user_to_device (o->ctx, &x, &y);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
return Py_BuildValue("(dd)", x, y);
}
@@ -1124,8 +1068,7 @@
return NULL;
cairo_user_to_device_distance (o->ctx, &dx, &dy);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
+ RETURN_NULL_IF_CONTEXT_STATUS_ERROR(o);
return Py_BuildValue("(dd)", dx, dy);
}
More information about the cairo-commit
mailing list