[cairo-commit] rcairo/src/lib cairo.rb,NONE,1.1

Kouhei Sutou commit at pdx.freedesktop.org
Tue Mar 6 04:17:41 PST 2007


Committed by: kou

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

Added Files:
	cairo.rb 
Log Message:
* setup.rb: removed dependency on setup.rb. used Ruby-GNOME2 style.
* extconf.rb: moved from packages/cairo/ext/.

* packages/cairo/ext: move to ...
* src/: ... here.

* packages/cairo/lib: move to ...
* src/lib: ... here.

* README, samples/: followed the changes.


--- NEW FILE: cairo.rb ---
# vim: filetype=ruby:expandtab:shiftwidth=2:tabstop=8:softtabstop=2 :

if /mingw|mswin|mswin32/ =~ RUBY_PLATFORM
  require 'rbconfig'
  ENV['PATH'] = %w(bin lib).collect do |dir|
    "#{Config::CONFIG["prefix"]}\\lib\\GTK\\#{dir};"
  end.join('') + ENV['PATH']
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")
      end
    end
  end
end

require 'cairo.so'

module Cairo
  class << self
    undef __add_one_arg_setter
  end

  module_function
  def bindings_version
    major, minor, micro, tag = BINDINGS_VERSION
    version = [major, minor, micro].join('.')
    version << "-#{tag}" if tag
    version
  end

  class Surface
    def dup
      raise NotImplementedError
    end
    def clone
      raise NotImplementedError
    end
  end

  class SVGSurface
    class << self
      def versions_as_string
        versions.collect do |version|
          version_to_string(version)
        end
      end
    end
  end

  class Matrix
    def dup
      Matrix.new(*to_a)
    end

    def clone
      copy = dup
      copy.freeze if self.frozen?
      copy
    end

    def translate(tx, ty); dup.translate!(tx, ty); end
    def scale(sx, sy); dup.scale!(sx, sy); end
    def rotate(radians); dup.rotate!(radians); end
    def invert; dup.invert!; end
    def multiply(other); dup.multiply!(other); end
    alias * multiply
  end
end

require 'cairo/context'



More information about the cairo-commit mailing list