[cairo-commit] rcairo/packages/cairo/ext rb_cairo_surface.c, 1.25, 1.26

Kouhei Sutou commit at pdx.freedesktop.org
Tue Jun 27 07:34:51 PDT 2006


Committed by: kou

Update of /cvs/cairo/rcairo/packages/cairo/ext
In directory kemper:/tmp/cvs-serv29540/packages/cairo/ext

Modified Files:
	rb_cairo_surface.c 
Log Message:
* packages/cairo/ext/rb_cairo_surface.c: use cairo_surface_type_t
  for Ruby <-> C surface conversion.


Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_surface.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- rb_cairo_surface.c	25 Jun 2006 14:29:24 -0000	1.25
+++ rb_cairo_surface.c	27 Jun 2006 14:34:49 -0000	1.26
@@ -71,11 +71,33 @@
 static VALUE
 cr_surface_get_klass (cairo_surface_t *surface)
 {
-  VALUE klass = (VALUE)cairo_surface_get_user_data (surface, &cr_klass_key);
-  if (!klass)
+  VALUE klass;
+  void *data = cairo_surface_get_user_data (surface, &cr_klass_key);
+
+  if (data)
+    klass = (VALUE) data;
+  else
     {
-      rb_raise (rb_eArgError, "[BUG] uninitialized surface for Ruby");
+      switch (cairo_surface_get_type (surface))
+        {
+        case CAIRO_SURFACE_TYPE_IMAGE:
+          klass = rb_cCairo_ImageSurface;
+          break;
+        case CAIRO_SURFACE_TYPE_PDF:
+          klass = rb_cCairo_PDFSurface;
+          break;
+        case CAIRO_SURFACE_TYPE_PS:
+          klass = rb_cCairo_PSSurface;
+          break;
+        case CAIRO_SURFACE_TYPE_SVG:
+          klass = rb_cCairo_SVGSurface;
+          break;
+        default:
+          klass = rb_cCairo_Surface;
+          break;
+        }
     }
+
   return klass;
 }
 



More information about the cairo-commit mailing list