Sha256: 6cfc0f9dfddecc13ab95121f77f695c7bd059ebdecd132248eb95bf26fccf752

Contents?: true

Size: 1.52 KB

Versions: 6

Compression:

Stored size: 1.52 KB

Contents

# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.
# 
# Some parts are
# Copyright 2004-2007, wxRuby development team
# released under the MIT-like wxRuby2 license

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

6 entries across 6 versions & 1 rubygems

Version Path
wxruby3-0.9.5-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.4-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.3-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.2-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.1-x64-mingw-ucrt lib/wx/core/ext.rb
wxruby3-0.9.0-x64-mingw-ucrt lib/wx/core/ext.rb