commit 585119ed454efe10632740256b7b375a1920cd57 Author: Daniel Beecham Date: Sat Aug 20 18:21:18 2016 +0200 Implement method chaining diff --git a/src/context.c b/src/context.c index 984cdfc..f87665a 100644 --- a/src/context.c +++ b/src/context.c @@ -90,7 +90,8 @@ pycairo_append_path (PycairoContext *o, PyObject *args) { cairo_append_path (o->ctx, p->path); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -103,7 +104,8 @@ pycairo_arc (PycairoContext *o, PyObject *args) { cairo_arc (o->ctx, xc, yc, radius, angle1, angle2); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -116,7 +118,8 @@ pycairo_arc_negative (PycairoContext *o, PyObject *args) { cairo_arc_negative (o->ctx, xc, yc, radius, angle1, angle2); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -125,7 +128,8 @@ pycairo_clip (PycairoContext *o) { cairo_clip (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -142,7 +146,8 @@ pycairo_clip_preserve (PycairoContext *o) { cairo_clip_preserve (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -151,7 +156,8 @@ pycairo_close_path (PycairoContext *o) { cairo_close_path (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -189,7 +195,8 @@ pycairo_copy_page (PycairoContext *o) { cairo_copy_page (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -220,7 +227,8 @@ pycairo_curve_to (PycairoContext *o, PyObject *args) { cairo_curve_to (o->ctx, x1, y1, x2, y2, x3, y3); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -254,7 +262,8 @@ pycairo_fill (PycairoContext *o) { cairo_fill (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -271,7 +280,8 @@ pycairo_fill_preserve (PycairoContext *o) { cairo_fill_preserve (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -511,7 +521,8 @@ pycairo_glyph_path (PycairoContext *o, PyObject *args) { cairo_glyph_path (o->ctx, glyphs, num_glyphs); PyMem_Free (glyphs); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -526,7 +537,8 @@ static PyObject * pycairo_identity_matrix (PycairoContext *o) { cairo_identity_matrix (o->ctx); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -580,7 +592,8 @@ pycairo_line_to (PycairoContext *o, PyObject *args) { cairo_line_to (o->ctx, x, y); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -594,7 +607,8 @@ pycairo_mask (PycairoContext *o, PyObject *args) { cairo_mask (o->ctx, p->pattern); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -610,7 +624,8 @@ pycairo_mask_surface (PycairoContext *o, PyObject *args) { cairo_mask_surface (o->ctx, s->surface, surface_x, surface_y); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -622,21 +637,24 @@ pycairo_move_to (PycairoContext *o, PyObject *args) { cairo_move_to (o->ctx, x, y); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * pycairo_new_path (PycairoContext *o) { cairo_new_path (o->ctx); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * pycairo_new_sub_path (PycairoContext *o) { cairo_new_sub_path (o->ctx); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -645,7 +663,8 @@ pycairo_paint (PycairoContext *o) { cairo_paint (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -659,7 +678,8 @@ pycairo_paint_with_alpha (PycairoContext *o, PyObject *args) { cairo_paint_with_alpha (o->ctx, alpha); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -678,14 +698,16 @@ pycairo_pop_group (PycairoContext *o) { static PyObject * pycairo_pop_group_to_source (PycairoContext *o) { cairo_pop_group_to_source (o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * pycairo_push_group (PycairoContext *o) { cairo_push_group (o->ctx); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -697,7 +719,8 @@ pycairo_push_group_with_content (PycairoContext *o, PyObject *args) { return NULL; cairo_push_group_with_content (o->ctx, content); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -710,7 +733,8 @@ pycairo_rectangle (PycairoContext *o, PyObject *args) { cairo_rectangle (o->ctx, x, y, width, height); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -723,7 +747,8 @@ pycairo_rel_curve_to (PycairoContext *o, PyObject *args) { cairo_rel_curve_to (o->ctx, dx1, dy1, dx2, dy2, dx3, dy3); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -735,7 +760,8 @@ pycairo_rel_line_to (PycairoContext *o, PyObject *args) { cairo_rel_line_to (o->ctx, dx, dy); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -747,21 +773,24 @@ pycairo_rel_move_to (PycairoContext *o, PyObject *args) { cairo_rel_move_to (o->ctx, dx, dy); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * pycairo_reset_clip (PycairoContext *o) { cairo_reset_clip (o->ctx); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * pycairo_restore (PycairoContext *o) { cairo_restore (o->ctx); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -773,14 +802,16 @@ pycairo_rotate (PycairoContext *o, PyObject *args) { cairo_rotate (o->ctx, angle); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * pycairo_save (PycairoContext *o) { cairo_save (o->ctx); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -792,7 +823,8 @@ pycairo_scale (PycairoContext *o, PyObject *args) { cairo_scale (o->ctx, sx, sy); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -808,7 +840,8 @@ pycairo_select_font_face (PycairoContext *o, PyObject *args) { cairo_select_font_face (o->ctx, utf8, slant, weight); PyMem_Free((void *)utf8); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -820,7 +853,8 @@ pycairo_set_antialias (PycairoContext *o, PyObject *args) { cairo_set_antialias (o->ctx, antialias); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -856,7 +890,8 @@ pycairo_set_dash (PycairoContext *o, PyObject *args) { PyMem_Free (dashes); Py_DECREF(py_dashes); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -868,7 +903,8 @@ pycairo_set_fill_rule (PycairoContext *o, PyObject *args) { cairo_set_fill_rule (o->ctx, fill_rule); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -884,7 +920,8 @@ pycairo_set_font_face (PycairoContext *o, PyObject *obj) { return NULL; } RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -897,7 +934,8 @@ pycairo_set_font_matrix (PycairoContext *o, PyObject *args) { cairo_set_font_matrix (o->ctx, &matrix->matrix); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -910,7 +948,8 @@ pycairo_set_font_options (PycairoContext *o, PyObject *args) { cairo_set_font_options (o->ctx, options->font_options); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -922,7 +961,8 @@ pycairo_set_font_size (PycairoContext *o, PyObject *args) { cairo_set_font_size (o->ctx, size); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -934,7 +974,8 @@ pycairo_set_line_cap (PycairoContext *o, PyObject *args) { cairo_set_line_cap (o->ctx, line_cap); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -946,7 +987,8 @@ pycairo_set_line_join (PycairoContext *o, PyObject *args) { cairo_set_line_join (o->ctx, line_join); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -958,7 +1000,8 @@ pycairo_set_line_width (PycairoContext *o, PyObject *args) { cairo_set_line_width (o->ctx, width); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -971,7 +1014,8 @@ pycairo_set_matrix (PycairoContext *o, PyObject *args) { cairo_set_matrix (o->ctx, &matrix->matrix); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -983,7 +1027,8 @@ pycairo_set_miter_limit (PycairoContext *o, PyObject *args) { cairo_set_miter_limit (o->ctx, limit); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -995,7 +1040,8 @@ pycairo_set_operator(PycairoContext *o, PyObject *args) { cairo_set_operator(o->ctx, op); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1007,7 +1053,8 @@ pycairo_set_scaled_font(PycairoContext *o, PyObject *args) { cairo_set_scaled_font(o->ctx, f->scaled_font); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1020,7 +1067,8 @@ pycairo_set_source (PycairoContext *o, PyObject *args) { cairo_set_source (o->ctx, p->pattern); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1033,7 +1081,8 @@ pycairo_set_source_rgb (PycairoContext *o, PyObject *args) { cairo_set_source_rgb (o->ctx, red, green, blue); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1047,7 +1096,8 @@ pycairo_set_source_rgba (PycairoContext *o, PyObject *args) { cairo_set_source_rgba (o->ctx, red, green, blue, alpha); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1061,7 +1111,8 @@ pycairo_set_source_surface (PycairoContext *o, PyObject *args) { cairo_set_source_surface (o->ctx, surface->surface, x, y); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1071,7 +1122,8 @@ pycairo_set_tolerance (PycairoContext *o, PyObject *args) { return NULL; cairo_set_tolerance (o->ctx, tolerance); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1092,7 +1144,8 @@ pycairo_show_glyphs (PycairoContext *o, PyObject *args) { Py_END_ALLOW_THREADS; PyMem_Free (glyphs); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1101,7 +1154,8 @@ pycairo_show_page (PycairoContext *o) { cairo_show_page (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1117,7 +1171,8 @@ pycairo_show_text (PycairoContext *o, PyObject *args) { PyMem_Free((void *)utf8); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1126,7 +1181,8 @@ pycairo_stroke (PycairoContext *o) { cairo_stroke (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1143,7 +1199,8 @@ pycairo_stroke_preserve (PycairoContext *o) { cairo_stroke_preserve (o->ctx); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1172,7 +1229,8 @@ pycairo_text_path (PycairoContext *o, PyObject *args) { cairo_text_path (o->ctx, utf8); PyMem_Free((void *)utf8); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1185,7 +1243,8 @@ pycairo_transform (PycairoContext *o, PyObject *args) { cairo_transform (o->ctx, &matrix->matrix); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -1197,7 +1256,8 @@ pycairo_translate (PycairoContext *o, PyObject *args) { cairo_translate (o->ctx, tx, ty); RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * diff --git a/src/font.c b/src/font.c index 6c7ca4e..4d82601 100644 --- a/src/font.c +++ b/src/font.c @@ -460,7 +460,8 @@ font_options_set_antialias (PycairoFontOptions *o, PyObject *args) { cairo_font_options_set_antialias (o->font_options, aa); RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -472,7 +473,8 @@ font_options_set_hint_metrics (PycairoFontOptions *o, PyObject *args) { cairo_font_options_set_hint_metrics (o->font_options, hm); RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -484,7 +486,8 @@ font_options_set_hint_style (PycairoFontOptions *o, PyObject *args) { cairo_font_options_set_hint_style (o->font_options, hs); RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -496,7 +499,8 @@ font_options_set_subpixel_order (PycairoFontOptions *o, PyObject *args) { cairo_font_options_set_subpixel_order (o->font_options, so); RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } diff --git a/src/matrix.c b/src/matrix.c index 24f6e4a..4ab26e8 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -76,7 +76,8 @@ static PyObject * matrix_invert (PycairoMatrix *o) { if (Pycairo_Check_Status (cairo_matrix_invert (&o->matrix))) return NULL; - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } /* cairo_matrix_multiply */ @@ -145,7 +146,8 @@ matrix_rotate (PycairoMatrix *o, PyObject *args) { return NULL; cairo_matrix_rotate (&o->matrix, radians); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -156,7 +158,8 @@ matrix_scale (PycairoMatrix *o, PyObject *args) { return NULL; cairo_matrix_scale (&o->matrix, sx, sy); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -189,7 +192,8 @@ matrix_translate (PycairoMatrix *o, PyObject *args) { return NULL; cairo_matrix_translate (&o->matrix, tx, ty); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * diff --git a/src/pattern.c b/src/pattern.c index 9daf5c4..0a2f19c 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -121,7 +121,8 @@ pattern_set_extend (PycairoPattern *o, PyObject *args) { return NULL; cairo_pattern_set_extend (o->pattern, extend); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -133,7 +134,8 @@ pattern_set_matrix (PycairoPattern *o, PyObject *args) { return NULL; cairo_pattern_set_matrix (o->pattern, &m->matrix); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyMethodDef pattern_methods[] = { @@ -305,7 +307,8 @@ surface_pattern_set_filter (PycairoSurfacePattern *o, PyObject *args) { return NULL; cairo_pattern_set_filter (o->pattern, filter); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyMethodDef surface_pattern_methods[] = { @@ -378,7 +381,8 @@ gradient_add_color_stop_rgb (PycairoGradient *o, PyObject *args) { return NULL; cairo_pattern_add_color_stop_rgb (o->pattern, offset, red, green, blue); RETURN_NULL_IF_CAIRO_PATTERN_ERROR(o->pattern); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -390,7 +394,8 @@ gradient_add_color_stop_rgba (PycairoGradient *o, PyObject *args) { cairo_pattern_add_color_stop_rgba (o->pattern, offset, red, green, blue, alpha); RETURN_NULL_IF_CAIRO_PATTERN_ERROR(o->pattern); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyMethodDef gradient_methods[] = { diff --git a/src/region.c b/src/region.c index 2198ccd..c4ef05b 100644 --- a/src/region.c +++ b/src/region.c @@ -414,7 +414,8 @@ region_translate (PycairoRegion *o, PyObject *args) { Py_BEGIN_ALLOW_THREADS; cairo_region_translate (o->region, x, y); Py_END_ALLOW_THREADS; - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } @@ -443,7 +444,8 @@ region_intersect (PycairoRegion *o, PyObject *args) { } RETURN_NULL_IF_CAIRO_ERROR(res); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } PyObject * @@ -470,7 +472,8 @@ region_subtract (PycairoRegion *o, PyObject *args) { return NULL; } RETURN_NULL_IF_CAIRO_ERROR(res); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } PyObject * @@ -497,7 +500,8 @@ region_union (PycairoRegion *o, PyObject *args) { return NULL; } RETURN_NULL_IF_CAIRO_ERROR(res); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } PyObject * @@ -524,7 +528,8 @@ region_xor (PycairoRegion *o, PyObject *args) { return NULL; } RETURN_NULL_IF_CAIRO_ERROR(res); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyMethodDef region_methods[] = { diff --git a/src/surface.c b/src/surface.c index 204af68..c8da15e 100644 --- a/src/surface.c +++ b/src/surface.c @@ -185,7 +185,8 @@ surface_copy_page (PycairoSurface *o) { cairo_surface_copy_page (o->surface); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -220,7 +221,8 @@ surface_finish (PycairoSurface *o) { cairo_surface_finish (o->surface); Py_CLEAR(o->base); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -229,7 +231,8 @@ surface_flush (PycairoSurface *o) { cairo_surface_flush (o->surface); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -264,7 +267,8 @@ static PyObject * surface_mark_dirty (PycairoSurface *o) { cairo_surface_mark_dirty (o->surface); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -277,7 +281,8 @@ surface_mark_dirty_rectangle (PycairoSurface *o, PyObject *args) { cairo_surface_mark_dirty_rectangle (o->surface, x, y, width, height); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -289,7 +294,8 @@ surface_set_device_offset (PycairoSurface *o, PyObject *args) { return NULL; cairo_surface_set_device_offset (o->surface, x_offset, y_offset); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -300,7 +306,8 @@ surface_set_fallback_resolution (PycairoSurface *o, PyObject *args) { &x_ppi, &y_ppi)) return NULL; cairo_surface_set_fallback_resolution (o->surface, x_ppi, y_ppi); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -309,7 +316,8 @@ surface_show_page (PycairoSurface *o) { cairo_surface_show_page (o->surface); Py_END_ALLOW_THREADS; RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } #ifdef CAIRO_HAS_PNG_FUNCTIONS @@ -351,7 +359,8 @@ surface_write_to_png (PycairoSurface *o, PyObject *args) { Py_END_ALLOW_THREADS; } RETURN_NULL_IF_CAIRO_ERROR(status); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } #endif /* CAIRO_HAS_PNG_FUNCTIONS */ @@ -765,7 +774,8 @@ pdf_surface_restrict_to_version (PycairoPDFSurface *o, PyObject *args) { return NULL; cairo_pdf_surface_restrict_to_version (o->surface, version); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -777,7 +787,8 @@ pdf_surface_set_size (PycairoPDFSurface *o, PyObject *args) { return NULL; cairo_pdf_surface_set_size (o->surface, width_in_points, height_in_points); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } /* METH_STATIC */ @@ -913,14 +924,16 @@ static PyObject * ps_surface_dsc_begin_page_setup (PycairoPSSurface *o) { cairo_ps_surface_dsc_begin_page_setup (o->surface); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * ps_surface_dsc_begin_setup (PycairoPSSurface *o) { cairo_ps_surface_dsc_begin_setup (o->surface); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -930,7 +943,8 @@ ps_surface_dsc_comment (PycairoPSSurface *o, PyObject *args) { return NULL; cairo_ps_surface_dsc_comment (o->surface, comment); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -963,7 +977,8 @@ ps_surface_restrict_to_level (PycairoPSSurface *o, PyObject *args) { return NULL; cairo_ps_surface_restrict_to_level (o->surface, level); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -974,7 +989,8 @@ ps_surface_set_eps (PycairoPSSurface *o, PyObject *args) { return NULL; cairo_ps_surface_set_eps (o->surface, (py_eps == Py_True)); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyObject * @@ -985,7 +1001,8 @@ ps_surface_set_size (PycairoPSSurface *o, PyObject *args) { &width_in_points, &height_in_points)) return NULL; cairo_ps_surface_set_size (o->surface, width_in_points, height_in_points); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } static PyMethodDef ps_surface_methods[] = { @@ -1207,7 +1224,8 @@ svg_surface_restrict_to_version (PycairoSVGSurface *o, PyObject *args) { return NULL; cairo_svg_surface_restrict_to_version (o->surface, version); RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } /* METH_STATIC */ @@ -1496,7 +1514,8 @@ xcb_surface_set_size (PycairoXCBSurface *o, PyObject *args) { if (!PyArg_ParseTuple(args, "ii:XCBSurface.set_size", &width, &height)) return NULL; cairo_xcb_surface_set_size (o->surface, width, height); - Py_RETURN_NONE; + Py_INCREF(o); + return (PyObject *)o; } #endif