class Clutter::Loader

Constants

NAMESPACE

Public Class Methods

new(base_module, init_arguments) click to toggle source
Calls superclass method
# File lib/clutter.rb, line 73
def initialize(base_module, init_arguments)
  super(base_module)
  @init_arguments = init_arguments
  @key_constants = {}
  @other_constant_infos = []
  @event_infos = []
end

Public Instance Methods

load() click to toggle source
Calls superclass method
# File lib/clutter.rb, line 81
def load
  super(NAMESPACE)
end

Private Instance Methods

load_constant_info(info) click to toggle source
# File lib/clutter.rb, line 165
def load_constant_info(info)
  case info.name
  when /\AKEY_/
    @key_constants[info.name] = true
    @keys_module.const_set(info.name, info.value)
  when /_VERSION\z/
    @version_module.const_set($PREMATCH, info.value)
  else
    @other_constant_infos << info
  end
end
load_events() click to toggle source
# File lib/clutter.rb, line 115
def load_events
  @event_infos.each do |event_info|
    define_struct(event_info, :parent => Event)
  end
  event_map = {
    EventType::KEY_PRESS      => KeyEvent,
    EventType::KEY_RELEASE    => KeyEvent,
    EventType::MOTION         => MotionEvent,
    EventType::ENTER          => CrossingEvent,
    EventType::LEAVE          => CrossingEvent,
    EventType::BUTTON_PRESS   => ButtonEvent,
    EventType::BUTTON_RELEASE => ButtonEvent,
    EventType::SCROLL         => ScrollEvent,
    EventType::STAGE_STATE    => StageStateEvent,
    EventType::TOUCH_UPDATE   => TouchEvent,
    EventType::TOUCH_END      => TouchEvent,
    EventType::TOUCH_CANCEL   => TouchEvent,
  }
  self.class.register_boxed_class_converter(Event.gtype) do |event|
    event_map[event.type] || Event
  end
end
load_function_info(info) click to toggle source
Calls superclass method
# File lib/clutter.rb, line 146
def load_function_info(info)
  name = info.name
  case name
  when "init"
    # ignore
  when /\Athreads_/
    define_module_function(@threads_module, $POSTMATCH, info)
  when /\Afeature_/
    method_name = rubyish_method_name(info, :prefix => "feature_")
    case method_name
    when "available"
      method_name = "#{method_name}?"
    end
    define_module_function(@feature_module, method_name, info)
  else
    super
  end
end
load_struct_info(info) click to toggle source
Calls superclass method
# File lib/clutter.rb, line 138
def load_struct_info(info)
  if info.name.end_with?("Event")
    @event_infos << info
  else
    super
  end
end
post_load(repository, namespace) click to toggle source
# File lib/clutter.rb, line 106
def post_load(repository, namespace)
  @other_constant_infos.each do |constant_info|
    name = constant_info.name
    next if @key_constants.has_key?("KEY_#{name}")
    @base_module.const_set(name, constant_info.value)
  end
  load_events
end
pre_load(repository, namespace) click to toggle source
# File lib/clutter.rb, line 86
def pre_load(repository, namespace)
  init = repository.find(namespace, "init")
  arguments = [
    [$0] + @init_arguments,
  ]
  error, returned_arguments = init.invoke(arguments)
  @init_arguments.replace(returned_arguments[1..-1])
  if error.to_i <= 0
    raise InitError, "failed to initialize Clutter: #{error.name}"
  end
  @keys_module = Module.new
  @base_module.const_set("Keys", @keys_module)
  @threads_module = Module.new
  @base_module.const_set("Threads", @threads_module)
  @feature_module = Module.new
  @base_module.const_set("Feature", @feature_module)
  @version_module = Module.new
  @base_module.const_set("Version", @version_module)
end