[cairo-commit] rcairo/packages/cairo/ext cairo.def, 1.6, 1.7 rb_cairo.h, 1.13, 1.14 rb_cairo_constants.c, 1.7, 1.8 rb_cairo_context.c, 1.18, 1.19 rb_cairo_font_options.c, 1.4, 1.5 rb_cairo_path.c, 1.2, 1.3 rb_cairo_pattern.c, 1.12, 1.13 rb_cairo_surface.c, 1.15, 1.16

Kouhei Sutou commit at pdx.freedesktop.org
Tue Oct 11 06:23:51 PDT 2005


Committed by: kou

Update of /cvs/cairo/rcairo/packages/cairo/ext
In directory gabe:/tmp/cvs-serv7894/packages/cairo/ext

Modified Files:
	cairo.def rb_cairo.h rb_cairo_constants.c rb_cairo_context.c 
	rb_cairo_font_options.c rb_cairo_path.c rb_cairo_pattern.c 
	rb_cairo_surface.c 
Log Message:
* packages/cairo/ext: Extracted Ruby object -> enum type codes.


Index: cairo.def
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/cairo.def,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cairo.def	9 Oct 2005 14:49:39 -0000	1.6
+++ cairo.def	11 Oct 2005 13:23:49 -0000	1.7
@@ -39,4 +39,19 @@
     rb_cairo_glyph_to_ruby_object
     rb_cairo_surface_from_ruby_object
     rb_cairo_surface_to_ruby_object
+    rb_cairo_operator_from_ruby_object
+    rb_cairo_antialias_from_ruby_object
+    rb_cairo_fill_rule_from_ruby_object
+    rb_cairo_line_cap_from_ruby_object
+    rb_cairo_line_join_from_ruby_object
+    rb_cairo_font_slant_from_ruby_object
+    rb_cairo_font_weight_from_ruby_object
+    rb_cairo_subpixel_order_from_ruby_object
+    rb_cairo_hint_style_from_ruby_object
+    rb_cairo_hint_metrics_from_ruby_object
+    rb_cairo_path_data_type_from_ruby_object
+    rb_cairo_content_from_ruby_object
+    rb_cairo_format_from_ruby_object
+    rb_cairo_extend_from_ruby_object
+    rb_cairo_filter_from_ruby_object
     rb_cairo_check_status

Index: rb_cairo.h
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- rb_cairo.h	10 Oct 2005 15:40:26 -0000	1.13
+++ rb_cairo.h	11 Oct 2005 13:23:49 -0000	1.14
@@ -102,8 +102,8 @@
 cairo_font_options_t *rb_cairo_font_options_from_ruby_object (VALUE obj);
 VALUE                 rb_cairo_font_options_to_ruby_object   (cairo_font_options_t *options);
 
-cairo_scaled_font_t  *rb_cairo_scaled_font_from_ruby_object (VALUE obj);
-VALUE                 rb_cairo_scaled_font_to_ruby_object   (cairo_scaled_font_t *options);
+cairo_scaled_font_t  *rb_cairo_scaled_font_from_ruby_object  (VALUE obj);
+VALUE                 rb_cairo_scaled_font_to_ruby_object    (cairo_scaled_font_t *options);
 
 cairo_text_extents_t *rb_cairo_text_extents_from_ruby_object (VALUE obj);
 VALUE                 rb_cairo_text_extents_to_ruby_object   (cairo_text_extents_t *extents);
@@ -115,6 +115,38 @@
 VALUE                 rb_cairo_surface_to_ruby_object        (cairo_surface_t *surface);
 
 
+#define RVAL2CROPERATOR(obj)      (rb_cairo_operator_from_ruby_object(obj))
+#define RVAL2CRANTIALIAS(obj)     (rb_cairo_antialias_from_ruby_object(obj))
+#define RVAL2CRFILLRULE(obj)      (rb_cairo_fill_rule_from_ruby_object(obj))
+#define RVAL2CRLINECAP(obj)       (rb_cairo_line_cap_from_ruby_object(obj))
+#define RVAL2CRLINEJOIN(obj)      (rb_cairo_line_join_from_ruby_object(obj))
+#define RVAL2CRFONTSLANT(obj)     (rb_cairo_font_slant_from_ruby_object(obj))
+#define RVAL2CRFONTWEIGHT(obj)    (rb_cairo_font_weight_from_ruby_object(obj))
+#define RVAL2CRSUBPIXELORDER(obj) (rb_cairo_subpixel_order_from_ruby_object(obj))
+#define RVAL2CRHINTSTYLE(obj)     (rb_cairo_hint_style_from_ruby_object(obj))
+#define RVAL2CRHINTMETRICS(obj)   (rb_cairo_hint_metrics_from_ruby_object(obj))
+#define RVAL2CRPATHDATATYPE(obj)  (rb_cairo_path_data_type_from_ruby_object(obj))
+#define RVAL2CRCONTENT(obj)       (rb_cairo_content_from_ruby_object(obj))
+#define RVAL2CRFORMAT(obj)        (rb_cairo_format_from_ruby_object(obj))
+#define RVAL2CREXTEND(obj)        (rb_cairo_extend_from_ruby_object(obj))
+#define RVAL2CRFILTER(obj)        (rb_cairo_filter_from_ruby_object(obj))
+
+cairo_operator_t       rb_cairo_operator_from_ruby_object       (VALUE obj);
+cairo_antialias_t      rb_cairo_antialias_from_ruby_object      (VALUE obj);
+cairo_fill_rule_t      rb_cairo_fill_rule_from_ruby_object      (VALUE obj);
+cairo_line_cap_t       rb_cairo_line_cap_from_ruby_object       (VALUE obj);
+cairo_line_join_t      rb_cairo_line_join_from_ruby_object      (VALUE obj);
+cairo_font_slant_t     rb_cairo_font_slant_from_ruby_object     (VALUE obj);
+cairo_font_weight_t    rb_cairo_font_weight_from_ruby_object    (VALUE obj);
+cairo_subpixel_order_t rb_cairo_subpixel_order_from_ruby_object (VALUE obj);
+cairo_hint_style_t     rb_cairo_hint_style_from_ruby_object     (VALUE obj);
+cairo_hint_metrics_t   rb_cairo_hint_metrics_from_ruby_object   (VALUE obj);
+cairo_path_data_type_t rb_cairo_path_data_type_from_ruby_object (VALUE obj);
+cairo_content_t        rb_cairo_content_from_ruby_object        (VALUE obj);
+cairo_format_t         rb_cairo_format_from_ruby_object         (VALUE obj);
+cairo_extend_t         rb_cairo_extend_from_ruby_object         (VALUE obj);
+cairo_filter_t         rb_cairo_filter_from_ruby_object         (VALUE obj);
+
 
 void rb_cairo_check_status (cairo_status_t status);
 

Index: rb_cairo_constants.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_constants.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rb_cairo_constants.c	10 Oct 2005 15:40:26 -0000	1.7
+++ rb_cairo_constants.c	11 Oct 2005 13:23:49 -0000	1.8
@@ -15,6 +15,87 @@
 
 #include "rb_cairo.h"
 
+#define CAIRO_OPERATOR_MIN CAIRO_OPERATOR_CLEAR
+#define CAIRO_OPERATOR_MAX CAIRO_OPERATOR_SATURATE
+
+#define CAIRO_ANTIALIAS_MIN CAIRO_ANTIALIAS_DEFAULT
+#define CAIRO_ANTIALIAS_MAX CAIRO_ANTIALIAS_SUBPIXEL
+
+#define CAIRO_FILL_RULE_MIN CAIRO_FILL_RULE_WINDING
+#define CAIRO_FILL_RULE_MAX CAIRO_FILL_RULE_EVEN_ODD
+
+#define CAIRO_LINE_CAP_MIN CAIRO_LINE_CAP_BUTT
+#define CAIRO_LINE_CAP_MAX CAIRO_LINE_CAP_SQUARE
+
+#define CAIRO_LINE_JOIN_MIN CAIRO_LINE_JOIN_MITER
+#define CAIRO_LINE_JOIN_MAX CAIRO_LINE_JOIN_BEVEL
+
+#define CAIRO_FONT_SLANT_MIN CAIRO_FONT_SLANT_NORMAL
+#define CAIRO_FONT_SLANT_MAX CAIRO_FONT_SLANT_OBLIQUE
+
+#define CAIRO_FONT_WEIGHT_MIN CAIRO_FONT_WEIGHT_NORMAL
+#define CAIRO_FONT_WEIGHT_MAX CAIRO_FONT_WEIGHT_BOLD
+
+#define CAIRO_SUBPIXEL_ORDER_MIN CAIRO_SUBPIXEL_ORDER_DEFAULT
+#define CAIRO_SUBPIXEL_ORDER_MAX CAIRO_SUBPIXEL_ORDER_VBGR
+
+#define CAIRO_HINT_STYLE_MIN CAIRO_HINT_STYLE_DEFAULT
+#define CAIRO_HINT_STYLE_MAX CAIRO_HINT_STYLE_FULL
+
+#define CAIRO_HINT_METRICS_MIN CAIRO_HINT_METRICS_DEFAULT
+#define CAIRO_HINT_METRICS_MAX CAIRO_HINT_METRICS_OFF
+
+#define CAIRO_PATH_MIN CAIRO_PATH_MOVE_TO
+#define CAIRO_PATH_MAX CAIRO_PATH_CLOSE_PATH
+
+#define CAIRO_CONTENT_MIN CAIRO_CONTENT_COLOR
+#define CAIRO_CONTENT_MAX CAIRO_CONTENT_COLOR_ALPHA
+
+#define CAIRO_FORMAT_MIN CAIRO_FORMAT_ARGB32
+#define CAIRO_FORMAT_MAX CAIRO_FORMAT_A1
+
+#define CAIRO_EXTEND_MIN CAIRO_EXTEND_NONE
+#define CAIRO_EXTEND_MAX CAIRO_EXTEND_REFLECT
+
+#define CAIRO_FILTER_MIN CAIRO_FILTER_FAST
+#define CAIRO_FILTER_MAX CAIRO_FILTER_GAUSSIAN
+
+#define DEFINE_RVAL2ENUM(name, const_name)                  \
+cairo_ ## name ## _t                                        \
+rb_cairo_ ## name ## _from_ruby_object (VALUE rb_ ## name)  \
+{                                                           \
+  cairo_ ## name ## _t name;                                \
+  name = FIX2INT (rb_ ## name);                             \
+  if (name < CAIRO_ ## const_name ## _MIN ||                \
+      name > CAIRO_ ## const_name ## _MAX)                  \
+    {                                                       \
+      rb_raise (rb_eArgError,                               \
+                "invalid %s: %d (expect %d <= %s <= %d)",   \
+                #name, name,                                \
+                CAIRO_ ## const_name ## _MIN,               \
+                #name,                                      \
+                CAIRO_ ## const_name ## _MAX);              \
+    }                                                       \
+  return name;                                              \
+}
+
+DEFINE_RVAL2ENUM(operator, OPERATOR)
+DEFINE_RVAL2ENUM(antialias, ANTIALIAS)
+DEFINE_RVAL2ENUM(fill_rule, FILL_RULE)
+DEFINE_RVAL2ENUM(line_cap, LINE_CAP)
+DEFINE_RVAL2ENUM(line_join, LINE_JOIN)
+DEFINE_RVAL2ENUM(font_slant, FONT_SLANT)
+DEFINE_RVAL2ENUM(font_weight, FONT_WEIGHT)
+DEFINE_RVAL2ENUM(subpixel_order, SUBPIXEL_ORDER)
+DEFINE_RVAL2ENUM(hint_style, HINT_STYLE)
+DEFINE_RVAL2ENUM(hint_metrics, HINT_METRICS)
+DEFINE_RVAL2ENUM(path_data_type, PATH)
+DEFINE_RVAL2ENUM(content, CONTENT)
+DEFINE_RVAL2ENUM(format, FORMAT)
+DEFINE_RVAL2ENUM(extend, EXTEND)
+DEFINE_RVAL2ENUM(filter, FILTER)
+
+
 void
 Init_cairo_constants (void)
 {
@@ -88,7 +169,7 @@
                    INT2FIX (CAIRO_LINE_JOIN_BEVEL));
 
 
-  /* cairo_slant_t */
+  /* cairo_font_slant_t */
   rb_define_const (rb_mCairo,    "FONT_SLANT_NORMAL",
                    INT2FIX (CAIRO_FONT_SLANT_NORMAL));
   rb_define_const (rb_mCairo,    "FONT_SLANT_ITALIC",
@@ -97,7 +178,7 @@
                    INT2FIX (CAIRO_FONT_SLANT_OBLIQUE));
 
 
-  /* cairo_weight_t */
+  /* cairo_font_weight_t */
   rb_define_const (rb_mCairo,    "FONT_WEIGHT_NORMAL",
                    INT2FIX (CAIRO_FONT_WEIGHT_NORMAL));
   rb_define_const (rb_mCairo,    "FONT_WEIGHT_BOLD",

Index: rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_context.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- rb_cairo_context.c	10 Oct 2005 15:40:26 -0000	1.18
+++ rb_cairo_context.c	11 Oct 2005 13:23:49 -0000	1.19
@@ -103,16 +103,9 @@
 
 /* Modify state */
 static VALUE
-cr_set_operator (VALUE self, VALUE rb_op)
+cr_set_operator (VALUE self, VALUE operator)
 {
-  int op;
-  Check_Type (rb_op, T_FIXNUM);
-  op = FIX2INT (rb_op);
-  if (op < CAIRO_OPERATOR_CLEAR || op > CAIRO_OPERATOR_SATURATE)
-    {
-      rb_raise (rb_eArgError, "invalid composition operator");
-    }
-  cairo_set_operator (_SELF, (cairo_operator_t) op);
+  cairo_set_operator (_SELF, RVAL2CROPERATOR (operator));
   cr_check_status (_SELF);
   return self;
 }
@@ -256,22 +249,15 @@
 static VALUE
 cr_set_antialias(VALUE self, VALUE antialias)
 {
-  cairo_set_antialias(_SELF, NUM2INT(antialias));
+  cairo_set_antialias(_SELF, RVAL2CRANTIALIAS (antialias));
   cr_check_status(_SELF);
   return self;
 }
 
 static VALUE
-cr_set_fill_rule (VALUE self, VALUE rb_rule)
+cr_set_fill_rule (VALUE self, VALUE rule)
 {
-  cairo_fill_rule_t rule;
-  Check_Type (rb_rule, T_FIXNUM);
-  rule = FIX2INT (rb_rule);
-  if (rule < CAIRO_FILL_RULE_WINDING || rule > CAIRO_FILL_RULE_EVEN_ODD)
-    {
-      rb_raise (rb_eArgError, "invalid fill rule");
-    }
-  cairo_set_fill_rule (_SELF, rule);
+  cairo_set_fill_rule (_SELF, RVAL2CRFILLRULE (rule));
   cr_check_status (_SELF);
   return self;
 }
@@ -284,31 +270,17 @@
 }
 
 static VALUE
-cr_set_line_cap (VALUE self, VALUE rb_cap)
+cr_set_line_cap (VALUE self, VALUE cap)
 {
-  cairo_line_cap_t cap;
-  Check_Type (rb_cap, T_FIXNUM);
-  cap = FIX2INT (rb_cap);
-  if (cap < CAIRO_LINE_CAP_BUTT || cap > CAIRO_LINE_CAP_SQUARE)
-    {
-      rb_raise (rb_eArgError, "invalid line cap type");
-    }
-  cairo_set_line_cap (_SELF, cap);
+  cairo_set_line_cap (_SELF, RVAL2CRLINECAP (cap));
   cr_check_status (_SELF);
   return self;
 }
 
 static VALUE
-cr_set_line_join (VALUE self, VALUE rb_join)
+cr_set_line_join (VALUE self, VALUE join)
 {
-  cairo_line_join_t join;
-  Check_Type (rb_join, T_FIXNUM);
-  join = FIX2INT (rb_join);
-  if (join < CAIRO_LINE_JOIN_MITER || join > CAIRO_LINE_JOIN_BEVEL)
-    {
-      rb_raise (rb_eArgError, "invalid line join type");
-    }
-  cairo_set_line_join (_SELF, join);
+  cairo_set_line_join (_SELF, RVAL2CRLINEJOIN (join));
   cr_check_status (_SELF);
   return self;
 }
@@ -771,25 +743,10 @@
 
 /* Font/Text functions */
 static   VALUE
-cr_select_font_face (VALUE self, VALUE family, VALUE rb_slant, VALUE rb_weight)
+cr_select_font_face (VALUE self, VALUE family, VALUE slant, VALUE weight)
 {
-  cairo_font_slant_t slant = NUM2INT (rb_slant);
-  cairo_font_weight_t weight = NUM2INT (rb_weight);
-
-  if (slant < CAIRO_FONT_SLANT_NORMAL ||
-      slant > CAIRO_FONT_SLANT_OBLIQUE)
-    {
-      rb_raise (rb_eArgError, "invalid font slant");
-    }
-
-  if (weight < CAIRO_FONT_WEIGHT_NORMAL ||
-      weight > CAIRO_FONT_WEIGHT_BOLD)
-    {
-      rb_raise (rb_eArgError, "invalid font weight");
-    }
- 
-
-  cairo_select_font_face (_SELF, STR2CSTR (family), slant, weight);
+  cairo_select_font_face (_SELF, STR2CSTR (family),
+                          RVAL2CRFONTSLANT (slant), RVAL2CRFONTWEIGHT (weight));
   cr_check_status (_SELF);
   return self;
 }

Index: rb_cairo_font_options.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_font_options.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- rb_cairo_font_options.c	10 Oct 2005 15:40:26 -0000	1.4
+++ rb_cairo_font_options.c	11 Oct 2005 13:23:49 -0000	1.5
@@ -105,19 +105,9 @@
 }
 
 static VALUE
-cr_options_set_antialias (VALUE self, VALUE rb_antialias)
+cr_options_set_antialias (VALUE self, VALUE antialias)
 {
-  cairo_antialias_t antialias;
-
-  antialias = NUM2INT (rb_antialias);
-  
-  if (antialias < CAIRO_ANTIALIAS_DEFAULT ||
-      antialias > CAIRO_ANTIALIAS_SUBPIXEL)
-    {
-      rb_raise (rb_eArgError, "invalid antialias");
-    }
-  
-  cairo_font_options_set_antialias (_SELF (self), antialias);
+  cairo_font_options_set_antialias (_SELF (self), RVAL2CRANTIALIAS (antialias));
   return self;
 }
 
@@ -128,19 +118,10 @@
 }
 
 static VALUE
-cr_options_set_subpixel_order (VALUE self, VALUE rb_subpixel_order)
+cr_options_set_subpixel_order (VALUE self, VALUE subpixel_order)
 {
-  cairo_subpixel_order_t subpixel_order;
-
-  subpixel_order = NUM2INT (rb_subpixel_order);
-  
-  if (subpixel_order < CAIRO_SUBPIXEL_ORDER_DEFAULT ||
-      subpixel_order > CAIRO_SUBPIXEL_ORDER_VBGR)
-    {
-      rb_raise (rb_eArgError, "invalid subpixel order");
-    }
-  
-  cairo_font_options_set_subpixel_order (_SELF (self), subpixel_order);
+  cairo_font_options_set_subpixel_order (_SELF (self),
+                                         RVAL2CRSUBPIXELORDER (subpixel_order));
   return self;
 }
 
@@ -151,19 +132,10 @@
 }
 
 static VALUE
-cr_options_set_hint_style (VALUE self, VALUE rb_hint_style)
+cr_options_set_hint_style (VALUE self, VALUE hint_style)
 {
-  cairo_hint_style_t hint_style;
-
-  hint_style = NUM2INT (rb_hint_style);
-  
-  if (hint_style < CAIRO_HINT_STYLE_DEFAULT ||
-      hint_style > CAIRO_HINT_STYLE_FULL)
-    {
-      rb_raise (rb_eArgError, "invalid hint style");
-    }
-  
-  cairo_font_options_set_hint_style (_SELF (self), hint_style);
+  cairo_font_options_set_hint_style (_SELF (self),
+                                     RVAL2CRHINTSTYLE (hint_style));
   return self;
 }
 
@@ -174,19 +146,10 @@
 }
 
 static VALUE
-cr_options_set_hint_metrics (VALUE self, VALUE rb_hint_metrics)
+cr_options_set_hint_metrics (VALUE self, VALUE hint_metrics)
 {
-  cairo_hint_metrics_t hint_metrics;
-
-  hint_metrics = NUM2INT (rb_hint_metrics);
-  
-  if (hint_metrics < CAIRO_HINT_METRICS_DEFAULT ||
-      hint_metrics > CAIRO_HINT_METRICS_ON)
-    {
-      rb_raise (rb_eArgError, "invalid hint metrics");
-    }
-  
-  cairo_font_options_set_hint_metrics (_SELF (self), hint_metrics);
+  cairo_font_options_set_hint_metrics (_SELF (self),
+                                       RVAL2CRHINTMETRICS (hint_metrics));
   return self;
 }
 

Index: rb_cairo_path.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_path.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rb_cairo_path.c	10 Oct 2005 15:40:26 -0000	1.2
+++ rb_cairo_path.c	11 Oct 2005 13:23:49 -0000	1.3
@@ -60,7 +60,11 @@
   for (i = 0; i < path->num_data; i += path->data[i].header.length)
     {
       cairo_path_data_t *data = &(path->data[i]);
-      VALUE points = rb_ary_new ();
+      cairo_path_data_type_t type;
+      VALUE points;
+
+      type = RVAL2CRPATHDATATYPE (data->header.type);
+      points = rb_ary_new ();
 
       for (j = 1; j < data->header.length; j++)
         {
@@ -68,7 +72,7 @@
                                             rb_float_new (data[j].point.x),
                                             rb_float_new (data[j].point.y)));
         }
-      rb_yield_values (2, INT2NUM (data->header.type), points);
+      rb_yield_values (2, type, points);
     }
 
   return self;

Index: rb_cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_pattern.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- rb_cairo_pattern.c	11 Oct 2005 01:59:07 -0000	1.12
+++ rb_cairo_pattern.c	11 Oct 2005 13:23:49 -0000	1.13
@@ -235,17 +235,9 @@
 
 /* Cairo::SurfacePattern */
 static VALUE
-cr_surface_pattern_set_extend (VALUE self, VALUE rb_extend)
+cr_surface_pattern_set_extend (VALUE self, VALUE extend)
 {
-  cairo_extend_t extend;
-  extend = NUM2INT (rb_extend);
-  if (extend < CAIRO_EXTEND_NONE ||
-      extend > CAIRO_EXTEND_REFLECT)
-    {
-      rb_raise (rb_eArgError, "invalide pattern extend type");
-    }
-
-  cairo_pattern_set_extend (_SELF (self), extend);
+  cairo_pattern_set_extend (_SELF (self), RVAL2CREXTEND (extend));
   cr_pattern_check_status (_SELF (self));
   return self;
 }
@@ -257,17 +249,9 @@
 }
 
 static VALUE
-cr_surface_pattern_set_filter (VALUE self, VALUE rb_filter)
+cr_surface_pattern_set_filter (VALUE self, VALUE filter)
 {
-  cairo_filter_t filter;
-  filter = NUM2INT (rb_filter);
-  if (filter < CAIRO_FILTER_FAST ||
-      filter > CAIRO_FILTER_GAUSSIAN)
-    {
-      rb_raise (rb_eArgError, "invalide pattern filter type");
-    }
-
-  cairo_pattern_set_filter (_SELF (self), filter);
+  cairo_pattern_set_filter (_SELF (self), RVAL2CRFILTER (filter));
   cr_pattern_check_status (_SELF (self));
   return self;
 }

Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_surface.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- rb_cairo_surface.c	10 Oct 2005 15:40:26 -0000	1.15
+++ rb_cairo_surface.c	11 Oct 2005 13:23:49 -0000	1.16
@@ -214,21 +214,13 @@
 
 /* Surface manipulation */
 static VALUE
-cr_surface_create_similar (VALUE self, VALUE rb_content,
+cr_surface_create_similar (VALUE self, VALUE content,
                            VALUE width, VALUE height)
 {
   cairo_surface_t *surface;
-  cairo_content_t content;
-
-  content = NUM2INT (rb_content);
 
-  if (content < CAIRO_CONTENT_COLOR ||
-      content > CAIRO_CONTENT_COLOR_ALPHA)
-    {
-        rb_raise (rb_eArgError, "invalid content");
-    }
-
-  surface = cairo_surface_create_similar (RVAL2CRSURFACE (self), content,
+  surface = cairo_surface_create_similar (RVAL2CRSURFACE (self),
+                                          RVAL2CRCONTENT (content),
                                           NUM2INT (width), NUM2INT (height));
   cr_surface_check_status (surface);
   cr_surface_set_klass (surface, rb_obj_class (self));
@@ -395,30 +387,21 @@
 static cairo_surface_t *
 cr_image_surface_create (VALUE self, VALUE format, VALUE width, VALUE height)
 {
-  return cairo_image_surface_create (NUM2INT (format),
+  return cairo_image_surface_create (RVAL2CRFORMAT (format),
                                      NUM2INT (width),
                                      NUM2INT (height));
 }
 
 static cairo_surface_t *
-cr_image_surface_create_for_data (VALUE self, VALUE rb_data, VALUE rb_format,
+cr_image_surface_create_for_data (VALUE self, VALUE rb_data, VALUE format,
                                   VALUE width, VALUE height, VALUE stride)
 {
   unsigned char *data;
-  cairo_format_t format;
-
-  format = NUM2INT (rb_format);
-
-  if (format < CAIRO_FORMAT_ARGB32 ||
-      format < CAIRO_FORMAT_A1)
-    {
-      rb_raise (rb_eArgError, "invalid format");
-    }
 
   data = (unsigned char *)StringValuePtr (rb_data);
   
   return cairo_image_surface_create_for_data (data,
-                                              format,
+                                              RVAL2CRFORMAT (format),
                                               NUM2INT (width),
                                               NUM2INT (height),
                                               NUM2INT (stride));



More information about the cairo-commit mailing list