class ChildProcess::Tools::Generator

Constants

DEFAULT_INCLUDES
EXE_NAME
TMP_PROGRAM

Public Class Methods

generate() click to toggle source
# File lib/childprocess/tools/generator.rb, line 10
def self.generate
  new.generate
end
new() click to toggle source
# File lib/childprocess/tools/generator.rb, line 14
def initialize
  @cc        = ENV['CC'] || 'gcc'
  @out       = File.expand_path("../../unix/platform/#{ChildProcess.platform_name}.rb", __FILE__)
  @sizeof    = {}
  @constants = {}
end

Public Instance Methods

fetch_size(type_name, opts = {}) click to toggle source
# File lib/childprocess/tools/generator.rb, line 47
def fetch_size(type_name, opts = {})
  print "sizeof(#{type_name}): "
  src = 
generate() click to toggle source
# File lib/childprocess/tools/generator.rb, line 21
def generate
  fetch_size 'posix_spawn_file_actions_t', :include => "spawn.h"
  fetch_size 'posix_spawnattr_t', :include => "spawn.h"
  fetch_size 'sigset_t', :include => "signal.h"

  fetch_constant 'POSIX_SPAWN_RESETIDS',   :include  => 'spawn.h'
  fetch_constant 'POSIX_SPAWN_SETPGROUP',  :include  => 'spawn.h'
  fetch_constant 'POSIX_SPAWN_SETSIGDEF',  :include  => 'spawn.h'
  fetch_constant 'POSIX_SPAWN_SETSIGMASK', :include  => 'spawn.h'

  if ChildProcess.linux?
    fetch_constant 'POSIX_SPAWN_USEVFORK', :include => 'spawn.h', :define => {'_GNU_SOURCE' => nil}
  end

  write
end
write() click to toggle source
# File lib/childprocess/tools/generator.rb, line 38
def write
  FileUtils.mkdir_p(File.dirname(@out))
  File.open(@out, 'w') do |io|
    io.puts result
  end

  puts "wrote #{@out}"
end