ext/cairo/rb_cairo_surface.c in cairo-1.17.7 vs ext/cairo/rb_cairo_surface.c in cairo-1.17.8

- old
+ new

@@ -278,11 +278,11 @@ { cairo_surface_t *surface; surface = _SELF; cr_surface_destroy_raw (surface); - DATA_PTR (self) = NULL; + RTYPEDDATA_DATA (self) = NULL; return self; } static VALUE @@ -532,11 +532,11 @@ closure = cairo_surface_get_user_data (surface, &cr_closure_key); cairo_surface_finish (surface); cairo_surface_set_user_data (surface, &cr_finished_key, (void *)CR_TRUE, NULL); cairo_surface_set_user_data (surface, &cr_object_holder_key, NULL, NULL); - DATA_PTR (self) = NULL; + RTYPEDDATA_DATA (self) = NULL; if (closure && !NIL_P (closure->error)) rb_exc_raise (closure->error); rb_cairo_surface_check_status (surface); @@ -748,10 +748,15 @@ } static VALUE cr_surface_write_to_png_generic (VALUE self, VALUE target) { + if (rb_respond_to (target, rb_cairo__io_id_to_path) && + !rb_respond_to (target, rb_cairo__io_id_to_io)) + { + target = rb_funcall (target, rb_cairo__io_id_to_path, 0); + } if (rb_respond_to (target, rb_cairo__io_id_write)) return cr_surface_write_to_png_stream (self, target); else return cr_surface_write_to_png (self, target); } @@ -1013,11 +1018,11 @@ else surface = cr_image_surface_create_from_png (target); rb_cairo_surface_check_status (surface); rb_surface = cr_surface_allocate (klass); - DATA_PTR (rb_surface) = surface; + RTYPEDDATA_DATA (rb_surface) = surface; return rb_surface; } #endif static cairo_surface_t * @@ -1070,11 +1075,11 @@ "(format, width, height) or " "(data, format, width, height, stride)): %s", rb_cairo__inspect (rb_ary_new3 (4, arg1, arg2, arg3, arg4))); rb_cairo_surface_check_status (surface); - DATA_PTR (self) = surface; + RTYPEDDATA_DATA (self) = surface; rb_cairo_surface_adjust_memory_usage (surface, CR_TRUE); if (rb_block_given_p ()) rb_cairo__surface_yield_and_finish (self); return Qnil; } @@ -1191,11 +1196,11 @@ width_in_points, \ height_in_points); \ } \ \ rb_cairo_surface_check_status (surface); \ - DATA_PTR (self) = surface; \ + RTYPEDDATA_DATA (self) = surface; \ if (rb_block_given_p ()) \ rb_cairo__surface_yield_and_finish (self); \ return Qnil; \ } @@ -1532,11 +1537,11 @@ } if (!surface) rb_cairo_check_status (CAIRO_STATUS_INVALID_FORMAT); rb_cairo_surface_check_status (surface); - DATA_PTR (self) = surface; + RTYPEDDATA_DATA (self) = surface; if (rb_block_given_p ()) rb_cairo__surface_yield_and_finish (self); return Qnil; } @@ -1608,11 +1613,11 @@ { cairo_surface_t *surface = NULL; surface = cairo_win32_printing_surface_create (NUM2PTR (hdc)); rb_cairo_surface_check_status (surface); - DATA_PTR (self) = surface; + RTYPEDDATA_DATA (self) = surface; if (rb_block_given_p ()) rb_cairo__surface_yield_and_finish (self); return Qnil; } #endif @@ -1663,11 +1668,11 @@ surface = cairo_script_surface_create_for_target (device, target); else surface = cairo_script_surface_create (device, content, width, height); rb_cairo_surface_check_status (surface); - DATA_PTR (self) = surface; + RTYPEDDATA_DATA (self) = surface; if (rb_block_given_p ()) rb_cairo__surface_yield_and_finish (self); return Qnil; } #endif @@ -1718,11 +1723,11 @@ rb_cairo__inspect (rb_ary_new4 (argc, argv))); } surface = cairo_recording_surface_create (content, &extents); rb_cairo_surface_check_status (surface); - DATA_PTR (self) = surface; + RTYPEDDATA_DATA (self) = surface; if (rb_block_given_p ()) rb_cairo__surface_yield_and_finish (self); return Qnil; } @@ -1795,11 +1800,11 @@ } surface = cairo_gl_surface_create (device, content, width, height); rb_cairo_surface_check_status (surface); - DATA_PTR (self) = surface; + RTYPEDDATA_DATA (self) = surface; if (rb_block_given_p ()) rb_cairo__surface_yield_and_finish (self); return Qnil; } @@ -1842,11 +1847,11 @@ texture, width, height); rb_cairo_surface_check_status (surface); - DATA_PTR (self) = surface; + RTYPEDDATA_DATA (self) = surface; if (rb_block_given_p ()) rb_cairo__surface_yield_and_finish (self); return Qnil; } @@ -1892,11 +1897,11 @@ { cairo_surface_t *surface = NULL; surface = cairo_tee_surface_create (RVAL2CRSURFACE (master)); rb_cairo_surface_check_status (surface); - DATA_PTR (self) = surface; + RTYPEDDATA_DATA (self) = surface; rb_iv_set (self, "surfaces", rb_ary_new3 (1, master)); if (rb_block_given_p ()) rb_cairo__surface_yield_and_finish (self); return Qnil; } @@ -2014,10 +2019,10 @@ } surface = cairo_xml_surface_create (device, content, width, height); rb_cairo_surface_check_status (surface); - DATA_PTR (self) = surface; + RTYPEDDATA_DATA (self) = surface; if (rb_block_given_p ()) rb_cairo__surface_yield_and_finish (self); return Qnil; } #endif