Sha256: 64bbce4e552d7534678f0501b8e628623d428bb391b060600af12af71bfc5faa

Contents?: true

Size: 1.3 KB

Versions: 11

Compression:

Stored size: 1.3 KB

Contents

module Wx

  class << self

    private

    class Key
      def initialize(mod, sym)
        @mod = mod
        @sym = sym
      end
      attr_reader :mod, :sym

      def eql?(other)
        self.class === other && mod == other.mod && sym == other.sym
      end

      def hash
        "#{mod}#{sym}".hash
      end
    end

    def delayed_constants
      @delayed_constants ||= ::Hash.new
    end

    public

    def add_delayed_constant(mod, sym, &block)
      delayed_constants[Key.new(mod,sym)] = block
    end

    def load_delayed_constants
      delayed_constants.each_pair { |key, blk| key.mod.const_set(key.sym, blk.call) }
      delayed_constants.clear # cleanup
    end

    def check_delayed_constant(mod, sym)
      if delayed_constants.has_key?(Key.new(mod, sym))
        raise "Delayed constant #{mod.name}::#{sym} cannot be referenced before the Wx::App has started."
      end
    end
  end

  if !defined?(::WxGlobalConstants)
    def self.const_missing(sym)
      Wx.check_delayed_constant(self, sym)
      super
    end
  end
end

Dir.glob(File.join(File.dirname(__FILE__), 'ext', '*.rb')) do | fpath |
  require_relative './ext/' + File.basename(fpath)
end
# Constant extension loader for wxRuby3
# Copyright (c) M.J.N. Corino, The Netherlands

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wxruby3-0.9.0.pre.rc.3-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0.pre.rc.2-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0.pre.rc.1-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0.pre.beta.14-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0.pre.beta.13-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0.pre.beta.11-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0.pre.beta.10-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0.pre.beta.9-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0.pre.beta.8-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0.pre.beta.2-x64-mingw-ucrt-3.2-3.2.2 lib/wx/core/ext.rb
wxruby3-0.9.0.pre.beta.1-x64-mingw-ucrt-3.2 lib/wx/core/ext.rb