module GLib

glib-mkenums.rb

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

Copyright© 2006-2015 Ruby-GNOME2 Project.

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

Copyright © 2022 Ruby-GNOME Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Copyright © 2015-2017 Ruby-GNOME2 Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Copyright © 2018-2021 Ruby-GNOME Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Copyright © 2016 Ruby-GNOME2 Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Copyright © 2024 Ruby-GNOME Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Copyright © 2022 Ruby-GNOME Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Copyright © 2015 Ruby-GNOME2 Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

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;

FILENAME_ENCODING
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
SIGNAL_HANDLER_PREFIX
SQRT2
VERSION

Version Information

VIRTUAL_FUNCTION_IMPLEMENTATION_PREFIX

Public Instance Methods

__add_one_arg_setter(klass) click to toggle source
# File lib/glib2.rb, line 49
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 24
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 33
def exit_application(exception, status)
  msg = exception.message || exception.to_s
  msg = exception.class.to_s if msg == ""
  backtrace = exception.backtrace || []
  first_line = backtrace.shift
  if first_line
    $stderr.puts("#{first_line}: #{msg}")
  else
    $stderr.puts(msg)
  end
  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 103
def prepend_dll_path(path)
  path = Pathname(path) unless path.is_a?(Pathname)
  return unless path.exist?

  begin
    require "ruby_installer/runtime"
  rescue LoadError
  else
    RubyInstaller::Runtime.add_dll_directory(path.to_s)
  end
  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 88
def prepend_path_to_environment_variable(path, environment_name)
  path = Pathname(path) unless path.is_a?(Pathname)
  return unless path.exist?

  dir = path.to_s
  dir = dir.gsub(/\//, ::File::ALT_SEPARATOR) if ::File::ALT_SEPARATOR

  separator = ::File::PATH_SEPARATOR
  paths = (ENV[environment_name] || '').split(separator)
  unless paths.include?(dir)
    paths = [dir] + paths
    ENV[environment_name] = paths.join(separator)
  end
end