[cairo-commit] rcairo/src rb_cairo.c, 1.18, 1.19 rb_cairo_exception.c, 1.2, 1.3

Kouhei Sutou commit at pdx.freedesktop.org
Wed Aug 13 01:27:46 PDT 2008


Committed by: kou

Update of /cvs/cairo/rcairo/src
In directory kemper:/tmp/cvs-serv19015/src

Modified Files:
	rb_cairo.c rb_cairo_exception.c 
Log Message:
        * src/rb_cairo_exception.c: support new statuses appeared since
        cairo 1.7.2.

        * src/rb_cairo.c (Cairo.satisfied_version?): add.

        * test/test_exception.rb: add.

        * test/cairo-test-utils.rb: add.


Index: rb_cairo.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- rb_cairo.c	19 Jul 2008 11:17:02 -0000	1.18
+++ rb_cairo.c	13 Aug 2008 08:27:44 -0000	1.19
@@ -27,6 +27,24 @@
   rb_funcall (rb_mCairo, id__add_one_arg_setter, 1, klass);
 }
 
+static VALUE
+rb_cairo_satisfied_version (int argc, VALUE *argv, VALUE self)
+{
+  VALUE major, minor, micro;
+
+  rb_scan_args (argc, argv, "21", &major, &minor, &micro);
+
+  if (NIL_P (micro))
+    micro = UINT2NUM (0);
+
+  return CBOOL2RVAL (CAIRO_VERSION_MAJOR > NUM2UINT(major) ||
+                     (CAIRO_VERSION_MAJOR == NUM2UINT(major) &&
+                      CAIRO_VERSION_MINOR > NUM2UINT(minor)) ||
+                     (CAIRO_VERSION_MAJOR == NUM2UINT(major) &&
+                      CAIRO_VERSION_MINOR == NUM2UINT(minor) &&
+                      CAIRO_VERSION_MICRO >= NUM2UINT(micro)));
+}
+
 void
 Init_cairo ()
 {
@@ -60,6 +78,9 @@
                    rb_ary_new3 (4,
                                 INT2FIX (1), INT2FIX (7), INT2FIX (0), Qnil));
 
+  rb_define_module_function (rb_mCairo, "satisfied_version?",
+                             rb_cairo_satisfied_version, -1);
+
   rb_mCairo_Color = rb_const_get (rb_mCairo, rb_intern ("Color"));
   rb_cCairo_Color_Base = rb_const_get (rb_mCairo_Color, rb_intern ("Base"));
   rb_cCairo_Paper = rb_const_get (rb_mCairo, rb_intern ("Paper"));

Index: rb_cairo_exception.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_exception.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rb_cairo_exception.c	21 Feb 2008 13:18:10 -0000	1.2
+++ rb_cairo_exception.c	13 Aug 2008 08:27:44 -0000	1.3
@@ -41,6 +41,15 @@
 static VALUE rb_eCairo_TempFileError;
 static VALUE rb_eCairo_InvalidStrideError;
 #endif
+#if CAIRO_CHECK_VERSION(1, 7, 2)
+static VALUE rb_eCairo_FontTypeMismatch;
+static VALUE rb_eCairo_UserFontImmutable;
+static VALUE rb_eCairo_UserFontError;
+static VALUE rb_eCairo_NegativeCount;
+static VALUE rb_eCairo_InvalidClusters;
+static VALUE rb_eCairo_InvalidSlant;
+static VALUE rb_eCairo_InvalidWeight;
+#endif
 
 void
 rb_cairo_check_status (cairo_status_t status)
@@ -127,6 +136,29 @@
       rb_raise (rb_eCairo_InvalidStringError, string);
       break;
 #endif
+#if CAIRO_CHECK_VERSION(1, 7, 2)
+    case CAIRO_STATUS_FONT_TYPE_MISMATCH:
+      rb_raise (rb_eCairo_FontTypeMismatch, string);
+      break;
+    case CAIRO_STATUS_USER_FONT_IMMUTABLE:
+      rb_raise (rb_eCairo_UserFontImmutable, string);
+      break;
+    case CAIRO_STATUS_USER_FONT_ERROR:
+      rb_raise (rb_eCairo_UserFontError, string);
+      break;
+    case CAIRO_STATUS_NEGATIVE_COUNT:
+      rb_raise (rb_eCairo_NegativeCount, string);
+      break;
+    case CAIRO_STATUS_INVALID_CLUSTERS:
+      rb_raise (rb_eCairo_InvalidClusters, string);
+      break;
+    case CAIRO_STATUS_INVALID_SLANT:
+      rb_raise (rb_eCairo_InvalidSlant, string);
+      break;
+    case CAIRO_STATUS_INVALID_WEIGHT:
+      rb_raise (rb_eCairo_InvalidWeight, string);
+      break;
+#endif
     }
 }
 
@@ -208,7 +240,37 @@
                            rb_eCairo_Error);
 
   rb_eCairo_InvalidStrideError =
-        rb_define_class_under (rb_mCairo, "InvalidStrideError",
-                               rb_eArgError);
+    rb_define_class_under (rb_mCairo, "InvalidStrideError",
+                           rb_eArgError);
+#endif
+
+#if CAIRO_CHECK_VERSION(1, 7, 2)
+  rb_eCairo_FontTypeMismatch =
+    rb_define_class_under (rb_mCairo, "FontTypeMismatch",
+                           rb_eCairo_Error);
+
+  rb_eCairo_UserFontImmutable =
+    rb_define_class_under (rb_mCairo, "UserFontImmutable",
+                           rb_eCairo_Error);
+
+  rb_eCairo_UserFontError =
+    rb_define_class_under (rb_mCairo, "UserFontError",
+                           rb_eCairo_Error);
+
+  rb_eCairo_NegativeCount =
+    rb_define_class_under (rb_mCairo, "NegativeCount",
+                           rb_eCairo_Error);
+
+  rb_eCairo_InvalidClusters =
+    rb_define_class_under (rb_mCairo, "InvalidClusters",
+                           rb_eArgError);
+
+  rb_eCairo_InvalidSlant =
+    rb_define_class_under (rb_mCairo, "InvalidSlant",
+                           rb_eCairo_Error);
+
+  rb_eCairo_InvalidWeight =
+    rb_define_class_under (rb_mCairo, "InvalidWeight",
+                           rb_eArgError);
 #endif
 }



More information about the cairo-commit mailing list