[cairo-commit] rcairo/src/lib cairo.rb,1.3,1.4

Kouhei Sutou commit at pdx.freedesktop.org
Tue May 1 04:49:52 PDT 2007


Committed by: kou

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

Modified Files:
	cairo.rb 
Log Message:
* src/rb_cairo_private.[ch] (rb_cairo__const_get,
  Init_cairo_private): added.
* src/rb_cairo.c: moved Init_* declarations to rb_cairo_private.h.
* src/rb_cairo_constants.c: supported abbrev notation for constant
  name. We can write just like
    context.antialias = :none
  instead of
    context.antialias = Cairo::ANTIALIAS_NONE

* src/lib/cairo.rb (Cairo.normalize_const_name): added.
* src/lib/cairo/color.rb: used Cairo.normalize_const_name.


Index: cairo.rb
===================================================================
RCS file: /cvs/cairo/rcairo/src/lib/cairo.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo.rb	16 Apr 2007 04:52:44 -0000	1.3
+++ cairo.rb	1 May 2007 11:49:43 -0000	1.4
@@ -8,15 +8,21 @@
 end
 
 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")
+  class << self
+    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
+
+    def normalize_const_name(name)
+      name.to_s.upcase.gsub(/[\s\-_]+/, "_")
+    end
   end
 end
 



More information about the cairo-commit mailing list