class Exports

Constants

PrivateNames

Public Class Methods

create(*args, &block) click to toggle source
# File ruby_3_3_0_preview1/win32/mkexports.rb, line 12
def self.create(*args, &block)
  platform = RUBY_PLATFORM
  klass = constants.find do |p|
    break const_get(p) if platform.include?(p.to_s.downcase)
  end
  unless klass
    raise ArgumentError, "unsupported platform: #{platform}"
  end
  klass.new(*args, &block)
end
extract(objs, *rest) click to toggle source
# File ruby_3_3_0_preview1/win32/mkexports.rb, line 23
def self.extract(objs, *rest)
  create(objs).exports(*rest)
end
new(objs) click to toggle source
# File ruby_3_3_0_preview1/win32/mkexports.rb, line 35
def initialize(objs)
  syms = {}
  winapis = {}
  syms["ruby_sysinit_real"] = "ruby_sysinit"
  each_export(objs) do |internal, export|
    syms[internal] = export
    winapis[$1] = internal if /^_?(rb_w32_\w+)(?:@\d+)?$/ =~ internal
  end
  incdir = File.join(File.dirname(File.dirname(__FILE__)), "include/ruby")
  read_substitution(incdir+"/win32.h", syms, winapis)
  read_substitution(incdir+"/subst.h", syms, winapis)
  syms["rb_w32_vsnprintf"] ||= "ruby_vsnprintf"
  syms["rb_w32_snprintf"] ||= "ruby_snprintf"
  @syms = syms
end
output(output = $output) { |STDOUT| ... } click to toggle source
# File ruby_3_3_0_preview1/win32/mkexports.rb, line 27
def self.output(output = $output, &block)
  if output
    File.open(output, 'wb', &block)
  else
    yield STDOUT
  end
end

Public Instance Methods

exports(name = $name, library = $library, description = $description) click to toggle source
# File ruby_3_3_0_preview1/win32/mkexports.rb, line 63
def exports(name = $name, library = $library, description = $description)
  exports = []
  if name
    exports << "Name " + name
  elsif library
    exports << "Library " + library
  end
  exports << "Description " + description.dump if description
  exports << "VERSION #{RbConfig::CONFIG['MAJOR']}.#{RbConfig::CONFIG['MINOR']}"
  exports << "EXPORTS" << symbols()
  exports
end
read_substitution(header, syms, winapis) click to toggle source
# File ruby_3_3_0_preview1/win32/mkexports.rb, line 51
def read_substitution(header, syms, winapis)
  File.foreach(header) do |line|
    if /^#define (\w+)\((.*?)\)\s+(?:\(void\))?(rb_w32_\w+)\((.*?)\)\s*$/ =~ line and
        $2.delete(" ") == $4.delete(" ")
      export, internal = $1, $3
      if syms[internal] or internal = winapis[internal]
        syms[forwarding(internal, export)] = internal
      end
    end
  end
end