[cairo-commit] rcairo/packages/cairo/lib cairo.rb,1.22,1.23

Kouhei Sutou commit at pdx.freedesktop.org
Sun Oct 15 00:12:36 PDT 2006


Committed by: kou

Update of /cvs/cairo/rcairo/packages/cairo/lib
In directory kemper:/tmp/cvs-serv15502/packages/cairo/lib

Modified Files:
	cairo.rb 
Log Message:
* packages/cairo/lib/cairo.rb: moved Cairo.__add_one_arg_setter
  call to ...
* packages/cairo/ext/rb_cairo.c, packages/cairo/ext/rb_cairo.h,
  packages/cairo/ext/rb_cairo_context.c,
  packages/cairo/ext/rb_cairo_font_options.c,
  packages/cairo/ext/rb_cairo_glyph.c,
  packages/cairo/ext/rb_cairo_matrix.c,
  packages/cairo/ext/rb_cairo_pattern.c,
  packages/cairo/ext/rb_cairo_surface.c: ... here.


Index: cairo.rb
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/lib/cairo.rb,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cairo.rb	15 Oct 2006 06:54:07 -0000	1.22
+++ cairo.rb	15 Oct 2006 07:12:33 -0000	1.23
@@ -1,8 +1,24 @@
 # vim: filetype=ruby:expandtab:shiftwidth=2:tabstop=8:softtabstop=2 :
 
+module Cairo
+  def self.__add_one_arg_setter(klass)
+    names = klass.instance_methods(false)
+    names.each do |name|
+      if /^set_(.*)/ =~ name and
+          not names.include? "#{$1}=" and
+          klass.instance_method(name).arity == 1
+        klass.module_eval("def #{$1}=(val); set_#{$1}(val); val; end")
+      end
+    end
+  end
+end
+
 require 'cairo.so'
 
 module Cairo
+  class << self
+    undef __add_one_arg_setter
+  end
 
   module_function
   def bindings_version
@@ -11,21 +27,8 @@
     version << "-#{tag}" if tag
     version
   end
-  
-  def __add_one_arg_setter(klass)
-    names = klass.instance_methods(false)
-    names.each do |name|
-      if /^set_(.*)/ =~ name and
-        not names.include? "#{$1}=" and
-        klass.instance_method(name).arity == 1
-        klass.module_eval("def #{$1}=(val); set_#{$1}(val); val; end")
-      end
-    end
-  end
 
   class Context
-    Cairo.__add_one_arg_setter(self)
-
     def quad_to(x1, y1, x2, y2)
       x0, y0 = current_point
       cx1 = x0 + 2 * (x1 - x0) / 3.0
@@ -34,7 +37,7 @@
       cy2 = cy1 + (y2 - y0) / 3.0
       curve_to(cx1, cy1, cx2, cy2, x2, y2)
     end
-    
+
     def rel_quad_to(x1, y1, x2, y2)
       x0, y0 = current_point
       quad_to(x1 + x0, y1 + y0, x2 + x0, y2 + x0)
@@ -48,9 +51,9 @@
 
       y_radius ||= x_radius
 
-      x_radius = [x_radius, width / 2].min
-      y_radius = [y_radius, height / 2].min
-      
+      x_radius = [x_radius, width / 2.0].min
+      y_radius = [y_radius, height / 2.0].min
+
       xr1 = x_radius
       xr2 = x_radius / 2.0
       yr1 = y_radius
@@ -67,16 +70,12 @@
       curve_to(x1, y1 + yr2, x1 + xr2, y1, x1 + xr1, y1)
       close_path
     end
-    
+
     def circle(x, y, radius)
       arc(x, y, radius, 0, 2 * Math::PI)
     end
   end
 
-  class Glyph
-    Cairo.__add_one_arg_setter(self)
-  end
-
   class Surface
     def dup
       raise NotImplementedError
@@ -100,7 +99,7 @@
     def dup
       Matrix.new(*to_a)
     end
-    
+
     def clone
       copy = dup
       copy.freeze if self.frozen?
@@ -114,16 +113,4 @@
     def multiply(other); dup.multiply!(other); end
     alias * multiply
   end
-
-  class FontOptions
-    Cairo.__add_one_arg_setter(self)
-  end
-
-  class Pattern
-    Cairo.__add_one_arg_setter(self)
-  end
-
-  class SurfacePattern
-    Cairo.__add_one_arg_setter(self)
-  end
 end



More information about the cairo-commit mailing list