[cairo-commit] rcairo/src rb_cairo_context.c, 1.21, 1.22 rb_cairo_pattern.c, 1.10, 1.11 rb_cairo_private.h, 1.6, 1.7

Kouhei Sutou commit at pdx.freedesktop.org
Thu Jun 12 03:59:56 PDT 2008


Committed by: kou

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

Modified Files:
	rb_cairo_context.c rb_cairo_pattern.c rb_cairo_private.h 
Log Message:
* src/rb_cairo_private.h: add fallback RARRAY_PTR and RARRAY_LEN.
* src/rb_cairo_context.c, src/rb_cairo_pattern.c: use RARRAY_PTR and RARRAY_LEN.


Index: rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_context.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- rb_cairo_context.c	25 Mar 2008 13:43:50 -0000	1.21
+++ rb_cairo_context.c	12 Jun 2008 10:59:54 -0000	1.22
@@ -211,7 +211,7 @@
   if (n == 1 && rb_cairo__is_kind_of (red, rb_cArray))
     {
       VALUE ary = red;
-      n = RARRAY (ary)->len;
+      n = RARRAY_LEN (ary);
       red = rb_ary_entry (ary, 0);
       green = rb_ary_entry (ary, 1);
       blue = rb_ary_entry (ary, 2);
@@ -248,7 +248,7 @@
   if (n == 1 && rb_cairo__is_kind_of (red, rb_cArray))
     {
       VALUE ary = red;
-      n = RARRAY (ary)->len;
+      n = RARRAY_LEN (ary);
       red = rb_ary_entry (ary, 0);
       green = rb_ary_entry (ary, 1);
       blue = rb_ary_entry (ary, 2);
@@ -413,7 +413,7 @@
       values[0] = NUM2DBL (dash_array);
       cairo_set_dash (_SELF, values, 1, offset);
     }
-  else if (NIL_P (dash_array) || RARRAY (dash_array)->len == 0)
+  else if (NIL_P (dash_array) || RARRAY_LEN (dash_array) == 0)
     {
       cairo_set_dash (_SELF, NULL, 0, offset);
     }
@@ -421,7 +421,7 @@
     {
       int i, length;
       double *values;
-      length = RARRAY (dash_array)->len;
+      length = RARRAY_LEN (dash_array);
       values = ALLOCA_N (double, length);
       if (!values)
         {
@@ -429,7 +429,7 @@
         }
       for (i = 0; i < length; i++)
         {
-          values[i] = NUM2DBL (RARRAY (dash_array)->ptr[i]);
+          values[i] = NUM2DBL (RARRAY_PTR (dash_array)[i]);
         }
       cairo_set_dash (_SELF, values, length, offset);
     }
@@ -588,8 +588,8 @@
   VALUE current_point, x0, y0, cx1, cy1, cx2, cy2;
 
   current_point = cr_get_current_point (self);
-  x0 = RARRAY (current_point)->ptr[0];
-  y0 = RARRAY (current_point)->ptr[1];
+  x0 = RARRAY_PTR (current_point)[0];
+  y0 = RARRAY_PTR (current_point)[1];
 
   /* cx1 = x0 + 2 * ((x1 - x0) / 3.0) */
   cx1 = rb_funcall (x0, cr_id_plus, 1,
@@ -689,8 +689,8 @@
   VALUE current_point, x0, y0;
 
   current_point = cr_get_current_point (self);
-  x0 = RARRAY (current_point)->ptr[0];
-  y0 = RARRAY (current_point)->ptr[1];
+  x0 = RARRAY_PTR (current_point)[0];
+  y0 = RARRAY_PTR (current_point)[1];
   return cr_quadratic_curve_to (self,
                                 rb_funcall (dx1, cr_id_plus, 1, x0),
                                 rb_funcall (dy1, cr_id_plus, 1, y0),

Index: rb_cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_pattern.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- rb_cairo_pattern.c	22 May 2007 14:24:34 -0000	1.10
+++ rb_cairo_pattern.c	12 Jun 2008 10:59:54 -0000	1.11
@@ -137,10 +137,10 @@
     }
 
   if (n == 1 && rb_cairo__is_kind_of (red, rb_cArray) &&
-      (RARRAY (red)->len == 3 || RARRAY (red)->len == 4))
+      (RARRAY_LEN (red) == 3 || RARRAY_LEN (red) == 4))
     {
       VALUE ary = red;
-      n = RARRAY (ary)->len;
+      n = RARRAY_LEN (ary);
 
       red = rb_ary_entry (ary, 0);
       green = rb_ary_entry (ary, 1);
@@ -247,7 +247,7 @@
   if (n == 2 && rb_cairo__is_kind_of (red, rb_cArray))
     {
       VALUE ary = red;
-      n = RARRAY (ary)->len + 1;
+      n = RARRAY_LEN (ary) + 1;
 
       red = rb_ary_entry (ary, 0);
       green = rb_ary_entry (ary, 1);

Index: rb_cairo_private.h
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_private.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- rb_cairo_private.h	11 Jan 2008 08:03:39 -0000	1.6
+++ rb_cairo_private.h	12 Jun 2008 10:59:54 -0000	1.7
@@ -27,6 +27,14 @@
 #  define RSTRING_LEN(string) (RSTRING(string)->len)
 #endif
 
+#ifndef RARRAY_PTR
+#  define RARRAY_PTR(array) (RARRAY(array)->ptr)
+#endif
+
+#ifndef RARRAY_LEN
+#  define RARRAY_LEN(array) (RARRAY(array)->len)
+#endif
+
 #ifdef HAVE_RB_ERRINFO
 #  define RB_ERRINFO (rb_errinfo())
 #else
@@ -54,7 +62,7 @@
 do                                                              \
   {                                                             \
     Check_Type (rb_array, T_ARRAY);                             \
-    length = RARRAY (rb_array)->len;                            \
+    length = RARRAY_LEN (rb_array);                             \
     glyphs = ALLOCA_N (cairo_glyph_t, length);                  \
                                                                 \
     if (!glyphs)                                                \



More information about the cairo-commit mailing list