module GLib - glib2-2.2.5 Documentation

# module GLib

glib-mkenums.rb

C language enum description generation library like as glib-mkenums tool.

Copyright(C) 2006-2013 Ruby-GNOME2 Project.

This program is licenced under the same license of Ruby-GNOME2.

### Constants

BINARY_AGE
BINDING_VERSION
BUILD_VERSION
DIR_SEPARATOR
E

      Don't implement them.

  define G_IEEE754_FLOAT_BIAS define G_IEEE754_DOUBLE_BIAS union GFloatIEEE754; union GDoubleIEEE754;

INTERFACE_AGE
LN10
LN2
LOG_2_BASE_10
LOG_DOMAIN
MAJOR_VERSION
MAXDOUBLE
MAXFLOAT
MAXINT
MAXINT16
MAXINT32
MAXINT64
MAXINT8
MAXLONG
MAXSHORT
MAXSIZE
MAXUINT
MAXUINT16
MAXUINT32
MAXUINT64
MAXUINT8
MAXULONG
MAXUSHORT
MICRO_VERSION
MINDOUBLE
MINFLOAT
MININT

  Limits of Basic Types

MININT16
MININT32
MININT64
MININT8
MINLONG
MINOR_VERSION
MINSHORT
PI
PI_2
PI_4
PRIORITY_DEFAULT
PRIORITY_DEFAULT_IDLE
PRIORITY_HIGH

  From “The Main Event Loop”

PRIORITY_HIGH_IDLE
PRIORITY_LOW
SEARCHPATH_SEPARATOR
SQRT2
VERSION

  Version Information

### Public Instance Methods

__add_one_arg_setter(klass) click to toggle source

    # File lib/glib2.rb, line 34
    def __add_one_arg_setter(klass)
      # for Instance methods.
      method_names = klass.instance_methods(false)
      method_names.each do |method_name|
        next if /\Aset_/ !~ method_name
        property_name = $POSTMATCH
        next if klass.method_defined?("#{property_name}=")
        next if klass.instance_method(method_name).arity != 1
        begin
          klass.module_eval("def #{property_name}=(val); set_#{property_name}(val); val; end\n")
        rescue SyntaxError
          if $DEBUG
            $stderr.puts "Couldn't create #{klass}\##{property_name}=(v)."
          end
        end
      end

      # for Class methods/Module functions.
      if klass.method(:methods).arity == -1
        method_names = klass.methods(false)
      else
        method_names = klass.methods
      end
      singleton_klass = (class << klass; self; end)
      method_names.each do |method_name|
        next if /\Aset_/ !~ method_name
        property_name = $POSTMATCH
        next if singleton_klass.method_defined?("#{property_name}=")
        next if klass.method(method_name).arity != 1
        begin
          klass.module_eval("def self.#{property_name}=(val); set_#{property_name}(val); val; end\n")
        rescue SyntaxError
          if $DEBUG
            $stderr.puts "Couldn't create #{klass}.#{property_name}=(v)."
          end
        end
      end
    end

check_binding_version?(major, minor, micro) click to toggle source

    # File lib/glib2.rb, line 14
    def check_binding_version?(major, minor, micro)
      BINDING_VERSION[0] > major ||
        (BINDING_VERSION[0] == major &&
         BINDING_VERSION[1] > minor) ||
        (BINDING_VERSION[0] == major &&
         BINDING_VERSION[1] == minor &&
         BINDING_VERSION[2] >= micro)
    end

exit_application(exception, status) click to toggle source

    # File lib/glib2.rb, line 23
    def exit_application(exception, status)
      msg = exception.message || exception.to_s
      msg = exception.class.to_s if msg == ""
      backtrace = exception.backtrace
      $stderr.puts backtrace.shift + ": #{msg}"
      backtrace.each do |v|
        $stderr.puts "\t from #{v}"
      end
      exit(status)
    end

prepend_dll_path(path) click to toggle source

    # File lib/glib2.rb, line 88
    def prepend_dll_path(path)
      prepend_path_to_environment_variable(path, "PATH")
    end

prepend_path_to_environment_variable(path, environment_name) click to toggle source

    # File lib/glib2.rb, line 73
    def prepend_path_to_environment_variable(path, environment_name)
      path = Pathname(path) unless path.is_a?(Pathname)
      if path.exist?
        separator = ::File::PATH_SEPARATOR

        paths = (ENV[environment_name] || '').split(/#{Regexp.escape(separator)}/)
        dir = path.to_s
        dir = dir.gsub(/\//, ::File::ALT_SEPARATOR) if ::File::ALT_SEPARATOR
        unless paths.include?(dir)
          paths = [dir] + paths
          ENV[environment_name] = paths.join(separator)
        end
      end
    end