Skip to content

Commit

Permalink
Support Pathname as output target
Browse files Browse the repository at this point in the history
GitHub: fix #37

Reported by scivola. Thanks!!!
  • Loading branch information
kou committed May 8, 2015
1 parent 5e962be commit 9c7c455
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/cairo/rb_cairo_io.c
Expand Up @@ -15,6 +15,8 @@
ID rb_cairo__io_id_read;
ID rb_cairo__io_id_write;
ID rb_cairo__io_id_output;
ID rb_cairo__io_id_to_io;
ID rb_cairo__io_id_to_path;

/* read/write callback */
rb_cairo__io_callback_closure_t *
Expand Down Expand Up @@ -163,4 +165,6 @@ Init_cairo_io (void)
rb_cairo__io_id_read = rb_intern ("read");
rb_cairo__io_id_write = rb_intern ("write");
rb_cairo__io_id_output = rb_intern ("output");
rb_cairo__io_id_to_io = rb_intern ("to_io");
rb_cairo__io_id_to_path = rb_intern ("to_path");
}
2 changes: 2 additions & 0 deletions ext/cairo/rb_cairo_io.h
Expand Up @@ -28,6 +28,8 @@ typedef struct rb_cairo__io_invoke_data {
RB_CAIRO_VAR ID rb_cairo__io_id_read;
RB_CAIRO_VAR ID rb_cairo__io_id_write;
RB_CAIRO_VAR ID rb_cairo__io_id_output;
RB_CAIRO_VAR ID rb_cairo__io_id_to_io;
RB_CAIRO_VAR ID rb_cairo__io_id_to_path;

rb_cairo__io_callback_closure_t *
rb_cairo__io_closure_new (VALUE target);
Expand Down
6 changes: 6 additions & 0 deletions ext/cairo/rb_cairo_surface.c
Expand Up @@ -1069,6 +1069,12 @@ cr_ ## type ## _surface_initialize (int argc, VALUE *argv, VALUE self) \
width_in_points = NUM2DBL (rb_width_in_points); \
height_in_points = NUM2DBL (rb_height_in_points); \
\
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)) \
{ \
rb_cairo__io_callback_closure_t *closure; \
Expand Down

0 comments on commit 9c7c455

Please sign in to comment.