-# Subject: Addressing Needs
-#
-# Community:
-#
-# Just wanted to send a quick note assuring that your needs are being addressed.
-#
-# I want you to know that my team will keep working on the issues, especially:
-#
-# * Run Ruby Quiz
-# * Document Modules
-# * Answer Questions on Ruby Talk
-#
-# Thanks for your patience.
-#
-# James Edward Gray II
-#
-# === Ruby in HTML
-#
-# ERB is often used in .rhtml files (HTML with embedded Ruby). Notice the need in
-# this example to provide a special binding when the template is run, so that the instance
-# variables in the Product object can be resolved.
-#
-# require "erb"
-#
-# # Build template data class.
-# class Product
-# def initialize( code, name, desc, cost )
-# @code = code
-# @name = name
-# @desc = desc
-# @cost = cost
-#
-# @features = [ ]
-# end
-#
-# def add_feature( feature )
-# @features << feature
-# end
-#
-# # Support templating of member data.
-# def get_binding
-# binding
-# end
-#
-# # ...
-# end
-#
-# # Create template.
-# template = %{
-#
-# Ruby Toys -- <%= @name %>
-#
-#
-# <%= @name %> (<%= @code %>)
-# <%= @desc %>
-#
-#
-# <% @features.each do |f| %>
-# - <%= f %>
-# <% end %>
-#
-#
-#
-# <% if @cost < 10 %>
-# Only <%= @cost %>!!!
-# <% else %>
-# Call for a price, today!
-# <% end %>
-#
-#
-#
-#
-# }.gsub(/^ /, '')
-#
-# rhtml = ERB.new(template)
-#
-# # Set up template data.
-# toy = Product.new( "TZ-1002",
-# "Rubysapien",
-# "Geek's Best Friend! Responds to Ruby commands...",
-# 999.95 )
-# toy.add_feature("Listens for verbal commands in the Ruby language!")
-# toy.add_feature("Ignores Perl, Java, and all C variants.")
-# toy.add_feature("Karate-Chop Action!!!")
-# toy.add_feature("Matz signature on left leg.")
-# toy.add_feature("Gem studded eyes... Rubies, of course!")
-#
-# # Produce result.
-# rhtml.run(toy.get_binding)
-#
-# Generates (some blank lines removed):
-#
-#
-# Ruby Toys -- Rubysapien
-#
-#
-# Rubysapien (TZ-1002)
-# Geek's Best Friend! Responds to Ruby commands...
-#
-#
-# - Listens for verbal commands in the Ruby language!
-# - Ignores Perl, Java, and all C variants.
-# - Karate-Chop Action!!!
-# - Matz signature on left leg.
-# - Gem studded eyes... Rubies, of course!
-#
-#
-#
-# Call for a price, today!
-#
-#
-#
-#
-#
-#
-# == Notes
-#
-# There are a variety of templating solutions available in various Ruby projects:
-# * ERB's big brother, eRuby, works the same but is written in C for speed;
-# * Amrita (smart at producing HTML/XML);
-# * cs/Template (written in C for speed);
-# * RDoc, distributed with Ruby, uses its own template engine, which can be reused elsewhere;
-# * and others; search {RubyGems.org}[https://rubygems.org/] or
-# {The Ruby Toolbox}[https://www.ruby-toolbox.com/].
-#
-# Rails, the web application framework, uses ERB to create views.
-#
-class ERB
- Revision = '$Date:: $' # :nodoc: #'
-
- # Returns revision information for the erb.rb module.
- def self.version
- "erb.rb [2.1.0 #{ERB::Revision.split[1]}]"
- end
-end
-
-#--
-# ERB::Compiler
-class ERB
- # = ERB::Compiler
- #
- # Compiles ERB templates into Ruby code; the compiled code produces the
- # template result when evaluated. ERB::Compiler provides hooks to define how
- # generated output is handled.
- #
- # Internally ERB does something like this to generate the code returned by
- # ERB#src:
- #
- # compiler = ERB::Compiler.new('<>')
- # compiler.pre_cmd = ["_erbout=''"]
- # compiler.put_cmd = "_erbout.concat"
- # compiler.insert_cmd = "_erbout.concat"
- # compiler.post_cmd = ["_erbout"]
- #
- # code, enc = compiler.compile("Got <%= obj %>!\n")
- # puts code
- #
- # Generates:
- #
- # #coding:UTF-8
- # _erbout=''; _erbout.concat "Got "; _erbout.concat(( obj ).to_s); _erbout.concat "!\n"; _erbout
- #
- # By default the output is sent to the print method. For example:
- #
- # compiler = ERB::Compiler.new('<>')
- # code, enc = compiler.compile("Got <%= obj %>!\n")
- # puts code
- #
- # Generates:
- #
- # #coding:UTF-8
- # print "Got "; print(( obj ).to_s); print "!\n"
- #
- # == Evaluation
- #
- # The compiled code can be used in any context where the names in the code
- # correctly resolve. Using the last example, each of these print 'Got It!'
- #
- # Evaluate using a variable:
- #
- # obj = 'It'
- # eval code
- #
- # Evaluate using an input:
- #
- # mod = Module.new
- # mod.module_eval %{
- # def get(obj)
- # #{code}
- # end
- # }
- # extend mod
- # get('It')
- #
- # Evaluate using an accessor:
- #
- # klass = Class.new Object
- # klass.class_eval %{
- # attr_accessor :obj
- # def initialize(obj)
- # @obj = obj
- # end
- # def get_it
- # #{code}
- # end
- # }
- # klass.new('It').get_it
- #
- # Good! See also ERB#def_method, ERB#def_module, and ERB#def_class.
- class Compiler # :nodoc:
- class PercentLine # :nodoc:
- def initialize(str)
- @value = str
- end
- attr_reader :value
- alias :to_s :value
-
- def empty?
- @value.empty?
- end
- end
-
- class Scanner # :nodoc:
- @scanner_map = {}
- def self.regist_scanner(klass, trim_mode, percent)
- @scanner_map[[trim_mode, percent]] = klass
- end
-
- def self.default_scanner=(klass)
- @default_scanner = klass
- end
-
- def self.make_scanner(src, trim_mode, percent)
- klass = @scanner_map.fetch([trim_mode, percent], @default_scanner)
- klass.new(src, trim_mode, percent)
- end
-
- def initialize(src, trim_mode, percent)
- @src = src
- @stag = nil
- end
- attr_accessor :stag
-
- def scan; end
- end
-
- class TrimScanner < Scanner # :nodoc:
- def initialize(src, trim_mode, percent)
- super
- @trim_mode = trim_mode
- @percent = percent
- if @trim_mode == '>'
- @scan_line = self.method(:trim_line1)
- elsif @trim_mode == '<>'
- @scan_line = self.method(:trim_line2)
- elsif @trim_mode == '-'
- @scan_line = self.method(:explicit_trim_line)
- else
- @scan_line = self.method(:scan_line)
- end
- end
- attr_accessor :stag
-
- def scan(&block)
- @stag = nil
- if @percent
- @src.each_line do |line|
- percent_line(line, &block)
- end
- else
- @scan_line.call(@src, &block)
- end
- nil
- end
-
- def percent_line(line, &block)
- if @stag || line[0] != ?%
- return @scan_line.call(line, &block)
- end
-
- line[0] = ''
- if line[0] == ?%
- @scan_line.call(line, &block)
- else
- yield(PercentLine.new(line.chomp))
- end
- end
-
- def scan_line(line)
- line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>|\n|\z)/m) do |tokens|
- tokens.each do |token|
- next if token.empty?
- yield(token)
- end
- end
- end
-
- def trim_line1(line)
- line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>\n|%>|\n|\z)/m) do |tokens|
- tokens.each do |token|
- next if token.empty?
- if token == "%>\n"
- yield('%>')
- yield(:cr)
- else
- yield(token)
- end
- end
- end
- end
-
- def trim_line2(line)
- head = nil
- line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>\n|%>|\n|\z)/m) do |tokens|
- tokens.each do |token|
- next if token.empty?
- head = token unless head
- if token == "%>\n"
- yield('%>')
- if is_erb_stag?(head)
- yield(:cr)
- else
- yield("\n")
- end
- head = nil
- else
- yield(token)
- head = nil if token == "\n"
- end
- end
- end
- end
-
- def explicit_trim_line(line)
- line.scan(/(.*?)(^[ \t]*<%\-|<%\-|<%%|%%>|<%=|<%#|<%|-%>\n|-%>|%>|\z)/m) do |tokens|
- tokens.each do |token|
- next if token.empty?
- if @stag.nil? && /[ \t]*<%-/ =~ token
- yield('<%')
- elsif @stag && token == "-%>\n"
- yield('%>')
- yield(:cr)
- elsif @stag && token == '-%>'
- yield('%>')
- else
- yield(token)
- end
- end
- end
- end
-
- ERB_STAG = %w(<%= <%# <%)
- def is_erb_stag?(s)
- ERB_STAG.member?(s)
- end
- end
-
- Scanner.default_scanner = TrimScanner
-
- class SimpleScanner < Scanner # :nodoc:
- def scan
- @src.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>|\n|\z)/m) do |tokens|
- tokens.each do |token|
- next if token.empty?
- yield(token)
- end
- end
- end
- end
-
- Scanner.regist_scanner(SimpleScanner, nil, false)
-
- begin
- require 'strscan'
- class SimpleScanner2 < Scanner # :nodoc:
- def scan
- stag_reg = /(.*?)(<%%|<%=|<%#|<%|\z)/m
- etag_reg = /(.*?)(%%>|%>|\z)/m
- scanner = StringScanner.new(@src)
- while ! scanner.eos?
- scanner.scan(@stag ? etag_reg : stag_reg)
- yield(scanner[1])
- yield(scanner[2])
- end
- end
- end
- Scanner.regist_scanner(SimpleScanner2, nil, false)
-
- class ExplicitScanner < Scanner # :nodoc:
- def scan
- stag_reg = /(.*?)(^[ \t]*<%-|<%%|<%=|<%#|<%-|<%|\z)/m
- etag_reg = /(.*?)(%%>|-%>|%>|\z)/m
- scanner = StringScanner.new(@src)
- while ! scanner.eos?
- scanner.scan(@stag ? etag_reg : stag_reg)
- yield(scanner[1])
-
- elem = scanner[2]
- if /[ \t]*<%-/ =~ elem
- yield('<%')
- elsif elem == '-%>'
- yield('%>')
- yield(:cr) if scanner.scan(/(\n|\z)/)
- else
- yield(elem)
- end
- end
- end
- end
- Scanner.regist_scanner(ExplicitScanner, '-', false)
-
- rescue LoadError
- end
-
- class Buffer # :nodoc:
- def initialize(compiler, enc=nil)
- @compiler = compiler
- @line = []
- @script = enc ? "#coding:#{enc}\n" : ""
- @compiler.pre_cmd.each do |x|
- push(x)
- end
- end
- attr_reader :script
-
- def push(cmd)
- @line << cmd
- end
-
- def cr
- @script << (@line.join('; '))
- @line = []
- @script << "\n"
- end
-
- def close
- return unless @line
- @compiler.post_cmd.each do |x|
- push(x)
- end
- @script << (@line.join('; '))
- @line = nil
- end
- end
-
- def content_dump(s) # :nodoc:
- n = s.count("\n")
- if n > 0
- s.dump + "\n" * n
- else
- s.dump
- end
- end
-
- def add_put_cmd(out, content)
- out.push("#{@put_cmd} #{content_dump(content)}")
- end
-
- def add_insert_cmd(out, content)
- out.push("#{@insert_cmd}((#{content}).to_s)")
- end
-
- # Compiles an ERB template into Ruby code. Returns an array of the code
- # and encoding like ["code", Encoding].
- def compile(s)
- enc = s.encoding
- raise ArgumentError, "#{enc} is not ASCII compatible" if enc.dummy?
- s = s.b # see String#b
- enc = detect_magic_comment(s) || enc
- out = Buffer.new(self, enc)
-
- content = ''
- scanner = make_scanner(s)
- scanner.scan do |token|
- next if token.nil?
- next if token == ''
- if scanner.stag.nil?
- case token
- when PercentLine
- add_put_cmd(out, content) if content.size > 0
- content = ''
- out.push(token.to_s)
- out.cr
- when :cr
- out.cr
- when '<%', '<%=', '<%#'
- scanner.stag = token
- add_put_cmd(out, content) if content.size > 0
- content = ''
- when "\n"
- content << "\n"
- add_put_cmd(out, content)
- content = ''
- when '<%%'
- content << '<%'
- else
- content << token
- end
- else
- case token
- when '%>'
- case scanner.stag
- when '<%'
- if content[-1] == ?\n
- content.chop!
- out.push(content)
- out.cr
- else
- out.push(content)
- end
- when '<%='
- add_insert_cmd(out, content)
- when '<%#'
- # out.push("# #{content_dump(content)}")
- end
- scanner.stag = nil
- content = ''
- when '%%>'
- content << '%>'
- else
- content << token
- end
- end
- end
- add_put_cmd(out, content) if content.size > 0
- out.close
- return out.script, enc
- end
-
- def prepare_trim_mode(mode) # :nodoc:
- case mode
- when 1
- return [false, '>']
- when 2
- return [false, '<>']
- when 0
- return [false, nil]
- when String
- perc = mode.include?('%')
- if mode.include?('-')
- return [perc, '-']
- elsif mode.include?('<>')
- return [perc, '<>']
- elsif mode.include?('>')
- return [perc, '>']
- else
- [perc, nil]
- end
- else
- return [false, nil]
- end
- end
-
- def make_scanner(src) # :nodoc:
- Scanner.make_scanner(src, @trim_mode, @percent)
- end
-
- # Construct a new compiler using the trim_mode. See ERB::new for available
- # trim modes.
- def initialize(trim_mode)
- @percent, @trim_mode = prepare_trim_mode(trim_mode)
- @put_cmd = 'print'
- @insert_cmd = @put_cmd
- @pre_cmd = []
- @post_cmd = []
- end
- attr_reader :percent, :trim_mode
-
- # The command to handle text that ends with a newline
- attr_accessor :put_cmd
-
- # The command to handle text that is inserted prior to a newline
- attr_accessor :insert_cmd
-
- # An array of commands prepended to compiled code
- attr_accessor :pre_cmd
-
- # An array of commands appended to compiled code
- attr_accessor :post_cmd
-
- private
- def detect_magic_comment(s)
- if /\A<%#(.*)%>/ =~ s or (@percent and /\A%#(.*)/ =~ s)
- comment = $1
- comment = $1 if comment[/-\*-\s*(.*?)\s*-*-$/]
- if %r"coding\s*[=:]\s*([[:alnum:]\-_]+)" =~ comment
- enc = $1.sub(/-(?:mac|dos|unix)/i, '')
- Encoding.find(enc)
- end
- end
- end
- end
-end
-
-#--
-# ERB
-class ERB
- #
- # Constructs a new ERB object with the template specified in _str_.
- #
- # An ERB object works by building a chunk of Ruby code that will output
- # the completed template when run. If _safe_level_ is set to a non-nil value,
- # ERB code will be run in a separate thread with $SAFE set to the
- # provided level.
- #
- # If _trim_mode_ is passed a String containing one or more of the following
- # modifiers, ERB will adjust its code generation as listed:
- #
- # % enables Ruby code processing for lines beginning with %
- # <> omit newline for lines starting with <% and ending in %>
- # > omit newline for lines ending in %>
- # - omit blank lines ending in -%>
- #
- # _eoutvar_ can be used to set the name of the variable ERB will build up
- # its output in. This is useful when you need to run multiple ERB
- # templates through the same binding and/or when you want to control where
- # output ends up. Pass the name of the variable to be used inside a String.
- #
- # === Example
- #
- # require "erb"
- #
- # # build data class
- # class Listings
- # PRODUCT = { :name => "Chicken Fried Steak",
- # :desc => "A well messages pattie, breaded and fried.",
- # :cost => 9.95 }
- #
- # attr_reader :product, :price
- #
- # def initialize( product = "", price = "" )
- # @product = product
- # @price = price
- # end
- #
- # def build
- # b = binding
- # # create and run templates, filling member data variables
- # ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), 0, "", "@product").result b
- # <%= PRODUCT[:name] %>
- # <%= PRODUCT[:desc] %>
- # END_PRODUCT
- # ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), 0, "", "@price").result b
- # <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
- # <%= PRODUCT[:desc] %>
- # END_PRICE
- # end
- # end
- #
- # # setup template data
- # listings = Listings.new
- # listings.build
- #
- # puts listings.product + "\n" + listings.price
- #
- # _Generates_
- #
- # Chicken Fried Steak
- # A well messages pattie, breaded and fried.
- #
- # Chicken Fried Steak -- 9.95
- # A well messages pattie, breaded and fried.
- #
- def initialize(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout')
- @safe_level = safe_level
- compiler = make_compiler(trim_mode)
- set_eoutvar(compiler, eoutvar)
- @src, @encoding = *compiler.compile(str)
- @filename = nil
- @lineno = 0
- end
-
- ##
- # Creates a new compiler for ERB. See ERB::Compiler.new for details
-
- def make_compiler(trim_mode)
- ERB::Compiler.new(trim_mode)
- end
-
- # The Ruby code generated by ERB
- attr_reader :src
-
- # The encoding to eval
- attr_reader :encoding
-
- # The optional _filename_ argument passed to Kernel#eval when the ERB code
- # is run
- attr_accessor :filename
-
- # The optional _lineno_ argument passed to Kernel#eval when the ERB code
- # is run
- attr_accessor :lineno
-
- def location=((filename, lineno))
- @filename = filename
- @lineno = lineno if lineno
- end
-
- #
- # Can be used to set _eoutvar_ as described in ERB::new. It's probably
- # easier to just use the constructor though, since calling this method
- # requires the setup of an ERB _compiler_ object.
- #
- def set_eoutvar(compiler, eoutvar = '_erbout')
- compiler.put_cmd = "#{eoutvar}.concat"
- compiler.insert_cmd = "#{eoutvar}.concat"
- compiler.pre_cmd = ["#{eoutvar} = ''"]
- compiler.post_cmd = ["#{eoutvar}.force_encoding(__ENCODING__)"]
- end
-
- # Generate results and print them. (see ERB#result)
- def run(b=new_toplevel)
- print self.result(b)
- end
-
- #
- # Executes the generated ERB code to produce a completed template, returning
- # the results of that code. (See ERB::new for details on how this process
- # can be affected by _safe_level_.)
- #
- # _b_ accepts a Binding object which is used to set the context of
- # code evaluation.
- #
- def result(b=new_toplevel)
- if @safe_level
- proc {
- $SAFE = @safe_level
- eval(@src, b, (@filename || '(erb)'), @lineno)
- }.call
- else
- eval(@src, b, (@filename || '(erb)'), @lineno)
- end
- end
-
- ##
- # Returns a new binding each time *near* TOPLEVEL_BINDING for runs that do
- # not specify a binding.
-
- def new_toplevel
- TOPLEVEL_BINDING.dup
- end
- private :new_toplevel
-
- # Define _methodname_ as instance method of _mod_ from compiled Ruby source.
- #
- # example:
- # filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml
- # erb = ERB.new(File.read(filename))
- # erb.def_method(MyClass, 'render(arg1, arg2)', filename)
- # print MyClass.new.render('foo', 123)
- def def_method(mod, methodname, fname='(ERB)')
- src = self.src
- magic_comment = "#coding:#{@encoding}\n"
- mod.module_eval do
- eval(magic_comment + "def #{methodname}\n" + src + "\nend\n", binding, fname, -2)
- end
- end
-
- # Create unnamed module, define _methodname_ as instance method of it, and return it.
- #
- # example:
- # filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml
- # erb = ERB.new(File.read(filename))
- # erb.filename = filename
- # MyModule = erb.def_module('render(arg1, arg2)')
- # class MyClass
- # include MyModule
- # end
- def def_module(methodname='erb')
- mod = Module.new
- def_method(mod, methodname, @filename || '(ERB)')
- mod
- end
-
- # Define unnamed class which has _methodname_ as instance method, and return it.
- #
- # example:
- # class MyClass_
- # def initialize(arg1, arg2)
- # @arg1 = arg1; @arg2 = arg2
- # end
- # end
- # filename = 'example.rhtml' # @arg1 and @arg2 are used in example.rhtml
- # erb = ERB.new(File.read(filename))
- # erb.filename = filename
- # MyClass = erb.def_class(MyClass_, 'render()')
- # print MyClass.new('foo', 123).render()
- def def_class(superklass=Object, methodname='result')
- cls = Class.new(superklass)
- def_method(cls, methodname, @filename || '(ERB)')
- cls
- end
-end
-
-#--
-# ERB::Util
-class ERB
- # A utility module for conversion routines, often handy in HTML generation.
- module Util
- public
- #
- # A utility method for escaping HTML tag characters in _s_.
- #
- # require "erb"
- # include ERB::Util
- #
- # puts html_escape("is a > 0 & a < 10?")
- #
- # _Generates_
- #
- # is a > 0 & a < 10?
- #
- def html_escape(s)
- CGI.escapeHTML(s.to_s)
- end
- alias h html_escape
- module_function :h
- module_function :html_escape
-
- #
- # A utility method for encoding the String _s_ as a URL.
- #
- # require "erb"
- # include ERB::Util
- #
- # puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
- #
- # _Generates_
- #
- # Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
- #
- def url_encode(s)
- s.to_s.b.gsub(/[^a-zA-Z0-9_\-.]/n) { |m|
- sprintf("%%%02X", m.unpack("C")[0])
- }
- end
- alias u url_encode
- module_function :u
- module_function :url_encode
- end
-end
-
-#--
-# ERB::DefMethod
-class ERB
- # Utility module to define eRuby script as instance method.
- #
- # === Example
- #
- # example.rhtml:
- # <% for item in @items %>
- # <%= item %>
- # <% end %>
- #
- # example.rb:
- # require 'erb'
- # class MyClass
- # extend ERB::DefMethod
- # def_erb_method('render()', 'example.rhtml')
- # def initialize(items)
- # @items = items
- # end
- # end
- # print MyClass.new([10,20,30]).render()
- #
- # result:
- #
- # 10
- #
- # 20
- #
- # 30
- #
- module DefMethod
- public
- # define _methodname_ as instance method of current module, using ERB
- # object or eRuby file
- def def_erb_method(methodname, erb_or_fname)
- if erb_or_fname.kind_of? String
- fname = erb_or_fname
- erb = ERB.new(File.read(fname))
- erb.def_method(self, methodname, fname)
- else
- erb = erb_or_fname
- erb.def_method(self, methodname, erb.filename || '(ERB)')
- end
- end
- module_function :def_erb_method
- end
-end
diff --git a/src/main/resources/stdlib/expect.rb b/src/main/resources/stdlib/expect.rb
deleted file mode 100644
index c3f3925..0000000
--- a/src/main/resources/stdlib/expect.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-$expect_verbose = false
-
-# Expect library adds the IO instance method #expect, which does similar act to
-# tcl's expect extension.
-#
-# In order to use this method, you must require expect:
-#
-# require 'expect'
-#
-# Please see #expect for usage.
-class IO
- # call-seq:
- # IO#expect(pattern,timeout=9999999) -> Array
- # IO#expect(pattern,timeout=9999999) { |result| ... } -> nil
- #
- # Reads from the IO until the given +pattern+ matches or the +timeout+ is over.
- #
- # It returns an array with the read buffer, followed by the matches.
- # If a block is given, the result is yielded to the block and returns nil.
- #
- # When called without a block, it waits until the input that matches the
- # given +pattern+ is obtained from the IO or the time specified as the
- # timeout passes. An array is returned when the pattern is obtained from the
- # IO. The first element of the array is the entire string obtained from the
- # IO until the pattern matches, followed by elements indicating which the
- # pattern which matched to the anchor in the regular expression.
- #
- # The optional timeout parameter defines, in seconds, the total time to wait
- # for the pattern. If the timeout expires or eof is found, nil is returned
- # or yielded. However, the buffer in a timeout session is kept for the next
- # expect call. The default timeout is 9999999 seconds.
- def expect(pat,timeout=9999999)
- buf = ''
- case pat
- when String
- e_pat = Regexp.new(Regexp.quote(pat))
- when Regexp
- e_pat = pat
- else
- raise TypeError, "unsupported pattern class: #{pat.class}"
- end
- @unusedBuf ||= ''
- while true
- if not @unusedBuf.empty?
- c = @unusedBuf.slice!(0).chr
- elsif !IO.select([self],nil,nil,timeout) or eof? then
- result = nil
- @unusedBuf = buf
- break
- else
- c = getc.chr
- end
- buf << c
- if $expect_verbose
- STDOUT.print c
- STDOUT.flush
- end
- if mat=e_pat.match(buf) then
- result = [buf,*mat.to_a[1..-1]]
- break
- end
- end
- if block_given? then
- yield result
- else
- return result
- end
- nil
- end
-end
-
diff --git a/src/main/resources/stdlib/ffi.rb b/src/main/resources/stdlib/ffi.rb
deleted file mode 100644
index aa42f40..0000000
--- a/src/main/resources/stdlib/ffi.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'ffi/ffi'
\ No newline at end of file
diff --git a/src/main/resources/stdlib/ffi/autopointer.rb b/src/main/resources/stdlib/ffi/autopointer.rb
deleted file mode 100644
index 513dff5..0000000
--- a/src/main/resources/stdlib/ffi/autopointer.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Copyright (C) 2008-2010 Wayne Meissner
-#
-# Version: EPL 1.0/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Common Public
-# License Version 1.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.eclipse.org/legal/cpl-v10.html
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the EPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the EPL, the GPL or the LGPL.
-
-module FFI
- class AutoPointer < Pointer
- extend DataConverter
-
- def self.native_type
- raise RuntimeError.new("no release method defined for #{self.inspect}") unless self.respond_to?(:release)
- Type::POINTER
- end
- end
-end
diff --git a/src/main/resources/stdlib/ffi/buffer.rb b/src/main/resources/stdlib/ffi/buffer.rb
deleted file mode 100644
index 6e7633b..0000000
--- a/src/main/resources/stdlib/ffi/buffer.rb
+++ /dev/null
@@ -1 +0,0 @@
-# This file intentionally left blank
diff --git a/src/main/resources/stdlib/ffi/enum.rb b/src/main/resources/stdlib/ffi/enum.rb
deleted file mode 100644
index 75ecdd3..0000000
--- a/src/main/resources/stdlib/ffi/enum.rb
+++ /dev/null
@@ -1 +0,0 @@
-# The enum functionality has been migrated to Enum.java
\ No newline at end of file
diff --git a/src/main/resources/stdlib/ffi/errno.rb b/src/main/resources/stdlib/ffi/errno.rb
deleted file mode 100644
index 9255829..0000000
--- a/src/main/resources/stdlib/ffi/errno.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (C) 2008 Wayne Meissner
-#
-# Version: EPL 1.0/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Common Public
-# License Version 1.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.eclipse.org/legal/cpl-v10.html
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the EPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the EPL, the GPL or the LGPL.
-#
-module FFI
- def self.errno
- FFI::LastError.error
- end
- def self.errno=(error)
- FFI::LastError.error = error
- end
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/ffi/ffi.rb b/src/main/resources/stdlib/ffi/ffi.rb
deleted file mode 100644
index c9e3b2b..0000000
--- a/src/main/resources/stdlib/ffi/ffi.rb
+++ /dev/null
@@ -1,145 +0,0 @@
-#
-# Version: EPL 1.0/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Common Public
-# License Version 1.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.eclipse.org/legal/cpl-v10.html
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Copyright (C) 2008 JRuby project
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the EPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the EPL, the GPL or the LGPL.
-#
-# Copyright (c) 2007, 2008 Evan Phoenix
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright notice
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-# * Neither the name of the Evan Phoenix nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-require 'rbconfig'
-
-module FFI
- # Specialised error classes - delcare before loading all the other classes
- class NativeError < LoadError; end
-
- class SignatureError < NativeError; end
-
- class NotFoundError < NativeError
- def initialize(function, *libraries)
- super("Function '#{function}' not found in [#{libraries[0].nil? ? 'current process' : libraries.join(", ")}]")
- end
- end
-end
-
-require 'ffi-internal.so' # Load the JRuby implementation class
-require 'ffi/platform'
-require 'ffi/types'
-require 'ffi/library'
-require 'ffi/pointer'
-require 'ffi/memorypointer'
-require 'ffi/autopointer'
-require 'ffi/struct'
-require 'ffi/union'
-require 'ffi/io'
-require 'ffi/variadic'
-require 'ffi/errno'
-require 'ffi/managedstruct'
-
-module FFI
-
- def self.map_library_name(lib)
- lib = lib.to_s
- # Mangle the library name to reflect the native library naming conventions
- lib = Platform::LIBC if lib == 'c'
- if lib && File.basename(lib) == lib
- lib = Platform::LIBPREFIX + lib unless lib =~ /^#{Platform::LIBPREFIX}/
- r = Platform::IS_LINUX ? "\\.so($|\\.[1234567890]+)" : "\\.#{Platform::LIBSUFFIX}$"
- lib += ".#{Platform::LIBSUFFIX}" unless lib =~ /#{r}/
- end
- lib
- end
-
- def self.create_invoker(lib, name, args, ret_type, options = { :convention => :default })
- # Current artificial limitation based on JRuby::FFI limit
- raise SignatureError, 'FFI functions may take max 32 arguments!' if args.size > 32
-
- # Open the library if needed
- library = if lib.kind_of?(DynamicLibrary)
- lib
- elsif lib.kind_of?(String)
- # Allow FFI.create_invoker to be called with a library name
- DynamicLibrary.open(FFI.map_library_name(lib), DynamicLibrary::RTLD_LAZY)
- elsif lib.nil?
- FFI::Library::DEFAULT
- else
- raise LoadError, "Invalid library '#{lib}'"
- end
- function = library.find_function(name)
- raise NotFoundError.new(name, library.name) unless function
-
- args = args.map {|e| find_type(e) }
- invoker = if args.length > 0 && args[args.length - 1] == FFI::NativeType::VARARGS
- FFI::VariadicInvoker.new(library, function, args, find_type(ret_type), options)
- else
- FFI::Function.new(find_type(ret_type), args, function, options)
- end
- raise NotFoundError.new(name, library.name) unless invoker
-
- return invoker
- end
-
- # Load all the platform dependent types/consts/struct members
- class Config
- CONFIG = Hash.new
- begin
- File.open(File.join(Platform::CONF_DIR, 'platform.conf'), "r") do |f|
- typedef = "rbx.platform.typedef."
- f.each_line { |line|
- if line.index(typedef) == 0
- new_type, orig_type = line.chomp.slice(typedef.length..-1).split(/\s*=\s*/)
- FFI.add_typedef(orig_type.to_sym, new_type.to_sym)
- else
- key, value = line.chomp.split(/\s*=\s*/)
- CONFIG[String.new << key] = String.new << value unless key.nil? or value.nil?
- end
- }
- end
- rescue Errno::ENOENT
- end
- end
-end
diff --git a/src/main/resources/stdlib/ffi/io.rb b/src/main/resources/stdlib/ffi/io.rb
deleted file mode 100644
index be19482..0000000
--- a/src/main/resources/stdlib/ffi/io.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (C) 2008 Wayne Meissner
-#
-# Version: EPL 1.0/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Common Public
-# License Version 1.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.eclipse.org/legal/cpl-v10.html
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the EPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the EPL, the GPL or the LGPL.
-#
-
-module FFI
- module IO
- def self.for_fd(fd, mode = 'r')
- FFI::FileDescriptorIO.new(fd)
- end
-
- #
- # A version of IO#read that reads into a native buffer
- #
- # This will be optimized at some future time to eliminate the double copy
- #
- # def self.native_read(io, buf, len)
-
- end
-end
-
diff --git a/src/main/resources/stdlib/ffi/library.rb b/src/main/resources/stdlib/ffi/library.rb
deleted file mode 100644
index 19c9526..0000000
--- a/src/main/resources/stdlib/ffi/library.rb
+++ /dev/null
@@ -1,499 +0,0 @@
-#
-# Copyright (C) 2008-2010 Wayne Meissner
-# Copyright (C) 2008 Luc Heinrich
-#
-# Version: EPL 1.0/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Common Public
-# License Version 1.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.eclipse.org/legal/cpl-v10.html
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the EPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the EPL, the GPL or the LGPL.
-#
-#
-# This file contains code that was originally under the following license:
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright notice
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-# * Neither the name of the Evan Phoenix nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-module FFI
- CURRENT_PROCESS = USE_THIS_PROCESS_AS_LIBRARY = Object.new
-
- # This module is the base to use native functions.
- #
- # A basic usage may be:
- # require 'ffi'
- #
- # module Hello
- # extend FFI::Library
- # ffi_lib FFI::Library::LIBC
- # attach_function 'puts', [ :string ], :int
- # end
- #
- # Hello.puts("Hello, World")
- #
- #
- module Library
- CURRENT_PROCESS = FFI::CURRENT_PROCESS
- LIBC = FFI::Platform::LIBC
-
- # @param [Array] names names of libraries to load
- # @return [Array]
- # @raise {LoadError} if a library cannot be opened
- # Load native libraries.
- def ffi_lib(*names)
- raise LoadError.new("library names list must not be empty") if names.empty?
-
- lib_flags = defined?(@ffi_lib_flags) ? @ffi_lib_flags : FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL
- ffi_libs = names.map do |name|
- if name == FFI::CURRENT_PROCESS
- FFI::DynamicLibrary.open(nil, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL)
- else
- libnames = (name.is_a?(::Array) ? name : [ name ]).map { |n| [ n, FFI.map_library_name(n) ].uniq }.flatten.compact
- lib = nil
- errors = {}
-
- libnames.each do |libname|
- begin
- lib = FFI::DynamicLibrary.open(libname, lib_flags)
- break if lib
- rescue Exception => ex
- ldscript = false
- if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format)/
- if File.read($1) =~ /(?:GROUP|INPUT) *\( *([^ \)]+)/
- libname = $1
- ldscript = true
- end
- end
-
- if ldscript
- retry
- else
- errors[libname] = ex
- end
- end
- end
-
- if lib.nil?
- raise LoadError.new(errors.values.join('. '))
- end
-
- # return the found lib
- lib
- end
- end
-
- @ffi_libs = ffi_libs
- end
-
- # Set the calling convention for {#attach_function} and {#callback}
- #
- # @see http://en.wikipedia.org/wiki/Stdcall#stdcall
- # @note +:stdcall+ is typically used for attaching Windows API functions
- #
- # @param [Symbol] convention one of +:default+, +:stdcall+
- # @return [Symbol] the new calling convention
- def ffi_convention(convention = nil)
- @ffi_convention ||= :default
- @ffi_convention = convention if convention
- @ffi_convention
- end
-
- # @see #ffi_lib
- # @return [Array] array of currently loaded FFI libraries
- # @raise [LoadError] if no libraries have been loaded (using {#ffi_lib})
- # Get FFI libraries loaded using {#ffi_lib}.
- def ffi_libraries
- raise LoadError.new("no library specified") if !defined?(@ffi_libs) || @ffi_libs.empty?
- @ffi_libs
- end
-
- # Flags used in {#ffi_lib}.
- #
- # This map allows you to supply symbols to {#ffi_lib_flags} instead of
- # the actual constants.
- FlagsMap = {
- :global => DynamicLibrary::RTLD_GLOBAL,
- :local => DynamicLibrary::RTLD_LOCAL,
- :lazy => DynamicLibrary::RTLD_LAZY,
- :now => DynamicLibrary::RTLD_NOW
- }
-
- # Sets library flags for {#ffi_lib}.
- #
- # @example
- # ffi_lib_flags(:lazy, :local) # => 5
- #
- # @param [Symbol, …] flags (see {FlagsMap})
- # @return [Fixnum] the new value
- def ffi_lib_flags(*flags)
- @ffi_lib_flags = flags.inject(0) { |result, f| result | FlagsMap[f] }
- end
-
-
- ##
- # @overload attach_function(func, args, returns, options = {})
- # @example attach function without an explicit name
- # module Foo
- # extend FFI::Library
- # ffi_lib FFI::Library::LIBC
- # attach_function :malloc, [:size_t], :pointer
- # end
- # # now callable via Foo.malloc
- # @overload attach_function(name, func, args, returns, options = {})
- # @example attach function with an explicit name
- # module Bar
- # extend FFI::Library
- # ffi_lib FFI::Library::LIBC
- # attach_function :c_malloc, :malloc, [:size_t], :pointer
- # end
- # # now callable via Bar.c_malloc
- #
- # Attach C function +func+ to this module.
- #
- #
- # @param [#to_s] name name of ruby method to attach as
- # @param [#to_s] func name of C function to attach
- # @param [Array] args an array of types
- # @param [Symbol] returns type of return value
- # @option options [Boolean] :blocking (@blocking) set to true if the C function is a blocking call
- # @option options [Symbol] :convention (:default) calling convention (see {#ffi_convention})
- # @option options [FFI::Enums] :enums
- # @option options [Hash] :type_map
- #
- # @return [FFI::VariadicInvoker]
- #
- # @raise [FFI::NotFoundError] if +func+ cannot be found in the attached libraries (see {#ffi_lib})
- def attach_function(name, func, args, returns = nil, options = nil)
- mname, a2, a3, a4, a5 = name, func, args, returns, options
- cname, arg_types, ret_type, opts = (a4 && (a2.is_a?(String) || a2.is_a?(Symbol))) ? [ a2, a3, a4, a5 ] : [ mname.to_s, a2, a3, a4 ]
-
- # Convert :foo to the native type
- arg_types = arg_types.map { |e| find_type(e) }
- options = {
- :convention => ffi_convention,
- :type_map => defined?(@ffi_typedefs) ? @ffi_typedefs : nil,
- :blocking => defined?(@blocking) && @blocking,
- :enums => defined?(@ffi_enums) ? @ffi_enums : nil,
- }
-
- @blocking = false
- options.merge!(opts) if opts && opts.is_a?(Hash)
-
- # Try to locate the function in any of the libraries
- invokers = []
- ffi_libraries.each do |lib|
- if invokers.empty?
- begin
- function = nil
- function_names(cname, arg_types).find do |fname|
- function = lib.find_function(fname)
- end
- raise LoadError unless function
-
- invokers << if arg_types.length > 0 && arg_types[arg_types.length - 1] == FFI::NativeType::VARARGS
- FFI::VariadicInvoker.new(find_type(ret_type), arg_types, function, options)
- else
- FFI::Function.new(find_type(ret_type), arg_types, function, options)
- end
-
- rescue LoadError
- end
- end
- end
- invoker = invokers.compact.shift
- raise FFI::NotFoundError.new(cname.to_s, ffi_libraries.map { |lib| lib.name }) unless invoker
-
- invoker.attach(self, mname.to_s)
- invoker # Return a version that can be called via #call
- end
-
- # @param [#to_s] name function name
- # @param [Array] arg_types function's argument types
- # @return [Array]
- # This function returns a list of possible names to lookup.
- # @note Function names on windows may be decorated if they are using stdcall. See
- # * http://en.wikipedia.org/wiki/Name_mangling#C_name_decoration_in_Microsoft_Windows
- # * http://msdn.microsoft.com/en-us/library/zxk0tw93%28v=VS.100%29.aspx
- # * http://en.wikibooks.org/wiki/X86_Disassembly/Calling_Conventions#STDCALL
- # Note that decorated names can be overridden via def files. Also note that the
- # windows api, although using, doesn't have decorated names.
- def function_names(name, arg_types)
- result = [name.to_s]
- if ffi_convention == :stdcall
- # Get the size of each parameter
- size = arg_types.inject(0) do |mem, arg|
- mem + arg.size
- end
-
- # Next, the size must be a multiple of 4
- size += (4 - size) % 4
-
- result << "_#{name.to_s}@#{size}" # win32
- result << "#{name.to_s}@#{size}" # win64
- end
- result
- end
-
- # @overload attach_variable(mname, cname, type)
- # @example
- # module Bar
- # extend FFI::Library
- # ffi_lib 'my_lib'
- # attach_variable :c_myvar, :myvar, :long
- # end
- # # now callable via Bar.c_myvar
- # @overload attach_variable(cname, type)
- # @example
- # module Bar
- # extend FFI::Library
- # ffi_lib 'my_lib'
- # attach_variable :myvar, :long
- # end
- # # now callable via Bar.myvar
- # @param [#to_s] mname name of ruby method to attach as
- # @param [#to_s] cname name of C variable to attach
- # @param [DataConverter, Struct, Symbol, Type] type C varaible's type
- # @return [DynamicLibrary::Symbol]
- # @raise {FFI::NotFoundError} if +cname+ cannot be found in libraries
- #
- # Attach C variable +cname+ to this module.
- def attach_variable(mname, a1, a2 = nil)
- cname, type = a2 ? [ a1, a2 ] : [ mname.to_s, a1 ]
- address = nil
- ffi_libraries.each do |lib|
- begin
- address = lib.find_variable(cname.to_s)
- break unless address.nil?
- rescue LoadError
- end
- end
-
- raise FFI::NotFoundError.new(cname, ffi_libraries) if address.nil? || address.null?
- if type.is_a?(Class) && type < FFI::Struct
- # If it is a global struct, just attach directly to the pointer
- s = type.new(address)
- self.module_eval <<-code, __FILE__, __LINE__
- @@ffi_gvar_#{mname} = s
- def self.#{mname}
- @@ffi_gvar_#{mname}
- end
- code
-
- else
- sc = Class.new(FFI::Struct)
- sc.layout :gvar, find_type(type)
- s = sc.new(address)
- #
- # Attach to this module as mname/mname=
- #
- self.module_eval <<-code, __FILE__, __LINE__
- @@ffi_gvar_#{mname} = s
- def self.#{mname}
- @@ffi_gvar_#{mname}[:gvar]
- end
- def self.#{mname}=(value)
- @@ffi_gvar_#{mname}[:gvar] = value
- end
- code
-
- end
-
- address
- end
-
-
- # @overload callback(name, params, ret)
- # @overload callback(params, ret)
- # @param name callback name to add to type map
- # @param [Array] params array of parameters' types
- # @param [DataConverter, Struct, Symbol, Type] ret callback return type
- # @return [FFI::CallbackInfo]
- def callback(*args)
- raise ArgumentError, "wrong number of arguments" if args.length < 2 || args.length > 3
- name, params, ret = if args.length == 3
- args
- else
- [ nil, args[0], args[1] ]
- end
-
- native_params = params.map { |e| find_type(e) }
- raise ArgumentError, "callbacks cannot have variadic parameters" if native_params.include?(FFI::Type::VARARGS)
- options = Hash.new
- options[:convention] = ffi_convention
- options[:enums] = @ffi_enums if defined?(@ffi_enums)
- cb = FFI::CallbackInfo.new(find_type(ret), native_params, options)
-
- # Add to the symbol -> type map (unless there was no name)
- unless name.nil?
- typedef cb, name
- end
-
- cb
- end
-
- # @param [DataConverter, Symbol, Type] old
- # @param add
- # @param [] info
- # @return [FFI::Enum, FFI::Type]
- # Register or get an already registered type definition.
- #
- # To register a new type definition, +old+ should be a {FFI::Type}. +add+
- # is in this case the type definition.
- #
- # If +old+ is a {DataConverter}, a {Type::Mapped} is returned.
- #
- # If +old+ is +:enum+
- # * and +add+ is an +Array+, a call to {#enum} is made with +add+ as single parameter;
- # * in others cases, +info+ is used to create a named enum.
- #
- # If +old+ is a key for type map, #typedef get +old+ type definition.
- def typedef(old, add, info=nil)
- @ffi_typedefs = Hash.new unless defined?(@ffi_typedefs)
-
- @ffi_typedefs[add] = if old.kind_of?(FFI::Type)
- old
-
- elsif @ffi_typedefs.has_key?(old)
- @ffi_typedefs[old]
-
- elsif old.is_a?(DataConverter)
- FFI::Type::Mapped.new(old)
-
- elsif old == :enum
- if add.kind_of?(Array)
- self.enum(add)
- else
- self.enum(info, add)
- end
-
- else
- FFI.find_type(old)
- end
- end
-
- # @overload enum(name, values)
- # Create a named enum.
- # @example
- # enum :foo, [:zero, :one, :two] # named enum
- # @param [Symbol] name name for new enum
- # @param [Array] values values for enum
- # @overload enum(*args)
- # Create an unnamed enum.
- # @example
- # enum :zero, :one, :two # unnamed enum
- # @param args values for enum
- # @overload enum(values)
- # Create an unnamed enum.
- # @example
- # enum [:zero, :one, :two] # unnamed enum, equivalent to above example
- # @param [Array] values values for enum
- # @overload enum(native_type, name, values)
- # Create a named enum and specify the native type.
- # @example
- # enum FFI::Type::UINT64, :foo, [:zero, :one, :two] # named enum
- # @param [FFI::Type] native_type native type for new enum
- # @param [Symbol] name name for new enum
- # @param [Array] values values for enum
- # @overload enum(native_type, *args)
- # Create an unnamed enum and specify the native type.
- # @example
- # enum FFI::Type::UINT64, :zero, :one, :two # unnamed enum
- # @param [FFI::Type] native_type native type for new enum
- # @param args values for enum
- # @overload enum(native_type, values)
- # Create an unnamed enum and specify the native type.
- # @example
- # enum Type::UINT64, [:zero, :one, :two] # unnamed enum, equivalent to above example
- # @param [FFI::Type] native_type native type for new enum
- # @param [Array] values values for enum
- # @return [FFI::Enum]
- # Create a new {FFI::Enum}.
- def enum(*args)
- native_type = args.first.kind_of?(FFI::Type) ? args.shift : nil
- name, values = if args[0].kind_of?(Symbol) && args[1].kind_of?(Array)
- [ args[0], args[1] ]
- elsif args[0].kind_of?(Array)
- [ nil, args[0] ]
- else
- [ nil, args ]
- end
- @ffi_enums = FFI::Enums.new unless defined?(@ffi_enums)
- @ffi_enums << (e = native_type ? FFI::Enum.new(native_type, values, name) : FFI::Enum.new(values, name))
-
- # If called as enum :foo, [ :zero, :one, :two ], add a typedef alias
- typedef(e, name) if name
- e
- end
-
- # @param name
- # @return [FFI::Enum]
- # Find an enum by name.
- def enum_type(name)
- @ffi_enums && @ffi_enums.find(name)
- end
-
- # @param symbol
- # @return [FFI::Enum]
- # Find an enum by a symbol it contains.
- def enum_value(symbol)
- @ffi_enums.__map_symbol(symbol)
- end
-
- # @param [DataConverter, Type, Struct, Symbol] t type to find
- # @return [Type]
- # Find a type definition.
- def find_type(t)
- if t.kind_of?(FFI::Type)
- t
-
- elsif defined?(@ffi_typedefs) && @ffi_typedefs.has_key?(t)
- @ffi_typedefs[t]
-
- elsif t.is_a?(Class) && t < Struct
- Type::POINTER
-
- elsif t.is_a?(DataConverter)
- # Add a typedef so next time the converter is used, it hits the cache
- typedef Type::Mapped.new(t), t
-
- end || FFI.find_type(t)
- end
- end
-end
diff --git a/src/main/resources/stdlib/ffi/managedstruct.rb b/src/main/resources/stdlib/ffi/managedstruct.rb
deleted file mode 100644
index 7643c87..0000000
--- a/src/main/resources/stdlib/ffi/managedstruct.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-#
-# Copyright (C) 2008 Mike Dalessio
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright notice
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-# * Neither the name of the Evan Phoenix nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-module FFI
- #
- # FFI::ManagedStruct allows custom garbage-collection of your FFI::Structs.
- #
- # The typical use case would be when interacting with a library
- # that has a nontrivial memory management design, such as a linked
- # list or a binary tree.
- #
- # When the Struct instance is garbage collected, FFI::ManagedStruct will
- # invoke the class's release() method during object finalization.
- #
- # Example usage:
- # module MyLibrary
- # ffi_lib "libmylibrary"
- # attach_function :new_dlist, [], :pointer
- # attach_function :destroy_dlist, [:pointer], :void
- # end
- #
- # class DoublyLinkedList < FFI::ManagedStruct
- # @@@
- # struct do |s|
- # s.name 'struct dlist'
- # s.include 'dlist.h'
- # s.field :head, :pointer
- # s.field :tail, :pointer
- # end
- # @@@
- #
- # def self.release ptr
- # MyLibrary.destroy_dlist(ptr)
- # end
- # end
- #
- # begin
- # ptr = DoublyLinkedList.new(MyLibrary.new_dlist)
- # # do something with the list
- # end
- # # struct is out of scope, and will be GC'd using DoublyLinkedList#release
- #
- #
- class ManagedStruct < FFI::Struct
-
- # call-seq:
- # ManagedStruct.new(pointer)
- # ManagedStruct.new
- #
- # When passed a pointer, create a new ManagedStruct which will invoke the class method release() on
- def initialize(pointer=nil)
- raise NoMethodError, "release() not implemented for class #{self.class}" unless self.class.respond_to? :release
- raise ArgumentError, "Must supply a pointer to memory for the Struct" unless pointer
- super FFI::AutoPointer.new(pointer, self.class.method(:release))
- end
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/memorypointer.rb b/src/main/resources/stdlib/ffi/memorypointer.rb
deleted file mode 100644
index 32c97a5..0000000
--- a/src/main/resources/stdlib/ffi/memorypointer.rb
+++ /dev/null
@@ -1 +0,0 @@
-# Now implemented in java
diff --git a/src/main/resources/stdlib/ffi/platform.rb b/src/main/resources/stdlib/ffi/platform.rb
deleted file mode 100644
index 5137ccd..0000000
--- a/src/main/resources/stdlib/ffi/platform.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'ffi-internal.so'
-
-module FFI
- module Platform
- #
- # Most of the constants are now defined in org.jruby.ext.ffi.Platform.java
- #
- FFI_DIR = File.dirname(__FILE__)
- CONF_DIR = File.join(FFI_DIR, "platform", NAME)
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/arm-linux/types.conf b/src/main/resources/stdlib/ffi/platform/arm-linux/types.conf
deleted file mode 100644
index ad4ced0..0000000
--- a/src/main/resources/stdlib/ffi/platform/arm-linux/types.conf
+++ /dev/null
@@ -1,102 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__quad_t = long_long
-rbx.platform.typedef.__u_quad_t = ulong_long
-rbx.platform.typedef.__dev_t = ulong_long
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long_long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong_long
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong_long
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong_long
-rbx.platform.typedef.__ssize_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.*__qaddr_t = long_long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.dev_t = ulong_long
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/errno.rb.ffi b/src/main/resources/stdlib/ffi/platform/errno.rb.ffi
deleted file mode 100644
index a97e45c..0000000
--- a/src/main/resources/stdlib/ffi/platform/errno.rb.ffi
+++ /dev/null
@@ -1,71 +0,0 @@
-module Platform; end
-module Platform::Errno
- @@@
- constants do |c|
- c.include 'errno.h'
- %w[
- EPERM
- ENOENT
- ESRCH
- EINTR
- EIO
- ENXIO
- E2BIG
- ENOEXEC
- EBADF
- ECHILD
- EDEADLK
- ENOMEM
- EACCES
- EFAULT
- EBUSY
- EEXIST
- EXDEV
- ENODEV
- ENOTDIR
- EISDIR
- EINVAL
- ENFILE
- EMFILE
- ENOTTY
- ETXTBSY
- EFBIG
- ENOSPC
- ESPIPE
- EROFS
- EMLINK
- EPIPE
- EAGAIN
- EWOULDBLOCK
- EINPROGRESS
- EALREADY
- ENOTSOCK
- EDESTADDRREQ
- EMSGSIZE
- EPROTOTYPE
- ENOPROTOOPT
- EPROTONOSUPPORT
- EOPNOTSUPP
- EAFNOSUPPORT
- EADDRINUSE
- EADDRNOTAVAIL
- ENETDOWN
- ENETUNREACH
- ENETRESET
- ECONNABORTED
- ECONNRESET
- ENOBUFS
- EISCONN
- ENOTCONN
- ETIMEDOUT
- ECONNREFUSED
- ELOOP
- ENAMETOOLONG
- EHOSTDOWN
- EHOSTUNREACH
- ENOTEMPTY
- ].each { |errno| c.const errno }
- end
- @@@
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/etc.rb.ffi b/src/main/resources/stdlib/ffi/platform/etc.rb.ffi
deleted file mode 100644
index ddfde7f..0000000
--- a/src/main/resources/stdlib/ffi/platform/etc.rb.ffi
+++ /dev/null
@@ -1,31 +0,0 @@
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- @@@
- struct do |s|
- s.include "sys/types.h"
- s.include "pwd.h"
-
- s.name "struct passwd"
- s.field :pw_name, :string
- s.field :pw_passwd, :string
- s.field :pw_uid, :uint
- s.field :pw_gid, :uint
- s.field :pw_dir, :string
- s.field :pw_shell, :string
- end
- @@@
- end
- class Group < FFI::Struct
- @@@
- struct do |s|
- s.include "sys/types.h"
- s.include "grp.h"
-
- s.name "struct group"
- s.field :gr_name, :string
- s.field :gr_gid, :uint
- end
- @@@
- end
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/ffi/platform/fcntl.rb.ffi b/src/main/resources/stdlib/ffi/platform/fcntl.rb.ffi
deleted file mode 100644
index 2e67a7c..0000000
--- a/src/main/resources/stdlib/ffi/platform/fcntl.rb.ffi
+++ /dev/null
@@ -1,32 +0,0 @@
-module Fcntl
- @@@
- constants do |c|
- c.include 'fcntl.h'
-
- c.const 'F_DUPFD'
- c.const 'F_GETFD'
- c.const 'F_GETLK'
- c.const 'F_SETFD'
- c.const 'F_GETFL'
- c.const 'F_SETFL'
- c.const 'F_SETLK'
- c.const 'F_SETLKW'
- c.const 'FD_CLOEXEC'
- c.const 'F_RDLCK'
- c.const 'F_UNLCK'
- c.const 'F_WRLCK'
- c.const 'O_CREAT'
- c.const 'O_EXCL'
- c.const 'O_NOCTTY'
- c.const 'O_TRUNC'
- c.const 'O_APPEND'
- c.const 'O_NONBLOCK'
- c.const 'O_NDELAY'
- c.const 'O_RDONLY'
- c.const 'O_RDWR'
- c.const 'O_WRONLY'
- c.const 'O_ACCMODE'
- end
- @@@
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/errno.rb b/src/main/resources/stdlib/ffi/platform/i386-darwin/errno.rb
deleted file mode 100644
index 12f09e0..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 48
- EADDRNOTAVAIL = 49
- EAFNOSUPPORT = 47
- EAGAIN = 35
- EALREADY = 37
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 53
- ECONNREFUSED = 61
- ECONNRESET = 54
- EDEADLK = 11
- EDESTADDRREQ = 39
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 64
- EHOSTUNREACH = 65
- EINPROGRESS = 36
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 56
- EISDIR = 21
- ELOOP = 62
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 40
- ENAMETOOLONG = 63
- ENETDOWN = 50
- ENETRESET = 52
- ENETUNREACH = 51
- ENFILE = 23
- ENOBUFS = 55
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 42
- ENOSPC = 28
- ENOTCONN = 57
- ENOTDIR = 20
- ENOTEMPTY = 66
- ENOTSOCK = 38
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 102
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 43
- EPROTOTYPE = 41
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 60
- ETXTBSY = 26
- EWOULDBLOCK = 35
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/etc.rb b/src/main/resources/stdlib/ffi/platform/i386-darwin/etc.rb
deleted file mode 100644
index 12fb4b7..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 40
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 4,
- :pw_uid, :uint, 8,
- :pw_gid, :uint, 12,
- :pw_dir, :string, 28,
- :pw_shell, :string, 32
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 16
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 8
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/fcntl.rb b/src/main/resources/stdlib/ffi/platform/i386-darwin/fcntl.rb
deleted file mode 100644
index a5333f6..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 7
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 8
- F_SETLKW = 9
- F_UNLCK = 2
- F_WRLCK = 3
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 512
- O_EXCL = 2048
- O_NDELAY = 4
- O_NOCTTY = 131072
- O_NONBLOCK = 4
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 1024
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/platform.conf b/src/main/resources/stdlib/ffi/platform/i386-darwin/platform.conf
deleted file mode 100644
index 8c6dade..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/platform.conf
+++ /dev/null
@@ -1,539 +0,0 @@
-rbx.platform.addrinfo.sizeof = 32
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 24
-rbx.platform.addrinfo.ai_addr.size = 4
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 20
-rbx.platform.addrinfo.ai_canonname.size = 4
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 28
-rbx.platform.addrinfo.ai_next.size = 4
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 1048
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 16
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 21
-rbx.platform.dirent.d_name.size = 1024
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 1
-rbx.platform.sockaddr_in.sin_family.size = 1
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 106
-rbx.platform.sockaddr_un.sun_family.offset = 1
-rbx.platform.sockaddr_un.sun_family.size = 1
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 104
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 108
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 8
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 4
-rbx.platform.stat.st_mode.size = 2
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 6
-rbx.platform.stat.st_nlink.size = 2
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 16
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 20
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 24
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 60
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 76
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 68
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 28
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 36
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 44
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 512
-rbx.platform.file.O_EXCL = 2048
-rbx.platform.file.O_NOCTTY = 131072
-rbx.platform.file.O_TRUNC = 1024
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 4
-rbx.platform.file.O_SYNC = 128
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT = 57344
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT = 21
-rbx.platform.socket.AF_COIP = 20
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 = 28
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 30
-rbx.platform.socket.AF_IPX = 23
-rbx.platform.socket.AF_ISDN = 28
-rbx.platform.socket.AF_ISO = 7
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 18
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 37
-rbx.platform.socket.AF_NATM = 31
-rbx.platform.socket.AF_NDRV = 27
-rbx.platform.socket.AF_NETBIOS = 33
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 7
-rbx.platform.socket.AF_PPP = 34
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 17
-rbx.platform.socket.AF_SIP = 24
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM = 32
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 1024
-rbx.platform.socket.AI_ALL = 256
-rbx.platform.socket.AI_CANONNAME = 2
-rbx.platform.socket.AI_DEFAULT = 1536
-rbx.platform.socket.AI_MASK = 7
-rbx.platform.socket.AI_NUMERICHOST = 4
-rbx.platform.socket.AI_PASSIVE = 1
-rbx.platform.socket.AI_V4MAPPED = 2048
-rbx.platform.socket.AI_V4MAPPED_CFG = 512
-rbx.platform.socket.EAI_ADDRFAMILY = 1
-rbx.platform.socket.EAI_AGAIN = 2
-rbx.platform.socket.EAI_BADFLAGS = 3
-rbx.platform.socket.EAI_BADHINTS = 12
-rbx.platform.socket.EAI_FAIL = 4
-rbx.platform.socket.EAI_FAMILY = 5
-rbx.platform.socket.EAI_MAX = 14
-rbx.platform.socket.EAI_MEMORY = 6
-rbx.platform.socket.EAI_NODATA = 7
-rbx.platform.socket.EAI_NONAME = 8
-rbx.platform.socket.EAI_PROTOCOL = 13
-rbx.platform.socket.EAI_SERVICE = 9
-rbx.platform.socket.EAI_SOCKTYPE = 10
-rbx.platform.socket.EAI_SYSTEM = 11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE = -1
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 5000
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO = 63
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND = 77
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP = 29
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP = 36
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 12
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 13
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS = 20
-rbx.platform.socket.IP_MULTICAST_IF = 9
-rbx.platform.socket.IP_MULTICAST_LOOP = 11
-rbx.platform.socket.IP_MULTICAST_TTL = 10
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 32
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 128
-rbx.platform.socket.MSG_EOF = 256
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH = 1024
-rbx.platform.socket.MSG_HAVEMORE = 8192
-rbx.platform.socket.MSG_HOLD = 2048
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE = 16384
-rbx.platform.socket.MSG_SEND = 4096
-rbx.platform.socket.MSG_TRUNC = 16
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 4
-rbx.platform.socket.NI_NOFQDN = 1
-rbx.platform.socket.NI_NUMERICHOST = 2
-rbx.platform.socket.NI_NUMERICSERV = 8
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT = 21
-rbx.platform.socket.PF_COIP = 20
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 30
-rbx.platform.socket.PF_IPX = 23
-rbx.platform.socket.PF_ISDN = 28
-rbx.platform.socket.PF_ISO = 7
-rbx.platform.socket.PF_KEY = 29
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 18
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 37
-rbx.platform.socket.PF_NATM = 31
-rbx.platform.socket.PF_NDRV = 27
-rbx.platform.socket.PF_NETBIOS = 33
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 7
-rbx.platform.socket.PF_PIP = 25
-rbx.platform.socket.PF_PPP = 34
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 17
-rbx.platform.socket.PF_RTIP = 22
-rbx.platform.socket.PF_SIP = 24
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM = 32
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP = 19
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC = 8192
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE = 4129
-rbx.platform.socket.SO_NOSIGPIPE = 4130
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD = 4128
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT = 512
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP = 1024
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE = 16384
-rbx.platform.socket.SO_WANTOOBFLAG = 32768
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS = 5
-rbx.platform.process.RLIMIT_NPROC = 7
-rbx.platform.process.RLIMIT_NOFILE = 8
-rbx.platform.process.RLIMIT_MEMLOCK = 6
-rbx.platform.process.RLIMIT_AS = 5
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_MAX = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_CUR = 9223372036854775807
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 16
-rbx.platform.signal.SIGSTOP = 17
-rbx.platform.signal.SIGTSTP = 18
-rbx.platform.signal.SIGCONT = 19
-rbx.platform.signal.SIGCHLD = 20
-rbx.platform.signal.SIGCLD =
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 23
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 26
-rbx.platform.signal.SIGPROF = 27
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 30
-rbx.platform.signal.SIGUSR2 = 31
-rbx.platform.signal.SIGLOST =
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR =
-rbx.platform.signal.SIGPOLL =
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO = 29
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__darwin_intptr_t = long
-rbx.platform.typedef.__darwin_natural_t = uint
-rbx.platform.typedef.__darwin_ct_rune_t = int
-rbx.platform.typedef.__darwin_ptrdiff_t = int
-rbx.platform.typedef.__darwin_size_t = ulong
-rbx.platform.typedef.__darwin_wchar_t = int
-rbx.platform.typedef.__darwin_rune_t = int
-rbx.platform.typedef.__darwin_wint_t = int
-rbx.platform.typedef.__darwin_clock_t = ulong
-rbx.platform.typedef.__darwin_socklen_t = uint
-rbx.platform.typedef.__darwin_ssize_t = long
-rbx.platform.typedef.__darwin_time_t = long
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.user_addr_t = ulong_long
-rbx.platform.typedef.user_size_t = ulong_long
-rbx.platform.typedef.user_ssize_t = long_long
-rbx.platform.typedef.user_long_t = long_long
-rbx.platform.typedef.user_ulong_t = ulong_long
-rbx.platform.typedef.user_time_t = long_long
-rbx.platform.typedef.syscall_arg_t = ulong_long
-rbx.platform.typedef.__darwin_blkcnt_t = long_long
-rbx.platform.typedef.__darwin_blksize_t = int
-rbx.platform.typedef.__darwin_dev_t = int
-rbx.platform.typedef.__darwin_fsblkcnt_t = uint
-rbx.platform.typedef.__darwin_fsfilcnt_t = uint
-rbx.platform.typedef.__darwin_gid_t = uint
-rbx.platform.typedef.__darwin_id_t = uint
-rbx.platform.typedef.__darwin_ino64_t = ulong_long
-rbx.platform.typedef.__darwin_ino_t = ulong_long
-rbx.platform.typedef.__darwin_mach_port_name_t = uint
-rbx.platform.typedef.__darwin_mach_port_t = uint
-rbx.platform.typedef.__darwin_mode_t = ushort
-rbx.platform.typedef.__darwin_off_t = long_long
-rbx.platform.typedef.__darwin_pid_t = int
-rbx.platform.typedef.__darwin_pthread_key_t = ulong
-rbx.platform.typedef.__darwin_sigset_t = uint
-rbx.platform.typedef.__darwin_suseconds_t = int
-rbx.platform.typedef.__darwin_uid_t = uint
-rbx.platform.typedef.__darwin_useconds_t = uint
-rbx.platform.typedef.__darwin_uuid_t[16] = uchar
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ushort
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.fd_mask = int
-rbx.platform.typedef.pthread_key_t = ulong
-rbx.platform.typedef.fsblkcnt_t = uint
-rbx.platform.typedef.fsfilcnt_t = uint
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.rlim_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/socket.rb b/src/main/resources/stdlib/ffi/platform/i386-darwin/socket.rb
deleted file mode 100644
index dd121e7..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- AF_CNT = 21
- AF_COIP = 20
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- AF_E164 = 28
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 30
- AF_IPX = 23
- AF_ISDN = 28
- AF_ISO = 7
- AF_LAT = 14
- AF_LINK = 18
- AF_LOCAL = 1
- AF_MAX = 38
- AF_NATM = 31
- AF_NDRV = 27
- AF_NETBIOS = 33
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 7
- AF_PPP = 34
- AF_PUP = 4
- AF_ROUTE = 17
- AF_SIP = 24
- AF_SNA = 11
- AF_SYSTEM = 32
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- NI_FQDN_FLAG_VALIDTTL = 256
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 4
- NI_NODEADDR_FLAG_ALL = 512
- NI_NODEADDR_FLAG_ANYCAST = 16384
- NI_NODEADDR_FLAG_COMPAT = 1024
- NI_NODEADDR_FLAG_GLOBAL = 8192
- NI_NODEADDR_FLAG_LINKLOCAL = 2048
- NI_NODEADDR_FLAG_SITELOCAL = 4096
- NI_NODEADDR_FLAG_TRUNCATE = 256
- NI_NOFQDN = 1
- NI_NUMERICHOST = 2
- NI_NUMERICSERV = 8
- NI_QTYPE_DNSNAME = 2
- NI_QTYPE_FQDN = 2
- NI_QTYPE_IPV4ADDR = 4
- NI_QTYPE_NODEADDR = 3
- NI_QTYPE_NOOP = 0
- NI_QTYPE_SUPTYPES = 1
- NI_SUPTYPE_FLAG_COMPRESS = 256
- NI_WITHSCOPEID = 32
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- PF_CNT = 21
- PF_COIP = 20
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 30
- PF_IPX = 23
- PF_ISDN = 28
- PF_ISO = 7
- PF_KEY = 29
- PF_LAT = 14
- PF_LINK = 18
- PF_LOCAL = 1
- PF_MAX = 38
- PF_NATM = 31
- PF_NDRV = 27
- PF_NETBIOS = 33
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 7
- PF_PIP = 25
- PF_PPP = 34
- PF_PUP = 4
- PF_ROUTE = 17
- PF_RTIP = 22
- PF_SIP = 24
- PF_SNA = 11
- PF_SYSTEM = 32
- PF_UNIX = 1
- PF_UNSPEC = 0
- PF_XTP = 19
- SOCK_DGRAM = 2
- SOCK_MAXADDRLEN = 255
- SOCK_RAW = 3
- SOCK_RDM = 4
- SOCK_SEQPACKET = 5
- SOCK_STREAM = 1
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- SO_DONTTRUNC = 8192
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- SO_LABEL = 4112
- SO_LINGER = 128
- SO_NKE = 4129
- SO_NOADDRERR = 4131
- SO_NOSIGPIPE = 4130
- # SO_NO_CHECK not available
- SO_NREAD = 4128
- SO_NWRITE = 4132
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- # SO_PEERCRED not available
- SO_PEERLABEL = 4113
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- SO_REUSEPORT = 512
- SO_REUSESHAREUID = 4133
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- SO_TIMESTAMP = 1024
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- SO_WANTMORE = 16384
- SO_WANTOOBFLAG = 32768
- pseudo_AF_HDRCMPLT = 35
- pseudo_AF_KEY = 29
- pseudo_AF_PIP = 25
- pseudo_AF_RTIP = 22
- pseudo_AF_XTP = 19
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/stat.rb b/src/main/resources/stdlib/ffi/platform/i386-darwin/stat.rb
deleted file mode 100644
index 8f3f95d..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 108
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 8,
- :st_nlink, :nlink_t, 6,
- :st_mode, :mode_t, 4,
- :st_uid, :uid_t, 16,
- :st_gid, :gid_t, 20,
- :st_size, :off_t, 60,
- :st_blocks, :blkcnt_t, 68,
- :st_atime, :time_t, 28,
- :st_mtime, :time_t, 36,
- :st_ctime, :time_t, 44
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/sysconf.rb b/src/main/resources/stdlib/ffi/platform/i386-darwin/sysconf.rb
deleted file mode 100644
index 8d80175..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 20
- SC_2_C_BIND = 18
- SC_2_C_DEV = 19
- SC_2_FORT_DEV = 21
- SC_2_FORT_RUN = 22
- SC_2_LOCALEDEF = 23
- SC_2_PBS = 59
- SC_2_PBS_ACCOUNTING = 60
- SC_2_PBS_CHECKPOINT = 61
- SC_2_PBS_LOCATE = 62
- SC_2_PBS_MESSAGE = 63
- SC_2_PBS_TRACK = 64
- SC_2_SW_DEV = 24
- SC_2_UPE = 25
- SC_2_VERSION = 17
- SC_ADVISORY_INFO = 65
- SC_AIO_LISTIO_MAX = 42
- SC_AIO_MAX = 43
- SC_AIO_PRIO_DELTA_MAX = 44
- SC_ARG_MAX = 1
- SC_ASYNCHRONOUS_IO = 28
- SC_ATEXIT_MAX = 107
- SC_BARRIERS = 66
- SC_BC_BASE_MAX = 9
- SC_BC_DIM_MAX = 10
- SC_BC_SCALE_MAX = 11
- SC_BC_STRING_MAX = 12
- SC_CHILD_MAX = 2
- SC_CLK_TCK = 3
- SC_CLOCK_SELECTION = 67
- SC_COLL_WEIGHTS_MAX = 13
- SC_CPUTIME = 68
- SC_DELAYTIMER_MAX = 45
- SC_EXPR_NEST_MAX = 14
- SC_FILE_LOCKING = 69
- SC_FSYNC = 38
- SC_GETGR_R_SIZE_MAX = 70
- SC_GETPW_R_SIZE_MAX = 71
- SC_HOST_NAME_MAX = 72
- SC_IOV_MAX = 56
- SC_IPV6 = 118
- SC_JOB_CONTROL = 6
- SC_LINE_MAX = 15
- SC_LOGIN_NAME_MAX = 73
- SC_MAPPED_FILES = 47
- SC_MEMLOCK = 30
- SC_MEMLOCK_RANGE = 31
- SC_MEMORY_PROTECTION = 32
- SC_MESSAGE_PASSING = 33
- SC_MONOTONIC_CLOCK = 74
- SC_MQ_OPEN_MAX = 46
- SC_MQ_PRIO_MAX = 75
- SC_NGROUPS_MAX = 4
- SC_NPROCESSORS_CONF = 57
- SC_NPROCESSORS_ONLN = 58
- SC_OPEN_MAX = 5
- SC_PAGESIZE = 29
- SC_PAGE_SIZE = 29
- SC_PASS_MAX = 131
- SC_PRIORITIZED_IO = 34
- SC_PRIORITY_SCHEDULING = 35
- SC_RAW_SOCKETS = 119
- SC_READER_WRITER_LOCKS = 76
- SC_REALTIME_SIGNALS = 36
- SC_REGEXP = 77
- SC_RE_DUP_MAX = 16
- SC_RTSIG_MAX = 48
- SC_SAVED_IDS = 7
- SC_SEMAPHORES = 37
- SC_SEM_NSEMS_MAX = 49
- SC_SEM_VALUE_MAX = 50
- SC_SHARED_MEMORY_OBJECTS = 39
- SC_SHELL = 78
- SC_SIGQUEUE_MAX = 51
- SC_SPAWN = 79
- SC_SPIN_LOCKS = 80
- SC_SPORADIC_SERVER = 81
- SC_SS_REPL_MAX = 126
- SC_STREAM_MAX = 26
- SC_SYMLOOP_MAX = 120
- SC_SYNCHRONIZED_IO = 40
- SC_THREADS = 96
- SC_THREAD_ATTR_STACKADDR = 82
- SC_THREAD_ATTR_STACKSIZE = 83
- SC_THREAD_CPUTIME = 84
- SC_THREAD_DESTRUCTOR_ITERATIONS = 85
- SC_THREAD_KEYS_MAX = 86
- SC_THREAD_PRIORITY_SCHEDULING = 89
- SC_THREAD_PRIO_INHERIT = 87
- SC_THREAD_PRIO_PROTECT = 88
- SC_THREAD_PROCESS_SHARED = 90
- SC_THREAD_SAFE_FUNCTIONS = 91
- SC_THREAD_SPORADIC_SERVER = 92
- SC_THREAD_STACK_MIN = 93
- SC_THREAD_THREADS_MAX = 94
- SC_TIMEOUTS = 95
- SC_TIMERS = 41
- SC_TIMER_MAX = 52
- SC_TRACE = 97
- SC_TRACE_EVENT_FILTER = 98
- SC_TRACE_EVENT_NAME_MAX = 127
- SC_TRACE_INHERIT = 99
- SC_TRACE_LOG = 100
- SC_TRACE_NAME_MAX = 128
- SC_TRACE_SYS_MAX = 129
- SC_TRACE_USER_EVENT_MAX = 130
- SC_TTY_NAME_MAX = 101
- SC_TYPED_MEMORY_OBJECTS = 102
- SC_TZNAME_MAX = 27
- SC_V6_ILP32_OFF32 = 103
- SC_V6_ILP32_OFFBIG = 104
- SC_V6_LP64_OFF64 = 105
- SC_V6_LPBIG_OFFBIG = 106
- SC_VERSION = 8
- SC_XBS5_ILP32_OFF32 = 122
- SC_XBS5_ILP32_OFFBIG = 123
- SC_XBS5_LP64_OFF64 = 124
- SC_XBS5_LPBIG_OFFBIG = 125
- SC_XOPEN_CRYPT = 108
- SC_XOPEN_ENH_I18N = 109
- SC_XOPEN_LEGACY = 110
- SC_XOPEN_REALTIME = 111
- SC_XOPEN_REALTIME_THREADS = 112
- SC_XOPEN_SHM = 113
- SC_XOPEN_STREAMS = 114
- SC_XOPEN_UNIX = 115
- SC_XOPEN_VERSION = 116
- SC_XOPEN_XCU_VERSION = 121
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/syslog.rb b/src/main/resources/stdlib/ffi/platform/i386-darwin/syslog.rb
deleted file mode 100644
index d502940..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- LOG_FTP = 88
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NDELAY = 8
- LOG_NEWS = 56
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- LOG_PERROR = 32
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/types.conf b/src/main/resources/stdlib/ffi/platform/i386-darwin/types.conf
deleted file mode 100644
index 6b9313e..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/types.conf
+++ /dev/null
@@ -1,100 +0,0 @@
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__darwin_intptr_t = long
-rbx.platform.typedef.__darwin_natural_t = uint
-rbx.platform.typedef.__darwin_ct_rune_t = int
-rbx.platform.typedef.__darwin_ptrdiff_t = int
-rbx.platform.typedef.__darwin_size_t = ulong
-rbx.platform.typedef.__darwin_wchar_t = int
-rbx.platform.typedef.__darwin_rune_t = int
-rbx.platform.typedef.__darwin_wint_t = int
-rbx.platform.typedef.__darwin_clock_t = ulong
-rbx.platform.typedef.__darwin_socklen_t = uint
-rbx.platform.typedef.__darwin_ssize_t = long
-rbx.platform.typedef.__darwin_time_t = long
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.user_addr_t = ulong_long
-rbx.platform.typedef.user_size_t = ulong_long
-rbx.platform.typedef.user_ssize_t = long_long
-rbx.platform.typedef.user_long_t = long_long
-rbx.platform.typedef.user_ulong_t = ulong_long
-rbx.platform.typedef.user_time_t = long_long
-rbx.platform.typedef.syscall_arg_t = ulong_long
-rbx.platform.typedef.__darwin_blkcnt_t = long_long
-rbx.platform.typedef.__darwin_blksize_t = int
-rbx.platform.typedef.__darwin_dev_t = int
-rbx.platform.typedef.__darwin_fsblkcnt_t = uint
-rbx.platform.typedef.__darwin_fsfilcnt_t = uint
-rbx.platform.typedef.__darwin_gid_t = uint
-rbx.platform.typedef.__darwin_id_t = uint
-rbx.platform.typedef.__darwin_ino64_t = ulong_long
-rbx.platform.typedef.__darwin_ino_t = ulong_long
-rbx.platform.typedef.__darwin_mach_port_name_t = uint
-rbx.platform.typedef.__darwin_mach_port_t = uint
-rbx.platform.typedef.__darwin_mode_t = ushort
-rbx.platform.typedef.__darwin_off_t = long_long
-rbx.platform.typedef.__darwin_pid_t = int
-rbx.platform.typedef.__darwin_pthread_key_t = ulong
-rbx.platform.typedef.__darwin_sigset_t = uint
-rbx.platform.typedef.__darwin_suseconds_t = int
-rbx.platform.typedef.__darwin_uid_t = uint
-rbx.platform.typedef.__darwin_useconds_t = uint
-rbx.platform.typedef.__darwin_uuid_t[16] = uchar
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ushort
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.fd_mask = int
-rbx.platform.typedef.pthread_key_t = ulong
-rbx.platform.typedef.fsblkcnt_t = uint
-rbx.platform.typedef.fsfilcnt_t = uint
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.rlim_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/i386-darwin/zlib.rb b/src/main/resources/stdlib/ffi/platform/i386-darwin/zlib.rb
deleted file mode 100644
index a08f385..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-darwin/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 56
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 4,
- :total_in, :ulong, 8,
- :next_out, :pointer, 12,
- :avail_out, :uint, 16,
- :total_out, :ulong, 20,
- :msg, :string, 24,
- :state, :pointer, 28,
- :zalloc, :pointer, 32,
- :zfree, :pointer, 36,
- :opaque, :pointer, 40,
- :data_type, :int, 44,
- :adler, :ulong, 48,
- :reserved, :ulong, 52
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-freebsd/types.conf b/src/main/resources/stdlib/ffi/platform/i386-freebsd/types.conf
deleted file mode 100644
index 3e7b20d..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-freebsd/types.conf
+++ /dev/null
@@ -1,152 +0,0 @@
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__clock_t = ulong
-rbx.platform.typedef.__cpumask_t = uint
-rbx.platform.typedef.__critical_t = int
-rbx.platform.typedef.__intfptr_t = int
-rbx.platform.typedef.__intmax_t = long_long
-rbx.platform.typedef.__intptr_t = int
-rbx.platform.typedef.__int_fast8_t = int
-rbx.platform.typedef.__int_fast16_t = int
-rbx.platform.typedef.__int_fast32_t = int
-rbx.platform.typedef.__int_fast64_t = long_long
-rbx.platform.typedef.__int_least8_t = char
-rbx.platform.typedef.__int_least16_t = short
-rbx.platform.typedef.__int_least32_t = int
-rbx.platform.typedef.__int_least64_t = long_long
-rbx.platform.typedef.__ptrdiff_t = int
-rbx.platform.typedef.__register_t = int
-rbx.platform.typedef.__segsz_t = int
-rbx.platform.typedef.__size_t = uint
-rbx.platform.typedef.__ssize_t = int
-rbx.platform.typedef.__time_t = int
-rbx.platform.typedef.__uintfptr_t = uint
-rbx.platform.typedef.__uintmax_t = ulong_long
-rbx.platform.typedef.__uintptr_t = uint
-rbx.platform.typedef.__uint_fast8_t = uint
-rbx.platform.typedef.__uint_fast16_t = uint
-rbx.platform.typedef.__uint_fast32_t = uint
-rbx.platform.typedef.__uint_fast64_t = ulong_long
-rbx.platform.typedef.__uint_least8_t = uchar
-rbx.platform.typedef.__uint_least16_t = ushort
-rbx.platform.typedef.__uint_least32_t = uint
-rbx.platform.typedef.__uint_least64_t = ulong_long
-rbx.platform.typedef.__u_register_t = uint
-rbx.platform.typedef.__vm_offset_t = uint
-rbx.platform.typedef.__vm_ooffset_t = long_long
-rbx.platform.typedef.__vm_paddr_t = uint
-rbx.platform.typedef.__vm_pindex_t = ulong_long
-rbx.platform.typedef.__vm_size_t = uint
-rbx.platform.typedef.__blksize_t = uint
-rbx.platform.typedef.__blkcnt_t = long_long
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__fflags_t = uint
-rbx.platform.typedef.__fsblkcnt_t = ulong_long
-rbx.platform.typedef.__fsfilcnt_t = ulong_long
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__id_t = long_long
-rbx.platform.typedef.__ino_t = uint
-rbx.platform.typedef.__key_t = long
-rbx.platform.typedef.__lwpid_t = int
-rbx.platform.typedef.__mode_t = ushort
-rbx.platform.typedef.__accmode_t = int
-rbx.platform.typedef.__nl_item = int
-rbx.platform.typedef.__nlink_t = ushort
-rbx.platform.typedef.__off_t = long_long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__rlim_t = long_long
-rbx.platform.typedef.__sa_family_t = uchar
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__cpuwhich_t = int
-rbx.platform.typedef.__cpulevel_t = int
-rbx.platform.typedef.__cpusetid_t = int
-rbx.platform.typedef.__ct_rune_t = int
-rbx.platform.typedef.__rune_t = int
-rbx.platform.typedef.__wchar_t = int
-rbx.platform.typedef.__wint_t = int
-rbx.platform.typedef.__wint_t = int
-rbx.platform.typedef.__dev_t = uint
-rbx.platform.typedef.__fixpt_t = uint
-rbx.platform.typedef.pthread_key_t = int
-rbx.platform.typedef.*) = pointer
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intptr_t = int
-rbx.platform.typedef.uintptr_t = uint
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.c_caddr_t = pointer
-rbx.platform.typedef.blksize_t = uint
-rbx.platform.typedef.cpuwhich_t = int
-rbx.platform.typedef.cpulevel_t = int
-rbx.platform.typedef.cpusetid_t = int
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.cpumask_t = uint
-rbx.platform.typedef.critical_t = int
-rbx.platform.typedef.daddr_t = long_long
-rbx.platform.typedef.dev_t = uint
-rbx.platform.typedef.fflags_t = uint
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.id_t = long_long
-rbx.platform.typedef.ino_t = uint
-rbx.platform.typedef.key_t = long
-rbx.platform.typedef.lwpid_t = int
-rbx.platform.typedef.mode_t = ushort
-rbx.platform.typedef.accmode_t = int
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.rlim_t = long_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.time_t = int
-rbx.platform.typedef.u_register_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.vm_offset_t = uint
-rbx.platform.typedef.vm_ooffset_t = long_long
-rbx.platform.typedef.vm_paddr_t = uint
-rbx.platform.typedef.vm_pindex_t = ulong_long
-rbx.platform.typedef.vm_size_t = uint
-rbx.platform.typedef.__fd_mask = ulong
-rbx.platform.typedef.fd_mask = ulong
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/errno.rb b/src/main/resources/stdlib/ffi/platform/i386-linux/errno.rb
deleted file mode 100644
index cb2014c..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 98
- EADDRNOTAVAIL = 99
- EAFNOSUPPORT = 97
- EAGAIN = 11
- EALREADY = 114
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 103
- ECONNREFUSED = 111
- ECONNRESET = 104
- EDEADLK = 35
- EDESTADDRREQ = 89
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 112
- EHOSTUNREACH = 113
- EINPROGRESS = 115
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 106
- EISDIR = 21
- ELOOP = 40
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 90
- ENAMETOOLONG = 36
- ENETDOWN = 100
- ENETRESET = 102
- ENETUNREACH = 101
- ENFILE = 23
- ENOBUFS = 105
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 92
- ENOSPC = 28
- ENOTCONN = 107
- ENOTDIR = 20
- ENOTEMPTY = 39
- ENOTSOCK = 88
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 95
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 93
- EPROTOTYPE = 91
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 110
- ETXTBSY = 26
- EWOULDBLOCK = 11
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/etc.rb b/src/main/resources/stdlib/ffi/platform/i386-linux/etc.rb
deleted file mode 100644
index 87a63ce..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 28
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 4,
- :pw_uid, :uint, 8,
- :pw_gid, :uint, 12,
- :pw_dir, :string, 20,
- :pw_shell, :string, 24
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 16
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 8
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/fcntl.rb b/src/main/resources/stdlib/ffi/platform/i386-linux/fcntl.rb
deleted file mode 100644
index 194bd87..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 12
- F_RDLCK = 0
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 13
- F_SETLKW = 14
- F_UNLCK = 2
- F_WRLCK = 1
- O_ACCMODE = 3
- O_APPEND = 1024
- O_CREAT = 64
- O_EXCL = 128
- O_NDELAY = 2048
- O_NOCTTY = 256
- O_NONBLOCK = 2048
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 512
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/platform.conf b/src/main/resources/stdlib/ffi/platform/i386-linux/platform.conf
deleted file mode 100644
index 5e76b56..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/platform.conf
+++ /dev/null
@@ -1,539 +0,0 @@
-rbx.platform.addrinfo.sizeof = 32
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 20
-rbx.platform.addrinfo.ai_addr.size = 4
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 24
-rbx.platform.addrinfo.ai_canonname.size = 4
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 28
-rbx.platform.addrinfo.ai_next.size = 4
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 276
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 16
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 19
-rbx.platform.dirent.d_name.size = 256
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 0
-rbx.platform.sockaddr_in.sin_family.size = 2
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 110
-rbx.platform.sockaddr_un.sun_family.offset = 0
-rbx.platform.sockaddr_un.sun_family.size = 2
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 108
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 96
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 8
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 88
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 16
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 20
-rbx.platform.stat.st_nlink.size = 4
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 24
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 28
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 32
-rbx.platform.stat.st_rdev.size = 8
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 44
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 52
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 56
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 64
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 72
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 80
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 64
-rbx.platform.file.O_EXCL = 128
-rbx.platform.file.O_NOCTTY = 256
-rbx.platform.file.O_TRUNC = 512
-rbx.platform.file.O_APPEND = 1024
-rbx.platform.file.O_NONBLOCK = 2048
-rbx.platform.file.O_SYNC = 4096
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 5
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 = 3
-rbx.platform.socket.AF_CCITT =
-rbx.platform.socket.AF_CHAOS =
-rbx.platform.socket.AF_CNT =
-rbx.platform.socket.AF_COIP =
-rbx.platform.socket.AF_DATAKIT =
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI =
-rbx.platform.socket.AF_E164 =
-rbx.platform.socket.AF_ECMA =
-rbx.platform.socket.AF_HYLINK =
-rbx.platform.socket.AF_IMPLINK =
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 10
-rbx.platform.socket.AF_IPX = 4
-rbx.platform.socket.AF_ISDN =
-rbx.platform.socket.AF_ISO =
-rbx.platform.socket.AF_LAT =
-rbx.platform.socket.AF_LINK =
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 34
-rbx.platform.socket.AF_NATM =
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS =
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS =
-rbx.platform.socket.AF_OSI =
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP =
-rbx.platform.socket.AF_ROUTE = 16
-rbx.platform.socket.AF_SIP =
-rbx.platform.socket.AF_SNA = 22
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 32
-rbx.platform.socket.AI_ALL = 16
-rbx.platform.socket.AI_CANONNAME = 2
-rbx.platform.socket.AI_DEFAULT =
-rbx.platform.socket.AI_MASK =
-rbx.platform.socket.AI_NUMERICHOST = 4
-rbx.platform.socket.AI_PASSIVE = 1
-rbx.platform.socket.AI_V4MAPPED = 8
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY = -9
-rbx.platform.socket.EAI_AGAIN = -3
-rbx.platform.socket.EAI_BADFLAGS = -1
-rbx.platform.socket.EAI_BADHINTS =
-rbx.platform.socket.EAI_FAIL = -4
-rbx.platform.socket.EAI_FAMILY = -6
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY = -10
-rbx.platform.socket.EAI_NODATA = -5
-rbx.platform.socket.EAI_NONAME = -2
-rbx.platform.socket.EAI_PROTOCOL =
-rbx.platform.socket.EAI_SERVICE = -8
-rbx.platform.socket.EAI_SOCKTYPE = -7
-rbx.platform.socket.EAI_SYSTEM = -11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE = -1
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED =
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON =
-rbx.platform.socket.IPPROTO_GGP =
-rbx.platform.socket.IPPROTO_HELLO =
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX =
-rbx.platform.socket.IPPROTO_ND =
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP = 29
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 35
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 36
-rbx.platform.socket.IP_HDRINCL = 3
-rbx.platform.socket.IP_MAX_MEMBERSHIPS = 20
-rbx.platform.socket.IP_MULTICAST_IF = 32
-rbx.platform.socket.IP_MULTICAST_LOOP = 34
-rbx.platform.socket.IP_MULTICAST_TTL = 33
-rbx.platform.socket.IP_OPTIONS = 4
-rbx.platform.socket.IP_RECVDSTADDR =
-rbx.platform.socket.IP_RECVOPTS = 6
-rbx.platform.socket.IP_RECVRETOPTS = 7
-rbx.platform.socket.IP_RETOPTS = 7
-rbx.platform.socket.IP_TOS = 1
-rbx.platform.socket.IP_TTL = 2
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 8
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 64
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR = 128
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 32
-rbx.platform.socket.MSG_WAITALL = 256
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 8
-rbx.platform.socket.NI_NOFQDN = 4
-rbx.platform.socket.NI_NUMERICHOST = 1
-rbx.platform.socket.NI_NUMERICSERV = 2
-rbx.platform.socket.PF_APPLETALK = 5
-rbx.platform.socket.PF_AX25 = 3
-rbx.platform.socket.PF_CCITT =
-rbx.platform.socket.PF_CHAOS =
-rbx.platform.socket.PF_CNT =
-rbx.platform.socket.PF_COIP =
-rbx.platform.socket.PF_DATAKIT =
-rbx.platform.socket.PF_DLI =
-rbx.platform.socket.PF_ECMA =
-rbx.platform.socket.PF_HYLINK =
-rbx.platform.socket.PF_IMPLINK =
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 10
-rbx.platform.socket.PF_IPX = 4
-rbx.platform.socket.PF_ISDN =
-rbx.platform.socket.PF_ISO =
-rbx.platform.socket.PF_KEY = 15
-rbx.platform.socket.PF_LAT =
-rbx.platform.socket.PF_LINK =
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 34
-rbx.platform.socket.PF_NATM =
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS =
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS =
-rbx.platform.socket.PF_OSI =
-rbx.platform.socket.PF_PIP =
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP =
-rbx.platform.socket.PF_ROUTE = 16
-rbx.platform.socket.PF_RTIP =
-rbx.platform.socket.PF_SIP =
-rbx.platform.socket.PF_SNA = 22
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP =
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET = 10
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP = 0
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 1
-rbx.platform.socket.SOL_TCP = 6
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 30
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER = 26
-rbx.platform.socket.SO_BINDTODEVICE = 25
-rbx.platform.socket.SO_BROADCAST = 6
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER = 27
-rbx.platform.socket.SO_DONTROUTE = 5
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4
-rbx.platform.socket.SO_KEEPALIVE = 9
-rbx.platform.socket.SO_LINGER = 13
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK = 11
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 10
-rbx.platform.socket.SO_PASSCRED = 16
-rbx.platform.socket.SO_PEERCRED = 17
-rbx.platform.socket.SO_PEERNAME = 28
-rbx.platform.socket.SO_PRIORITY = 12
-rbx.platform.socket.SO_RCVBUF = 8
-rbx.platform.socket.SO_RCVLOWAT = 18
-rbx.platform.socket.SO_RCVTIMEO = 20
-rbx.platform.socket.SO_REUSEADDR = 2
-rbx.platform.socket.SO_REUSEPORT =
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION = 22
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK = 24
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT = 23
-rbx.platform.socket.SO_SNDBUF = 7
-rbx.platform.socket.SO_SNDLOWAT = 19
-rbx.platform.socket.SO_SNDTIMEO = 21
-rbx.platform.socket.SO_TIMESTAMP = 29
-rbx.platform.socket.SO_TYPE = 3
-rbx.platform.socket.SO_USELOOPBACK =
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS = 5
-rbx.platform.process.RLIMIT_NPROC = 6
-rbx.platform.process.RLIMIT_NOFILE = 7
-rbx.platform.process.RLIMIT_MEMLOCK = 8
-rbx.platform.process.RLIMIT_AS = 9
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 18446744073709551615
-rbx.platform.process.RLIM_SAVED_MAX = 18446744073709551615
-rbx.platform.process.RLIM_SAVED_CUR = 18446744073709551615
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT =
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 7
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 31
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 23
-rbx.platform.signal.SIGSTOP = 19
-rbx.platform.signal.SIGTSTP = 20
-rbx.platform.signal.SIGCONT = 18
-rbx.platform.signal.SIGCHLD = 17
-rbx.platform.signal.SIGCLD = 17
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 29
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 26
-rbx.platform.signal.SIGPROF = 27
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 10
-rbx.platform.signal.SIGUSR2 = 12
-rbx.platform.signal.SIGLOST =
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR = 30
-rbx.platform.signal.SIGPOLL = 29
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO =
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3.3
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__quad_t = long_long
-rbx.platform.typedef.__u_quad_t = ulong_long
-rbx.platform.typedef.__dev_t = ulong_long
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long_long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong_long
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong_long
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong_long
-rbx.platform.typedef.__ssize_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.*__qaddr_t = long_long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.dev_t = ulong_long
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/socket.rb b/src/main/resources/stdlib/ffi/platform/i386-linux/socket.rb
deleted file mode 100644
index 6470eda..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 5
- # AF_ATM not available
- AF_AX25 = 3
- # AF_CCITT not available
- # AF_CHAOS not available
- # AF_CNT not available
- # AF_COIP not available
- # AF_DATAKIT not available
- AF_DECnet = 12
- # AF_DLI not available
- # AF_E164 not available
- # AF_ECMA not available
- # AF_HYLINK not available
- # AF_IMPLINK not available
- AF_INET = 2
- AF_INET6 = 10
- AF_IPX = 4
- AF_ISDN = 34
- # AF_ISO not available
- # AF_LAT not available
- # AF_LINK not available
- AF_LOCAL = 1
- AF_MAX = 37
- # AF_NATM not available
- # AF_NDRV not available
- # AF_NETBIOS not available
- # AF_NETGRAPH not available
- # AF_NS not available
- # AF_OSI not available
- # AF_PPP not available
- # AF_PUP not available
- AF_ROUTE = 16
- # AF_SIP not available
- AF_SNA = 22
- # AF_SYSTEM not available
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- # NI_FQDN_FLAG_VALIDTTL not available
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 8
- # NI_NODEADDR_FLAG_ALL not available
- # NI_NODEADDR_FLAG_ANYCAST not available
- # NI_NODEADDR_FLAG_COMPAT not available
- # NI_NODEADDR_FLAG_GLOBAL not available
- # NI_NODEADDR_FLAG_LINKLOCAL not available
- # NI_NODEADDR_FLAG_SITELOCAL not available
- # NI_NODEADDR_FLAG_TRUNCATE not available
- NI_NOFQDN = 4
- NI_NUMERICHOST = 1
- NI_NUMERICSERV = 2
- # NI_QTYPE_DNSNAME not available
- # NI_QTYPE_FQDN not available
- # NI_QTYPE_IPV4ADDR not available
- # NI_QTYPE_NODEADDR not available
- # NI_QTYPE_NOOP not available
- # NI_QTYPE_SUPTYPES not available
- # NI_SUPTYPE_FLAG_COMPRESS not available
- # NI_WITHSCOPEID not available
- PF_APPLETALK = 5
- # PF_ATM not available
- # PF_CCITT not available
- # PF_CHAOS not available
- # PF_CNT not available
- # PF_COIP not available
- # PF_DATAKIT not available
- PF_DECnet = 12
- # PF_DLI not available
- # PF_ECMA not available
- # PF_HYLINK not available
- # PF_IMPLINK not available
- PF_INET = 2
- PF_INET6 = 10
- PF_IPX = 4
- PF_ISDN = 34
- # PF_ISO not available
- PF_KEY = 15
- # PF_LAT not available
- # PF_LINK not available
- PF_LOCAL = 1
- PF_MAX = 37
- # PF_NATM not available
- # PF_NDRV not available
- # PF_NETBIOS not available
- # PF_NETGRAPH not available
- # PF_NS not available
- # PF_OSI not available
- # PF_PIP not available
- # PF_PPP not available
- # PF_PUP not available
- PF_ROUTE = 16
- # PF_RTIP not available
- # PF_SIP not available
- PF_SNA = 22
- # PF_SYSTEM not available
- PF_UNIX = 1
- PF_UNSPEC = 0
- # PF_XTP not available
- SOCK_DGRAM = 2
- # SOCK_MAXADDRLEN not available
- SOCK_RAW = 3
- SOCK_RDM = 4
- SOCK_SEQPACKET = 5
- SOCK_STREAM = 1
- SO_ACCEPTCONN = 30
- # SO_ACCEPTFILTER not available
- SO_ATTACH_FILTER = 26
- SO_BINDTODEVICE = 25
- SO_BROADCAST = 6
- SO_DEBUG = 1
- SO_DETACH_FILTER = 27
- SO_DONTROUTE = 5
- # SO_DONTTRUNC not available
- SO_ERROR = 4
- SO_KEEPALIVE = 9
- # SO_LABEL not available
- SO_LINGER = 13
- # SO_NKE not available
- # SO_NOADDRERR not available
- # SO_NOSIGPIPE not available
- SO_NO_CHECK = 11
- # SO_NREAD not available
- # SO_NWRITE not available
- SO_OOBINLINE = 10
- SO_PASSCRED = 16
- SO_PEERCRED = 17
- # SO_PEERLABEL not available
- SO_PEERNAME = 28
- SO_PRIORITY = 12
- SO_RCVBUF = 8
- SO_RCVLOWAT = 18
- SO_RCVTIMEO = 20
- SO_REUSEADDR = 2
- # SO_REUSEPORT not available
- # SO_REUSESHAREUID not available
- SO_SECURITY_AUTHENTICATION = 22
- SO_SECURITY_ENCRYPTION_NETWORK = 24
- SO_SECURITY_ENCRYPTION_TRANSPORT = 23
- SO_SNDBUF = 7
- SO_SNDLOWAT = 19
- SO_SNDTIMEO = 21
- SO_TIMESTAMP = 29
- SO_TYPE = 3
- # SO_USELOOPBACK not available
- # SO_WANTMORE not available
- # SO_WANTOOBFLAG not available
- # pseudo_AF_HDRCMPLT not available
- # pseudo_AF_KEY not available
- # pseudo_AF_PIP not available
- # pseudo_AF_RTIP not available
- # pseudo_AF_XTP not available
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/stat.rb b/src/main/resources/stdlib/ffi/platform/i386-linux/stat.rb
deleted file mode 100644
index 3ab5a00..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 96
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 88,
- :st_nlink, :nlink_t, 20,
- :st_mode, :mode_t, 16,
- :st_uid, :uid_t, 24,
- :st_gid, :gid_t, 28,
- :st_size, :off_t, 44,
- :st_blocks, :blkcnt_t, 56,
- :st_atime, :time_t, 64,
- :st_mtime, :time_t, 72,
- :st_ctime, :time_t, 80
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/sysconf.rb b/src/main/resources/stdlib/ffi/platform/i386-linux/sysconf.rb
deleted file mode 100644
index 783458e..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 95
- SC_2_C_BIND = 47
- SC_2_C_DEV = 48
- SC_2_FORT_DEV = 49
- SC_2_FORT_RUN = 50
- SC_2_LOCALEDEF = 52
- SC_2_PBS = 168
- SC_2_PBS_ACCOUNTING = 169
- SC_2_PBS_CHECKPOINT = 175
- SC_2_PBS_LOCATE = 170
- SC_2_PBS_MESSAGE = 171
- SC_2_PBS_TRACK = 172
- SC_2_SW_DEV = 51
- SC_2_UPE = 97
- SC_2_VERSION = 46
- SC_ADVISORY_INFO = 132
- SC_AIO_LISTIO_MAX = 23
- SC_AIO_MAX = 24
- SC_AIO_PRIO_DELTA_MAX = 25
- SC_ARG_MAX = 0
- SC_ASYNCHRONOUS_IO = 12
- SC_ATEXIT_MAX = 87
- SC_BARRIERS = 133
- SC_BC_BASE_MAX = 36
- SC_BC_DIM_MAX = 37
- SC_BC_SCALE_MAX = 38
- SC_BC_STRING_MAX = 39
- SC_CHILD_MAX = 1
- SC_CLK_TCK = 2
- SC_CLOCK_SELECTION = 137
- SC_COLL_WEIGHTS_MAX = 40
- SC_CPUTIME = 138
- SC_DELAYTIMER_MAX = 26
- SC_EXPR_NEST_MAX = 42
- SC_FILE_LOCKING = 147
- SC_FSYNC = 15
- SC_GETGR_R_SIZE_MAX = 69
- SC_GETPW_R_SIZE_MAX = 70
- SC_HOST_NAME_MAX = 180
- SC_IOV_MAX = 60
- SC_IPV6 = 235
- SC_JOB_CONTROL = 7
- SC_LINE_MAX = 43
- SC_LOGIN_NAME_MAX = 71
- SC_MAPPED_FILES = 16
- SC_MEMLOCK = 17
- SC_MEMLOCK_RANGE = 18
- SC_MEMORY_PROTECTION = 19
- SC_MESSAGE_PASSING = 20
- SC_MONOTONIC_CLOCK = 149
- SC_MQ_OPEN_MAX = 27
- SC_MQ_PRIO_MAX = 28
- SC_NGROUPS_MAX = 3
- SC_NPROCESSORS_CONF = 83
- SC_NPROCESSORS_ONLN = 84
- SC_OPEN_MAX = 4
- SC_PAGESIZE = 30
- SC_PAGE_SIZE = 30
- SC_PASS_MAX = 88
- SC_PRIORITIZED_IO = 13
- SC_PRIORITY_SCHEDULING = 10
- SC_RAW_SOCKETS = 236
- SC_READER_WRITER_LOCKS = 153
- SC_REALTIME_SIGNALS = 9
- SC_REGEXP = 155
- SC_RE_DUP_MAX = 44
- SC_RTSIG_MAX = 31
- SC_SAVED_IDS = 8
- SC_SEMAPHORES = 21
- SC_SEM_NSEMS_MAX = 32
- SC_SEM_VALUE_MAX = 33
- SC_SHARED_MEMORY_OBJECTS = 22
- SC_SHELL = 157
- SC_SIGQUEUE_MAX = 34
- SC_SPAWN = 159
- SC_SPIN_LOCKS = 154
- SC_SPORADIC_SERVER = 160
- SC_SS_REPL_MAX = 241
- SC_STREAM_MAX = 5
- SC_SYMLOOP_MAX = 173
- SC_SYNCHRONIZED_IO = 14
- SC_THREADS = 67
- SC_THREAD_ATTR_STACKADDR = 77
- SC_THREAD_ATTR_STACKSIZE = 78
- SC_THREAD_CPUTIME = 139
- SC_THREAD_DESTRUCTOR_ITERATIONS = 73
- SC_THREAD_KEYS_MAX = 74
- SC_THREAD_PRIORITY_SCHEDULING = 79
- SC_THREAD_PRIO_INHERIT = 80
- SC_THREAD_PRIO_PROTECT = 81
- SC_THREAD_PROCESS_SHARED = 82
- SC_THREAD_SAFE_FUNCTIONS = 68
- SC_THREAD_SPORADIC_SERVER = 161
- SC_THREAD_STACK_MIN = 75
- SC_THREAD_THREADS_MAX = 76
- SC_TIMEOUTS = 164
- SC_TIMERS = 11
- SC_TIMER_MAX = 35
- SC_TRACE = 181
- SC_TRACE_EVENT_FILTER = 182
- SC_TRACE_EVENT_NAME_MAX = 242
- SC_TRACE_INHERIT = 183
- SC_TRACE_LOG = 184
- SC_TRACE_NAME_MAX = 243
- SC_TRACE_SYS_MAX = 244
- SC_TRACE_USER_EVENT_MAX = 245
- SC_TTY_NAME_MAX = 72
- SC_TYPED_MEMORY_OBJECTS = 165
- SC_TZNAME_MAX = 6
- SC_V6_ILP32_OFF32 = 176
- SC_V6_ILP32_OFFBIG = 177
- SC_V6_LP64_OFF64 = 178
- SC_V6_LPBIG_OFFBIG = 179
- SC_VERSION = 29
- SC_XBS5_ILP32_OFF32 = 125
- SC_XBS5_ILP32_OFFBIG = 126
- SC_XBS5_LP64_OFF64 = 127
- SC_XBS5_LPBIG_OFFBIG = 128
- SC_XOPEN_CRYPT = 92
- SC_XOPEN_ENH_I18N = 93
- SC_XOPEN_LEGACY = 129
- SC_XOPEN_REALTIME = 130
- SC_XOPEN_REALTIME_THREADS = 131
- SC_XOPEN_SHM = 94
- SC_XOPEN_STREAMS = 246
- SC_XOPEN_UNIX = 91
- SC_XOPEN_VERSION = 89
- SC_XOPEN_XCU_VERSION = 90
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/syslog.rb b/src/main/resources/stdlib/ffi/platform/i386-linux/syslog.rb
deleted file mode 100644
index d502940..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- LOG_FTP = 88
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NDELAY = 8
- LOG_NEWS = 56
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- LOG_PERROR = 32
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/types.conf b/src/main/resources/stdlib/ffi/platform/i386-linux/types.conf
deleted file mode 100644
index 76014cd..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/types.conf
+++ /dev/null
@@ -1,100 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__quad_t = long_long
-rbx.platform.typedef.__u_quad_t = ulong_long
-rbx.platform.typedef.__dev_t = ulong_long
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long_long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong_long
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong_long
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong_long
-rbx.platform.typedef.__ssize_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.*__qaddr_t = long_long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.dev_t = ulong_long
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/i386-linux/zlib.rb b/src/main/resources/stdlib/ffi/platform/i386-linux/zlib.rb
deleted file mode 100644
index 04b2130..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-linux/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3.4"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 56
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 4,
- :total_in, :ulong, 8,
- :next_out, :pointer, 12,
- :avail_out, :uint, 16,
- :total_out, :ulong, 20,
- :msg, :string, 24,
- :state, :pointer, 28,
- :zalloc, :pointer, 32,
- :zfree, :pointer, 36,
- :opaque, :pointer, 40,
- :data_type, :int, 44,
- :adler, :ulong, 48,
- :reserved, :ulong, 52
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/errno.rb b/src/main/resources/stdlib/ffi/platform/i386-openbsd/errno.rb
deleted file mode 100644
index 7493c0d..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 48
- EADDRNOTAVAIL = 49
- EAFNOSUPPORT = 47
- EAGAIN = 35
- EALREADY = 37
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 53
- ECONNREFUSED = 61
- ECONNRESET = 54
- EDEADLK = 11
- EDESTADDRREQ = 39
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 64
- EHOSTUNREACH = 65
- EINPROGRESS = 36
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 56
- EISDIR = 21
- ELOOP = 62
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 40
- ENAMETOOLONG = 63
- ENETDOWN = 50
- ENETRESET = 52
- ENETUNREACH = 51
- ENFILE = 23
- ENOBUFS = 55
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 42
- ENOSPC = 28
- ENOTCONN = 57
- ENOTDIR = 20
- ENOTEMPTY = 66
- ENOTSOCK = 38
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 45
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 43
- EPROTOTYPE = 41
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 60
- ETXTBSY = 26
- EWOULDBLOCK = 35
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/etc.rb b/src/main/resources/stdlib/ffi/platform/i386-openbsd/etc.rb
deleted file mode 100644
index 12fb4b7..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 40
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 4,
- :pw_uid, :uint, 8,
- :pw_gid, :uint, 12,
- :pw_dir, :string, 28,
- :pw_shell, :string, 32
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 16
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 8
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/fcntl.rb b/src/main/resources/stdlib/ffi/platform/i386-openbsd/fcntl.rb
deleted file mode 100644
index 1db3cc0..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 7
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 8
- F_SETLKW = 9
- F_UNLCK = 2
- F_WRLCK = 3
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 512
- O_EXCL = 2048
- O_NDELAY = 4
- O_NOCTTY = 32768
- O_NONBLOCK = 4
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 1024
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/platform.conf b/src/main/resources/stdlib/ffi/platform/i386-openbsd/platform.conf
deleted file mode 100644
index 9476874..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/platform.conf
+++ /dev/null
@@ -1,565 +0,0 @@
-rbx.platform.addrinfo.sizeof = 32
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 20
-rbx.platform.addrinfo.ai_addr.size = 4
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 24
-rbx.platform.addrinfo.ai_canonname.size = 4
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 28
-rbx.platform.addrinfo.ai_next.size = 4
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 264
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 4
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 4
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 8
-rbx.platform.dirent.d_name.size = 256
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 1
-rbx.platform.sockaddr_in.sin_family.size = 1
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 106
-rbx.platform.sockaddr_un.sun_family.offset = 1
-rbx.platform.sockaddr_un.sun_family.size = 1
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 104
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 112
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 4
-rbx.platform.stat.st_ino.size = 4
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 8
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 12
-rbx.platform.stat.st_nlink.size = 4
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 16
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 20
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 24
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 56
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 72
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 64
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 32
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 40
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 48
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 512
-rbx.platform.file.O_EXCL = 2048
-rbx.platform.file.O_NOCTTY = 32768
-rbx.platform.file.O_TRUNC = 1024
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 4
-rbx.platform.file.O_SYNC = 128
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT = 21
-rbx.platform.socket.AF_COIP = 20
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 = 26
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 24
-rbx.platform.socket.AF_IPX = 23
-rbx.platform.socket.AF_ISDN = 26
-rbx.platform.socket.AF_ISO = 7
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 18
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 33
-rbx.platform.socket.AF_NATM = 27
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS =
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 7
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 17
-rbx.platform.socket.AF_SIP = 29
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG =
-rbx.platform.socket.AI_ALL =
-rbx.platform.socket.AI_CANONNAME = 2
-rbx.platform.socket.AI_DEFAULT =
-rbx.platform.socket.AI_MASK = 23
-rbx.platform.socket.AI_NUMERICHOST = 4
-rbx.platform.socket.AI_PASSIVE = 1
-rbx.platform.socket.AI_V4MAPPED =
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY = -9
-rbx.platform.socket.EAI_AGAIN = -3
-rbx.platform.socket.EAI_BADFLAGS = -1
-rbx.platform.socket.EAI_BADHINTS = -12
-rbx.platform.socket.EAI_FAIL = -4
-rbx.platform.socket.EAI_FAMILY = -6
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY = -10
-rbx.platform.socket.EAI_NODATA = -5
-rbx.platform.socket.EAI_NONAME = -2
-rbx.platform.socket.EAI_PROTOCOL = -13
-rbx.platform.socket.EAI_SERVICE = -8
-rbx.platform.socket.EAI_SOCKTYPE = -7
-rbx.platform.socket.EAI_SYSTEM = -11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE = -1
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 49151
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO =
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND =
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP = 29
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 12
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 13
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS = 4095
-rbx.platform.socket.IP_MULTICAST_IF = 9
-rbx.platform.socket.IP_MULTICAST_LOOP = 11
-rbx.platform.socket.IP_MULTICAST_TTL = 10
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 32
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 128
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 16
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 256
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 8
-rbx.platform.socket.NI_NOFQDN = 4
-rbx.platform.socket.NI_NUMERICHOST = 1
-rbx.platform.socket.NI_NUMERICSERV = 2
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT = 21
-rbx.platform.socket.PF_COIP = 20
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 24
-rbx.platform.socket.PF_IPX = 23
-rbx.platform.socket.PF_ISDN = 26
-rbx.platform.socket.PF_ISO = 7
-rbx.platform.socket.PF_KEY = 30
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 18
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 33
-rbx.platform.socket.PF_NATM = 27
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS =
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 7
-rbx.platform.socket.PF_PIP = 25
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 17
-rbx.platform.socket.PF_RTIP = 22
-rbx.platform.socket.PF_SIP = 29
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP = 19
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT = 512
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP =
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS = 5
-rbx.platform.process.RLIMIT_NPROC = 7
-rbx.platform.process.RLIMIT_NOFILE = 8
-rbx.platform.process.RLIMIT_MEMLOCK = 6
-rbx.platform.process.RLIMIT_AS =
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_MAX = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_CUR = 9223372036854775807
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 16
-rbx.platform.signal.SIGSTOP = 17
-rbx.platform.signal.SIGTSTP = 18
-rbx.platform.signal.SIGCONT = 19
-rbx.platform.signal.SIGCHLD = 20
-rbx.platform.signal.SIGCLD =
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 23
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 26
-rbx.platform.signal.SIGPROF = 27
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 30
-rbx.platform.signal.SIGUSR2 = 31
-rbx.platform.signal.SIGLOST =
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR =
-rbx.platform.signal.SIGPOLL =
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO = 29
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__int_least8_t = char
-rbx.platform.typedef.__uint_least8_t = uchar
-rbx.platform.typedef.__int_least16_t = short
-rbx.platform.typedef.__uint_least16_t = ushort
-rbx.platform.typedef.__int_least32_t = int
-rbx.platform.typedef.__uint_least32_t = uint
-rbx.platform.typedef.__int_least64_t = long_long
-rbx.platform.typedef.__uint_least64_t = ulong_long
-rbx.platform.typedef.__int_fast8_t = int
-rbx.platform.typedef.__uint_fast8_t = uint
-rbx.platform.typedef.__int_fast16_t = int
-rbx.platform.typedef.__uint_fast16_t = uint
-rbx.platform.typedef.__int_fast32_t = int
-rbx.platform.typedef.__uint_fast32_t = uint
-rbx.platform.typedef.__int_fast64_t = long_long
-rbx.platform.typedef.__uint_fast64_t = ulong_long
-rbx.platform.typedef.__intptr_t = long
-rbx.platform.typedef.__uintptr_t = ulong
-rbx.platform.typedef.__intmax_t = long_long
-rbx.platform.typedef.__uintmax_t = ulong_long
-rbx.platform.typedef.__register_t = int
-rbx.platform.typedef.__vaddr_t = ulong
-rbx.platform.typedef.__paddr_t = ulong
-rbx.platform.typedef.__vsize_t = ulong
-rbx.platform.typedef.__psize_t = ulong
-rbx.platform.typedef.__clock_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__off_t = long_long
-rbx.platform.typedef.__ptrdiff_t = long
-rbx.platform.typedef.__size_t = ulong
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__time_t = int
-rbx.platform.typedef.__timer_t = int
-rbx.platform.typedef.__wchar_t = int
-rbx.platform.typedef.__wint_t = int
-rbx.platform.typedef.__rune_t = int
-rbx.platform.typedef.__wctrans_t = pointer
-rbx.platform.typedef.__wctype_t = pointer
-rbx.platform.typedef.__cpuid_t = ulong
-rbx.platform.typedef.__dev_t = int
-rbx.platform.typedef.__fixpt_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__in_addr_t = uint
-rbx.platform.typedef.__in_port_t = ushort
-rbx.platform.typedef.__ino_t = uint
-rbx.platform.typedef.__key_t = long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__rlim_t = ulong_long
-rbx.platform.typedef.__sa_family_t = uchar
-rbx.platform.typedef.__segsz_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.__swblk_t = int
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = int
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.cpuid_t = ulong
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.vaddr_t = ulong
-rbx.platform.typedef.paddr_t = ulong
-rbx.platform.typedef.vsize_t = ulong
-rbx.platform.typedef.psize_t = ulong
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.daddr32_t = int
-rbx.platform.typedef.daddr64_t = long_long
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ino_t = uint
-rbx.platform.typedef.key_t = long
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.clock_t = int
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.__fd_mask = int
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/socket.rb b/src/main/resources/stdlib/ffi/platform/i386-openbsd/socket.rb
deleted file mode 100644
index 5d02e66..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- AF_CNT = 21
- AF_COIP = 20
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- AF_E164 = 26
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 24
- AF_IPX = 23
- AF_ISDN = 26
- AF_ISO = 7
- AF_LAT = 14
- AF_LINK = 18
- AF_LOCAL = 1
- AF_MAX = 35
- AF_NATM = 27
- # AF_NDRV not available
- # AF_NETBIOS not available
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 7
- # AF_PPP not available
- AF_PUP = 4
- AF_ROUTE = 17
- AF_SIP = 29
- AF_SNA = 11
- # AF_SYSTEM not available
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- NI_FQDN_FLAG_VALIDTTL = 256
- NI_MAXHOST = 256
- NI_MAXSERV = 32
- NI_NAMEREQD = 8
- NI_NODEADDR_FLAG_ALL = 512
- NI_NODEADDR_FLAG_ANYCAST = 16384
- NI_NODEADDR_FLAG_COMPAT = 1024
- NI_NODEADDR_FLAG_GLOBAL = 8192
- NI_NODEADDR_FLAG_LINKLOCAL = 2048
- NI_NODEADDR_FLAG_SITELOCAL = 4096
- NI_NODEADDR_FLAG_TRUNCATE = 256
- NI_NOFQDN = 4
- NI_NUMERICHOST = 1
- NI_NUMERICSERV = 2
- NI_QTYPE_DNSNAME = 2
- NI_QTYPE_FQDN = 2
- NI_QTYPE_IPV4ADDR = 4
- NI_QTYPE_NODEADDR = 3
- NI_QTYPE_NOOP = 0
- NI_QTYPE_SUPTYPES = 1
- NI_SUPTYPE_FLAG_COMPRESS = 256
- # NI_WITHSCOPEID not available
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- PF_CNT = 21
- PF_COIP = 20
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 24
- PF_IPX = 23
- PF_ISDN = 26
- PF_ISO = 7
- PF_KEY = 30
- PF_LAT = 14
- PF_LINK = 18
- PF_LOCAL = 1
- PF_MAX = 35
- PF_NATM = 27
- # PF_NDRV not available
- # PF_NETBIOS not available
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 7
- PF_PIP = 25
- # PF_PPP not available
- PF_PUP = 4
- PF_ROUTE = 17
- PF_RTIP = 22
- PF_SIP = 29
- PF_SNA = 11
- # PF_SYSTEM not available
- PF_UNIX = 1
- PF_UNSPEC = 0
- PF_XTP = 19
- SOCK_DGRAM = 2
- # SOCK_MAXADDRLEN not available
- SOCK_RAW = 3
- SOCK_RDM = 4
- SOCK_SEQPACKET = 5
- SOCK_STREAM = 1
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- # SO_DONTTRUNC not available
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- # SO_LABEL not available
- SO_LINGER = 128
- # SO_NKE not available
- # SO_NOADDRERR not available
- # SO_NOSIGPIPE not available
- # SO_NO_CHECK not available
- # SO_NREAD not available
- # SO_NWRITE not available
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- SO_PEERCRED = 4130
- # SO_PEERLABEL not available
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- SO_REUSEPORT = 512
- # SO_REUSESHAREUID not available
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- SO_TIMESTAMP = 2048
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- # SO_WANTMORE not available
- # SO_WANTOOBFLAG not available
- pseudo_AF_HDRCMPLT = 31
- # pseudo_AF_KEY not available
- pseudo_AF_PIP = 25
- pseudo_AF_RTIP = 22
- pseudo_AF_XTP = 19
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/stat.rb b/src/main/resources/stdlib/ffi/platform/i386-openbsd/stat.rb
deleted file mode 100644
index 75b9c0f..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 112
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 4,
- :st_nlink, :nlink_t, 12,
- :st_mode, :mode_t, 8,
- :st_uid, :uid_t, 16,
- :st_gid, :gid_t, 20,
- :st_size, :off_t, 56,
- :st_blocks, :blkcnt_t, 64,
- :st_atime, :time_t, 32,
- :st_mtime, :time_t, 40,
- :st_ctime, :time_t, 48
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/sysconf.rb b/src/main/resources/stdlib/ffi/platform/i386-openbsd/sysconf.rb
deleted file mode 100644
index 0eeda91..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 20
- SC_2_C_BIND = 18
- SC_2_C_DEV = 19
- SC_2_FORT_DEV = 21
- SC_2_FORT_RUN = 22
- SC_2_LOCALEDEF = 23
- # _SC_2_PBS not available
- # _SC_2_PBS_ACCOUNTING not available
- # _SC_2_PBS_CHECKPOINT not available
- # _SC_2_PBS_LOCATE not available
- # _SC_2_PBS_MESSAGE not available
- # _SC_2_PBS_TRACK not available
- SC_2_SW_DEV = 24
- SC_2_UPE = 25
- SC_2_VERSION = 17
- # _SC_ADVISORY_INFO not available
- # _SC_AIO_LISTIO_MAX not available
- # _SC_AIO_MAX not available
- # _SC_AIO_PRIO_DELTA_MAX not available
- SC_ARG_MAX = 1
- # _SC_ASYNCHRONOUS_IO not available
- # _SC_ATEXIT_MAX not available
- # _SC_BARRIERS not available
- SC_BC_BASE_MAX = 9
- SC_BC_DIM_MAX = 10
- SC_BC_SCALE_MAX = 11
- SC_BC_STRING_MAX = 12
- SC_CHILD_MAX = 2
- SC_CLK_TCK = 3
- # _SC_CLOCK_SELECTION not available
- SC_COLL_WEIGHTS_MAX = 13
- # _SC_CPUTIME not available
- # _SC_DELAYTIMER_MAX not available
- SC_EXPR_NEST_MAX = 14
- # _SC_FILE_LOCKING not available
- SC_FSYNC = 29
- SC_GETGR_R_SIZE_MAX = 100
- SC_GETPW_R_SIZE_MAX = 101
- # _SC_HOST_NAME_MAX not available
- # _SC_IOV_MAX not available
- # _SC_IPV6 not available
- SC_JOB_CONTROL = 6
- SC_LINE_MAX = 15
- SC_LOGIN_NAME_MAX = 102
- # _SC_MAPPED_FILES not available
- # _SC_MEMLOCK not available
- # _SC_MEMLOCK_RANGE not available
- # _SC_MEMORY_PROTECTION not available
- # _SC_MESSAGE_PASSING not available
- # _SC_MONOTONIC_CLOCK not available
- # _SC_MQ_OPEN_MAX not available
- # _SC_MQ_PRIO_MAX not available
- SC_NGROUPS_MAX = 4
- SC_NPROCESSORS_CONF = 502
- SC_NPROCESSORS_ONLN = 503
- SC_OPEN_MAX = 5
- SC_PAGESIZE = 28
- SC_PAGE_SIZE = 28
- # _SC_PASS_MAX not available
- # _SC_PRIORITIZED_IO not available
- # _SC_PRIORITY_SCHEDULING not available
- # _SC_RAW_SOCKETS not available
- # _SC_READER_WRITER_LOCKS not available
- # _SC_REALTIME_SIGNALS not available
- # _SC_REGEXP not available
- SC_RE_DUP_MAX = 16
- # _SC_RTSIG_MAX not available
- SC_SAVED_IDS = 7
- # _SC_SEMAPHORES not available
- SC_SEM_NSEMS_MAX = 31
- SC_SEM_VALUE_MAX = 32
- # _SC_SHARED_MEMORY_OBJECTS not available
- # _SC_SHELL not available
- # _SC_SIGQUEUE_MAX not available
- # _SC_SPAWN not available
- # _SC_SPIN_LOCKS not available
- # _SC_SPORADIC_SERVER not available
- # _SC_SS_REPL_MAX not available
- SC_STREAM_MAX = 26
- # _SC_SYMLOOP_MAX not available
- # _SC_SYNCHRONIZED_IO not available
- # _SC_THREADS not available
- # _SC_THREAD_ATTR_STACKADDR not available
- # _SC_THREAD_ATTR_STACKSIZE not available
- # _SC_THREAD_CPUTIME not available
- # _SC_THREAD_DESTRUCTOR_ITERATIONS not available
- # _SC_THREAD_KEYS_MAX not available
- # _SC_THREAD_PRIORITY_SCHEDULING not available
- # _SC_THREAD_PRIO_INHERIT not available
- # _SC_THREAD_PRIO_PROTECT not available
- # _SC_THREAD_PROCESS_SHARED not available
- SC_THREAD_SAFE_FUNCTIONS = 103
- # _SC_THREAD_SPORADIC_SERVER not available
- # _SC_THREAD_STACK_MIN not available
- # _SC_THREAD_THREADS_MAX not available
- # _SC_TIMEOUTS not available
- # _SC_TIMERS not available
- # _SC_TIMER_MAX not available
- # _SC_TRACE not available
- # _SC_TRACE_EVENT_FILTER not available
- # _SC_TRACE_EVENT_NAME_MAX not available
- # _SC_TRACE_INHERIT not available
- # _SC_TRACE_LOG not available
- # _SC_TRACE_NAME_MAX not available
- # _SC_TRACE_SYS_MAX not available
- # _SC_TRACE_USER_EVENT_MAX not available
- # _SC_TTY_NAME_MAX not available
- # _SC_TYPED_MEMORY_OBJECTS not available
- SC_TZNAME_MAX = 27
- # _SC_V6_ILP32_OFF32 not available
- # _SC_V6_ILP32_OFFBIG not available
- # _SC_V6_LP64_OFF64 not available
- # _SC_V6_LPBIG_OFFBIG not available
- SC_VERSION = 8
- # _SC_XBS5_ILP32_OFF32 not available
- # _SC_XBS5_ILP32_OFFBIG not available
- # _SC_XBS5_LP64_OFF64 not available
- # _SC_XBS5_LPBIG_OFFBIG not available
- # _SC_XOPEN_CRYPT not available
- # _SC_XOPEN_ENH_I18N not available
- # _SC_XOPEN_LEGACY not available
- # _SC_XOPEN_REALTIME not available
- # _SC_XOPEN_REALTIME_THREADS not available
- SC_XOPEN_SHM = 30
- # _SC_XOPEN_STREAMS not available
- # _SC_XOPEN_UNIX not available
- # _SC_XOPEN_VERSION not available
- # _SC_XOPEN_XCU_VERSION not available
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/syslog.rb b/src/main/resources/stdlib/ffi/platform/i386-openbsd/syslog.rb
deleted file mode 100644
index 41797be..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- LOG_FTP = 88
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NEWS = 56
- # LOG_NODELAY not available
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- LOG_PERROR = 32
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/types.conf b/src/main/resources/stdlib/ffi/platform/i386-openbsd/types.conf
deleted file mode 100644
index 33bd12b..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/types.conf
+++ /dev/null
@@ -1,126 +0,0 @@
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__int_least8_t = char
-rbx.platform.typedef.__uint_least8_t = uchar
-rbx.platform.typedef.__int_least16_t = short
-rbx.platform.typedef.__uint_least16_t = ushort
-rbx.platform.typedef.__int_least32_t = int
-rbx.platform.typedef.__uint_least32_t = uint
-rbx.platform.typedef.__int_least64_t = long_long
-rbx.platform.typedef.__uint_least64_t = ulong_long
-rbx.platform.typedef.__int_fast8_t = int
-rbx.platform.typedef.__uint_fast8_t = uint
-rbx.platform.typedef.__int_fast16_t = int
-rbx.platform.typedef.__uint_fast16_t = uint
-rbx.platform.typedef.__int_fast32_t = int
-rbx.platform.typedef.__uint_fast32_t = uint
-rbx.platform.typedef.__int_fast64_t = long_long
-rbx.platform.typedef.__uint_fast64_t = ulong_long
-rbx.platform.typedef.__intptr_t = long
-rbx.platform.typedef.__uintptr_t = ulong
-rbx.platform.typedef.__intmax_t = long_long
-rbx.platform.typedef.__uintmax_t = ulong_long
-rbx.platform.typedef.__register_t = int
-rbx.platform.typedef.__vaddr_t = ulong
-rbx.platform.typedef.__paddr_t = ulong
-rbx.platform.typedef.__vsize_t = ulong
-rbx.platform.typedef.__psize_t = ulong
-rbx.platform.typedef.__clock_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__off_t = long_long
-rbx.platform.typedef.__ptrdiff_t = long
-rbx.platform.typedef.__size_t = ulong
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__time_t = int
-rbx.platform.typedef.__timer_t = int
-rbx.platform.typedef.__wchar_t = int
-rbx.platform.typedef.__wint_t = int
-rbx.platform.typedef.__rune_t = int
-rbx.platform.typedef.__wctrans_t = pointer
-rbx.platform.typedef.__wctype_t = pointer
-rbx.platform.typedef.__cpuid_t = ulong
-rbx.platform.typedef.__dev_t = int
-rbx.platform.typedef.__fixpt_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__in_addr_t = uint
-rbx.platform.typedef.__in_port_t = ushort
-rbx.platform.typedef.__ino_t = uint
-rbx.platform.typedef.__key_t = long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__rlim_t = ulong_long
-rbx.platform.typedef.__sa_family_t = uchar
-rbx.platform.typedef.__segsz_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.__swblk_t = int
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = int
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.cpuid_t = ulong
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.vaddr_t = ulong
-rbx.platform.typedef.paddr_t = ulong
-rbx.platform.typedef.vsize_t = ulong
-rbx.platform.typedef.psize_t = ulong
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.daddr32_t = int
-rbx.platform.typedef.daddr64_t = long_long
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ino_t = uint
-rbx.platform.typedef.key_t = long
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.clock_t = int
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.__fd_mask = int
diff --git a/src/main/resources/stdlib/ffi/platform/i386-openbsd/zlib.rb b/src/main/resources/stdlib/ffi/platform/i386-openbsd/zlib.rb
deleted file mode 100644
index d95bc1a..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-openbsd/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 64
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 4,
- :total_in, :ulong, 8,
- :next_out, :pointer, 16,
- :avail_out, :uint, 20,
- :total_out, :ulong, 24,
- :msg, :string, 32,
- :state, :pointer, 36,
- :zalloc, :pointer, 40,
- :zfree, :pointer, 44,
- :opaque, :pointer, 48,
- :data_type, :int, 52,
- :adler, :ulong, 56,
- :reserved, :ulong, 60
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/errno.rb b/src/main/resources/stdlib/ffi/platform/i386-solaris/errno.rb
deleted file mode 100644
index b89dab7..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 125
- EADDRNOTAVAIL = 126
- EAFNOSUPPORT = 124
- EAGAIN = 11
- EALREADY = 149
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 130
- ECONNREFUSED = 146
- ECONNRESET = 131
- EDEADLK = 45
- EDESTADDRREQ = 96
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 147
- EHOSTUNREACH = 148
- EINPROGRESS = 150
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 133
- EISDIR = 21
- ELOOP = 90
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 97
- ENAMETOOLONG = 78
- ENETDOWN = 127
- ENETRESET = 129
- ENETUNREACH = 128
- ENFILE = 23
- ENOBUFS = 132
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 99
- ENOSPC = 28
- ENOTCONN = 134
- ENOTDIR = 20
- ENOTEMPTY = 93
- ENOTSOCK = 95
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 122
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 120
- EPROTOTYPE = 98
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 145
- ETXTBSY = 26
- EWOULDBLOCK = 11
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/etc.rb b/src/main/resources/stdlib/ffi/platform/i386-solaris/etc.rb
deleted file mode 100644
index cf7acee..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 36
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 4,
- :pw_uid, :uint, 8,
- :pw_gid, :uint, 12,
- :pw_dir, :string, 28,
- :pw_shell, :string, 32
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 16
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 8
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/fcntl.rb b/src/main/resources/stdlib/ffi/platform/i386-solaris/fcntl.rb
deleted file mode 100644
index 75f07b2..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 33
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 34
- F_SETLKW = 35
- F_UNLCK = 3
- F_WRLCK = 2
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 256
- O_EXCL = 1024
- O_NDELAY = 4
- O_NOCTTY = 2048
- O_NONBLOCK = 128
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 512
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/platform.conf b/src/main/resources/stdlib/ffi/platform/i386-solaris/platform.conf
deleted file mode 100644
index 38f7454..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/platform.conf
+++ /dev/null
@@ -1,561 +0,0 @@
-rbx.platform.addrinfo.sizeof = 32
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 24
-rbx.platform.addrinfo.ai_addr.size = 4
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 20
-rbx.platform.addrinfo.ai_canonname.size = 4
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 28
-rbx.platform.addrinfo.ai_next.size = 4
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 20
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 16
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 18
-rbx.platform.dirent.d_name.size = 1
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 0
-rbx.platform.sockaddr_in.sin_family.size = 2
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 110
-rbx.platform.sockaddr_un.sun_family.offset = 0
-rbx.platform.sockaddr_un.sun_family.size = 2
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 108
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 144
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 16
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 24
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 28
-rbx.platform.stat.st_nlink.size = 4
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 32
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 36
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 40
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 52
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 84
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 88
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 60
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 68
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 76
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 256
-rbx.platform.file.O_EXCL = 1024
-rbx.platform.file.O_NOCTTY = 2048
-rbx.platform.file.O_TRUNC = 512
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 128
-rbx.platform.file.O_SYNC = 16
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT =
-rbx.platform.socket.AF_COIP =
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 =
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 26
-rbx.platform.socket.AF_IPX = 23
-rbx.platform.socket.AF_ISDN =
-rbx.platform.socket.AF_ISO =
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 25
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 30
-rbx.platform.socket.AF_NATM =
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS =
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 19
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 24
-rbx.platform.socket.AF_SIP =
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 4
-rbx.platform.socket.AI_ALL = 2
-rbx.platform.socket.AI_CANONNAME = 16
-rbx.platform.socket.AI_DEFAULT = 5
-rbx.platform.socket.AI_MASK =
-rbx.platform.socket.AI_NUMERICHOST = 32
-rbx.platform.socket.AI_PASSIVE = 8
-rbx.platform.socket.AI_V4MAPPED = 1
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY = 1
-rbx.platform.socket.EAI_AGAIN = 2
-rbx.platform.socket.EAI_BADFLAGS = 3
-rbx.platform.socket.EAI_BADHINTS =
-rbx.platform.socket.EAI_FAIL = 4
-rbx.platform.socket.EAI_FAMILY = 5
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY = 6
-rbx.platform.socket.EAI_NODATA = 7
-rbx.platform.socket.EAI_NONAME = 8
-rbx.platform.socket.EAI_PROTOCOL =
-rbx.platform.socket.EAI_SERVICE = 9
-rbx.platform.socket.EAI_SOCKTYPE = 10
-rbx.platform.socket.EAI_SYSTEM = 11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE = -1
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 5000
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO = 63
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND = 77
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP =
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 19
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 20
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS =
-rbx.platform.socket.IP_MULTICAST_IF = 16
-rbx.platform.socket.IP_MULTICAST_LOOP = 18
-rbx.platform.socket.IP_MULTICAST_TTL = 17
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 16
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 128
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 32
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 4
-rbx.platform.socket.NI_NOFQDN = 1
-rbx.platform.socket.NI_NUMERICHOST = 2
-rbx.platform.socket.NI_NUMERICSERV = 8
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT =
-rbx.platform.socket.PF_COIP =
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 26
-rbx.platform.socket.PF_IPX = 23
-rbx.platform.socket.PF_ISDN =
-rbx.platform.socket.PF_ISO =
-rbx.platform.socket.PF_KEY = 27
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 25
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 30
-rbx.platform.socket.PF_NATM =
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS =
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 19
-rbx.platform.socket.PF_PIP =
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 24
-rbx.platform.socket.PF_RTIP =
-rbx.platform.socket.PF_SIP =
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP =
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 1
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 4
-rbx.platform.socket.SOCK_RDM = 5
-rbx.platform.socket.SOCK_SEQPACKET = 6
-rbx.platform.socket.SOCK_STREAM = 2
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT =
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP = 4115
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 64
-rbx.platform.process.WUNTRACED = 4
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS =
-rbx.platform.process.RLIMIT_NPROC =
-rbx.platform.process.RLIMIT_NOFILE = 5
-rbx.platform.process.RLIMIT_MEMLOCK =
-rbx.platform.process.RLIMIT_AS = 6
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 18446744073709551613
-rbx.platform.process.RLIM_SAVED_MAX = 18446744073709551614
-rbx.platform.process.RLIM_SAVED_CUR = 18446744073709551615
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 21
-rbx.platform.signal.SIGSTOP = 23
-rbx.platform.signal.SIGTSTP = 24
-rbx.platform.signal.SIGCONT = 25
-rbx.platform.signal.SIGCHLD = 18
-rbx.platform.signal.SIGCLD = 18
-rbx.platform.signal.SIGTTIN = 26
-rbx.platform.signal.SIGTTOU = 27
-rbx.platform.signal.SIGIO = 22
-rbx.platform.signal.SIGXCPU = 30
-rbx.platform.signal.SIGXFSZ = 31
-rbx.platform.signal.SIGVTALRM = 28
-rbx.platform.signal.SIGPROF = 29
-rbx.platform.signal.SIGWINCH = 20
-rbx.platform.signal.SIGUSR1 = 16
-rbx.platform.signal.SIGUSR2 = 17
-rbx.platform.signal.SIGLOST = 37
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR = 19
-rbx.platform.signal.SIGPOLL = 22
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO =
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3
-rbx.platform.typedef.lock_t = uchar
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.intptr_t = int
-rbx.platform.typedef.uintptr_t = uint
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = int
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = uint
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.t_scalar_t = long
-rbx.platform.typedef.t_uscalar_t = ulong
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.*caddr_t = char
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.ptrdiff_t = int
-rbx.platform.typedef.pfn_t = ulong
-rbx.platform.typedef.pgcnt_t = ulong
-rbx.platform.typedef.spgcnt_t = long
-rbx.platform.typedef.use_t = uchar
-rbx.platform.typedef.sysid_t = short
-rbx.platform.typedef.index_t = short
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.off64_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.blkcnt64_t = long_long
-rbx.platform.typedef.fsblkcnt64_t = ulong_long
-rbx.platform.typedef.fsfilcnt64_t = ulong_long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.pad64_t = long_long
-rbx.platform.typedef.upad64_t = ulong_long
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.u_offset_t = ulong_long
-rbx.platform.typedef.len_t = ulong_long
-rbx.platform.typedef.diskaddr_t = ulong_long
-rbx.platform.typedef.k_fltset_t = uint
-rbx.platform.typedef.id_t = long
-rbx.platform.typedef.lgrp_id_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.major_t = ulong
-rbx.platform.typedef.minor_t = ulong
-rbx.platform.typedef.pri_t = short
-rbx.platform.typedef.cpu_flag_t = ushort
-rbx.platform.typedef.o_mode_t = ushort
-rbx.platform.typedef.o_dev_t = short
-rbx.platform.typedef.o_uid_t = ushort
-rbx.platform.typedef.o_gid_t = ushort
-rbx.platform.typedef.o_nlink_t = short
-rbx.platform.typedef.o_pid_t = short
-rbx.platform.typedef.o_ino_t = ushort
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ulong
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.datalink_id_t = uint
-rbx.platform.typedef.taskid_t = long
-rbx.platform.typedef.projid_t = long
-rbx.platform.typedef.poolid_t = long
-rbx.platform.typedef.zoneid_t = long
-rbx.platform.typedef.ctid_t = long
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.pid_t = long
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.hrtime_t = long_long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.fds_mask = long
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.nfds_t = ulong
-rbx.platform.typedef.disp_lock_t = uchar
-rbx.platform.typedef.model_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.ipaddr_t = uint
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.rlim64_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/socket.rb b/src/main/resources/stdlib/ffi/platform/i386-solaris/socket.rb
deleted file mode 100644
index 26b97a4..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- # AF_CNT not available
- # AF_COIP not available
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- # AF_E164 not available
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 26
- AF_IPX = 23
- # AF_ISDN not available
- # AF_ISO not available
- AF_LAT = 14
- AF_LINK = 25
- AF_LOCAL = 1
- AF_MAX = 30
- # AF_NATM not available
- # AF_NDRV not available
- # AF_NETBIOS not available
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 19
- # AF_PPP not available
- AF_PUP = 4
- AF_ROUTE = 24
- # AF_SIP not available
- AF_SNA = 11
- # AF_SYSTEM not available
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- # NI_FQDN_FLAG_VALIDTTL not available
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 4
- # NI_NODEADDR_FLAG_ALL not available
- # NI_NODEADDR_FLAG_ANYCAST not available
- # NI_NODEADDR_FLAG_COMPAT not available
- # NI_NODEADDR_FLAG_GLOBAL not available
- # NI_NODEADDR_FLAG_LINKLOCAL not available
- # NI_NODEADDR_FLAG_SITELOCAL not available
- # NI_NODEADDR_FLAG_TRUNCATE not available
- NI_NOFQDN = 1
- NI_NUMERICHOST = 2
- NI_NUMERICSERV = 8
- # NI_QTYPE_DNSNAME not available
- # NI_QTYPE_FQDN not available
- # NI_QTYPE_IPV4ADDR not available
- # NI_QTYPE_NODEADDR not available
- # NI_QTYPE_NOOP not available
- # NI_QTYPE_SUPTYPES not available
- # NI_SUPTYPE_FLAG_COMPRESS not available
- NI_WITHSCOPEID = 32
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- # PF_CNT not available
- # PF_COIP not available
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 26
- PF_IPX = 23
- # PF_ISDN not available
- # PF_ISO not available
- PF_KEY = 27
- PF_LAT = 14
- PF_LINK = 25
- PF_LOCAL = 1
- PF_MAX = 30
- # PF_NATM not available
- # PF_NDRV not available
- # PF_NETBIOS not available
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 19
- # PF_PIP not available
- # PF_PPP not available
- PF_PUP = 4
- PF_ROUTE = 24
- # PF_RTIP not available
- # PF_SIP not available
- PF_SNA = 11
- # PF_SYSTEM not available
- PF_UNIX = 1
- PF_UNSPEC = 0
- # PF_XTP not available
- SOCK_DGRAM = 1
- # SOCK_MAXADDRLEN not available
- SOCK_RAW = 4
- SOCK_RDM = 5
- SOCK_SEQPACKET = 6
- SOCK_STREAM = 2
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- # SO_DONTTRUNC not available
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- # SO_LABEL not available
- SO_LINGER = 128
- # SO_NKE not available
- # SO_NOADDRERR not available
- # SO_NOSIGPIPE not available
- # SO_NO_CHECK not available
- # SO_NREAD not available
- # SO_NWRITE not available
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- # SO_PEERCRED not available
- # SO_PEERLABEL not available
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- # SO_REUSEPORT not available
- # SO_REUSESHAREUID not available
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- SO_TIMESTAMP = 4115
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- # SO_WANTMORE not available
- # SO_WANTOOBFLAG not available
- # pseudo_AF_HDRCMPLT not available
- # pseudo_AF_KEY not available
- # pseudo_AF_PIP not available
- # pseudo_AF_RTIP not available
- # pseudo_AF_XTP not available
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/stat.rb b/src/main/resources/stdlib/ffi/platform/i386-solaris/stat.rb
deleted file mode 100644
index 517adcb..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 144
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 16,
- :st_nlink, :nlink_t, 28,
- :st_mode, :mode_t, 24,
- :st_uid, :uid_t, 32,
- :st_gid, :gid_t, 36,
- :st_size, :off_t, 52,
- :st_blocks, :blkcnt_t, 88,
- :st_atime, :time_t, 60,
- :st_mtime, :time_t, 68,
- :st_ctime, :time_t, 76
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/sysconf.rb b/src/main/resources/stdlib/ffi/platform/i386-solaris/sysconf.rb
deleted file mode 100644
index 53d6fff..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 66
- SC_2_C_BIND = 45
- SC_2_C_DEV = 46
- SC_2_FORT_DEV = 48
- SC_2_FORT_RUN = 49
- SC_2_LOCALEDEF = 50
- SC_2_PBS = 724
- SC_2_PBS_ACCOUNTING = 725
- SC_2_PBS_CHECKPOINT = 726
- SC_2_PBS_LOCATE = 728
- SC_2_PBS_MESSAGE = 729
- SC_2_PBS_TRACK = 730
- SC_2_SW_DEV = 51
- SC_2_UPE = 52
- SC_2_VERSION = 53
- SC_ADVISORY_INFO = 731
- SC_AIO_LISTIO_MAX = 18
- SC_AIO_MAX = 19
- SC_AIO_PRIO_DELTA_MAX = 20
- SC_ARG_MAX = 1
- SC_ASYNCHRONOUS_IO = 21
- SC_ATEXIT_MAX = 76
- SC_BARRIERS = 732
- SC_BC_BASE_MAX = 54
- SC_BC_DIM_MAX = 55
- SC_BC_SCALE_MAX = 56
- SC_BC_STRING_MAX = 57
- SC_CHILD_MAX = 2
- SC_CLK_TCK = 3
- SC_CLOCK_SELECTION = 733
- SC_COLL_WEIGHTS_MAX = 58
- SC_CPUTIME = 734
- SC_DELAYTIMER_MAX = 22
- SC_EXPR_NEST_MAX = 59
- # _SC_FILE_LOCKING not available
- SC_FSYNC = 23
- SC_GETGR_R_SIZE_MAX = 569
- SC_GETPW_R_SIZE_MAX = 570
- SC_HOST_NAME_MAX = 735
- SC_IOV_MAX = 77
- SC_IPV6 = 762
- SC_JOB_CONTROL = 6
- SC_LINE_MAX = 60
- SC_LOGIN_NAME_MAX = 571
- SC_MAPPED_FILES = 24
- SC_MEMLOCK = 25
- SC_MEMLOCK_RANGE = 26
- SC_MEMORY_PROTECTION = 27
- SC_MESSAGE_PASSING = 28
- SC_MONOTONIC_CLOCK = 736
- SC_MQ_OPEN_MAX = 29
- SC_MQ_PRIO_MAX = 30
- SC_NGROUPS_MAX = 4
- SC_NPROCESSORS_CONF = 14
- SC_NPROCESSORS_ONLN = 15
- SC_OPEN_MAX = 5
- SC_PAGESIZE = 11
- SC_PAGE_SIZE = 11
- SC_PASS_MAX = 9
- SC_PRIORITIZED_IO = 31
- SC_PRIORITY_SCHEDULING = 32
- SC_RAW_SOCKETS = 763
- SC_READER_WRITER_LOCKS = 737
- SC_REALTIME_SIGNALS = 33
- SC_REGEXP = 738
- SC_RE_DUP_MAX = 61
- SC_RTSIG_MAX = 34
- SC_SAVED_IDS = 7
- SC_SEMAPHORES = 35
- SC_SEM_NSEMS_MAX = 36
- SC_SEM_VALUE_MAX = 37
- SC_SHARED_MEMORY_OBJECTS = 38
- SC_SHELL = 739
- SC_SIGQUEUE_MAX = 39
- SC_SPAWN = 740
- SC_SPIN_LOCKS = 741
- SC_SPORADIC_SERVER = 742
- SC_SS_REPL_MAX = 743
- SC_STREAM_MAX = 16
- SC_SYMLOOP_MAX = 744
- SC_SYNCHRONIZED_IO = 42
- SC_THREADS = 576
- SC_THREAD_ATTR_STACKADDR = 577
- SC_THREAD_ATTR_STACKSIZE = 578
- SC_THREAD_CPUTIME = 745
- SC_THREAD_DESTRUCTOR_ITERATIONS = 568
- SC_THREAD_KEYS_MAX = 572
- SC_THREAD_PRIORITY_SCHEDULING = 579
- SC_THREAD_PRIO_INHERIT = 580
- SC_THREAD_PRIO_PROTECT = 581
- SC_THREAD_PROCESS_SHARED = 582
- SC_THREAD_SAFE_FUNCTIONS = 583
- SC_THREAD_SPORADIC_SERVER = 746
- SC_THREAD_STACK_MIN = 573
- SC_THREAD_THREADS_MAX = 574
- SC_TIMEOUTS = 747
- SC_TIMERS = 43
- SC_TIMER_MAX = 44
- SC_TRACE = 748
- SC_TRACE_EVENT_FILTER = 749
- SC_TRACE_EVENT_NAME_MAX = 750
- SC_TRACE_INHERIT = 751
- SC_TRACE_LOG = 752
- SC_TRACE_NAME_MAX = 753
- SC_TRACE_SYS_MAX = 754
- SC_TRACE_USER_EVENT_MAX = 755
- SC_TTY_NAME_MAX = 575
- SC_TYPED_MEMORY_OBJECTS = 756
- SC_TZNAME_MAX = 17
- SC_V6_ILP32_OFF32 = 757
- SC_V6_ILP32_OFFBIG = 758
- SC_V6_LP64_OFF64 = 759
- SC_V6_LPBIG_OFFBIG = 760
- SC_VERSION = 8
- SC_XBS5_ILP32_OFF32 = 720
- SC_XBS5_ILP32_OFFBIG = 721
- SC_XBS5_LP64_OFF64 = 722
- SC_XBS5_LPBIG_OFFBIG = 723
- SC_XOPEN_CRYPT = 62
- SC_XOPEN_ENH_I18N = 63
- SC_XOPEN_LEGACY = 717
- SC_XOPEN_REALTIME = 718
- SC_XOPEN_REALTIME_THREADS = 719
- SC_XOPEN_SHM = 64
- SC_XOPEN_STREAMS = 761
- SC_XOPEN_UNIX = 78
- SC_XOPEN_VERSION = 12
- SC_XOPEN_XCU_VERSION = 67
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/syslog.rb b/src/main/resources/stdlib/ffi/platform/i386-solaris/syslog.rb
deleted file mode 100644
index 4f0f711..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- # LOG_AUTHPRIV not available
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 120
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- # LOG_FTP not available
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NEWS = 56
- # LOG_NODELAY not available
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- # LOG_PERROR not available
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/types.conf b/src/main/resources/stdlib/ffi/platform/i386-solaris/types.conf
deleted file mode 100644
index a585100..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/types.conf
+++ /dev/null
@@ -1,122 +0,0 @@
-rbx.platform.typedef.lock_t = uchar
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.intptr_t = int
-rbx.platform.typedef.uintptr_t = uint
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = int
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = uint
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.t_scalar_t = long
-rbx.platform.typedef.t_uscalar_t = ulong
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.*caddr_t = char
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.ptrdiff_t = int
-rbx.platform.typedef.pfn_t = ulong
-rbx.platform.typedef.pgcnt_t = ulong
-rbx.platform.typedef.spgcnt_t = long
-rbx.platform.typedef.use_t = uchar
-rbx.platform.typedef.sysid_t = short
-rbx.platform.typedef.index_t = short
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.off64_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.blkcnt64_t = long_long
-rbx.platform.typedef.fsblkcnt64_t = ulong_long
-rbx.platform.typedef.fsfilcnt64_t = ulong_long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.pad64_t = long_long
-rbx.platform.typedef.upad64_t = ulong_long
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.u_offset_t = ulong_long
-rbx.platform.typedef.len_t = ulong_long
-rbx.platform.typedef.diskaddr_t = ulong_long
-rbx.platform.typedef.k_fltset_t = uint
-rbx.platform.typedef.id_t = long
-rbx.platform.typedef.lgrp_id_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.major_t = ulong
-rbx.platform.typedef.minor_t = ulong
-rbx.platform.typedef.pri_t = short
-rbx.platform.typedef.cpu_flag_t = ushort
-rbx.platform.typedef.o_mode_t = ushort
-rbx.platform.typedef.o_dev_t = short
-rbx.platform.typedef.o_uid_t = ushort
-rbx.platform.typedef.o_gid_t = ushort
-rbx.platform.typedef.o_nlink_t = short
-rbx.platform.typedef.o_pid_t = short
-rbx.platform.typedef.o_ino_t = ushort
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ulong
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.datalink_id_t = uint
-rbx.platform.typedef.taskid_t = long
-rbx.platform.typedef.projid_t = long
-rbx.platform.typedef.poolid_t = long
-rbx.platform.typedef.zoneid_t = long
-rbx.platform.typedef.ctid_t = long
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.pid_t = long
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.hrtime_t = long_long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.fds_mask = long
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.nfds_t = ulong
-rbx.platform.typedef.disp_lock_t = uchar
-rbx.platform.typedef.model_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.ipaddr_t = uint
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.rlim64_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/i386-solaris/zlib.rb b/src/main/resources/stdlib/ffi/platform/i386-solaris/zlib.rb
deleted file mode 100644
index a08f385..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-solaris/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 56
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 4,
- :total_in, :ulong, 8,
- :next_out, :pointer, 12,
- :avail_out, :uint, 16,
- :total_out, :ulong, 20,
- :msg, :string, 24,
- :state, :pointer, 28,
- :zalloc, :pointer, 32,
- :zfree, :pointer, 36,
- :opaque, :pointer, 40,
- :data_type, :int, 44,
- :adler, :ulong, 48,
- :reserved, :ulong, 52
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-windows/errno.rb b/src/main/resources/stdlib/ffi/platform/i386-windows/errno.rb
deleted file mode 100644
index afdd42f..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-windows/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 112
- EADDRNOTAVAIL = 125
- EAFNOSUPPORT = 106
- EAGAIN = 11
- EALREADY = 120
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 113
- ECONNREFUSED = 111
- ECONNRESET = 104
- EDEADLK = 45
- EDESTADDRREQ = 121
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 117
- EHOSTUNREACH = 118
- EINPROGRESS = 119
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 127
- EISDIR = 21
- ELOOP = 92
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 122
- ENAMETOOLONG = 91
- ENETDOWN = 115
- ENETRESET = 126
- ENETUNREACH = 114
- ENFILE = 23
- ENOBUFS = 105
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 109
- ENOSPC = 28
- ENOTCONN = 128
- ENOTDIR = 20
- ENOTEMPTY = 90
- ENOTSOCK = 108
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 95
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 123
- EPROTOTYPE = 107
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 116
- ETXTBSY = 26
- EWOULDBLOCK = 11
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-windows/etc.rb b/src/main/resources/stdlib/ffi/platform/i386-windows/etc.rb
deleted file mode 100644
index 0ea968c..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-windows/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 4,
- :pw_uid, :uint, 8,
- :pw_gid, :uint, 12,
- :pw_dir, :string, 24,
- :pw_shell, :string, 28
-
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 8
-
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/i386-windows/fcntl.rb b/src/main/resources/stdlib/ffi/platform/i386-windows/fcntl.rb
deleted file mode 100644
index 8af8dd3..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-windows/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 7
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 8
- F_SETLKW = 9
- F_UNLCK = 3
- F_WRLCK = 2
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 512
- O_EXCL = 2048
- O_NDELAY = 16384
- O_NOCTTY = 32768
- O_NONBLOCK = 16384
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 1024
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i386-windows/platform.conf b/src/main/resources/stdlib/ffi/platform/i386-windows/platform.conf
deleted file mode 100644
index b204866..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-windows/platform.conf
+++ /dev/null
@@ -1,516 +0,0 @@
-rbx.platform.dirent.sizeof = 276
-rbx.platform.dirent.d_ino.offset = 4
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_name.offset = 20
-rbx.platform.dirent.d_name.size = 256
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 0
-rbx.platform.sockaddr_in.sin_family.size = 2
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 110
-rbx.platform.sockaddr_un.sun_family.offset = 0
-rbx.platform.sockaddr_un.sun_family.size = 2
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 108
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 2
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 96
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 8
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 16
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 20
-rbx.platform.stat.st_nlink.size = 2
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 24
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 28
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 32
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 40
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 72
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 80
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 48
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 56
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 64
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 8
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 4
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 4
-rbx.platform.rlimit.rlim_max.size = 4
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 512
-rbx.platform.file.O_EXCL = 2048
-rbx.platform.file.O_NOCTTY = 32768
-rbx.platform.file.O_TRUNC = 1024
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 16384
-rbx.platform.file.O_SYNC = 8192
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT =
-rbx.platform.socket.AF_COIP =
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 =
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 =
-rbx.platform.socket.AF_IPX =
-rbx.platform.socket.AF_ISDN =
-rbx.platform.socket.AF_ISO = 7
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK =
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 32
-rbx.platform.socket.AF_NATM =
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS = 17
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 7
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE =
-rbx.platform.socket.AF_SIP =
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG =
-rbx.platform.socket.AI_ALL =
-rbx.platform.socket.AI_CANONNAME =
-rbx.platform.socket.AI_DEFAULT =
-rbx.platform.socket.AI_MASK =
-rbx.platform.socket.AI_NUMERICHOST =
-rbx.platform.socket.AI_PASSIVE =
-rbx.platform.socket.AI_V4MAPPED =
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY =
-rbx.platform.socket.EAI_AGAIN =
-rbx.platform.socket.EAI_BADFLAGS =
-rbx.platform.socket.EAI_BADHINTS =
-rbx.platform.socket.EAI_FAIL =
-rbx.platform.socket.EAI_FAMILY =
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY =
-rbx.platform.socket.EAI_NODATA =
-rbx.platform.socket.EAI_NONAME =
-rbx.platform.socket.EAI_PROTOCOL =
-rbx.platform.socket.EAI_SERVICE =
-rbx.platform.socket.EAI_SOCKTYPE =
-rbx.platform.socket.EAI_SYSTEM =
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE = -1
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED =
-rbx.platform.socket.IPPORT_USERRESERVED =
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON =
-rbx.platform.socket.IPPROTO_GGP =
-rbx.platform.socket.IPPROTO_HELLO =
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX =
-rbx.platform.socket.IPPROTO_ND =
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP =
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE = 1
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 12
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 13
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS = 20
-rbx.platform.socket.IP_MULTICAST_IF = 9
-rbx.platform.socket.IP_MULTICAST_LOOP = 11
-rbx.platform.socket.IP_MULTICAST_TTL = 10
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR =
-rbx.platform.socket.IP_RECVOPTS =
-rbx.platform.socket.IP_RECVRETOPTS =
-rbx.platform.socket.IP_RETOPTS =
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 512
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT =
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR =
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 256
-rbx.platform.socket.MSG_WAITALL =
-rbx.platform.socket.NI_DGRAM =
-rbx.platform.socket.NI_MAXHOST =
-rbx.platform.socket.NI_MAXSERV =
-rbx.platform.socket.NI_NAMEREQD =
-rbx.platform.socket.NI_NOFQDN =
-rbx.platform.socket.NI_NUMERICHOST =
-rbx.platform.socket.NI_NUMERICSERV =
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT =
-rbx.platform.socket.PF_COIP =
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 =
-rbx.platform.socket.PF_IPX =
-rbx.platform.socket.PF_ISDN =
-rbx.platform.socket.PF_ISO = 7
-rbx.platform.socket.PF_KEY =
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK =
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 32
-rbx.platform.socket.PF_NATM =
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS = 17
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 7
-rbx.platform.socket.PF_PIP =
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE =
-rbx.platform.socket.PF_RTIP =
-rbx.platform.socket.PF_SIP =
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP =
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK = 258
-rbx.platform.socket.SOL_AX25 = 257
-rbx.platform.socket.SOL_IP = 0
-rbx.platform.socket.SOL_IPX = 256
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP = 6
-rbx.platform.socket.SOL_UDP = 17
-rbx.platform.socket.SOPRI_BACKGROUND = 2
-rbx.platform.socket.SOPRI_INTERACTIVE = 0
-rbx.platform.socket.SOPRI_NORMAL = 1
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED = 512
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT =
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP =
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS =
-rbx.platform.process.RLIMIT_NPROC =
-rbx.platform.process.RLIMIT_NOFILE = 5
-rbx.platform.process.RLIMIT_MEMLOCK =
-rbx.platform.process.RLIMIT_AS = 6
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 4294967295
-rbx.platform.process.RLIM_SAVED_MAX = 4294967295
-rbx.platform.process.RLIM_SAVED_CUR = 4294967295
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT =
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 16
-rbx.platform.signal.SIGSTOP = 17
-rbx.platform.signal.SIGTSTP = 18
-rbx.platform.signal.SIGCONT = 19
-rbx.platform.signal.SIGCHLD = 20
-rbx.platform.signal.SIGCLD = 20
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 23
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 26
-rbx.platform.signal.SIGPROF = 27
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 30
-rbx.platform.signal.SIGUSR2 = 31
-rbx.platform.signal.SIGLOST = 29
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR =
-rbx.platform.signal.SIGPOLL = 23
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO =
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int_least16_t = short
-rbx.platform.typedef.__uint_least16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int_least32_t = int
-rbx.platform.typedef.__uint_least32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef._off_t = long
-rbx.platform.typedef._off64_t = long_long
-rbx.platform.typedef._ssize_t = int
-rbx.platform.typedef.wint_t = uint
-rbx.platform.typedef.ptrdiff_t = int
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.clockid_t = ulong
-rbx.platform.typedef.timer_t = ulong
-rbx.platform.typedef.useconds_t = ulong
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = long
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = ulong
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = long
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = ulong
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = long
-rbx.platform.typedef.int_fast32_t = long
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = ulong
-rbx.platform.typedef.uint_fast32_t = ulong
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.__dev16_t = short
-rbx.platform.typedef.__dev32_t = ulong
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.__blkcnt32_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.__uid16_t = ushort
-rbx.platform.typedef.__uid32_t = ulong
-rbx.platform.typedef.uid_t = ulong
-rbx.platform.typedef.__gid16_t = ushort
-rbx.platform.typedef.__gid32_t = ulong
-rbx.platform.typedef.gid_t = ulong
-rbx.platform.typedef.__ino32_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.id_t = ulong
-rbx.platform.typedef.key_t = long_long
-rbx.platform.typedef.vm_offset_t = ulong
-rbx.platform.typedef.vm_size_t = ulong
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.*addr_t = char
-rbx.platform.typedef.socklen_t = int
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.__ULong = ulong
-rbx.platform.typedef._fpos_t = long
-rbx.platform.typedef._fpos64_t = long_long
-rbx.platform.typedef.sigset_t = ulong
-rbx.platform.typedef.sig_atomic_t = int
-rbx.platform.typedef.rlim_t = ulong
diff --git a/src/main/resources/stdlib/ffi/platform/i386-windows/types.conf b/src/main/resources/stdlib/ffi/platform/i386-windows/types.conf
deleted file mode 100644
index 38168be..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-windows/types.conf
+++ /dev/null
@@ -1,105 +0,0 @@
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int_least16_t = short
-rbx.platform.typedef.__uint_least16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int_least32_t = int
-rbx.platform.typedef.__uint_least32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef._off_t = long
-rbx.platform.typedef._off64_t = long_long
-rbx.platform.typedef._ssize_t = int
-rbx.platform.typedef.wint_t = uint
-rbx.platform.typedef.ptrdiff_t = int
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.clockid_t = ulong
-rbx.platform.typedef.timer_t = ulong
-rbx.platform.typedef.useconds_t = ulong
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = long
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = ulong
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = long
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = ulong
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = long
-rbx.platform.typedef.int_fast32_t = long
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = ulong
-rbx.platform.typedef.uint_fast32_t = ulong
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.__dev16_t = short
-rbx.platform.typedef.__dev32_t = ulong
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.__blkcnt32_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.__uid16_t = ushort
-rbx.platform.typedef.__uid32_t = ulong
-rbx.platform.typedef.uid_t = ulong
-rbx.platform.typedef.__gid16_t = ushort
-rbx.platform.typedef.__gid32_t = ulong
-rbx.platform.typedef.gid_t = ulong
-rbx.platform.typedef.__ino32_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.id_t = ulong
-rbx.platform.typedef.key_t = long_long
-rbx.platform.typedef.vm_offset_t = ulong
-rbx.platform.typedef.vm_size_t = ulong
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.*addr_t = char
-rbx.platform.typedef.socklen_t = int
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.__ULong = ulong
-rbx.platform.typedef._fpos_t = long
-rbx.platform.typedef._fpos64_t = long_long
-rbx.platform.typedef.sigset_t = ulong
-rbx.platform.typedef.sig_atomic_t = int
-rbx.platform.typedef.rlim_t = ulong
diff --git a/src/main/resources/stdlib/ffi/platform/i386-windows/zlib.rb b/src/main/resources/stdlib/ffi/platform/i386-windows/zlib.rb
deleted file mode 100644
index b1636ac..0000000
--- a/src/main/resources/stdlib/ffi/platform/i386-windows/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 4,
- :total_in, :ulong, 8,
- :next_out, :pointer, 12,
- :avail_out, :uint, 16,
- :total_out, :ulong, 20,
- :msg, :string, 24,
- :state, :pointer, 28,
- :zalloc, :pointer, 32,
- :zfree, :pointer, 36,
- :opaque, :pointer, 40,
- :data_type, :int, 44,
- :adler, :ulong, 48,
- :reserved, :ulong, 52
-
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function 'deflateInit2_', :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function 'deflate', :deflate, [:pointer, :int], :int
- attach_function 'deflateEnd', :deflateEnd, [:pointer], :int
- attach_function 'deflateParams', :deflateParams, [:pointer, :int, :int],
- :int
- attach_function 'deflateReset', :deflateReset, [:pointer], :int
- attach_function 'deflateSetDictionary', :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function 'inflateInit2_', :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function 'inflate', :inflate, [:pointer, :int], :int
- attach_function 'inflateEnd', :inflateEnd, [:pointer], :int
- attach_function 'inflateReset', :inflateReset, [:pointer], :int
- attach_function 'inflateSetDictionary', :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function 'adler32', :adler32_c, [:ulong, :string, :uint],
- :ulong
- attach_function 'crc32', :crc32_c, [:ulong, :string, :uint],
- :ulong
- attach_function 'get_crc_table', :get_crc_table_c, [], :pointer
-
- attach_function 'zError', :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/i486-gnu/types.conf b/src/main/resources/stdlib/ffi/platform/i486-gnu/types.conf
deleted file mode 100644
index f9169c2..0000000
--- a/src/main/resources/stdlib/ffi/platform/i486-gnu/types.conf
+++ /dev/null
@@ -1,107 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__quad_t = long_long
-rbx.platform.typedef.__u_quad_t = ulong_long
-rbx.platform.typedef.__dev_t = uint
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long_long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__fsid_t = ulong_long
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong_long
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = int
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong_long
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong_long
-rbx.platform.typedef.__ssize_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.*__qaddr_t = long_long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.fsid_t = ulong_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.dev_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.__sigset_t = ulong
-rbx.platform.typedef.sigset_t = ulong
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.__pthread_t = int
-rbx.platform.typedef.pthread_t = int
-rbx.platform.typedef.__pthread_key = int
-rbx.platform.typedef.pthread_key_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/mips-linux/types.conf b/src/main/resources/stdlib/ffi/platform/mips-linux/types.conf
deleted file mode 100644
index ad4ced0..0000000
--- a/src/main/resources/stdlib/ffi/platform/mips-linux/types.conf
+++ /dev/null
@@ -1,102 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__quad_t = long_long
-rbx.platform.typedef.__u_quad_t = ulong_long
-rbx.platform.typedef.__dev_t = ulong_long
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long_long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong_long
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong_long
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong_long
-rbx.platform.typedef.__ssize_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.*__qaddr_t = long_long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.dev_t = ulong_long
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/mipsel-linux/types.conf b/src/main/resources/stdlib/ffi/platform/mipsel-linux/types.conf
deleted file mode 100644
index ad4ced0..0000000
--- a/src/main/resources/stdlib/ffi/platform/mipsel-linux/types.conf
+++ /dev/null
@@ -1,102 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__quad_t = long_long
-rbx.platform.typedef.__u_quad_t = ulong_long
-rbx.platform.typedef.__dev_t = ulong_long
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long_long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong_long
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong_long
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong_long
-rbx.platform.typedef.__ssize_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.*__qaddr_t = long_long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.dev_t = ulong_long
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/errno.rb b/src/main/resources/stdlib/ffi/platform/powerpc-aix/errno.rb
deleted file mode 100644
index c356d4f..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 67
- EADDRNOTAVAIL = 68
- EAFNOSUPPORT = 66
- EAGAIN = 11
- EALREADY = 56
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 72
- ECONNREFUSED = 79
- ECONNRESET = 73
- EDEADLK = 45
- EDESTADDRREQ = 58
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 80
- EHOSTUNREACH = 81
- EINPROGRESS = 55
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 75
- EISDIR = 21
- ELOOP = 85
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 59
- ENAMETOOLONG = 86
- ENETDOWN = 69
- ENETRESET = 71
- ENETUNREACH = 70
- ENFILE = 23
- ENOBUFS = 74
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 61
- ENOSPC = 28
- ENOTCONN = 76
- ENOTDIR = 20
- ENOTEMPTY = 17
- ENOTSOCK = 57
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 64
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 62
- EPROTOTYPE = 60
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 78
- ETXTBSY = 26
- EWOULDBLOCK = 11
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/etc.rb b/src/main/resources/stdlib/ffi/platform/powerpc-aix/etc.rb
deleted file mode 100644
index 87a63ce..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 28
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 4,
- :pw_uid, :uint, 8,
- :pw_gid, :uint, 12,
- :pw_dir, :string, 20,
- :pw_shell, :string, 24
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 16
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 8
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/fcntl.rb b/src/main/resources/stdlib/ffi/platform/powerpc-aix/fcntl.rb
deleted file mode 100644
index 2e05b21..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 5
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 6
- F_SETLKW = 7
- F_UNLCK = 3
- F_WRLCK = 2
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 256
- O_EXCL = 1024
- O_NDELAY = 32768
- O_NOCTTY = 2048
- O_NONBLOCK = 4
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 512
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/platform.conf b/src/main/resources/stdlib/ffi/platform/powerpc-aix/platform.conf
deleted file mode 100644
index 38162eb..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/platform.conf
+++ /dev/null
@@ -1,619 +0,0 @@
-rbx.platform.addrinfo.sizeof = 32
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 24
-rbx.platform.addrinfo.ai_addr.size = 4
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 20
-rbx.platform.addrinfo.ai_canonname.size = 4
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 28
-rbx.platform.addrinfo.ai_next.size = 4
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 268
-rbx.platform.dirent.d_ino.offset = 4
-rbx.platform.dirent.d_ino.size = 4
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 8
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 12
-rbx.platform.dirent.d_name.size = 256
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 1
-rbx.platform.sockaddr_in.sin_family.size = 1
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 1025
-rbx.platform.sockaddr_un.sun_family.offset = 1
-rbx.platform.sockaddr_un.sun_family.size = 1
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 1023
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 116
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 4
-rbx.platform.stat.st_ino.size = 4
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 8
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 12
-rbx.platform.stat.st_nlink.size = 2
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 16
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 20
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 24
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 28
-rbx.platform.stat.st_size.size = 4
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 56
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 60
-rbx.platform.stat.st_blocks.size = 4
-rbx.platform.stat.st_atime.offset = 32
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 40
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 48
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 8
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 4
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 4
-rbx.platform.rlimit.rlim_max.size = 4
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 256
-rbx.platform.file.O_EXCL = 1024
-rbx.platform.file.O_NOCTTY = 2048
-rbx.platform.file.O_TRUNC = 512
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 4
-rbx.platform.file.O_SYNC = 16
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT =
-rbx.platform.socket.AF_COIP =
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 =
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 24
-rbx.platform.socket.AF_IPX =
-rbx.platform.socket.AF_ISDN =
-rbx.platform.socket.AF_ISO = 7
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 18
-rbx.platform.socket.AF_LOCAL =
-rbx.platform.socket.AF_MAX = 30
-rbx.platform.socket.AF_NATM =
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS =
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 7
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 17
-rbx.platform.socket.AF_SIP =
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 8
-rbx.platform.socket.AI_ALL = 32
-rbx.platform.socket.AI_CANONNAME = 1
-rbx.platform.socket.AI_DEFAULT = 24
-rbx.platform.socket.AI_MASK =
-rbx.platform.socket.AI_NUMERICHOST = 4
-rbx.platform.socket.AI_PASSIVE = 2
-rbx.platform.socket.AI_V4MAPPED = 16
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY = 1
-rbx.platform.socket.EAI_AGAIN = 2
-rbx.platform.socket.EAI_BADFLAGS = 3
-rbx.platform.socket.EAI_BADHINTS =
-rbx.platform.socket.EAI_FAIL = 4
-rbx.platform.socket.EAI_FAMILY = 5
-rbx.platform.socket.EAI_MAX = 11
-rbx.platform.socket.EAI_MEMORY = 6
-rbx.platform.socket.EAI_NODATA = 7
-rbx.platform.socket.EAI_NONAME = 8
-rbx.platform.socket.EAI_PROTOCOL =
-rbx.platform.socket.EAI_SERVICE = 9
-rbx.platform.socket.EAI_SOCKTYPE = 10
-rbx.platform.socket.EAI_SYSTEM = 11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE = -1
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 5000
-rbx.platform.socket.IPPROTO_BIP = 83
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO =
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND =
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP = 29
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 12
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 13
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS =
-rbx.platform.socket.IP_MULTICAST_IF = 9
-rbx.platform.socket.IP_MULTICAST_LOOP = 11
-rbx.platform.socket.IP_MULTICAST_TTL = 10
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT = 32768
-rbx.platform.socket.MSG_CTRUNC = 32
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT =
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 16
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 4
-rbx.platform.socket.NI_NOFQDN = 1
-rbx.platform.socket.NI_NUMERICHOST = 2
-rbx.platform.socket.NI_NUMERICSERV = 8
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT =
-rbx.platform.socket.PF_COIP =
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 24
-rbx.platform.socket.PF_IPX =
-rbx.platform.socket.PF_ISDN =
-rbx.platform.socket.PF_ISO = 7
-rbx.platform.socket.PF_KEY =
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 18
-rbx.platform.socket.PF_LOCAL =
-rbx.platform.socket.PF_MAX = 30
-rbx.platform.socket.PF_NATM =
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS =
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 7
-rbx.platform.socket.PF_PIP =
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 17
-rbx.platform.socket.PF_RTIP =
-rbx.platform.socket.PF_SIP =
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP = 19
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT = 512
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP =
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS = 5
-rbx.platform.process.RLIMIT_NPROC =
-rbx.platform.process.RLIMIT_NOFILE = 7
-rbx.platform.process.RLIMIT_MEMLOCK =
-rbx.platform.process.RLIMIT_AS = 6
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 2147483647
-rbx.platform.process.RLIM_SAVED_MAX = 2147483646
-rbx.platform.process.RLIM_SAVED_CUR = 2147483645
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 16
-rbx.platform.signal.SIGSTOP = 17
-rbx.platform.signal.SIGTSTP = 18
-rbx.platform.signal.SIGCONT = 19
-rbx.platform.signal.SIGCHLD = 20
-rbx.platform.signal.SIGCLD = 20
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 23
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 34
-rbx.platform.signal.SIGPROF = 32
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 30
-rbx.platform.signal.SIGUSR2 = 31
-rbx.platform.signal.SIGLOST = 6
-rbx.platform.signal.SIGMSG = 27
-rbx.platform.signal.SIGPWR = 29
-rbx.platform.signal.SIGPOLL = 23
-rbx.platform.signal.SIGDANGER = 33
-rbx.platform.signal.SIGMIGRATE = 35
-rbx.platform.signal.SIGPRE = 36
-rbx.platform.signal.SIGGRANT = 60
-rbx.platform.signal.SIGRETRACT = 61
-rbx.platform.signal.SIGSOUND = 62
-rbx.platform.signal.SIGINFO =
-rbx.platform.zlib.ZLIB_VERSION = 1.1.4
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = short
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = ushort
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.wchar_t = ushort
-rbx.platform.typedef.intfast_t = int
-rbx.platform.typedef.uintfast_t = uint
-rbx.platform.typedef.__long32_t = long
-rbx.platform.typedef.__ulong32_t = ulong
-rbx.platform.typedef.__long64_t = int
-rbx.platform.typedef.__ulong64_t = uint
-rbx.platform.typedef.int32long64_t = int
-rbx.platform.typedef.uint32long64_t = uint
-rbx.platform.typedef.long32int64_t = long
-rbx.platform.typedef.ulong32int64_t = ulong
-rbx.platform.typedef.int8 = char
-rbx.platform.typedef.int16 = short
-rbx.platform.typedef.int32 = int
-rbx.platform.typedef.int64 = long_long
-rbx.platform.typedef.u_int8 = uchar
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16 = ushort
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32 = uint
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64 = ulong_long
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.ptrdiff_t = long
-rbx.platform.typedef.wctype_t = uint
-rbx.platform.typedef.fpos_t = long
-rbx.platform.typedef.fpos64_t = long_long
-rbx.platform.typedef.time_t = int
-rbx.platform.typedef.clock_t = int
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.level_t = int
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.daddr32_t = int
-rbx.platform.typedef.daddr64_t = long_long
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.ino_t = uint
-rbx.platform.typedef.ino32_t = uint
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.dev_t = uint
-rbx.platform.typedef.dev32_t = uint
-rbx.platform.typedef.dev64_t = ulong_long
-rbx.platform.typedef.chan_t = int
-rbx.platform.typedef.time32_t = int
-rbx.platform.typedef.pid32_t = int
-rbx.platform.typedef.tid32_t = int
-rbx.platform.typedef.pid64_t = ulong_long
-rbx.platform.typedef.tid64_t = ulong_long
-rbx.platform.typedef.time64_t = long_long
-rbx.platform.typedef.__ptr32 = pointer
-rbx.platform.typedef.__cptr32 = string
-rbx.platform.typedef.soff_t = int
-rbx.platform.typedef.off_t = long
-rbx.platform.typedef.off64_t = long_long
-rbx.platform.typedef.paddr_t = long
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.timer32_t = int
-rbx.platform.typedef.timer64_t = long_long
-rbx.platform.typedef.nlink_t = short
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mid_t = pointer
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.tid_t = int
-rbx.platform.typedef.slab_t[12] = char
-rbx.platform.typedef.mtyp_t = long
-rbx.platform.typedef.boolean_t = int
-rbx.platform.typedef.crid_t = int
-rbx.platform.typedef.blkcnt_t = int
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.blkcnt32_t = int
-rbx.platform.typedef.blksize32_t = int
-rbx.platform.typedef.blkcnt64_t = ulong_long
-rbx.platform.typedef.blksize64_t = ulong_long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.wint_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.clockid_t = long_long
-rbx.platform.typedef.signal_t = int
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.vmid_t = long
-rbx.platform.typedef.vmhandle_t = ulong
-rbx.platform.typedef.vmid32_t = int
-rbx.platform.typedef.vmhandle32_t = uint
-rbx.platform.typedef.kvmid_t = long
-rbx.platform.typedef.kvmhandle_t = ulong
-rbx.platform.typedef.vmid64_t = long_long
-rbx.platform.typedef.rpn64_t = long_long
-rbx.platform.typedef.cnt64_t = long_long
-rbx.platform.typedef.psize_t = long_long
-rbx.platform.typedef.vmidx_t = int
-rbx.platform.typedef.vmfkey_t = uint
-rbx.platform.typedef.vmprkey_t = uint
-rbx.platform.typedef.vmkey_t = int
-rbx.platform.typedef.vmhwkey_t = int
-rbx.platform.typedef.vpn_t = int
-rbx.platform.typedef.rpn_t = int
-rbx.platform.typedef.ptex_t = ulong
-rbx.platform.typedef.swhatx_t = ulong
-rbx.platform.typedef.esid_t = uint
-rbx.platform.typedef.aptx_t = ushort
-rbx.platform.typedef.pdtx_t = int
-rbx.platform.typedef.psx_t = short
-rbx.platform.typedef.pshift_t = ushort
-rbx.platform.typedef.sshift_t = ushort
-rbx.platform.typedef.unidx_t = int
-rbx.platform.typedef.snidx_t = int
-rbx.platform.typedef.vmnodeidx_t = int
-rbx.platform.typedef.kvpn_t = int
-rbx.platform.typedef.krpn_t = int
-rbx.platform.typedef.vmsize_t = int
-rbx.platform.typedef.vmm_lock_t = int
-rbx.platform.typedef.ureg_t = ulong
-rbx.platform.typedef.vmlpghandle_t = ulong
-rbx.platform.typedef.ext_t = int
-rbx.platform.typedef.va_list = string
-rbx.platform.typedef.__ptr64 = ulong_long
-rbx.platform.typedef.__cptr64 = ulong_long
-rbx.platform.typedef.UniChar = ushort
-rbx.platform.typedef.UTF32Char = uint
-rbx.platform.typedef.uchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.ssize64_t = long_long
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.class_id_t = uint
-rbx.platform.typedef.liobn_t = uint
-rbx.platform.typedef.unit_addr_t = ulong_long
-rbx.platform.typedef.size64_t = ulong_long
-rbx.platform.typedef.socklen_t = ulong
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.rlim_t = ulong
-rbx.platform.typedef.rlim64_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/socket.rb b/src/main/resources/stdlib/ffi/platform/powerpc-aix/socket.rb
deleted file mode 100644
index 1f22b5c..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- # AF_CNT not available
- # AF_COIP not available
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- # AF_E164 not available
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 24
- # AF_IPX not available
- # AF_ISDN not available
- AF_ISO = 7
- AF_LAT = 14
- AF_LINK = 18
- # AF_LOCAL not available
- AF_MAX = 30
- # AF_NATM not available
- # AF_NDRV not available
- # AF_NETBIOS not available
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 7
- # AF_PPP not available
- AF_PUP = 4
- AF_ROUTE = 17
- # AF_SIP not available
- AF_SNA = 11
- # AF_SYSTEM not available
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- # NI_FQDN_FLAG_VALIDTTL not available
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 4
- # NI_NODEADDR_FLAG_ALL not available
- # NI_NODEADDR_FLAG_ANYCAST not available
- # NI_NODEADDR_FLAG_COMPAT not available
- # NI_NODEADDR_FLAG_GLOBAL not available
- # NI_NODEADDR_FLAG_LINKLOCAL not available
- # NI_NODEADDR_FLAG_SITELOCAL not available
- # NI_NODEADDR_FLAG_TRUNCATE not available
- NI_NOFQDN = 1
- NI_NUMERICHOST = 2
- NI_NUMERICSERV = 8
- # NI_QTYPE_DNSNAME not available
- # NI_QTYPE_FQDN not available
- # NI_QTYPE_IPV4ADDR not available
- # NI_QTYPE_NODEADDR not available
- # NI_QTYPE_NOOP not available
- # NI_QTYPE_SUPTYPES not available
- # NI_SUPTYPE_FLAG_COMPRESS not available
- # NI_WITHSCOPEID not available
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- # PF_CNT not available
- # PF_COIP not available
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 24
- # PF_IPX not available
- # PF_ISDN not available
- PF_ISO = 7
- # PF_KEY not available
- PF_LAT = 14
- PF_LINK = 18
- # PF_LOCAL not available
- PF_MAX = 30
- # PF_NATM not available
- # PF_NDRV not available
- # PF_NETBIOS not available
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 7
- # PF_PIP not available
- # PF_PPP not available
- PF_PUP = 4
- PF_ROUTE = 17
- # PF_RTIP not available
- # PF_SIP not available
- PF_SNA = 11
- # PF_SYSTEM not available
- PF_UNIX = 1
- PF_UNSPEC = 0
- PF_XTP = 19
- SOCK_DGRAM = 2
- # SOCK_MAXADDRLEN not available
- SOCK_RAW = 3
- SOCK_RDM = 4
- SOCK_SEQPACKET = 5
- SOCK_STREAM = 1
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- # SO_DONTTRUNC not available
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- # SO_LABEL not available
- SO_LINGER = 128
- # SO_NKE not available
- # SO_NOADDRERR not available
- # SO_NOSIGPIPE not available
- # SO_NO_CHECK not available
- # SO_NREAD not available
- # SO_NWRITE not available
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- # SO_PEERCRED not available
- # SO_PEERLABEL not available
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- SO_REUSEPORT = 512
- # SO_REUSESHAREUID not available
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- # SO_TIMESTAMP not available
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- # SO_WANTMORE not available
- # SO_WANTOOBFLAG not available
- # pseudo_AF_HDRCMPLT not available
- # pseudo_AF_KEY not available
- # pseudo_AF_PIP not available
- # pseudo_AF_RTIP not available
- pseudo_AF_XTP = 19
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/stat.rb b/src/main/resources/stdlib/ffi/platform/powerpc-aix/stat.rb
deleted file mode 100644
index d4d966d..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 116
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 4,
- :st_nlink, :nlink_t, 12,
- :st_mode, :mode_t, 8,
- :st_uid, :uid_t, 16,
- :st_gid, :gid_t, 20,
- :st_size, :off_t, 28,
- :st_blocks, :blkcnt_t, 60,
- :st_atime, :time_t, 32,
- :st_mtime, :time_t, 40,
- :st_ctime, :time_t, 48
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/sysconf.rb b/src/main/resources/stdlib/ffi/platform/powerpc-aix/sysconf.rb
deleted file mode 100644
index 93bce99..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 54
- SC_2_C_BIND = 51
- SC_2_C_DEV = 32
- SC_2_FORT_DEV = 33
- SC_2_FORT_RUN = 34
- SC_2_LOCALEDEF = 35
- SC_2_PBS = 132
- SC_2_PBS_ACCOUNTING = 133
- SC_2_PBS_CHECKPOINT = 134
- SC_2_PBS_LOCATE = 135
- SC_2_PBS_MESSAGE = 136
- SC_2_PBS_TRACK = 137
- SC_2_SW_DEV = 36
- SC_2_UPE = 53
- SC_2_VERSION = 31
- SC_ADVISORY_INFO = 130
- SC_AIO_LISTIO_MAX = 75
- SC_AIO_MAX = 76
- SC_AIO_PRIO_DELTA_MAX = 77
- SC_ARG_MAX = 0
- SC_ASYNCHRONOUS_IO = 78
- SC_ATEXIT_MAX = 47
- SC_BARRIERS = 138
- SC_BC_BASE_MAX = 23
- SC_BC_DIM_MAX = 24
- SC_BC_SCALE_MAX = 25
- SC_BC_STRING_MAX = 26
- SC_CHILD_MAX = 1
- SC_CLK_TCK = 2
- SC_CLOCK_SELECTION = 139
- SC_COLL_WEIGHTS_MAX = 50
- SC_CPUTIME = 140
- SC_DELAYTIMER_MAX = 79
- SC_EXPR_NEST_MAX = 28
- SC_FILE_LOCKING = 131
- SC_FSYNC = 80
- SC_GETGR_R_SIZE_MAX = 81
- SC_GETPW_R_SIZE_MAX = 82
- SC_HOST_NAME_MAX = 126
- SC_IOV_MAX = 58
- SC_IPV6 = 154
- SC_JOB_CONTROL = 7
- SC_LINE_MAX = 29
- SC_LOGIN_NAME_MAX = 83
- SC_MAPPED_FILES = 84
- SC_MEMLOCK = 85
- SC_MEMLOCK_RANGE = 86
- SC_MEMORY_PROTECTION = 87
- SC_MESSAGE_PASSING = 88
- SC_MONOTONIC_CLOCK = 141
- SC_MQ_OPEN_MAX = 89
- SC_MQ_PRIO_MAX = 90
- SC_NGROUPS_MAX = 3
- SC_NPROCESSORS_CONF = 71
- SC_NPROCESSORS_ONLN = 72
- SC_OPEN_MAX = 4
- SC_PAGESIZE = 48
- SC_PAGE_SIZE = 48
- SC_PASS_MAX = 45
- SC_PRIORITIZED_IO = 91
- SC_PRIORITY_SCHEDULING = 92
- SC_RAW_SOCKETS = 155
- SC_READER_WRITER_LOCKS = 142
- SC_REALTIME_SIGNALS = 93
- SC_REGEXP = 127
- SC_RE_DUP_MAX = 30
- SC_RTSIG_MAX = 94
- SC_SAVED_IDS = 8
- SC_SEMAPHORES = 95
- SC_SEM_NSEMS_MAX = 96
- SC_SEM_VALUE_MAX = 97
- SC_SHARED_MEMORY_OBJECTS = 98
- SC_SHELL = 128
- SC_SIGQUEUE_MAX = 99
- SC_SPAWN = 143
- SC_SPIN_LOCKS = 144
- SC_SPORADIC_SERVER = 145
- SC_SS_REPL_MAX = 156
- SC_STREAM_MAX = 5
- SC_SYMLOOP_MAX = 129
- SC_SYNCHRONIZED_IO = 100
- SC_THREADS = 60
- SC_THREAD_ATTR_STACKADDR = 61
- SC_THREAD_ATTR_STACKSIZE = 62
- SC_THREAD_CPUTIME = 146
- SC_THREAD_DESTRUCTOR_ITERATIONS = 101
- SC_THREAD_KEYS_MAX = 68
- SC_THREAD_PRIORITY_SCHEDULING = 64
- SC_THREAD_PRIO_INHERIT = 65
- SC_THREAD_PRIO_PROTECT = 66
- SC_THREAD_PROCESS_SHARED = 67
- SC_THREAD_SAFE_FUNCTIONS = 59
- SC_THREAD_SPORADIC_SERVER = 147
- SC_THREAD_STACK_MIN = 69
- SC_THREAD_THREADS_MAX = 70
- SC_TIMEOUTS = 148
- SC_TIMERS = 102
- SC_TIMER_MAX = 103
- SC_TRACE = 149
- SC_TRACE_EVENT_FILTER = 150
- SC_TRACE_EVENT_NAME_MAX = 157
- SC_TRACE_INHERIT = 151
- SC_TRACE_LOG = 152
- SC_TRACE_NAME_MAX = 158
- SC_TRACE_SYS_MAX = 159
- SC_TRACE_USER_EVENT_MAX = 160
- SC_TTY_NAME_MAX = 104
- SC_TYPED_MEMORY_OBJECTS = 153
- SC_TZNAME_MAX = 6
- SC_V6_ILP32_OFF32 = 121
- SC_V6_ILP32_OFFBIG = 122
- SC_V6_LP64_OFF64 = 123
- SC_V6_LPBIG_OFFBIG = 124
- SC_VERSION = 9
- SC_XBS5_ILP32_OFF32 = 105
- SC_XBS5_ILP32_OFFBIG = 106
- SC_XBS5_LP64_OFF64 = 107
- SC_XBS5_LPBIG_OFFBIG = 108
- SC_XOPEN_CRYPT = 56
- SC_XOPEN_ENH_I18N = 57
- SC_XOPEN_LEGACY = 112
- SC_XOPEN_REALTIME = 110
- SC_XOPEN_REALTIME_THREADS = 111
- SC_XOPEN_SHM = 55
- SC_XOPEN_STREAMS = 125
- SC_XOPEN_UNIX = 73
- SC_XOPEN_VERSION = 46
- SC_XOPEN_XCU_VERSION = 109
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/syslog.rb b/src/main/resources/stdlib/ffi/platform/powerpc-aix/syslog.rb
deleted file mode 100644
index 4b3f022..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- # LOG_FTP not available
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NEWS = 56
- # LOG_NODELAY not available
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- LOG_PERROR = 32
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/types.conf b/src/main/resources/stdlib/ffi/platform/powerpc-aix/types.conf
deleted file mode 100644
index 30ee66b..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/types.conf
+++ /dev/null
@@ -1,180 +0,0 @@
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = short
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = ushort
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.wchar_t = ushort
-rbx.platform.typedef.intfast_t = int
-rbx.platform.typedef.uintfast_t = uint
-rbx.platform.typedef.__long32_t = long
-rbx.platform.typedef.__ulong32_t = ulong
-rbx.platform.typedef.__long64_t = int
-rbx.platform.typedef.__ulong64_t = uint
-rbx.platform.typedef.int32long64_t = int
-rbx.platform.typedef.uint32long64_t = uint
-rbx.platform.typedef.long32int64_t = long
-rbx.platform.typedef.ulong32int64_t = ulong
-rbx.platform.typedef.int8 = char
-rbx.platform.typedef.int16 = short
-rbx.platform.typedef.int32 = int
-rbx.platform.typedef.int64 = long_long
-rbx.platform.typedef.u_int8 = uchar
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16 = ushort
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32 = uint
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64 = ulong_long
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.ptrdiff_t = long
-rbx.platform.typedef.wctype_t = uint
-rbx.platform.typedef.fpos_t = long
-rbx.platform.typedef.fpos64_t = long_long
-rbx.platform.typedef.time_t = int
-rbx.platform.typedef.clock_t = int
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.level_t = int
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.daddr32_t = int
-rbx.platform.typedef.daddr64_t = long_long
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.ino_t = uint
-rbx.platform.typedef.ino32_t = uint
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.dev_t = uint
-rbx.platform.typedef.dev32_t = uint
-rbx.platform.typedef.dev64_t = ulong_long
-rbx.platform.typedef.chan_t = int
-rbx.platform.typedef.time32_t = int
-rbx.platform.typedef.pid32_t = int
-rbx.platform.typedef.tid32_t = int
-rbx.platform.typedef.pid64_t = ulong_long
-rbx.platform.typedef.tid64_t = ulong_long
-rbx.platform.typedef.time64_t = long_long
-rbx.platform.typedef.__ptr32 = pointer
-rbx.platform.typedef.__cptr32 = string
-rbx.platform.typedef.soff_t = int
-rbx.platform.typedef.off_t = long
-rbx.platform.typedef.off64_t = long_long
-rbx.platform.typedef.paddr_t = long
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.timer32_t = int
-rbx.platform.typedef.timer64_t = long_long
-rbx.platform.typedef.nlink_t = short
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mid_t = pointer
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.tid_t = int
-rbx.platform.typedef.slab_t[12] = char
-rbx.platform.typedef.mtyp_t = long
-rbx.platform.typedef.boolean_t = int
-rbx.platform.typedef.crid_t = int
-rbx.platform.typedef.blkcnt_t = int
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.blkcnt32_t = int
-rbx.platform.typedef.blksize32_t = int
-rbx.platform.typedef.blkcnt64_t = ulong_long
-rbx.platform.typedef.blksize64_t = ulong_long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.wint_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.clockid_t = long_long
-rbx.platform.typedef.signal_t = int
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.vmid_t = long
-rbx.platform.typedef.vmhandle_t = ulong
-rbx.platform.typedef.vmid32_t = int
-rbx.platform.typedef.vmhandle32_t = uint
-rbx.platform.typedef.kvmid_t = long
-rbx.platform.typedef.kvmhandle_t = ulong
-rbx.platform.typedef.vmid64_t = long_long
-rbx.platform.typedef.rpn64_t = long_long
-rbx.platform.typedef.cnt64_t = long_long
-rbx.platform.typedef.psize_t = long_long
-rbx.platform.typedef.vmidx_t = int
-rbx.platform.typedef.vmfkey_t = uint
-rbx.platform.typedef.vmprkey_t = uint
-rbx.platform.typedef.vmkey_t = int
-rbx.platform.typedef.vmhwkey_t = int
-rbx.platform.typedef.vpn_t = int
-rbx.platform.typedef.rpn_t = int
-rbx.platform.typedef.ptex_t = ulong
-rbx.platform.typedef.swhatx_t = ulong
-rbx.platform.typedef.esid_t = uint
-rbx.platform.typedef.aptx_t = ushort
-rbx.platform.typedef.pdtx_t = int
-rbx.platform.typedef.psx_t = short
-rbx.platform.typedef.pshift_t = ushort
-rbx.platform.typedef.sshift_t = ushort
-rbx.platform.typedef.unidx_t = int
-rbx.platform.typedef.snidx_t = int
-rbx.platform.typedef.vmnodeidx_t = int
-rbx.platform.typedef.kvpn_t = int
-rbx.platform.typedef.krpn_t = int
-rbx.platform.typedef.vmsize_t = int
-rbx.platform.typedef.vmm_lock_t = int
-rbx.platform.typedef.ureg_t = ulong
-rbx.platform.typedef.vmlpghandle_t = ulong
-rbx.platform.typedef.ext_t = int
-rbx.platform.typedef.va_list = string
-rbx.platform.typedef.__ptr64 = ulong_long
-rbx.platform.typedef.__cptr64 = ulong_long
-rbx.platform.typedef.UniChar = ushort
-rbx.platform.typedef.UTF32Char = uint
-rbx.platform.typedef.uchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.ssize64_t = long_long
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.class_id_t = uint
-rbx.platform.typedef.liobn_t = uint
-rbx.platform.typedef.unit_addr_t = ulong_long
-rbx.platform.typedef.size64_t = ulong_long
-rbx.platform.typedef.socklen_t = ulong
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.rlim_t = ulong
-rbx.platform.typedef.rlim64_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-aix/zlib.rb b/src/main/resources/stdlib/ffi/platform/powerpc-aix/zlib.rb
deleted file mode 100644
index a08f385..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-aix/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 56
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 4,
- :total_in, :ulong, 8,
- :next_out, :pointer, 12,
- :avail_out, :uint, 16,
- :total_out, :ulong, 20,
- :msg, :string, 24,
- :state, :pointer, 28,
- :zalloc, :pointer, 32,
- :zfree, :pointer, 36,
- :opaque, :pointer, 40,
- :data_type, :int, 44,
- :adler, :ulong, 48,
- :reserved, :ulong, 52
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/errno.rb b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/errno.rb
deleted file mode 100644
index 12f09e0..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 48
- EADDRNOTAVAIL = 49
- EAFNOSUPPORT = 47
- EAGAIN = 35
- EALREADY = 37
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 53
- ECONNREFUSED = 61
- ECONNRESET = 54
- EDEADLK = 11
- EDESTADDRREQ = 39
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 64
- EHOSTUNREACH = 65
- EINPROGRESS = 36
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 56
- EISDIR = 21
- ELOOP = 62
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 40
- ENAMETOOLONG = 63
- ENETDOWN = 50
- ENETRESET = 52
- ENETUNREACH = 51
- ENFILE = 23
- ENOBUFS = 55
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 42
- ENOSPC = 28
- ENOTCONN = 57
- ENOTDIR = 20
- ENOTEMPTY = 66
- ENOTSOCK = 38
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 102
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 43
- EPROTOTYPE = 41
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 60
- ETXTBSY = 26
- EWOULDBLOCK = 35
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/etc.rb b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/etc.rb
deleted file mode 100644
index 12fb4b7..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 40
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 4,
- :pw_uid, :uint, 8,
- :pw_gid, :uint, 12,
- :pw_dir, :string, 28,
- :pw_shell, :string, 32
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 16
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 8
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/fcntl.rb b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/fcntl.rb
deleted file mode 100644
index a5333f6..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 7
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 8
- F_SETLKW = 9
- F_UNLCK = 2
- F_WRLCK = 3
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 512
- O_EXCL = 2048
- O_NDELAY = 4
- O_NOCTTY = 131072
- O_NONBLOCK = 4
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 1024
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/platform.conf b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/platform.conf
deleted file mode 100644
index 8c6dade..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/platform.conf
+++ /dev/null
@@ -1,539 +0,0 @@
-rbx.platform.addrinfo.sizeof = 32
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 24
-rbx.platform.addrinfo.ai_addr.size = 4
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 20
-rbx.platform.addrinfo.ai_canonname.size = 4
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 28
-rbx.platform.addrinfo.ai_next.size = 4
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 1048
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 16
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 21
-rbx.platform.dirent.d_name.size = 1024
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 1
-rbx.platform.sockaddr_in.sin_family.size = 1
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 106
-rbx.platform.sockaddr_un.sun_family.offset = 1
-rbx.platform.sockaddr_un.sun_family.size = 1
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 104
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 108
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 8
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 4
-rbx.platform.stat.st_mode.size = 2
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 6
-rbx.platform.stat.st_nlink.size = 2
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 16
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 20
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 24
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 60
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 76
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 68
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 28
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 36
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 44
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 512
-rbx.platform.file.O_EXCL = 2048
-rbx.platform.file.O_NOCTTY = 131072
-rbx.platform.file.O_TRUNC = 1024
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 4
-rbx.platform.file.O_SYNC = 128
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT = 57344
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT = 21
-rbx.platform.socket.AF_COIP = 20
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 = 28
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 30
-rbx.platform.socket.AF_IPX = 23
-rbx.platform.socket.AF_ISDN = 28
-rbx.platform.socket.AF_ISO = 7
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 18
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 37
-rbx.platform.socket.AF_NATM = 31
-rbx.platform.socket.AF_NDRV = 27
-rbx.platform.socket.AF_NETBIOS = 33
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 7
-rbx.platform.socket.AF_PPP = 34
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 17
-rbx.platform.socket.AF_SIP = 24
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM = 32
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 1024
-rbx.platform.socket.AI_ALL = 256
-rbx.platform.socket.AI_CANONNAME = 2
-rbx.platform.socket.AI_DEFAULT = 1536
-rbx.platform.socket.AI_MASK = 7
-rbx.platform.socket.AI_NUMERICHOST = 4
-rbx.platform.socket.AI_PASSIVE = 1
-rbx.platform.socket.AI_V4MAPPED = 2048
-rbx.platform.socket.AI_V4MAPPED_CFG = 512
-rbx.platform.socket.EAI_ADDRFAMILY = 1
-rbx.platform.socket.EAI_AGAIN = 2
-rbx.platform.socket.EAI_BADFLAGS = 3
-rbx.platform.socket.EAI_BADHINTS = 12
-rbx.platform.socket.EAI_FAIL = 4
-rbx.platform.socket.EAI_FAMILY = 5
-rbx.platform.socket.EAI_MAX = 14
-rbx.platform.socket.EAI_MEMORY = 6
-rbx.platform.socket.EAI_NODATA = 7
-rbx.platform.socket.EAI_NONAME = 8
-rbx.platform.socket.EAI_PROTOCOL = 13
-rbx.platform.socket.EAI_SERVICE = 9
-rbx.platform.socket.EAI_SOCKTYPE = 10
-rbx.platform.socket.EAI_SYSTEM = 11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE = -1
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 5000
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO = 63
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND = 77
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP = 29
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP = 36
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 12
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 13
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS = 20
-rbx.platform.socket.IP_MULTICAST_IF = 9
-rbx.platform.socket.IP_MULTICAST_LOOP = 11
-rbx.platform.socket.IP_MULTICAST_TTL = 10
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 32
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 128
-rbx.platform.socket.MSG_EOF = 256
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH = 1024
-rbx.platform.socket.MSG_HAVEMORE = 8192
-rbx.platform.socket.MSG_HOLD = 2048
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE = 16384
-rbx.platform.socket.MSG_SEND = 4096
-rbx.platform.socket.MSG_TRUNC = 16
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 4
-rbx.platform.socket.NI_NOFQDN = 1
-rbx.platform.socket.NI_NUMERICHOST = 2
-rbx.platform.socket.NI_NUMERICSERV = 8
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT = 21
-rbx.platform.socket.PF_COIP = 20
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 30
-rbx.platform.socket.PF_IPX = 23
-rbx.platform.socket.PF_ISDN = 28
-rbx.platform.socket.PF_ISO = 7
-rbx.platform.socket.PF_KEY = 29
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 18
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 37
-rbx.platform.socket.PF_NATM = 31
-rbx.platform.socket.PF_NDRV = 27
-rbx.platform.socket.PF_NETBIOS = 33
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 7
-rbx.platform.socket.PF_PIP = 25
-rbx.platform.socket.PF_PPP = 34
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 17
-rbx.platform.socket.PF_RTIP = 22
-rbx.platform.socket.PF_SIP = 24
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM = 32
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP = 19
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC = 8192
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE = 4129
-rbx.platform.socket.SO_NOSIGPIPE = 4130
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD = 4128
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT = 512
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP = 1024
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE = 16384
-rbx.platform.socket.SO_WANTOOBFLAG = 32768
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS = 5
-rbx.platform.process.RLIMIT_NPROC = 7
-rbx.platform.process.RLIMIT_NOFILE = 8
-rbx.platform.process.RLIMIT_MEMLOCK = 6
-rbx.platform.process.RLIMIT_AS = 5
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_MAX = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_CUR = 9223372036854775807
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 16
-rbx.platform.signal.SIGSTOP = 17
-rbx.platform.signal.SIGTSTP = 18
-rbx.platform.signal.SIGCONT = 19
-rbx.platform.signal.SIGCHLD = 20
-rbx.platform.signal.SIGCLD =
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 23
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 26
-rbx.platform.signal.SIGPROF = 27
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 30
-rbx.platform.signal.SIGUSR2 = 31
-rbx.platform.signal.SIGLOST =
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR =
-rbx.platform.signal.SIGPOLL =
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO = 29
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__darwin_intptr_t = long
-rbx.platform.typedef.__darwin_natural_t = uint
-rbx.platform.typedef.__darwin_ct_rune_t = int
-rbx.platform.typedef.__darwin_ptrdiff_t = int
-rbx.platform.typedef.__darwin_size_t = ulong
-rbx.platform.typedef.__darwin_wchar_t = int
-rbx.platform.typedef.__darwin_rune_t = int
-rbx.platform.typedef.__darwin_wint_t = int
-rbx.platform.typedef.__darwin_clock_t = ulong
-rbx.platform.typedef.__darwin_socklen_t = uint
-rbx.platform.typedef.__darwin_ssize_t = long
-rbx.platform.typedef.__darwin_time_t = long
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.user_addr_t = ulong_long
-rbx.platform.typedef.user_size_t = ulong_long
-rbx.platform.typedef.user_ssize_t = long_long
-rbx.platform.typedef.user_long_t = long_long
-rbx.platform.typedef.user_ulong_t = ulong_long
-rbx.platform.typedef.user_time_t = long_long
-rbx.platform.typedef.syscall_arg_t = ulong_long
-rbx.platform.typedef.__darwin_blkcnt_t = long_long
-rbx.platform.typedef.__darwin_blksize_t = int
-rbx.platform.typedef.__darwin_dev_t = int
-rbx.platform.typedef.__darwin_fsblkcnt_t = uint
-rbx.platform.typedef.__darwin_fsfilcnt_t = uint
-rbx.platform.typedef.__darwin_gid_t = uint
-rbx.platform.typedef.__darwin_id_t = uint
-rbx.platform.typedef.__darwin_ino64_t = ulong_long
-rbx.platform.typedef.__darwin_ino_t = ulong_long
-rbx.platform.typedef.__darwin_mach_port_name_t = uint
-rbx.platform.typedef.__darwin_mach_port_t = uint
-rbx.platform.typedef.__darwin_mode_t = ushort
-rbx.platform.typedef.__darwin_off_t = long_long
-rbx.platform.typedef.__darwin_pid_t = int
-rbx.platform.typedef.__darwin_pthread_key_t = ulong
-rbx.platform.typedef.__darwin_sigset_t = uint
-rbx.platform.typedef.__darwin_suseconds_t = int
-rbx.platform.typedef.__darwin_uid_t = uint
-rbx.platform.typedef.__darwin_useconds_t = uint
-rbx.platform.typedef.__darwin_uuid_t[16] = uchar
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ushort
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.fd_mask = int
-rbx.platform.typedef.pthread_key_t = ulong
-rbx.platform.typedef.fsblkcnt_t = uint
-rbx.platform.typedef.fsfilcnt_t = uint
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.rlim_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/socket.rb b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/socket.rb
deleted file mode 100644
index 06ffe8d..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- AF_CNT = 21
- AF_COIP = 20
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- AF_E164 = 28
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 30
- AF_IPX = 23
- AF_ISDN = 28
- AF_ISO = 7
- AF_LAT = 14
- AF_LINK = 18
- AF_LOCAL = 1
- AF_MAX = 37
- AF_NATM = 31
- AF_NDRV = 27
- AF_NETBIOS = 33
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 7
- AF_PPP = 34
- AF_PUP = 4
- AF_ROUTE = 17
- AF_SIP = 24
- AF_SNA = 11
- AF_SYSTEM = 32
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- NI_FQDN_FLAG_VALIDTTL = 1
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 4
- NI_NODEADDR_FLAG_ALL = 2
- NI_NODEADDR_FLAG_ANYCAST = 64
- NI_NODEADDR_FLAG_COMPAT = 4
- NI_NODEADDR_FLAG_GLOBAL = 32
- NI_NODEADDR_FLAG_LINKLOCAL = 8
- NI_NODEADDR_FLAG_SITELOCAL = 16
- NI_NODEADDR_FLAG_TRUNCATE = 1
- NI_NOFQDN = 1
- NI_NUMERICHOST = 2
- NI_NUMERICSERV = 8
- NI_QTYPE_DNSNAME = 2
- NI_QTYPE_FQDN = 2
- NI_QTYPE_IPV4ADDR = 4
- NI_QTYPE_NODEADDR = 3
- NI_QTYPE_NOOP = 0
- NI_QTYPE_SUPTYPES = 1
- NI_SUPTYPE_FLAG_COMPRESS = 1
- NI_WITHSCOPEID = 32
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- PF_CNT = 21
- PF_COIP = 20
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 30
- PF_IPX = 23
- PF_ISDN = 28
- PF_ISO = 7
- PF_KEY = 29
- PF_LAT = 14
- PF_LINK = 18
- PF_LOCAL = 1
- PF_MAX = 37
- PF_NATM = 31
- PF_NDRV = 27
- PF_NETBIOS = 33
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 7
- PF_PIP = 25
- PF_PPP = 34
- PF_PUP = 4
- PF_ROUTE = 17
- PF_RTIP = 22
- PF_SIP = 24
- PF_SNA = 11
- PF_SYSTEM = 32
- PF_UNIX = 1
- PF_UNSPEC = 0
- PF_XTP = 19
- SOCK_DGRAM = 2
- SOCK_MAXADDRLEN = 255
- SOCK_RAW = 3
- SOCK_RDM = 4
- SOCK_SEQPACKET = 5
- SOCK_STREAM = 1
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- SO_DONTTRUNC = 8192
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- SO_LABEL = 4112
- SO_LINGER = 128
- SO_NKE = 4129
- SO_NOADDRERR = 4131
- SO_NOSIGPIPE = 4130
- # SO_NO_CHECK not available
- SO_NREAD = 4128
- SO_NWRITE = 4132
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- # SO_PEERCRED not available
- SO_PEERLABEL = 4113
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- SO_REUSEPORT = 512
- SO_REUSESHAREUID = 4133
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- SO_TIMESTAMP = 1024
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- SO_WANTMORE = 16384
- SO_WANTOOBFLAG = 32768
- pseudo_AF_HDRCMPLT = 35
- pseudo_AF_KEY = 29
- pseudo_AF_PIP = 25
- pseudo_AF_RTIP = 22
- pseudo_AF_XTP = 19
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/stat.rb b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/stat.rb
deleted file mode 100644
index 8f3f95d..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 108
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 8,
- :st_nlink, :nlink_t, 6,
- :st_mode, :mode_t, 4,
- :st_uid, :uid_t, 16,
- :st_gid, :gid_t, 20,
- :st_size, :off_t, 60,
- :st_blocks, :blkcnt_t, 68,
- :st_atime, :time_t, 28,
- :st_mtime, :time_t, 36,
- :st_ctime, :time_t, 44
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/sysconf.rb b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/sysconf.rb
deleted file mode 100644
index 8d80175..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 20
- SC_2_C_BIND = 18
- SC_2_C_DEV = 19
- SC_2_FORT_DEV = 21
- SC_2_FORT_RUN = 22
- SC_2_LOCALEDEF = 23
- SC_2_PBS = 59
- SC_2_PBS_ACCOUNTING = 60
- SC_2_PBS_CHECKPOINT = 61
- SC_2_PBS_LOCATE = 62
- SC_2_PBS_MESSAGE = 63
- SC_2_PBS_TRACK = 64
- SC_2_SW_DEV = 24
- SC_2_UPE = 25
- SC_2_VERSION = 17
- SC_ADVISORY_INFO = 65
- SC_AIO_LISTIO_MAX = 42
- SC_AIO_MAX = 43
- SC_AIO_PRIO_DELTA_MAX = 44
- SC_ARG_MAX = 1
- SC_ASYNCHRONOUS_IO = 28
- SC_ATEXIT_MAX = 107
- SC_BARRIERS = 66
- SC_BC_BASE_MAX = 9
- SC_BC_DIM_MAX = 10
- SC_BC_SCALE_MAX = 11
- SC_BC_STRING_MAX = 12
- SC_CHILD_MAX = 2
- SC_CLK_TCK = 3
- SC_CLOCK_SELECTION = 67
- SC_COLL_WEIGHTS_MAX = 13
- SC_CPUTIME = 68
- SC_DELAYTIMER_MAX = 45
- SC_EXPR_NEST_MAX = 14
- SC_FILE_LOCKING = 69
- SC_FSYNC = 38
- SC_GETGR_R_SIZE_MAX = 70
- SC_GETPW_R_SIZE_MAX = 71
- SC_HOST_NAME_MAX = 72
- SC_IOV_MAX = 56
- SC_IPV6 = 118
- SC_JOB_CONTROL = 6
- SC_LINE_MAX = 15
- SC_LOGIN_NAME_MAX = 73
- SC_MAPPED_FILES = 47
- SC_MEMLOCK = 30
- SC_MEMLOCK_RANGE = 31
- SC_MEMORY_PROTECTION = 32
- SC_MESSAGE_PASSING = 33
- SC_MONOTONIC_CLOCK = 74
- SC_MQ_OPEN_MAX = 46
- SC_MQ_PRIO_MAX = 75
- SC_NGROUPS_MAX = 4
- SC_NPROCESSORS_CONF = 57
- SC_NPROCESSORS_ONLN = 58
- SC_OPEN_MAX = 5
- SC_PAGESIZE = 29
- SC_PAGE_SIZE = 29
- SC_PASS_MAX = 131
- SC_PRIORITIZED_IO = 34
- SC_PRIORITY_SCHEDULING = 35
- SC_RAW_SOCKETS = 119
- SC_READER_WRITER_LOCKS = 76
- SC_REALTIME_SIGNALS = 36
- SC_REGEXP = 77
- SC_RE_DUP_MAX = 16
- SC_RTSIG_MAX = 48
- SC_SAVED_IDS = 7
- SC_SEMAPHORES = 37
- SC_SEM_NSEMS_MAX = 49
- SC_SEM_VALUE_MAX = 50
- SC_SHARED_MEMORY_OBJECTS = 39
- SC_SHELL = 78
- SC_SIGQUEUE_MAX = 51
- SC_SPAWN = 79
- SC_SPIN_LOCKS = 80
- SC_SPORADIC_SERVER = 81
- SC_SS_REPL_MAX = 126
- SC_STREAM_MAX = 26
- SC_SYMLOOP_MAX = 120
- SC_SYNCHRONIZED_IO = 40
- SC_THREADS = 96
- SC_THREAD_ATTR_STACKADDR = 82
- SC_THREAD_ATTR_STACKSIZE = 83
- SC_THREAD_CPUTIME = 84
- SC_THREAD_DESTRUCTOR_ITERATIONS = 85
- SC_THREAD_KEYS_MAX = 86
- SC_THREAD_PRIORITY_SCHEDULING = 89
- SC_THREAD_PRIO_INHERIT = 87
- SC_THREAD_PRIO_PROTECT = 88
- SC_THREAD_PROCESS_SHARED = 90
- SC_THREAD_SAFE_FUNCTIONS = 91
- SC_THREAD_SPORADIC_SERVER = 92
- SC_THREAD_STACK_MIN = 93
- SC_THREAD_THREADS_MAX = 94
- SC_TIMEOUTS = 95
- SC_TIMERS = 41
- SC_TIMER_MAX = 52
- SC_TRACE = 97
- SC_TRACE_EVENT_FILTER = 98
- SC_TRACE_EVENT_NAME_MAX = 127
- SC_TRACE_INHERIT = 99
- SC_TRACE_LOG = 100
- SC_TRACE_NAME_MAX = 128
- SC_TRACE_SYS_MAX = 129
- SC_TRACE_USER_EVENT_MAX = 130
- SC_TTY_NAME_MAX = 101
- SC_TYPED_MEMORY_OBJECTS = 102
- SC_TZNAME_MAX = 27
- SC_V6_ILP32_OFF32 = 103
- SC_V6_ILP32_OFFBIG = 104
- SC_V6_LP64_OFF64 = 105
- SC_V6_LPBIG_OFFBIG = 106
- SC_VERSION = 8
- SC_XBS5_ILP32_OFF32 = 122
- SC_XBS5_ILP32_OFFBIG = 123
- SC_XBS5_LP64_OFF64 = 124
- SC_XBS5_LPBIG_OFFBIG = 125
- SC_XOPEN_CRYPT = 108
- SC_XOPEN_ENH_I18N = 109
- SC_XOPEN_LEGACY = 110
- SC_XOPEN_REALTIME = 111
- SC_XOPEN_REALTIME_THREADS = 112
- SC_XOPEN_SHM = 113
- SC_XOPEN_STREAMS = 114
- SC_XOPEN_UNIX = 115
- SC_XOPEN_VERSION = 116
- SC_XOPEN_XCU_VERSION = 121
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/syslog.rb b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/syslog.rb
deleted file mode 100644
index 41797be..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- LOG_FTP = 88
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NEWS = 56
- # LOG_NODELAY not available
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- LOG_PERROR = 32
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/types.conf b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/types.conf
deleted file mode 100644
index 6b9313e..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/types.conf
+++ /dev/null
@@ -1,100 +0,0 @@
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__darwin_intptr_t = long
-rbx.platform.typedef.__darwin_natural_t = uint
-rbx.platform.typedef.__darwin_ct_rune_t = int
-rbx.platform.typedef.__darwin_ptrdiff_t = int
-rbx.platform.typedef.__darwin_size_t = ulong
-rbx.platform.typedef.__darwin_wchar_t = int
-rbx.platform.typedef.__darwin_rune_t = int
-rbx.platform.typedef.__darwin_wint_t = int
-rbx.platform.typedef.__darwin_clock_t = ulong
-rbx.platform.typedef.__darwin_socklen_t = uint
-rbx.platform.typedef.__darwin_ssize_t = long
-rbx.platform.typedef.__darwin_time_t = long
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.user_addr_t = ulong_long
-rbx.platform.typedef.user_size_t = ulong_long
-rbx.platform.typedef.user_ssize_t = long_long
-rbx.platform.typedef.user_long_t = long_long
-rbx.platform.typedef.user_ulong_t = ulong_long
-rbx.platform.typedef.user_time_t = long_long
-rbx.platform.typedef.syscall_arg_t = ulong_long
-rbx.platform.typedef.__darwin_blkcnt_t = long_long
-rbx.platform.typedef.__darwin_blksize_t = int
-rbx.platform.typedef.__darwin_dev_t = int
-rbx.platform.typedef.__darwin_fsblkcnt_t = uint
-rbx.platform.typedef.__darwin_fsfilcnt_t = uint
-rbx.platform.typedef.__darwin_gid_t = uint
-rbx.platform.typedef.__darwin_id_t = uint
-rbx.platform.typedef.__darwin_ino64_t = ulong_long
-rbx.platform.typedef.__darwin_ino_t = ulong_long
-rbx.platform.typedef.__darwin_mach_port_name_t = uint
-rbx.platform.typedef.__darwin_mach_port_t = uint
-rbx.platform.typedef.__darwin_mode_t = ushort
-rbx.platform.typedef.__darwin_off_t = long_long
-rbx.platform.typedef.__darwin_pid_t = int
-rbx.platform.typedef.__darwin_pthread_key_t = ulong
-rbx.platform.typedef.__darwin_sigset_t = uint
-rbx.platform.typedef.__darwin_suseconds_t = int
-rbx.platform.typedef.__darwin_uid_t = uint
-rbx.platform.typedef.__darwin_useconds_t = uint
-rbx.platform.typedef.__darwin_uuid_t[16] = uchar
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ushort
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.fd_mask = int
-rbx.platform.typedef.pthread_key_t = ulong
-rbx.platform.typedef.fsblkcnt_t = uint
-rbx.platform.typedef.fsfilcnt_t = uint
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.rlim_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/zlib.rb b/src/main/resources/stdlib/ffi/platform/powerpc-darwin/zlib.rb
deleted file mode 100644
index a08f385..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-darwin/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 56
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 4,
- :total_in, :ulong, 8,
- :next_out, :pointer, 12,
- :avail_out, :uint, 16,
- :total_out, :ulong, 20,
- :msg, :string, 24,
- :state, :pointer, 28,
- :zalloc, :pointer, 32,
- :zfree, :pointer, 36,
- :opaque, :pointer, 40,
- :data_type, :int, 44,
- :adler, :ulong, 48,
- :reserved, :ulong, 52
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/powerpc-linux/types.conf b/src/main/resources/stdlib/ffi/platform/powerpc-linux/types.conf
deleted file mode 100644
index 76014cd..0000000
--- a/src/main/resources/stdlib/ffi/platform/powerpc-linux/types.conf
+++ /dev/null
@@ -1,100 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__quad_t = long_long
-rbx.platform.typedef.__u_quad_t = ulong_long
-rbx.platform.typedef.__dev_t = ulong_long
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long_long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong_long
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong_long
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong_long
-rbx.platform.typedef.__ssize_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.*__qaddr_t = long_long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.dev_t = ulong_long
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/ppc-darwin/syslog.rb b/src/main/resources/stdlib/ffi/platform/ppc-darwin/syslog.rb
deleted file mode 100644
index d502940..0000000
--- a/src/main/resources/stdlib/ffi/platform/ppc-darwin/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- LOG_FTP = 88
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NDELAY = 8
- LOG_NEWS = 56
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- LOG_PERROR = 32
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/ppc64le-linux/types.conf b/src/main/resources/stdlib/ffi/platform/ppc64le-linux/types.conf
deleted file mode 100644
index cd9eb77..0000000
--- a/src/main/resources/stdlib/ffi/platform/ppc64le-linux/types.conf
+++ /dev/null
@@ -1,100 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long
-rbx.platform.typedef.__uint64_t = ulong
-rbx.platform.typedef.__quad_t = long
-rbx.platform.typedef.__u_quad_t = ulong
-rbx.platform.typedef.__dev_t = ulong
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = ulong
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__loff_t = long
-rbx.platform.typedef.*__qaddr_t = long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = long
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long
-rbx.platform.typedef.u_quad_t = ulong
-rbx.platform.typedef.loff_t = long
-rbx.platform.typedef.ino_t = ulong
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blkcnt_t = long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/s390-linux/types.conf b/src/main/resources/stdlib/ffi/platform/s390-linux/types.conf
deleted file mode 100644
index 1cc79ee..0000000
--- a/src/main/resources/stdlib/ffi/platform/s390-linux/types.conf
+++ /dev/null
@@ -1,102 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__quad_t = long_long
-rbx.platform.typedef.__u_quad_t = ulong_long
-rbx.platform.typedef.__dev_t = ulong_long
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long_long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong_long
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong_long
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong_long
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.*__qaddr_t = long_long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.dev_t = ulong_long
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/s390x-linux/types.conf b/src/main/resources/stdlib/ffi/platform/s390x-linux/types.conf
deleted file mode 100644
index f4c8cec..0000000
--- a/src/main/resources/stdlib/ffi/platform/s390x-linux/types.conf
+++ /dev/null
@@ -1,102 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long
-rbx.platform.typedef.__uint64_t = ulong
-rbx.platform.typedef.__quad_t = long
-rbx.platform.typedef.__u_quad_t = ulong
-rbx.platform.typedef.__dev_t = ulong
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = ulong
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__loff_t = long
-rbx.platform.typedef.*__qaddr_t = long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = long
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long
-rbx.platform.typedef.u_quad_t = ulong
-rbx.platform.typedef.loff_t = long
-rbx.platform.typedef.ino_t = ulong
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.blkcnt_t = long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/socket.rb.ffi b/src/main/resources/stdlib/ffi/platform/socket.rb.ffi
deleted file mode 100644
index dacfc40..0000000
--- a/src/main/resources/stdlib/ffi/platform/socket.rb.ffi
+++ /dev/null
@@ -1,197 +0,0 @@
-module Platform; end
-module Platform::Socket
- @@@
- constants do |cg|
- cg.include "sys/types.h"
- cg.include "sys/socket.h"
- cg.include "netinet/in.h"
- cg.include "netinet/icmp6.h"
- cg.include "netdb.h"
-
- %w[
- SO_DEBUG
- SO_ACCEPTCONN
- SO_REUSEADDR
- SO_KEEPALIVE
- SO_DONTROUTE
- SO_BROADCAST
- SO_USELOOPBACK
- SO_LINGER
- SO_OOBINLINE
- SO_REUSEPORT
- SO_TIMESTAMP
- SO_ACCEPTFILTER
- SO_DONTTRUNC
- SO_WANTMORE
- SO_WANTOOBFLAG
- SO_SNDBUF
- SO_RCVBUF
- SO_SNDLOWAT
- SO_RCVLOWAT
- SO_SNDTIMEO
- SO_RCVTIMEO
- SO_ERROR
- SO_TYPE
- SO_NREAD
- SO_NKE
- SO_NOSIGPIPE
- SO_NOADDRERR
- SO_NWRITE
- SO_REUSESHAREUID
- SO_LABEL
- SO_PEERLABEL
- SO_ATTACH_FILTER
- SO_BINDTODEVICE
- SO_DETACH_FILTER
- SO_NO_CHECK
- SO_PASSCRED
- SO_PEERCRED
- SO_PEERNAME
- SO_PRIORITY
- SO_SECURITY_AUTHENTICATION
- SO_SECURITY_ENCRYPTION_NETWORK
- SO_SECURITY_ENCRYPTION_TRANSPORT
- ].each {|c| cg.const(c, "%#x", "(unsigned int)") { |v| v.hex} }
- %w[
- SOCK_STREAM
- SOCK_DGRAM
- SOCK_RAW
- SOCK_RDM
- SOCK_SEQPACKET
- SOCK_MAXADDRLEN
- ].each {|c| cg.const c }
- %w[
- AF_UNSPEC
- AF_LOCAL
- AF_UNIX
- AF_INET
- AF_IMPLINK
- AF_PUP
- AF_CHAOS
- AF_NS
- AF_ISO
- AF_OSI
- AF_ECMA
- AF_DATAKIT
- AF_CCITT
- AF_SNA
- AF_DECnet
- AF_DLI
- AF_LAT
- AF_HYLINK
- AF_APPLETALK
- AF_ROUTE
- AF_LINK
- pseudo_AF_XTP
- AF_COIP
- AF_CNT
- pseudo_AF_RTIP
- AF_IPX
- AF_SIP
- pseudo_AF_PIP
- AF_NDRV
- AF_ISDN
- AF_E164
- pseudo_AF_KEY
- AF_INET6
- AF_NATM
- AF_SYSTEM
- AF_NETBIOS
- AF_PPP
- AF_ATM
- pseudo_AF_HDRCMPLT
- AF_NETGRAPH
- AF_AX25
- AF_MAX
- ].each {|c| cg.const c }
- %w[
- PF_UNSPEC
- PF_LOCAL
- PF_UNIX
- PF_INET
- PF_IMPLINK
- PF_PUP
- PF_CHAOS
- PF_NS
- PF_ISO
- PF_OSI
- PF_ECMA
- PF_DATAKIT
- PF_CCITT
- PF_SNA
- PF_DECnet
- PF_DLI
- PF_LAT
- PF_HYLINK
- PF_APPLETALK
- PF_ROUTE
- PF_LINK
- PF_XTP
- PF_COIP
- PF_CNT
- PF_SIP
- PF_IPX
- PF_RTIP
- PF_PIP
- PF_NDRV
- PF_ISDN
- PF_KEY
- PF_INET6
- PF_NATM
- PF_SYSTEM
- PF_NETBIOS
- PF_PPP
- PF_ATM
- PF_NETGRAPH
- PF_MAX
- ].each {|c| cg.const c}
- %w[
- NI_MAXHOST
- NI_MAXSERV
- NI_NOFQDN
- NI_NUMERICHOST
- NI_NAMEREQD
- NI_NUMERICSERV
- NI_DGRAM
- NI_WITHSCOPEID
- NI_QTYPE_NOOP
- NI_QTYPE_SUPTYPES
- NI_QTYPE_FQDN
- NI_QTYPE_DNSNAME
- NI_QTYPE_NODEADDR
- NI_QTYPE_IPV4ADDR
- NI_SUPTYPE_FLAG_COMPRESS
- NI_FQDN_FLAG_VALIDTTL
- NI_SUPTYPE_FLAG_COMPRESS
- NI_FQDN_FLAG_VALIDTTL
- NI_NODEADDR_FLAG_LINKLOCAL
- NI_NODEADDR_FLAG_SITELOCAL
- NI_NODEADDR_FLAG_GLOBAL
- NI_NODEADDR_FLAG_ALL
- NI_NODEADDR_FLAG_TRUNCATE
- NI_NODEADDR_FLAG_ANYCAST
- NI_NODEADDR_FLAG_LINKLOCAL
- NI_NODEADDR_FLAG_SITELOCAL
- NI_NODEADDR_FLAG_GLOBAL
- NI_NODEADDR_FLAG_ALL
- NI_NODEADDR_FLAG_TRUNCATE
- NI_NODEADDR_FLAG_ANYCAST
- NI_NODEADDR_FLAG_TRUNCATE
- NI_NODEADDR_FLAG_ALL
- NI_NODEADDR_FLAG_COMPAT
- NI_NODEADDR_FLAG_LINKLOCAL
- NI_NODEADDR_FLAG_SITELOCAL
- NI_NODEADDR_FLAG_GLOBAL
- NI_NODEADDR_FLAG_ANYCAST
- NI_NODEADDR_FLAG_TRUNCATE
- NI_NODEADDR_FLAG_ALL
- NI_NODEADDR_FLAG_COMPAT
- NI_NODEADDR_FLAG_LINKLOCAL
- NI_NODEADDR_FLAG_SITELOCAL
- NI_NODEADDR_FLAG_GLOBAL
- NI_NODEADDR_FLAG_ANYCAST
- ].each {|c| cg.const c}
- end
- @@@
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/errno.rb b/src/main/resources/stdlib/ffi/platform/sparc-solaris/errno.rb
deleted file mode 100644
index b89dab7..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 125
- EADDRNOTAVAIL = 126
- EAFNOSUPPORT = 124
- EAGAIN = 11
- EALREADY = 149
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 130
- ECONNREFUSED = 146
- ECONNRESET = 131
- EDEADLK = 45
- EDESTADDRREQ = 96
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 147
- EHOSTUNREACH = 148
- EINPROGRESS = 150
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 133
- EISDIR = 21
- ELOOP = 90
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 97
- ENAMETOOLONG = 78
- ENETDOWN = 127
- ENETRESET = 129
- ENETUNREACH = 128
- ENFILE = 23
- ENOBUFS = 132
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 99
- ENOSPC = 28
- ENOTCONN = 134
- ENOTDIR = 20
- ENOTEMPTY = 93
- ENOTSOCK = 95
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 122
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 120
- EPROTOTYPE = 98
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 145
- ETXTBSY = 26
- EWOULDBLOCK = 11
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/etc.rb b/src/main/resources/stdlib/ffi/platform/sparc-solaris/etc.rb
deleted file mode 100644
index cf7acee..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 36
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 4,
- :pw_uid, :uint, 8,
- :pw_gid, :uint, 12,
- :pw_dir, :string, 28,
- :pw_shell, :string, 32
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 16
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 8
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/fcntl.rb b/src/main/resources/stdlib/ffi/platform/sparc-solaris/fcntl.rb
deleted file mode 100644
index 75f07b2..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 33
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 34
- F_SETLKW = 35
- F_UNLCK = 3
- F_WRLCK = 2
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 256
- O_EXCL = 1024
- O_NDELAY = 4
- O_NOCTTY = 2048
- O_NONBLOCK = 128
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 512
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/platform.conf b/src/main/resources/stdlib/ffi/platform/sparc-solaris/platform.conf
deleted file mode 100644
index 07be5a6..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/platform.conf
+++ /dev/null
@@ -1,567 +0,0 @@
-rbx.platform.addrinfo.sizeof = 32
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 24
-rbx.platform.addrinfo.ai_addr.size = 4
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 20
-rbx.platform.addrinfo.ai_canonname.size = 4
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 28
-rbx.platform.addrinfo.ai_next.size = 4
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 24
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 16
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 18
-rbx.platform.dirent.d_name.size = 1
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 0
-rbx.platform.sockaddr_in.sin_family.size = 2
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 110
-rbx.platform.sockaddr_un.sun_family.offset = 0
-rbx.platform.sockaddr_un.sun_family.size = 2
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 108
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 152
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 16
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 24
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 28
-rbx.platform.stat.st_nlink.size = 4
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 32
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 36
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 40
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 56
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 88
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 96
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 64
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 72
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 80
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 256
-rbx.platform.file.O_EXCL = 1024
-rbx.platform.file.O_NOCTTY = 2048
-rbx.platform.file.O_TRUNC = 512
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 128
-rbx.platform.file.O_SYNC = 16
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT =
-rbx.platform.socket.AF_COIP =
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 =
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 26
-rbx.platform.socket.AF_IPX = 23
-rbx.platform.socket.AF_ISDN =
-rbx.platform.socket.AF_ISO =
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 25
-rbx.platform.socket.AF_LOCAL =
-rbx.platform.socket.AF_MAX = 29
-rbx.platform.socket.AF_NATM =
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS =
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 19
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 24
-rbx.platform.socket.AF_SIP =
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 4
-rbx.platform.socket.AI_ALL = 2
-rbx.platform.socket.AI_CANONNAME = 16
-rbx.platform.socket.AI_DEFAULT = 5
-rbx.platform.socket.AI_MASK =
-rbx.platform.socket.AI_NUMERICHOST = 32
-rbx.platform.socket.AI_PASSIVE = 8
-rbx.platform.socket.AI_V4MAPPED = 1
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY = 1
-rbx.platform.socket.EAI_AGAIN = 2
-rbx.platform.socket.EAI_BADFLAGS = 3
-rbx.platform.socket.EAI_BADHINTS =
-rbx.platform.socket.EAI_FAIL = 4
-rbx.platform.socket.EAI_FAMILY = 5
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY = 6
-rbx.platform.socket.EAI_NODATA = 7
-rbx.platform.socket.EAI_NONAME = 8
-rbx.platform.socket.EAI_PROTOCOL =
-rbx.platform.socket.EAI_SERVICE = 9
-rbx.platform.socket.EAI_SOCKTYPE = 10
-rbx.platform.socket.EAI_SYSTEM = 11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE =
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 5000
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO = 63
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND = 77
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP =
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 19
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 20
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS =
-rbx.platform.socket.IP_MULTICAST_IF = 16
-rbx.platform.socket.IP_MULTICAST_LOOP = 18
-rbx.platform.socket.IP_MULTICAST_TTL = 17
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 16
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 128
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 32
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 4
-rbx.platform.socket.NI_NOFQDN = 1
-rbx.platform.socket.NI_NUMERICHOST = 2
-rbx.platform.socket.NI_NUMERICSERV = 8
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT =
-rbx.platform.socket.PF_COIP =
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 26
-rbx.platform.socket.PF_IPX = 23
-rbx.platform.socket.PF_ISDN =
-rbx.platform.socket.PF_ISO =
-rbx.platform.socket.PF_KEY = 27
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 25
-rbx.platform.socket.PF_LOCAL =
-rbx.platform.socket.PF_MAX = 29
-rbx.platform.socket.PF_NATM =
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS =
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 19
-rbx.platform.socket.PF_PIP =
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 24
-rbx.platform.socket.PF_RTIP =
-rbx.platform.socket.PF_SIP =
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP =
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 1
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 4
-rbx.platform.socket.SOCK_RDM = 5
-rbx.platform.socket.SOCK_SEQPACKET = 6
-rbx.platform.socket.SOCK_STREAM = 2
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT =
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP =
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 64
-rbx.platform.process.WUNTRACED = 4
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS =
-rbx.platform.process.RLIMIT_NPROC =
-rbx.platform.process.RLIMIT_NOFILE = 5
-rbx.platform.process.RLIMIT_MEMLOCK =
-rbx.platform.process.RLIMIT_AS = 6
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 18446744073709551613
-rbx.platform.process.RLIM_SAVED_MAX = 18446744073709551614
-rbx.platform.process.RLIM_SAVED_CUR = 18446744073709551615
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 21
-rbx.platform.signal.SIGSTOP = 23
-rbx.platform.signal.SIGTSTP = 24
-rbx.platform.signal.SIGCONT = 25
-rbx.platform.signal.SIGCHLD = 18
-rbx.platform.signal.SIGCLD = 18
-rbx.platform.signal.SIGTTIN = 26
-rbx.platform.signal.SIGTTOU = 27
-rbx.platform.signal.SIGIO = 22
-rbx.platform.signal.SIGXCPU = 30
-rbx.platform.signal.SIGXFSZ = 31
-rbx.platform.signal.SIGVTALRM = 28
-rbx.platform.signal.SIGPROF = 29
-rbx.platform.signal.SIGWINCH = 20
-rbx.platform.signal.SIGUSR1 = 16
-rbx.platform.signal.SIGUSR2 = 17
-rbx.platform.signal.SIGLOST = 37
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR = 19
-rbx.platform.signal.SIGPOLL = 22
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO =
-rbx.platform.zlib.ZLIB_VERSION = 1.1.4
-rbx.platform.typedef.lock_t = uchar
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.intptr_t = int
-rbx.platform.typedef.uintptr_t = uint
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = int
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = uint
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.t_scalar_t = long
-rbx.platform.typedef.t_uscalar_t = ulong
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.*caddr_t = char
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.ptrdiff_t = int
-rbx.platform.typedef.pfn_t = ulong
-rbx.platform.typedef.pgcnt_t = ulong
-rbx.platform.typedef.spgcnt_t = long
-rbx.platform.typedef.use_t = uchar
-rbx.platform.typedef.sysid_t = short
-rbx.platform.typedef.index_t = short
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.off64_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.blkcnt64_t = long_long
-rbx.platform.typedef.fsblkcnt64_t = ulong_long
-rbx.platform.typedef.fsfilcnt64_t = ulong_long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.pad64_t = long_long
-rbx.platform.typedef.upad64_t = ulong_long
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.u_offset_t = ulong_long
-rbx.platform.typedef.len_t = ulong_long
-rbx.platform.typedef.diskaddr_t = ulong_long
-rbx.platform.typedef.k_fltset_t = uint
-rbx.platform.typedef.id_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.major_t = ulong
-rbx.platform.typedef.minor_t = ulong
-rbx.platform.typedef.pri_t = short
-rbx.platform.typedef.cpu_flag_t = ushort
-rbx.platform.typedef.o_mode_t = ushort
-rbx.platform.typedef.o_dev_t = short
-rbx.platform.typedef.o_uid_t = ushort
-rbx.platform.typedef.o_gid_t = ushort
-rbx.platform.typedef.o_nlink_t = short
-rbx.platform.typedef.o_pid_t = short
-rbx.platform.typedef.o_ino_t = ushort
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ulong
-rbx.platform.typedef.uid_t = long
-rbx.platform.typedef.gid_t = long
-rbx.platform.typedef.taskid_t = long
-rbx.platform.typedef.projid_t = long
-rbx.platform.typedef.poolid_t = long
-rbx.platform.typedef.zoneid_t = long
-rbx.platform.typedef.ctid_t = long
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.pid_t = long
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.hrtime_t = long_long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.fds_mask = long
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.Psocklen_t = pointer
-rbx.platform.typedef.disp_lock_t = uchar
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.rlim64_t = ulong_long
-rbx.platform.typedef.kid_t = int
-rbx.platform.typedef.int) = pointer
-rbx.platform.typedef.size_t) = pointer
-rbx.platform.typedef.int) = pointer
-rbx.platform.typedef.avl_index_t = uint
-rbx.platform.typedef.() = pointer
-rbx.platform.typedef.nfds_t = ulong
-rbx.platform.typedef.model_t = uint
-rbx.platform.typedef.ts_t = long_long
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.ipaddr_t = uint
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/socket.rb b/src/main/resources/stdlib/ffi/platform/sparc-solaris/socket.rb
deleted file mode 100644
index 47d1386..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- # AF_CNT not available
- # AF_COIP not available
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- # AF_E164 not available
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 26
- AF_IPX = 23
- # AF_ISDN not available
- # AF_ISO not available
- AF_LAT = 14
- AF_LINK = 25
- # AF_LOCAL not available
- AF_MAX = 29
- # AF_NATM not available
- # AF_NDRV not available
- # AF_NETBIOS not available
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 19
- # AF_PPP not available
- AF_PUP = 4
- AF_ROUTE = 24
- # AF_SIP not available
- AF_SNA = 11
- # AF_SYSTEM not available
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- # NI_FQDN_FLAG_VALIDTTL not available
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 4
- # NI_NODEADDR_FLAG_ALL not available
- # NI_NODEADDR_FLAG_ANYCAST not available
- # NI_NODEADDR_FLAG_COMPAT not available
- # NI_NODEADDR_FLAG_GLOBAL not available
- # NI_NODEADDR_FLAG_LINKLOCAL not available
- # NI_NODEADDR_FLAG_SITELOCAL not available
- # NI_NODEADDR_FLAG_TRUNCATE not available
- NI_NOFQDN = 1
- NI_NUMERICHOST = 2
- NI_NUMERICSERV = 8
- # NI_QTYPE_DNSNAME not available
- # NI_QTYPE_FQDN not available
- # NI_QTYPE_IPV4ADDR not available
- # NI_QTYPE_NODEADDR not available
- # NI_QTYPE_NOOP not available
- # NI_QTYPE_SUPTYPES not available
- # NI_SUPTYPE_FLAG_COMPRESS not available
- NI_WITHSCOPEID = 32
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- # PF_CNT not available
- # PF_COIP not available
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 26
- PF_IPX = 23
- # PF_ISDN not available
- # PF_ISO not available
- PF_KEY = 27
- PF_LAT = 14
- PF_LINK = 25
- # PF_LOCAL not available
- PF_MAX = 29
- # PF_NATM not available
- # PF_NDRV not available
- # PF_NETBIOS not available
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 19
- # PF_PIP not available
- # PF_PPP not available
- PF_PUP = 4
- PF_ROUTE = 24
- # PF_RTIP not available
- # PF_SIP not available
- PF_SNA = 11
- # PF_SYSTEM not available
- PF_UNIX = 1
- PF_UNSPEC = 0
- # PF_XTP not available
- SOCK_DGRAM = 1
- # SOCK_MAXADDRLEN not available
- SOCK_RAW = 4
- SOCK_RDM = 5
- SOCK_SEQPACKET = 6
- SOCK_STREAM = 2
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- # SO_DONTTRUNC not available
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- # SO_LABEL not available
- SO_LINGER = 128
- # SO_NKE not available
- # SO_NOADDRERR not available
- # SO_NOSIGPIPE not available
- # SO_NO_CHECK not available
- # SO_NREAD not available
- # SO_NWRITE not available
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- # SO_PEERCRED not available
- # SO_PEERLABEL not available
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- # SO_REUSEPORT not available
- # SO_REUSESHAREUID not available
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- # SO_TIMESTAMP not available
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- # SO_WANTMORE not available
- # SO_WANTOOBFLAG not available
- # pseudo_AF_HDRCMPLT not available
- # pseudo_AF_KEY not available
- # pseudo_AF_PIP not available
- # pseudo_AF_RTIP not available
- # pseudo_AF_XTP not available
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/stat.rb b/src/main/resources/stdlib/ffi/platform/sparc-solaris/stat.rb
deleted file mode 100644
index f7f4d1d..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 152
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 16,
- :st_nlink, :nlink_t, 28,
- :st_mode, :mode_t, 24,
- :st_uid, :uid_t, 32,
- :st_gid, :gid_t, 36,
- :st_size, :off_t, 56,
- :st_blocks, :blkcnt_t, 96,
- :st_atime, :time_t, 64,
- :st_mtime, :time_t, 72,
- :st_ctime, :time_t, 80
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/sysconf.rb b/src/main/resources/stdlib/ffi/platform/sparc-solaris/sysconf.rb
deleted file mode 100644
index 53d6fff..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 66
- SC_2_C_BIND = 45
- SC_2_C_DEV = 46
- SC_2_FORT_DEV = 48
- SC_2_FORT_RUN = 49
- SC_2_LOCALEDEF = 50
- SC_2_PBS = 724
- SC_2_PBS_ACCOUNTING = 725
- SC_2_PBS_CHECKPOINT = 726
- SC_2_PBS_LOCATE = 728
- SC_2_PBS_MESSAGE = 729
- SC_2_PBS_TRACK = 730
- SC_2_SW_DEV = 51
- SC_2_UPE = 52
- SC_2_VERSION = 53
- SC_ADVISORY_INFO = 731
- SC_AIO_LISTIO_MAX = 18
- SC_AIO_MAX = 19
- SC_AIO_PRIO_DELTA_MAX = 20
- SC_ARG_MAX = 1
- SC_ASYNCHRONOUS_IO = 21
- SC_ATEXIT_MAX = 76
- SC_BARRIERS = 732
- SC_BC_BASE_MAX = 54
- SC_BC_DIM_MAX = 55
- SC_BC_SCALE_MAX = 56
- SC_BC_STRING_MAX = 57
- SC_CHILD_MAX = 2
- SC_CLK_TCK = 3
- SC_CLOCK_SELECTION = 733
- SC_COLL_WEIGHTS_MAX = 58
- SC_CPUTIME = 734
- SC_DELAYTIMER_MAX = 22
- SC_EXPR_NEST_MAX = 59
- # _SC_FILE_LOCKING not available
- SC_FSYNC = 23
- SC_GETGR_R_SIZE_MAX = 569
- SC_GETPW_R_SIZE_MAX = 570
- SC_HOST_NAME_MAX = 735
- SC_IOV_MAX = 77
- SC_IPV6 = 762
- SC_JOB_CONTROL = 6
- SC_LINE_MAX = 60
- SC_LOGIN_NAME_MAX = 571
- SC_MAPPED_FILES = 24
- SC_MEMLOCK = 25
- SC_MEMLOCK_RANGE = 26
- SC_MEMORY_PROTECTION = 27
- SC_MESSAGE_PASSING = 28
- SC_MONOTONIC_CLOCK = 736
- SC_MQ_OPEN_MAX = 29
- SC_MQ_PRIO_MAX = 30
- SC_NGROUPS_MAX = 4
- SC_NPROCESSORS_CONF = 14
- SC_NPROCESSORS_ONLN = 15
- SC_OPEN_MAX = 5
- SC_PAGESIZE = 11
- SC_PAGE_SIZE = 11
- SC_PASS_MAX = 9
- SC_PRIORITIZED_IO = 31
- SC_PRIORITY_SCHEDULING = 32
- SC_RAW_SOCKETS = 763
- SC_READER_WRITER_LOCKS = 737
- SC_REALTIME_SIGNALS = 33
- SC_REGEXP = 738
- SC_RE_DUP_MAX = 61
- SC_RTSIG_MAX = 34
- SC_SAVED_IDS = 7
- SC_SEMAPHORES = 35
- SC_SEM_NSEMS_MAX = 36
- SC_SEM_VALUE_MAX = 37
- SC_SHARED_MEMORY_OBJECTS = 38
- SC_SHELL = 739
- SC_SIGQUEUE_MAX = 39
- SC_SPAWN = 740
- SC_SPIN_LOCKS = 741
- SC_SPORADIC_SERVER = 742
- SC_SS_REPL_MAX = 743
- SC_STREAM_MAX = 16
- SC_SYMLOOP_MAX = 744
- SC_SYNCHRONIZED_IO = 42
- SC_THREADS = 576
- SC_THREAD_ATTR_STACKADDR = 577
- SC_THREAD_ATTR_STACKSIZE = 578
- SC_THREAD_CPUTIME = 745
- SC_THREAD_DESTRUCTOR_ITERATIONS = 568
- SC_THREAD_KEYS_MAX = 572
- SC_THREAD_PRIORITY_SCHEDULING = 579
- SC_THREAD_PRIO_INHERIT = 580
- SC_THREAD_PRIO_PROTECT = 581
- SC_THREAD_PROCESS_SHARED = 582
- SC_THREAD_SAFE_FUNCTIONS = 583
- SC_THREAD_SPORADIC_SERVER = 746
- SC_THREAD_STACK_MIN = 573
- SC_THREAD_THREADS_MAX = 574
- SC_TIMEOUTS = 747
- SC_TIMERS = 43
- SC_TIMER_MAX = 44
- SC_TRACE = 748
- SC_TRACE_EVENT_FILTER = 749
- SC_TRACE_EVENT_NAME_MAX = 750
- SC_TRACE_INHERIT = 751
- SC_TRACE_LOG = 752
- SC_TRACE_NAME_MAX = 753
- SC_TRACE_SYS_MAX = 754
- SC_TRACE_USER_EVENT_MAX = 755
- SC_TTY_NAME_MAX = 575
- SC_TYPED_MEMORY_OBJECTS = 756
- SC_TZNAME_MAX = 17
- SC_V6_ILP32_OFF32 = 757
- SC_V6_ILP32_OFFBIG = 758
- SC_V6_LP64_OFF64 = 759
- SC_V6_LPBIG_OFFBIG = 760
- SC_VERSION = 8
- SC_XBS5_ILP32_OFF32 = 720
- SC_XBS5_ILP32_OFFBIG = 721
- SC_XBS5_LP64_OFF64 = 722
- SC_XBS5_LPBIG_OFFBIG = 723
- SC_XOPEN_CRYPT = 62
- SC_XOPEN_ENH_I18N = 63
- SC_XOPEN_LEGACY = 717
- SC_XOPEN_REALTIME = 718
- SC_XOPEN_REALTIME_THREADS = 719
- SC_XOPEN_SHM = 64
- SC_XOPEN_STREAMS = 761
- SC_XOPEN_UNIX = 78
- SC_XOPEN_VERSION = 12
- SC_XOPEN_XCU_VERSION = 67
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/syslog.rb b/src/main/resources/stdlib/ffi/platform/sparc-solaris/syslog.rb
deleted file mode 100644
index 4f0f711..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- # LOG_AUTHPRIV not available
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 120
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- # LOG_FTP not available
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NEWS = 56
- # LOG_NODELAY not available
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- # LOG_PERROR not available
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/types.conf b/src/main/resources/stdlib/ffi/platform/sparc-solaris/types.conf
deleted file mode 100644
index c03c144..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/types.conf
+++ /dev/null
@@ -1,128 +0,0 @@
-rbx.platform.typedef.lock_t = uchar
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.intptr_t = int
-rbx.platform.typedef.uintptr_t = uint
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = int
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = uint
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.t_scalar_t = long
-rbx.platform.typedef.t_uscalar_t = ulong
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.*caddr_t = char
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.ptrdiff_t = int
-rbx.platform.typedef.pfn_t = ulong
-rbx.platform.typedef.pgcnt_t = ulong
-rbx.platform.typedef.spgcnt_t = long
-rbx.platform.typedef.use_t = uchar
-rbx.platform.typedef.sysid_t = short
-rbx.platform.typedef.index_t = short
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.off64_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.blkcnt64_t = long_long
-rbx.platform.typedef.fsblkcnt64_t = ulong_long
-rbx.platform.typedef.fsfilcnt64_t = ulong_long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.pad64_t = long_long
-rbx.platform.typedef.upad64_t = ulong_long
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.u_offset_t = ulong_long
-rbx.platform.typedef.len_t = ulong_long
-rbx.platform.typedef.diskaddr_t = ulong_long
-rbx.platform.typedef.k_fltset_t = uint
-rbx.platform.typedef.id_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.major_t = ulong
-rbx.platform.typedef.minor_t = ulong
-rbx.platform.typedef.pri_t = short
-rbx.platform.typedef.cpu_flag_t = ushort
-rbx.platform.typedef.o_mode_t = ushort
-rbx.platform.typedef.o_dev_t = short
-rbx.platform.typedef.o_uid_t = ushort
-rbx.platform.typedef.o_gid_t = ushort
-rbx.platform.typedef.o_nlink_t = short
-rbx.platform.typedef.o_pid_t = short
-rbx.platform.typedef.o_ino_t = ushort
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ulong
-rbx.platform.typedef.uid_t = long
-rbx.platform.typedef.gid_t = long
-rbx.platform.typedef.taskid_t = long
-rbx.platform.typedef.projid_t = long
-rbx.platform.typedef.poolid_t = long
-rbx.platform.typedef.zoneid_t = long
-rbx.platform.typedef.ctid_t = long
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.pid_t = long
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.hrtime_t = long_long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.fds_mask = long
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.Psocklen_t = pointer
-rbx.platform.typedef.disp_lock_t = uchar
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.rlim64_t = ulong_long
-rbx.platform.typedef.kid_t = int
-rbx.platform.typedef.int) = pointer
-rbx.platform.typedef.size_t) = pointer
-rbx.platform.typedef.int) = pointer
-rbx.platform.typedef.avl_index_t = uint
-rbx.platform.typedef.() = pointer
-rbx.platform.typedef.nfds_t = ulong
-rbx.platform.typedef.model_t = uint
-rbx.platform.typedef.ts_t = long_long
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.ipaddr_t = uint
diff --git a/src/main/resources/stdlib/ffi/platform/sparc-solaris/zlib.rb b/src/main/resources/stdlib/ffi/platform/sparc-solaris/zlib.rb
deleted file mode 100644
index a08f385..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparc-solaris/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 56
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 4,
- :total_in, :ulong, 8,
- :next_out, :pointer, 12,
- :avail_out, :uint, 16,
- :total_out, :ulong, 20,
- :msg, :string, 24,
- :state, :pointer, 28,
- :zalloc, :pointer, 32,
- :zfree, :pointer, 36,
- :opaque, :pointer, 40,
- :data_type, :int, 44,
- :adler, :ulong, 48,
- :reserved, :ulong, 52
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/errno.rb b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/errno.rb
deleted file mode 100644
index b89dab7..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 125
- EADDRNOTAVAIL = 126
- EAFNOSUPPORT = 124
- EAGAIN = 11
- EALREADY = 149
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 130
- ECONNREFUSED = 146
- ECONNRESET = 131
- EDEADLK = 45
- EDESTADDRREQ = 96
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 147
- EHOSTUNREACH = 148
- EINPROGRESS = 150
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 133
- EISDIR = 21
- ELOOP = 90
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 97
- ENAMETOOLONG = 78
- ENETDOWN = 127
- ENETRESET = 129
- ENETUNREACH = 128
- ENFILE = 23
- ENOBUFS = 132
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 99
- ENOSPC = 28
- ENOTCONN = 134
- ENOTDIR = 20
- ENOTEMPTY = 93
- ENOTSOCK = 95
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 122
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 120
- EPROTOTYPE = 98
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 145
- ETXTBSY = 26
- EWOULDBLOCK = 11
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/etc.rb b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/etc.rb
deleted file mode 100644
index cf7acee..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 36
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 4,
- :pw_uid, :uint, 8,
- :pw_gid, :uint, 12,
- :pw_dir, :string, 28,
- :pw_shell, :string, 32
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 16
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 8
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/fcntl.rb b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/fcntl.rb
deleted file mode 100644
index 75f07b2..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 33
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 34
- F_SETLKW = 35
- F_UNLCK = 3
- F_WRLCK = 2
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 256
- O_EXCL = 1024
- O_NDELAY = 4
- O_NOCTTY = 2048
- O_NONBLOCK = 128
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 512
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/platform.conf b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/platform.conf
deleted file mode 100644
index 07be5a6..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/platform.conf
+++ /dev/null
@@ -1,567 +0,0 @@
-rbx.platform.addrinfo.sizeof = 32
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 24
-rbx.platform.addrinfo.ai_addr.size = 4
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 20
-rbx.platform.addrinfo.ai_canonname.size = 4
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 28
-rbx.platform.addrinfo.ai_next.size = 4
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 24
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 16
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 18
-rbx.platform.dirent.d_name.size = 1
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 0
-rbx.platform.sockaddr_in.sin_family.size = 2
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 110
-rbx.platform.sockaddr_un.sun_family.offset = 0
-rbx.platform.sockaddr_un.sun_family.size = 2
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 108
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 152
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 16
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 24
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 28
-rbx.platform.stat.st_nlink.size = 4
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 32
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 36
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 40
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 56
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 88
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 96
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 64
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 72
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 80
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 256
-rbx.platform.file.O_EXCL = 1024
-rbx.platform.file.O_NOCTTY = 2048
-rbx.platform.file.O_TRUNC = 512
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 128
-rbx.platform.file.O_SYNC = 16
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT =
-rbx.platform.socket.AF_COIP =
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 =
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 26
-rbx.platform.socket.AF_IPX = 23
-rbx.platform.socket.AF_ISDN =
-rbx.platform.socket.AF_ISO =
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 25
-rbx.platform.socket.AF_LOCAL =
-rbx.platform.socket.AF_MAX = 29
-rbx.platform.socket.AF_NATM =
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS =
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 19
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 24
-rbx.platform.socket.AF_SIP =
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 4
-rbx.platform.socket.AI_ALL = 2
-rbx.platform.socket.AI_CANONNAME = 16
-rbx.platform.socket.AI_DEFAULT = 5
-rbx.platform.socket.AI_MASK =
-rbx.platform.socket.AI_NUMERICHOST = 32
-rbx.platform.socket.AI_PASSIVE = 8
-rbx.platform.socket.AI_V4MAPPED = 1
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY = 1
-rbx.platform.socket.EAI_AGAIN = 2
-rbx.platform.socket.EAI_BADFLAGS = 3
-rbx.platform.socket.EAI_BADHINTS =
-rbx.platform.socket.EAI_FAIL = 4
-rbx.platform.socket.EAI_FAMILY = 5
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY = 6
-rbx.platform.socket.EAI_NODATA = 7
-rbx.platform.socket.EAI_NONAME = 8
-rbx.platform.socket.EAI_PROTOCOL =
-rbx.platform.socket.EAI_SERVICE = 9
-rbx.platform.socket.EAI_SOCKTYPE = 10
-rbx.platform.socket.EAI_SYSTEM = 11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE =
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 5000
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO = 63
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND = 77
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP =
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 19
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 20
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS =
-rbx.platform.socket.IP_MULTICAST_IF = 16
-rbx.platform.socket.IP_MULTICAST_LOOP = 18
-rbx.platform.socket.IP_MULTICAST_TTL = 17
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 16
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 128
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 32
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 4
-rbx.platform.socket.NI_NOFQDN = 1
-rbx.platform.socket.NI_NUMERICHOST = 2
-rbx.platform.socket.NI_NUMERICSERV = 8
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT =
-rbx.platform.socket.PF_COIP =
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 26
-rbx.platform.socket.PF_IPX = 23
-rbx.platform.socket.PF_ISDN =
-rbx.platform.socket.PF_ISO =
-rbx.platform.socket.PF_KEY = 27
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 25
-rbx.platform.socket.PF_LOCAL =
-rbx.platform.socket.PF_MAX = 29
-rbx.platform.socket.PF_NATM =
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS =
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 19
-rbx.platform.socket.PF_PIP =
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 24
-rbx.platform.socket.PF_RTIP =
-rbx.platform.socket.PF_SIP =
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP =
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 1
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 4
-rbx.platform.socket.SOCK_RDM = 5
-rbx.platform.socket.SOCK_SEQPACKET = 6
-rbx.platform.socket.SOCK_STREAM = 2
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT =
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP =
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 64
-rbx.platform.process.WUNTRACED = 4
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS =
-rbx.platform.process.RLIMIT_NPROC =
-rbx.platform.process.RLIMIT_NOFILE = 5
-rbx.platform.process.RLIMIT_MEMLOCK =
-rbx.platform.process.RLIMIT_AS = 6
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 18446744073709551613
-rbx.platform.process.RLIM_SAVED_MAX = 18446744073709551614
-rbx.platform.process.RLIM_SAVED_CUR = 18446744073709551615
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 21
-rbx.platform.signal.SIGSTOP = 23
-rbx.platform.signal.SIGTSTP = 24
-rbx.platform.signal.SIGCONT = 25
-rbx.platform.signal.SIGCHLD = 18
-rbx.platform.signal.SIGCLD = 18
-rbx.platform.signal.SIGTTIN = 26
-rbx.platform.signal.SIGTTOU = 27
-rbx.platform.signal.SIGIO = 22
-rbx.platform.signal.SIGXCPU = 30
-rbx.platform.signal.SIGXFSZ = 31
-rbx.platform.signal.SIGVTALRM = 28
-rbx.platform.signal.SIGPROF = 29
-rbx.platform.signal.SIGWINCH = 20
-rbx.platform.signal.SIGUSR1 = 16
-rbx.platform.signal.SIGUSR2 = 17
-rbx.platform.signal.SIGLOST = 37
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR = 19
-rbx.platform.signal.SIGPOLL = 22
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO =
-rbx.platform.zlib.ZLIB_VERSION = 1.1.4
-rbx.platform.typedef.lock_t = uchar
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.intptr_t = int
-rbx.platform.typedef.uintptr_t = uint
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = int
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = uint
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.t_scalar_t = long
-rbx.platform.typedef.t_uscalar_t = ulong
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.*caddr_t = char
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.ptrdiff_t = int
-rbx.platform.typedef.pfn_t = ulong
-rbx.platform.typedef.pgcnt_t = ulong
-rbx.platform.typedef.spgcnt_t = long
-rbx.platform.typedef.use_t = uchar
-rbx.platform.typedef.sysid_t = short
-rbx.platform.typedef.index_t = short
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.off64_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.blkcnt64_t = long_long
-rbx.platform.typedef.fsblkcnt64_t = ulong_long
-rbx.platform.typedef.fsfilcnt64_t = ulong_long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.pad64_t = long_long
-rbx.platform.typedef.upad64_t = ulong_long
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.u_offset_t = ulong_long
-rbx.platform.typedef.len_t = ulong_long
-rbx.platform.typedef.diskaddr_t = ulong_long
-rbx.platform.typedef.k_fltset_t = uint
-rbx.platform.typedef.id_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.major_t = ulong
-rbx.platform.typedef.minor_t = ulong
-rbx.platform.typedef.pri_t = short
-rbx.platform.typedef.cpu_flag_t = ushort
-rbx.platform.typedef.o_mode_t = ushort
-rbx.platform.typedef.o_dev_t = short
-rbx.platform.typedef.o_uid_t = ushort
-rbx.platform.typedef.o_gid_t = ushort
-rbx.platform.typedef.o_nlink_t = short
-rbx.platform.typedef.o_pid_t = short
-rbx.platform.typedef.o_ino_t = ushort
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ulong
-rbx.platform.typedef.uid_t = long
-rbx.platform.typedef.gid_t = long
-rbx.platform.typedef.taskid_t = long
-rbx.platform.typedef.projid_t = long
-rbx.platform.typedef.poolid_t = long
-rbx.platform.typedef.zoneid_t = long
-rbx.platform.typedef.ctid_t = long
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.pid_t = long
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.hrtime_t = long_long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.fds_mask = long
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.Psocklen_t = pointer
-rbx.platform.typedef.disp_lock_t = uchar
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.rlim64_t = ulong_long
-rbx.platform.typedef.kid_t = int
-rbx.platform.typedef.int) = pointer
-rbx.platform.typedef.size_t) = pointer
-rbx.platform.typedef.int) = pointer
-rbx.platform.typedef.avl_index_t = uint
-rbx.platform.typedef.() = pointer
-rbx.platform.typedef.nfds_t = ulong
-rbx.platform.typedef.model_t = uint
-rbx.platform.typedef.ts_t = long_long
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.ipaddr_t = uint
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/socket.rb b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/socket.rb
deleted file mode 100644
index 47d1386..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- # AF_CNT not available
- # AF_COIP not available
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- # AF_E164 not available
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 26
- AF_IPX = 23
- # AF_ISDN not available
- # AF_ISO not available
- AF_LAT = 14
- AF_LINK = 25
- # AF_LOCAL not available
- AF_MAX = 29
- # AF_NATM not available
- # AF_NDRV not available
- # AF_NETBIOS not available
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 19
- # AF_PPP not available
- AF_PUP = 4
- AF_ROUTE = 24
- # AF_SIP not available
- AF_SNA = 11
- # AF_SYSTEM not available
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- # NI_FQDN_FLAG_VALIDTTL not available
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 4
- # NI_NODEADDR_FLAG_ALL not available
- # NI_NODEADDR_FLAG_ANYCAST not available
- # NI_NODEADDR_FLAG_COMPAT not available
- # NI_NODEADDR_FLAG_GLOBAL not available
- # NI_NODEADDR_FLAG_LINKLOCAL not available
- # NI_NODEADDR_FLAG_SITELOCAL not available
- # NI_NODEADDR_FLAG_TRUNCATE not available
- NI_NOFQDN = 1
- NI_NUMERICHOST = 2
- NI_NUMERICSERV = 8
- # NI_QTYPE_DNSNAME not available
- # NI_QTYPE_FQDN not available
- # NI_QTYPE_IPV4ADDR not available
- # NI_QTYPE_NODEADDR not available
- # NI_QTYPE_NOOP not available
- # NI_QTYPE_SUPTYPES not available
- # NI_SUPTYPE_FLAG_COMPRESS not available
- NI_WITHSCOPEID = 32
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- # PF_CNT not available
- # PF_COIP not available
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 26
- PF_IPX = 23
- # PF_ISDN not available
- # PF_ISO not available
- PF_KEY = 27
- PF_LAT = 14
- PF_LINK = 25
- # PF_LOCAL not available
- PF_MAX = 29
- # PF_NATM not available
- # PF_NDRV not available
- # PF_NETBIOS not available
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 19
- # PF_PIP not available
- # PF_PPP not available
- PF_PUP = 4
- PF_ROUTE = 24
- # PF_RTIP not available
- # PF_SIP not available
- PF_SNA = 11
- # PF_SYSTEM not available
- PF_UNIX = 1
- PF_UNSPEC = 0
- # PF_XTP not available
- SOCK_DGRAM = 1
- # SOCK_MAXADDRLEN not available
- SOCK_RAW = 4
- SOCK_RDM = 5
- SOCK_SEQPACKET = 6
- SOCK_STREAM = 2
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- # SO_DONTTRUNC not available
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- # SO_LABEL not available
- SO_LINGER = 128
- # SO_NKE not available
- # SO_NOADDRERR not available
- # SO_NOSIGPIPE not available
- # SO_NO_CHECK not available
- # SO_NREAD not available
- # SO_NWRITE not available
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- # SO_PEERCRED not available
- # SO_PEERLABEL not available
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- # SO_REUSEPORT not available
- # SO_REUSESHAREUID not available
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- # SO_TIMESTAMP not available
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- # SO_WANTMORE not available
- # SO_WANTOOBFLAG not available
- # pseudo_AF_HDRCMPLT not available
- # pseudo_AF_KEY not available
- # pseudo_AF_PIP not available
- # pseudo_AF_RTIP not available
- # pseudo_AF_XTP not available
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/stat.rb b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/stat.rb
deleted file mode 100644
index f7f4d1d..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 152
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 16,
- :st_nlink, :nlink_t, 28,
- :st_mode, :mode_t, 24,
- :st_uid, :uid_t, 32,
- :st_gid, :gid_t, 36,
- :st_size, :off_t, 56,
- :st_blocks, :blkcnt_t, 96,
- :st_atime, :time_t, 64,
- :st_mtime, :time_t, 72,
- :st_ctime, :time_t, 80
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/sysconf.rb b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/sysconf.rb
deleted file mode 100644
index 53d6fff..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 66
- SC_2_C_BIND = 45
- SC_2_C_DEV = 46
- SC_2_FORT_DEV = 48
- SC_2_FORT_RUN = 49
- SC_2_LOCALEDEF = 50
- SC_2_PBS = 724
- SC_2_PBS_ACCOUNTING = 725
- SC_2_PBS_CHECKPOINT = 726
- SC_2_PBS_LOCATE = 728
- SC_2_PBS_MESSAGE = 729
- SC_2_PBS_TRACK = 730
- SC_2_SW_DEV = 51
- SC_2_UPE = 52
- SC_2_VERSION = 53
- SC_ADVISORY_INFO = 731
- SC_AIO_LISTIO_MAX = 18
- SC_AIO_MAX = 19
- SC_AIO_PRIO_DELTA_MAX = 20
- SC_ARG_MAX = 1
- SC_ASYNCHRONOUS_IO = 21
- SC_ATEXIT_MAX = 76
- SC_BARRIERS = 732
- SC_BC_BASE_MAX = 54
- SC_BC_DIM_MAX = 55
- SC_BC_SCALE_MAX = 56
- SC_BC_STRING_MAX = 57
- SC_CHILD_MAX = 2
- SC_CLK_TCK = 3
- SC_CLOCK_SELECTION = 733
- SC_COLL_WEIGHTS_MAX = 58
- SC_CPUTIME = 734
- SC_DELAYTIMER_MAX = 22
- SC_EXPR_NEST_MAX = 59
- # _SC_FILE_LOCKING not available
- SC_FSYNC = 23
- SC_GETGR_R_SIZE_MAX = 569
- SC_GETPW_R_SIZE_MAX = 570
- SC_HOST_NAME_MAX = 735
- SC_IOV_MAX = 77
- SC_IPV6 = 762
- SC_JOB_CONTROL = 6
- SC_LINE_MAX = 60
- SC_LOGIN_NAME_MAX = 571
- SC_MAPPED_FILES = 24
- SC_MEMLOCK = 25
- SC_MEMLOCK_RANGE = 26
- SC_MEMORY_PROTECTION = 27
- SC_MESSAGE_PASSING = 28
- SC_MONOTONIC_CLOCK = 736
- SC_MQ_OPEN_MAX = 29
- SC_MQ_PRIO_MAX = 30
- SC_NGROUPS_MAX = 4
- SC_NPROCESSORS_CONF = 14
- SC_NPROCESSORS_ONLN = 15
- SC_OPEN_MAX = 5
- SC_PAGESIZE = 11
- SC_PAGE_SIZE = 11
- SC_PASS_MAX = 9
- SC_PRIORITIZED_IO = 31
- SC_PRIORITY_SCHEDULING = 32
- SC_RAW_SOCKETS = 763
- SC_READER_WRITER_LOCKS = 737
- SC_REALTIME_SIGNALS = 33
- SC_REGEXP = 738
- SC_RE_DUP_MAX = 61
- SC_RTSIG_MAX = 34
- SC_SAVED_IDS = 7
- SC_SEMAPHORES = 35
- SC_SEM_NSEMS_MAX = 36
- SC_SEM_VALUE_MAX = 37
- SC_SHARED_MEMORY_OBJECTS = 38
- SC_SHELL = 739
- SC_SIGQUEUE_MAX = 39
- SC_SPAWN = 740
- SC_SPIN_LOCKS = 741
- SC_SPORADIC_SERVER = 742
- SC_SS_REPL_MAX = 743
- SC_STREAM_MAX = 16
- SC_SYMLOOP_MAX = 744
- SC_SYNCHRONIZED_IO = 42
- SC_THREADS = 576
- SC_THREAD_ATTR_STACKADDR = 577
- SC_THREAD_ATTR_STACKSIZE = 578
- SC_THREAD_CPUTIME = 745
- SC_THREAD_DESTRUCTOR_ITERATIONS = 568
- SC_THREAD_KEYS_MAX = 572
- SC_THREAD_PRIORITY_SCHEDULING = 579
- SC_THREAD_PRIO_INHERIT = 580
- SC_THREAD_PRIO_PROTECT = 581
- SC_THREAD_PROCESS_SHARED = 582
- SC_THREAD_SAFE_FUNCTIONS = 583
- SC_THREAD_SPORADIC_SERVER = 746
- SC_THREAD_STACK_MIN = 573
- SC_THREAD_THREADS_MAX = 574
- SC_TIMEOUTS = 747
- SC_TIMERS = 43
- SC_TIMER_MAX = 44
- SC_TRACE = 748
- SC_TRACE_EVENT_FILTER = 749
- SC_TRACE_EVENT_NAME_MAX = 750
- SC_TRACE_INHERIT = 751
- SC_TRACE_LOG = 752
- SC_TRACE_NAME_MAX = 753
- SC_TRACE_SYS_MAX = 754
- SC_TRACE_USER_EVENT_MAX = 755
- SC_TTY_NAME_MAX = 575
- SC_TYPED_MEMORY_OBJECTS = 756
- SC_TZNAME_MAX = 17
- SC_V6_ILP32_OFF32 = 757
- SC_V6_ILP32_OFFBIG = 758
- SC_V6_LP64_OFF64 = 759
- SC_V6_LPBIG_OFFBIG = 760
- SC_VERSION = 8
- SC_XBS5_ILP32_OFF32 = 720
- SC_XBS5_ILP32_OFFBIG = 721
- SC_XBS5_LP64_OFF64 = 722
- SC_XBS5_LPBIG_OFFBIG = 723
- SC_XOPEN_CRYPT = 62
- SC_XOPEN_ENH_I18N = 63
- SC_XOPEN_LEGACY = 717
- SC_XOPEN_REALTIME = 718
- SC_XOPEN_REALTIME_THREADS = 719
- SC_XOPEN_SHM = 64
- SC_XOPEN_STREAMS = 761
- SC_XOPEN_UNIX = 78
- SC_XOPEN_VERSION = 12
- SC_XOPEN_XCU_VERSION = 67
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/syslog.rb b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/syslog.rb
deleted file mode 100644
index 4f0f711..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- # LOG_AUTHPRIV not available
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 120
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- # LOG_FTP not available
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NEWS = 56
- # LOG_NODELAY not available
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- # LOG_PERROR not available
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/types.conf b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/types.conf
deleted file mode 100644
index c03c144..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/types.conf
+++ /dev/null
@@ -1,128 +0,0 @@
-rbx.platform.typedef.lock_t = uchar
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.intptr_t = int
-rbx.platform.typedef.uintptr_t = uint
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = int
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = uint
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.t_scalar_t = long
-rbx.platform.typedef.t_uscalar_t = ulong
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.*caddr_t = char
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.ptrdiff_t = int
-rbx.platform.typedef.pfn_t = ulong
-rbx.platform.typedef.pgcnt_t = ulong
-rbx.platform.typedef.spgcnt_t = long
-rbx.platform.typedef.use_t = uchar
-rbx.platform.typedef.sysid_t = short
-rbx.platform.typedef.index_t = short
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.off64_t = long_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong_long
-rbx.platform.typedef.fsfilcnt_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.blkcnt64_t = long_long
-rbx.platform.typedef.fsblkcnt64_t = ulong_long
-rbx.platform.typedef.fsfilcnt64_t = ulong_long
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.pad64_t = long_long
-rbx.platform.typedef.upad64_t = ulong_long
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.u_offset_t = ulong_long
-rbx.platform.typedef.len_t = ulong_long
-rbx.platform.typedef.diskaddr_t = ulong_long
-rbx.platform.typedef.k_fltset_t = uint
-rbx.platform.typedef.id_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.major_t = ulong
-rbx.platform.typedef.minor_t = ulong
-rbx.platform.typedef.pri_t = short
-rbx.platform.typedef.cpu_flag_t = ushort
-rbx.platform.typedef.o_mode_t = ushort
-rbx.platform.typedef.o_dev_t = short
-rbx.platform.typedef.o_uid_t = ushort
-rbx.platform.typedef.o_gid_t = ushort
-rbx.platform.typedef.o_nlink_t = short
-rbx.platform.typedef.o_pid_t = short
-rbx.platform.typedef.o_ino_t = ushort
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ulong
-rbx.platform.typedef.uid_t = long
-rbx.platform.typedef.gid_t = long
-rbx.platform.typedef.taskid_t = long
-rbx.platform.typedef.projid_t = long
-rbx.platform.typedef.poolid_t = long
-rbx.platform.typedef.zoneid_t = long
-rbx.platform.typedef.ctid_t = long
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.pid_t = long
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.hrtime_t = long_long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.fds_mask = long
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.Psocklen_t = pointer
-rbx.platform.typedef.disp_lock_t = uchar
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.rlim64_t = ulong_long
-rbx.platform.typedef.kid_t = int
-rbx.platform.typedef.int) = pointer
-rbx.platform.typedef.size_t) = pointer
-rbx.platform.typedef.int) = pointer
-rbx.platform.typedef.avl_index_t = uint
-rbx.platform.typedef.() = pointer
-rbx.platform.typedef.nfds_t = ulong
-rbx.platform.typedef.model_t = uint
-rbx.platform.typedef.ts_t = long_long
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.ipaddr_t = uint
diff --git a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/zlib.rb b/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/zlib.rb
deleted file mode 100644
index a08f385..0000000
--- a/src/main/resources/stdlib/ffi/platform/sparcv9-solaris/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 56
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 4,
- :total_in, :ulong, 8,
- :next_out, :pointer, 12,
- :avail_out, :uint, 16,
- :total_out, :ulong, 20,
- :msg, :string, 24,
- :state, :pointer, 28,
- :zalloc, :pointer, 32,
- :zfree, :pointer, 36,
- :opaque, :pointer, 40,
- :data_type, :int, 44,
- :adler, :ulong, 48,
- :reserved, :ulong, 52
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/stat.rb.ffi b/src/main/resources/stdlib/ffi/platform/stat.rb.ffi
deleted file mode 100644
index 84938bf..0000000
--- a/src/main/resources/stdlib/ffi/platform/stat.rb.ffi
+++ /dev/null
@@ -1,53 +0,0 @@
-module Platform
- module Stat
- class Stat < FFI::Struct
- @@@
- struct do |s|
- s.include "sys/types.h"
- s.include "sys/stat.h"
-
- s.name "struct stat"
- s.field :st_dev, :dev_t
- s.field :st_ino, :ino_t
- s.field :st_nlink, :nlink_t
- s.field :st_mode, :mode_t
- s.field :st_uid, :uid_t
- s.field :st_gid, :gid_t
- s.field :st_size, :off_t
- s.field :st_blocks, :blkcnt_t
- s.field :st_atime, :time_t
- s.field :st_mtime, :time_t
- s.field :st_ctime, :time_t
- end
- @@@
- end
- module Constants
- @@@
- constants do |cg|
- cg.include "sys/types.h"
- cg.include "sys/stat.h"
- %w[
- S_ISUID
- S_ISGID
- S_IRUSR
- S_IWUSR
- S_IXUSR
- S_IRWXU
- S_IREAD
- S_IWRITE
- S_IEXEC
- S_IRGRP
- S_IWGRP
- S_IXGRP
- S_IRWXG
- S_IROTH
- S_IWOTH
- S_IXOTH
- S_IRWXO
- ].each {|c| cg.const(c, "%#x", "(unsigned int)") }
- end
- @@@
- end
- include Constants
- end
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/ffi/platform/sysconf.rb.ffi b/src/main/resources/stdlib/ffi/platform/sysconf.rb.ffi
deleted file mode 100644
index 24310a5..0000000
--- a/src/main/resources/stdlib/ffi/platform/sysconf.rb.ffi
+++ /dev/null
@@ -1,139 +0,0 @@
-module Platform;end
-module Platform::Sysconf
- @@@
- constants do |cg|
- cg.include "sys/types.h"
- cg.include "unistd.h"
- %w[
- _SC_ARG_MAX
- _SC_CHILD_MAX
- _SC_CLK_TCK
- _SC_NGROUPS_MAX
- _SC_OPEN_MAX
- _SC_JOB_CONTROL
- _SC_SAVED_IDS
- _SC_VERSION
- _SC_BC_BASE_MAX
- _SC_BC_DIM_MAX
- _SC_BC_SCALE_MAX
- _SC_BC_STRING_MAX
- _SC_COLL_WEIGHTS_MAX
- _SC_EXPR_NEST_MAX
- _SC_LINE_MAX
- _SC_RE_DUP_MAX
- _SC_2_VERSION
- _SC_2_C_BIND
- _SC_2_C_DEV
- _SC_2_CHAR_TERM
- _SC_2_FORT_DEV
- _SC_2_FORT_RUN
- _SC_2_LOCALEDEF
- _SC_2_SW_DEV
- _SC_2_UPE
- _SC_STREAM_MAX
- _SC_TZNAME_MAX
- _SC_ASYNCHRONOUS_IO
- _SC_PAGESIZE
- _SC_MEMLOCK
- _SC_MEMLOCK_RANGE
- _SC_MEMORY_PROTECTION
- _SC_MESSAGE_PASSING
- _SC_PRIORITIZED_IO
- _SC_PRIORITY_SCHEDULING
- _SC_REALTIME_SIGNALS
- _SC_SEMAPHORES
- _SC_FSYNC
- _SC_SHARED_MEMORY_OBJECTS
- _SC_SYNCHRONIZED_IO
- _SC_TIMERS
- _SC_AIO_LISTIO_MAX
- _SC_AIO_MAX
- _SC_AIO_PRIO_DELTA_MAX
- _SC_DELAYTIMER_MAX
- _SC_MQ_OPEN_MAX
- _SC_MAPPED_FILES
- _SC_RTSIG_MAX
- _SC_SEM_NSEMS_MAX
- _SC_SEM_VALUE_MAX
- _SC_SIGQUEUE_MAX
- _SC_TIMER_MAX
- _SC_NPROCESSORS_CONF
- _SC_NPROCESSORS_ONLN
- _SC_2_PBS
- _SC_2_PBS_ACCOUNTING
- _SC_2_PBS_CHECKPOINT
- _SC_2_PBS_LOCATE
- _SC_2_PBS_MESSAGE
- _SC_2_PBS_TRACK
- _SC_ADVISORY_INFO
- _SC_BARRIERS
- _SC_CLOCK_SELECTION
- _SC_CPUTIME
- _SC_FILE_LOCKING
- _SC_GETGR_R_SIZE_MAX
- _SC_GETPW_R_SIZE_MAX
- _SC_HOST_NAME_MAX
- _SC_LOGIN_NAME_MAX
- _SC_MONOTONIC_CLOCK
- _SC_MQ_PRIO_MAX
- _SC_READER_WRITER_LOCKS
- _SC_REGEXP
- _SC_SHELL
- _SC_SPAWN
- _SC_SPIN_LOCKS
- _SC_SPORADIC_SERVER
- _SC_THREAD_ATTR_STACKADDR
- _SC_THREAD_ATTR_STACKSIZE
- _SC_THREAD_CPUTIME
- _SC_THREAD_DESTRUCTOR_ITERATIONS
- _SC_THREAD_KEYS_MAX
- _SC_THREAD_PRIO_INHERIT
- _SC_THREAD_PRIO_PROTECT
- _SC_THREAD_PRIORITY_SCHEDULING
- _SC_THREAD_PROCESS_SHARED
- _SC_THREAD_SAFE_FUNCTIONS
- _SC_THREAD_SPORADIC_SERVER
- _SC_THREAD_STACK_MIN
- _SC_THREAD_THREADS_MAX
- _SC_TIMEOUTS
- _SC_THREADS
- _SC_TRACE
- _SC_TRACE_EVENT_FILTER
- _SC_TRACE_INHERIT
- _SC_TRACE_LOG
- _SC_TTY_NAME_MAX
- _SC_TYPED_MEMORY_OBJECTS
- _SC_V6_ILP32_OFF32
- _SC_V6_ILP32_OFFBIG
- _SC_V6_LP64_OFF64
- _SC_V6_LPBIG_OFFBIG
- _SC_IPV6
- _SC_RAW_SOCKETS
- _SC_SYMLOOP_MAX
- _SC_ATEXIT_MAX
- _SC_IOV_MAX
- _SC_PAGE_SIZE
- _SC_XOPEN_CRYPT
- _SC_XOPEN_ENH_I18N
- _SC_XOPEN_LEGACY
- _SC_XOPEN_REALTIME
- _SC_XOPEN_REALTIME_THREADS
- _SC_XOPEN_SHM
- _SC_XOPEN_STREAMS
- _SC_XOPEN_UNIX
- _SC_XOPEN_VERSION
- _SC_XOPEN_XCU_VERSION
- _SC_XBS5_ILP32_OFF32
- _SC_XBS5_ILP32_OFFBIG
- _SC_XBS5_LP64_OFF64
- _SC_XBS5_LPBIG_OFFBIG
- _SC_SS_REPL_MAX
- _SC_TRACE_EVENT_NAME_MAX
- _SC_TRACE_NAME_MAX
- _SC_TRACE_SYS_MAX
- _SC_TRACE_USER_EVENT_MAX
- _SC_PASS_MAX
- ].each {|c| cg.const(c, nil, '', c.sub(/^_/, '')) }
- end
- @@@
-end
diff --git a/src/main/resources/stdlib/ffi/platform/syslog.rb.ffi b/src/main/resources/stdlib/ffi/platform/syslog.rb.ffi
deleted file mode 100644
index 615a474..0000000
--- a/src/main/resources/stdlib/ffi/platform/syslog.rb.ffi
+++ /dev/null
@@ -1,47 +0,0 @@
-module Syslog
- module Constants
- @@@
- constants do |c|
- c.include 'syslog.h'
-
- c.const 'LOG_EMERG'
- c.const 'LOG_ALERT'
- c.const 'LOG_ERR'
- c.const 'LOG_CRIT'
- c.const 'LOG_WARNING'
- c.const 'LOG_NOTICE'
- c.const 'LOG_INFO'
- c.const 'LOG_DEBUG'
- c.const 'LOG_PID'
- c.const 'LOG_CONS'
- c.const 'LOG_ODELAY'
- c.const 'LOG_NDELAY'
- c.const 'LOG_NOWAIT'
- c.const 'LOG_PERROR'
- c.const 'LOG_AUTH'
- c.const 'LOG_AUTHPRIV'
- c.const 'LOG_CONSOLE'
- c.const 'LOG_CRON'
- c.const 'LOG_DAEMON'
- c.const 'LOG_FTP'
- c.const 'LOG_KERN'
- c.const 'LOG_LPR'
- c.const 'LOG_MAIL'
- c.const 'LOG_NEWS'
- c.const 'LOG_NTP'
- c.const 'LOG_SECURITY'
- c.const 'LOG_SYSLOG'
- c.const 'LOG_USER'
- c.const 'LOG_UUCP'
- c.const 'LOG_LOCAL0'
- c.const 'LOG_LOCAL1'
- c.const 'LOG_LOCAL2'
- c.const 'LOG_LOCAL3'
- c.const 'LOG_LOCAL4'
- c.const 'LOG_LOCAL5'
- c.const 'LOG_LOCAL6'
- c.const 'LOG_LOCAL7'
- end
- @@@
- end
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/errno.rb b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/errno.rb
deleted file mode 100644
index 12f09e0..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 48
- EADDRNOTAVAIL = 49
- EAFNOSUPPORT = 47
- EAGAIN = 35
- EALREADY = 37
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 53
- ECONNREFUSED = 61
- ECONNRESET = 54
- EDEADLK = 11
- EDESTADDRREQ = 39
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 64
- EHOSTUNREACH = 65
- EINPROGRESS = 36
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 56
- EISDIR = 21
- ELOOP = 62
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 40
- ENAMETOOLONG = 63
- ENETDOWN = 50
- ENETRESET = 52
- ENETUNREACH = 51
- ENFILE = 23
- ENOBUFS = 55
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 42
- ENOSPC = 28
- ENOTCONN = 57
- ENOTDIR = 20
- ENOTEMPTY = 66
- ENOTSOCK = 38
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 102
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 43
- EPROTOTYPE = 41
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 60
- ETXTBSY = 26
- EWOULDBLOCK = 35
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/etc.rb b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/etc.rb
deleted file mode 100644
index b52f6e1..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 72
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 8,
- :pw_uid, :uint, 16,
- :pw_gid, :uint, 20,
- :pw_dir, :string, 48,
- :pw_shell, :string, 56
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 32
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 16
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/fcntl.rb b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/fcntl.rb
deleted file mode 100644
index a5333f6..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 7
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 8
- F_SETLKW = 9
- F_UNLCK = 2
- F_WRLCK = 3
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 512
- O_EXCL = 2048
- O_NDELAY = 4
- O_NOCTTY = 131072
- O_NONBLOCK = 4
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 1024
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/platform.conf b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/platform.conf
deleted file mode 100644
index 5b02858..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/platform.conf
+++ /dev/null
@@ -1,539 +0,0 @@
-rbx.platform.addrinfo.sizeof = 48
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 32
-rbx.platform.addrinfo.ai_addr.size = 8
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 24
-rbx.platform.addrinfo.ai_canonname.size = 8
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 40
-rbx.platform.addrinfo.ai_next.size = 8
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 1048
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 16
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 21
-rbx.platform.dirent.d_name.size = 1024
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 16
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 8
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 8
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 1
-rbx.platform.sockaddr_in.sin_family.size = 1
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 106
-rbx.platform.sockaddr_un.sun_family.offset = 1
-rbx.platform.sockaddr_un.sun_family.size = 1
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 104
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 32
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 8
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 8
-rbx.platform.servent.s_aliases.size = 8
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 16
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 24
-rbx.platform.servent.s_proto.size = 8
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 144
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 8
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 4
-rbx.platform.stat.st_mode.size = 2
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 6
-rbx.platform.stat.st_nlink.size = 2
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 16
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 20
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 24
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 96
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 112
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 104
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 32
-rbx.platform.stat.st_atime.size = 8
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 48
-rbx.platform.stat.st_mtime.size = 8
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 64
-rbx.platform.stat.st_ctime.size = 8
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 512
-rbx.platform.file.O_EXCL = 2048
-rbx.platform.file.O_NOCTTY = 131072
-rbx.platform.file.O_TRUNC = 1024
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 4
-rbx.platform.file.O_SYNC = 128
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT = 57344
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT = 21
-rbx.platform.socket.AF_COIP = 20
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 = 28
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 30
-rbx.platform.socket.AF_IPX = 23
-rbx.platform.socket.AF_ISDN = 28
-rbx.platform.socket.AF_ISO = 7
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 18
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 37
-rbx.platform.socket.AF_NATM = 31
-rbx.platform.socket.AF_NDRV = 27
-rbx.platform.socket.AF_NETBIOS = 33
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 7
-rbx.platform.socket.AF_PPP = 34
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 17
-rbx.platform.socket.AF_SIP = 24
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM = 32
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 1024
-rbx.platform.socket.AI_ALL = 256
-rbx.platform.socket.AI_CANONNAME = 2
-rbx.platform.socket.AI_DEFAULT = 1536
-rbx.platform.socket.AI_MASK = 7
-rbx.platform.socket.AI_NUMERICHOST = 4
-rbx.platform.socket.AI_PASSIVE = 1
-rbx.platform.socket.AI_V4MAPPED = 2048
-rbx.platform.socket.AI_V4MAPPED_CFG = 512
-rbx.platform.socket.EAI_ADDRFAMILY = 1
-rbx.platform.socket.EAI_AGAIN = 2
-rbx.platform.socket.EAI_BADFLAGS = 3
-rbx.platform.socket.EAI_BADHINTS = 12
-rbx.platform.socket.EAI_FAIL = 4
-rbx.platform.socket.EAI_FAMILY = 5
-rbx.platform.socket.EAI_MAX = 14
-rbx.platform.socket.EAI_MEMORY = 6
-rbx.platform.socket.EAI_NODATA = 7
-rbx.platform.socket.EAI_NONAME = 8
-rbx.platform.socket.EAI_PROTOCOL = 13
-rbx.platform.socket.EAI_SERVICE = 9
-rbx.platform.socket.EAI_SOCKTYPE = 10
-rbx.platform.socket.EAI_SYSTEM = 11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = 3758096385
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = 4294967295
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = 3758096639
-rbx.platform.socket.INADDR_NONE = 4294967295
-rbx.platform.socket.INADDR_UNSPEC_GROUP = 3758096384
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 5000
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO = 63
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND = 77
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP = 29
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP = 36
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 12
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 13
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS = 20
-rbx.platform.socket.IP_MULTICAST_IF = 9
-rbx.platform.socket.IP_MULTICAST_LOOP = 11
-rbx.platform.socket.IP_MULTICAST_TTL = 10
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 32
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 128
-rbx.platform.socket.MSG_EOF = 256
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH = 1024
-rbx.platform.socket.MSG_HAVEMORE = 8192
-rbx.platform.socket.MSG_HOLD = 2048
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE = 16384
-rbx.platform.socket.MSG_SEND = 4096
-rbx.platform.socket.MSG_TRUNC = 16
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 4
-rbx.platform.socket.NI_NOFQDN = 1
-rbx.platform.socket.NI_NUMERICHOST = 2
-rbx.platform.socket.NI_NUMERICSERV = 8
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT = 21
-rbx.platform.socket.PF_COIP = 20
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 30
-rbx.platform.socket.PF_IPX = 23
-rbx.platform.socket.PF_ISDN = 28
-rbx.platform.socket.PF_ISO = 7
-rbx.platform.socket.PF_KEY = 29
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 18
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 37
-rbx.platform.socket.PF_NATM = 31
-rbx.platform.socket.PF_NDRV = 27
-rbx.platform.socket.PF_NETBIOS = 33
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 7
-rbx.platform.socket.PF_PIP = 25
-rbx.platform.socket.PF_PPP = 34
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 17
-rbx.platform.socket.PF_RTIP = 22
-rbx.platform.socket.PF_SIP = 24
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM = 32
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP = 19
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC = 8192
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE = 4129
-rbx.platform.socket.SO_NOSIGPIPE = 4130
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD = 4128
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT = 512
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP = 1024
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE = 16384
-rbx.platform.socket.SO_WANTOOBFLAG = 32768
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS = 5
-rbx.platform.process.RLIMIT_NPROC = 7
-rbx.platform.process.RLIMIT_NOFILE = 8
-rbx.platform.process.RLIMIT_MEMLOCK = 6
-rbx.platform.process.RLIMIT_AS = 5
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_MAX = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_CUR = 9223372036854775807
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 16
-rbx.platform.signal.SIGSTOP = 17
-rbx.platform.signal.SIGTSTP = 18
-rbx.platform.signal.SIGCONT = 19
-rbx.platform.signal.SIGCHLD = 20
-rbx.platform.signal.SIGCLD =
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 23
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 26
-rbx.platform.signal.SIGPROF = 27
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 30
-rbx.platform.signal.SIGUSR2 = 31
-rbx.platform.signal.SIGLOST =
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR =
-rbx.platform.signal.SIGPOLL =
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO = 29
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__darwin_intptr_t = long
-rbx.platform.typedef.__darwin_natural_t = uint
-rbx.platform.typedef.__darwin_ct_rune_t = int
-rbx.platform.typedef.__darwin_ptrdiff_t = long
-rbx.platform.typedef.__darwin_size_t = ulong
-rbx.platform.typedef.__darwin_wchar_t = int
-rbx.platform.typedef.__darwin_rune_t = int
-rbx.platform.typedef.__darwin_wint_t = int
-rbx.platform.typedef.__darwin_clock_t = ulong
-rbx.platform.typedef.__darwin_socklen_t = uint
-rbx.platform.typedef.__darwin_ssize_t = long
-rbx.platform.typedef.__darwin_time_t = long
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long_long
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.user_addr_t = ulong_long
-rbx.platform.typedef.user_size_t = ulong_long
-rbx.platform.typedef.user_ssize_t = long_long
-rbx.platform.typedef.user_long_t = long_long
-rbx.platform.typedef.user_ulong_t = ulong_long
-rbx.platform.typedef.user_time_t = long_long
-rbx.platform.typedef.syscall_arg_t = ulong_long
-rbx.platform.typedef.__darwin_blkcnt_t = long_long
-rbx.platform.typedef.__darwin_blksize_t = int
-rbx.platform.typedef.__darwin_dev_t = int
-rbx.platform.typedef.__darwin_fsblkcnt_t = uint
-rbx.platform.typedef.__darwin_fsfilcnt_t = uint
-rbx.platform.typedef.__darwin_gid_t = uint
-rbx.platform.typedef.__darwin_id_t = uint
-rbx.platform.typedef.__darwin_ino64_t = ulong_long
-rbx.platform.typedef.__darwin_ino_t = ulong_long
-rbx.platform.typedef.__darwin_mach_port_name_t = uint
-rbx.platform.typedef.__darwin_mach_port_t = uint
-rbx.platform.typedef.__darwin_mode_t = ushort
-rbx.platform.typedef.__darwin_off_t = long_long
-rbx.platform.typedef.__darwin_pid_t = int
-rbx.platform.typedef.__darwin_pthread_key_t = ulong
-rbx.platform.typedef.__darwin_sigset_t = uint
-rbx.platform.typedef.__darwin_suseconds_t = int
-rbx.platform.typedef.__darwin_uid_t = uint
-rbx.platform.typedef.__darwin_useconds_t = uint
-rbx.platform.typedef.__darwin_uuid_t[16] = uchar
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ushort
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.fd_mask = int
-rbx.platform.typedef.pthread_key_t = ulong
-rbx.platform.typedef.fsblkcnt_t = uint
-rbx.platform.typedef.fsfilcnt_t = uint
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.rlim_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/socket.rb b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/socket.rb
deleted file mode 100644
index dd121e7..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- AF_CNT = 21
- AF_COIP = 20
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- AF_E164 = 28
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 30
- AF_IPX = 23
- AF_ISDN = 28
- AF_ISO = 7
- AF_LAT = 14
- AF_LINK = 18
- AF_LOCAL = 1
- AF_MAX = 38
- AF_NATM = 31
- AF_NDRV = 27
- AF_NETBIOS = 33
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 7
- AF_PPP = 34
- AF_PUP = 4
- AF_ROUTE = 17
- AF_SIP = 24
- AF_SNA = 11
- AF_SYSTEM = 32
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- NI_FQDN_FLAG_VALIDTTL = 256
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 4
- NI_NODEADDR_FLAG_ALL = 512
- NI_NODEADDR_FLAG_ANYCAST = 16384
- NI_NODEADDR_FLAG_COMPAT = 1024
- NI_NODEADDR_FLAG_GLOBAL = 8192
- NI_NODEADDR_FLAG_LINKLOCAL = 2048
- NI_NODEADDR_FLAG_SITELOCAL = 4096
- NI_NODEADDR_FLAG_TRUNCATE = 256
- NI_NOFQDN = 1
- NI_NUMERICHOST = 2
- NI_NUMERICSERV = 8
- NI_QTYPE_DNSNAME = 2
- NI_QTYPE_FQDN = 2
- NI_QTYPE_IPV4ADDR = 4
- NI_QTYPE_NODEADDR = 3
- NI_QTYPE_NOOP = 0
- NI_QTYPE_SUPTYPES = 1
- NI_SUPTYPE_FLAG_COMPRESS = 256
- NI_WITHSCOPEID = 32
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- PF_CNT = 21
- PF_COIP = 20
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 30
- PF_IPX = 23
- PF_ISDN = 28
- PF_ISO = 7
- PF_KEY = 29
- PF_LAT = 14
- PF_LINK = 18
- PF_LOCAL = 1
- PF_MAX = 38
- PF_NATM = 31
- PF_NDRV = 27
- PF_NETBIOS = 33
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 7
- PF_PIP = 25
- PF_PPP = 34
- PF_PUP = 4
- PF_ROUTE = 17
- PF_RTIP = 22
- PF_SIP = 24
- PF_SNA = 11
- PF_SYSTEM = 32
- PF_UNIX = 1
- PF_UNSPEC = 0
- PF_XTP = 19
- SOCK_DGRAM = 2
- SOCK_MAXADDRLEN = 255
- SOCK_RAW = 3
- SOCK_RDM = 4
- SOCK_SEQPACKET = 5
- SOCK_STREAM = 1
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- SO_DONTTRUNC = 8192
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- SO_LABEL = 4112
- SO_LINGER = 128
- SO_NKE = 4129
- SO_NOADDRERR = 4131
- SO_NOSIGPIPE = 4130
- # SO_NO_CHECK not available
- SO_NREAD = 4128
- SO_NWRITE = 4132
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- # SO_PEERCRED not available
- SO_PEERLABEL = 4113
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- SO_REUSEPORT = 512
- SO_REUSESHAREUID = 4133
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- SO_TIMESTAMP = 1024
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- SO_WANTMORE = 16384
- SO_WANTOOBFLAG = 32768
- pseudo_AF_HDRCMPLT = 35
- pseudo_AF_KEY = 29
- pseudo_AF_PIP = 25
- pseudo_AF_RTIP = 22
- pseudo_AF_XTP = 19
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/stat.rb b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/stat.rb
deleted file mode 100644
index 927ebb2..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 144
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 8,
- :st_nlink, :nlink_t, 6,
- :st_mode, :mode_t, 4,
- :st_uid, :uid_t, 16,
- :st_gid, :gid_t, 20,
- :st_size, :off_t, 96,
- :st_blocks, :blkcnt_t, 104,
- :st_atime, :time_t, 32,
- :st_mtime, :time_t, 48,
- :st_ctime, :time_t, 64
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/sysconf.rb b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/sysconf.rb
deleted file mode 100644
index 8d80175..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 20
- SC_2_C_BIND = 18
- SC_2_C_DEV = 19
- SC_2_FORT_DEV = 21
- SC_2_FORT_RUN = 22
- SC_2_LOCALEDEF = 23
- SC_2_PBS = 59
- SC_2_PBS_ACCOUNTING = 60
- SC_2_PBS_CHECKPOINT = 61
- SC_2_PBS_LOCATE = 62
- SC_2_PBS_MESSAGE = 63
- SC_2_PBS_TRACK = 64
- SC_2_SW_DEV = 24
- SC_2_UPE = 25
- SC_2_VERSION = 17
- SC_ADVISORY_INFO = 65
- SC_AIO_LISTIO_MAX = 42
- SC_AIO_MAX = 43
- SC_AIO_PRIO_DELTA_MAX = 44
- SC_ARG_MAX = 1
- SC_ASYNCHRONOUS_IO = 28
- SC_ATEXIT_MAX = 107
- SC_BARRIERS = 66
- SC_BC_BASE_MAX = 9
- SC_BC_DIM_MAX = 10
- SC_BC_SCALE_MAX = 11
- SC_BC_STRING_MAX = 12
- SC_CHILD_MAX = 2
- SC_CLK_TCK = 3
- SC_CLOCK_SELECTION = 67
- SC_COLL_WEIGHTS_MAX = 13
- SC_CPUTIME = 68
- SC_DELAYTIMER_MAX = 45
- SC_EXPR_NEST_MAX = 14
- SC_FILE_LOCKING = 69
- SC_FSYNC = 38
- SC_GETGR_R_SIZE_MAX = 70
- SC_GETPW_R_SIZE_MAX = 71
- SC_HOST_NAME_MAX = 72
- SC_IOV_MAX = 56
- SC_IPV6 = 118
- SC_JOB_CONTROL = 6
- SC_LINE_MAX = 15
- SC_LOGIN_NAME_MAX = 73
- SC_MAPPED_FILES = 47
- SC_MEMLOCK = 30
- SC_MEMLOCK_RANGE = 31
- SC_MEMORY_PROTECTION = 32
- SC_MESSAGE_PASSING = 33
- SC_MONOTONIC_CLOCK = 74
- SC_MQ_OPEN_MAX = 46
- SC_MQ_PRIO_MAX = 75
- SC_NGROUPS_MAX = 4
- SC_NPROCESSORS_CONF = 57
- SC_NPROCESSORS_ONLN = 58
- SC_OPEN_MAX = 5
- SC_PAGESIZE = 29
- SC_PAGE_SIZE = 29
- SC_PASS_MAX = 131
- SC_PRIORITIZED_IO = 34
- SC_PRIORITY_SCHEDULING = 35
- SC_RAW_SOCKETS = 119
- SC_READER_WRITER_LOCKS = 76
- SC_REALTIME_SIGNALS = 36
- SC_REGEXP = 77
- SC_RE_DUP_MAX = 16
- SC_RTSIG_MAX = 48
- SC_SAVED_IDS = 7
- SC_SEMAPHORES = 37
- SC_SEM_NSEMS_MAX = 49
- SC_SEM_VALUE_MAX = 50
- SC_SHARED_MEMORY_OBJECTS = 39
- SC_SHELL = 78
- SC_SIGQUEUE_MAX = 51
- SC_SPAWN = 79
- SC_SPIN_LOCKS = 80
- SC_SPORADIC_SERVER = 81
- SC_SS_REPL_MAX = 126
- SC_STREAM_MAX = 26
- SC_SYMLOOP_MAX = 120
- SC_SYNCHRONIZED_IO = 40
- SC_THREADS = 96
- SC_THREAD_ATTR_STACKADDR = 82
- SC_THREAD_ATTR_STACKSIZE = 83
- SC_THREAD_CPUTIME = 84
- SC_THREAD_DESTRUCTOR_ITERATIONS = 85
- SC_THREAD_KEYS_MAX = 86
- SC_THREAD_PRIORITY_SCHEDULING = 89
- SC_THREAD_PRIO_INHERIT = 87
- SC_THREAD_PRIO_PROTECT = 88
- SC_THREAD_PROCESS_SHARED = 90
- SC_THREAD_SAFE_FUNCTIONS = 91
- SC_THREAD_SPORADIC_SERVER = 92
- SC_THREAD_STACK_MIN = 93
- SC_THREAD_THREADS_MAX = 94
- SC_TIMEOUTS = 95
- SC_TIMERS = 41
- SC_TIMER_MAX = 52
- SC_TRACE = 97
- SC_TRACE_EVENT_FILTER = 98
- SC_TRACE_EVENT_NAME_MAX = 127
- SC_TRACE_INHERIT = 99
- SC_TRACE_LOG = 100
- SC_TRACE_NAME_MAX = 128
- SC_TRACE_SYS_MAX = 129
- SC_TRACE_USER_EVENT_MAX = 130
- SC_TTY_NAME_MAX = 101
- SC_TYPED_MEMORY_OBJECTS = 102
- SC_TZNAME_MAX = 27
- SC_V6_ILP32_OFF32 = 103
- SC_V6_ILP32_OFFBIG = 104
- SC_V6_LP64_OFF64 = 105
- SC_V6_LPBIG_OFFBIG = 106
- SC_VERSION = 8
- SC_XBS5_ILP32_OFF32 = 122
- SC_XBS5_ILP32_OFFBIG = 123
- SC_XBS5_LP64_OFF64 = 124
- SC_XBS5_LPBIG_OFFBIG = 125
- SC_XOPEN_CRYPT = 108
- SC_XOPEN_ENH_I18N = 109
- SC_XOPEN_LEGACY = 110
- SC_XOPEN_REALTIME = 111
- SC_XOPEN_REALTIME_THREADS = 112
- SC_XOPEN_SHM = 113
- SC_XOPEN_STREAMS = 114
- SC_XOPEN_UNIX = 115
- SC_XOPEN_VERSION = 116
- SC_XOPEN_XCU_VERSION = 121
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/syslog.rb b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/syslog.rb
deleted file mode 100644
index d502940..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- LOG_FTP = 88
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NDELAY = 8
- LOG_NEWS = 56
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- LOG_PERROR = 32
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/types.conf b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/types.conf
deleted file mode 100644
index 0cec3bf..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/types.conf
+++ /dev/null
@@ -1,100 +0,0 @@
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__darwin_intptr_t = long
-rbx.platform.typedef.__darwin_natural_t = uint
-rbx.platform.typedef.__darwin_ct_rune_t = int
-rbx.platform.typedef.__darwin_ptrdiff_t = long
-rbx.platform.typedef.__darwin_size_t = ulong
-rbx.platform.typedef.__darwin_wchar_t = int
-rbx.platform.typedef.__darwin_rune_t = int
-rbx.platform.typedef.__darwin_wint_t = int
-rbx.platform.typedef.__darwin_clock_t = ulong
-rbx.platform.typedef.__darwin_socklen_t = uint
-rbx.platform.typedef.__darwin_ssize_t = long
-rbx.platform.typedef.__darwin_time_t = long
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long_long
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.user_addr_t = ulong_long
-rbx.platform.typedef.user_size_t = ulong_long
-rbx.platform.typedef.user_ssize_t = long_long
-rbx.platform.typedef.user_long_t = long_long
-rbx.platform.typedef.user_ulong_t = ulong_long
-rbx.platform.typedef.user_time_t = long_long
-rbx.platform.typedef.syscall_arg_t = ulong_long
-rbx.platform.typedef.__darwin_blkcnt_t = long_long
-rbx.platform.typedef.__darwin_blksize_t = int
-rbx.platform.typedef.__darwin_dev_t = int
-rbx.platform.typedef.__darwin_fsblkcnt_t = uint
-rbx.platform.typedef.__darwin_fsfilcnt_t = uint
-rbx.platform.typedef.__darwin_gid_t = uint
-rbx.platform.typedef.__darwin_id_t = uint
-rbx.platform.typedef.__darwin_ino64_t = ulong_long
-rbx.platform.typedef.__darwin_ino_t = ulong_long
-rbx.platform.typedef.__darwin_mach_port_name_t = uint
-rbx.platform.typedef.__darwin_mach_port_t = uint
-rbx.platform.typedef.__darwin_mode_t = ushort
-rbx.platform.typedef.__darwin_off_t = long_long
-rbx.platform.typedef.__darwin_pid_t = int
-rbx.platform.typedef.__darwin_pthread_key_t = ulong
-rbx.platform.typedef.__darwin_sigset_t = uint
-rbx.platform.typedef.__darwin_suseconds_t = int
-rbx.platform.typedef.__darwin_uid_t = uint
-rbx.platform.typedef.__darwin_useconds_t = uint
-rbx.platform.typedef.__darwin_uuid_t[16] = uchar
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.ino64_t = ulong_long
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = ushort
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.fd_mask = int
-rbx.platform.typedef.pthread_key_t = ulong
-rbx.platform.typedef.fsblkcnt_t = uint
-rbx.platform.typedef.fsfilcnt_t = uint
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.rlim_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/zlib.rb b/src/main/resources/stdlib/ffi/platform/x86_64-darwin/zlib.rb
deleted file mode 100644
index 38e3713..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-darwin/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 112
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 8,
- :total_in, :ulong, 16,
- :next_out, :pointer, 24,
- :avail_out, :uint, 32,
- :total_out, :ulong, 40,
- :msg, :string, 48,
- :state, :pointer, 56,
- :zalloc, :pointer, 64,
- :zfree, :pointer, 72,
- :opaque, :pointer, 80,
- :data_type, :int, 88,
- :adler, :ulong, 96,
- :reserved, :ulong, 104
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-freebsd/syslog.rb b/src/main/resources/stdlib/ffi/platform/x86_64-freebsd/syslog.rb
deleted file mode 100644
index 2066330..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-freebsd/syslog.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# This file hand crafted for FreeBSD, not via Rake
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- LOG_CONSOLE = 112
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- LOG_FTP = 88
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NEWS = 56
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- LOG_NTP = 96
- LOG_ODELAY = 4
- LOG_NDELAY = 8
- LOG_PERROR = 32
- LOG_PID = 1
- LOG_SECURITY = 104
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
- end
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-freebsd/types.conf b/src/main/resources/stdlib/ffi/platform/x86_64-freebsd/types.conf
deleted file mode 100644
index 33bd12b..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-freebsd/types.conf
+++ /dev/null
@@ -1,126 +0,0 @@
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__int_least8_t = char
-rbx.platform.typedef.__uint_least8_t = uchar
-rbx.platform.typedef.__int_least16_t = short
-rbx.platform.typedef.__uint_least16_t = ushort
-rbx.platform.typedef.__int_least32_t = int
-rbx.platform.typedef.__uint_least32_t = uint
-rbx.platform.typedef.__int_least64_t = long_long
-rbx.platform.typedef.__uint_least64_t = ulong_long
-rbx.platform.typedef.__int_fast8_t = int
-rbx.platform.typedef.__uint_fast8_t = uint
-rbx.platform.typedef.__int_fast16_t = int
-rbx.platform.typedef.__uint_fast16_t = uint
-rbx.platform.typedef.__int_fast32_t = int
-rbx.platform.typedef.__uint_fast32_t = uint
-rbx.platform.typedef.__int_fast64_t = long_long
-rbx.platform.typedef.__uint_fast64_t = ulong_long
-rbx.platform.typedef.__intptr_t = long
-rbx.platform.typedef.__uintptr_t = ulong
-rbx.platform.typedef.__intmax_t = long_long
-rbx.platform.typedef.__uintmax_t = ulong_long
-rbx.platform.typedef.__register_t = int
-rbx.platform.typedef.__vaddr_t = ulong
-rbx.platform.typedef.__paddr_t = ulong
-rbx.platform.typedef.__vsize_t = ulong
-rbx.platform.typedef.__psize_t = ulong
-rbx.platform.typedef.__clock_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__off_t = long_long
-rbx.platform.typedef.__ptrdiff_t = long
-rbx.platform.typedef.__size_t = ulong
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__time_t = int
-rbx.platform.typedef.__timer_t = int
-rbx.platform.typedef.__wchar_t = int
-rbx.platform.typedef.__wint_t = int
-rbx.platform.typedef.__rune_t = int
-rbx.platform.typedef.__wctrans_t = pointer
-rbx.platform.typedef.__wctype_t = pointer
-rbx.platform.typedef.__cpuid_t = ulong
-rbx.platform.typedef.__dev_t = int
-rbx.platform.typedef.__fixpt_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__in_addr_t = uint
-rbx.platform.typedef.__in_port_t = ushort
-rbx.platform.typedef.__ino_t = uint
-rbx.platform.typedef.__key_t = long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__rlim_t = ulong_long
-rbx.platform.typedef.__sa_family_t = uchar
-rbx.platform.typedef.__segsz_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.__swblk_t = int
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = int
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.cpuid_t = ulong
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.vaddr_t = ulong
-rbx.platform.typedef.paddr_t = ulong
-rbx.platform.typedef.vsize_t = ulong
-rbx.platform.typedef.psize_t = ulong
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.daddr32_t = int
-rbx.platform.typedef.daddr64_t = long_long
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ino_t = uint
-rbx.platform.typedef.key_t = long
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.clock_t = int
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.__fd_mask = int
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/errno.rb b/src/main/resources/stdlib/ffi/platform/x86_64-linux/errno.rb
deleted file mode 100644
index cb2014c..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 98
- EADDRNOTAVAIL = 99
- EAFNOSUPPORT = 97
- EAGAIN = 11
- EALREADY = 114
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 103
- ECONNREFUSED = 111
- ECONNRESET = 104
- EDEADLK = 35
- EDESTADDRREQ = 89
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 112
- EHOSTUNREACH = 113
- EINPROGRESS = 115
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 106
- EISDIR = 21
- ELOOP = 40
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 90
- ENAMETOOLONG = 36
- ENETDOWN = 100
- ENETRESET = 102
- ENETUNREACH = 101
- ENFILE = 23
- ENOBUFS = 105
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 92
- ENOSPC = 28
- ENOTCONN = 107
- ENOTDIR = 20
- ENOTEMPTY = 39
- ENOTSOCK = 88
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 95
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 93
- EPROTOTYPE = 91
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 110
- ETXTBSY = 26
- EWOULDBLOCK = 11
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/etc.rb b/src/main/resources/stdlib/ffi/platform/x86_64-linux/etc.rb
deleted file mode 100644
index c4861fe..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 48
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 8,
- :pw_uid, :uint, 16,
- :pw_gid, :uint, 20,
- :pw_dir, :string, 32,
- :pw_shell, :string, 40
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 32
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 16
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/fcntl.rb b/src/main/resources/stdlib/ffi/platform/x86_64-linux/fcntl.rb
deleted file mode 100644
index 6032c53..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 5
- F_RDLCK = 0
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 6
- F_SETLKW = 7
- F_UNLCK = 2
- F_WRLCK = 1
- O_ACCMODE = 3
- O_APPEND = 1024
- O_CREAT = 64
- O_EXCL = 128
- O_NDELAY = 2048
- O_NOCTTY = 256
- O_NONBLOCK = 2048
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 512
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/platform.conf b/src/main/resources/stdlib/ffi/platform/x86_64-linux/platform.conf
deleted file mode 100644
index 0b33878..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/platform.conf
+++ /dev/null
@@ -1,539 +0,0 @@
-rbx.platform.addrinfo.sizeof = 48
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 24
-rbx.platform.addrinfo.ai_addr.size = 8
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 32
-rbx.platform.addrinfo.ai_canonname.size = 8
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 40
-rbx.platform.addrinfo.ai_next.size = 8
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 280
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 16
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 19
-rbx.platform.dirent.d_name.size = 256
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 16
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 8
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 8
-rbx.platform.timeval.tv_usec.size = 8
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 0
-rbx.platform.sockaddr_in.sin_family.size = 2
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 110
-rbx.platform.sockaddr_un.sun_family.offset = 0
-rbx.platform.sockaddr_un.sun_family.size = 2
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 108
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 32
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 8
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 8
-rbx.platform.servent.s_aliases.size = 8
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 16
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 24
-rbx.platform.servent.s_proto.size = 8
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 144
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 8
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 8
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 24
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 16
-rbx.platform.stat.st_nlink.size = 8
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 28
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 32
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 40
-rbx.platform.stat.st_rdev.size = 8
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 48
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 56
-rbx.platform.stat.st_blksize.size = 8
-rbx.platform.stat.st_blocks.offset = 64
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 72
-rbx.platform.stat.st_atime.size = 8
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 88
-rbx.platform.stat.st_mtime.size = 8
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 104
-rbx.platform.stat.st_ctime.size = 8
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 64
-rbx.platform.file.O_EXCL = 128
-rbx.platform.file.O_NOCTTY = 256
-rbx.platform.file.O_TRUNC = 512
-rbx.platform.file.O_APPEND = 1024
-rbx.platform.file.O_NONBLOCK = 2048
-rbx.platform.file.O_SYNC = 4096
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 5
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 = 3
-rbx.platform.socket.AF_CCITT =
-rbx.platform.socket.AF_CHAOS =
-rbx.platform.socket.AF_CNT =
-rbx.platform.socket.AF_COIP =
-rbx.platform.socket.AF_DATAKIT =
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI =
-rbx.platform.socket.AF_E164 =
-rbx.platform.socket.AF_ECMA =
-rbx.platform.socket.AF_HYLINK =
-rbx.platform.socket.AF_IMPLINK =
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 10
-rbx.platform.socket.AF_IPX = 4
-rbx.platform.socket.AF_ISDN = 34
-rbx.platform.socket.AF_ISO =
-rbx.platform.socket.AF_LAT =
-rbx.platform.socket.AF_LINK =
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 35
-rbx.platform.socket.AF_NATM =
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS =
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS =
-rbx.platform.socket.AF_OSI =
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP =
-rbx.platform.socket.AF_ROUTE = 16
-rbx.platform.socket.AF_SIP =
-rbx.platform.socket.AF_SNA = 22
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 32
-rbx.platform.socket.AI_ALL = 16
-rbx.platform.socket.AI_CANONNAME = 2
-rbx.platform.socket.AI_DEFAULT =
-rbx.platform.socket.AI_MASK =
-rbx.platform.socket.AI_NUMERICHOST = 4
-rbx.platform.socket.AI_PASSIVE = 1
-rbx.platform.socket.AI_V4MAPPED = 8
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY =
-rbx.platform.socket.EAI_AGAIN = -3
-rbx.platform.socket.EAI_BADFLAGS = -1
-rbx.platform.socket.EAI_BADHINTS =
-rbx.platform.socket.EAI_FAIL = -4
-rbx.platform.socket.EAI_FAMILY = -6
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY = -10
-rbx.platform.socket.EAI_NODATA =
-rbx.platform.socket.EAI_NONAME = -2
-rbx.platform.socket.EAI_PROTOCOL =
-rbx.platform.socket.EAI_SERVICE = -8
-rbx.platform.socket.EAI_SOCKTYPE = -7
-rbx.platform.socket.EAI_SYSTEM = -11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = 3758096385
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = 4294967295
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = 3758096639
-rbx.platform.socket.INADDR_NONE = 4294967295
-rbx.platform.socket.INADDR_UNSPEC_GROUP = 3758096384
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED =
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON =
-rbx.platform.socket.IPPROTO_GGP =
-rbx.platform.socket.IPPROTO_HELLO =
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX =
-rbx.platform.socket.IPPROTO_ND =
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP = 29
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 35
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 36
-rbx.platform.socket.IP_HDRINCL = 3
-rbx.platform.socket.IP_MAX_MEMBERSHIPS = 20
-rbx.platform.socket.IP_MULTICAST_IF = 32
-rbx.platform.socket.IP_MULTICAST_LOOP = 34
-rbx.platform.socket.IP_MULTICAST_TTL = 33
-rbx.platform.socket.IP_OPTIONS = 4
-rbx.platform.socket.IP_RECVDSTADDR =
-rbx.platform.socket.IP_RECVOPTS = 6
-rbx.platform.socket.IP_RECVRETOPTS = 7
-rbx.platform.socket.IP_RETOPTS = 7
-rbx.platform.socket.IP_TOS = 1
-rbx.platform.socket.IP_TTL = 2
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 8
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 64
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR = 128
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 32
-rbx.platform.socket.MSG_WAITALL = 256
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 8
-rbx.platform.socket.NI_NOFQDN = 4
-rbx.platform.socket.NI_NUMERICHOST = 1
-rbx.platform.socket.NI_NUMERICSERV = 2
-rbx.platform.socket.PF_APPLETALK = 5
-rbx.platform.socket.PF_AX25 = 3
-rbx.platform.socket.PF_CCITT =
-rbx.platform.socket.PF_CHAOS =
-rbx.platform.socket.PF_CNT =
-rbx.platform.socket.PF_COIP =
-rbx.platform.socket.PF_DATAKIT =
-rbx.platform.socket.PF_DLI =
-rbx.platform.socket.PF_ECMA =
-rbx.platform.socket.PF_HYLINK =
-rbx.platform.socket.PF_IMPLINK =
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 10
-rbx.platform.socket.PF_IPX = 4
-rbx.platform.socket.PF_ISDN = 34
-rbx.platform.socket.PF_ISO =
-rbx.platform.socket.PF_KEY = 15
-rbx.platform.socket.PF_LAT =
-rbx.platform.socket.PF_LINK =
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 35
-rbx.platform.socket.PF_NATM =
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS =
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS =
-rbx.platform.socket.PF_OSI =
-rbx.platform.socket.PF_PIP =
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP =
-rbx.platform.socket.PF_ROUTE = 16
-rbx.platform.socket.PF_RTIP =
-rbx.platform.socket.PF_SIP =
-rbx.platform.socket.PF_SNA = 22
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP =
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET = 10
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP = 0
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 1
-rbx.platform.socket.SOL_TCP = 6
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 30
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER = 26
-rbx.platform.socket.SO_BINDTODEVICE = 25
-rbx.platform.socket.SO_BROADCAST = 6
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER = 27
-rbx.platform.socket.SO_DONTROUTE = 5
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4
-rbx.platform.socket.SO_KEEPALIVE = 9
-rbx.platform.socket.SO_LINGER = 13
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK = 11
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 10
-rbx.platform.socket.SO_PASSCRED = 16
-rbx.platform.socket.SO_PEERCRED = 17
-rbx.platform.socket.SO_PEERNAME = 28
-rbx.platform.socket.SO_PRIORITY = 12
-rbx.platform.socket.SO_RCVBUF = 8
-rbx.platform.socket.SO_RCVLOWAT = 18
-rbx.platform.socket.SO_RCVTIMEO = 20
-rbx.platform.socket.SO_REUSEADDR = 2
-rbx.platform.socket.SO_REUSEPORT =
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION = 22
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK = 24
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT = 23
-rbx.platform.socket.SO_SNDBUF = 7
-rbx.platform.socket.SO_SNDLOWAT = 19
-rbx.platform.socket.SO_SNDTIMEO = 21
-rbx.platform.socket.SO_TIMESTAMP = 29
-rbx.platform.socket.SO_TYPE = 3
-rbx.platform.socket.SO_USELOOPBACK =
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS = 5
-rbx.platform.process.RLIMIT_NPROC = 6
-rbx.platform.process.RLIMIT_NOFILE = 7
-rbx.platform.process.RLIMIT_MEMLOCK = 8
-rbx.platform.process.RLIMIT_AS = 9
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 18446744073709551615
-rbx.platform.process.RLIM_SAVED_MAX = 18446744073709551615
-rbx.platform.process.RLIM_SAVED_CUR = 18446744073709551615
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT =
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 7
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 31
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 23
-rbx.platform.signal.SIGSTOP = 19
-rbx.platform.signal.SIGTSTP = 20
-rbx.platform.signal.SIGCONT = 18
-rbx.platform.signal.SIGCHLD = 17
-rbx.platform.signal.SIGCLD = 17
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 29
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 26
-rbx.platform.signal.SIGPROF = 27
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 10
-rbx.platform.signal.SIGUSR2 = 12
-rbx.platform.signal.SIGLOST =
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR = 30
-rbx.platform.signal.SIGPOLL = 29
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO =
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long
-rbx.platform.typedef.__uint64_t = ulong
-rbx.platform.typedef.__quad_t = long
-rbx.platform.typedef.__u_quad_t = ulong
-rbx.platform.typedef.__dev_t = ulong
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = ulong
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__loff_t = long
-rbx.platform.typedef.*__qaddr_t = long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = long
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long
-rbx.platform.typedef.u_quad_t = ulong
-rbx.platform.typedef.loff_t = long
-rbx.platform.typedef.ino_t = ulong
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blkcnt_t = long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/socket.rb b/src/main/resources/stdlib/ffi/platform/x86_64-linux/socket.rb
deleted file mode 100644
index 6470eda..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 5
- # AF_ATM not available
- AF_AX25 = 3
- # AF_CCITT not available
- # AF_CHAOS not available
- # AF_CNT not available
- # AF_COIP not available
- # AF_DATAKIT not available
- AF_DECnet = 12
- # AF_DLI not available
- # AF_E164 not available
- # AF_ECMA not available
- # AF_HYLINK not available
- # AF_IMPLINK not available
- AF_INET = 2
- AF_INET6 = 10
- AF_IPX = 4
- AF_ISDN = 34
- # AF_ISO not available
- # AF_LAT not available
- # AF_LINK not available
- AF_LOCAL = 1
- AF_MAX = 37
- # AF_NATM not available
- # AF_NDRV not available
- # AF_NETBIOS not available
- # AF_NETGRAPH not available
- # AF_NS not available
- # AF_OSI not available
- # AF_PPP not available
- # AF_PUP not available
- AF_ROUTE = 16
- # AF_SIP not available
- AF_SNA = 22
- # AF_SYSTEM not available
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- # NI_FQDN_FLAG_VALIDTTL not available
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 8
- # NI_NODEADDR_FLAG_ALL not available
- # NI_NODEADDR_FLAG_ANYCAST not available
- # NI_NODEADDR_FLAG_COMPAT not available
- # NI_NODEADDR_FLAG_GLOBAL not available
- # NI_NODEADDR_FLAG_LINKLOCAL not available
- # NI_NODEADDR_FLAG_SITELOCAL not available
- # NI_NODEADDR_FLAG_TRUNCATE not available
- NI_NOFQDN = 4
- NI_NUMERICHOST = 1
- NI_NUMERICSERV = 2
- # NI_QTYPE_DNSNAME not available
- # NI_QTYPE_FQDN not available
- # NI_QTYPE_IPV4ADDR not available
- # NI_QTYPE_NODEADDR not available
- # NI_QTYPE_NOOP not available
- # NI_QTYPE_SUPTYPES not available
- # NI_SUPTYPE_FLAG_COMPRESS not available
- # NI_WITHSCOPEID not available
- PF_APPLETALK = 5
- # PF_ATM not available
- # PF_CCITT not available
- # PF_CHAOS not available
- # PF_CNT not available
- # PF_COIP not available
- # PF_DATAKIT not available
- PF_DECnet = 12
- # PF_DLI not available
- # PF_ECMA not available
- # PF_HYLINK not available
- # PF_IMPLINK not available
- PF_INET = 2
- PF_INET6 = 10
- PF_IPX = 4
- PF_ISDN = 34
- # PF_ISO not available
- PF_KEY = 15
- # PF_LAT not available
- # PF_LINK not available
- PF_LOCAL = 1
- PF_MAX = 37
- # PF_NATM not available
- # PF_NDRV not available
- # PF_NETBIOS not available
- # PF_NETGRAPH not available
- # PF_NS not available
- # PF_OSI not available
- # PF_PIP not available
- # PF_PPP not available
- # PF_PUP not available
- PF_ROUTE = 16
- # PF_RTIP not available
- # PF_SIP not available
- PF_SNA = 22
- # PF_SYSTEM not available
- PF_UNIX = 1
- PF_UNSPEC = 0
- # PF_XTP not available
- SOCK_DGRAM = 2
- # SOCK_MAXADDRLEN not available
- SOCK_RAW = 3
- SOCK_RDM = 4
- SOCK_SEQPACKET = 5
- SOCK_STREAM = 1
- SO_ACCEPTCONN = 30
- # SO_ACCEPTFILTER not available
- SO_ATTACH_FILTER = 26
- SO_BINDTODEVICE = 25
- SO_BROADCAST = 6
- SO_DEBUG = 1
- SO_DETACH_FILTER = 27
- SO_DONTROUTE = 5
- # SO_DONTTRUNC not available
- SO_ERROR = 4
- SO_KEEPALIVE = 9
- # SO_LABEL not available
- SO_LINGER = 13
- # SO_NKE not available
- # SO_NOADDRERR not available
- # SO_NOSIGPIPE not available
- SO_NO_CHECK = 11
- # SO_NREAD not available
- # SO_NWRITE not available
- SO_OOBINLINE = 10
- SO_PASSCRED = 16
- SO_PEERCRED = 17
- # SO_PEERLABEL not available
- SO_PEERNAME = 28
- SO_PRIORITY = 12
- SO_RCVBUF = 8
- SO_RCVLOWAT = 18
- SO_RCVTIMEO = 20
- SO_REUSEADDR = 2
- # SO_REUSEPORT not available
- # SO_REUSESHAREUID not available
- SO_SECURITY_AUTHENTICATION = 22
- SO_SECURITY_ENCRYPTION_NETWORK = 24
- SO_SECURITY_ENCRYPTION_TRANSPORT = 23
- SO_SNDBUF = 7
- SO_SNDLOWAT = 19
- SO_SNDTIMEO = 21
- SO_TIMESTAMP = 29
- SO_TYPE = 3
- # SO_USELOOPBACK not available
- # SO_WANTMORE not available
- # SO_WANTOOBFLAG not available
- # pseudo_AF_HDRCMPLT not available
- # pseudo_AF_KEY not available
- # pseudo_AF_PIP not available
- # pseudo_AF_RTIP not available
- # pseudo_AF_XTP not available
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/stat.rb b/src/main/resources/stdlib/ffi/platform/x86_64-linux/stat.rb
deleted file mode 100644
index 6622481..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 144
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 8,
- :st_nlink, :nlink_t, 16,
- :st_mode, :mode_t, 24,
- :st_uid, :uid_t, 28,
- :st_gid, :gid_t, 32,
- :st_size, :off_t, 48,
- :st_blocks, :blkcnt_t, 64,
- :st_atime, :time_t, 72,
- :st_mtime, :time_t, 88,
- :st_ctime, :time_t, 104
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/sysconf.rb b/src/main/resources/stdlib/ffi/platform/x86_64-linux/sysconf.rb
deleted file mode 100644
index 783458e..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 95
- SC_2_C_BIND = 47
- SC_2_C_DEV = 48
- SC_2_FORT_DEV = 49
- SC_2_FORT_RUN = 50
- SC_2_LOCALEDEF = 52
- SC_2_PBS = 168
- SC_2_PBS_ACCOUNTING = 169
- SC_2_PBS_CHECKPOINT = 175
- SC_2_PBS_LOCATE = 170
- SC_2_PBS_MESSAGE = 171
- SC_2_PBS_TRACK = 172
- SC_2_SW_DEV = 51
- SC_2_UPE = 97
- SC_2_VERSION = 46
- SC_ADVISORY_INFO = 132
- SC_AIO_LISTIO_MAX = 23
- SC_AIO_MAX = 24
- SC_AIO_PRIO_DELTA_MAX = 25
- SC_ARG_MAX = 0
- SC_ASYNCHRONOUS_IO = 12
- SC_ATEXIT_MAX = 87
- SC_BARRIERS = 133
- SC_BC_BASE_MAX = 36
- SC_BC_DIM_MAX = 37
- SC_BC_SCALE_MAX = 38
- SC_BC_STRING_MAX = 39
- SC_CHILD_MAX = 1
- SC_CLK_TCK = 2
- SC_CLOCK_SELECTION = 137
- SC_COLL_WEIGHTS_MAX = 40
- SC_CPUTIME = 138
- SC_DELAYTIMER_MAX = 26
- SC_EXPR_NEST_MAX = 42
- SC_FILE_LOCKING = 147
- SC_FSYNC = 15
- SC_GETGR_R_SIZE_MAX = 69
- SC_GETPW_R_SIZE_MAX = 70
- SC_HOST_NAME_MAX = 180
- SC_IOV_MAX = 60
- SC_IPV6 = 235
- SC_JOB_CONTROL = 7
- SC_LINE_MAX = 43
- SC_LOGIN_NAME_MAX = 71
- SC_MAPPED_FILES = 16
- SC_MEMLOCK = 17
- SC_MEMLOCK_RANGE = 18
- SC_MEMORY_PROTECTION = 19
- SC_MESSAGE_PASSING = 20
- SC_MONOTONIC_CLOCK = 149
- SC_MQ_OPEN_MAX = 27
- SC_MQ_PRIO_MAX = 28
- SC_NGROUPS_MAX = 3
- SC_NPROCESSORS_CONF = 83
- SC_NPROCESSORS_ONLN = 84
- SC_OPEN_MAX = 4
- SC_PAGESIZE = 30
- SC_PAGE_SIZE = 30
- SC_PASS_MAX = 88
- SC_PRIORITIZED_IO = 13
- SC_PRIORITY_SCHEDULING = 10
- SC_RAW_SOCKETS = 236
- SC_READER_WRITER_LOCKS = 153
- SC_REALTIME_SIGNALS = 9
- SC_REGEXP = 155
- SC_RE_DUP_MAX = 44
- SC_RTSIG_MAX = 31
- SC_SAVED_IDS = 8
- SC_SEMAPHORES = 21
- SC_SEM_NSEMS_MAX = 32
- SC_SEM_VALUE_MAX = 33
- SC_SHARED_MEMORY_OBJECTS = 22
- SC_SHELL = 157
- SC_SIGQUEUE_MAX = 34
- SC_SPAWN = 159
- SC_SPIN_LOCKS = 154
- SC_SPORADIC_SERVER = 160
- SC_SS_REPL_MAX = 241
- SC_STREAM_MAX = 5
- SC_SYMLOOP_MAX = 173
- SC_SYNCHRONIZED_IO = 14
- SC_THREADS = 67
- SC_THREAD_ATTR_STACKADDR = 77
- SC_THREAD_ATTR_STACKSIZE = 78
- SC_THREAD_CPUTIME = 139
- SC_THREAD_DESTRUCTOR_ITERATIONS = 73
- SC_THREAD_KEYS_MAX = 74
- SC_THREAD_PRIORITY_SCHEDULING = 79
- SC_THREAD_PRIO_INHERIT = 80
- SC_THREAD_PRIO_PROTECT = 81
- SC_THREAD_PROCESS_SHARED = 82
- SC_THREAD_SAFE_FUNCTIONS = 68
- SC_THREAD_SPORADIC_SERVER = 161
- SC_THREAD_STACK_MIN = 75
- SC_THREAD_THREADS_MAX = 76
- SC_TIMEOUTS = 164
- SC_TIMERS = 11
- SC_TIMER_MAX = 35
- SC_TRACE = 181
- SC_TRACE_EVENT_FILTER = 182
- SC_TRACE_EVENT_NAME_MAX = 242
- SC_TRACE_INHERIT = 183
- SC_TRACE_LOG = 184
- SC_TRACE_NAME_MAX = 243
- SC_TRACE_SYS_MAX = 244
- SC_TRACE_USER_EVENT_MAX = 245
- SC_TTY_NAME_MAX = 72
- SC_TYPED_MEMORY_OBJECTS = 165
- SC_TZNAME_MAX = 6
- SC_V6_ILP32_OFF32 = 176
- SC_V6_ILP32_OFFBIG = 177
- SC_V6_LP64_OFF64 = 178
- SC_V6_LPBIG_OFFBIG = 179
- SC_VERSION = 29
- SC_XBS5_ILP32_OFF32 = 125
- SC_XBS5_ILP32_OFFBIG = 126
- SC_XBS5_LP64_OFF64 = 127
- SC_XBS5_LPBIG_OFFBIG = 128
- SC_XOPEN_CRYPT = 92
- SC_XOPEN_ENH_I18N = 93
- SC_XOPEN_LEGACY = 129
- SC_XOPEN_REALTIME = 130
- SC_XOPEN_REALTIME_THREADS = 131
- SC_XOPEN_SHM = 94
- SC_XOPEN_STREAMS = 246
- SC_XOPEN_UNIX = 91
- SC_XOPEN_VERSION = 89
- SC_XOPEN_XCU_VERSION = 90
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/syslog.rb b/src/main/resources/stdlib/ffi/platform/x86_64-linux/syslog.rb
deleted file mode 100644
index d502940..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- LOG_FTP = 88
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NDELAY = 8
- LOG_NEWS = 56
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- LOG_PERROR = 32
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/types.conf b/src/main/resources/stdlib/ffi/platform/x86_64-linux/types.conf
deleted file mode 100644
index 1676aad..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/types.conf
+++ /dev/null
@@ -1,100 +0,0 @@
-rbx.platform.typedef.__u_char = uchar
-rbx.platform.typedef.__u_short = ushort
-rbx.platform.typedef.__u_int = uint
-rbx.platform.typedef.__u_long = ulong
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long
-rbx.platform.typedef.__uint64_t = ulong
-rbx.platform.typedef.__quad_t = long
-rbx.platform.typedef.__u_quad_t = ulong
-rbx.platform.typedef.__dev_t = ulong
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__ino_t = ulong
-rbx.platform.typedef.__ino64_t = ulong
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = ulong
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__off64_t = long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__clock_t = long
-rbx.platform.typedef.__rlim_t = ulong
-rbx.platform.typedef.__rlim64_t = ulong
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__time_t = long
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = long
-rbx.platform.typedef.__daddr_t = int
-rbx.platform.typedef.__swblk_t = long
-rbx.platform.typedef.__key_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__timer_t = pointer
-rbx.platform.typedef.__blksize_t = long
-rbx.platform.typedef.__blkcnt_t = long
-rbx.platform.typedef.__blkcnt64_t = long
-rbx.platform.typedef.__fsblkcnt_t = ulong
-rbx.platform.typedef.__fsblkcnt64_t = ulong
-rbx.platform.typedef.__fsfilcnt_t = ulong
-rbx.platform.typedef.__fsfilcnt64_t = ulong
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__loff_t = long
-rbx.platform.typedef.*__qaddr_t = long
-rbx.platform.typedef.*__caddr_t = char
-rbx.platform.typedef.__intptr_t = long
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.quad_t = long
-rbx.platform.typedef.u_quad_t = ulong
-rbx.platform.typedef.loff_t = long
-rbx.platform.typedef.ino_t = ulong
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = ulong
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.off_t = long
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = pointer
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = long
-rbx.platform.typedef.__sig_atomic_t = int
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.__fd_mask = long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.blkcnt_t = long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.pthread_t = ulong
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.pthread_once_t = int
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.rlim_t = ulong
-rbx.platform.typedef.__rlimit_resource_t = int
-rbx.platform.typedef.__rusage_who_t = int
-rbx.platform.typedef.__priority_which_t = int
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-linux/zlib.rb b/src/main/resources/stdlib/ffi/platform/x86_64-linux/zlib.rb
deleted file mode 100644
index fabb15d..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-linux/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3.4"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 112
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 8,
- :total_in, :ulong, 16,
- :next_out, :pointer, 24,
- :avail_out, :uint, 32,
- :total_out, :ulong, 40,
- :msg, :string, 48,
- :state, :pointer, 56,
- :zalloc, :pointer, 64,
- :zfree, :pointer, 72,
- :opaque, :pointer, 80,
- :data_type, :int, 88,
- :adler, :ulong, 96,
- :reserved, :ulong, 104
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/errno.rb b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/errno.rb
deleted file mode 100644
index 7493c0d..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 48
- EADDRNOTAVAIL = 49
- EAFNOSUPPORT = 47
- EAGAIN = 35
- EALREADY = 37
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 53
- ECONNREFUSED = 61
- ECONNRESET = 54
- EDEADLK = 11
- EDESTADDRREQ = 39
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 64
- EHOSTUNREACH = 65
- EINPROGRESS = 36
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 56
- EISDIR = 21
- ELOOP = 62
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 40
- ENAMETOOLONG = 63
- ENETDOWN = 50
- ENETRESET = 52
- ENETUNREACH = 51
- ENFILE = 23
- ENOBUFS = 55
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 42
- ENOSPC = 28
- ENOTCONN = 57
- ENOTDIR = 20
- ENOTEMPTY = 66
- ENOTSOCK = 38
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 45
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 43
- EPROTOTYPE = 41
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 60
- ETXTBSY = 26
- EWOULDBLOCK = 35
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/etc.rb b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/etc.rb
deleted file mode 100644
index b52f6e1..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 72
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 8,
- :pw_uid, :uint, 16,
- :pw_gid, :uint, 20,
- :pw_dir, :string, 48,
- :pw_shell, :string, 56
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 32
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 16
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/fcntl.rb b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/fcntl.rb
deleted file mode 100644
index 1db3cc0..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 7
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 8
- F_SETLKW = 9
- F_UNLCK = 2
- F_WRLCK = 3
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 512
- O_EXCL = 2048
- O_NDELAY = 4
- O_NOCTTY = 32768
- O_NONBLOCK = 4
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 1024
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/platform.conf b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/platform.conf
deleted file mode 100644
index 9476874..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/platform.conf
+++ /dev/null
@@ -1,565 +0,0 @@
-rbx.platform.addrinfo.sizeof = 32
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 20
-rbx.platform.addrinfo.ai_addr.size = 4
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 24
-rbx.platform.addrinfo.ai_canonname.size = 4
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 28
-rbx.platform.addrinfo.ai_next.size = 4
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 264
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 4
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 4
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 8
-rbx.platform.dirent.d_name.size = 256
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 1
-rbx.platform.sockaddr_in.sin_family.size = 1
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 106
-rbx.platform.sockaddr_un.sun_family.offset = 1
-rbx.platform.sockaddr_un.sun_family.size = 1
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 104
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 112
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 4
-rbx.platform.stat.st_ino.size = 4
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 8
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 12
-rbx.platform.stat.st_nlink.size = 4
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 16
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 20
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 24
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 56
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 72
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 64
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 32
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 40
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 48
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 512
-rbx.platform.file.O_EXCL = 2048
-rbx.platform.file.O_NOCTTY = 32768
-rbx.platform.file.O_TRUNC = 1024
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 4
-rbx.platform.file.O_SYNC = 128
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT = 21
-rbx.platform.socket.AF_COIP = 20
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 = 26
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 24
-rbx.platform.socket.AF_IPX = 23
-rbx.platform.socket.AF_ISDN = 26
-rbx.platform.socket.AF_ISO = 7
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 18
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 33
-rbx.platform.socket.AF_NATM = 27
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS =
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 7
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 17
-rbx.platform.socket.AF_SIP = 29
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG =
-rbx.platform.socket.AI_ALL =
-rbx.platform.socket.AI_CANONNAME = 2
-rbx.platform.socket.AI_DEFAULT =
-rbx.platform.socket.AI_MASK = 23
-rbx.platform.socket.AI_NUMERICHOST = 4
-rbx.platform.socket.AI_PASSIVE = 1
-rbx.platform.socket.AI_V4MAPPED =
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY = -9
-rbx.platform.socket.EAI_AGAIN = -3
-rbx.platform.socket.EAI_BADFLAGS = -1
-rbx.platform.socket.EAI_BADHINTS = -12
-rbx.platform.socket.EAI_FAIL = -4
-rbx.platform.socket.EAI_FAMILY = -6
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY = -10
-rbx.platform.socket.EAI_NODATA = -5
-rbx.platform.socket.EAI_NONAME = -2
-rbx.platform.socket.EAI_PROTOCOL = -13
-rbx.platform.socket.EAI_SERVICE = -8
-rbx.platform.socket.EAI_SOCKTYPE = -7
-rbx.platform.socket.EAI_SYSTEM = -11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE = -1
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 49151
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO =
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND =
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP = 29
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 12
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 13
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS = 4095
-rbx.platform.socket.IP_MULTICAST_IF = 9
-rbx.platform.socket.IP_MULTICAST_LOOP = 11
-rbx.platform.socket.IP_MULTICAST_TTL = 10
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 32
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 128
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 16
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 256
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 8
-rbx.platform.socket.NI_NOFQDN = 4
-rbx.platform.socket.NI_NUMERICHOST = 1
-rbx.platform.socket.NI_NUMERICSERV = 2
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT = 21
-rbx.platform.socket.PF_COIP = 20
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 24
-rbx.platform.socket.PF_IPX = 23
-rbx.platform.socket.PF_ISDN = 26
-rbx.platform.socket.PF_ISO = 7
-rbx.platform.socket.PF_KEY = 30
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 18
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 33
-rbx.platform.socket.PF_NATM = 27
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS =
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 7
-rbx.platform.socket.PF_PIP = 25
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 17
-rbx.platform.socket.PF_RTIP = 22
-rbx.platform.socket.PF_SIP = 29
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP = 19
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT = 512
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP =
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS = 5
-rbx.platform.process.RLIMIT_NPROC = 7
-rbx.platform.process.RLIMIT_NOFILE = 8
-rbx.platform.process.RLIMIT_MEMLOCK = 6
-rbx.platform.process.RLIMIT_AS =
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_MAX = 9223372036854775807
-rbx.platform.process.RLIM_SAVED_CUR = 9223372036854775807
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 16
-rbx.platform.signal.SIGSTOP = 17
-rbx.platform.signal.SIGTSTP = 18
-rbx.platform.signal.SIGCONT = 19
-rbx.platform.signal.SIGCHLD = 20
-rbx.platform.signal.SIGCLD =
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 23
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 26
-rbx.platform.signal.SIGPROF = 27
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 30
-rbx.platform.signal.SIGUSR2 = 31
-rbx.platform.signal.SIGLOST =
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR =
-rbx.platform.signal.SIGPOLL =
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO = 29
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__int_least8_t = char
-rbx.platform.typedef.__uint_least8_t = uchar
-rbx.platform.typedef.__int_least16_t = short
-rbx.platform.typedef.__uint_least16_t = ushort
-rbx.platform.typedef.__int_least32_t = int
-rbx.platform.typedef.__uint_least32_t = uint
-rbx.platform.typedef.__int_least64_t = long_long
-rbx.platform.typedef.__uint_least64_t = ulong_long
-rbx.platform.typedef.__int_fast8_t = int
-rbx.platform.typedef.__uint_fast8_t = uint
-rbx.platform.typedef.__int_fast16_t = int
-rbx.platform.typedef.__uint_fast16_t = uint
-rbx.platform.typedef.__int_fast32_t = int
-rbx.platform.typedef.__uint_fast32_t = uint
-rbx.platform.typedef.__int_fast64_t = long_long
-rbx.platform.typedef.__uint_fast64_t = ulong_long
-rbx.platform.typedef.__intptr_t = long
-rbx.platform.typedef.__uintptr_t = ulong
-rbx.platform.typedef.__intmax_t = long_long
-rbx.platform.typedef.__uintmax_t = ulong_long
-rbx.platform.typedef.__register_t = int
-rbx.platform.typedef.__vaddr_t = ulong
-rbx.platform.typedef.__paddr_t = ulong
-rbx.platform.typedef.__vsize_t = ulong
-rbx.platform.typedef.__psize_t = ulong
-rbx.platform.typedef.__clock_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__off_t = long_long
-rbx.platform.typedef.__ptrdiff_t = long
-rbx.platform.typedef.__size_t = ulong
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__time_t = int
-rbx.platform.typedef.__timer_t = int
-rbx.platform.typedef.__wchar_t = int
-rbx.platform.typedef.__wint_t = int
-rbx.platform.typedef.__rune_t = int
-rbx.platform.typedef.__wctrans_t = pointer
-rbx.platform.typedef.__wctype_t = pointer
-rbx.platform.typedef.__cpuid_t = ulong
-rbx.platform.typedef.__dev_t = int
-rbx.platform.typedef.__fixpt_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__in_addr_t = uint
-rbx.platform.typedef.__in_port_t = ushort
-rbx.platform.typedef.__ino_t = uint
-rbx.platform.typedef.__key_t = long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__rlim_t = ulong_long
-rbx.platform.typedef.__sa_family_t = uchar
-rbx.platform.typedef.__segsz_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.__swblk_t = int
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = int
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.cpuid_t = ulong
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.vaddr_t = ulong
-rbx.platform.typedef.paddr_t = ulong
-rbx.platform.typedef.vsize_t = ulong
-rbx.platform.typedef.psize_t = ulong
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.daddr32_t = int
-rbx.platform.typedef.daddr64_t = long_long
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ino_t = uint
-rbx.platform.typedef.key_t = long
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.clock_t = int
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.__fd_mask = int
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/socket.rb b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/socket.rb
deleted file mode 100644
index 5d02e66..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- AF_CNT = 21
- AF_COIP = 20
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- AF_E164 = 26
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 24
- AF_IPX = 23
- AF_ISDN = 26
- AF_ISO = 7
- AF_LAT = 14
- AF_LINK = 18
- AF_LOCAL = 1
- AF_MAX = 35
- AF_NATM = 27
- # AF_NDRV not available
- # AF_NETBIOS not available
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 7
- # AF_PPP not available
- AF_PUP = 4
- AF_ROUTE = 17
- AF_SIP = 29
- AF_SNA = 11
- # AF_SYSTEM not available
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- NI_FQDN_FLAG_VALIDTTL = 256
- NI_MAXHOST = 256
- NI_MAXSERV = 32
- NI_NAMEREQD = 8
- NI_NODEADDR_FLAG_ALL = 512
- NI_NODEADDR_FLAG_ANYCAST = 16384
- NI_NODEADDR_FLAG_COMPAT = 1024
- NI_NODEADDR_FLAG_GLOBAL = 8192
- NI_NODEADDR_FLAG_LINKLOCAL = 2048
- NI_NODEADDR_FLAG_SITELOCAL = 4096
- NI_NODEADDR_FLAG_TRUNCATE = 256
- NI_NOFQDN = 4
- NI_NUMERICHOST = 1
- NI_NUMERICSERV = 2
- NI_QTYPE_DNSNAME = 2
- NI_QTYPE_FQDN = 2
- NI_QTYPE_IPV4ADDR = 4
- NI_QTYPE_NODEADDR = 3
- NI_QTYPE_NOOP = 0
- NI_QTYPE_SUPTYPES = 1
- NI_SUPTYPE_FLAG_COMPRESS = 256
- # NI_WITHSCOPEID not available
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- PF_CNT = 21
- PF_COIP = 20
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 24
- PF_IPX = 23
- PF_ISDN = 26
- PF_ISO = 7
- PF_KEY = 30
- PF_LAT = 14
- PF_LINK = 18
- PF_LOCAL = 1
- PF_MAX = 35
- PF_NATM = 27
- # PF_NDRV not available
- # PF_NETBIOS not available
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 7
- PF_PIP = 25
- # PF_PPP not available
- PF_PUP = 4
- PF_ROUTE = 17
- PF_RTIP = 22
- PF_SIP = 29
- PF_SNA = 11
- # PF_SYSTEM not available
- PF_UNIX = 1
- PF_UNSPEC = 0
- PF_XTP = 19
- SOCK_DGRAM = 2
- # SOCK_MAXADDRLEN not available
- SOCK_RAW = 3
- SOCK_RDM = 4
- SOCK_SEQPACKET = 5
- SOCK_STREAM = 1
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- # SO_DONTTRUNC not available
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- # SO_LABEL not available
- SO_LINGER = 128
- # SO_NKE not available
- # SO_NOADDRERR not available
- # SO_NOSIGPIPE not available
- # SO_NO_CHECK not available
- # SO_NREAD not available
- # SO_NWRITE not available
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- SO_PEERCRED = 4130
- # SO_PEERLABEL not available
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- SO_REUSEPORT = 512
- # SO_REUSESHAREUID not available
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- SO_TIMESTAMP = 2048
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- # SO_WANTMORE not available
- # SO_WANTOOBFLAG not available
- pseudo_AF_HDRCMPLT = 31
- # pseudo_AF_KEY not available
- pseudo_AF_PIP = 25
- pseudo_AF_RTIP = 22
- pseudo_AF_XTP = 19
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/stat.rb b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/stat.rb
deleted file mode 100644
index 87ecbd5..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 144
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 4,
- :st_nlink, :nlink_t, 12,
- :st_mode, :mode_t, 8,
- :st_uid, :uid_t, 16,
- :st_gid, :gid_t, 20,
- :st_size, :off_t, 80,
- :st_blocks, :blkcnt_t, 88,
- :st_atime, :time_t, 32,
- :st_mtime, :time_t, 48,
- :st_ctime, :time_t, 64
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/sysconf.rb b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/sysconf.rb
deleted file mode 100644
index 0eeda91..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 20
- SC_2_C_BIND = 18
- SC_2_C_DEV = 19
- SC_2_FORT_DEV = 21
- SC_2_FORT_RUN = 22
- SC_2_LOCALEDEF = 23
- # _SC_2_PBS not available
- # _SC_2_PBS_ACCOUNTING not available
- # _SC_2_PBS_CHECKPOINT not available
- # _SC_2_PBS_LOCATE not available
- # _SC_2_PBS_MESSAGE not available
- # _SC_2_PBS_TRACK not available
- SC_2_SW_DEV = 24
- SC_2_UPE = 25
- SC_2_VERSION = 17
- # _SC_ADVISORY_INFO not available
- # _SC_AIO_LISTIO_MAX not available
- # _SC_AIO_MAX not available
- # _SC_AIO_PRIO_DELTA_MAX not available
- SC_ARG_MAX = 1
- # _SC_ASYNCHRONOUS_IO not available
- # _SC_ATEXIT_MAX not available
- # _SC_BARRIERS not available
- SC_BC_BASE_MAX = 9
- SC_BC_DIM_MAX = 10
- SC_BC_SCALE_MAX = 11
- SC_BC_STRING_MAX = 12
- SC_CHILD_MAX = 2
- SC_CLK_TCK = 3
- # _SC_CLOCK_SELECTION not available
- SC_COLL_WEIGHTS_MAX = 13
- # _SC_CPUTIME not available
- # _SC_DELAYTIMER_MAX not available
- SC_EXPR_NEST_MAX = 14
- # _SC_FILE_LOCKING not available
- SC_FSYNC = 29
- SC_GETGR_R_SIZE_MAX = 100
- SC_GETPW_R_SIZE_MAX = 101
- # _SC_HOST_NAME_MAX not available
- # _SC_IOV_MAX not available
- # _SC_IPV6 not available
- SC_JOB_CONTROL = 6
- SC_LINE_MAX = 15
- SC_LOGIN_NAME_MAX = 102
- # _SC_MAPPED_FILES not available
- # _SC_MEMLOCK not available
- # _SC_MEMLOCK_RANGE not available
- # _SC_MEMORY_PROTECTION not available
- # _SC_MESSAGE_PASSING not available
- # _SC_MONOTONIC_CLOCK not available
- # _SC_MQ_OPEN_MAX not available
- # _SC_MQ_PRIO_MAX not available
- SC_NGROUPS_MAX = 4
- SC_NPROCESSORS_CONF = 502
- SC_NPROCESSORS_ONLN = 503
- SC_OPEN_MAX = 5
- SC_PAGESIZE = 28
- SC_PAGE_SIZE = 28
- # _SC_PASS_MAX not available
- # _SC_PRIORITIZED_IO not available
- # _SC_PRIORITY_SCHEDULING not available
- # _SC_RAW_SOCKETS not available
- # _SC_READER_WRITER_LOCKS not available
- # _SC_REALTIME_SIGNALS not available
- # _SC_REGEXP not available
- SC_RE_DUP_MAX = 16
- # _SC_RTSIG_MAX not available
- SC_SAVED_IDS = 7
- # _SC_SEMAPHORES not available
- SC_SEM_NSEMS_MAX = 31
- SC_SEM_VALUE_MAX = 32
- # _SC_SHARED_MEMORY_OBJECTS not available
- # _SC_SHELL not available
- # _SC_SIGQUEUE_MAX not available
- # _SC_SPAWN not available
- # _SC_SPIN_LOCKS not available
- # _SC_SPORADIC_SERVER not available
- # _SC_SS_REPL_MAX not available
- SC_STREAM_MAX = 26
- # _SC_SYMLOOP_MAX not available
- # _SC_SYNCHRONIZED_IO not available
- # _SC_THREADS not available
- # _SC_THREAD_ATTR_STACKADDR not available
- # _SC_THREAD_ATTR_STACKSIZE not available
- # _SC_THREAD_CPUTIME not available
- # _SC_THREAD_DESTRUCTOR_ITERATIONS not available
- # _SC_THREAD_KEYS_MAX not available
- # _SC_THREAD_PRIORITY_SCHEDULING not available
- # _SC_THREAD_PRIO_INHERIT not available
- # _SC_THREAD_PRIO_PROTECT not available
- # _SC_THREAD_PROCESS_SHARED not available
- SC_THREAD_SAFE_FUNCTIONS = 103
- # _SC_THREAD_SPORADIC_SERVER not available
- # _SC_THREAD_STACK_MIN not available
- # _SC_THREAD_THREADS_MAX not available
- # _SC_TIMEOUTS not available
- # _SC_TIMERS not available
- # _SC_TIMER_MAX not available
- # _SC_TRACE not available
- # _SC_TRACE_EVENT_FILTER not available
- # _SC_TRACE_EVENT_NAME_MAX not available
- # _SC_TRACE_INHERIT not available
- # _SC_TRACE_LOG not available
- # _SC_TRACE_NAME_MAX not available
- # _SC_TRACE_SYS_MAX not available
- # _SC_TRACE_USER_EVENT_MAX not available
- # _SC_TTY_NAME_MAX not available
- # _SC_TYPED_MEMORY_OBJECTS not available
- SC_TZNAME_MAX = 27
- # _SC_V6_ILP32_OFF32 not available
- # _SC_V6_ILP32_OFFBIG not available
- # _SC_V6_LP64_OFF64 not available
- # _SC_V6_LPBIG_OFFBIG not available
- SC_VERSION = 8
- # _SC_XBS5_ILP32_OFF32 not available
- # _SC_XBS5_ILP32_OFFBIG not available
- # _SC_XBS5_LP64_OFF64 not available
- # _SC_XBS5_LPBIG_OFFBIG not available
- # _SC_XOPEN_CRYPT not available
- # _SC_XOPEN_ENH_I18N not available
- # _SC_XOPEN_LEGACY not available
- # _SC_XOPEN_REALTIME not available
- # _SC_XOPEN_REALTIME_THREADS not available
- SC_XOPEN_SHM = 30
- # _SC_XOPEN_STREAMS not available
- # _SC_XOPEN_UNIX not available
- # _SC_XOPEN_VERSION not available
- # _SC_XOPEN_XCU_VERSION not available
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/syslog.rb b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/syslog.rb
deleted file mode 100644
index 41797be..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- LOG_AUTHPRIV = 80
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 72
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- LOG_FTP = 88
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NEWS = 56
- # LOG_NODELAY not available
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- LOG_PERROR = 32
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/types.conf b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/types.conf
deleted file mode 100644
index 33bd12b..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/types.conf
+++ /dev/null
@@ -1,126 +0,0 @@
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef.__int_least8_t = char
-rbx.platform.typedef.__uint_least8_t = uchar
-rbx.platform.typedef.__int_least16_t = short
-rbx.platform.typedef.__uint_least16_t = ushort
-rbx.platform.typedef.__int_least32_t = int
-rbx.platform.typedef.__uint_least32_t = uint
-rbx.platform.typedef.__int_least64_t = long_long
-rbx.platform.typedef.__uint_least64_t = ulong_long
-rbx.platform.typedef.__int_fast8_t = int
-rbx.platform.typedef.__uint_fast8_t = uint
-rbx.platform.typedef.__int_fast16_t = int
-rbx.platform.typedef.__uint_fast16_t = uint
-rbx.platform.typedef.__int_fast32_t = int
-rbx.platform.typedef.__uint_fast32_t = uint
-rbx.platform.typedef.__int_fast64_t = long_long
-rbx.platform.typedef.__uint_fast64_t = ulong_long
-rbx.platform.typedef.__intptr_t = long
-rbx.platform.typedef.__uintptr_t = ulong
-rbx.platform.typedef.__intmax_t = long_long
-rbx.platform.typedef.__uintmax_t = ulong_long
-rbx.platform.typedef.__register_t = int
-rbx.platform.typedef.__vaddr_t = ulong
-rbx.platform.typedef.__paddr_t = ulong
-rbx.platform.typedef.__vsize_t = ulong
-rbx.platform.typedef.__psize_t = ulong
-rbx.platform.typedef.__clock_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__off_t = long_long
-rbx.platform.typedef.__ptrdiff_t = long
-rbx.platform.typedef.__size_t = ulong
-rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__time_t = int
-rbx.platform.typedef.__timer_t = int
-rbx.platform.typedef.__wchar_t = int
-rbx.platform.typedef.__wint_t = int
-rbx.platform.typedef.__rune_t = int
-rbx.platform.typedef.__wctrans_t = pointer
-rbx.platform.typedef.__wctype_t = pointer
-rbx.platform.typedef.__cpuid_t = ulong
-rbx.platform.typedef.__dev_t = int
-rbx.platform.typedef.__fixpt_t = uint
-rbx.platform.typedef.__gid_t = uint
-rbx.platform.typedef.__id_t = uint
-rbx.platform.typedef.__in_addr_t = uint
-rbx.platform.typedef.__in_port_t = ushort
-rbx.platform.typedef.__ino_t = uint
-rbx.platform.typedef.__key_t = long
-rbx.platform.typedef.__mode_t = uint
-rbx.platform.typedef.__nlink_t = uint
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__rlim_t = ulong_long
-rbx.platform.typedef.__sa_family_t = uchar
-rbx.platform.typedef.__segsz_t = int
-rbx.platform.typedef.__socklen_t = uint
-rbx.platform.typedef.__swblk_t = int
-rbx.platform.typedef.__uid_t = uint
-rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = int
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.cpuid_t = ulong
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.quad_t = long_long
-rbx.platform.typedef.u_quad_t = ulong_long
-rbx.platform.typedef.qaddr_t = pointer
-rbx.platform.typedef.vaddr_t = ulong
-rbx.platform.typedef.paddr_t = ulong
-rbx.platform.typedef.vsize_t = ulong
-rbx.platform.typedef.psize_t = ulong
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
-rbx.platform.typedef.daddr32_t = int
-rbx.platform.typedef.daddr64_t = long_long
-rbx.platform.typedef.dev_t = int
-rbx.platform.typedef.fixpt_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ino_t = uint
-rbx.platform.typedef.key_t = long
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.rlim_t = ulong_long
-rbx.platform.typedef.segsz_t = int
-rbx.platform.typedef.swblk_t = int
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.clock_t = int
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.__fd_mask = int
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/zlib.rb b/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/zlib.rb
deleted file mode 100644
index 38e3713..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-openbsd/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 112
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 8,
- :total_in, :ulong, 16,
- :next_out, :pointer, 24,
- :avail_out, :uint, 32,
- :total_out, :ulong, 40,
- :msg, :string, 48,
- :state, :pointer, 56,
- :zalloc, :pointer, 64,
- :zfree, :pointer, 72,
- :opaque, :pointer, 80,
- :data_type, :int, 88,
- :adler, :ulong, 96,
- :reserved, :ulong, 104
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/errno.rb b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/errno.rb
deleted file mode 100644
index b89dab7..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/errno.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Errno
- E2BIG = 7
- EACCES = 13
- EADDRINUSE = 125
- EADDRNOTAVAIL = 126
- EAFNOSUPPORT = 124
- EAGAIN = 11
- EALREADY = 149
- EBADF = 9
- EBUSY = 16
- ECHILD = 10
- ECONNABORTED = 130
- ECONNREFUSED = 146
- ECONNRESET = 131
- EDEADLK = 45
- EDESTADDRREQ = 96
- EEXIST = 17
- EFAULT = 14
- EFBIG = 27
- EHOSTDOWN = 147
- EHOSTUNREACH = 148
- EINPROGRESS = 150
- EINTR = 4
- EINVAL = 22
- EIO = 5
- EISCONN = 133
- EISDIR = 21
- ELOOP = 90
- EMFILE = 24
- EMLINK = 31
- EMSGSIZE = 97
- ENAMETOOLONG = 78
- ENETDOWN = 127
- ENETRESET = 129
- ENETUNREACH = 128
- ENFILE = 23
- ENOBUFS = 132
- ENODEV = 19
- ENOENT = 2
- ENOEXEC = 8
- ENOMEM = 12
- ENOPROTOOPT = 99
- ENOSPC = 28
- ENOTCONN = 134
- ENOTDIR = 20
- ENOTEMPTY = 93
- ENOTSOCK = 95
- ENOTTY = 25
- ENXIO = 6
- EOPNOTSUPP = 122
- EPERM = 1
- EPIPE = 32
- EPROTONOSUPPORT = 120
- EPROTOTYPE = 98
- EROFS = 30
- ESPIPE = 29
- ESRCH = 3
- ETIMEDOUT = 145
- ETXTBSY = 26
- EWOULDBLOCK = 11
- EXDEV = 18
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/etc.rb b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/etc.rb
deleted file mode 100644
index 823448b..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/etc.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Etc
- class Passwd < FFI::Struct
- self.size = 64
- layout :pw_name, :string, 0,
- :pw_passwd, :string, 8,
- :pw_uid, :uint, 16,
- :pw_gid, :uint, 20,
- :pw_dir, :string, 48,
- :pw_shell, :string, 56
-
-
-
-
-
-
- end
- class Group < FFI::Struct
- self.size = 32
- layout :gr_name, :string, 0,
- :gr_gid, :uint, 16
-
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/fcntl.rb b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/fcntl.rb
deleted file mode 100644
index 9208d6f..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/fcntl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Fcntl
- FD_CLOEXEC = 1
- F_DUPFD = 0
- F_GETFD = 1
- F_GETFL = 3
- F_GETLK = 14
- F_RDLCK = 1
- F_SETFD = 2
- F_SETFL = 4
- F_SETLK = 6
- F_SETLKW = 7
- F_UNLCK = 3
- F_WRLCK = 2
- O_ACCMODE = 3
- O_APPEND = 8
- O_CREAT = 256
- O_EXCL = 1024
- O_NDELAY = 4
- O_NOCTTY = 2048
- O_NONBLOCK = 128
- O_RDONLY = 0
- O_RDWR = 2
- O_TRUNC = 512
- O_WRONLY = 1
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/platform.conf b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/platform.conf
deleted file mode 100644
index 7341032..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/platform.conf
+++ /dev/null
@@ -1,561 +0,0 @@
-rbx.platform.addrinfo.sizeof = 48
-rbx.platform.addrinfo.ai_flags.offset = 0
-rbx.platform.addrinfo.ai_flags.size = 4
-rbx.platform.addrinfo.ai_flags.type = int
-rbx.platform.addrinfo.ai_family.offset = 4
-rbx.platform.addrinfo.ai_family.size = 4
-rbx.platform.addrinfo.ai_family.type = int
-rbx.platform.addrinfo.ai_socktype.offset = 8
-rbx.platform.addrinfo.ai_socktype.size = 4
-rbx.platform.addrinfo.ai_socktype.type = int
-rbx.platform.addrinfo.ai_protocol.offset = 12
-rbx.platform.addrinfo.ai_protocol.size = 4
-rbx.platform.addrinfo.ai_protocol.type = int
-rbx.platform.addrinfo.ai_addrlen.offset = 16
-rbx.platform.addrinfo.ai_addrlen.size = 4
-rbx.platform.addrinfo.ai_addrlen.type = int
-rbx.platform.addrinfo.ai_addr.offset = 32
-rbx.platform.addrinfo.ai_addr.size = 8
-rbx.platform.addrinfo.ai_addr.type = pointer
-rbx.platform.addrinfo.ai_canonname.offset = 24
-rbx.platform.addrinfo.ai_canonname.size = 8
-rbx.platform.addrinfo.ai_canonname.type = string
-rbx.platform.addrinfo.ai_next.offset = 40
-rbx.platform.addrinfo.ai_next.size = 8
-rbx.platform.addrinfo.ai_next.type = pointer
-rbx.platform.dirent.sizeof = 24
-rbx.platform.dirent.d_ino.offset = 0
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_reclen.offset = 16
-rbx.platform.dirent.d_reclen.size = 2
-rbx.platform.dirent.d_reclen.type = ushort
-rbx.platform.dirent.d_name.offset = 18
-rbx.platform.dirent.d_name.size = 1
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 16
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 8
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 8
-rbx.platform.timeval.tv_usec.size = 8
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 0
-rbx.platform.sockaddr_in.sin_family.size = 2
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 110
-rbx.platform.sockaddr_un.sun_family.offset = 0
-rbx.platform.sockaddr_un.sun_family.size = 2
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 108
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 32
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 8
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 8
-rbx.platform.servent.s_aliases.size = 8
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 16
-rbx.platform.servent.s_port.size = 4
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 24
-rbx.platform.servent.s_proto.size = 8
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 128
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 8
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 8
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 16
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 20
-rbx.platform.stat.st_nlink.size = 4
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 24
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 28
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 32
-rbx.platform.stat.st_rdev.size = 8
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 40
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 96
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 104
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 48
-rbx.platform.stat.st_atime.size = 8
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 64
-rbx.platform.stat.st_mtime.size = 8
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 80
-rbx.platform.stat.st_ctime.size = 8
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 16
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 8
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 8
-rbx.platform.rlimit.rlim_max.size = 8
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 256
-rbx.platform.file.O_EXCL = 1024
-rbx.platform.file.O_NOCTTY = 2048
-rbx.platform.file.O_TRUNC = 512
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 128
-rbx.platform.file.O_SYNC = 16
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT =
-rbx.platform.socket.AF_COIP =
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 =
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 26
-rbx.platform.socket.AF_IPX = 23
-rbx.platform.socket.AF_ISDN =
-rbx.platform.socket.AF_ISO =
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK = 25
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 30
-rbx.platform.socket.AF_NATM =
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS =
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 19
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE = 24
-rbx.platform.socket.AF_SIP =
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 4
-rbx.platform.socket.AI_ALL = 2
-rbx.platform.socket.AI_CANONNAME = 16
-rbx.platform.socket.AI_DEFAULT = 5
-rbx.platform.socket.AI_MASK =
-rbx.platform.socket.AI_NUMERICHOST = 32
-rbx.platform.socket.AI_PASSIVE = 8
-rbx.platform.socket.AI_V4MAPPED = 1
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY = 1
-rbx.platform.socket.EAI_AGAIN = 2
-rbx.platform.socket.EAI_BADFLAGS = 3
-rbx.platform.socket.EAI_BADHINTS =
-rbx.platform.socket.EAI_FAIL = 4
-rbx.platform.socket.EAI_FAMILY = 5
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY = 6
-rbx.platform.socket.EAI_NODATA = 7
-rbx.platform.socket.EAI_NONAME = 8
-rbx.platform.socket.EAI_PROTOCOL =
-rbx.platform.socket.EAI_SERVICE = 9
-rbx.platform.socket.EAI_SOCKTYPE = 10
-rbx.platform.socket.EAI_SYSTEM = 11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = 3758096385
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = 4294967295
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = 3758096639
-rbx.platform.socket.INADDR_NONE = 4294967295
-rbx.platform.socket.INADDR_UNSPEC_GROUP = 3758096384
-rbx.platform.socket.IPPORT_RESERVED = 1024
-rbx.platform.socket.IPPORT_USERRESERVED = 5000
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON = 80
-rbx.platform.socket.IPPROTO_GGP = 3
-rbx.platform.socket.IPPROTO_HELLO = 63
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX = 256
-rbx.platform.socket.IPPROTO_ND = 77
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP =
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE =
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 19
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 20
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS =
-rbx.platform.socket.IP_MULTICAST_IF = 16
-rbx.platform.socket.IP_MULTICAST_LOOP = 18
-rbx.platform.socket.IP_MULTICAST_TTL = 17
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR = 7
-rbx.platform.socket.IP_RECVOPTS = 5
-rbx.platform.socket.IP_RECVRETOPTS = 6
-rbx.platform.socket.IP_RETOPTS = 8
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 16
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 128
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR = 8
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 32
-rbx.platform.socket.MSG_WAITALL = 64
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 4
-rbx.platform.socket.NI_NOFQDN = 1
-rbx.platform.socket.NI_NUMERICHOST = 2
-rbx.platform.socket.NI_NUMERICSERV = 8
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT =
-rbx.platform.socket.PF_COIP =
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 26
-rbx.platform.socket.PF_IPX = 23
-rbx.platform.socket.PF_ISDN =
-rbx.platform.socket.PF_ISO =
-rbx.platform.socket.PF_KEY = 27
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK = 25
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 30
-rbx.platform.socket.PF_NATM =
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS =
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 19
-rbx.platform.socket.PF_PIP =
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE = 24
-rbx.platform.socket.PF_RTIP =
-rbx.platform.socket.PF_SIP =
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP =
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 1
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 4
-rbx.platform.socket.SOCK_RDM = 5
-rbx.platform.socket.SOCK_SEQPACKET = 6
-rbx.platform.socket.SOCK_STREAM = 2
-rbx.platform.socket.SOL_ATALK =
-rbx.platform.socket.SOL_AX25 =
-rbx.platform.socket.SOL_IP =
-rbx.platform.socket.SOL_IPX =
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP =
-rbx.platform.socket.SOL_UDP =
-rbx.platform.socket.SOPRI_BACKGROUND =
-rbx.platform.socket.SOPRI_INTERACTIVE =
-rbx.platform.socket.SOPRI_NORMAL =
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED =
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT =
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP = 4115
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 64
-rbx.platform.process.WUNTRACED = 4
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS =
-rbx.platform.process.RLIMIT_NPROC =
-rbx.platform.process.RLIMIT_NOFILE = 5
-rbx.platform.process.RLIMIT_MEMLOCK =
-rbx.platform.process.RLIMIT_AS = 6
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 18446744073709551613
-rbx.platform.process.RLIM_SAVED_MAX = 18446744073709551614
-rbx.platform.process.RLIM_SAVED_CUR = 18446744073709551615
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT = 6
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 21
-rbx.platform.signal.SIGSTOP = 23
-rbx.platform.signal.SIGTSTP = 24
-rbx.platform.signal.SIGCONT = 25
-rbx.platform.signal.SIGCHLD = 18
-rbx.platform.signal.SIGCLD = 18
-rbx.platform.signal.SIGTTIN = 26
-rbx.platform.signal.SIGTTOU = 27
-rbx.platform.signal.SIGIO = 22
-rbx.platform.signal.SIGXCPU = 30
-rbx.platform.signal.SIGXFSZ = 31
-rbx.platform.signal.SIGVTALRM = 28
-rbx.platform.signal.SIGPROF = 29
-rbx.platform.signal.SIGWINCH = 20
-rbx.platform.signal.SIGUSR1 = 16
-rbx.platform.signal.SIGUSR2 = 17
-rbx.platform.signal.SIGLOST = 37
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR = 19
-rbx.platform.signal.SIGPOLL = 22
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO =
-rbx.platform.zlib.ZLIB_VERSION = 1.2.3
-rbx.platform.typedef.lock_t = uchar
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong
-rbx.platform.typedef.intmax_t = long
-rbx.platform.typedef.uintmax_t = ulong
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = int
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.int_fast64_t = long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = uint
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.uint_fast64_t = ulong
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.t_scalar_t = int
-rbx.platform.typedef.t_uscalar_t = uint
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.*caddr_t = char
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.ptrdiff_t = long
-rbx.platform.typedef.pfn_t = ulong
-rbx.platform.typedef.pgcnt_t = ulong
-rbx.platform.typedef.spgcnt_t = long
-rbx.platform.typedef.use_t = uchar
-rbx.platform.typedef.sysid_t = short
-rbx.platform.typedef.index_t = short
-rbx.platform.typedef.off_t = long
-rbx.platform.typedef.off64_t = long
-rbx.platform.typedef.ino_t = ulong
-rbx.platform.typedef.blkcnt_t = long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.ino64_t = ulong
-rbx.platform.typedef.blkcnt64_t = long
-rbx.platform.typedef.fsblkcnt64_t = ulong
-rbx.platform.typedef.fsfilcnt64_t = ulong
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.pad64_t = long
-rbx.platform.typedef.upad64_t = ulong
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.u_offset_t = ulong_long
-rbx.platform.typedef.len_t = ulong_long
-rbx.platform.typedef.diskaddr_t = ulong_long
-rbx.platform.typedef.k_fltset_t = uint
-rbx.platform.typedef.id_t = int
-rbx.platform.typedef.lgrp_id_t = int
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.major_t = uint
-rbx.platform.typedef.minor_t = uint
-rbx.platform.typedef.pri_t = short
-rbx.platform.typedef.cpu_flag_t = ushort
-rbx.platform.typedef.o_mode_t = ushort
-rbx.platform.typedef.o_dev_t = short
-rbx.platform.typedef.o_uid_t = ushort
-rbx.platform.typedef.o_gid_t = ushort
-rbx.platform.typedef.o_nlink_t = short
-rbx.platform.typedef.o_pid_t = short
-rbx.platform.typedef.o_ino_t = ushort
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.datalink_id_t = uint
-rbx.platform.typedef.taskid_t = int
-rbx.platform.typedef.projid_t = int
-rbx.platform.typedef.poolid_t = int
-rbx.platform.typedef.zoneid_t = int
-rbx.platform.typedef.ctid_t = int
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.hrtime_t = long_long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.fds_mask = long
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.nfds_t = ulong
-rbx.platform.typedef.disp_lock_t = uchar
-rbx.platform.typedef.model_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.ipaddr_t = uint
-rbx.platform.typedef.rlim_t = ulong
-rbx.platform.typedef.rlim64_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/socket.rb b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/socket.rb
deleted file mode 100644
index 26b97a4..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/socket.rb
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform; end
-module Platform::Socket
- AF_APPLETALK = 16
- # AF_ATM not available
- # AF_AX25 not available
- AF_CCITT = 10
- AF_CHAOS = 5
- # AF_CNT not available
- # AF_COIP not available
- AF_DATAKIT = 9
- AF_DECnet = 12
- AF_DLI = 13
- # AF_E164 not available
- AF_ECMA = 8
- AF_HYLINK = 15
- AF_IMPLINK = 3
- AF_INET = 2
- AF_INET6 = 26
- AF_IPX = 23
- # AF_ISDN not available
- # AF_ISO not available
- AF_LAT = 14
- AF_LINK = 25
- AF_LOCAL = 1
- AF_MAX = 30
- # AF_NATM not available
- # AF_NDRV not available
- # AF_NETBIOS not available
- # AF_NETGRAPH not available
- AF_NS = 6
- AF_OSI = 19
- # AF_PPP not available
- AF_PUP = 4
- AF_ROUTE = 24
- # AF_SIP not available
- AF_SNA = 11
- # AF_SYSTEM not available
- AF_UNIX = 1
- AF_UNSPEC = 0
- NI_DGRAM = 16
- # NI_FQDN_FLAG_VALIDTTL not available
- NI_MAXHOST = 1025
- NI_MAXSERV = 32
- NI_NAMEREQD = 4
- # NI_NODEADDR_FLAG_ALL not available
- # NI_NODEADDR_FLAG_ANYCAST not available
- # NI_NODEADDR_FLAG_COMPAT not available
- # NI_NODEADDR_FLAG_GLOBAL not available
- # NI_NODEADDR_FLAG_LINKLOCAL not available
- # NI_NODEADDR_FLAG_SITELOCAL not available
- # NI_NODEADDR_FLAG_TRUNCATE not available
- NI_NOFQDN = 1
- NI_NUMERICHOST = 2
- NI_NUMERICSERV = 8
- # NI_QTYPE_DNSNAME not available
- # NI_QTYPE_FQDN not available
- # NI_QTYPE_IPV4ADDR not available
- # NI_QTYPE_NODEADDR not available
- # NI_QTYPE_NOOP not available
- # NI_QTYPE_SUPTYPES not available
- # NI_SUPTYPE_FLAG_COMPRESS not available
- NI_WITHSCOPEID = 32
- PF_APPLETALK = 16
- # PF_ATM not available
- PF_CCITT = 10
- PF_CHAOS = 5
- # PF_CNT not available
- # PF_COIP not available
- PF_DATAKIT = 9
- PF_DECnet = 12
- PF_DLI = 13
- PF_ECMA = 8
- PF_HYLINK = 15
- PF_IMPLINK = 3
- PF_INET = 2
- PF_INET6 = 26
- PF_IPX = 23
- # PF_ISDN not available
- # PF_ISO not available
- PF_KEY = 27
- PF_LAT = 14
- PF_LINK = 25
- PF_LOCAL = 1
- PF_MAX = 30
- # PF_NATM not available
- # PF_NDRV not available
- # PF_NETBIOS not available
- # PF_NETGRAPH not available
- PF_NS = 6
- PF_OSI = 19
- # PF_PIP not available
- # PF_PPP not available
- PF_PUP = 4
- PF_ROUTE = 24
- # PF_RTIP not available
- # PF_SIP not available
- PF_SNA = 11
- # PF_SYSTEM not available
- PF_UNIX = 1
- PF_UNSPEC = 0
- # PF_XTP not available
- SOCK_DGRAM = 1
- # SOCK_MAXADDRLEN not available
- SOCK_RAW = 4
- SOCK_RDM = 5
- SOCK_SEQPACKET = 6
- SOCK_STREAM = 2
- SO_ACCEPTCONN = 2
- # SO_ACCEPTFILTER not available
- # SO_ATTACH_FILTER not available
- # SO_BINDTODEVICE not available
- SO_BROADCAST = 32
- SO_DEBUG = 1
- # SO_DETACH_FILTER not available
- SO_DONTROUTE = 16
- # SO_DONTTRUNC not available
- SO_ERROR = 4103
- SO_KEEPALIVE = 8
- # SO_LABEL not available
- SO_LINGER = 128
- # SO_NKE not available
- # SO_NOADDRERR not available
- # SO_NOSIGPIPE not available
- # SO_NO_CHECK not available
- # SO_NREAD not available
- # SO_NWRITE not available
- SO_OOBINLINE = 256
- # SO_PASSCRED not available
- # SO_PEERCRED not available
- # SO_PEERLABEL not available
- # SO_PEERNAME not available
- # SO_PRIORITY not available
- SO_RCVBUF = 4098
- SO_RCVLOWAT = 4100
- SO_RCVTIMEO = 4102
- SO_REUSEADDR = 4
- # SO_REUSEPORT not available
- # SO_REUSESHAREUID not available
- # SO_SECURITY_AUTHENTICATION not available
- # SO_SECURITY_ENCRYPTION_NETWORK not available
- # SO_SECURITY_ENCRYPTION_TRANSPORT not available
- SO_SNDBUF = 4097
- SO_SNDLOWAT = 4099
- SO_SNDTIMEO = 4101
- SO_TIMESTAMP = 4115
- SO_TYPE = 4104
- SO_USELOOPBACK = 64
- # SO_WANTMORE not available
- # SO_WANTOOBFLAG not available
- # pseudo_AF_HDRCMPLT not available
- # pseudo_AF_KEY not available
- # pseudo_AF_PIP not available
- # pseudo_AF_RTIP not available
- # pseudo_AF_XTP not available
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/stat.rb b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/stat.rb
deleted file mode 100644
index 512a6e2..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/stat.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform
- module Stat
- class Stat < FFI::Struct
- self.size = 128
- layout :st_dev, :dev_t, 0,
- :st_ino, :ino_t, 8,
- :st_nlink, :nlink_t, 20,
- :st_mode, :mode_t, 16,
- :st_uid, :uid_t, 24,
- :st_gid, :gid_t, 28,
- :st_size, :off_t, 40,
- :st_blocks, :blkcnt_t, 104,
- :st_atime, :time_t, 48,
- :st_mtime, :time_t, 64,
- :st_ctime, :time_t, 80
-
-
-
-
-
-
- end
- module Constants
- S_IEXEC = 0x40
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
-
-
-
-
-
-
-
- end
- include Constants
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/sysconf.rb b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/sysconf.rb
deleted file mode 100644
index 53d6fff..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/sysconf.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Platform;end
-module Platform::Sysconf
- SC_2_CHAR_TERM = 66
- SC_2_C_BIND = 45
- SC_2_C_DEV = 46
- SC_2_FORT_DEV = 48
- SC_2_FORT_RUN = 49
- SC_2_LOCALEDEF = 50
- SC_2_PBS = 724
- SC_2_PBS_ACCOUNTING = 725
- SC_2_PBS_CHECKPOINT = 726
- SC_2_PBS_LOCATE = 728
- SC_2_PBS_MESSAGE = 729
- SC_2_PBS_TRACK = 730
- SC_2_SW_DEV = 51
- SC_2_UPE = 52
- SC_2_VERSION = 53
- SC_ADVISORY_INFO = 731
- SC_AIO_LISTIO_MAX = 18
- SC_AIO_MAX = 19
- SC_AIO_PRIO_DELTA_MAX = 20
- SC_ARG_MAX = 1
- SC_ASYNCHRONOUS_IO = 21
- SC_ATEXIT_MAX = 76
- SC_BARRIERS = 732
- SC_BC_BASE_MAX = 54
- SC_BC_DIM_MAX = 55
- SC_BC_SCALE_MAX = 56
- SC_BC_STRING_MAX = 57
- SC_CHILD_MAX = 2
- SC_CLK_TCK = 3
- SC_CLOCK_SELECTION = 733
- SC_COLL_WEIGHTS_MAX = 58
- SC_CPUTIME = 734
- SC_DELAYTIMER_MAX = 22
- SC_EXPR_NEST_MAX = 59
- # _SC_FILE_LOCKING not available
- SC_FSYNC = 23
- SC_GETGR_R_SIZE_MAX = 569
- SC_GETPW_R_SIZE_MAX = 570
- SC_HOST_NAME_MAX = 735
- SC_IOV_MAX = 77
- SC_IPV6 = 762
- SC_JOB_CONTROL = 6
- SC_LINE_MAX = 60
- SC_LOGIN_NAME_MAX = 571
- SC_MAPPED_FILES = 24
- SC_MEMLOCK = 25
- SC_MEMLOCK_RANGE = 26
- SC_MEMORY_PROTECTION = 27
- SC_MESSAGE_PASSING = 28
- SC_MONOTONIC_CLOCK = 736
- SC_MQ_OPEN_MAX = 29
- SC_MQ_PRIO_MAX = 30
- SC_NGROUPS_MAX = 4
- SC_NPROCESSORS_CONF = 14
- SC_NPROCESSORS_ONLN = 15
- SC_OPEN_MAX = 5
- SC_PAGESIZE = 11
- SC_PAGE_SIZE = 11
- SC_PASS_MAX = 9
- SC_PRIORITIZED_IO = 31
- SC_PRIORITY_SCHEDULING = 32
- SC_RAW_SOCKETS = 763
- SC_READER_WRITER_LOCKS = 737
- SC_REALTIME_SIGNALS = 33
- SC_REGEXP = 738
- SC_RE_DUP_MAX = 61
- SC_RTSIG_MAX = 34
- SC_SAVED_IDS = 7
- SC_SEMAPHORES = 35
- SC_SEM_NSEMS_MAX = 36
- SC_SEM_VALUE_MAX = 37
- SC_SHARED_MEMORY_OBJECTS = 38
- SC_SHELL = 739
- SC_SIGQUEUE_MAX = 39
- SC_SPAWN = 740
- SC_SPIN_LOCKS = 741
- SC_SPORADIC_SERVER = 742
- SC_SS_REPL_MAX = 743
- SC_STREAM_MAX = 16
- SC_SYMLOOP_MAX = 744
- SC_SYNCHRONIZED_IO = 42
- SC_THREADS = 576
- SC_THREAD_ATTR_STACKADDR = 577
- SC_THREAD_ATTR_STACKSIZE = 578
- SC_THREAD_CPUTIME = 745
- SC_THREAD_DESTRUCTOR_ITERATIONS = 568
- SC_THREAD_KEYS_MAX = 572
- SC_THREAD_PRIORITY_SCHEDULING = 579
- SC_THREAD_PRIO_INHERIT = 580
- SC_THREAD_PRIO_PROTECT = 581
- SC_THREAD_PROCESS_SHARED = 582
- SC_THREAD_SAFE_FUNCTIONS = 583
- SC_THREAD_SPORADIC_SERVER = 746
- SC_THREAD_STACK_MIN = 573
- SC_THREAD_THREADS_MAX = 574
- SC_TIMEOUTS = 747
- SC_TIMERS = 43
- SC_TIMER_MAX = 44
- SC_TRACE = 748
- SC_TRACE_EVENT_FILTER = 749
- SC_TRACE_EVENT_NAME_MAX = 750
- SC_TRACE_INHERIT = 751
- SC_TRACE_LOG = 752
- SC_TRACE_NAME_MAX = 753
- SC_TRACE_SYS_MAX = 754
- SC_TRACE_USER_EVENT_MAX = 755
- SC_TTY_NAME_MAX = 575
- SC_TYPED_MEMORY_OBJECTS = 756
- SC_TZNAME_MAX = 17
- SC_V6_ILP32_OFF32 = 757
- SC_V6_ILP32_OFFBIG = 758
- SC_V6_LP64_OFF64 = 759
- SC_V6_LPBIG_OFFBIG = 760
- SC_VERSION = 8
- SC_XBS5_ILP32_OFF32 = 720
- SC_XBS5_ILP32_OFFBIG = 721
- SC_XBS5_LP64_OFF64 = 722
- SC_XBS5_LPBIG_OFFBIG = 723
- SC_XOPEN_CRYPT = 62
- SC_XOPEN_ENH_I18N = 63
- SC_XOPEN_LEGACY = 717
- SC_XOPEN_REALTIME = 718
- SC_XOPEN_REALTIME_THREADS = 719
- SC_XOPEN_SHM = 64
- SC_XOPEN_STREAMS = 761
- SC_XOPEN_UNIX = 78
- SC_XOPEN_VERSION = 12
- SC_XOPEN_XCU_VERSION = 67
-
-
-
-
-
-
-
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/syslog.rb b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/syslog.rb
deleted file mode 100644
index 4f0f711..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/syslog.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-module Syslog
- module Constants
- LOG_ALERT = 1
- LOG_AUTH = 32
- # LOG_AUTHPRIV not available
- LOG_CONS = 2
- # LOG_CONSOLE not available
- LOG_CRIT = 2
- LOG_CRON = 120
- LOG_DAEMON = 24
- LOG_DEBUG = 7
- LOG_EMERG = 0
- LOG_ERR = 3
- # LOG_FTP not available
- LOG_INFO = 6
- LOG_KERN = 0
- LOG_LOCAL0 = 128
- LOG_LOCAL1 = 136
- LOG_LOCAL2 = 144
- LOG_LOCAL3 = 152
- LOG_LOCAL4 = 160
- LOG_LOCAL5 = 168
- LOG_LOCAL6 = 176
- LOG_LOCAL7 = 184
- LOG_LPR = 48
- LOG_MAIL = 16
- LOG_NEWS = 56
- # LOG_NODELAY not available
- LOG_NOTICE = 5
- LOG_NOWAIT = 16
- # LOG_NTP not available
- LOG_ODELAY = 4
- # LOG_PERROR not available
- LOG_PID = 1
- # LOG_SECURITY not available
- LOG_SYSLOG = 40
- LOG_USER = 8
- LOG_UUCP = 64
- LOG_WARNING = 4
-
-
-
-
-
- end
-end
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/types.conf b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/types.conf
deleted file mode 100644
index f461b7e..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/types.conf
+++ /dev/null
@@ -1,122 +0,0 @@
-rbx.platform.typedef.lock_t = uchar
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong
-rbx.platform.typedef.intmax_t = long
-rbx.platform.typedef.uintmax_t = ulong
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = int
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.int_fast64_t = long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = uint
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.uint_fast64_t = ulong
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong
-rbx.platform.typedef.longlong_t = long_long
-rbx.platform.typedef.u_longlong_t = ulong_long
-rbx.platform.typedef.t_scalar_t = int
-rbx.platform.typedef.t_uscalar_t = uint
-rbx.platform.typedef.uchar_t = uchar
-rbx.platform.typedef.ushort_t = ushort
-rbx.platform.typedef.uint_t = uint
-rbx.platform.typedef.ulong_t = ulong
-rbx.platform.typedef.*caddr_t = char
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.cnt_t = short
-rbx.platform.typedef.ptrdiff_t = long
-rbx.platform.typedef.pfn_t = ulong
-rbx.platform.typedef.pgcnt_t = ulong
-rbx.platform.typedef.spgcnt_t = long
-rbx.platform.typedef.use_t = uchar
-rbx.platform.typedef.sysid_t = short
-rbx.platform.typedef.index_t = short
-rbx.platform.typedef.off_t = long
-rbx.platform.typedef.off64_t = long
-rbx.platform.typedef.ino_t = ulong
-rbx.platform.typedef.blkcnt_t = long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.ino64_t = ulong
-rbx.platform.typedef.blkcnt64_t = long
-rbx.platform.typedef.fsblkcnt64_t = ulong
-rbx.platform.typedef.fsfilcnt64_t = ulong
-rbx.platform.typedef.blksize_t = int
-rbx.platform.typedef.pad64_t = long
-rbx.platform.typedef.upad64_t = ulong
-rbx.platform.typedef.offset_t = long_long
-rbx.platform.typedef.u_offset_t = ulong_long
-rbx.platform.typedef.len_t = ulong_long
-rbx.platform.typedef.diskaddr_t = ulong_long
-rbx.platform.typedef.k_fltset_t = uint
-rbx.platform.typedef.id_t = int
-rbx.platform.typedef.lgrp_id_t = int
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.major_t = uint
-rbx.platform.typedef.minor_t = uint
-rbx.platform.typedef.pri_t = short
-rbx.platform.typedef.cpu_flag_t = ushort
-rbx.platform.typedef.o_mode_t = ushort
-rbx.platform.typedef.o_dev_t = short
-rbx.platform.typedef.o_uid_t = ushort
-rbx.platform.typedef.o_gid_t = ushort
-rbx.platform.typedef.o_nlink_t = short
-rbx.platform.typedef.o_pid_t = short
-rbx.platform.typedef.o_ino_t = ushort
-rbx.platform.typedef.key_t = int
-rbx.platform.typedef.mode_t = uint
-rbx.platform.typedef.uid_t = uint
-rbx.platform.typedef.gid_t = uint
-rbx.platform.typedef.datalink_id_t = uint
-rbx.platform.typedef.taskid_t = int
-rbx.platform.typedef.projid_t = int
-rbx.platform.typedef.poolid_t = int
-rbx.platform.typedef.zoneid_t = int
-rbx.platform.typedef.ctid_t = int
-rbx.platform.typedef.pthread_t = uint
-rbx.platform.typedef.pthread_key_t = uint
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.size_t = ulong
-rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.clock_t = long
-rbx.platform.typedef.clockid_t = int
-rbx.platform.typedef.timer_t = int
-rbx.platform.typedef.unchar = uchar
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.hrtime_t = long_long
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.fds_mask = long
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.nfds_t = ulong
-rbx.platform.typedef.disp_lock_t = uchar
-rbx.platform.typedef.model_t = uint
-rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.in_addr_t = uint
-rbx.platform.typedef.ipaddr_t = uint
-rbx.platform.typedef.rlim_t = ulong
-rbx.platform.typedef.rlim64_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/zlib.rb b/src/main/resources/stdlib/ffi/platform/x86_64-solaris/zlib.rb
deleted file mode 100644
index 38e3713..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-solaris/zlib.rb
+++ /dev/null
@@ -1,1465 +0,0 @@
-# This file is generated by rake. Do not edit.
-
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- ZLIB_VERSION = "1.2.3"
- BEST_COMPRESSION = 9
- BEST_SPEED = 1
- BLOCK = 5
- BUF_ERROR = -5
- DATA_ERROR = -3
- DEFAULT_COMPRESSION = -1
- DEFAULT_STRATEGY = 0
- DEFLATED = 8
- ERRNO = -1
- FILTERED = 1
- FINISH = 4
- FIXED = 4
- FULL_FLUSH = 3
- HUFFMAN_ONLY = 2
- MEM_ERROR = -4
- NEED_DICT = 2
- NO_COMPRESSION = 0
- NO_FLUSH = 0
- OK = 0
- PARTIAL_FLUSH = 1
- RLE = 3
- STREAM_END = 1
- STREAM_ERROR = -2
- SYNC_FLUSH = 2
- VERSION_ERROR = -6
-
-
-
-
-
-
-
-
-
-
-
- # DEF_MEM_LEVEL not available
- MAX_MEM_LEVEL = 9
- MAX_WBITS = 15
-
-
-
-
-
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- # OS_CODE not available
-
-
-
-
-
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- self.size = 112
- layout :next_in, :pointer, 0,
- :avail_in, :uint, 8,
- :total_in, :ulong, 16,
- :next_out, :pointer, 24,
- :avail_out, :uint, 32,
- :total_out, :ulong, 40,
- :msg, :string, 48,
- :state, :pointer, 56,
- :zalloc, :pointer, 64,
- :zfree, :pointer, 72,
- :opaque, :pointer, 80,
- :data_type, :int, 88,
- :adler, :ulong, 96,
- :reserved, :ulong, 104
-
-
-
-
-
-
-
-
-
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-windows/platform.conf b/src/main/resources/stdlib/ffi/platform/x86_64-windows/platform.conf
deleted file mode 100644
index d79a5ca..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-windows/platform.conf
+++ /dev/null
@@ -1,520 +0,0 @@
-rbx.platform.dirent.sizeof = 276
-rbx.platform.dirent.d_ino.offset = 4
-rbx.platform.dirent.d_ino.size = 8
-rbx.platform.dirent.d_ino.type = ino_t
-rbx.platform.dirent.d_name.offset = 20
-rbx.platform.dirent.d_name.size = 256
-rbx.platform.dirent.d_name.type = char_array
-rbx.platform.timeval.sizeof = 8
-rbx.platform.timeval.tv_sec.offset = 0
-rbx.platform.timeval.tv_sec.size = 4
-rbx.platform.timeval.tv_sec.type = time_t
-rbx.platform.timeval.tv_usec.offset = 4
-rbx.platform.timeval.tv_usec.size = 4
-rbx.platform.timeval.tv_usec.type = suseconds_t
-rbx.platform.sockaddr_in.sizeof = 16
-rbx.platform.sockaddr_in.sin_family.offset = 0
-rbx.platform.sockaddr_in.sin_family.size = 2
-rbx.platform.sockaddr_in.sin_family.type = sa_family_t
-rbx.platform.sockaddr_in.sin_port.offset = 2
-rbx.platform.sockaddr_in.sin_port.size = 2
-rbx.platform.sockaddr_in.sin_port.type = ushort
-rbx.platform.sockaddr_in.sin_addr.offset = 4
-rbx.platform.sockaddr_in.sin_addr.size = 4
-rbx.platform.sockaddr_in.sin_zero.offset = 8
-rbx.platform.sockaddr_in.sin_zero.size = 8
-rbx.platform.sockaddr_in.sin_zero.type = char_array
-rbx.platform.sockaddr_un.sizeof = 110
-rbx.platform.sockaddr_un.sun_family.offset = 0
-rbx.platform.sockaddr_un.sun_family.size = 2
-rbx.platform.sockaddr_un.sun_family.type = sa_family_t
-rbx.platform.sockaddr_un.sun_path.offset = 2
-rbx.platform.sockaddr_un.sun_path.size = 108
-rbx.platform.sockaddr_un.sun_path.type = char_array
-rbx.platform.servent.sizeof = 16
-rbx.platform.servent.s_name.offset = 0
-rbx.platform.servent.s_name.size = 4
-rbx.platform.servent.s_name.type = pointer
-rbx.platform.servent.s_aliases.offset = 4
-rbx.platform.servent.s_aliases.size = 4
-rbx.platform.servent.s_aliases.type = pointer
-rbx.platform.servent.s_port.offset = 8
-rbx.platform.servent.s_port.size = 2
-rbx.platform.servent.s_port.type = int
-rbx.platform.servent.s_proto.offset = 12
-rbx.platform.servent.s_proto.size = 4
-rbx.platform.servent.s_proto.type = pointer
-rbx.platform.stat.sizeof = 96
-rbx.platform.stat.st_dev.offset = 0
-rbx.platform.stat.st_dev.size = 4
-rbx.platform.stat.st_dev.type = dev_t
-rbx.platform.stat.st_ino.offset = 8
-rbx.platform.stat.st_ino.size = 8
-rbx.platform.stat.st_ino.type = ino_t
-rbx.platform.stat.st_mode.offset = 16
-rbx.platform.stat.st_mode.size = 4
-rbx.platform.stat.st_mode.type = mode_t
-rbx.platform.stat.st_nlink.offset = 20
-rbx.platform.stat.st_nlink.size = 2
-rbx.platform.stat.st_nlink.type = nlink_t
-rbx.platform.stat.st_uid.offset = 24
-rbx.platform.stat.st_uid.size = 4
-rbx.platform.stat.st_uid.type = uid_t
-rbx.platform.stat.st_gid.offset = 28
-rbx.platform.stat.st_gid.size = 4
-rbx.platform.stat.st_gid.type = gid_t
-rbx.platform.stat.st_rdev.offset = 32
-rbx.platform.stat.st_rdev.size = 4
-rbx.platform.stat.st_rdev.type = dev_t
-rbx.platform.stat.st_size.offset = 40
-rbx.platform.stat.st_size.size = 8
-rbx.platform.stat.st_size.type = off_t
-rbx.platform.stat.st_blksize.offset = 72
-rbx.platform.stat.st_blksize.size = 4
-rbx.platform.stat.st_blocks.offset = 80
-rbx.platform.stat.st_blocks.size = 8
-rbx.platform.stat.st_atime.offset = 48
-rbx.platform.stat.st_atime.size = 4
-rbx.platform.stat.st_atime.type = time_t
-rbx.platform.stat.st_mtime.offset = 56
-rbx.platform.stat.st_mtime.size = 4
-rbx.platform.stat.st_mtime.type = time_t
-rbx.platform.stat.st_ctime.offset = 64
-rbx.platform.stat.st_ctime.size = 4
-rbx.platform.stat.st_ctime.type = time_t
-rbx.platform.rlimit.sizeof = 8
-rbx.platform.rlimit.rlim_cur.offset = 0
-rbx.platform.rlimit.rlim_cur.size = 4
-rbx.platform.rlimit.rlim_cur.type = rlim_t
-rbx.platform.rlimit.rlim_max.offset = 4
-rbx.platform.rlimit.rlim_max.size = 4
-rbx.platform.rlimit.rlim_max.type = rlim_t
-rbx.platform.file.O_RDONLY = 0
-rbx.platform.file.O_WRONLY = 1
-rbx.platform.file.O_RDWR = 2
-rbx.platform.file.O_CREAT = 512
-rbx.platform.file.O_EXCL = 2048
-rbx.platform.file.O_NOCTTY = 32768
-rbx.platform.file.O_TRUNC = 1024
-rbx.platform.file.O_APPEND = 8
-rbx.platform.file.O_NONBLOCK = 16384
-rbx.platform.file.O_SYNC = 8192
-rbx.platform.file.S_IRUSR = 256
-rbx.platform.file.S_IWUSR = 128
-rbx.platform.file.S_IXUSR = 64
-rbx.platform.file.S_IRGRP = 32
-rbx.platform.file.S_IWGRP = 16
-rbx.platform.file.S_IXGRP = 8
-rbx.platform.file.S_IROTH = 4
-rbx.platform.file.S_IWOTH = 2
-rbx.platform.file.S_IXOTH = 1
-rbx.platform.file.S_IFMT = 61440
-rbx.platform.file.S_IFIFO = 4096
-rbx.platform.file.S_IFCHR = 8192
-rbx.platform.file.S_IFDIR = 16384
-rbx.platform.file.S_IFBLK = 24576
-rbx.platform.file.S_IFREG = 32768
-rbx.platform.file.S_IFLNK = 40960
-rbx.platform.file.S_IFSOCK = 49152
-rbx.platform.file.S_IFWHT =
-rbx.platform.file.S_ISUID = 2048
-rbx.platform.file.S_ISGID = 1024
-rbx.platform.io.SEEK_SET = 0
-rbx.platform.io.SEEK_CUR = 1
-rbx.platform.io.SEEK_END = 2
-rbx.platform.fcntl.F_GETFL = 3
-rbx.platform.fcntl.F_SETFL = 4
-rbx.platform.fcntl.O_ACCMODE = 3
-rbx.platform.socket.AF_APPLETALK = 16
-rbx.platform.socket.AF_ATM =
-rbx.platform.socket.AF_AX25 =
-rbx.platform.socket.AF_CCITT = 10
-rbx.platform.socket.AF_CHAOS = 5
-rbx.platform.socket.AF_CNT =
-rbx.platform.socket.AF_COIP =
-rbx.platform.socket.AF_DATAKIT = 9
-rbx.platform.socket.AF_DEC =
-rbx.platform.socket.AF_DLI = 13
-rbx.platform.socket.AF_E164 =
-rbx.platform.socket.AF_ECMA = 8
-rbx.platform.socket.AF_HYLINK = 15
-rbx.platform.socket.AF_IMPLINK = 3
-rbx.platform.socket.AF_INET = 2
-rbx.platform.socket.AF_INET6 = 23
-rbx.platform.socket.AF_IPX =
-rbx.platform.socket.AF_ISDN =
-rbx.platform.socket.AF_ISO = 7
-rbx.platform.socket.AF_LAT = 14
-rbx.platform.socket.AF_LINK =
-rbx.platform.socket.AF_LOCAL = 1
-rbx.platform.socket.AF_MAX = 32
-rbx.platform.socket.AF_NATM =
-rbx.platform.socket.AF_NDRV =
-rbx.platform.socket.AF_NETBIOS = 17
-rbx.platform.socket.AF_NETGRAPH =
-rbx.platform.socket.AF_NS = 6
-rbx.platform.socket.AF_OSI = 7
-rbx.platform.socket.AF_PPP =
-rbx.platform.socket.AF_PUP = 4
-rbx.platform.socket.AF_ROUTE =
-rbx.platform.socket.AF_SIP =
-rbx.platform.socket.AF_SNA = 11
-rbx.platform.socket.AF_SYSTEM =
-rbx.platform.socket.AF_UNIX = 1
-rbx.platform.socket.AF_UNSPEC = 0
-rbx.platform.socket.AI_ADDRCONFIG = 1024
-rbx.platform.socket.AI_ALL = 256
-rbx.platform.socket.AI_CANONNAME = 2
-rbx.platform.socket.AI_DEFAULT =
-rbx.platform.socket.AI_MASK =
-rbx.platform.socket.AI_NUMERICHOST = 4
-rbx.platform.socket.AI_PASSIVE = 1
-rbx.platform.socket.AI_V4MAPPED = 2048
-rbx.platform.socket.AI_V4MAPPED_CFG =
-rbx.platform.socket.EAI_ADDRFAMILY = 1
-rbx.platform.socket.EAI_AGAIN = 2
-rbx.platform.socket.EAI_BADFLAGS = 3
-rbx.platform.socket.EAI_BADHINTS = 12
-rbx.platform.socket.EAI_FAIL = 4
-rbx.platform.socket.EAI_FAMILY = 5
-rbx.platform.socket.EAI_MAX =
-rbx.platform.socket.EAI_MEMORY = 6
-rbx.platform.socket.EAI_NODATA = 7
-rbx.platform.socket.EAI_NONAME = 8
-rbx.platform.socket.EAI_PROTOCOL = 13
-rbx.platform.socket.EAI_SERVICE = 9
-rbx.platform.socket.EAI_SOCKTYPE = 10
-rbx.platform.socket.EAI_SYSTEM = 11
-rbx.platform.socket.INADDR_ALLHOSTS_GROUP = -536870911
-rbx.platform.socket.INADDR_ANY = 0
-rbx.platform.socket.INADDR_BROADCAST = -1
-rbx.platform.socket.INADDR_LOOPBACK = 2130706433
-rbx.platform.socket.INADDR_MAX_LOCAL_GROUP = -536870657
-rbx.platform.socket.INADDR_NONE = -1
-rbx.platform.socket.INADDR_UNSPEC_GROUP = -536870912
-rbx.platform.socket.IPPORT_RESERVED =
-rbx.platform.socket.IPPORT_USERRESERVED =
-rbx.platform.socket.IPPROTO_BIP =
-rbx.platform.socket.IPPROTO_EGP = 8
-rbx.platform.socket.IPPROTO_EON =
-rbx.platform.socket.IPPROTO_GGP =
-rbx.platform.socket.IPPROTO_HELLO =
-rbx.platform.socket.IPPROTO_ICMP = 1
-rbx.platform.socket.IPPROTO_IDP = 22
-rbx.platform.socket.IPPROTO_IGMP = 2
-rbx.platform.socket.IPPROTO_IP = 0
-rbx.platform.socket.IPPROTO_MAX =
-rbx.platform.socket.IPPROTO_ND =
-rbx.platform.socket.IPPROTO_PUP = 12
-rbx.platform.socket.IPPROTO_RAW = 255
-rbx.platform.socket.IPPROTO_TCP = 6
-rbx.platform.socket.IPPROTO_TP =
-rbx.platform.socket.IPPROTO_UDP = 17
-rbx.platform.socket.IPPROTO_XTP =
-rbx.platform.socket.IPX_TYPE = 1
-rbx.platform.socket.IP_ADD_MEMBERSHIP = 12
-rbx.platform.socket.IP_DEFAULT_MULTICAST_LOOP = 1
-rbx.platform.socket.IP_DEFAULT_MULTICAST_TTL = 1
-rbx.platform.socket.IP_DROP_MEMBERSHIP = 13
-rbx.platform.socket.IP_HDRINCL = 2
-rbx.platform.socket.IP_MAX_MEMBERSHIPS = 20
-rbx.platform.socket.IP_MULTICAST_IF = 9
-rbx.platform.socket.IP_MULTICAST_LOOP = 11
-rbx.platform.socket.IP_MULTICAST_TTL = 10
-rbx.platform.socket.IP_OPTIONS = 1
-rbx.platform.socket.IP_RECVDSTADDR =
-rbx.platform.socket.IP_RECVOPTS =
-rbx.platform.socket.IP_RECVRETOPTS =
-rbx.platform.socket.IP_RETOPTS =
-rbx.platform.socket.IP_TOS = 3
-rbx.platform.socket.IP_TTL = 4
-rbx.platform.socket.MSG_COMPAT =
-rbx.platform.socket.MSG_CTRUNC = 512
-rbx.platform.socket.MSG_DONTROUTE = 4
-rbx.platform.socket.MSG_DONTWAIT = 16
-rbx.platform.socket.MSG_EOF =
-rbx.platform.socket.MSG_EOR =
-rbx.platform.socket.MSG_FLUSH =
-rbx.platform.socket.MSG_HAVEMORE =
-rbx.platform.socket.MSG_HOLD =
-rbx.platform.socket.MSG_OOB = 1
-rbx.platform.socket.MSG_PEEK = 2
-rbx.platform.socket.MSG_RCVMORE =
-rbx.platform.socket.MSG_SEND =
-rbx.platform.socket.MSG_TRUNC = 256
-rbx.platform.socket.MSG_WAITALL = 8
-rbx.platform.socket.NI_DGRAM = 16
-rbx.platform.socket.NI_MAXHOST = 1025
-rbx.platform.socket.NI_MAXSERV = 32
-rbx.platform.socket.NI_NAMEREQD = 4
-rbx.platform.socket.NI_NOFQDN = 1
-rbx.platform.socket.NI_NUMERICHOST = 2
-rbx.platform.socket.NI_NUMERICSERV = 8
-rbx.platform.socket.PF_APPLETALK = 16
-rbx.platform.socket.PF_AX25 =
-rbx.platform.socket.PF_CCITT = 10
-rbx.platform.socket.PF_CHAOS = 5
-rbx.platform.socket.PF_CNT =
-rbx.platform.socket.PF_COIP =
-rbx.platform.socket.PF_DATAKIT = 9
-rbx.platform.socket.PF_DLI = 13
-rbx.platform.socket.PF_ECMA = 8
-rbx.platform.socket.PF_HYLINK = 15
-rbx.platform.socket.PF_IMPLINK = 3
-rbx.platform.socket.PF_INET = 2
-rbx.platform.socket.PF_INET6 = 23
-rbx.platform.socket.PF_IPX =
-rbx.platform.socket.PF_ISDN =
-rbx.platform.socket.PF_ISO = 7
-rbx.platform.socket.PF_KEY =
-rbx.platform.socket.PF_LAT = 14
-rbx.platform.socket.PF_LINK =
-rbx.platform.socket.PF_LOCAL = 1
-rbx.platform.socket.PF_MAX = 32
-rbx.platform.socket.PF_NATM =
-rbx.platform.socket.PF_NDRV =
-rbx.platform.socket.PF_NETBIOS = 17
-rbx.platform.socket.PF_NETGRAPH =
-rbx.platform.socket.PF_NS = 6
-rbx.platform.socket.PF_OSI = 7
-rbx.platform.socket.PF_PIP =
-rbx.platform.socket.PF_PPP =
-rbx.platform.socket.PF_PUP = 4
-rbx.platform.socket.PF_ROUTE =
-rbx.platform.socket.PF_RTIP =
-rbx.platform.socket.PF_SIP =
-rbx.platform.socket.PF_SNA = 11
-rbx.platform.socket.PF_SYSTEM =
-rbx.platform.socket.PF_UNIX = 1
-rbx.platform.socket.PF_UNSPEC = 0
-rbx.platform.socket.PF_XTP =
-rbx.platform.socket.SHUT_RD = 0
-rbx.platform.socket.SHUT_RDWR = 2
-rbx.platform.socket.SHUT_WR = 1
-rbx.platform.socket.SOCK_DGRAM = 2
-rbx.platform.socket.SOCK_PACKET =
-rbx.platform.socket.SOCK_RAW = 3
-rbx.platform.socket.SOCK_RDM = 4
-rbx.platform.socket.SOCK_SEQPACKET = 5
-rbx.platform.socket.SOCK_STREAM = 1
-rbx.platform.socket.SOL_ATALK = 258
-rbx.platform.socket.SOL_AX25 = 257
-rbx.platform.socket.SOL_IP = 0
-rbx.platform.socket.SOL_IPX = 256
-rbx.platform.socket.SOL_SOCKET = 65535
-rbx.platform.socket.SOL_TCP = 6
-rbx.platform.socket.SOL_UDP = 17
-rbx.platform.socket.SOPRI_BACKGROUND = 2
-rbx.platform.socket.SOPRI_INTERACTIVE = 0
-rbx.platform.socket.SOPRI_NORMAL = 1
-rbx.platform.socket.SO_ACCEPTCONN = 2
-rbx.platform.socket.SO_ACCEPTFILTER =
-rbx.platform.socket.SO_ATTACH_FILTER =
-rbx.platform.socket.SO_BINDTODEVICE =
-rbx.platform.socket.SO_BROADCAST = 32
-rbx.platform.socket.SO_DEBUG = 1
-rbx.platform.socket.SO_DETACH_FILTER =
-rbx.platform.socket.SO_DONTROUTE = 16
-rbx.platform.socket.SO_DONTTRUNC =
-rbx.platform.socket.SO_ERROR = 4103
-rbx.platform.socket.SO_KEEPALIVE = 8
-rbx.platform.socket.SO_LINGER = 128
-rbx.platform.socket.SO_NKE =
-rbx.platform.socket.SO_NOSIGPIPE =
-rbx.platform.socket.SO_NO_CHECK =
-rbx.platform.socket.SO_NREAD =
-rbx.platform.socket.SO_OOBINLINE = 256
-rbx.platform.socket.SO_PASSCRED =
-rbx.platform.socket.SO_PEERCRED = 512
-rbx.platform.socket.SO_PEERNAME =
-rbx.platform.socket.SO_PRIORITY =
-rbx.platform.socket.SO_RCVBUF = 4098
-rbx.platform.socket.SO_RCVLOWAT = 4100
-rbx.platform.socket.SO_RCVTIMEO = 4102
-rbx.platform.socket.SO_REUSEADDR = 4
-rbx.platform.socket.SO_REUSEPORT =
-rbx.platform.socket.SO_SECURITY_AUTHENTICATION =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_NETWORK =
-rbx.platform.socket.SO_SECURITY_ENCRYPTION_TRANSPORT =
-rbx.platform.socket.SO_SNDBUF = 4097
-rbx.platform.socket.SO_SNDLOWAT = 4099
-rbx.platform.socket.SO_SNDTIMEO = 4101
-rbx.platform.socket.SO_TIMESTAMP =
-rbx.platform.socket.SO_TYPE = 4104
-rbx.platform.socket.SO_USELOOPBACK = 64
-rbx.platform.socket.SO_WANTMORE =
-rbx.platform.socket.SO_WANTOOBFLAG =
-rbx.platform.socket.TCP_MAXSEG = 2
-rbx.platform.socket.TCP_NODELAY = 1
-rbx.platform.process.WNOHANG = 1
-rbx.platform.process.WUNTRACED = 2
-rbx.platform.process.PRIO_PROCESS = 0
-rbx.platform.process.PRIO_PGRP = 1
-rbx.platform.process.PRIO_USER = 2
-rbx.platform.process.RLIMIT_CPU = 0
-rbx.platform.process.RLIMIT_FSIZE = 1
-rbx.platform.process.RLIMIT_DATA = 2
-rbx.platform.process.RLIMIT_STACK = 3
-rbx.platform.process.RLIMIT_CORE = 4
-rbx.platform.process.RLIMIT_RSS =
-rbx.platform.process.RLIMIT_NPROC =
-rbx.platform.process.RLIMIT_NOFILE = 5
-rbx.platform.process.RLIMIT_MEMLOCK =
-rbx.platform.process.RLIMIT_AS = 6
-rbx.platform.process.RLIMIT_SBSIZE =
-rbx.platform.process.RLIM_INFINITY = 4294967295
-rbx.platform.process.RLIM_SAVED_MAX = 4294967295
-rbx.platform.process.RLIM_SAVED_CUR = 4294967295
-rbx.platform.signal.SIGHUP = 1
-rbx.platform.signal.SIGINT = 2
-rbx.platform.signal.SIGQUIT = 3
-rbx.platform.signal.SIGILL = 4
-rbx.platform.signal.SIGTRAP = 5
-rbx.platform.signal.SIGIOT =
-rbx.platform.signal.SIGABRT = 6
-rbx.platform.signal.SIGEMT = 7
-rbx.platform.signal.SIGFPE = 8
-rbx.platform.signal.SIGKILL = 9
-rbx.platform.signal.SIGBUS = 10
-rbx.platform.signal.SIGSEGV = 11
-rbx.platform.signal.SIGSYS = 12
-rbx.platform.signal.SIGPIPE = 13
-rbx.platform.signal.SIGALRM = 14
-rbx.platform.signal.SIGTERM = 15
-rbx.platform.signal.SIGURG = 16
-rbx.platform.signal.SIGSTOP = 17
-rbx.platform.signal.SIGTSTP = 18
-rbx.platform.signal.SIGCONT = 19
-rbx.platform.signal.SIGCHLD = 20
-rbx.platform.signal.SIGCLD = 20
-rbx.platform.signal.SIGTTIN = 21
-rbx.platform.signal.SIGTTOU = 22
-rbx.platform.signal.SIGIO = 23
-rbx.platform.signal.SIGXCPU = 24
-rbx.platform.signal.SIGXFSZ = 25
-rbx.platform.signal.SIGVTALRM = 26
-rbx.platform.signal.SIGPROF = 27
-rbx.platform.signal.SIGWINCH = 28
-rbx.platform.signal.SIGUSR1 = 30
-rbx.platform.signal.SIGUSR2 = 31
-rbx.platform.signal.SIGLOST = 29
-rbx.platform.signal.SIGMSG =
-rbx.platform.signal.SIGPWR = 29
-rbx.platform.signal.SIGPOLL = 23
-rbx.platform.signal.SIGDANGER =
-rbx.platform.signal.SIGMIGRATE =
-rbx.platform.signal.SIGPRE =
-rbx.platform.signal.SIGGRANT =
-rbx.platform.signal.SIGRETRACT =
-rbx.platform.signal.SIGSOUND =
-rbx.platform.signal.SIGINFO =
-rbx.platform.zlib.ZLIB_VERSION = 1.2.5
-rbx.platform.typedef.__int8_t = char
-rbx.platform.typedef.__uint8_t = uchar
-rbx.platform.typedef.__int16_t = short
-rbx.platform.typedef.__uint16_t = ushort
-rbx.platform.typedef.__int_least16_t = short
-rbx.platform.typedef.__uint_least16_t = ushort
-rbx.platform.typedef.__int32_t = int
-rbx.platform.typedef.__uint32_t = uint
-rbx.platform.typedef.__int_least32_t = int
-rbx.platform.typedef.__uint_least32_t = uint
-rbx.platform.typedef.__int64_t = long_long
-rbx.platform.typedef.__uint64_t = ulong_long
-rbx.platform.typedef._off_t = long
-rbx.platform.typedef.__dev_t = short
-rbx.platform.typedef.__uid_t = ushort
-rbx.platform.typedef.__gid_t = ushort
-rbx.platform.typedef._off64_t = long_long
-rbx.platform.typedef._fpos_t = long
-rbx.platform.typedef._fpos64_t = long_long
-rbx.platform.typedef._ssize_t = int
-rbx.platform.typedef.wint_t = uint
-rbx.platform.typedef.ptrdiff_t = int
-rbx.platform.typedef.size_t = uint
-rbx.platform.typedef.__off_t = long
-rbx.platform.typedef.__pid_t = int
-rbx.platform.typedef.__loff_t = long_long
-rbx.platform.typedef.u_char = uchar
-rbx.platform.typedef.u_short = ushort
-rbx.platform.typedef.u_int = uint
-rbx.platform.typedef.u_long = ulong
-rbx.platform.typedef.ushort = ushort
-rbx.platform.typedef.uint = uint
-rbx.platform.typedef.ulong = ulong
-rbx.platform.typedef.clock_t = ulong
-rbx.platform.typedef.time_t = long
-rbx.platform.typedef.daddr_t = long
-rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.pid_t = int
-rbx.platform.typedef.ssize_t = int
-rbx.platform.typedef.nlink_t = ushort
-rbx.platform.typedef.fd_mask = long
-rbx.platform.typedef.clockid_t = ulong
-rbx.platform.typedef.timer_t = ulong
-rbx.platform.typedef.useconds_t = ulong
-rbx.platform.typedef.suseconds_t = long
-rbx.platform.typedef.int8_t = char
-rbx.platform.typedef.int16_t = short
-rbx.platform.typedef.int32_t = int
-rbx.platform.typedef.int64_t = long_long
-rbx.platform.typedef.uint8_t = uchar
-rbx.platform.typedef.uint16_t = ushort
-rbx.platform.typedef.uint32_t = uint
-rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.int_least8_t = char
-rbx.platform.typedef.int_least16_t = short
-rbx.platform.typedef.int_least32_t = int
-rbx.platform.typedef.int_least64_t = long_long
-rbx.platform.typedef.uint_least8_t = uchar
-rbx.platform.typedef.uint_least16_t = ushort
-rbx.platform.typedef.uint_least32_t = uint
-rbx.platform.typedef.uint_least64_t = ulong_long
-rbx.platform.typedef.int_fast8_t = char
-rbx.platform.typedef.int_fast16_t = int
-rbx.platform.typedef.int_fast32_t = int
-rbx.platform.typedef.int_fast64_t = long_long
-rbx.platform.typedef.uint_fast8_t = uchar
-rbx.platform.typedef.uint_fast16_t = uint
-rbx.platform.typedef.uint_fast32_t = uint
-rbx.platform.typedef.uint_fast64_t = ulong_long
-rbx.platform.typedef.intptr_t = int
-rbx.platform.typedef.uintptr_t = ulong_long
-rbx.platform.typedef.intmax_t = long_long
-rbx.platform.typedef.uintmax_t = ulong_long
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.loff_t = long_long
-rbx.platform.typedef.__dev16_t = short
-rbx.platform.typedef.__dev32_t = ulong
-rbx.platform.typedef.dev_t = ulong
-rbx.platform.typedef.blksize_t = long
-rbx.platform.typedef.__blkcnt32_t = long
-rbx.platform.typedef.__blkcnt64_t = long_long
-rbx.platform.typedef.blkcnt_t = long_long
-rbx.platform.typedef.fsblkcnt_t = ulong
-rbx.platform.typedef.fsfilcnt_t = ulong
-rbx.platform.typedef.__uid16_t = ushort
-rbx.platform.typedef.__uid32_t = ulong
-rbx.platform.typedef.uid_t = ulong
-rbx.platform.typedef.__gid16_t = ushort
-rbx.platform.typedef.__gid32_t = ulong
-rbx.platform.typedef.gid_t = ulong
-rbx.platform.typedef.__ino32_t = ulong
-rbx.platform.typedef.__ino64_t = ulong_long
-rbx.platform.typedef.ino_t = ulong_long
-rbx.platform.typedef.id_t = ulong
-rbx.platform.typedef.key_t = long_long
-rbx.platform.typedef.vm_offset_t = ulong
-rbx.platform.typedef.vm_size_t = ulong
-rbx.platform.typedef.u_int8_t = uchar
-rbx.platform.typedef.u_int16_t = ushort
-rbx.platform.typedef.u_int32_t = uint
-rbx.platform.typedef.u_int64_t = ulong_long
-rbx.platform.typedef.register_t = int
-rbx.platform.typedef.*addr_t = char
-rbx.platform.typedef.socklen_t = int
-rbx.platform.typedef.sa_family_t = ushort
-rbx.platform.typedef.__ULong = ulong
-rbx.platform.typedef.sigset_t = ulong
-rbx.platform.typedef.sig_atomic_t = int
-rbx.platform.typedef.rlim_t = ulong
diff --git a/src/main/resources/stdlib/ffi/platform/x86_64-windows/types.conf b/src/main/resources/stdlib/ffi/platform/x86_64-windows/types.conf
deleted file mode 100644
index 0909c19..0000000
--- a/src/main/resources/stdlib/ffi/platform/x86_64-windows/types.conf
+++ /dev/null
@@ -1,27 +0,0 @@
-rbx.platform.typedef.size_t = ulong_long
-rbx.platform.typedef.ssize_t = long_long
-rbx.platform.typedef.intptr_t = long_long
-rbx.platform.typedef.uintptr_t = ulong_long
-rbx.platform.typedef.ptrdiff_t = long_long
-rbx.platform.typedef.wchar_t = ushort
-rbx.platform.typedef.wint_t = ushort
-rbx.platform.typedef.wctype_t = ushort
-rbx.platform.typedef.errno_t = int
-rbx.platform.typedef.__time32_t = long
-rbx.platform.typedef.__time64_t = long_long
-rbx.platform.typedef.time_t = long_long
-rbx.platform.typedef._ino_t = ushort
-rbx.platform.typedef.ino_t = ushort
-rbx.platform.typedef._dev_t = uint
-rbx.platform.typedef.dev_t = uint
-rbx.platform.typedef._pid_t = long_long
-rbx.platform.typedef.pid_t = long_long
-rbx.platform.typedef._mode_t = ushort
-rbx.platform.typedef.mode_t = ushort
-rbx.platform.typedef._off_t = long
-rbx.platform.typedef.off32_t = long
-rbx.platform.typedef._off64_t = long_long
-rbx.platform.typedef.off64_t = long_long
-rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef._sigset_t = ulong_long
diff --git a/src/main/resources/stdlib/ffi/platform/zlib.rb.ffi b/src/main/resources/stdlib/ffi/platform/zlib.rb.ffi
deleted file mode 100644
index 6bfa9ca..0000000
--- a/src/main/resources/stdlib/ffi/platform/zlib.rb.ffi
+++ /dev/null
@@ -1,1467 +0,0 @@
-##
-# The Zlib module contains several classes for compressing and decompressing
-# streams, and for working with "gzip" files.
-#
-# == Classes
-#
-# Following are the classes that are most likely to be of interest to the
-# user:
-# - Zlib::Inflate
-# - Zlib::Deflate
-# - Zlib::GzipReader
-# - Zlib::GzipWriter
-#
-# There are two important base classes for the classes above: Zlib::ZStream
-# and Zlib::GzipFile. Everything else is an error class.
-#
-# == Constants
-#
-# Here's a list.
-#
-# Zlib::VERSION
-# The Ruby/zlib version string.
-#
-# Zlib::ZLIB_VERSION
-# The string which represents the version of zlib.h.
-#
-# Zlib::BINARY
-# Zlib::ASCII
-# Zlib::UNKNOWN
-# The integers representing data types which Zlib::ZStream#data_type
-# method returns.
-#
-# Zlib::NO_COMPRESSION
-# Zlib::BEST_SPEED
-# Zlib::BEST_COMPRESSION
-# Zlib::DEFAULT_COMPRESSION
-# The integers representing compression levels which are an argument
-# for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
-#
-# Zlib::FILTERED
-# Zlib::HUFFMAN_ONLY
-# Zlib::DEFAULT_STRATEGY
-# The integers representing compression methods which are an argument
-# for Zlib::Deflate.new and Zlib::Deflate#params.
-#
-# Zlib::DEF_MEM_LEVEL
-# Zlib::MAX_MEM_LEVEL
-# The integers representing memory levels which are an argument for
-# Zlib::Deflate.new, Zlib::Deflate#params, and so on.
-#
-# Zlib::MAX_WBITS
-# The default value of windowBits which is an argument for
-# Zlib::Deflate.new and Zlib::Inflate.new.
-#
-# Zlib::NO_FLUSH
-# Zlib::SYNC_FLUSH
-# Zlib::FULL_FLUSH
-# Zlib::FINISH
-# The integers to control the output of the deflate stream, which are
-# an argument for Zlib::Deflate#deflate and so on.
-#--
-# These constants are missing!
-#
-# Zlib::OS_CODE
-# Zlib::OS_MSDOS
-# Zlib::OS_AMIGA
-# Zlib::OS_VMS
-# Zlib::OS_UNIX
-# Zlib::OS_VMCMS
-# Zlib::OS_ATARI
-# Zlib::OS_OS2
-# Zlib::OS_MACOS
-# Zlib::OS_ZSYSTEM
-# Zlib::OS_CPM
-# Zlib::OS_TOPS20
-# Zlib::OS_WIN32
-# Zlib::OS_QDOS
-# Zlib::OS_RISCOS
-# Zlib::OS_UNKNOWN
-# The return values of Zlib::GzipFile#os_code method.
-
-module Zlib
-
- @@@
- constants :required => true do |c|
- c.include 'zlib.h'
-
- c.const 'ZLIB_VERSION', '%s', '(char *)', nil, to_s
-
- c.const 'Z_NO_FLUSH', nil, nil, 'NO_FLUSH'
- c.const 'Z_PARTIAL_FLUSH', nil, nil, 'PARTIAL_FLUSH'
- c.const 'Z_SYNC_FLUSH', nil, nil, 'SYNC_FLUSH'
- c.const 'Z_FULL_FLUSH', nil, nil, 'FULL_FLUSH'
- c.const 'Z_FINISH', nil, nil, 'FINISH'
- c.const 'Z_BLOCK', nil, nil, 'BLOCK'
-
- c.const 'Z_OK', nil, nil, 'OK'
- c.const 'Z_STREAM_END', nil, nil, 'STREAM_END'
- c.const 'Z_NEED_DICT', nil, nil, 'NEED_DICT'
- c.const 'Z_ERRNO', nil, nil, 'ERRNO'
- c.const 'Z_STREAM_ERROR', nil, nil, 'STREAM_ERROR'
- c.const 'Z_DATA_ERROR', nil, nil, 'DATA_ERROR'
- c.const 'Z_MEM_ERROR', nil, nil, 'MEM_ERROR'
- c.const 'Z_BUF_ERROR', nil, nil, 'BUF_ERROR'
- c.const 'Z_VERSION_ERROR', nil, nil, 'VERSION_ERROR'
-
- c.const 'Z_NO_COMPRESSION', nil, nil, 'NO_COMPRESSION'
- c.const 'Z_BEST_SPEED', nil, nil, 'BEST_SPEED'
- c.const 'Z_BEST_COMPRESSION', nil, nil, 'BEST_COMPRESSION'
- c.const 'Z_DEFAULT_COMPRESSION', nil, nil, 'DEFAULT_COMPRESSION'
-
- c.const 'Z_FILTERED', nil, nil, 'FILTERED'
- c.const 'Z_HUFFMAN_ONLY', nil, nil, 'HUFFMAN_ONLY'
- c.const 'Z_RLE', nil, nil, 'RLE'
- c.const 'Z_FIXED', nil, nil, 'FIXED'
- c.const 'Z_DEFAULT_STRATEGY', nil, nil, 'DEFAULT_STRATEGY'
-
- c.const 'Z_DEFLATED', nil, nil, 'DEFLATED'
- end
- @@@
-
- @@@
- constants do |c|
- c.include 'zconf.h'
-
- c.const 'MAX_WBITS'
- c.const 'MAX_MEM_LEVEL'
- c.const 'DEF_MEM_LEVEL'
- end
- @@@
-
- OS_MSDOS = 0x00
- OS_AMIGA = 0x01
- OS_VMS = 0x02
- OS_UNIX = 0x03
- OS_ATARI = 0x05
- OS_OS2 = 0x06
- OS_MACOS = 0x07
- OS_TOPS20 = 0x0a
- OS_WIN32 = 0x0b
-
- OS_VMCMS = 0x04
- OS_ZSYSTEM = 0x08
- OS_CPM = 0x09
- OS_QDOS = 0x0c
- OS_RISCOS = 0x0d
- OS_UNKNOWN = 0xff
-
- @@@
- constants do |c|
- c.include 'zlib.h'
-
- c.const 'OS_CODE'
- end
- @@@
-
- unless defined? OS_CODE then
- OS_CODE = OS_UNIX
- end
-
- # from zutil.h
- unless defined? DEF_MEM_LEVEL then
- DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL
- end
-
- class Error < StandardError; end
-
- class StreamEnd < Error; end
- class NeedDict < Error; end
- class StreamError < Error; end
- class DataError < Error; end
- class BufError < Error; end
- class VersionError < Error; end
- class MemError < Error; end
-
- ##
- # Zlib::ZStream is the abstract class for the stream which handles the
- # compressed data. The operations are defined in the subclasses:
- # Zlib::Deflate for compression, and Zlib::Inflate for decompression.
- #
- # An instance of Zlib::ZStream has one stream (struct zstream in the source)
- # and two variable-length buffers which associated to the input (next_in) of
- # the stream and the output (next_out) of the stream. In this document,
- # "input buffer" means the buffer for input, and "output buffer" means the
- # buffer for output.
- #
- # Data input into an instance of Zlib::ZStream are temporally stored into
- # the end of input buffer, and then data in input buffer are processed from
- # the beginning of the buffer until no more output from the stream is
- # produced (i.e. until avail_out > 0 after processing). During processing,
- # output buffer is allocated and expanded automatically to hold all output
- # data.
- #
- # Some particular instance methods consume the data in output buffer and
- # return them as a String.
- #
- # Here is an ascii art for describing above:
- #
- # +================ an instance of Zlib::ZStream ================+
- # || ||
- # || +--------+ +-------+ +--------+ ||
- # || +--| output |<---------|zstream|<---------| input |<--+ ||
- # || | | buffer | next_out+-------+next_in | buffer | | ||
- # || | +--------+ +--------+ | ||
- # || | | ||
- # +===|======================================================|===+
- # | |
- # v |
- # "output data" "input data"
- #
- # If an error occurs during processing input buffer, an exception which is a
- # subclass of Zlib::Error is raised. At that time, both input and output
- # buffer keep their conditions at the time when the error occurs.
- #
- # == Method Catalogue
- #
- # Many of the methods in this class are fairly low-level and unlikely to be
- # of interest to users. In fact, users are unlikely to use this class
- # directly; rather they will be interested in Zlib::Inflate and
- # Zlib::Deflate.
- #
- # The higher level methods are listed below.
- #
- # - #total_in
- # - #total_out
- # - #data_type
- # - #adler
- # - #reset
- # - #finish
- # - #finished?
- # - #close
- # - #closed?
-
- class ZStream < FFI::Struct
-
- @@@
- struct do |s|
- s.include "zlib.h"
-
- s.name "struct z_stream_s"
- s.field :next_in, :pointer
- s.field :avail_in, :uint
- s.field :total_in, :ulong
-
- s.field :next_out, :pointer
- s.field :avail_out, :uint
- s.field :total_out, :ulong
-
- s.field :msg, :string
- s.field :state, :pointer
-
- s.field :zalloc, :pointer
- s.field :zfree, :pointer
- s.field :opaque, :pointer
-
- s.field :data_type, :int
- s.field :adler, :ulong
- s.field :reserved, :ulong
- end
- @@@
-
- #--
- # HACK from MRI's zlib.c
- #++
-
- READY = 0x1
- IN_STREAM = 0x2
- FINISHED = 0x4
- CLOSING = 0x8
- UNUSED = 0x10
-
- attr_accessor :flags
-
- attr_reader :input
-
- attr_reader :output
-
- def self.inherited(subclass)
- subclass.instance_variable_set :@layout, @layout
- subclass.instance_variable_set :@size, @size
- end
-
- def initialize
- super
-
- self[:avail_in] = 0
- self[:avail_out] = 0
- self[:next_in] = nil
- self[:opaque] = nil
- self[:zalloc] = nil
- self[:zfree] = nil
-
- reset_input
- @output = nil
- @flags = 0
- @func = nil
- end
-
- def closing?
- @flags & CLOSING == CLOSING
- end
-
- def detatch_output
- if @output.nil? then
- data = ''
- else
- data = @output
-
- @output = nil
- self[:avail_out] = 0
- self[:next_out] = nil
- end
-
- data
- end
-
- ##
- # Closes the stream. All operations on the closed stream will raise an
- # exception.
-
- def end
- unless ready? then
- warn "attempt to close uninitialized stream; ignored."
- return nil
- end
-
- if in_stream? then
- warn "attempt to close unfinished zstream; reset forced"
- reset
- end
-
- reset_input
-
- err = Zlib.send @func_end, pointer
-
- Zlib.handle_error err, message
-
- @flags = 0
-
- # HACK this may be wrong
- @output = nil
- @next_out.free unless @next_out.nil?
- @next_out = nil
-
- nil
- end
-
- alias :close :end
-
- def expand_output
- if @output.nil? then
- @output = ''
- @next_out = MemoryPointer.new CHUNK if @next_out.nil?
- @next_out.write_string "\000" * CHUNK
- self[:next_out] = @next_out
- else
- have = CHUNK - self[:avail_out]
- @output << @next_out.read_string(have)
-
- self[:next_out] = @next_out # Zlib advances self[:next_out]
- end
-
- self[:avail_out] = CHUNK
- end
-
- ##
- # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish
- # and Zlib::Inflate#finish for details of this behavior.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # Returns true if the stream is finished.
-
- def finished?
- @flags & FINISHED == FINISHED
- end
-
- ##
- # Flushes output buffer and returns all data in that buffer.
-
- def flush_next_out
- detatch_output
- end
-
- def in_stream?
- @flags & IN_STREAM == IN_STREAM
- end
-
- def input_empty?
- @input.nil? or @input.empty?
- end
-
- ##
- # The msg field of the struct
-
- def message
- self[:msg]
- end
-
- def ready
- @flags |= READY
- end
-
- def ready?
- @flags & READY == READY
- end
-
- ##
- # Resets and initializes the stream. All data in both input and output
- # buffer are discarded.
-
- def reset
- err = Zlib.send @func_reset, pointer
-
- Zlib.handle_error err, message
-
- @flags = READY
-
- reset_input
- end
-
- def reset_input
- @input = nil
- end
-
- def run(data, flush)
- if @input.nil? and data.empty? then
- data_in = MemoryPointer.new 1
- data_in.write_string "\000", 1
- self[:next_in] = data_in
- self[:avail_in] = 0
- else
- @input ||= ''
- @input << data
-
- data_in = MemoryPointer.new @input.length
- data_in.write_string @input, @input.length
- self[:next_in] = data_in
- self[:avail_in] = @input.length
- end
-
- expand_output if self[:avail_out] == 0
-
- loop do
- err = Zlib.send @func_run, pointer, flush
-
- available = self[:avail_out]
-
- expand_output # HACK does this work when err is set?
-
- if err == Zlib::STREAM_END then
- @flags &= ~IN_STREAM
- @flags |= FINISHED
- break
- end
-
- unless err == Zlib::OK then
- if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and
- self[:avail_out] > 0 then
- @flags |= IN_STREAM
- break
- end
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string(self[:avail_in]) + @input
- end
-
- Zlib.handle_error err, message
- end
-
- if available > 0 then
- @flags |= IN_STREAM
- break
- end
- end
-
- reset_input
-
- if self[:avail_in] > 0 then
- @input = self[:next_in].read_string self[:avail_in]
- end
- ensure
- data_in.free
- self[:next_in] = nil
- end
-
- ##
- # Returns the number of bytes consumed
-
- def total_in
- self[:total_in]
- end
-
- ##
- # Returns the number bytes processed
-
- def total_out
- self[:total_out]
- end
-
- end
-
- set_ffi_lib 'libz'
-
- # deflateInit2 is a macro pointing to deflateInit2_
- attach_function :deflateInit2_, [
- :pointer, # z_streamp strm
- :int, # int level
- :int, # int method
- :int, # int windowBits
- :int, # int memLevel
- :int, # int strategy
- :string, # ZLIB_VERSION
- :int # (int)sizeof(z_stream)
- ], :int
-
- def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy)
- deflateInit2_ stream, level, method, window_bits, mem_level, strategy,
- ZLIB_VERSION, ZStream.size
- end
-
- attach_function :deflate, [:pointer, :int], :int
- attach_function :deflateEnd, [:pointer], :int
- attach_function :deflateParams, [:pointer, :int, :int],
- :int
- attach_function :deflateReset, [:pointer], :int
- attach_function :deflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- # inflateInit2 is a macro pointing to inflateInit2_
- attach_function :inflateInit2_,
- [:pointer, :int, :string, :int], :int
-
- def self.inflateInit2(stream, window_bits)
- inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size
- end
-
- attach_function :inflate, [:pointer, :int], :int
- attach_function :inflateEnd, [:pointer], :int
- attach_function :inflateReset, [:pointer], :int
- attach_function :inflateSetDictionary,
- [:pointer, :string, :uint], :int
-
- attach_function :adler32_c, :adler32, [:ulong, :string, :uint],
- :ulong
- attach_function :crc32_c, :crc32, [:ulong, :string, :uint],
- :ulong
- attach_function :get_crc_table_c, :get_crc_table, [], :pointer
-
- attach_function :zError, [:int], :string
-
- # Chunk size for inflation and deflation
-
- CHUNK = 1024
-
- #--
- # HACK from zlib.c
- #++
-
- GZ_EXTRAFLAG_FAST = 0x4
- GZ_EXTRAFLAG_SLOW = 0x2
-
- ##
- # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for
- # more information.
-
- class Deflate < ZStream
-
- ##
- # Compresses the given +string+. Valid values of level are
- # Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
- # Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and
- # an integer from 0 to 9.
- #
- # This method is almost equivalent to the following code:
- #
- # def deflate(string, level)
- # z = Zlib::Deflate.new(level)
- # dst = z.deflate(string, Zlib::FINISH)
- # z.close
- # dst
- # end
-
- def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION)
- deflator = new level
-
- zipped = deflator.deflate data, Zlib::FINISH
-
- zipped
- ensure
- deflator.end
- end
-
- ##
- # Creates a new deflate stream for compression. See zlib.h for details of
- # each argument. If an argument is nil, the default value of that argument
- # is used.
-
- def initialize(level = Zlib::DEFAULT_COMPRESSION,
- window_bits = Zlib::MAX_WBITS,
- mem_level = Zlib::DEF_MEM_LEVEL,
- strategy = Zlib::DEFAULT_STRATEGY)
- level ||= Zlib::DEFAULT_COMPRESSION
- window_bits ||= Zlib::MAX_WBITS
- mem_level ||= Zlib::DEF_MEM_LEVEL
- strategy ||= Zlib::DEFAULT_STRATEGY
-
- super()
-
- @func_end = :deflateEnd
- @func_reset = :deflateReset
- @func_run = :deflate
-
- err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED,
- window_bits, mem_level, strategy)
-
- Zlib.handle_error err, message
-
- ready
- end
-
- ##
- # Same as IO.
-
- def <<(data)
- do_deflate data, Zlib::NO_FLUSH
-
- self
- end
-
- ##
- # Inputs +string+ into the deflate stream and returns the output from the
- # stream. On calling this method, both the input and the output buffers
- # of the stream are flushed. If +string+ is nil, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # The value of +flush+ should be either Zlib::NO_FLUSH,
- # Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or
- # Zlib::FINISH. See zlib.h for details.
-
- def deflate(data, flush = Zlib::NO_FLUSH)
- do_deflate data, flush
-
- detatch_output
- end
-
- ##
- # Performs the deflate operation and leaves the compressed data in the
- # output buffer
-
- def do_deflate(data, flush)
- if data.nil? then
- run '', Zlib::FINISH
- else
- data = StringValue data
-
- if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
- run data, flush
- end
- end
- end
-
- ##
- # Finishes compressing the deflate input stream and returns the output
- # buffer.
-
- def finish
- run '', Zlib::FINISH
-
- detatch_output
- end
-
- ##
- # This method is equivalent to deflate('', flush). If flush is
- # omitted, Zlib::SYNC_FLUSH is used as flush. This method is
- # just provided to improve the readability of your Ruby program.
-
- def flush(flush = Zlib::SYNC_FLUSH)
- run '', flush unless flush == Zlib::NO_FLUSH
-
- detatch_output
- end
-
- ##
- # Changes the parameters of the deflate stream. See zlib.h for details.
- # The output from the stream by changing the params is preserved in output
- # buffer.
-
- def params(level, strategy)
- err = Zlib.deflateParams pointer, level, strategy
-
- raise Zlib::BufError, 'buffer expansion not implemented' if
- err == Zlib::BUF_ERROR
-
- Zlib.handle_error err, message
-
- nil
- end
-
- ##
- # Sets the preset dictionary and returns +dictionary+. This method is
- # available just only after Zlib::Deflate.new or Zlib::ZStream#reset
- # method was called. See zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.deflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Zlib::GzipFile is an abstract class for handling a gzip formatted
- # compressed file. The operations are defined in the subclasses,
- # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
- #
- # GzipReader should be used by associating an IO, or IO-like, object.
-
- class GzipFile
-
- SYNC = Zlib::ZStream::UNUSED
- HEADER_FINISHED = Zlib::ZStream::UNUSED << 1
- FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2
-
- FLAG_MULTIPART = 0x2
- FLAG_EXTRA = 0x4
- FLAG_ORIG_NAME = 0x8
- FLAG_COMMENT = 0x10
- FLAG_ENCRYPT = 0x20
- FLAG_UNKNOWN_MASK = 0xc0
-
- EXTRAFLAG_FAST = 0x4
- EXTRAFLAG_SLOW = 0x2
-
- MAGIC1 = 0x1f
- MAGIC2 = 0x8b
- METHOD_DEFLATE = 8
-
- ##
- # Base class of errors that occur when processing GZIP files.
-
- class Error < Zlib::Error; end
-
- ##
- # Raised when gzip file footer is not found.
-
- class NoFooter < Error; end
-
- ##
- # Raised when the CRC checksum recorded in gzip file footer is not
- # equivalent to the CRC checksum of the actual uncompressed data.
-
- class CRCError < Error; end
-
- ##
- # Raised when the data length recorded in the gzip file footer is not
- # equivalent to the length of the actual uncompressed data.
-
- class LengthError < Error; end
-
- ##
- # Accessor for the underlying ZStream
-
- attr_reader :zstream # :nodoc:
-
- ##
- # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
-
- def self.wrap(*args)
- obj = new(*args)
-
- if block_given? then
- begin
- yield obj
- ensure
- obj.close if obj.zstream.ready?
- end
- end
- end
-
- def initialize
- @comment = nil
- @crc = 0
- @level = nil
- @mtime = Time.at 0
- @orig_name = nil
- @os_code = Zlib::OS_CODE
- end
-
- ##
- # Closes the GzipFile object. This method calls close method of the
- # associated IO object. Returns the associated IO object.
-
- def close
- io = finish
-
- io.close if io.respond_to? :close
-
- io
- end
-
- ##
- # Same as IO
-
- def closed?
- @io.nil?
- end
-
- ##
- # Returns comments recorded in the gzip file header, or nil if the
- # comment is not present.
-
- def comment
- raise Error, 'closed gzip stream' if @io.nil?
-
- @comment.dup
- end
-
- def end
- return if @zstream.closing?
-
- @zstream.flags |= Zlib::ZStream::CLOSING
-
- begin
- end_run
- ensure
- @zstream.end
- end
- end
-
- ##
- # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method
- # never calls the close method of the associated IO object. Returns the
- # associated IO object.
-
- def finish
- self.end
-
- io = @io
- @io = nil
- @orig_name = nil
- @comment = nil
-
- io
- end
-
- def finished?
- @zstream.finished? and @zstream.output.empty? # HACK I think
- end
-
- def footer_finished?
- @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED ==
- Zlib::GzipFile::FOOTER_FINISHED
- end
-
- def header_finished?
- @zstream.flags & Zlib::GzipFile::HEADER_FINISHED ==
- Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Returns last modification time recorded in the gzip file header.
-
- def mtime
- Time.at @mtime
- end
-
- ##
- # Returns original filename recorded in the gzip file header, or +nil+ if
- # original filename is not present.
-
- def orig_name
- raise Error, 'closed gzip stream' if @io.nil?
-
- @orig_name.dup
- end
-
- end
-
- ##
- # Zlib::GzipReader is the class for reading a gzipped file. GzipReader
- # should be used an IO, or -IO-lie, object.
- #
- # Zlib::GzipReader.open('hoge.gz') {|gz|
- # print gz.read
- # }
- #
- # File.open('hoge.gz') do |f|
- # gz = Zlib::GzipReader.new(f)
- # print gz.read
- # gz.close
- # end
- #
- # == Method Catalogue
- #
- # The following methods in Zlib::GzipReader are just like their counterparts
- # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
- # error was found in the gzip file.
- #
- # - #each
- # - #each_line
- # - #each_byte
- # - #gets
- # - #getc
- # - #lineno
- # - #lineno=
- # - #read
- # - #readchar
- # - #readline
- # - #readlines
- # - #ungetc
- #
- # Be careful of the footer of the gzip file. A gzip file has the checksum of
- # pre-compressed data in its footer. GzipReader checks all uncompressed data
- # against that checksum at the following cases, and if it fails, raises
- # Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or
- # Zlib::GzipFile::LengthError exception.
- #
- # - When an reading request is received beyond the end of file (the end of
- # compressed data). That is, when Zlib::GzipReader#read,
- # Zlib::GzipReader#gets, or some other methods for reading returns nil.
- # - When Zlib::GzipFile#close method is called after the object reaches the
- # end of file.
- # - When Zlib::GzipReader#unused method is called after the object reaches
- # the end of file.
- #
- # The rest of the methods are adequately described in their own
- # documentation.
-
- class GzipReader < GzipFile # HACK use a buffer class
-
- ##
- # Creates a GzipReader object associated with +io+. The GzipReader object
- # reads gzipped data from +io+, and parses/decompresses them. At least,
- # +io+ must have a +read+ method that behaves same as the +read+ method in
- # IO class.
- #
- # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
- # exception.
-
- def initialize(io)
- @io = io
-
- @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS
-
- @buffer = ''
-
- super()
-
- read_header
- end
-
- def check_footer
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
-
- footer = @zstream.input.slice! 0, 8
- rest = @io.read 8 - footer.length
- footer << rest if rest
-
- raise NoFooter, 'footer is not found' unless footer.length == 8
-
- crc, length = footer.unpack 'VV'
-
- @zstream[:total_in] += 8 # to rewind correctly
-
- raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
-
- raise LengthError, 'invalid compressed data -- length error' unless
- length == @zstream.total_out
- end
-
- def end_run
- check_footer if @zstream.finished? and not footer_finished?
- end
-
- def eof?
- @zstream.finished? and @zstream.input_empty?
- end
-
- def pos
- @zstream[:total_out] - @buffer.length
- end
-
- ##
- # See Zlib::GzipReader documentation for a description.
-
- def read(length = nil)
- data = @buffer
-
- while chunk = @io.read(CHUNK) do
- inflated = @zstream.inflate(chunk)
- @crc = Zlib.crc32 inflated, @crc
- data << inflated
-
- break if length and data.length > length
- end
-
- if length then
- @buffer = data.slice! length..-1
- else
- @buffer = ''
- end
-
- check_footer if @zstream.finished? and not footer_finished?
-
- data
- rescue Zlib::Error => e
- raise GzipFile::Error, e.message
- end
-
- def read_header
- header = @io.read 10
-
- raise Error, 'not in gzip format' unless header.length == 10
-
- magic1, magic2, method, flags, @mtime, extra_flags, @os_code =
- header.unpack 'CCCCVCC'
-
- unless magic1 == Zlib::GzipFile::MAGIC1 and
- magic2 == Zlib::GzipFile::MAGIC2 then
- raise Error, 'not in gzip format'
- end
-
- unless method == Zlib::GzipFile::METHOD_DEFLATE then
- raise Error, "unsupported compression method #{method}"
- end
-
- if flags & Zlib::GzipFile::FLAG_MULTIPART ==
- Zlib::GzipFile::FLAG_MULTIPART then
- raise Error, 'multi-part gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_ENCRYPT ==
- Zlib::GzipFile::FLAG_ENCRYPT then
- raise Error, 'encrypted gzip file is not supported'
- end
-
- if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK ==
- Zlib::GzipFile::FLAG_UNKNOWN_MASK then
- raise Error, "unknown flags 0x#{flags.to_s 16}"
- end
-
- if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST ==
- Zlib::GzipFile::EXTRAFLAG_FAST then
- @level = Zlib::BEST_SPEED
- elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW ==
- Zlib::GzipFile::EXTRAFLAG_SLOW then
- @level = Zlib::BEST_COMPRESSION
- else
- @level = Zlib::DEFAULT_COMPRESSION
- end
-
- if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then
- length = @io.read 2
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- length.nil? or length.length != 2
-
- length, = length.unpack 'v'
-
- extra = @io.read length + 2
-
- raise Zlib::GzipFile::Error, 'unexpected end of file' if
- extra.nil? or extra.length != length + 2
- end
-
- if flags & Zlib::GzipFile::FLAG_ORIG_NAME ==
- Zlib::GzipFile::FLAG_ORIG_NAME then
- @orig_name = ''
-
- c = @io.getc
-
- until c == 0 do
- @orig_name << c.chr
- c = @io.getc
- end
- end
-
- if flags & Zlib::GzipFile::FLAG_COMMENT ==
- Zlib::GzipFile::FLAG_COMMENT then
- @comment = ''
-
- c = @io.getc
-
- until c == 0 do
- @comment << c.chr
- c = @io.getc
- end
- end
- end
-
- end
-
- ##
- # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
- # be used with an instance of IO, or IO-like, object.
- #
- # For example:
- #
- # Zlib::GzipWriter.open('hoge.gz') do |gz|
- # gz.write 'jugemu jugemu gokou no surikire...'
- # end
- #
- # File.open('hoge.gz', 'w') do |f|
- # gz = Zlib::GzipWriter.new(f)
- # gz.write 'jugemu jugemu gokou no surikire...'
- # gz.close
- # end
- #
- # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
- # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
- # will be not able to write the gzip footer and will generate a broken gzip
- # file.
-
- class GzipWriter < GzipFile # HACK use a buffer class
-
- ##
- # Set the comment
-
- attr_writer :comment
-
- ##
- # Set the original name
-
- attr_writer :orig_name
-
- ##
- # Creates a GzipWriter object associated with +io+. +level+ and +strategy+
- # should be the same as the arguments of Zlib::Deflate.new. The
- # GzipWriter object writes gzipped data to +io+. At least, +io+ must
- # respond to the +write+ method that behaves same as write method in IO
- # class.
-
- def initialize(io, level = Zlib::DEFAULT_COMPRESSION,
- strategy = Zlib::DEFAULT_STRATEGY)
- @io = io
-
- @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS,
- Zlib::DEF_MEM_LEVEL, strategy
-
- @buffer = ''
-
- super()
- end
-
- def end_run
- make_header unless header_finished?
-
- @zstream.run '', Zlib::FINISH
-
- write_raw
-
- make_footer
-
- nil
- end
-
- ##
- # Flushes all the internal buffers of the GzipWriter object. The meaning
- # of +flush+ is same as in Zlib::Deflate#deflate.
- # Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use
- # giving flush Zlib::NO_FLUSH.
-
- def flush
- true
- end
-
- ##
- # Writes out a gzip header
-
- def make_header
- flags = 0
- extra_flags = 0
-
- flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
- flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
- @level == Zlib::BEST_SPEED
-
- extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
- @level == Zlib::BEST_COMPRESSION
-
- header = [
- Zlib::GzipFile::MAGIC1, # byte 0
- Zlib::GzipFile::MAGIC2, # byte 1
- Zlib::GzipFile::METHOD_DEFLATE, # byte 2
- flags, # byte 3
- @mtime.to_i, # bytes 4-7
- extra_flags, # byte 8
- @os_code # byte 9
- ].pack 'CCCCVCC'
-
- @io.write header
-
- @io.write "#{@orig_name}\0" if @orig_name
- @io.write "#{@comment}\0" if @comment
-
- @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
- end
-
- ##
- # Writes out a gzip footer
-
- def make_footer
- footer = [
- @crc, # bytes 0-3
- @zstream.total_in, # bytes 4-7
- ].pack 'VV'
-
- @io.write footer
-
- @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
- end
-
- ##
- # Sets the modification time of this file
-
- def mtime=(time)
- if header_finished? then
- raise Zlib::GzipFile::Error, 'header is already written'
- end
-
- @mtime = Integer time
- end
-
- def sync?
- @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC
- end
-
- ##
- # Same as IO.
-
- def write(data)
- make_header unless header_finished?
-
- data = String data
-
- if data.length > 0 or sync? then
- @crc = Zlib.crc32_c @crc, data, data.length
-
- flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
-
- @zstream.run data, flush
- end
-
- write_raw
- end
-
- ##
- # Same as IO.
-
- alias << write
-
- def write_raw
- data = @zstream.detatch_output
-
- unless data.empty? then
- @io.write data
- @io.flush if sync? and io.respond_to :flush
- end
- end
-
- end
-
- ##
- # Zlib:Inflate is the class for decompressing compressed data. Unlike
- # Zlib::Deflate, an instance of this class is not able to duplicate (clone,
- # dup) itself.
-
- class Inflate < ZStream
-
- ##
- # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
- # dictionary is needed for decompression.
- #
- # This method is almost equivalent to the following code:
- #
- # def inflate(string)
- # zstream = Zlib::Inflate.new
- # buf = zstream.inflate(string)
- # zstream.finish
- # zstream.close
- # buf
- # end
-
- def self.inflate(data)
- inflator = new
-
- unzipped = inflator.inflate data
-
- unzipped
- ensure
- inflator.end
- end
-
- ##
- # Creates a new inflate stream for decompression. See zlib.h for details
- # of the argument. If +window_bits+ is +nil+, the default value is used.
-
- def initialize(window_bits = Zlib::MAX_WBITS)
- super()
-
- @func_end = :inflateEnd
- @func_reset = :inflateReset
- @func_run = :inflate
-
- err = Zlib.inflateInit2 pointer, window_bits
-
- Zlib.handle_error err, message # HACK
-
- ready
- end
-
- ##
- # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
- # but returns the Zlib::Inflate object itself. The output from the stream
- # is preserved in output buffer.
-
- def <<(string)
- string = StringValue string unless string.nil?
-
- if finished? then
- unless string.nil? then
- @input ||= ''
- @input << string
- end
- else
- run string, Zlib::SYNC_FLUSH
- end
- end
-
- ##
- # Inputs +string+ into the inflate stream and returns the output from the
- # stream. Calling this method, both the input and the output buffer of
- # the stream are flushed. If string is +nil+, this method finishes the
- # stream, just like Zlib::ZStream#finish.
- #
- # Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- # decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- # call this method again with an empty string. (???)
-
- def inflate(data)
- data = Type.coerce_to data, String, :to_str unless data.nil?
-
- if finished? then
- if data.nil? then
- unzipped = detatch_output
- else
- @input ||= ''
- @input << data
-
- unzipped = ''
- end
- else
- if data.nil? then
- run '', Zlib::FINISH
- elsif not data.empty? then
- run data, Zlib::SYNC_FLUSH
- end
-
- unzipped = detatch_output
-
- if finished? and not @input.nil? then
- expand_output
- end
- end
-
- unzipped
- end
-
- ##
- # Sets the preset dictionary and returns +string+. This method is
- # available just only after a Zlib::NeedDict exception was raised. See
- # zlib.h for details.
-
- def set_dictionary(dictionary)
- dict = StringValue dictionary
-
- err = Zlib.inflateSetDictionary pointer, dict, dict.length
-
- Zlib.handle_error err, message
-
- dictionary
- end
-
- end
-
- ##
- # Calculates Alder-32 checksum for +string+, and returns updated value of
- # +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
- # +adler+ is omitted, it assumes that the initial value is given to +adler+.
-
- def self.adler32(string = "", sum = 1)
- do_checksum(string, sum, :adler32_c)
- end
-
- ##
- # Returns the table for calculating CRC checksum as an array.
-
- def self.crc_table
- get_crc_table_c.read_array_of_long(256).map do |x|
- x >= 0 ? x : 2 ** 32 + x # HACK convert back to unsigned
- end
- end
-
- ##
- # Calculates CRC checksum for +string+, and returns updated value of +crc+.
- # If +string+ is omitted, it returns the CRC initial value. If +crc+ is
- # omitted, it assumes that the initial value is given to +crc+.
-
- def self.crc32(string = "", sum = 0)
- do_checksum(string, sum, :crc32_c)
- end
-
- ##
- # Generates a checksum using function +type+
-
- def self.do_checksum(string, vsum, type)
- if vsum
- raise RangeError if vsum >= (2 ** 128)
- raise "Explain why you did this: email ephoenix@engineyard.com" if vsum < 0
- sum = vsum
- elsif string.nil?
- sum = 0
- else
- sum = send(type, 0, nil, 0)
- end
-
- send(type, sum, string, string ? string.size : 0)
- end
-
- ##
- # Raises an exception of the appropriate class
-
- def self.handle_error(error, message = nil)
- return if error == Zlib::OK
-
- message = zError error if message.nil?
-
- klass = case error
- when Zlib::STREAM_END then Zlib::StreamEnd
- when Zlib::NEED_DICT then Zlib::NeedDict
- when Zlib::STREAM_ERROR then Zlib::StreamError
- when Zlib::DATA_ERROR then Zlib::DataError
- when Zlib::BUF_ERROR then Zlib::BufError
- when Zlib::MEM_ERROR then Zlib::MemError
- when Errno then Errno.handle message
- else
- message = "unknown zlib error #{error}: #{message}"
- Zlib::Error
- end
-
- raise klass, message
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/pointer.rb b/src/main/resources/stdlib/ffi/pointer.rb
deleted file mode 100644
index 2fc510d..0000000
--- a/src/main/resources/stdlib/ffi/pointer.rb
+++ /dev/null
@@ -1 +0,0 @@
-# All FFI::Pointer functionality is implemented in java
diff --git a/src/main/resources/stdlib/ffi/rbx.rb b/src/main/resources/stdlib/ffi/rbx.rb
deleted file mode 100644
index 6e7633b..0000000
--- a/src/main/resources/stdlib/ffi/rbx.rb
+++ /dev/null
@@ -1 +0,0 @@
-# This file intentionally left blank
diff --git a/src/main/resources/stdlib/ffi/struct.rb b/src/main/resources/stdlib/ffi/struct.rb
deleted file mode 100644
index 002dbe0..0000000
--- a/src/main/resources/stdlib/ffi/struct.rb
+++ /dev/null
@@ -1,189 +0,0 @@
-#
-# Copyright (C) 2008, 2009 Wayne Meissner
-# Copyright (C) 2008, 2009 Andrea Fazzi
-# Copyright (C) 2008, 2009 Luc Heinrich
-# Copyright (c) 2007, 2008 Evan Phoenix
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright notice
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-# * Neither the name of the Evan Phoenix nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-require 'ffi/platform'
-require 'ffi/struct_layout_builder'
-
-module FFI
-
- class Struct
- alias_method :align, :alignment
-
- def self.size=(size)
- raise ArgumentError, "Size already set" if defined?(@size) || defined?(@layout)
- @size = size
- end
-
- def self.in
- ptr(:in)
- end
-
- def self.out
- ptr(:out)
- end
-
- def self.ptr(flags = :inout)
- @ref_data_type ||= Type::Mapped.new(StructByReference.new(self))
- end
-
- def self.val
- @val_data_type ||= StructByValue.new(self)
- end
-
- def self.by_value
- self.val
- end
-
- def self.by_ref(flags = :inout)
- self.ptr(flags)
- end
-
- class ManagedStructConverter < StructByReference
-
- def initialize(struct_class)
- super(struct_class)
-
- raise NoMethodError, "release() not implemented for class #{struct_class}" unless struct_class.respond_to? :release
- @method = struct_class.method(:release)
- end
-
- def from_native(ptr, ctx)
- struct_class.new(AutoPointer.new(ptr, @method))
- end
- end
-
- def self.auto_ptr
- @managed_type ||= Type::Mapped.new(ManagedStructConverter.new(self))
- end
-
-
- class << self
- public
-
- def layout(*spec)
- return @layout if spec.size == 0
-
- builder = StructLayoutBuilder.new
- builder.union = self < Union
- builder.packed = @packed if defined?(@packed)
- builder.alignment = @min_alignment if defined?(@min_alignment)
-
- if spec[0].kind_of?(Hash)
- hash_layout(builder, spec)
- else
- array_layout(builder, spec)
- end
-
- builder.size = @size if defined?(@size) && @size > builder.size
- layout = builder.build
- @size = layout.size
- self.layout = layout unless self == Struct
- layout
- end
-
-
- protected
-
- def callback(params, ret)
- mod = enclosing_module
- FFI::CallbackInfo.new(find_type(ret, mod), params.map { |e| find_type(e, mod) })
- end
-
- def packed(packed = 1)
- @packed = packed
- end
- alias :pack :packed
-
- def aligned(alignment = 1)
- @min_alignment = alignment
- end
- alias :align :aligned
-
- def enclosing_module
- begin
- mod = self.name.split("::")[0..-2].inject(Object) { |obj, c| obj.const_get(c) }
- (mod < FFI::Library || mod < FFI::Struct || mod.respond_to?(:find_type)) ? mod : nil
- rescue Exception => ex
- nil
- end
- end
-
-
- def find_field_type(type, mod = enclosing_module)
- if type.kind_of?(Class) && type < Struct
- FFI::Type::Struct.new(type)
-
- elsif type.kind_of?(Class) && type < FFI::StructLayout::Field
- type
-
- elsif type.kind_of?(::Array)
- FFI::Type::Array.new(find_field_type(type[0]), type[1])
-
- else
- find_type(type, mod)
- end
- end
-
- def find_type(type, mod = enclosing_module)
- if mod
- mod.find_type(type)
- end || FFI.find_type(type)
- end
-
- private
-
- def hash_layout(builder, spec)
- raise "Ruby version not supported" if RUBY_VERSION =~ /1.8.*/ && !(RUBY_PLATFORM =~ /java/)
- spec[0].each do |name, type|
- builder.add name, find_field_type(type), nil
- end
- end
-
- def array_layout(builder, spec)
- i = 0
- while i < spec.size
- name, type = spec[i, 2]
- i += 2
-
- # If the next param is a Integer, it specifies the offset
- if spec[i].kind_of?(Integer)
- offset = spec[i]
- i += 1
- else
- offset = nil
- end
-
- builder.add name, find_field_type(type), offset
- end
- end
- end
- end
- end
diff --git a/src/main/resources/stdlib/ffi/struct_layout_builder.rb b/src/main/resources/stdlib/ffi/struct_layout_builder.rb
deleted file mode 100644
index 0703bfc..0000000
--- a/src/main/resources/stdlib/ffi/struct_layout_builder.rb
+++ /dev/null
@@ -1,167 +0,0 @@
-#
-# Copyright (C) 2008-2010 Wayne Meissner
-#
-# Version: EPL 1.0/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Common Public
-# License Version 1.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.eclipse.org/legal/cpl-v10.html
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the EPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the EPL, the GPL or the LGPL.
-#
-
-module FFI
- class StructLayoutBuilder
- attr_reader :size, :alignment
-
- def initialize
- @size = 0
- @alignment = 1
- @min_alignment = 1
- @packed = false
- @union = false
- @fields = Array.new
- end
-
- def size=(size)
- @size = size if size > @size
- end
-
- def alignment=(align)
- @alignment = align if align > @alignment
- @min_alignment = align
- end
-
- def union=(is_union)
- @union = is_union
- end
-
- def union?
- @union
- end
-
- def packed=(packed)
- if packed.is_a?(Fixnum)
- @alignment = packed
- @packed = packed
- else
- @packed = packed ? 1 : 0
- end
- end
-
-
- SCALAR_TYPES = [
- Type::INT8,
- Type::UINT8,
- Type::INT16,
- Type::UINT16,
- Type::INT32,
- Type::UINT32,
- Type::LONG,
- Type::ULONG,
- Type::INT64,
- Type::UINT64,
- Type::FLOAT32,
- Type::FLOAT64,
- Type::BOOL,
- ]
-
- def add(name, type, offset = nil)
-
- if offset.nil? || offset == -1
- offset = @union ? 0 : align(@size, @packed ? [ @packed, type.alignment ].min : [ @min_alignment, type.alignment ].max)
- end
-
- #
- # If a FFI::Type type was passed in as the field arg, try and convert to a StructLayout::Field instance
- #
- field = type.is_a?(StructLayout::Field) ? type : field_for_type(name, offset, type)
- @fields << field
- @alignment = [ @alignment, field.alignment ].max unless @packed
- @size = [ @size, field.size + (@union ? 0 : field.offset) ].max
-
- return self
- end
-
- def add_field(name, type, offset = nil)
- add(name, type, offset)
- end
-
- def add_struct(name, type, offset = nil)
- add(name, Type::Struct.new(type), offset)
- end
-
- def add_array(name, type, count, offset = nil)
- add(name, Type::Array.new(type, count), offset)
- end
-
- def build
- # Add tail padding if the struct is not packed
- size = @packed ? @size : align(@size, @alignment)
-
- StructLayout.new(@fields, size, @alignment)
- end
-
- private
-
- def align(offset, align)
- align + ((offset - 1) & ~(align - 1));
- end
-
- def field_for_type(name, offset, type)
- field_class = case
- when type.is_a?(Type::Function)
- StructLayout::Function
-
- when type.is_a?(Type::Struct)
- StructLayout::InnerStruct
-
- when type.is_a?(Type::Array)
- StructLayout::Array
-
- when type.is_a?(FFI::Enum)
- StructLayout::Enum
-
- when SCALAR_TYPES.include?(type)
- StructLayout::Number
-
- when type == Type::POINTER
- StructLayout::Pointer
-
- when type == Type::STRING
- StructLayout::String
-
- when type.is_a?(Class) && type < StructLayout::Field
- type
-
- when type.is_a?(DataConverter)
- return StructLayout::Mapped.new(name, offset, Type::Mapped.new(type), field_for_type(name, offset, type.native_type))
-
- when type.is_a?(Type::Mapped)
- return StructLayout::Mapped.new(name, offset, type, field_for_type(name, offset, type.native_type))
-
- else
- raise TypeError, "invalid struct field type #{type.inspect}"
- end
-
- field_class.new(name, offset, type)
- end
- end
-
-end
diff --git a/src/main/resources/stdlib/ffi/tools/Rakefile b/src/main/resources/stdlib/ffi/tools/Rakefile
deleted file mode 100644
index c376810..0000000
--- a/src/main/resources/stdlib/ffi/tools/Rakefile
+++ /dev/null
@@ -1,58 +0,0 @@
-$VERBOSE = true
-$verbose = Rake.application.options.trace
-
-require 'ffi'
-require 'ffi/tools/struct_generator'
-require 'ffi/tools/const_generator'
-require 'ffi/tools/types_generator'
-require 'ffi/tools/generator'
-require 'fileutils'
-require 'rbconfig'
-
-arches = [ ]
-arch_options = {}
-conf_files = []
-
-if FFI::Platform.mac?
- osx_arches = [ "ppc", "i386" ]
- osx_arches << "x86_64" if RbConfig::CONFIG['host_cpu'] == 'x86_64'
- osx_arches.each do |arch|
- arches << arch
- platform_dir = File.join(FFI::Platform::FFI_DIR, "platform", "#{arch}-darwin")
- arch_options[arch] = { :platform_dir => platform_dir, :cppflags => "-arch #{arch}"}
- end
-else
- arches = [ FFI::Platform::ARCH ]
- arch_options[FFI::Platform::ARCH] = {
- :platform_dir => FFI::Platform::CONF_DIR,
- :cppflags => FFI::Platform.solaris? ? "-m#{FFI::Platform::ADDRESS_SIZE}" : ""
- }
-end
-arches.each { |arch|
- options = arch_options[arch]
- platform_conf = File.join(options[:platform_dir], "platform.conf")
- types_conf = File.join(options[:platform_dir], "types.conf")
- conf_files << platform_conf
- file platform_conf do |task|
- FileUtils.mkdir_p(File.dirname(task.name), { :mode => 0755 })
- gen_platform_conf task, { :cppflags => options[:cppflags]}
- end
- file types_conf do |task|
- FileUtils.mkdir_p(File.dirname(task.name), { :mode => 0755 })
- File.open(task.name, "w") do |f|
- f.puts FFI::TypesGenerator.generate(:cppflags => options[:cppflags])
- end
- end
- task "gen_ffi_files_#{arch}" do |task|
- Dir["#{File.join(FFI::Platform::FFI_DIR, 'platform')}/*.rb.ffi"].each do |file|
- rb_name = File.join(options[:platform_dir], File.basename(file, '.ffi'))
- FFI::Generator.new file, rb_name, { :cppflags => options[:cppflags] }
- end unless FFI::Platform.windows?
- end
- task "#{arch}" => [ platform_conf, types_conf, "gen_ffi_files_#{arch}" ]
-}
-
-task :default => :build
-task :build => arches
-
-load 'ffi/tools/platform.rake'
diff --git a/src/main/resources/stdlib/ffi/tools/const_generator.rb b/src/main/resources/stdlib/ffi/tools/const_generator.rb
deleted file mode 100644
index e3eb9ba..0000000
--- a/src/main/resources/stdlib/ffi/tools/const_generator.rb
+++ /dev/null
@@ -1,178 +0,0 @@
-require 'tmpdir'
-require 'tempfile'
-require 'open3'
-
-module FFI
-
- ##
- # ConstGenerator turns C constants into ruby values.
-
- class ConstGenerator
- @options = {}
- attr_reader :constants
-
- ##
- # Creates a new constant generator that uses +prefix+ as a name, and an
- # options hash.
- #
- # The only option is :required, which if set to true raises an error if a
- # constant you have requested was not found.
- #
- # When passed a block, #calculate is automatically called at the end of
- # the block, otherwise you must call it yourself.
-
- def initialize(prefix = nil, options = {})
- @includes = []
- @constants = {}
- @prefix = prefix
-
- @required = options[:required]
- @options = options
-
- if block_given? then
- yield self
- calculate self.class.options.merge(options)
- end
- end
- def self.options=(options)
- @options = options
- end
- def self.options
- @options
- end
- def [](name)
- @constants[name].value
- end
-
- ##
- # Request the value for C constant +name+. +format+ is a printf format
- # string to print the value out, and +cast+ is a C cast for the value.
- # +ruby_name+ allows you to give the constant an alternate ruby name for
- # #to_ruby. +converter+ or +converter_proc+ allow you to convert the
- # value from a string to the appropriate type for #to_ruby.
-
- def const(name, format = nil, cast = '', ruby_name = nil, converter = nil,
- &converter_proc)
- format ||= '%d'
- cast ||= ''
-
- if converter_proc and converter then
- raise ArgumentError, "Supply only converter or converter block"
- end
-
- converter = converter_proc if converter.nil?
-
- const = Constant.new name, format, cast, ruby_name, converter
- @constants[name.to_s] = const
- return const
- end
-
- def calculate(options = {})
- binary = File.join Dir.tmpdir, "rb_const_gen_bin_#{Process.pid}"
-
- Tempfile.open("#{@prefix}.const_generator") do |f|
- f.puts "#include "
-
- @includes.each do |inc|
- f.puts "#include <#{inc}>"
- end
-
- f.puts "#include \n\n"
- f.puts "int main(int argc, char **argv)\n{"
-
- @constants.each_value do |const|
- f.puts <<-EOF
- #ifdef #{const.name}
- printf("#{const.name} #{const.format}\\n", #{const.cast}#{const.name});
- #endif
- EOF
- end
-
- f.puts "\n\treturn 0;\n}"
- f.flush
-
- output = `gcc #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -x c -Wall -Werror #{f.path} -o #{binary} 2>&1`
-
- unless $?.success? then
- output = output.split("\n").map { |l| "\t#{l}" }.join "\n"
- raise "Compilation error generating constants #{@prefix}:\n#{output}"
- end
- end
-
- output = `#{binary}`
- File.unlink(binary + (FFI::Platform.windows? ? ".exe" : ""))
- output.each_line do |line|
- line =~ /^(\S+)\s(.*)$/
- const = @constants[$1]
- const.value = $2
- end
-
- missing_constants = @constants.select do |name, constant|
- constant.value.nil?
- end.map { |name,| name }
-
- if @required and not missing_constants.empty? then
- raise "Missing required constants for #{@prefix}: #{missing_constants.join ', '}"
- end
- end
-
- def dump_constants(io)
- @constants.each do |name, constant|
- name = [@prefix, name].join '.'
- io.puts "#{name} = #{constant.converted_value}"
- end
- end
-
- ##
- # Outputs values for discovered constants. If the constant's value was
- # not discovered it is not omitted.
-
- def to_ruby
- @constants.sort_by { |name,| name }.map do |name, constant|
- if constant.value.nil? then
- "# #{name} not available"
- else
- constant.to_ruby
- end
- end.join "\n"
- end
-
- def include(i)
- @includes << i
- end
-
- end
-
- class ConstGenerator::Constant
-
- attr_reader :name, :format, :cast
- attr_accessor :value
-
- def initialize(name, format, cast, ruby_name = nil, converter=nil)
- @name = name
- @format = format
- @cast = cast
- @ruby_name = ruby_name
- @converter = converter
- @value = nil
- end
-
- def converted_value
- if @converter
- @converter.call(@value)
- else
- @value
- end
- end
-
- def ruby_name
- @ruby_name || @name
- end
-
- def to_ruby
- "#{ruby_name} = #{converted_value}"
- end
-
- end
-
-end
diff --git a/src/main/resources/stdlib/ffi/tools/generator.rb b/src/main/resources/stdlib/ffi/tools/generator.rb
deleted file mode 100644
index 45413f6..0000000
--- a/src/main/resources/stdlib/ffi/tools/generator.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-module FFI
- class Generator
-
- def initialize(ffi_name, rb_name, options = {})
- @ffi_name = ffi_name
- @rb_name = rb_name
- @options = options
- @name = File.basename rb_name, '.rb'
-
- file = File.read @ffi_name
-
- new_file = file.gsub(/^( *)@@@(.*?)@@@/m) do
- @constants = []
- @structs = []
-
- indent = $1
- original_lines = $2.count "\n"
-
- instance_eval $2
-
- new_lines = []
- @constants.each { |c| new_lines << c.to_ruby }
- @structs.each { |s| new_lines << s.generate_layout }
-
- new_lines = new_lines.join("\n").split "\n" # expand multiline blocks
- new_lines = new_lines.map { |line| indent + line }
-
- padding = original_lines - new_lines.length
- new_lines += [nil] * padding if padding >= 0
-
- new_lines.join "\n"
- end
-
- open @rb_name, 'w' do |f|
- f.puts "# This file is generated by rake. Do not edit."
- f.puts
- f.puts new_file
- end
- end
-
- def constants(options = {}, &block)
- @constants << FFI::ConstGenerator.new(@name, @options.merge(options), &block)
- end
-
- def struct(options = {}, &block)
- @structs << FFI::StructGenerator.new(@name, @options.merge(options), &block)
- end
-
- ##
- # Utility converter for constants
-
- def to_s
- proc { |obj| obj.to_s.inspect }
- end
-
- end
-end
-
diff --git a/src/main/resources/stdlib/ffi/tools/generator_task.rb b/src/main/resources/stdlib/ffi/tools/generator_task.rb
deleted file mode 100644
index 07e234f..0000000
--- a/src/main/resources/stdlib/ffi/tools/generator_task.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-begin
- require 'ffi/struct_generator'
- require 'ffi/const_generator'
- require 'ffi/generator'
-rescue LoadError
- # from Rakefile
- require 'lib/ffi/struct_generator'
- require 'lib/ffi/const_generator'
- require 'lib/ffi/generator'
-end
-
-require 'rake'
-require 'rake/tasklib'
-require 'tempfile'
-
-##
-# Rake task that calculates C structs for FFI::Struct.
-
-class FFI::Generator::Task < Rake::TaskLib
-
- def initialize(rb_names)
- task :clean do rm_f rb_names end
-
- rb_names.each do |rb_name|
- ffi_name = "#{rb_name}.ffi"
-
- file rb_name => ffi_name do |t|
- puts "Generating #{rb_name}..." if Rake.application.options.trace
-
- FFI::Generator.new ffi_name, rb_name
- end
- end
- end
-
-end
diff --git a/src/main/resources/stdlib/ffi/tools/platform.rake b/src/main/resources/stdlib/ffi/tools/platform.rake
deleted file mode 100644
index 85fd1b8..0000000
--- a/src/main/resources/stdlib/ffi/tools/platform.rake
+++ /dev/null
@@ -1,554 +0,0 @@
-require 'ffi/platform'
-require 'ffi/tools/struct_generator'
-require 'ffi/tools/const_generator'
-require 'ffi/tools/types_generator'
-
-deps = %w[Rakefile] + Dir['lib/ffi/*rb']
-
-#file PLATFORM_CONF => deps do |task|
-# gen_platform_conf task
-#end
-def gen_platform_conf(task, options = {})
- FFI::StructGenerator.options = options
- FFI::ConstGenerator.options = options
-
- addrinfo = FFI::StructGenerator.new 'addrinfo' do |s|
- s.include 'sys/types.h'
- s.include 'sys/socket.h'
- s.include 'netdb.h'
- s.name 'struct addrinfo'
- s.field :ai_flags, :int
- s.field :ai_family, :int
- s.field :ai_socktype, :int
- s.field :ai_protocol, :int
- s.field :ai_addrlen, :int
- s.field :ai_addr, :pointer
- s.field :ai_canonname, :string
- s.field :ai_next, :pointer
- end unless FFI::Platform::IS_WINDOWS
-
- dirent = FFI::StructGenerator.new 'dirent' do |s|
- s.include "sys/types.h"
- s.include "dirent.h"
- s.name 'struct dirent'
- s.field :d_ino, :ino_t
- s.field :d_reclen, :ushort unless FFI::Platform::IS_WINDOWS
- s.field :d_name, :char_array
- end
-
- timeval = FFI::StructGenerator.new 'timeval' do |s|
- s.include "sys/time.h"
- s.name 'struct timeval'
- s.field :tv_sec, :time_t
- s.field :tv_usec, :suseconds_t
- end
-
- sockaddr_in = FFI::StructGenerator.new 'sockaddr_in' do |s|
- s.include "netinet/in.h"
- s.include "fcntl.h"
- s.include "sys/socket.h"
- s.include "sys/stat.h"
- s.name 'struct sockaddr_in'
- s.field :sin_family, :sa_family_t
- s.field :sin_port, :ushort
- s.field :sin_addr
- s.field :sin_zero, :char_array
- end
-
- sockaddr_un = FFI::StructGenerator.new 'sockaddr_un' do |s|
- s.include "sys/un.h"
- s.name 'struct sockaddr_un'
- s.field :sun_family, :sa_family_t
- s.field :sun_path, :char_array
- end
-
- servent = FFI::StructGenerator.new 'servent' do |s|
- s.include "netdb.h"
- s.name 'struct servent'
- s.field :s_name, :pointer
- s.field :s_aliases, :pointer
- s.field :s_port, :int
- s.field :s_proto, :pointer
- end
-
- stat = FFI::StructGenerator.new 'stat' do |s|
- s.include "sys/types.h"
- s.include "sys/stat.h"
- s.name 'struct stat'
- s.field :st_dev, :dev_t
- s.field :st_ino, :ino_t
- s.field :st_mode, :mode_t
- s.field :st_nlink, :nlink_t
- s.field :st_uid, :uid_t
- s.field :st_gid, :gid_t
- s.field :st_rdev, :dev_t
- s.field :st_size, :off_t
- s.field :st_blksize
- s.field :st_blocks
- s.field :st_atime, :time_t
- s.field :st_mtime, :time_t
- s.field :st_ctime, :time_t
- end
-
- rlimit = FFI::StructGenerator.new 'rlimit' do |s|
- s.include "sys/types.h"
- s.include "sys/time.h"
- s.include "sys/resource.h"
- s.name 'struct rlimit'
- s.field :rlim_cur, :rlim_t
- s.field :rlim_max, :rlim_t
- end
-
- # FIXME these constants don't have standard names. LOCK_SH == Linux,
- # O_SHLOCK on Bsd/Darwin, etc. Binary doesn't exist at all in many non-Unix
- # variants. This should come out of something like config.h
-
- fixme_constants = %w{
- LOCK_SH
- LOCK_EX
- LOCK_NB
- LOCK_UN
- BINARY
- }
-
- file_cg = FFI::ConstGenerator.new 'rbx.platform.file' do |cg|
- cg.include 'stdio.h'
- cg.include 'fcntl.h'
- cg.include 'sys/stat.h'
-
- file_constants = %w[
- O_RDONLY
- O_WRONLY
- O_RDWR
- O_CREAT
- O_EXCL
- O_NOCTTY
- O_TRUNC
- O_APPEND
- O_NONBLOCK
- O_SYNC
- S_IRUSR
- S_IWUSR
- S_IXUSR
- S_IRGRP
- S_IWGRP
- S_IXGRP
- S_IROTH
- S_IWOTH
- S_IXOTH
- S_IFMT
- S_IFIFO
- S_IFCHR
- S_IFDIR
- S_IFBLK
- S_IFREG
- S_IFLNK
- S_IFSOCK
- S_IFWHT
- S_ISUID
- S_ISGID
- ]
-
- file_constants.each { |c| cg.const c }
- end
-
- io_cg = FFI::ConstGenerator.new 'rbx.platform.io' do |cg|
- cg.include 'stdio.h'
-
- io_constants = %w[
- SEEK_SET
- SEEK_CUR
- SEEK_END
- ]
-
- io_constants.each { |c| cg.const c }
- end
-
- # Only constants needed by core are added here
- fcntl_cg = FFI::ConstGenerator.new 'rbx.platform.fcntl' do |cg|
- cg.include 'fcntl.h'
-
- fcntl_constants = %w[
- F_GETFL
- F_SETFL
- O_ACCMODE
- ]
-
- fcntl_constants.each { |c| cg.const c }
- end
-
- socket_cg = FFI::ConstGenerator.new 'rbx.platform.socket' do |cg|
- cg.include 'sys/types.h'
- cg.include 'sys/socket.h'
- cg.include 'netdb.h'
- cg.include 'netinet/tcp.h'
- cg.include 'netinet/in.h'
-
- socket_constants = %w[
- AF_APPLETALK
- AF_ATM
- AF_AX25
- AF_CCITT
- AF_CHAOS
- AF_CNT
- AF_COIP
- AF_DATAKIT
- AF_DEC
- AF_DLI
- AF_E164
- AF_ECMA
- AF_HYLINK
- AF_IMPLINK
- AF_INET
- AF_INET6
- AF_IPX
- AF_ISDN
- AF_ISO
- AF_LAT
- AF_LINK
- AF_LOCAL
- AF_MAX
- AF_NATM
- AF_NDRV
- AF_NETBIOS
- AF_NETGRAPH
- AF_NS
- AF_OSI
- AF_PPP
- AF_PUP
- AF_ROUTE
- AF_SIP
- AF_SNA
- AF_SYSTEM
- AF_UNIX
- AF_UNSPEC
-
- AI_ADDRCONFIG
- AI_ALL
- AI_CANONNAME
- AI_DEFAULT
- AI_MASK
- AI_NUMERICHOST
- AI_PASSIVE
- AI_V4MAPPED
- AI_V4MAPPED_CFG
-
- EAI_ADDRFAMILY
- EAI_AGAIN
- EAI_BADFLAGS
- EAI_BADHINTS
- EAI_FAIL
- EAI_FAMILY
- EAI_MAX
- EAI_MEMORY
- EAI_NODATA
- EAI_NONAME
- EAI_PROTOCOL
- EAI_SERVICE
- EAI_SOCKTYPE
- EAI_SYSTEM
-
- INADDR_ALLHOSTS_GROUP
- INADDR_ANY
- INADDR_BROADCAST
- INADDR_LOOPBACK
- INADDR_MAX_LOCAL_GROUP
- INADDR_NONE
- INADDR_UNSPEC_GROUP
-
- IPPORT_RESERVED
- IPPORT_USERRESERVED
-
- IPPROTO_BIP
- IPPROTO_EGP
- IPPROTO_EON
- IPPROTO_GGP
- IPPROTO_HELLO
- IPPROTO_ICMP
- IPPROTO_IDP
- IPPROTO_IGMP
- IPPROTO_IP
- IPPROTO_MAX
- IPPROTO_ND
- IPPROTO_PUP
- IPPROTO_RAW
- IPPROTO_TCP
- IPPROTO_TP
- IPPROTO_UDP
- IPPROTO_XTP
-
- IPX_TYPE
-
- IP_ADD_MEMBERSHIP
- IP_DEFAULT_MULTICAST_LOOP
- IP_DEFAULT_MULTICAST_TTL
- IP_DROP_MEMBERSHIP
- IP_HDRINCL
- IP_MAX_MEMBERSHIPS
- IP_MULTICAST_IF
- IP_MULTICAST_LOOP
- IP_MULTICAST_TTL
- IP_OPTIONS
- IP_RECVDSTADDR
- IP_RECVOPTS
- IP_RECVRETOPTS
- IP_RETOPTS
- IP_TOS
- IP_TTL
-
- MSG_COMPAT
- MSG_CTRUNC
- MSG_DONTROUTE
- MSG_DONTWAIT
- MSG_EOF
- MSG_EOR
- MSG_FLUSH
- MSG_HAVEMORE
- MSG_HOLD
- MSG_OOB
- MSG_PEEK
- MSG_RCVMORE
- MSG_SEND
- MSG_TRUNC
- MSG_WAITALL
-
- NI_DGRAM
- NI_MAXHOST
- NI_MAXSERV
- NI_NAMEREQD
- NI_NOFQDN
- NI_NUMERICHOST
- NI_NUMERICSERV
-
- PF_APPLETALK
- PF_AX25
- PF_CCITT
- PF_CHAOS
- PF_CNT
- PF_COIP
- PF_DATAKIT
- PF_DLI
- PF_ECMA
- PF_HYLINK
- PF_IMPLINK
- PF_INET
- PF_INET6
- PF_IPX
- PF_ISDN
- PF_ISO
- PF_KEY
- PF_LAT
- PF_LINK
- PF_LOCAL
- PF_MAX
- PF_NATM
- PF_NDRV
- PF_NETBIOS
- PF_NETGRAPH
- PF_NS
- PF_OSI
- PF_PIP
- PF_PPP
- PF_PUP
- PF_ROUTE
- PF_RTIP
- PF_SIP
- PF_SNA
- PF_SYSTEM
- PF_UNIX
- PF_UNSPEC
- PF_XTP
-
- SHUT_RD
- SHUT_RDWR
- SHUT_WR
-
- SOCK_DGRAM
- SOCK_PACKET
- SOCK_RAW
- SOCK_RDM
- SOCK_SEQPACKET
- SOCK_STREAM
-
- SOL_ATALK
- SOL_AX25
- SOL_IP
- SOL_IPX
- SOL_SOCKET
- SOL_TCP
- SOL_UDP
-
- SOPRI_BACKGROUND
- SOPRI_INTERACTIVE
- SOPRI_NORMAL
-
- SO_ACCEPTCONN
- SO_ACCEPTFILTER
- SO_ATTACH_FILTER
- SO_BINDTODEVICE
- SO_BROADCAST
- SO_DEBUG
- SO_DETACH_FILTER
- SO_DONTROUTE
- SO_DONTTRUNC
- SO_ERROR
- SO_KEEPALIVE
- SO_LINGER
- SO_NKE
- SO_NOSIGPIPE
- SO_NO_CHECK
- SO_NREAD
- SO_OOBINLINE
- SO_PASSCRED
- SO_PEERCRED
- SO_PEERNAME
- SO_PRIORITY
- SO_RCVBUF
- SO_RCVLOWAT
- SO_RCVTIMEO
- SO_REUSEADDR
- SO_REUSEPORT
- SO_SECURITY_AUTHENTICATION
- SO_SECURITY_ENCRYPTION_NETWORK
- SO_SECURITY_ENCRYPTION_TRANSPORT
- SO_SNDBUF
- SO_SNDLOWAT
- SO_SNDTIMEO
- SO_TIMESTAMP
- SO_TYPE
- SO_USELOOPBACK
- SO_WANTMORE
- SO_WANTOOBFLAG
-
- TCP_MAXSEG
- TCP_NODELAY
- ]
-
- socket_constants.each { |c| cg.const c, "%ld", '(long)' }
- end
-
- process_cg = FFI::ConstGenerator.new 'rbx.platform.process' do |cg|
- cg.include 'sys/wait.h'
- cg.include 'sys/resource.h'
-
- process_constants = %w{
- WNOHANG
- WUNTRACED
- PRIO_PROCESS
- PRIO_PGRP
- PRIO_USER
- RLIMIT_CPU
- RLIMIT_FSIZE
- RLIMIT_DATA
- RLIMIT_STACK
- RLIMIT_CORE
- RLIMIT_RSS
- RLIMIT_NPROC
- RLIMIT_NOFILE
- RLIMIT_MEMLOCK
- RLIMIT_AS
- RLIMIT_SBSIZE
- }
-
- process_constants.each { |c| cg.const c }
-
- long_process_constants = %w[
- RLIM_INFINITY
- RLIM_SAVED_MAX
- RLIM_SAVED_CUR
- ]
-
- long_process_constants.each { |c|
- cg.const c, "%llu", "(unsigned long long)"
- }
- end
-
- # The constants come from MRI's signal.c. This means that some of them might
- # be missing.
-
- signal_cg = FFI::ConstGenerator.new 'rbx.platform.signal' do |cg|
- cg.include 'signal.h'
- cg.include 'sys/signal.h'
-
- signal_constants = %w{
- SIGHUP
- SIGINT
- SIGQUIT
- SIGILL
- SIGTRAP
- SIGIOT
- SIGABRT
- SIGEMT
- SIGFPE
- SIGKILL
- SIGBUS
- SIGSEGV
- SIGSYS
- SIGPIPE
- SIGALRM
- SIGTERM
- SIGURG
- SIGSTOP
- SIGTSTP
- SIGCONT
- SIGCHLD
- SIGCLD
- SIGCHLD
- SIGTTIN
- SIGTTOU
- SIGIO
- SIGXCPU
- SIGXFSZ
- SIGVTALRM
- SIGPROF
- SIGWINCH
- SIGUSR1
- SIGUSR2
- SIGLOST
- SIGMSG
- SIGPWR
- SIGPOLL
- SIGDANGER
- SIGMIGRATE
- SIGPRE
- SIGGRANT
- SIGRETRACT
- SIGSOUND
- SIGINFO
- }
-
- signal_constants.each { |c| cg.const c }
- end
-
- zlib_cg = FFI::ConstGenerator.new 'rbx.platform.zlib' do |cg|
- cg.include 'zlib.h'
-
- zlib_constants = %w[ZLIB_VERSION]
-
- zlib_constants.each { |c| cg.const c, "%s", "(char *)" }
- end
-
- puts "Generating #{task.name}..." if $verbose
-
- File.open task.name, "w" do |f|
- addrinfo.dump_config f unless FFI::Platform::IS_WINDOWS
- dirent.dump_config f
- timeval.dump_config f
- sockaddr_in.dump_config f
- sockaddr_un.dump_config f if sockaddr_un.found?
- servent.dump_config f
- stat.dump_config f
- rlimit.dump_config f
-
- file_cg.dump_constants f
- io_cg.dump_constants f
- fcntl_cg.dump_constants f
- socket_cg.dump_constants f
- process_cg.dump_constants f
- signal_cg.dump_constants f
- zlib_cg.dump_constants f
-
- f.puts FFI::TypesGenerator.generate options
- end
-
-end
diff --git a/src/main/resources/stdlib/ffi/tools/struct_generator.rb b/src/main/resources/stdlib/ffi/tools/struct_generator.rb
deleted file mode 100644
index 2633c4f..0000000
--- a/src/main/resources/stdlib/ffi/tools/struct_generator.rb
+++ /dev/null
@@ -1,196 +0,0 @@
-require 'tmpdir'
-require 'tempfile'
-
-module FFI
-
- ##
- # Generates an FFI Struct layout.
- #
- # Given the @@@ portion in:
- #
- # module Zlib::ZStream < FFI::Struct
- # @@@
- # name "struct z_stream_s"
- # include "zlib.h"
- #
- # field :next_in, :pointer
- # field :avail_in, :uint
- # field :total_in, :ulong
- #
- # # ...
- # @@@
- # end
- #
- # StructGenerator will create the layout:
- #
- # layout :next_in, :pointer, 0,
- # :avail_in, :uint, 4,
- # :total_in, :ulong, 8,
- # # ...
- #
- # StructGenerator does its best to pad the layout it produces to preserve
- # line numbers. Place the struct definition as close to the top of the file
- # for best results.
-
- class StructGenerator
- @options = {}
- attr_accessor :size
- attr_reader :fields
-
- def initialize(name, options = {})
- @name = name
- @struct_name = nil
- @includes = []
- @fields = []
- @found = false
- @size = nil
-
- if block_given? then
- yield self
- calculate self.class.options.merge(options)
- end
- end
- def self.options=(options)
- @options = options
- end
- def self.options
- @options
- end
- def calculate(options = {})
- binary = File.join Dir.tmpdir, "rb_struct_gen_bin_#{Process.pid}"
-
- raise "struct name not set" if @struct_name.nil?
-
- Tempfile.open("#{@name}.struct_generator") do |f|
- f.puts "#include "
-
- @includes.each do |inc|
- f.puts "#include <#{inc}>"
- end
-
- f.puts "#include \n\n"
- f.puts "int main(int argc, char **argv)\n{"
- f.puts " #{@struct_name} s;"
- f.puts %[ printf("sizeof(#{@struct_name}) %u\\n", (unsigned int) sizeof(#{@struct_name}));]
-
- @fields.each do |field|
- f.puts <<-EOF
- printf("#{field.name} %u %u\\n", (unsigned int) offsetof(#{@struct_name}, #{field.name}),
- (unsigned int) sizeof(s.#{field.name}));
- EOF
- end
-
- f.puts "\n return 0;\n}"
- f.flush
-
- output = `gcc #{options[:cppflags]} #{options[:cflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -x c -Wall -Werror #{f.path} -o #{binary} 2>&1`
-
- unless $?.success? then
- @found = false
- output = output.split("\n").map { |l| "\t#{l}" }.join "\n"
- raise "Compilation error generating struct #{@name} (#{@struct_name}):\n#{output}"
- end
- end
-
- output = `#{binary}`.split "\n"
- File.unlink(binary + (FFI::Platform.windows? ? ".exe" : ""))
- sizeof = output.shift
- unless @size
- m = /\s*sizeof\([^)]+\) (\d+)/.match sizeof
- @size = m[1]
- end
-
- line_no = 0
- output.each do |line|
- md = line.match(/.+ (\d+) (\d+)/)
- @fields[line_no].offset = md[1].to_i
- @fields[line_no].size = md[2].to_i
-
- line_no += 1
- end
-
- @found = true
- end
-
- def field(name, type=nil)
- field = Field.new(name, type)
- @fields << field
- return field
- end
-
- def found?
- @found
- end
-
- def dump_config(io)
- io.puts "rbx.platform.#{@name}.sizeof = #{@size}"
-
- @fields.each { |field| io.puts field.to_config(@name) }
- end
-
- def generate_layout
- buf = ""
- buf << "self.size = #{@size}\n"
-
- @fields.each_with_index do |field, i|
- if i < 1
- buf << "layout :#{field.name}, :#{field.type}, #{field.offset}"
- else
- buf << " :#{field.name}, :#{field.type}, #{field.offset}"
- end
-
- if i < @fields.length - 1
- buf << ",\n"
- end
- end
-
- buf
- end
-
- def get_field(name)
- @fields.find { |f| name == f.name }
- end
-
- def include(i)
- @includes << i
- end
-
- def name(n)
- @struct_name = n
- end
-
- end
-
- ##
- # A field in a Struct.
-
- class StructGenerator::Field
-
- attr_reader :name
- attr_reader :type
- attr_reader :offset
- attr_accessor :size
-
- def initialize(name, type)
- @name = name
- @type = type
- @offset = nil
- @size = nil
- end
-
- def offset=(o)
- @offset = o
- end
-
- def to_config(name)
- buf = []
- buf << "rbx.platform.#{name}.#{@name}.offset = #{@offset}"
- buf << "rbx.platform.#{name}.#{@name}.size = #{@size}"
- buf << "rbx.platform.#{name}.#{@name}.type = #{@type}" if @type
- buf
- end
-
- end
-
-end
-
diff --git a/src/main/resources/stdlib/ffi/tools/types_generator.rb b/src/main/resources/stdlib/ffi/tools/types_generator.rb
deleted file mode 100644
index d36ba85..0000000
--- a/src/main/resources/stdlib/ffi/tools/types_generator.rb
+++ /dev/null
@@ -1,123 +0,0 @@
-require 'tempfile'
-
-module FFI
- class TypesGenerator
-
- ##
- # Maps different C types to the C type representations we use
-
- TYPE_MAP = {
- "char" => :char,
- "signed char" => :char,
- "__signed char" => :char,
- "unsigned char" => :uchar,
-
- "short" => :short,
- "signed short" => :short,
- "signed short int" => :short,
- "unsigned short" => :ushort,
- "unsigned short int" => :ushort,
-
- "int" => :int,
- "signed int" => :int,
- "unsigned int" => :uint,
-
- "long" => :long,
- "long int" => :long,
- "signed long" => :long,
- "signed long int" => :long,
- "unsigned long" => :ulong,
- "unsigned long int" => :ulong,
- "long unsigned int" => :ulong,
-
- "long long" => :long_long,
- "long long int" => :long_long,
- "signed long long" => :long_long,
- "signed long long int" => :long_long,
- "unsigned long long" => :ulong_long,
- "unsigned long long int" => :ulong_long,
-
- "char *" => :string,
- "void *" => :pointer,
- }
-
- def self.generate(options = {})
- typedefs = nil
- Tempfile.open 'ffi_types_generator' do |io|
- io.puts <<-C
-#include
-#include
-#include
- C
-
- io.close
- typedefs = `gcc -E -x c #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c #{io.path}`
- end
-
- code = ""
-
- typedefs.each do |type|
- # We only care about single line typedef
- next unless type =~ /typedef/
- # Ignore unions or structs
- next if type =~ /union|struct/
-
- # strip off the starting typedef and ending ;
- type.gsub!(/^(.*typedef\s*)/, "")
- type.gsub!(/\s*;\s*$/, "")
-
- parts = type.split(/\s+/)
- def_type = parts.join(" ")
-
- # GCC does mapping with __attribute__ stuf, also see
- # http://hal.cs.berkeley.edu/cil/cil016.html section 16.2.7. Problem
- # with this is that the __attribute__ stuff can either occur before or
- # after the new type that is defined...
- if type =~ /__attribute__/
- if parts.last =~ /__QI__|__HI__|__SI__|__DI__|__word__/
-
- # In this case, the new type is BEFORE __attribute__ we need to
- # find the final_type as the type before the part that starts with
- # __attribute__
- final_type = ""
- parts.each do |p|
- break if p =~ /__attribute__/
- final_type = p
- end
- else
- final_type = parts.pop
- end
-
- def_type = case type
- when /__QI__/ then "char"
- when /__HI__/ then "short"
- when /__SI__/ then "int"
- when /__DI__/ then "long long"
- when /__word__/ then "long"
- else "int"
- end
-
- def_type = "unsigned #{def_type}" if type =~ /unsigned/
- else
- final_type = parts.pop
- def_type = parts.join(" ")
- end
-
- if type = TYPE_MAP[def_type]
- code << "rbx.platform.typedef.#{final_type} = #{type}\n"
- TYPE_MAP[final_type] = TYPE_MAP[def_type]
- else
- # Fallback to an ordinary pointer if we don't know the type
- if def_type =~ /\*/
- code << "rbx.platform.typedef.#{final_type} = pointer\n"
- TYPE_MAP[final_type] = :pointer
- end
- end
- end
-
- code
- end
-
- end
-end
-
diff --git a/src/main/resources/stdlib/ffi/types.rb b/src/main/resources/stdlib/ffi/types.rb
deleted file mode 100644
index 4c81140..0000000
--- a/src/main/resources/stdlib/ffi/types.rb
+++ /dev/null
@@ -1,164 +0,0 @@
-#
-# Copyright (C) 2008, 2009 Wayne Meissner
-# Copyright (C) 2009 Luc Heinrich
-# Copyright (c) 2007, 2008 Evan Phoenix
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright notice
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-# * Neither the name of the Evan Phoenix nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-module FFI
-
- def self.typedef(old, add)
- TypeDefs[add] = self.find_type(old)
- end
-
- def self.add_typedef(old, add)
- typedef old, add
- end
-
-
- def self.find_type(name, type_map = nil)
- if name.is_a?(Type)
- name
-
- elsif type_map && type_map.has_key?(name)
- type_map[name]
-
- elsif TypeDefs.has_key?(name)
- TypeDefs[name]
-
- elsif name.is_a?(DataConverter)
- (type_map || TypeDefs)[name] = Type::Mapped.new(name)
-
- else
- raise TypeError, "unable to resolve type '#{name}'"
- end
- end
-
- TypeDefs.merge!({
- # The C void type; only useful for function return types
- :void => Type::VOID,
-
- # C boolean type
- :bool => Type::BOOL,
-
- # C nul-terminated string
- :string => Type::STRING,
-
- # C signed char
- :char => Type::CHAR,
- # C unsigned char
- :uchar => Type::UCHAR,
-
- # C signed short
- :short => Type::SHORT,
- # C unsigned short
- :ushort => Type::USHORT,
-
- # C signed int
- :int => Type::INT,
- # C unsigned int
- :uint => Type::UINT,
-
- # C signed long
- :long => Type::LONG,
-
- # C unsigned long
- :ulong => Type::ULONG,
-
- # C signed long long integer
- :long_long => Type::LONG_LONG,
-
- # C unsigned long long integer
- :ulong_long => Type::ULONG_LONG,
-
- # C single precision float
- :float => Type::FLOAT,
-
- # C double precision float
- :double => Type::DOUBLE,
-
- # Native memory address
- :pointer => Type::POINTER,
-
- # 8 bit signed integer
- :int8 => Type::INT8,
- # 8 bit unsigned integer
- :uint8 => Type::UINT8,
-
- # 16 bit signed integer
- :int16 => Type::INT16,
- # 16 bit unsigned integer
- :uint16 => Type::UINT16,
-
- # 32 bit signed integer
- :int32 => Type::INT32,
- # 32 bit unsigned integer
- :uint32 => Type::UINT32,
-
- # 64 bit signed integer
- :int64 => Type::INT64,
- # 64 bit unsigned integer
- :uint64 => Type::UINT64,
-
- :buffer_in => Type::BUFFER_IN,
- :buffer_out => Type::BUFFER_OUT,
- :buffer_inout => Type::BUFFER_INOUT,
-
- # Used in function prototypes to indicate the arguments are variadic
- :varargs => Type::VARARGS,
- })
-
- # Returns a [ String, Pointer ] tuple so the C memory for the string can be freed
- class StrPtrConverter
- extend DataConverter
- native_type Type::POINTER
-
- def self.from_native(val, ctx)
- [ val.null? ? nil : val.get_string(0), val ]
- end
-
- end
-
- typedef(StrPtrConverter, :strptr)
-
- def self.type_size(type)
- find_type(type).size
- end
-
- # Load all the platform dependent types
- begin
- File.open(File.join(Platform::CONF_DIR, 'types.conf'), "r") do |f|
- prefix = "rbx.platform.typedef."
- f.each_line { |line|
- if line.index(prefix) == 0
- new_type, orig_type = line.chomp.slice(prefix.length..-1).split(/\s*=\s*/)
- typedef(orig_type.to_sym, new_type.to_sym)
- end
- }
- end
- typedef :pointer, :caddr_t
- rescue Errno::ENOENT
- end
-end
diff --git a/src/main/resources/stdlib/ffi/union.rb b/src/main/resources/stdlib/ffi/union.rb
deleted file mode 100644
index 17a16e2..0000000
--- a/src/main/resources/stdlib/ffi/union.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Copyright (C) 2009-2010 Wayne Meissner
-# Copyright (C) 2009-2010 Andrea Fazzi
-#
-# Version: EPL 1.0/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Common Public
-# License Version 1.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.eclipse.org/legal/cpl-v10.html
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the EPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the EPL, the GPL or the LGPL.
-#
-#
-# This file contains code that was originally under the following license:
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright notice
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-# * Neither the name of the Evan Phoenix nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-require 'ffi/struct'
-
-module FFI
-
- class Union < FFI::Struct
- def self.builder
- b = StructLayoutBuilder.new
- b.union = true
- b
- end
- end
-end
diff --git a/src/main/resources/stdlib/ffi/variadic.rb b/src/main/resources/stdlib/ffi/variadic.rb
deleted file mode 100644
index 7a9bc18..0000000
--- a/src/main/resources/stdlib/ffi/variadic.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-#
-# Copyright (C) 2008-2010 Wayne Meissner
-#
-# Version: EPL 1.0/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Common Public
-# License Version 1.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.eclipse.org/legal/cpl-v10.html
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the EPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the EPL, the GPL or the LGPL.
-#
-
-module FFI
- class VariadicInvoker
- def init(arg_types, type_map)
- @fixed = Array.new
- @type_map = type_map
- arg_types.each_with_index do |type, i|
- @fixed << type unless type == FFI::NativeType::VARARGS
- end
- end
-
- def call(*args, &block)
- param_types = Array.new(@fixed)
- param_values = Array.new
- @fixed.each_with_index do |t, i|
- param_values << args[i]
- end
- i = @fixed.length
- while i < args.length
- param_types << FFI.find_type(args[i], @type_map)
- param_values << args[i + 1]
- i += 2
- end
- invoke(param_types, param_values, &block)
- end
-
- #
- # Attach the invoker to module +mod+ as +mname+
- #
- def attach(mod, mname)
- invoker = self
- params = "*args"
- call = "call"
- mod.module_eval <<-code
- @@#{mname} = invoker
- def self.#{mname}(#{params})
- @@#{mname}.#{call}(#{params})
- end
- def #{mname}(#{params})
- @@#{mname}.#{call}(#{params})
- end
- code
- invoker
- end
- end
-end
diff --git a/src/main/resources/stdlib/fiber.rb b/src/main/resources/stdlib/fiber.rb
deleted file mode 100644
index d568fc8..0000000
--- a/src/main/resources/stdlib/fiber.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-##
-# Extensions to Fiber. In JRuby, these are all still defined in the normal
-# Fiber class, so we alias them to the right names here.
-#
-class Fiber
- class << self
- alias current __current__
- end
-
- alias transfer __transfer__
- alias alive? __alive__
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/fiddle.rb b/src/main/resources/stdlib/fiddle.rb
deleted file mode 100644
index 981e454..0000000
--- a/src/main/resources/stdlib/fiddle.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require 'fiddle.so' unless RUBY_ENGINE == 'jruby'
-require 'fiddle/jruby' if RUBY_ENGINE == 'jruby'
-require 'fiddle/function'
-require 'fiddle/closure'
-
-module Fiddle
- if WINDOWS
- # Returns the last win32 +Error+ of the current executing +Thread+ or nil
- # if none
- def self.win32_last_error
- if RUBY_ENGINE == 'jruby'
- errno = FFI.errno
- errno = nil if errno == 0
- else
- Thread.current[:__FIDDLE_WIN32_LAST_ERROR__]
- end
- end
-
- # Sets the last win32 +Error+ of the current executing +Thread+ to +error+
- def self.win32_last_error= error
- if RUBY_ENGINE == 'jruby'
- FFI.errno = error || 0
- else
- Thread.current[:__FIDDLE_WIN32_LAST_ERROR__] = error
- end
- end
- end
-
- # Returns the last +Error+ of the current executing +Thread+ or nil if none
- def self.last_error
- if RUBY_ENGINE == 'jruby'
- errno = FFI.errno
- errno = nil if errno == 0
- errno
- else
- Thread.current[:__FIDDLE_LAST_ERROR__]
- end
- end
-
- # Sets the last +Error+ of the current executing +Thread+ to +error+
- def self.last_error= error
- if RUBY_ENGINE == 'jruby'
- FFI.errno = error || 0
- else
- Thread.current[:__DL2_LAST_ERROR__] = error
- Thread.current[:__FIDDLE_LAST_ERROR__] = error
- end
- end
-
- # call-seq: dlopen(library) => Fiddle::Handle
- #
- # Creates a new handler that opens +library+, and returns an instance of
- # Fiddle::Handle.
- #
- # If +nil+ is given for the +library+, Fiddle::Handle::DEFAULT is used, which
- # is the equivalent to RTLD_DEFAULT. See man 3 dlopen for more.
- #
- # lib = Fiddle.dlopen(nil)
- #
- # The default is dependent on OS, and provide a handle for all libraries
- # already loaded. For example, in most cases you can use this to access
- # +libc+ functions, or ruby functions like +rb_str_new+.
- #
- # See Fiddle::Handle.new for more.
- def dlopen library
- Fiddle::Handle.new library
- end
- module_function :dlopen
-
- # Add constants for backwards compat
-
- RTLD_GLOBAL = Handle::RTLD_GLOBAL # :nodoc:
- RTLD_LAZY = Handle::RTLD_LAZY # :nodoc:
- RTLD_NOW = Handle::RTLD_NOW # :nodoc:
-end
diff --git a/src/main/resources/stdlib/fiddle/closure.rb b/src/main/resources/stdlib/fiddle/closure.rb
deleted file mode 100644
index beb90ec..0000000
--- a/src/main/resources/stdlib/fiddle/closure.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-module Fiddle
- class Closure
-
- # the C type of the return of the FFI closure
- attr_reader :ctype
-
- # arguments of the FFI closure
- attr_reader :args
-
- # Extends Fiddle::Closure to allow for building the closure in a block
- class BlockCaller < Fiddle::Closure
-
- # == Description
- #
- # Construct a new BlockCaller object.
- #
- # * +ctype+ is the C type to be returned
- # * +args+ are passed the callback
- # * +abi+ is the abi of the closure
- #
- # If there is an error in preparing the +ffi_cif+ or +ffi_prep_closure+,
- # then a RuntimeError will be raised.
- #
- # == Example
- #
- # include Fiddle
- #
- # cb = Closure::BlockCaller.new(TYPE_INT, [TYPE_INT]) do |one|
- # one
- # end
- #
- # func = Function.new(cb, [TYPE_INT], TYPE_INT)
- #
- def initialize ctype, args, abi = Fiddle::Function::DEFAULT, &block
- super(ctype, args, abi)
- @block = block
- end
-
- # Calls the constructed BlockCaller, with +args+
- #
- # For an example see Fiddle::Closure::BlockCaller.new
- #
- def call *args
- @block.call(*args)
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/fiddle/cparser.rb b/src/main/resources/stdlib/fiddle/cparser.rb
deleted file mode 100644
index 43fb184..0000000
--- a/src/main/resources/stdlib/fiddle/cparser.rb
+++ /dev/null
@@ -1,176 +0,0 @@
-module Fiddle
- # A mixin that provides methods for parsing C struct and prototype signatures.
- #
- # == Example
- # require 'fiddle/import'
- #
- # include Fiddle::CParser
- # #=> Object
- #
- # parse_ctype('int increment(int)')
- # #=> ["increment", Fiddle::TYPE_INT, [Fiddle::TYPE_INT]]
- #
- module CParser
- # Parses a C struct's members
- #
- # Example:
- #
- # include Fiddle::CParser
- # #=> Object
- #
- # parse_struct_signature(['int i', 'char c'])
- # #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]]
- #
- def parse_struct_signature(signature, tymap=nil)
- if( signature.is_a?(String) )
- signature = signature.split(/\s*,\s*/)
- end
- mems = []
- tys = []
- signature.each{|msig|
- tks = msig.split(/\s+(\*)?/)
- ty = tks[0..-2].join(" ")
- member = tks[-1]
-
- case ty
- when /\[(\d+)\]/
- n = $1.to_i
- ty.gsub!(/\s*\[\d+\]/,"")
- ty = [ty, n]
- when /\[\]/
- ty.gsub!(/\s*\[\]/, "*")
- end
-
- case member
- when /\[(\d+)\]/
- ty = [ty, $1.to_i]
- member.gsub!(/\s*\[\d+\]/,"")
- when /\[\]/
- ty = ty + "*"
- member.gsub!(/\s*\[\]/, "")
- end
-
- mems.push(member)
- tys.push(parse_ctype(ty,tymap))
- }
- return tys, mems
- end
-
- # Parses a C prototype signature
- #
- # If Hash +tymap+ is provided, the return value and the arguments from the
- # +signature+ are expected to be keys, and the value will be the C type to
- # be looked up.
- #
- # Example:
- #
- # include Fiddle::CParser
- # #=> Object
- #
- # parse_signature('double sum(double, double)')
- # #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]]
- #
- def parse_signature(signature, tymap=nil)
- tymap ||= {}
- signature = signature.gsub(/\s+/, " ").strip
- case signature
- when /^([\w@\*\s]+)\(([\w\*\s\,\[\]]*)\)$/
- ret = $1
- (args = $2).strip!
- ret = ret.split(/\s+/)
- args = args.split(/\s*,\s*/)
- func = ret.pop
- if( func =~ /^\*/ )
- func.gsub!(/^\*+/,"")
- ret.push("*")
- end
- ret = ret.join(" ")
- return [func, parse_ctype(ret, tymap), args.collect{|arg| parse_ctype(arg, tymap)}]
- else
- raise(RuntimeError,"can't parse the function prototype: #{signature}")
- end
- end
-
- # Given a String of C type +ty+, returns the corresponding Fiddle constant.
- #
- # +ty+ can also accept an Array of C type Strings, and will be returned in
- # a corresponding Array.
- #
- # If Hash +tymap+ is provided, +ty+ is expected to be the key, and the
- # value will be the C type to be looked up.
- #
- # Example:
- #
- # include Fiddle::CParser
- # #=> Object
- #
- # parse_ctype('int')
- # #=> Fiddle::TYPE_INT
- #
- # parse_ctype('double')
- # #=> Fiddle::TYPE_DOUBLE
- #
- # parse_ctype('unsigned char')
- # #=> -Fiddle::TYPE_CHAR
- #
- def parse_ctype(ty, tymap=nil)
- tymap ||= {}
- case ty
- when Array
- return [parse_ctype(ty[0], tymap), ty[1]]
- when "void"
- return TYPE_VOID
- when "char"
- return TYPE_CHAR
- when "unsigned char"
- return -TYPE_CHAR
- when "short"
- return TYPE_SHORT
- when "unsigned short"
- return -TYPE_SHORT
- when "int"
- return TYPE_INT
- when "unsigned int", 'uint'
- return -TYPE_INT
- when "long"
- return TYPE_LONG
- when "unsigned long"
- return -TYPE_LONG
- when "long long"
- if( defined?(TYPE_LONG_LONG) )
- return TYPE_LONG_LONG
- else
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- when "unsigned long long"
- if( defined?(TYPE_LONG_LONG) )
- return -TYPE_LONG_LONG
- else
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- when "float"
- return TYPE_FLOAT
- when "double"
- return TYPE_DOUBLE
- when "size_t"
- return TYPE_SIZE_T
- when "ssize_t"
- return TYPE_SSIZE_T
- when "ptrdiff_t"
- return TYPE_PTRDIFF_T
- when "intptr_t"
- return TYPE_INTPTR_T
- when "uintptr_t"
- return TYPE_UINTPTR_T
- when /\*/, /\[\s*\]/
- return TYPE_VOIDP
- else
- if( tymap[ty] )
- return parse_ctype(tymap[ty], tymap)
- else
- raise(DLError, "unknown type: #{ty}")
- end
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/fiddle/function.rb b/src/main/resources/stdlib/fiddle/function.rb
deleted file mode 100644
index ab7496e..0000000
--- a/src/main/resources/stdlib/fiddle/function.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-module Fiddle
- class Function
- # The ABI of the Function.
- attr_reader :abi
-
- # The address of this function
- attr_reader :ptr
-
- # The name of this function
- attr_reader :name
-
- # The integer memory location of this function
- def to_i
- ptr.to_i
- end
- end
-end
diff --git a/src/main/resources/stdlib/fiddle/import.rb b/src/main/resources/stdlib/fiddle/import.rb
deleted file mode 100644
index 34f5d7f..0000000
--- a/src/main/resources/stdlib/fiddle/import.rb
+++ /dev/null
@@ -1,314 +0,0 @@
-require 'fiddle'
-require 'fiddle/struct'
-require 'fiddle/cparser'
-
-module Fiddle
-
- # Used internally by Fiddle::Importer
- class CompositeHandler
- # Create a new handler with the open +handlers+
- #
- # Used internally by Fiddle::Importer.dlload
- def initialize(handlers)
- @handlers = handlers
- end
-
- # Array of the currently loaded libraries.
- def handlers()
- @handlers
- end
-
- # Returns the address as an Integer from any handlers with the function
- # named +symbol+.
- #
- # Raises a DLError if the handle is closed.
- def sym(symbol)
- @handlers.each{|handle|
- if( handle )
- begin
- addr = handle.sym(symbol)
- return addr
- rescue DLError
- end
- end
- }
- return nil
- end
-
- # See Fiddle::CompositeHandler.sym
- def [](symbol)
- sym(symbol)
- end
- end
-
- # A DSL that provides the means to dynamically load libraries and build
- # modules around them including calling extern functions within the C
- # library that has been loaded.
- #
- # == Example
- #
- # require 'fiddle'
- # require 'fiddle/import'
- #
- # module LibSum
- # extend Fiddle::Importer
- # dlload './libsum.so'
- # extern 'double sum(double*, int)'
- # extern 'double split(double)'
- # end
- #
- module Importer
- include Fiddle
- include CParser
- extend Importer
-
- # Creates an array of handlers for the given +libs+, can be an instance of
- # Fiddle::Handle, Fiddle::Importer, or will create a new instance of
- # Fiddle::Handle using Fiddle.dlopen
- #
- # Raises a DLError if the library cannot be loaded.
- #
- # See Fiddle.dlopen
- def dlload(*libs)
- handles = libs.collect{|lib|
- case lib
- when nil
- nil
- when Handle
- lib
- when Importer
- lib.handlers
- else
- begin
- Fiddle.dlopen(lib)
- rescue DLError
- raise(DLError, "can't load #{lib}")
- end
- end
- }.flatten()
- @handler = CompositeHandler.new(handles)
- @func_map = {}
- @type_alias = {}
- end
-
- # Sets the type alias for +alias_type+ as +orig_type+
- def typealias(alias_type, orig_type)
- @type_alias[alias_type] = orig_type
- end
-
- # Returns the sizeof +ty+, using Fiddle::Importer.parse_ctype to determine
- # the C type and the appropriate Fiddle constant.
- def sizeof(ty)
- case ty
- when String
- ty = parse_ctype(ty, @type_alias).abs()
- case ty
- when TYPE_CHAR
- return SIZEOF_CHAR
- when TYPE_SHORT
- return SIZEOF_SHORT
- when TYPE_INT
- return SIZEOF_INT
- when TYPE_LONG
- return SIZEOF_LONG
- when TYPE_LONG_LONG
- return SIZEOF_LONG_LONG
- when TYPE_FLOAT
- return SIZEOF_FLOAT
- when TYPE_DOUBLE
- return SIZEOF_DOUBLE
- when TYPE_VOIDP
- return SIZEOF_VOIDP
- else
- raise(DLError, "unknown type: #{ty}")
- end
- when Class
- if( ty.instance_methods().include?(:to_ptr) )
- return ty.size()
- end
- end
- return Pointer[ty].size()
- end
-
- def parse_bind_options(opts)
- h = {}
- while( opt = opts.shift() )
- case opt
- when :stdcall, :cdecl
- h[:call_type] = opt
- when :carried, :temp, :temporal, :bind
- h[:callback_type] = opt
- h[:carrier] = opts.shift()
- else
- h[opt] = true
- end
- end
- h
- end
- private :parse_bind_options
-
- # :stopdoc:
- CALL_TYPE_TO_ABI = Hash.new { |h, k|
- raise RuntimeError, "unsupported call type: #{k}"
- }.merge({ :stdcall => (Function::STDCALL rescue Function::DEFAULT),
- :cdecl => Function::DEFAULT,
- nil => Function::DEFAULT
- }).freeze
- private_constant :CALL_TYPE_TO_ABI
- # :startdoc:
-
- # Creates a global method from the given C +signature+.
- def extern(signature, *opts)
- symname, ctype, argtype = parse_signature(signature, @type_alias)
- opt = parse_bind_options(opts)
- f = import_function(symname, ctype, argtype, opt[:call_type])
- name = symname.gsub(/@.+/,'')
- @func_map[name] = f
- # define_method(name){|*args,&block| f.call(*args,&block)}
- begin
- /^(.+?):(\d+)/ =~ caller.first
- file, line = $1, $2.to_i
- rescue
- file, line = __FILE__, __LINE__+3
- end
- module_eval(<<-EOS, file, line)
- def #{name}(*args, &block)
- @func_map['#{name}'].call(*args,&block)
- end
- EOS
- module_function(name)
- f
- end
-
- # Creates a global method from the given C +signature+ using the given
- # +opts+ as bind parameters with the given block.
- def bind(signature, *opts, &blk)
- name, ctype, argtype = parse_signature(signature, @type_alias)
- h = parse_bind_options(opts)
- case h[:callback_type]
- when :bind, nil
- f = bind_function(name, ctype, argtype, h[:call_type], &blk)
- else
- raise(RuntimeError, "unknown callback type: #{h[:callback_type]}")
- end
- @func_map[name] = f
- #define_method(name){|*args,&block| f.call(*args,&block)}
- begin
- /^(.+?):(\d+)/ =~ caller.first
- file, line = $1, $2.to_i
- rescue
- file, line = __FILE__, __LINE__+3
- end
- module_eval(<<-EOS, file, line)
- def #{name}(*args,&block)
- @func_map['#{name}'].call(*args,&block)
- end
- EOS
- module_function(name)
- f
- end
-
- # Creates a class to wrap the C struct described by +signature+.
- #
- # MyStruct = struct ['int i', 'char c']
- def struct(signature)
- tys, mems = parse_struct_signature(signature, @type_alias)
- Fiddle::CStructBuilder.create(CStruct, tys, mems)
- end
-
- # Creates a class to wrap the C union described by +signature+.
- #
- # MyUnion = union ['int i', 'char c']
- def union(signature)
- tys, mems = parse_struct_signature(signature, @type_alias)
- Fiddle::CStructBuilder.create(CUnion, tys, mems)
- end
-
- # Returns the function mapped to +name+, that was created by either
- # Fiddle::Importer.extern or Fiddle::Importer.bind
- def [](name)
- @func_map[name]
- end
-
- # Creates a class to wrap the C struct with the value +ty+
- #
- # See also Fiddle::Importer.struct
- def create_value(ty, val=nil)
- s = struct([ty + " value"])
- ptr = s.malloc()
- if( val )
- ptr.value = val
- end
- return ptr
- end
- alias value create_value
-
- # Returns a new instance of the C struct with the value +ty+ at the +addr+
- # address.
- def import_value(ty, addr)
- s = struct([ty + " value"])
- ptr = s.new(addr)
- return ptr
- end
-
-
- # The Fiddle::CompositeHandler instance
- #
- # Will raise an error if no handlers are open.
- def handler
- @handler or raise "call dlload before importing symbols and functions"
- end
-
- # Returns a new Fiddle::Pointer instance at the memory address of the given
- # +name+ symbol.
- #
- # Raises a DLError if the +name+ doesn't exist.
- #
- # See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym
- def import_symbol(name)
- addr = handler.sym(name)
- if( !addr )
- raise(DLError, "cannot find the symbol: #{name}")
- end
- Pointer.new(addr)
- end
-
- # Returns a new Fiddle::Function instance at the memory address of the given
- # +name+ function.
- #
- # Raises a DLError if the +name+ doesn't exist.
- #
- # * +argtype+ is an Array of arguments, passed to the +name+ function.
- # * +ctype+ is the return type of the function
- # * +call_type+ is the ABI of the function
- #
- # See also Fiddle:Function.new
- #
- # See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym
- def import_function(name, ctype, argtype, call_type = nil)
- addr = handler.sym(name)
- if( !addr )
- raise(DLError, "cannot find the function: #{name}()")
- end
- Function.new(addr, argtype, ctype, CALL_TYPE_TO_ABI[call_type],
- name: name)
- end
-
- # Returns a new closure wrapper for the +name+ function.
- #
- # * +ctype+ is the return type of the function
- # * +argtype+ is an Array of arguments, passed to the callback function
- # * +call_type+ is the abi of the closure
- # * +block+ is passed to the callback
- #
- # See Fiddle::Closure
- def bind_function(name, ctype, argtype, call_type = nil, &block)
- abi = CALL_TYPE_TO_ABI[call_type]
- closure = Class.new(Fiddle::Closure) {
- define_method(:call, block)
- }.new(ctype, argtype, abi)
-
- Function.new(closure, argtype, ctype, abi, name: name)
- end
- end
-end
diff --git a/src/main/resources/stdlib/fiddle/jruby.rb b/src/main/resources/stdlib/fiddle/jruby.rb
deleted file mode 100644
index 88a5fde..0000000
--- a/src/main/resources/stdlib/fiddle/jruby.rb
+++ /dev/null
@@ -1,306 +0,0 @@
-require 'ffi'
-
-module Fiddle
- TYPE_VOID = 0
- TYPE_VOIDP = 1
- TYPE_CHAR = 2
- TYPE_SHORT = 3
- TYPE_INT = 4
- TYPE_LONG = 5
- TYPE_LONG_LONG = 6
- TYPE_FLOAT = 7
- TYPE_DOUBLE = 8
-
- WINDOWS = FFI::Platform.windows?
-
- module JRuby
- FFITypes = {
- 'c' => FFI::Type::INT8,
- 'h' => FFI::Type::INT16,
- 'i' => FFI::Type::INT32,
- 'l' => FFI::Type::LONG,
- 'f' => FFI::Type::FLOAT32,
- 'd' => FFI::Type::FLOAT64,
- 'p' => FFI::Type::POINTER,
- 's' => FFI::Type::STRING,
-
- TYPE_VOID => FFI::Type::Builtin::VOID,
- TYPE_VOIDP => FFI::Type::Builtin::POINTER,
- TYPE_CHAR => FFI::Type::Builtin::CHAR,
- TYPE_SHORT => FFI::Type::Builtin::SHORT,
- TYPE_INT => FFI::Type::Builtin::INT,
- TYPE_LONG => FFI::Type::Builtin::LONG,
- TYPE_LONG_LONG => FFI::Type::Builtin::LONG_LONG,
- TYPE_FLOAT => FFI::Type::Builtin::FLOAT,
- TYPE_DOUBLE => FFI::Type::Builtin::DOUBLE,
- }
-
- def self.__ffi_type__(dl_type)
- ffi_type = FFITypes[dl_type]
- ffi_type = FFITypes[-dl_type] if ffi_type.nil? && dl_type.is_a?(Integer) && dl_type < 0
- raise TypeError.new("cannot convert #{dl_type} to ffi") unless ffi_type
- ffi_type
- end
- end
-
- class Function
- DEFAULT = "default"
- STDCALL = "stdcall"
-
- def initialize(ptr, args, return_type, abi = DEFAULT, kwargs = nil)
- if kwargs.nil?
- if abi.kind_of? Hash
- kwargs = abi
- abi = DEFAULT
- end
- end
- @ptr, @args, @return_type, @abi = ptr, args, return_type, abi
- raise TypeError.new "invalid return type" unless return_type.is_a?(Integer)
- raise TypeError.new "invalid return type" unless args.is_a?(Array)
-
- @function = FFI::Function.new(
- Fiddle::JRuby::__ffi_type__(@return_type),
- @args.map { |t| Fiddle::JRuby.__ffi_type__(t) },
- FFI::Pointer.new(ptr.to_i),
- :convention => @abi
- )
- @function.attach(self, "call")
- end
-
- # stubbed; should be overwritten by initialize's #attach call above
- def call(*args); end
- end
-
- class Closure
- def initialize(ret, args, abi = Function::DEFAULT)
- @ctype, @args = ret, args
- raise TypeError.new "invalid return type" unless ret.is_a?(Integer)
- raise TypeError.new "invalid return type" unless args.is_a?(Array)
-
- @function = FFI::Function.new(
- __ffi_type__(@ctype),
- @args.map { |t| Fiddle::JRuby.__ffi_type__(t) },
- self,
- :convention => abi
- )
- end
-
- def to_i
- @function.to_i
- end
- end
-
- class DLError < StandardError; end
-
- class Pointer
- attr_reader :ffi_ptr
- extend FFI::DataConverter
- native_type FFI::Type::Builtin::POINTER
-
- def self.to_native(value, ctx)
- if value.is_a?(Pointer)
- value.ffi_ptr
-
- elsif value.is_a?(Integer)
- FFI::Pointer.new(value)
-
- elsif value.is_a?(String)
- value
- end
- end
-
- def self.from_native(value, ctx)
- self.new(value)
- end
-
- def self.to_ptr(value)
- if value.is_a?(String)
- cptr = Pointer.malloc(value.bytesize + 1)
- size = value.bytesize + 1
- cptr.ffi_ptr.put_string(0, value)
- cptr
-
- elsif value.respond_to?(:to_ptr)
- ptr = value.to_ptr
- ptr.is_a?(Pointer) ? ptr : Pointer.new(ptr)
-
- else
- Pointer.new(value)
- end
- end
-
- class << self
- alias [] to_ptr
- end
-
- def initialize(addr, size = nil, free = nil)
- ptr = if addr.is_a?(FFI::Pointer)
- addr
-
- elsif addr.is_a?(Integer)
- FFI::Pointer.new(addr)
- end
-
- @size = size ? size : ptr.size
- @free = free
- @ffi_ptr = free.nil? ? ptr : FFI::AutoPointer.new(ptr, self.class.__freefunc__(free))
- end
-
- def self.__freefunc__(free)
- if free.is_a?(FFI::Function)
- free
-
- elsif free.is_a?(FFI::Pointer)
- free.null? ? Proc.new { |ptr| } : FFI::Function.new(:void, [ :pointer ], free)
-
- elsif free.is_a?(Integer)
- free == 0 ? Proc.new { |ptr| } : FFI::Function.new(:void, [ :pointer ], FFI::Pointer.new(free))
-
- elsif free.respond_to?(:call)
- free
-
- else
- raise ArgumentError.new("invalid free func")
- end
- end
-
- def self.malloc(size, free = nil)
- self.new(LibC.malloc(size), size, free ? free : LibC::FREE)
- end
-
- def null?
- @ffi_ptr.null?
- end
-
- def to_ptr
- @ffi_ptr
- end
-
- def size
- defined?(@layout) ? @layout.size : @size
- end
-
- def size=(size)
- @size = size
- end
-
- def [](index, length = nil)
- if length
- ffi_ptr.get_string(index, length)
- else
- ffi_ptr.get_int(index)
- end
- end
-
- def to_i
- ffi_ptr.to_i
- end
- alias to_int to_i
-
- def to_str(len = nil)
- if len
- ffi_ptr.get_string(0, len)
- else
- ffi_ptr.get_string(0)
- end
- end
- alias to_s to_str
-
- def inspect
- "#<#{self.class.name} ptr=#{ffi_ptr.address.to_s(16)} size=#{@size} free=#{@free.inspect}>"
- end
-
- def +(delta)
- self.class.new(ffi_ptr + delta, @size - delta)
- end
-
- def -(delta)
- self.class.new(ffi_ptr - delta, @size + delta)
- end
-
- def ptr
- Pointer.new(ffi_ptr.get_pointer(0))
- end
-
- def ref
- cptr = Pointer.malloc(FFI::Type::POINTER.size)
- cptr.ffi_ptr.put_pointer(0, ffi_ptr)
- cptr
- end
- end
-
- class Handle
- RTLD_GLOBAL = FFI::DynamicLibrary::RTLD_GLOBAL
- RTLD_LAZY = FFI::DynamicLibrary::RTLD_LAZY
- RTLD_NOW = FFI::DynamicLibrary::RTLD_NOW
-
- def initialize(libname = nil, flags = RTLD_LAZY | RTLD_GLOBAL)
- @lib = FFI::DynamicLibrary.open(libname, flags)
- raise RuntimeError, "Could not open #{libname}" unless @lib
-
- @open = true
-
- begin
- yield(self)
- ensure
- self.close
- end if block_given?
- end
-
- def close
- raise DLError.new("closed handle") unless @open
- @open = false
- 0
- end
-
- def self.sym(func)
- DEFAULT.sym(func)
- end
-
- def sym(func)
- raise TypeError.new("invalid function name") unless func.is_a?(String)
- raise DLError.new("closed handle") unless @open
- address = @lib.find_function(func)
- raise DLError.new("unknown symbol #{func}") if address.nil? || address.null?
- address.to_i
- end
-
- def self.[](func)
- self.sym(func)
- end
-
- def [](func)
- sym(func)
- end
-
- def enable_close
- @enable_close = true
- end
-
- def close_enabled?
- @enable_close
- end
-
- def disable_close
- @enable_close = false
- end
- end
-
- ALIGN_VOIDP = Fiddle::JRuby::FFITypes[TYPE_VOIDP].alignment
- ALIGN_CHAR = Fiddle::JRuby::FFITypes[TYPE_CHAR].alignment
- ALIGN_SHORT = Fiddle::JRuby::FFITypes[TYPE_SHORT].alignment
- ALIGN_INT = Fiddle::JRuby::FFITypes[TYPE_INT].alignment
- ALIGN_LONG = Fiddle::JRuby::FFITypes[TYPE_LONG].alignment
- ALIGN_LONG_LONG = Fiddle::JRuby::FFITypes[TYPE_LONG_LONG].alignment
- ALIGN_FLOAT = Fiddle::JRuby::FFITypes[TYPE_FLOAT].alignment
- ALIGN_DOUBLE = Fiddle::JRuby::FFITypes[TYPE_DOUBLE].alignment
-
- SIZEOF_VOIDP = Fiddle::JRuby::FFITypes[TYPE_VOIDP].size
- SIZEOF_CHAR = Fiddle::JRuby::FFITypes[TYPE_CHAR].size
- SIZEOF_SHORT = Fiddle::JRuby::FFITypes[TYPE_SHORT].size
- SIZEOF_INT = Fiddle::JRuby::FFITypes[TYPE_INT].size
- SIZEOF_LONG = Fiddle::JRuby::FFITypes[TYPE_LONG].size
- SIZEOF_LONG_LONG = Fiddle::JRuby::FFITypes[TYPE_LONG_LONG].size
- SIZEOF_FLOAT = Fiddle::JRuby::FFITypes[TYPE_FLOAT].size
- SIZEOF_DOUBLE = Fiddle::JRuby::FFITypes[TYPE_DOUBLE].size
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/fiddle/pack.rb b/src/main/resources/stdlib/fiddle/pack.rb
deleted file mode 100644
index e4e9542..0000000
--- a/src/main/resources/stdlib/fiddle/pack.rb
+++ /dev/null
@@ -1,128 +0,0 @@
-require 'fiddle'
-
-module Fiddle
- module PackInfo # :nodoc: all
- ALIGN_MAP = {
- TYPE_VOIDP => ALIGN_VOIDP,
- TYPE_CHAR => ALIGN_CHAR,
- TYPE_SHORT => ALIGN_SHORT,
- TYPE_INT => ALIGN_INT,
- TYPE_LONG => ALIGN_LONG,
- TYPE_FLOAT => ALIGN_FLOAT,
- TYPE_DOUBLE => ALIGN_DOUBLE,
- -TYPE_CHAR => ALIGN_CHAR,
- -TYPE_SHORT => ALIGN_SHORT,
- -TYPE_INT => ALIGN_INT,
- -TYPE_LONG => ALIGN_LONG,
- }
-
- PACK_MAP = {
- TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG) ? "q" : "l!"),
- TYPE_CHAR => "c",
- TYPE_SHORT => "s!",
- TYPE_INT => "i!",
- TYPE_LONG => "l!",
- TYPE_FLOAT => "f",
- TYPE_DOUBLE => "d",
- -TYPE_CHAR => "c",
- -TYPE_SHORT => "s!",
- -TYPE_INT => "i!",
- -TYPE_LONG => "l!",
- }
-
- SIZE_MAP = {
- TYPE_VOIDP => SIZEOF_VOIDP,
- TYPE_CHAR => SIZEOF_CHAR,
- TYPE_SHORT => SIZEOF_SHORT,
- TYPE_INT => SIZEOF_INT,
- TYPE_LONG => SIZEOF_LONG,
- TYPE_FLOAT => SIZEOF_FLOAT,
- TYPE_DOUBLE => SIZEOF_DOUBLE,
- -TYPE_CHAR => SIZEOF_CHAR,
- -TYPE_SHORT => SIZEOF_SHORT,
- -TYPE_INT => SIZEOF_INT,
- -TYPE_LONG => SIZEOF_LONG,
- }
- if defined?(TYPE_LONG_LONG)
- ALIGN_MAP[TYPE_LONG_LONG] = ALIGN_MAP[-TYPE_LONG_LONG] = ALIGN_LONG_LONG
- PACK_MAP[TYPE_LONG_LONG] = PACK_MAP[-TYPE_LONG_LONG] = "q"
- SIZE_MAP[TYPE_LONG_LONG] = SIZE_MAP[-TYPE_LONG_LONG] = SIZEOF_LONG_LONG
- end
-
- def align(addr, align)
- d = addr % align
- if( d == 0 )
- addr
- else
- addr + (align - d)
- end
- end
- module_function :align
- end
-
- class Packer # :nodoc: all
- include PackInfo
-
- def self.[](*types)
- new(types)
- end
-
- def initialize(types)
- parse_types(types)
- end
-
- def size()
- @size
- end
-
- def pack(ary)
- case SIZEOF_VOIDP
- when SIZEOF_LONG
- ary.pack(@template)
- when SIZEOF_LONG_LONG
- ary.pack(@template)
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
-
- def unpack(ary)
- case SIZEOF_VOIDP
- when SIZEOF_LONG
- ary.join().unpack(@template)
- when SIZEOF_LONG_LONG
- ary.join().unpack(@template)
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
-
- private
-
- def parse_types(types)
- @template = ""
- addr = 0
- types.each{|t|
- orig_addr = addr
- if( t.is_a?(Array) )
- addr = align(orig_addr, ALIGN_MAP[TYPE_VOIDP])
- else
- addr = align(orig_addr, ALIGN_MAP[t])
- end
- d = addr - orig_addr
- if( d > 0 )
- @template << "x#{d}"
- end
- if( t.is_a?(Array) )
- @template << (PACK_MAP[t[0]] * t[1])
- addr += (SIZE_MAP[t[0]] * t[1])
- else
- @template << PACK_MAP[t]
- addr += SIZE_MAP[t]
- end
- }
- addr = align(addr, ALIGN_MAP[TYPE_VOIDP])
- @size = addr
- end
- end
-end
diff --git a/src/main/resources/stdlib/fiddle/struct.rb b/src/main/resources/stdlib/fiddle/struct.rb
deleted file mode 100644
index 695a4d2..0000000
--- a/src/main/resources/stdlib/fiddle/struct.rb
+++ /dev/null
@@ -1,243 +0,0 @@
-require 'fiddle'
-require 'fiddle/value'
-require 'fiddle/pack'
-
-module Fiddle
- # C struct shell
- class CStruct
- # accessor to Fiddle::CStructEntity
- def CStruct.entity_class
- CStructEntity
- end
- end
-
- # C union shell
- class CUnion
- # accessor to Fiddle::CUnionEntity
- def CUnion.entity_class
- CUnionEntity
- end
- end
-
- # Used to construct C classes (CUnion, CStruct, etc)
- #
- # Fiddle::Importer#struct and Fiddle::Importer#union wrap this functionality in an
- # easy-to-use manner.
- module CStructBuilder
- # Construct a new class given a C:
- # * class +klass+ (CUnion, CStruct, or other that provide an
- # #entity_class)
- # * +types+ (Fiddle::TYPE_INT, Fiddle::TYPE_SIZE_T, etc., see the C types
- # constants)
- # * corresponding +members+
- #
- # Fiddle::Importer#struct and Fiddle::Importer#union wrap this functionality in an
- # easy-to-use manner.
- #
- # Example:
- #
- # require 'fiddle/struct'
- # require 'fiddle/cparser'
- #
- # include Fiddle::CParser
- #
- # types, members = parse_struct_signature(['int i','char c'])
- #
- # MyStruct = Fiddle::CStructBuilder.create(Fiddle::CUnion, types, members)
- #
- # obj = MyStruct.allocate
- #
- def create(klass, types, members)
- new_class = Class.new(klass){
- define_method(:initialize){|addr|
- @entity = klass.entity_class.new(addr, types)
- @entity.assign_names(members)
- }
- define_method(:to_ptr){ @entity }
- define_method(:to_i){ @entity.to_i }
- members.each{|name|
- define_method(name){ @entity[name] }
- define_method(name + "="){|val| @entity[name] = val }
- }
- }
- size = klass.entity_class.size(types)
- new_class.module_eval(<<-EOS, __FILE__, __LINE__+1)
- def new_class.size()
- #{size}
- end
- def new_class.malloc()
- addr = Fiddle.malloc(#{size})
- new(addr)
- end
- EOS
- return new_class
- end
- module_function :create
- end
-
- # A C struct wrapper
- class CStructEntity < Fiddle::Pointer
- include PackInfo
- include ValueUtil
-
- # Allocates a C struct with the +types+ provided.
- #
- # When the instance is garbage collected, the C function +func+ is called.
- def CStructEntity.malloc(types, func = nil)
- addr = Fiddle.malloc(CStructEntity.size(types))
- CStructEntity.new(addr, types, func)
- end
-
- # Returns the offset for the packed sizes for the given +types+.
- #
- # Fiddle::CStructEntity.size(
- # [ Fiddle::TYPE_DOUBLE,
- # Fiddle::TYPE_INT,
- # Fiddle::TYPE_CHAR,
- # Fiddle::TYPE_VOIDP ]) #=> 24
- def CStructEntity.size(types)
- offset = 0
-
- max_align = types.map { |type, count = 1|
- last_offset = offset
-
- align = PackInfo::ALIGN_MAP[type]
- offset = PackInfo.align(last_offset, align) +
- (PackInfo::SIZE_MAP[type] * count)
-
- align
- }.max
-
- PackInfo.align(offset, max_align)
- end
-
- # Wraps the C pointer +addr+ as a C struct with the given +types+.
- #
- # When the instance is garbage collected, the C function +func+ is called.
- #
- # See also Fiddle::Pointer.new
- def initialize(addr, types, func = nil)
- set_ctypes(types)
- super(addr, @size, func)
- end
-
- # Set the names of the +members+ in this C struct
- def assign_names(members)
- @members = members
- end
-
- # Calculates the offsets and sizes for the given +types+ in the struct.
- def set_ctypes(types)
- @ctypes = types
- @offset = []
- offset = 0
-
- max_align = types.map { |type, count = 1|
- orig_offset = offset
- align = ALIGN_MAP[type]
- offset = PackInfo.align(orig_offset, align)
-
- @offset << offset
-
- offset += (SIZE_MAP[type] * count)
-
- align
- }.max
-
- @size = PackInfo.align(offset, max_align)
- end
-
- # Fetch struct member +name+
- def [](name)
- idx = @members.index(name)
- if( idx.nil? )
- raise(ArgumentError, "no such member: #{name}")
- end
- ty = @ctypes[idx]
- if( ty.is_a?(Array) )
- r = super(@offset[idx], SIZE_MAP[ty[0]] * ty[1])
- else
- r = super(@offset[idx], SIZE_MAP[ty.abs])
- end
- packer = Packer.new([ty])
- val = packer.unpack([r])
- case ty
- when Array
- case ty[0]
- when TYPE_VOIDP
- val = val.collect{|v| Pointer.new(v)}
- end
- when TYPE_VOIDP
- val = Pointer.new(val[0])
- else
- val = val[0]
- end
- if( ty.is_a?(Integer) && (ty < 0) )
- return unsigned_value(val, ty)
- elsif( ty.is_a?(Array) && (ty[0] < 0) )
- return val.collect{|v| unsigned_value(v,ty[0])}
- else
- return val
- end
- end
-
- # Set struct member +name+, to value +val+
- def []=(name, val)
- idx = @members.index(name)
- if( idx.nil? )
- raise(ArgumentError, "no such member: #{name}")
- end
- ty = @ctypes[idx]
- packer = Packer.new([ty])
- val = wrap_arg(val, ty, [])
- buff = packer.pack([val].flatten())
- super(@offset[idx], buff.size, buff)
- if( ty.is_a?(Integer) && (ty < 0) )
- return unsigned_value(val, ty)
- elsif( ty.is_a?(Array) && (ty[0] < 0) )
- return val.collect{|v| unsigned_value(v,ty[0])}
- else
- return val
- end
- end
-
- def to_s() # :nodoc:
- super(@size)
- end
- end
-
- # A C union wrapper
- class CUnionEntity < CStructEntity
- include PackInfo
-
- # Allocates a C union the +types+ provided.
- #
- # When the instance is garbage collected, the C function +func+ is called.
- def CUnionEntity.malloc(types, func=nil)
- addr = Fiddle.malloc(CUnionEntity.size(types))
- CUnionEntity.new(addr, types, func)
- end
-
- # Returns the size needed for the union with the given +types+.
- #
- # Fiddle::CUnionEntity.size(
- # [ Fiddle::TYPE_DOUBLE,
- # Fiddle::TYPE_INT,
- # Fiddle::TYPE_CHAR,
- # Fiddle::TYPE_VOIDP ]) #=> 8
- def CUnionEntity.size(types)
- types.map { |type, count = 1|
- PackInfo::SIZE_MAP[type] * count
- }.max
- end
-
- # Calculate the necessary offset and for each union member with the given
- # +types+
- def set_ctypes(types)
- @ctypes = types
- @offset = Array.new(types.length, 0)
- @size = self.class.size types
- end
- end
-end
-
diff --git a/src/main/resources/stdlib/fiddle/types.rb b/src/main/resources/stdlib/fiddle/types.rb
deleted file mode 100644
index 02c1d25..0000000
--- a/src/main/resources/stdlib/fiddle/types.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-module Fiddle
- # Adds Windows type aliases to the including class for use with
- # Fiddle::Importer.
- #
- # The aliases added are:
- # * ATOM
- # * BOOL
- # * BYTE
- # * DWORD
- # * DWORD32
- # * DWORD64
- # * HANDLE
- # * HDC
- # * HINSTANCE
- # * HWND
- # * LPCSTR
- # * LPSTR
- # * PBYTE
- # * PDWORD
- # * PHANDLE
- # * PVOID
- # * PWORD
- # * UCHAR
- # * UINT
- # * ULONG
- # * WORD
- module Win32Types
- def included(m) # :nodoc:
- m.module_eval{
- typealias "DWORD", "unsigned long"
- typealias "PDWORD", "unsigned long *"
- typealias "DWORD32", "unsigned long"
- typealias "DWORD64", "unsigned long long"
- typealias "WORD", "unsigned short"
- typealias "PWORD", "unsigned short *"
- typealias "BOOL", "int"
- typealias "ATOM", "int"
- typealias "BYTE", "unsigned char"
- typealias "PBYTE", "unsigned char *"
- typealias "UINT", "unsigned int"
- typealias "ULONG", "unsigned long"
- typealias "UCHAR", "unsigned char"
- typealias "HANDLE", "uintptr_t"
- typealias "PHANDLE", "void*"
- typealias "PVOID", "void*"
- typealias "LPCSTR", "char*"
- typealias "LPSTR", "char*"
- typealias "HINSTANCE", "unsigned int"
- typealias "HDC", "unsigned int"
- typealias "HWND", "unsigned int"
- }
- end
- module_function :included
- end
-
- # Adds basic type aliases to the including class for use with Fiddle::Importer.
- #
- # The aliases added are +uint+ and +u_int+ (unsigned int) and
- # +ulong+ and +u_long+ (unsigned long)
- module BasicTypes
- def included(m) # :nodoc:
- m.module_eval{
- typealias "uint", "unsigned int"
- typealias "u_int", "unsigned int"
- typealias "ulong", "unsigned long"
- typealias "u_long", "unsigned long"
- }
- end
- module_function :included
- end
-end
diff --git a/src/main/resources/stdlib/fiddle/value.rb b/src/main/resources/stdlib/fiddle/value.rb
deleted file mode 100644
index 8d71e47..0000000
--- a/src/main/resources/stdlib/fiddle/value.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-require 'fiddle'
-
-module Fiddle
- module ValueUtil #:nodoc: all
- def unsigned_value(val, ty)
- case ty.abs
- when TYPE_CHAR
- [val].pack("c").unpack("C")[0]
- when TYPE_SHORT
- [val].pack("s!").unpack("S!")[0]
- when TYPE_INT
- [val].pack("i!").unpack("I!")[0]
- when TYPE_LONG
- [val].pack("l!").unpack("L!")[0]
- when TYPE_LONG_LONG
- [val].pack("q").unpack("Q")[0]
- else
- val
- end
- end
-
- def signed_value(val, ty)
- case ty.abs
- when TYPE_CHAR
- [val].pack("C").unpack("c")[0]
- when TYPE_SHORT
- [val].pack("S!").unpack("s!")[0]
- when TYPE_INT
- [val].pack("I!").unpack("i!")[0]
- when TYPE_LONG
- [val].pack("L!").unpack("l!")[0]
- when TYPE_LONG_LONG
- [val].pack("Q").unpack("q")[0]
- else
- val
- end
- end
-
- def wrap_args(args, tys, funcs, &block)
- result = []
- tys ||= []
- args.each_with_index{|arg, idx|
- result.push(wrap_arg(arg, tys[idx], funcs, &block))
- }
- result
- end
-
- def wrap_arg(arg, ty, funcs = [], &block)
- funcs ||= []
- case arg
- when nil
- return 0
- when Pointer
- return arg.to_i
- when IO
- case ty
- when TYPE_VOIDP
- return Pointer[arg].to_i
- else
- return arg.to_i
- end
- when Function
- if( block )
- arg.bind_at_call(&block)
- funcs.push(arg)
- elsif !arg.bound?
- raise(RuntimeError, "block must be given.")
- end
- return arg.to_i
- when String
- if( ty.is_a?(Array) )
- return arg.unpack('C*')
- else
- case SIZEOF_VOIDP
- when SIZEOF_LONG
- return [arg].pack("p").unpack("l!")[0]
- when SIZEOF_LONG_LONG
- return [arg].pack("p").unpack("q")[0]
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
- when Float, Integer
- return arg
- when Array
- if( ty.is_a?(Array) ) # used only by struct
- case ty[0]
- when TYPE_VOIDP
- return arg.collect{|v| Integer(v)}
- when TYPE_CHAR
- if( arg.is_a?(String) )
- return val.unpack('C*')
- end
- end
- return arg
- else
- return arg
- end
- else
- if( arg.respond_to?(:to_ptr) )
- return arg.to_ptr.to_i
- else
- begin
- return Integer(arg)
- rescue
- raise(ArgumentError, "unknown argument type: #{arg.class}")
- end
- end
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/fileutils.rb b/src/main/resources/stdlib/fileutils.rb
deleted file mode 100644
index 18f24a2..0000000
--- a/src/main/resources/stdlib/fileutils.rb
+++ /dev/null
@@ -1,1771 +0,0 @@
-#
-# = fileutils.rb
-#
-# Copyright (c) 2000-2007 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-#
-# == module FileUtils
-#
-# Namespace for several file utility methods for copying, moving, removing, etc.
-#
-# === Module Functions
-#
-# require 'fileutils'
-#
-# FileUtils.cd(dir, options)
-# FileUtils.cd(dir, options) {|dir| .... }
-# FileUtils.pwd()
-# FileUtils.mkdir(dir, options)
-# FileUtils.mkdir(list, options)
-# FileUtils.mkdir_p(dir, options)
-# FileUtils.mkdir_p(list, options)
-# FileUtils.rmdir(dir, options)
-# FileUtils.rmdir(list, options)
-# FileUtils.ln(old, new, options)
-# FileUtils.ln(list, destdir, options)
-# FileUtils.ln_s(old, new, options)
-# FileUtils.ln_s(list, destdir, options)
-# FileUtils.ln_sf(src, dest, options)
-# FileUtils.cp(src, dest, options)
-# FileUtils.cp(list, dir, options)
-# FileUtils.cp_r(src, dest, options)
-# FileUtils.cp_r(list, dir, options)
-# FileUtils.mv(src, dest, options)
-# FileUtils.mv(list, dir, options)
-# FileUtils.rm(list, options)
-# FileUtils.rm_r(list, options)
-# FileUtils.rm_rf(list, options)
-# FileUtils.install(src, dest, mode = , options)
-# FileUtils.chmod(mode, list, options)
-# FileUtils.chmod_R(mode, list, options)
-# FileUtils.chown(user, group, list, options)
-# FileUtils.chown_R(user, group, list, options)
-# FileUtils.touch(list, options)
-#
-# The options parameter is a hash of options, taken from the list
-# :force, :noop, :preserve, and :verbose.
-# :noop means that no changes are made. The other two are obvious.
-# Each method documents the options that it honours.
-#
-# All methods that have the concept of a "source" file or directory can take
-# either one file or a list of files in that argument. See the method
-# documentation for examples.
-#
-# There are some `low level' methods, which do not accept any option:
-#
-# FileUtils.copy_entry(src, dest, preserve = false, dereference = false)
-# FileUtils.copy_file(src, dest, preserve = false, dereference = true)
-# FileUtils.copy_stream(srcstream, deststream)
-# FileUtils.remove_entry(path, force = false)
-# FileUtils.remove_entry_secure(path, force = false)
-# FileUtils.remove_file(path, force = false)
-# FileUtils.compare_file(path_a, path_b)
-# FileUtils.compare_stream(stream_a, stream_b)
-# FileUtils.uptodate?(file, cmp_list)
-#
-# == module FileUtils::Verbose
-#
-# This module has all methods of FileUtils module, but it outputs messages
-# before acting. This equates to passing the :verbose flag to methods
-# in FileUtils.
-#
-# == module FileUtils::NoWrite
-#
-# This module has all methods of FileUtils module, but never changes
-# files/directories. This equates to passing the :noop flag to methods
-# in FileUtils.
-#
-# == module FileUtils::DryRun
-#
-# This module has all methods of FileUtils module, but never changes
-# files/directories. This equates to passing the :noop and
-# :verbose flags to methods in FileUtils.
-#
-
-module FileUtils
-
- def self.private_module_function(name) #:nodoc:
- module_function name
- private_class_method name
- end
-
- # This hash table holds command options.
- OPT_TABLE = {} #:nodoc: internal use only
-
- #
- # Options: (none)
- #
- # Returns the name of the current directory.
- #
- def pwd
- Dir.pwd
- end
- module_function :pwd
-
- alias getwd pwd
- module_function :getwd
-
- #
- # Options: verbose
- #
- # Changes the current directory to the directory +dir+.
- #
- # If this method is called with block, resumes to the old
- # working directory after the block execution finished.
- #
- # FileUtils.cd('/', :verbose => true) # chdir and report it
- #
- # FileUtils.cd('/') do # chdir
- # [...] # do something
- # end # return to original directory
- #
- def cd(dir, options = {}, &block) # :yield: dir
- fu_check_options options, OPT_TABLE['cd']
- fu_output_message "cd #{dir}" if options[:verbose]
- Dir.chdir(dir, &block)
- fu_output_message 'cd -' if options[:verbose] and block
- end
- module_function :cd
-
- alias chdir cd
- module_function :chdir
-
- OPT_TABLE['cd'] =
- OPT_TABLE['chdir'] = [:verbose]
-
- #
- # Options: (none)
- #
- # Returns true if +new+ is newer than all +old_list+.
- # Non-existent files are older than any file.
- #
- # FileUtils.uptodate?('hello.o', %w(hello.c hello.h)) or \
- # system 'make hello.o'
- #
- def uptodate?(new, old_list)
- return false unless File.exist?(new)
- new_time = File.mtime(new)
- old_list.each do |old|
- if File.exist?(old)
- return false unless new_time > File.mtime(old)
- end
- end
- true
- end
- module_function :uptodate?
-
- def remove_tailing_slash(dir)
- dir == '/' ? dir : dir.chomp(?/)
- end
- private_module_function :remove_tailing_slash
-
- #
- # Options: mode noop verbose
- #
- # Creates one or more directories.
- #
- # FileUtils.mkdir 'test'
- # FileUtils.mkdir %w( tmp data )
- # FileUtils.mkdir 'notexist', :noop => true # Does not really create.
- # FileUtils.mkdir 'tmp', :mode => 0700
- #
- def mkdir(list, options = {})
- fu_check_options options, OPT_TABLE['mkdir']
- list = fu_list(list)
- fu_output_message "mkdir #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose]
- return if options[:noop]
-
- list.each do |dir|
- fu_mkdir dir, options[:mode]
- end
- end
- module_function :mkdir
-
- OPT_TABLE['mkdir'] = [:mode, :noop, :verbose]
-
- #
- # Options: mode noop verbose
- #
- # Creates a directory and all its parent directories.
- # For example,
- #
- # FileUtils.mkdir_p '/usr/local/lib/ruby'
- #
- # causes to make following directories, if it does not exist.
- # * /usr
- # * /usr/local
- # * /usr/local/lib
- # * /usr/local/lib/ruby
- #
- # You can pass several directories at a time in a list.
- #
- def mkdir_p(list, options = {})
- fu_check_options options, OPT_TABLE['mkdir_p']
- list = fu_list(list)
- fu_output_message "mkdir -p #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose]
- return *list if options[:noop]
-
- list.map {|path| remove_tailing_slash(path)}.each do |path|
- # optimize for the most common case
- begin
- fu_mkdir path, options[:mode]
- next
- rescue SystemCallError
- next if File.directory?(path)
- end
-
- stack = []
- until path == stack.last # dirname("/")=="/", dirname("C:/")=="C:/"
- stack.push path
- path = File.dirname(path)
- end
- stack.reverse_each do |dir|
- begin
- fu_mkdir dir, options[:mode]
- rescue SystemCallError
- raise unless File.directory?(dir)
- end
- end
- end
-
- return *list
- end
- module_function :mkdir_p
-
- alias mkpath mkdir_p
- alias makedirs mkdir_p
- module_function :mkpath
- module_function :makedirs
-
- OPT_TABLE['mkdir_p'] =
- OPT_TABLE['mkpath'] =
- OPT_TABLE['makedirs'] = [:mode, :noop, :verbose]
-
- def fu_mkdir(path, mode) #:nodoc:
- path = remove_tailing_slash(path)
- if mode
- Dir.mkdir path, mode
- File.chmod mode, path
- else
- Dir.mkdir path
- end
- end
- private_module_function :fu_mkdir
-
- #
- # Options: parents, noop, verbose
- #
- # Removes one or more directories.
- #
- # FileUtils.rmdir 'somedir'
- # FileUtils.rmdir %w(somedir anydir otherdir)
- # # Does not really remove directory; outputs message.
- # FileUtils.rmdir 'somedir', :verbose => true, :noop => true
- #
- def rmdir(list, options = {})
- fu_check_options options, OPT_TABLE['rmdir']
- list = fu_list(list)
- parents = options[:parents]
- fu_output_message "rmdir #{parents ? '-p ' : ''}#{list.join ' '}" if options[:verbose]
- return if options[:noop]
- list.each do |dir|
- begin
- Dir.rmdir(dir = remove_tailing_slash(dir))
- if parents
- until (parent = File.dirname(dir)) == '.' or parent == dir
- dir = parent
- Dir.rmdir(dir)
- end
- end
- rescue Errno::ENOTEMPTY, Errno::EEXIST, Errno::ENOENT
- end
- end
- end
- module_function :rmdir
-
- OPT_TABLE['rmdir'] = [:parents, :noop, :verbose]
-
- #
- # Options: force noop verbose
- #
- # ln(old, new, options = {})
- #
- # Creates a hard link +new+ which points to +old+.
- # If +new+ already exists and it is a directory, creates a link +new/old+.
- # If +new+ already exists and it is not a directory, raises Errno::EEXIST.
- # But if :force option is set, overwrite +new+.
- #
- # FileUtils.ln 'gcc', 'cc', :verbose => true
- # FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
- #
- # ln(list, destdir, options = {})
- #
- # Creates several hard links in a directory, with each one pointing to the
- # item in +list+. If +destdir+ is not a directory, raises Errno::ENOTDIR.
- #
- # include FileUtils
- # cd '/sbin'
- # FileUtils.ln %w(cp mv mkdir), '/bin' # Now /sbin/cp and /bin/cp are linked.
- #
- def ln(src, dest, options = {})
- fu_check_options options, OPT_TABLE['ln']
- fu_output_message "ln#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
- return if options[:noop]
- fu_each_src_dest0(src, dest) do |s,d|
- remove_file d, true if options[:force]
- File.link s, d
- end
- end
- module_function :ln
-
- alias link ln
- module_function :link
-
- OPT_TABLE['ln'] =
- OPT_TABLE['link'] = [:force, :noop, :verbose]
-
- #
- # Options: force noop verbose
- #
- # ln_s(old, new, options = {})
- #
- # Creates a symbolic link +new+ which points to +old+. If +new+ already
- # exists and it is a directory, creates a symbolic link +new/old+. If +new+
- # already exists and it is not a directory, raises Errno::EEXIST. But if
- # :force option is set, overwrite +new+.
- #
- # FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
- # FileUtils.ln_s 'verylongsourcefilename.c', 'c', :force => true
- #
- # ln_s(list, destdir, options = {})
- #
- # Creates several symbolic links in a directory, with each one pointing to the
- # item in +list+. If +destdir+ is not a directory, raises Errno::ENOTDIR.
- #
- # If +destdir+ is not a directory, raises Errno::ENOTDIR.
- #
- # FileUtils.ln_s Dir.glob('bin/*.rb'), '/home/aamine/bin'
- #
- def ln_s(src, dest, options = {})
- fu_check_options options, OPT_TABLE['ln_s']
- fu_output_message "ln -s#{options[:force] ? 'f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
- return if options[:noop]
- fu_each_src_dest0(src, dest) do |s,d|
- remove_file d, true if options[:force]
- File.symlink s, d
- end
- end
- module_function :ln_s
-
- alias symlink ln_s
- module_function :symlink
-
- OPT_TABLE['ln_s'] =
- OPT_TABLE['symlink'] = [:force, :noop, :verbose]
-
- #
- # Options: noop verbose
- #
- # Same as
- # #ln_s(src, dest, :force => true)
- #
- def ln_sf(src, dest, options = {})
- fu_check_options options, OPT_TABLE['ln_sf']
- options = options.dup
- options[:force] = true
- ln_s src, dest, options
- end
- module_function :ln_sf
-
- OPT_TABLE['ln_sf'] = [:noop, :verbose]
-
- #
- # Options: preserve noop verbose
- #
- # Copies a file content +src+ to +dest+. If +dest+ is a directory,
- # copies +src+ to +dest/src+.
- #
- # If +src+ is a list of files, then +dest+ must be a directory.
- #
- # FileUtils.cp 'eval.c', 'eval.c.org'
- # FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
- # FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :verbose => true
- # FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
- #
- def cp(src, dest, options = {})
- fu_check_options options, OPT_TABLE['cp']
- fu_output_message "cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
- return if options[:noop]
- fu_each_src_dest(src, dest) do |s, d|
- copy_file s, d, options[:preserve]
- end
- end
- module_function :cp
-
- alias copy cp
- module_function :copy
-
- OPT_TABLE['cp'] =
- OPT_TABLE['copy'] = [:preserve, :noop, :verbose]
-
- #
- # Options: preserve noop verbose dereference_root remove_destination
- #
- # Copies +src+ to +dest+. If +src+ is a directory, this method copies
- # all its contents recursively. If +dest+ is a directory, copies
- # +src+ to +dest/src+.
- #
- # +src+ can be a list of files.
- #
- # # Installing Ruby library "mylib" under the site_ruby
- # FileUtils.rm_r site_ruby + '/mylib', :force
- # FileUtils.cp_r 'lib/', site_ruby + '/mylib'
- #
- # # Examples of copying several files to target directory.
- # FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
- # FileUtils.cp_r Dir.glob('*.rb'), '/home/aamine/lib/ruby', :noop => true, :verbose => true
- #
- # # If you want to copy all contents of a directory instead of the
- # # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
- # # use following code.
- # FileUtils.cp_r 'src/.', 'dest' # cp_r('src', 'dest') makes dest/src,
- # # but this doesn't.
- #
- def cp_r(src, dest, options = {})
- fu_check_options options, OPT_TABLE['cp_r']
- fu_output_message "cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
- return if options[:noop]
- options = options.dup
- options[:dereference_root] = true unless options.key?(:dereference_root)
- fu_each_src_dest(src, dest) do |s, d|
- copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]
- end
- end
- module_function :cp_r
-
- OPT_TABLE['cp_r'] = [:preserve, :noop, :verbose,
- :dereference_root, :remove_destination]
-
- #
- # Copies a file system entry +src+ to +dest+.
- # If +src+ is a directory, this method copies its contents recursively.
- # This method preserves file types, c.f. symlink, directory...
- # (FIFO, device files and etc. are not supported yet)
- #
- # Both of +src+ and +dest+ must be a path name.
- # +src+ must exist, +dest+ must not exist.
- #
- # If +preserve+ is true, this method preserves owner, group, and
- # modified time. Permissions are copied regardless +preserve+.
- #
- # If +dereference_root+ is true, this method dereference tree root.
- #
- # If +remove_destination+ is true, this method removes each destination file before copy.
- #
- def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
- Entry_.new(src, nil, dereference_root).wrap_traverse(proc do |ent|
- destent = Entry_.new(dest, ent.rel, false)
- File.unlink destent.path if remove_destination && File.file?(destent.path)
- ent.copy destent.path
- end, proc do |ent|
- destent = Entry_.new(dest, ent.rel, false)
- ent.copy_metadata destent.path if preserve
- end)
- end
- module_function :copy_entry
-
- #
- # Copies file contents of +src+ to +dest+.
- # Both of +src+ and +dest+ must be a path name.
- #
- def copy_file(src, dest, preserve = false, dereference = true)
- ent = Entry_.new(src, nil, dereference)
- ent.copy_file dest
- ent.copy_metadata dest if preserve
- end
- module_function :copy_file
-
- #
- # Copies stream +src+ to +dest+.
- # +src+ must respond to #read(n) and
- # +dest+ must respond to #write(str).
- #
- def copy_stream(src, dest)
- IO.copy_stream(src, dest)
- end
- module_function :copy_stream
-
- #
- # Options: force noop verbose
- #
- # Moves file(s) +src+ to +dest+. If +file+ and +dest+ exist on the different
- # disk partition, the file is copied then the original file is removed.
- #
- # FileUtils.mv 'badname.rb', 'goodname.rb'
- # FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :force => true # no error
- #
- # FileUtils.mv %w(junk.txt dust.txt), '/home/aamine/.trash/'
- # FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose => true
- #
- def mv(src, dest, options = {})
- fu_check_options options, OPT_TABLE['mv']
- fu_output_message "mv#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
- return if options[:noop]
- fu_each_src_dest(src, dest) do |s, d|
- destent = Entry_.new(d, nil, true)
- begin
- if destent.exist?
- if destent.directory?
- raise Errno::EEXIST, dest
- else
- destent.remove_file if rename_cannot_overwrite_file?
- end
- end
- begin
- File.rename s, d
- rescue *MV_RESCUES
- copy_entry s, d, true
- if options[:secure]
- remove_entry_secure s, options[:force]
- else
- remove_entry s, options[:force]
- end
- end
- rescue SystemCallError
- raise unless options[:force]
- end
- end
- end
- module_function :mv
-
- # JRuby raises EACCES because JDK reports errors differently
- MV_RESCUES = begin
- if RUBY_ENGINE == 'jruby'
- [Errno::EXDEV, Errno::EACCES]
- else
- [Errno::EXDEV]
- end
- end
-
- alias move mv
- module_function :move
-
- OPT_TABLE['mv'] =
- OPT_TABLE['move'] = [:force, :noop, :verbose, :secure]
-
- def rename_cannot_overwrite_file? #:nodoc:
- /cygwin|mswin|mingw|bccwin|emx/ =~ RUBY_PLATFORM
- end
- private_module_function :rename_cannot_overwrite_file?
-
- #
- # Options: force noop verbose
- #
- # Remove file(s) specified in +list+. This method cannot remove directories.
- # All StandardErrors are ignored when the :force option is set.
- #
- # FileUtils.rm %w( junk.txt dust.txt )
- # FileUtils.rm Dir.glob('*.so')
- # FileUtils.rm 'NotExistFile', :force => true # never raises exception
- #
- def rm(list, options = {})
- fu_check_options options, OPT_TABLE['rm']
- list = fu_list(list)
- fu_output_message "rm#{options[:force] ? ' -f' : ''} #{list.join ' '}" if options[:verbose]
- return if options[:noop]
-
- list.each do |path|
- remove_file path, options[:force]
- end
- end
- module_function :rm
-
- alias remove rm
- module_function :remove
-
- OPT_TABLE['rm'] =
- OPT_TABLE['remove'] = [:force, :noop, :verbose]
-
- #
- # Options: noop verbose
- #
- # Equivalent to
- #
- # #rm(list, :force => true)
- #
- def rm_f(list, options = {})
- fu_check_options options, OPT_TABLE['rm_f']
- options = options.dup
- options[:force] = true
- rm list, options
- end
- module_function :rm_f
-
- alias safe_unlink rm_f
- module_function :safe_unlink
-
- OPT_TABLE['rm_f'] =
- OPT_TABLE['safe_unlink'] = [:noop, :verbose]
-
- #
- # Options: force noop verbose secure
- #
- # remove files +list+[0] +list+[1]... If +list+[n] is a directory,
- # removes its all contents recursively. This method ignores
- # StandardError when :force option is set.
- #
- # FileUtils.rm_r Dir.glob('/tmp/*')
- # FileUtils.rm_r '/', :force => true # :-)
- #
- # WARNING: This method causes local vulnerability
- # if one of parent directories or removing directory tree are world
- # writable (including /tmp, whose permission is 1777), and the current
- # process has strong privilege such as Unix super user (root), and the
- # system has symbolic link. For secure removing, read the documentation
- # of #remove_entry_secure carefully, and set :secure option to true.
- # Default is :secure=>false.
- #
- # NOTE: This method calls #remove_entry_secure if :secure option is set.
- # See also #remove_entry_secure.
- #
- def rm_r(list, options = {})
- fu_check_options options, OPT_TABLE['rm_r']
- # options[:secure] = true unless options.key?(:secure)
- list = fu_list(list)
- fu_output_message "rm -r#{options[:force] ? 'f' : ''} #{list.join ' '}" if options[:verbose]
- return if options[:noop]
- list.each do |path|
- if options[:secure]
- remove_entry_secure path, options[:force]
- else
- remove_entry path, options[:force]
- end
- end
- end
- module_function :rm_r
-
- OPT_TABLE['rm_r'] = [:force, :noop, :verbose, :secure]
-
- #
- # Options: noop verbose secure
- #
- # Equivalent to
- #
- # #rm_r(list, :force => true)
- #
- # WARNING: This method causes local vulnerability.
- # Read the documentation of #rm_r first.
- #
- def rm_rf(list, options = {})
- fu_check_options options, OPT_TABLE['rm_rf']
- options = options.dup
- options[:force] = true
- rm_r list, options
- end
- module_function :rm_rf
-
- alias rmtree rm_rf
- module_function :rmtree
-
- OPT_TABLE['rm_rf'] =
- OPT_TABLE['rmtree'] = [:noop, :verbose, :secure]
-
- #
- # This method removes a file system entry +path+. +path+ shall be a
- # regular file, a directory, or something. If +path+ is a directory,
- # remove it recursively. This method is required to avoid TOCTTOU
- # (time-of-check-to-time-of-use) local security vulnerability of #rm_r.
- # #rm_r causes security hole when:
- #
- # * Parent directory is world writable (including /tmp).
- # * Removing directory tree includes world writable directory.
- # * The system has symbolic link.
- #
- # To avoid this security hole, this method applies special preprocess.
- # If +path+ is a directory, this method chown(2) and chmod(2) all
- # removing directories. This requires the current process is the
- # owner of the removing whole directory tree, or is the super user (root).
- #
- # WARNING: You must ensure that *ALL* parent directories cannot be
- # moved by other untrusted users. For example, parent directories
- # should not be owned by untrusted users, and should not be world
- # writable except when the sticky bit set.
- #
- # WARNING: Only the owner of the removing directory tree, or Unix super
- # user (root) should invoke this method. Otherwise this method does not
- # work.
- #
- # For details of this security vulnerability, see Perl's case:
- #
- # http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448
- # http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
- #
- # For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
- #
- def remove_entry_secure(path, force = false)
- unless fu_have_symlink?
- remove_entry path, force
- return
- end
- fullpath = File.expand_path(path)
- st = File.lstat(fullpath)
- unless st.directory?
- File.unlink fullpath
- return
- end
- # is a directory.
- parent_st = File.stat(File.dirname(fullpath))
- unless parent_st.world_writable?
- remove_entry path, force
- return
- end
- unless parent_st.sticky?
- raise ArgumentError, "parent directory is world writable, FileUtils#remove_entry_secure does not work; abort: #{path.inspect} (parent directory mode #{'%o' % parent_st.mode})"
- end
- # freeze tree root
- euid = Process.euid
- dot_file = fullpath + "/."
- File.lstat(dot_file).tap {|fstat|
- unless fu_stat_identical_entry?(st, fstat)
- # symlink (TOC-to-TOU attack?)
- File.unlink fullpath
- return
- end
- File.chown euid, -1, dot_file
- File.chmod 0700, dot_file
- unless fu_stat_identical_entry?(st, File.lstat(fullpath))
- # TOC-to-TOU attack?
- File.unlink fullpath
- return
- end
- }
- # ---- tree root is frozen ----
- root = Entry_.new(path)
- root.preorder_traverse do |ent|
- if ent.directory?
- ent.chown euid, -1
- ent.chmod 0700
- end
- end
- root.postorder_traverse do |ent|
- begin
- ent.remove
- rescue
- raise unless force
- end
- end
- rescue
- raise unless force
- end
- module_function :remove_entry_secure
-
- def fu_have_symlink? #:nodoc:
- File.symlink nil, nil
- rescue NotImplementedError
- return false
- rescue TypeError
- return true
- end
- private_module_function :fu_have_symlink?
-
- def fu_stat_identical_entry?(a, b) #:nodoc:
- a.dev == b.dev and a.ino == b.ino
- end
- private_module_function :fu_stat_identical_entry?
-
- #
- # This method removes a file system entry +path+.
- # +path+ might be a regular file, a directory, or something.
- # If +path+ is a directory, remove it recursively.
- #
- # See also #remove_entry_secure.
- #
- def remove_entry(path, force = false)
- Entry_.new(path).postorder_traverse do |ent|
- begin
- ent.remove
- rescue
- raise unless force
- end
- end
- rescue
- raise unless force
- end
- module_function :remove_entry
-
- #
- # Removes a file +path+.
- # This method ignores StandardError if +force+ is true.
- #
- def remove_file(path, force = false)
- Entry_.new(path).remove_file
- rescue
- raise unless force
- end
- module_function :remove_file
-
- #
- # Removes a directory +dir+ and its contents recursively.
- # This method ignores StandardError if +force+ is true.
- #
- def remove_dir(path, force = false)
- remove_entry path, force # FIXME?? check if it is a directory
- end
- module_function :remove_dir
-
- #
- # Returns true if the contents of a file A and a file B are identical.
- #
- # FileUtils.compare_file('somefile', 'somefile') #=> true
- # FileUtils.compare_file('/bin/cp', '/bin/mv') #=> maybe false
- #
- def compare_file(a, b)
- return false unless File.size(a) == File.size(b)
- File.open(a, 'rb') {|fa|
- File.open(b, 'rb') {|fb|
- return compare_stream(fa, fb)
- }
- }
- end
- module_function :compare_file
-
- alias identical? compare_file
- alias cmp compare_file
- module_function :identical?
- module_function :cmp
-
- #
- # Returns true if the contents of a stream +a+ and +b+ are identical.
- #
- def compare_stream(a, b)
- bsize = fu_stream_blksize(a, b)
- sa = ""
- sb = ""
- begin
- a.read(bsize, sa)
- b.read(bsize, sb)
- return true if sa.empty? && sb.empty?
- end while sa == sb
- false
- end
- module_function :compare_stream
-
- #
- # Options: mode preserve noop verbose
- #
- # If +src+ is not same as +dest+, copies it and changes the permission
- # mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+.
- # This method removes destination before copy.
- #
- # FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true
- # FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
- #
- def install(src, dest, options = {})
- fu_check_options options, OPT_TABLE['install']
- fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
- return if options[:noop]
- fu_each_src_dest(src, dest) do |s, d|
- st = File.stat(s)
- unless File.exist?(d) and compare_file(s, d)
- remove_file d, true
- copy_file s, d
- File.utime st.atime, st.mtime, d if options[:preserve]
- File.chmod options[:mode], d if options[:mode]
- end
- end
- end
- module_function :install
-
- OPT_TABLE['install'] = [:mode, :preserve, :noop, :verbose]
-
- def user_mask(target) #:nodoc:
- target.each_char.inject(0) do |mask, chr|
- case chr
- when "u"
- mask | 04700
- when "g"
- mask | 02070
- when "o"
- mask | 01007
- when "a"
- mask | 07777
- else
- raise ArgumentError, "invalid `who' symbol in file mode: #{chr}"
- end
- end
- end
- private_module_function :user_mask
-
- def apply_mask(mode, user_mask, op, mode_mask)
- case op
- when '='
- (mode & ~user_mask) | (user_mask & mode_mask)
- when '+'
- mode | (user_mask & mode_mask)
- when '-'
- mode & ~(user_mask & mode_mask)
- end
- end
- private_module_function :apply_mask
-
- def symbolic_modes_to_i(mode_sym, path) #:nodoc:
- mode_sym.split(/,/).inject(File.stat(path).mode & 07777) do |current_mode, clause|
- target, *actions = clause.split(/([=+-])/)
- raise ArgumentError, "invalid file mode: #{mode_sym}" if actions.empty?
- target = 'a' if target.empty?
- user_mask = user_mask(target)
- actions.each_slice(2) do |op, perm|
- need_apply = op == '='
- mode_mask = (perm || '').each_char.inject(0) do |mask, chr|
- case chr
- when "r"
- mask | 0444
- when "w"
- mask | 0222
- when "x"
- mask | 0111
- when "X"
- if FileTest.directory? path
- mask | 0111
- else
- mask
- end
- when "s"
- mask | 06000
- when "t"
- mask | 01000
- when "u", "g", "o"
- if mask.nonzero?
- current_mode = apply_mask(current_mode, user_mask, op, mask)
- end
- need_apply = false
- copy_mask = user_mask(chr)
- (current_mode & copy_mask) / (copy_mask & 0111) * (user_mask & 0111)
- else
- raise ArgumentError, "invalid `perm' symbol in file mode: #{chr}"
- end
- end
-
- if mode_mask.nonzero? || need_apply
- current_mode = apply_mask(current_mode, user_mask, op, mode_mask)
- end
- end
- current_mode
- end
- end
- private_module_function :symbolic_modes_to_i
-
- def fu_mode(mode, path) #:nodoc:
- mode.is_a?(String) ? symbolic_modes_to_i(mode, path) : mode
- end
- private_module_function :fu_mode
-
- def mode_to_s(mode) #:nodoc:
- mode.is_a?(String) ? mode : "%o" % mode
- end
- private_module_function :mode_to_s
-
- #
- # Options: noop verbose
- #
- # Changes permission bits on the named files (in +list+) to the bit pattern
- # represented by +mode+.
- #
- # +mode+ is the symbolic and absolute mode can be used.
- #
- # Absolute mode is
- # FileUtils.chmod 0755, 'somecommand'
- # FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
- # FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
- #
- # Symbolic mode is
- # FileUtils.chmod "u=wrx,go=rx", 'somecommand'
- # FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
- # FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', :verbose => true
- #
- # "a" :: is user, group, other mask.
- # "u" :: is user's mask.
- # "g" :: is group's mask.
- # "o" :: is other's mask.
- # "w" :: is write permission.
- # "r" :: is read permission.
- # "x" :: is execute permission.
- # "X" ::
- # is execute permission for directories only, must be used in conjunction with "+"
- # "s" :: is uid, gid.
- # "t" :: is sticky bit.
- # "+" :: is added to a class given the specified mode.
- # "-" :: Is removed from a given class given mode.
- # "=" :: Is the exact nature of the class will be given a specified mode.
-
- def chmod(mode, list, options = {})
- fu_check_options options, OPT_TABLE['chmod']
- list = fu_list(list)
- fu_output_message sprintf('chmod %s %s', mode_to_s(mode), list.join(' ')) if options[:verbose]
- return if options[:noop]
- list.each do |path|
- Entry_.new(path).chmod(fu_mode(mode, path))
- end
- end
- module_function :chmod
-
- OPT_TABLE['chmod'] = [:noop, :verbose]
-
- #
- # Options: noop verbose force
- #
- # Changes permission bits on the named files (in +list+)
- # to the bit pattern represented by +mode+.
- #
- # FileUtils.chmod_R 0700, "/tmp/app.#{$$}"
- # FileUtils.chmod_R "u=wrx", "/tmp/app.#{$$}"
- #
- def chmod_R(mode, list, options = {})
- fu_check_options options, OPT_TABLE['chmod_R']
- list = fu_list(list)
- fu_output_message sprintf('chmod -R%s %s %s',
- (options[:force] ? 'f' : ''),
- mode_to_s(mode), list.join(' ')) if options[:verbose]
- return if options[:noop]
- list.each do |root|
- Entry_.new(root).traverse do |ent|
- begin
- ent.chmod(fu_mode(mode, ent.path))
- rescue
- raise unless options[:force]
- end
- end
- end
- end
- module_function :chmod_R
-
- OPT_TABLE['chmod_R'] = [:noop, :verbose, :force]
-
- #
- # Options: noop verbose
- #
- # Changes owner and group on the named files (in +list+)
- # to the user +user+ and the group +group+. +user+ and +group+
- # may be an ID (Integer/String) or a name (String).
- # If +user+ or +group+ is nil, this method does not change
- # the attribute.
- #
- # FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
- # FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :verbose => true
- #
- def chown(user, group, list, options = {})
- fu_check_options options, OPT_TABLE['chown']
- list = fu_list(list)
- fu_output_message sprintf('chown %s %s',
- (group ? "#{user}:#{group}" : user || ':'),
- list.join(' ')) if options[:verbose]
- return if options[:noop]
- uid = fu_get_uid(user)
- gid = fu_get_gid(group)
- list.each do |path|
- Entry_.new(path).chown uid, gid
- end
- end
- module_function :chown
-
- OPT_TABLE['chown'] = [:noop, :verbose]
-
- #
- # Options: noop verbose force
- #
- # Changes owner and group on the named files (in +list+)
- # to the user +user+ and the group +group+ recursively.
- # +user+ and +group+ may be an ID (Integer/String) or
- # a name (String). If +user+ or +group+ is nil, this
- # method does not change the attribute.
- #
- # FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
- # FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', :verbose => true
- #
- def chown_R(user, group, list, options = {})
- fu_check_options options, OPT_TABLE['chown_R']
- list = fu_list(list)
- fu_output_message sprintf('chown -R%s %s %s',
- (options[:force] ? 'f' : ''),
- (group ? "#{user}:#{group}" : user || ':'),
- list.join(' ')) if options[:verbose]
- return if options[:noop]
- uid = fu_get_uid(user)
- gid = fu_get_gid(group)
- list.each do |root|
- Entry_.new(root).traverse do |ent|
- begin
- ent.chown uid, gid
- rescue
- raise unless options[:force]
- end
- end
- end
- end
- module_function :chown_R
-
- OPT_TABLE['chown_R'] = [:noop, :verbose, :force]
-
- begin
- require 'etc'
- rescue LoadError # rescue LoadError for miniruby
- end
-
- def fu_get_uid(user) #:nodoc:
- return nil unless user
- case user
- when Integer
- user
- when /\A\d+\z/
- user.to_i
- else
- Etc.getpwnam(user) ? Etc.getpwnam(user).uid : nil
- end
- end
- private_module_function :fu_get_uid
-
- def fu_get_gid(group) #:nodoc:
- return nil unless group
- case group
- when Integer
- group
- when /\A\d+\z/
- group.to_i
- else
- Etc.getgrnam(group) ? Etc.getgrnam(group).gid : nil
- end
- end
- private_module_function :fu_get_gid
-
- #
- # Options: noop verbose mtime nocreate
- #
- # Updates modification time (mtime) and access time (atime) of file(s) in
- # +list+. Files are created if they don't exist.
- #
- # FileUtils.touch 'timestamp'
- # FileUtils.touch Dir.glob('*.c'); system 'make'
- #
- def touch(list, options = {})
- fu_check_options options, OPT_TABLE['touch']
- list = fu_list(list)
- nocreate = options[:nocreate]
- t = options[:mtime]
- if options[:verbose]
- fu_output_message "touch #{nocreate ? '-c ' : ''}#{t ? t.strftime('-t %Y%m%d%H%M.%S ') : ''}#{list.join ' '}"
- end
- return if options[:noop]
- list.each do |path|
- created = nocreate
- begin
- File.utime(t, t, path)
- rescue Errno::ENOENT
- raise if created
- File.open(path, 'a') {
- ;
- }
- created = true
- retry if t
- end
- end
- end
- module_function :touch
-
- OPT_TABLE['touch'] = [:noop, :verbose, :mtime, :nocreate]
-
- private
-
- module StreamUtils_
- private
-
- def fu_windows?
- /mswin|mingw|bccwin|emx/ =~ RUBY_PLATFORM
- end
-
- def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
- IO.copy_stream(src, dest)
- end
-
- def fu_stream_blksize(*streams)
- streams.each do |s|
- next unless s.respond_to?(:stat)
- size = fu_blksize(s.stat)
- return size if size
- end
- fu_default_blksize()
- end
-
- def fu_blksize(st)
- s = st.blksize
- return nil unless s
- return nil if s == 0
- s
- end
-
- def fu_default_blksize
- 1024
- end
- end
-
- include StreamUtils_
- extend StreamUtils_
-
- class Entry_ #:nodoc: internal use only
- include StreamUtils_
-
- def initialize(a, b = nil, deref = false)
- @prefix = @rel = @path = nil
- if b
- @prefix = a
- @rel = b
- else
- @path = a
- end
- @deref = deref
- @stat = nil
- @lstat = nil
- end
-
- def inspect
- "\#<#{self.class} #{path()}>"
- end
-
- def path
- if @path
- File.path(@path)
- else
- join(@prefix, @rel)
- end
- end
-
- def prefix
- @prefix || @path
- end
-
- def rel
- @rel
- end
-
- def dereference?
- @deref
- end
-
- def exist?
- begin
- lstat
- true
- rescue Errno::ENOENT
- false
- end
- end
-
- def file?
- s = lstat!
- s and s.file?
- end
-
- def directory?
- s = lstat!
- s and s.directory?
- end
-
- def symlink?
- s = lstat!
- s and s.symlink?
- end
-
- def chardev?
- s = lstat!
- s and s.chardev?
- end
-
- def blockdev?
- s = lstat!
- s and s.blockdev?
- end
-
- def socket?
- s = lstat!
- s and s.socket?
- end
-
- def pipe?
- s = lstat!
- s and s.pipe?
- end
-
- S_IF_DOOR = 0xD000
-
- def door?
- s = lstat!
- s and (s.mode & 0xF000 == S_IF_DOOR)
- end
-
- def entries
- opts = {}
- opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
- Dir.entries(path(), opts)\
- .reject {|n| n == '.' or n == '..' }\
- .map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }
- end
-
- def stat
- return @stat if @stat
- if lstat() and lstat().symlink?
- @stat = File.stat(path())
- else
- @stat = lstat()
- end
- @stat
- end
-
- def stat!
- return @stat if @stat
- if lstat! and lstat!.symlink?
- @stat = File.stat(path())
- else
- @stat = lstat!
- end
- @stat
- rescue SystemCallError
- nil
- end
-
- def lstat
- if dereference?
- @lstat ||= File.stat(path())
- else
- @lstat ||= File.lstat(path())
- end
- end
-
- def lstat!
- lstat()
- rescue SystemCallError
- nil
- end
-
- def chmod(mode)
- if symlink?
- File.lchmod mode, path() if have_lchmod?
- else
- File.chmod mode, path()
- end
- end
-
- def chown(uid, gid)
- if symlink?
- File.lchown uid, gid, path() if have_lchown?
- else
- File.chown uid, gid, path()
- end
- end
-
- def copy(dest)
- case
- when file?
- copy_file dest
- when directory?
- if !File.exist?(dest) and descendant_directory?(dest, path)
- raise ArgumentError, "cannot copy directory %s to itself %s" % [path, dest]
- end
- begin
- Dir.mkdir dest
- rescue
- raise unless File.directory?(dest)
- end
- when symlink?
- File.symlink File.readlink(path()), dest
- when chardev?
- raise "cannot handle device file" unless File.respond_to?(:mknod)
- mknod dest, ?c, 0666, lstat().rdev
- when blockdev?
- raise "cannot handle device file" unless File.respond_to?(:mknod)
- mknod dest, ?b, 0666, lstat().rdev
- when socket?
- raise "cannot handle socket" unless File.respond_to?(:mknod)
- mknod dest, nil, lstat().mode, 0
- when pipe?
- raise "cannot handle FIFO" unless File.respond_to?(:mkfifo)
- mkfifo dest, 0666
- when door?
- raise "cannot handle door: #{path()}"
- else
- raise "unknown file type: #{path()}"
- end
- end
-
- def copy_file(dest)
- File.open(path()) do |s|
- File.open(dest, 'wb', s.stat.mode) do |f|
- IO.copy_stream(s, f)
- end
- end
- end
-
- def copy_metadata(path)
- st = lstat()
- if !st.symlink?
- File.utime st.atime, st.mtime, path
- end
- begin
- if st.symlink?
- begin
- File.lchown st.uid, st.gid, path
- rescue NotImplementedError
- end
- else
- File.chown st.uid, st.gid, path
- end
- rescue Errno::EPERM
- # clear setuid/setgid
- if st.symlink?
- begin
- File.lchmod st.mode & 01777, path
- rescue NotImplementedError
- end
- else
- File.chmod st.mode & 01777, path
- end
- else
- if st.symlink?
- begin
- File.lchmod st.mode, path
- rescue NotImplementedError
- end
- else
- File.chmod st.mode, path
- end
- end
- end
-
- def remove
- if directory?
- remove_dir1
- else
- remove_file
- end
- end
-
- def remove_dir1
- platform_support {
- Dir.rmdir path().chomp(?/)
- }
- end
-
- def remove_file
- platform_support {
- File.unlink path
- }
- end
-
- def platform_support
- return yield unless fu_windows?
- first_time_p = true
- begin
- yield
- rescue Errno::ENOENT
- raise
- rescue => err
- if first_time_p
- first_time_p = false
- begin
- File.chmod 0700, path() # Windows does not have symlink
- retry
- rescue SystemCallError
- end
- end
- raise err
- end
- end
-
- def preorder_traverse
- stack = [self]
- while ent = stack.pop
- yield ent
- stack.concat ent.entries.reverse if ent.directory?
- end
- end
-
- alias traverse preorder_traverse
-
- def postorder_traverse
- if directory?
- entries().each do |ent|
- ent.postorder_traverse do |e|
- yield e
- end
- end
- end
- ensure
- yield self
- end
-
- def wrap_traverse(pre, post)
- pre.call self
- if directory?
- entries.each do |ent|
- ent.wrap_traverse pre, post
- end
- end
- post.call self
- end
-
- private
-
- $fileutils_rb_have_lchmod = nil
-
- def have_lchmod?
- # This is not MT-safe, but it does not matter.
- if $fileutils_rb_have_lchmod == nil
- $fileutils_rb_have_lchmod = check_have_lchmod?
- end
- $fileutils_rb_have_lchmod
- end
-
- def check_have_lchmod?
- return false unless File.respond_to?(:lchmod)
- File.lchmod 0
- return true
- rescue NotImplementedError
- return false
- end
-
- $fileutils_rb_have_lchown = nil
-
- def have_lchown?
- # This is not MT-safe, but it does not matter.
- if $fileutils_rb_have_lchown == nil
- $fileutils_rb_have_lchown = check_have_lchown?
- end
- $fileutils_rb_have_lchown
- end
-
- def check_have_lchown?
- return false unless File.respond_to?(:lchown)
- File.lchown nil, nil
- return true
- rescue NotImplementedError
- return false
- end
-
- def join(dir, base)
- return File.path(dir) if not base or base == '.'
- return File.path(base) if not dir or dir == '.'
- File.join(dir, base)
- end
-
- if File::ALT_SEPARATOR
- DIRECTORY_TERM = "(?=[/#{Regexp.quote(File::ALT_SEPARATOR)}]|\\z)".freeze
- else
- DIRECTORY_TERM = "(?=/|\\z)".freeze
- end
- SYSCASE = File::FNM_SYSCASE.nonzero? ? "-i" : ""
-
- def descendant_directory?(descendant, ascendant)
- /\A(?#{SYSCASE}:#{Regexp.quote(ascendant)})#{DIRECTORY_TERM}/ =~ File.dirname(descendant)
- end
- end # class Entry_
-
- def fu_list(arg) #:nodoc:
- [arg].flatten.map {|path| File.path(path) }
- end
- private_module_function :fu_list
-
- def fu_each_src_dest(src, dest) #:nodoc:
- fu_each_src_dest0(src, dest) do |s, d|
- raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
- yield s, d
- end
- end
- private_module_function :fu_each_src_dest
-
- def fu_each_src_dest0(src, dest) #:nodoc:
- if tmp = Array.try_convert(src)
- tmp.each do |s|
- s = File.path(s)
- yield s, File.join(dest, File.basename(s))
- end
- else
- src = File.path(src)
- if File.directory?(dest)
- yield src, File.join(dest, File.basename(src))
- else
- yield src, File.path(dest)
- end
- end
- end
- private_module_function :fu_each_src_dest0
-
- def fu_same?(a, b) #:nodoc:
- File.identical?(a, b)
- end
- private_module_function :fu_same?
-
- def fu_check_options(options, optdecl) #:nodoc:
- h = options.dup
- optdecl.each do |opt|
- h.delete opt
- end
- raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
- end
- private_module_function :fu_check_options
-
- def fu_update_option(args, new) #:nodoc:
- if tmp = Hash.try_convert(args.last)
- args[-1] = tmp.dup.update(new)
- else
- args.push new
- end
- args
- end
- private_module_function :fu_update_option
-
- @fileutils_output = $stderr
- @fileutils_label = ''
-
- def fu_output_message(msg) #:nodoc:
- @fileutils_output ||= $stderr
- @fileutils_label ||= ''
- @fileutils_output.puts @fileutils_label + msg
- end
- private_module_function :fu_output_message
-
- #
- # Returns an Array of method names which have any options.
- #
- # p FileUtils.commands #=> ["chmod", "cp", "cp_r", "install", ...]
- #
- def FileUtils.commands
- OPT_TABLE.keys
- end
-
- #
- # Returns an Array of option names.
- #
- # p FileUtils.options #=> ["noop", "force", "verbose", "preserve", "mode"]
- #
- def FileUtils.options
- OPT_TABLE.values.flatten.uniq.map {|sym| sym.to_s }
- end
-
- #
- # Returns true if the method +mid+ have an option +opt+.
- #
- # p FileUtils.have_option?(:cp, :noop) #=> true
- # p FileUtils.have_option?(:rm, :force) #=> true
- # p FileUtils.have_option?(:rm, :preserve) #=> false
- #
- def FileUtils.have_option?(mid, opt)
- li = OPT_TABLE[mid.to_s] or raise ArgumentError, "no such method: #{mid}"
- li.include?(opt)
- end
-
- #
- # Returns an Array of option names of the method +mid+.
- #
- # p FileUtils.options_of(:rm) #=> ["noop", "verbose", "force"]
- #
- def FileUtils.options_of(mid)
- OPT_TABLE[mid.to_s].map {|sym| sym.to_s }
- end
-
- #
- # Returns an Array of method names which have the option +opt+.
- #
- # p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
- #
- def FileUtils.collect_method(opt)
- OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }
- end
-
- LOW_METHODS = singleton_methods(false) - collect_method(:noop).map(&:intern)
- module LowMethods
- module_eval("private\n" + ::FileUtils::LOW_METHODS.map {|name| "def #{name}(*)end"}.join("\n"),
- __FILE__, __LINE__)
- end
-
- METHODS = singleton_methods() - [:private_module_function,
- :commands, :options, :have_option?, :options_of, :collect_method]
-
- #
- # This module has all methods of FileUtils module, but it outputs messages
- # before acting. This equates to passing the :verbose flag to
- # methods in FileUtils.
- #
- module Verbose
- include FileUtils
- @fileutils_output = $stderr
- @fileutils_label = ''
- ::FileUtils.collect_method(:verbose).each do |name|
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
- def #{name}(*args)
- super(*fu_update_option(args, :verbose => true))
- end
- private :#{name}
- EOS
- end
- extend self
- class << self
- ::FileUtils::METHODS.each do |m|
- public m
- end
- end
- end
-
- #
- # This module has all methods of FileUtils module, but never changes
- # files/directories. This equates to passing the :noop flag
- # to methods in FileUtils.
- #
- module NoWrite
- include FileUtils
- include LowMethods
- @fileutils_output = $stderr
- @fileutils_label = ''
- ::FileUtils.collect_method(:noop).each do |name|
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
- def #{name}(*args)
- super(*fu_update_option(args, :noop => true))
- end
- private :#{name}
- EOS
- end
- extend self
- class << self
- ::FileUtils::METHODS.each do |m|
- public m
- end
- end
- end
-
- #
- # This module has all methods of FileUtils module, but never changes
- # files/directories, with printing message before acting.
- # This equates to passing the :noop and :verbose flag
- # to methods in FileUtils.
- #
- module DryRun
- include FileUtils
- include LowMethods
- @fileutils_output = $stderr
- @fileutils_label = ''
- ::FileUtils.collect_method(:noop).each do |name|
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
- def #{name}(*args)
- super(*fu_update_option(args, :noop => true, :verbose => true))
- end
- private :#{name}
- EOS
- end
- extend self
- class << self
- ::FileUtils::METHODS.each do |m|
- public m
- end
- end
- end
-
-end
diff --git a/src/main/resources/stdlib/find.rb b/src/main/resources/stdlib/find.rb
deleted file mode 100644
index 55783a5..0000000
--- a/src/main/resources/stdlib/find.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# find.rb: the Find module for processing all files under a given directory.
-#
-
-#
-# The +Find+ module supports the top-down traversal of a set of file paths.
-#
-# For example, to total the size of all files under your home directory,
-# ignoring anything in a "dot" directory (e.g. $HOME/.ssh):
-#
-# require 'find'
-#
-# total_size = 0
-#
-# Find.find(ENV["HOME"]) do |path|
-# if FileTest.directory?(path)
-# if File.basename(path)[0] == ?.
-# Find.prune # Don't look any further into this directory.
-# else
-# next
-# end
-# else
-# total_size += FileTest.size(path)
-# end
-# end
-#
-module Find
-
- #
- # Calls the associated block with the name of every file and directory listed
- # as arguments, then recursively on their subdirectories, and so on.
- #
- # Returns an enumerator if no block is given.
- #
- # See the +Find+ module documentation for an example.
- #
- def find(*paths, ignore_error: true) # :yield: path
- block_given? or return enum_for(__method__, *paths, ignore_error: ignore_error)
-
- fs_encoding = Encoding.find("filesystem")
-
- paths.collect!{|d| raise Errno::ENOENT unless File.exist?(d); d.dup}.each do |path|
- path = path.to_path if path.respond_to? :to_path
- enc = path.encoding == Encoding::US_ASCII ? fs_encoding : path.encoding
- ps = [path]
- while file = ps.shift
- catch(:prune) do
- yield file.dup.taint
- begin
- s = File.lstat(file)
- rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
- raise unless ignore_error
- next
- end
- if s.directory? then
- begin
- fs = Dir.entries(file, encoding: enc)
- rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
- raise unless ignore_error
- next
- end
- fs.sort!
- fs.reverse_each {|f|
- next if f == "." or f == ".."
- f = File.join(file, f)
- ps.unshift f.untaint
- }
- end
- end
- end
- end
- nil
- end
-
- #
- # Skips the current file or directory, restarting the loop with the next
- # entry. If the current file is a directory, that directory will not be
- # recursively entered. Meaningful only within the block associated with
- # Find::find.
- #
- # See the +Find+ module documentation for an example.
- #
- def prune
- throw :prune
- end
-
- module_function :find, :prune
-end
diff --git a/src/main/resources/stdlib/forwardable.rb b/src/main/resources/stdlib/forwardable.rb
deleted file mode 100644
index ecc5f03..0000000
--- a/src/main/resources/stdlib/forwardable.rb
+++ /dev/null
@@ -1,289 +0,0 @@
-#
-# forwardable.rb -
-# $Release Version: 1.1$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ishitsuka.com)
-# original definition by delegator.rb
-# Revised by Daniel J. Berger with suggestions from Florian Gross.
-#
-# Documentation by James Edward Gray II and Gavin Sinclair
-
-
-
-# The Forwardable module provides delegation of specified
-# methods to a designated object, using the methods #def_delegator
-# and #def_delegators.
-#
-# For example, say you have a class RecordCollection which
-# contains an array @records. You could provide the lookup method
-# #record_number(), which simply calls #[] on the @records
-# array, like this:
-#
-# require 'forwardable'
-#
-# class RecordCollection
-# attr_accessor :records
-# extend Forwardable
-# def_delegator :@records, :[], :record_number
-# end
-#
-# We can use the lookup method like so:
-#
-# r = RecordCollection.new
-# r.records = [4,5,6]
-# r.record_number(0) # => 4
-#
-# Further, if you wish to provide the methods #size, #<<, and #map,
-# all of which delegate to @records, this is how you can do it:
-#
-# class RecordCollection # re-open RecordCollection class
-# def_delegators :@records, :size, :<<, :map
-# end
-#
-# r = RecordCollection.new
-# r.records = [1,2,3]
-# r.record_number(0) # => 1
-# r.size # => 3
-# r << 4 # => [1, 2, 3, 4]
-# r.map { |x| x * 2 } # => [2, 4, 6, 8]
-#
-# You can even extend regular objects with Forwardable.
-#
-# my_hash = Hash.new
-# my_hash.extend Forwardable # prepare object for delegation
-# my_hash.def_delegator "STDOUT", "puts" # add delegation for STDOUT.puts()
-# my_hash.puts "Howdy!"
-#
-# == Another example
-#
-# We want to rely on what has come before obviously, but with delegation we can
-# take just the methods we need and even rename them as appropriate. In many
-# cases this is preferable to inheritance, which gives us the entire old
-# interface, even if much of it isn't needed.
-#
-# class Queue
-# extend Forwardable
-#
-# def initialize
-# @q = [ ] # prepare delegate object
-# end
-#
-# # setup preferred interface, enq() and deq()...
-# def_delegator :@q, :push, :enq
-# def_delegator :@q, :shift, :deq
-#
-# # support some general Array methods that fit Queues well
-# def_delegators :@q, :clear, :first, :push, :shift, :size
-# end
-#
-# q = Queue.new
-# q.enq 1, 2, 3, 4, 5
-# q.push 6
-#
-# q.shift # => 1
-# while q.size > 0
-# puts q.deq
-# end
-#
-# q.enq "Ruby", "Perl", "Python"
-# puts q.first
-# q.clear
-# puts q.first
-#
-# This should output:
-#
-# 2
-# 3
-# 4
-# 5
-# 6
-# Ruby
-# nil
-#
-# == Notes
-#
-# Be advised, RDoc will not detect delegated methods.
-#
-# +forwardable.rb+ provides single-method delegation via the def_delegator and
-# def_delegators methods. For full-class delegation via DelegateClass, see
-# +delegate.rb+.
-#
-module Forwardable
- # Version of +forwardable.rb+
- FORWARDABLE_VERSION = "1.1.0"
-
- FILE_REGEXP = %r"#{Regexp.quote(__FILE__)}"
-
- @debug = nil
- class << self
- # If true, __FILE__ will remain in the backtrace in the event an
- # Exception is raised.
- attr_accessor :debug
- end
-
- # Takes a hash as its argument. The key is a symbol or an array of
- # symbols. These symbols correspond to method names. The value is
- # the accessor to which the methods will be delegated.
- #
- # :call-seq:
- # delegate method => accessor
- # delegate [method, method, ...] => accessor
- #
- def instance_delegate(hash)
- hash.each{ |methods, accessor|
- methods = [methods] unless methods.respond_to?(:each)
- methods.each{ |method|
- def_instance_delegator(accessor, method)
- }
- }
- end
-
- #
- # Shortcut for defining multiple delegator methods, but with no
- # provision for using a different name. The following two code
- # samples have the same effect:
- #
- # def_delegators :@records, :size, :<<, :map
- #
- # def_delegator :@records, :size
- # def_delegator :@records, :<<
- # def_delegator :@records, :map
- #
- def def_instance_delegators(accessor, *methods)
- methods.delete("__send__")
- methods.delete("__id__")
- for method in methods
- def_instance_delegator(accessor, method)
- end
- end
-
- # Define +method+ as delegator instance method with an optional
- # alias name +ali+. Method calls to +ali+ will be delegated to
- # +accessor.method+.
- #
- # class MyQueue
- # extend Forwardable
- # attr_reader :queue
- # def initialize
- # @queue = []
- # end
- #
- # def_delegator :@queue, :push, :mypush
- # end
- #
- # q = MyQueue.new
- # q.mypush 42
- # q.queue #=> [42]
- # q.push 23 #=> NoMethodError
- #
- def def_instance_delegator(accessor, method, ali = method)
- line_no = __LINE__; str = %{
- def #{ali}(*args, &block)
- begin
- #{accessor}.__send__(:#{method}, *args, &block)
- rescue Exception
- $@.delete_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug
- ::Kernel::raise
- end
- end
- }
- # If it's not a class or module, it's an instance
- begin
- module_eval(str, __FILE__, line_no)
- rescue
- instance_eval(str, __FILE__, line_no)
- end
-
- end
-
- alias delegate instance_delegate
- alias def_delegators def_instance_delegators
- alias def_delegator def_instance_delegator
-end
-
-# SingleForwardable can be used to setup delegation at the object level as well.
-#
-# printer = String.new
-# printer.extend SingleForwardable # prepare object for delegation
-# printer.def_delegator "STDOUT", "puts" # add delegation for STDOUT.puts()
-# printer.puts "Howdy!"
-#
-# Also, SingleForwardable can be used to set up delegation for a Class or Module.
-#
-# class Implementation
-# def self.service
-# puts "serviced!"
-# end
-# end
-#
-# module Facade
-# extend SingleForwardable
-# def_delegator :Implementation, :service
-# end
-#
-# Facade.service #=> serviced!
-#
-# If you want to use both Forwardable and SingleForwardable, you can
-# use methods def_instance_delegator and def_single_delegator, etc.
-module SingleForwardable
- # Takes a hash as its argument. The key is a symbol or an array of
- # symbols. These symbols correspond to method names. The value is
- # the accessor to which the methods will be delegated.
- #
- # :call-seq:
- # delegate method => accessor
- # delegate [method, method, ...] => accessor
- #
- def single_delegate(hash)
- hash.each{ |methods, accessor|
- methods = [methods] unless methods.respond_to?(:each)
- methods.each{ |method|
- def_single_delegator(accessor, method)
- }
- }
- end
-
- #
- # Shortcut for defining multiple delegator methods, but with no
- # provision for using a different name. The following two code
- # samples have the same effect:
- #
- # def_delegators :@records, :size, :<<, :map
- #
- # def_delegator :@records, :size
- # def_delegator :@records, :<<
- # def_delegator :@records, :map
- #
- def def_single_delegators(accessor, *methods)
- methods.delete("__send__")
- methods.delete("__id__")
- for method in methods
- def_single_delegator(accessor, method)
- end
- end
-
- # :call-seq:
- # def_single_delegator(accessor, method, new_name=method)
- #
- # Defines a method _method_ which delegates to _accessor_ (i.e. it calls
- # the method of the same name in _accessor_). If _new_name_ is
- # provided, it is used as the name for the delegate method.
- def def_single_delegator(accessor, method, ali = method)
- str = %{
- def #{ali}(*args, &block)
- begin
- #{accessor}.__send__(:#{method}, *args, &block)
- rescue Exception
- $@.delete_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug
- ::Kernel::raise
- end
- end
- }
-
- instance_eval(str, __FILE__, __LINE__)
- end
-
- alias delegate single_delegate
- alias def_delegators def_single_delegators
- alias def_delegator def_single_delegator
-end
diff --git a/src/main/resources/stdlib/gauntlet_rdoc.rb b/src/main/resources/stdlib/gauntlet_rdoc.rb
deleted file mode 100644
index 16665da..0000000
--- a/src/main/resources/stdlib/gauntlet_rdoc.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-require 'rubygems'
-Gem.load_yaml
-require 'rdoc'
-require 'gauntlet'
-require 'fileutils'
-
-##
-# Allows for testing of RDoc against every gem
-
-class RDoc::Gauntlet < Gauntlet
-
- def initialize # :nodoc:
- super
-
- @args = nil
- @type = nil
- end
-
- ##
- # Runs an RDoc generator for gem +name+
-
- def run name
- return if self.data.key? name
-
- dir = File.expand_path "~/.gauntlet/data/#{@type}/#{name}"
- FileUtils.rm_rf dir if File.exist? dir
-
- yaml = File.read 'gemspec'
- begin
- spec = Gem::Specification.from_yaml yaml
- rescue Psych::SyntaxError
- puts "bad spec #{name}"
- self.data[name] = false
- return
- end
-
- args = @args.dup
- args << '--op' << dir
- args.concat spec.rdoc_options
- args << spec.require_paths
- args << spec.extra_rdoc_files
- args = args.flatten.map { |a| a.to_s }
- args.delete '--quiet'
-
- puts "#{name} - rdoc #{args.join ' '}"
-
- self.dirty = true
- r = RDoc::RDoc.new
-
- begin
- r.document args
- self.data[name] = true
- puts 'passed'
- FileUtils.rm_rf dir
- rescue Interrupt, StandardError, RDoc::Error, SystemStackError => e
- puts "failed - (#{e.class}) #{e.message}"
- self.data[name] = false
- end
- rescue Gem::Exception
- puts "bad gem #{name}"
- ensure
- puts
- end
-
- ##
- # Runs the gauntlet with the given +type+ (rdoc or ri) and +filter+ for
- # which gems to run
-
- def run_the_gauntlet type = 'rdoc', filter = nil
- @type = type || 'rdoc'
- @args = type == 'rdoc' ? [] : %w[--ri]
- @data_file = "#{DATADIR}/#{@type}-data.yml"
-
- super filter
- end
-
-end
-
-type = ARGV.shift
-filter = ARGV.shift
-filter = /#{filter}/ if filter
-
-RDoc::Gauntlet.new.run_the_gauntlet type, filter
-
diff --git a/src/main/resources/stdlib/getoptlong.rb b/src/main/resources/stdlib/getoptlong.rb
deleted file mode 100644
index cf635f0..0000000
--- a/src/main/resources/stdlib/getoptlong.rb
+++ /dev/null
@@ -1,612 +0,0 @@
-#
-# GetoptLong for Ruby
-#
-# Copyright (C) 1998, 1999, 2000 Motoyuki Kasahara.
-#
-# You may redistribute and/or modify this library under the same license
-# terms as Ruby.
-#
-# See GetoptLong for documentation.
-#
-# Additional documents and the latest version of `getoptlong.rb' can be
-# found at http://www.sra.co.jp/people/m-kasahr/ruby/getoptlong/
-
-# The GetoptLong class allows you to parse command line options similarly to
-# the GNU getopt_long() C library call. Note, however, that GetoptLong is a
-# pure Ruby implementation.
-#
-# GetoptLong allows for POSIX-style options like --file as well
-# as single letter options like -f
-#
-# The empty option -- (two minus symbols) is used to end option
-# processing. This can be particularly important if options have optional
-# arguments.
-#
-# Here is a simple example of usage:
-#
-# require 'getoptlong'
-#
-# opts = GetoptLong.new(
-# [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
-# [ '--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT ],
-# [ '--name', GetoptLong::OPTIONAL_ARGUMENT ]
-# )
-#
-# dir = nil
-# name = nil
-# repetitions = 1
-# opts.each do |opt, arg|
-# case opt
-# when '--help'
-# puts <<-EOF
-# hello [OPTION] ... DIR
-#
-# -h, --help:
-# show help
-#
-# --repeat x, -n x:
-# repeat x times
-#
-# --name [name]:
-# greet user by name, if name not supplied default is John
-#
-# DIR: The directory in which to issue the greeting.
-# EOF
-# when '--repeat'
-# repetitions = arg.to_i
-# when '--name'
-# if arg == ''
-# name = 'John'
-# else
-# name = arg
-# end
-# end
-# end
-#
-# if ARGV.length != 1
-# puts "Missing dir argument (try --help)"
-# exit 0
-# end
-#
-# dir = ARGV.shift
-#
-# Dir.chdir(dir)
-# for i in (1..repetitions)
-# print "Hello"
-# if name
-# print ", #{name}"
-# end
-# puts
-# end
-#
-# Example command line:
-#
-# hello -n 6 --name -- /tmp
-#
-class GetoptLong
- #
- # Orderings.
- #
- ORDERINGS = [REQUIRE_ORDER = 0, PERMUTE = 1, RETURN_IN_ORDER = 2]
-
- #
- # Argument flags.
- #
- ARGUMENT_FLAGS = [NO_ARGUMENT = 0, REQUIRED_ARGUMENT = 1,
- OPTIONAL_ARGUMENT = 2]
-
- #
- # Status codes.
- #
- STATUS_YET, STATUS_STARTED, STATUS_TERMINATED = 0, 1, 2
-
- #
- # Error types.
- #
- class Error < StandardError; end
- class AmbiguousOption < Error; end
- class NeedlessArgument < Error; end
- class MissingArgument < Error; end
- class InvalidOption < Error; end
-
- #
- # Set up option processing.
- #
- # The options to support are passed to new() as an array of arrays.
- # Each sub-array contains any number of String option names which carry
- # the same meaning, and one of the following flags:
- #
- # GetoptLong::NO_ARGUMENT :: Option does not take an argument.
- #
- # GetoptLong::REQUIRED_ARGUMENT :: Option always takes an argument.
- #
- # GetoptLong::OPTIONAL_ARGUMENT :: Option may or may not take an argument.
- #
- # The first option name is considered to be the preferred (canonical) name.
- # Other than that, the elements of each sub-array can be in any order.
- #
- def initialize(*arguments)
- #
- # Current ordering.
- #
- if ENV.include?('POSIXLY_CORRECT')
- @ordering = REQUIRE_ORDER
- else
- @ordering = PERMUTE
- end
-
- #
- # Hash table of option names.
- # Keys of the table are option names, and their values are canonical
- # names of the options.
- #
- @canonical_names = Hash.new
-
- #
- # Hash table of argument flags.
- # Keys of the table are option names, and their values are argument
- # flags of the options.
- #
- @argument_flags = Hash.new
-
- #
- # Whether error messages are output to $stderr.
- #
- @quiet = FALSE
-
- #
- # Status code.
- #
- @status = STATUS_YET
-
- #
- # Error code.
- #
- @error = nil
-
- #
- # Error message.
- #
- @error_message = nil
-
- #
- # Rest of catenated short options.
- #
- @rest_singles = ''
-
- #
- # List of non-option-arguments.
- # Append them to ARGV when option processing is terminated.
- #
- @non_option_arguments = Array.new
-
- if 0 < arguments.length
- set_options(*arguments)
- end
- end
-
- #
- # Set the handling of the ordering of options and arguments.
- # A RuntimeError is raised if option processing has already started.
- #
- # The supplied value must be a member of GetoptLong::ORDERINGS. It alters
- # the processing of options as follows:
- #
- # REQUIRE_ORDER :
- #
- # Options are required to occur before non-options.
- #
- # Processing of options ends as soon as a word is encountered that has not
- # been preceded by an appropriate option flag.
- #
- # For example, if -a and -b are options which do not take arguments,
- # parsing command line arguments of '-a one -b two' would result in
- # 'one', '-b', 'two' being left in ARGV, and only ('-a', '') being
- # processed as an option/arg pair.
- #
- # This is the default ordering, if the environment variable
- # POSIXLY_CORRECT is set. (This is for compatibility with GNU getopt_long.)
- #
- # PERMUTE :
- #
- # Options can occur anywhere in the command line parsed. This is the
- # default behavior.
- #
- # Every sequence of words which can be interpreted as an option (with or
- # without argument) is treated as an option; non-option words are skipped.
- #
- # For example, if -a does not require an argument and -b optionally takes
- # an argument, parsing '-a one -b two three' would result in ('-a','') and
- # ('-b', 'two') being processed as option/arg pairs, and 'one','three'
- # being left in ARGV.
- #
- # If the ordering is set to PERMUTE but the environment variable
- # POSIXLY_CORRECT is set, REQUIRE_ORDER is used instead. This is for
- # compatibility with GNU getopt_long.
- #
- # RETURN_IN_ORDER :
- #
- # All words on the command line are processed as options. Words not
- # preceded by a short or long option flag are passed as arguments
- # with an option of '' (empty string).
- #
- # For example, if -a requires an argument but -b does not, a command line
- # of '-a one -b two three' would result in option/arg pairs of ('-a', 'one')
- # ('-b', ''), ('', 'two'), ('', 'three') being processed.
- #
- def ordering=(ordering)
- #
- # The method is failed if option processing has already started.
- #
- if @status != STATUS_YET
- set_error(ArgumentError, "argument error")
- raise RuntimeError,
- "invoke ordering=, but option processing has already started"
- end
-
- #
- # Check ordering.
- #
- if !ORDERINGS.include?(ordering)
- raise ArgumentError, "invalid ordering `#{ordering}'"
- end
- if ordering == PERMUTE && ENV.include?('POSIXLY_CORRECT')
- @ordering = REQUIRE_ORDER
- else
- @ordering = ordering
- end
- end
-
- #
- # Return ordering.
- #
- attr_reader :ordering
-
- #
- # Set options. Takes the same argument as GetoptLong.new.
- #
- # Raises a RuntimeError if option processing has already started.
- #
- def set_options(*arguments)
- #
- # The method is failed if option processing has already started.
- #
- if @status != STATUS_YET
- raise RuntimeError,
- "invoke set_options, but option processing has already started"
- end
-
- #
- # Clear tables of option names and argument flags.
- #
- @canonical_names.clear
- @argument_flags.clear
-
- arguments.each do |arg|
- if !arg.is_a?(Array)
- raise ArgumentError, "the option list contains non-Array argument"
- end
-
- #
- # Find an argument flag and it set to `argument_flag'.
- #
- argument_flag = nil
- arg.each do |i|
- if ARGUMENT_FLAGS.include?(i)
- if argument_flag != nil
- raise ArgumentError, "too many argument-flags"
- end
- argument_flag = i
- end
- end
-
- raise ArgumentError, "no argument-flag" if argument_flag == nil
-
- canonical_name = nil
- arg.each do |i|
- #
- # Check an option name.
- #
- next if i == argument_flag
- begin
- if !i.is_a?(String) || i !~ /^-([^-]|-.+)$/
- raise ArgumentError, "an invalid option `#{i}'"
- end
- if (@canonical_names.include?(i))
- raise ArgumentError, "option redefined `#{i}'"
- end
- rescue
- @canonical_names.clear
- @argument_flags.clear
- raise
- end
-
- #
- # Register the option (`i') to the `@canonical_names' and
- # `@canonical_names' Hashes.
- #
- if canonical_name == nil
- canonical_name = i
- end
- @canonical_names[i] = canonical_name
- @argument_flags[i] = argument_flag
- end
- raise ArgumentError, "no option name" if canonical_name == nil
- end
- return self
- end
-
- #
- # Set/Unset `quiet' mode.
- #
- attr_writer :quiet
-
- #
- # Return the flag of `quiet' mode.
- #
- attr_reader :quiet
-
- #
- # `quiet?' is an alias of `quiet'.
- #
- alias quiet? quiet
-
- #
- # Explicitly terminate option processing.
- #
- def terminate
- return nil if @status == STATUS_TERMINATED
- raise RuntimeError, "an error has occurred" if @error != nil
-
- @status = STATUS_TERMINATED
- @non_option_arguments.reverse_each do |argument|
- ARGV.unshift(argument)
- end
-
- @canonical_names = nil
- @argument_flags = nil
- @rest_singles = nil
- @non_option_arguments = nil
-
- return self
- end
-
- #
- # Returns true if option processing has terminated, false otherwise.
- #
- def terminated?
- return @status == STATUS_TERMINATED
- end
-
- #
- # Set an error (a protected method).
- #
- def set_error(type, message)
- $stderr.print("#{$0}: #{message}\n") if !@quiet
-
- @error = type
- @error_message = message
- @canonical_names = nil
- @argument_flags = nil
- @rest_singles = nil
- @non_option_arguments = nil
-
- raise type, message
- end
- protected :set_error
-
- #
- # Examine whether an option processing is failed.
- #
- attr_reader :error
-
- #
- # `error?' is an alias of `error'.
- #
- alias error? error
-
- # Return the appropriate error message in POSIX-defined format.
- # If no error has occurred, returns nil.
- #
- def error_message
- return @error_message
- end
-
- #
- # Get next option name and its argument, as an Array of two elements.
- #
- # The option name is always converted to the first (preferred)
- # name given in the original options to GetoptLong.new.
- #
- # Example: ['--option', 'value']
- #
- # Returns nil if the processing is complete (as determined by
- # STATUS_TERMINATED).
- #
- def get
- option_name, option_argument = nil, ''
-
- #
- # Check status.
- #
- return nil if @error != nil
- case @status
- when STATUS_YET
- @status = STATUS_STARTED
- when STATUS_TERMINATED
- return nil
- end
-
- #
- # Get next option argument.
- #
- if 0 < @rest_singles.length
- argument = '-' + @rest_singles
- elsif (ARGV.length == 0)
- terminate
- return nil
- elsif @ordering == PERMUTE
- while 0 < ARGV.length && ARGV[0] !~ /^-./
- @non_option_arguments.push(ARGV.shift)
- end
- if ARGV.length == 0
- terminate
- return nil
- end
- argument = ARGV.shift
- elsif @ordering == REQUIRE_ORDER
- if (ARGV[0] !~ /^-./)
- terminate
- return nil
- end
- argument = ARGV.shift
- else
- argument = ARGV.shift
- end
-
- #
- # Check the special argument `--'.
- # `--' indicates the end of the option list.
- #
- if argument == '--' && @rest_singles.length == 0
- terminate
- return nil
- end
-
- #
- # Check for long and short options.
- #
- if argument =~ /^(--[^=]+)/ && @rest_singles.length == 0
- #
- # This is a long style option, which start with `--'.
- #
- pattern = $1
- if @canonical_names.include?(pattern)
- option_name = pattern
- else
- #
- # The option `option_name' is not registered in `@canonical_names'.
- # It may be an abbreviated.
- #
- matches = []
- @canonical_names.each_key do |key|
- if key.index(pattern) == 0
- option_name = key
- matches << key
- end
- end
- if 2 <= matches.length
- set_error(AmbiguousOption, "option `#{argument}' is ambiguous between #{matches.join(', ')}")
- elsif matches.length == 0
- set_error(InvalidOption, "unrecognized option `#{argument}'")
- end
- end
-
- #
- # Check an argument to the option.
- #
- if @argument_flags[option_name] == REQUIRED_ARGUMENT
- if argument =~ /=(.*)$/
- option_argument = $1
- elsif 0 < ARGV.length
- option_argument = ARGV.shift
- else
- set_error(MissingArgument,
- "option `#{argument}' requires an argument")
- end
- elsif @argument_flags[option_name] == OPTIONAL_ARGUMENT
- if argument =~ /=(.*)$/
- option_argument = $1
- elsif 0 < ARGV.length && ARGV[0] !~ /^-./
- option_argument = ARGV.shift
- else
- option_argument = ''
- end
- elsif argument =~ /=(.*)$/
- set_error(NeedlessArgument,
- "option `#{option_name}' doesn't allow an argument")
- end
-
- elsif argument =~ /^(-(.))(.*)/
- #
- # This is a short style option, which start with `-' (not `--').
- # Short options may be catenated (e.g. `-l -g' is equivalent to
- # `-lg').
- #
- option_name, ch, @rest_singles = $1, $2, $3
-
- if @canonical_names.include?(option_name)
- #
- # The option `option_name' is found in `@canonical_names'.
- # Check its argument.
- #
- if @argument_flags[option_name] == REQUIRED_ARGUMENT
- if 0 < @rest_singles.length
- option_argument = @rest_singles
- @rest_singles = ''
- elsif 0 < ARGV.length
- option_argument = ARGV.shift
- else
- # 1003.2 specifies the format of this message.
- set_error(MissingArgument, "option requires an argument -- #{ch}")
- end
- elsif @argument_flags[option_name] == OPTIONAL_ARGUMENT
- if 0 < @rest_singles.length
- option_argument = @rest_singles
- @rest_singles = ''
- elsif 0 < ARGV.length && ARGV[0] !~ /^-./
- option_argument = ARGV.shift
- else
- option_argument = ''
- end
- end
- else
- #
- # This is an invalid option.
- # 1003.2 specifies the format of this message.
- #
- if ENV.include?('POSIXLY_CORRECT')
- set_error(InvalidOption, "invalid option -- #{ch}")
- else
- set_error(InvalidOption, "invalid option -- #{ch}")
- end
- end
- else
- #
- # This is a non-option argument.
- # Only RETURN_IN_ORDER falled into here.
- #
- return '', argument
- end
-
- return @canonical_names[option_name], option_argument
- end
-
- #
- # `get_option' is an alias of `get'.
- #
- alias get_option get
-
- # Iterator version of `get'.
- #
- # The block is called repeatedly with two arguments:
- # The first is the option name.
- # The second is the argument which followed it (if any).
- # Example: ('--opt', 'value')
- #
- # The option name is always converted to the first (preferred)
- # name given in the original options to GetoptLong.new.
- #
- def each
- loop do
- option_name, option_argument = get_option
- break if option_name == nil
- yield option_name, option_argument
- end
- end
-
- #
- # `each_option' is an alias of `each'.
- #
- alias each_option each
-end
diff --git a/src/main/resources/stdlib/hoe/minitest.rb b/src/main/resources/stdlib/hoe/minitest.rb
deleted file mode 100644
index dc2f029..0000000
--- a/src/main/resources/stdlib/hoe/minitest.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# :stopdoc:
-
-class Hoe
-end
-
-module Hoe::Minitest
- def initialize_minitest
- dir = "../../minitest/dev/lib"
- Hoe.add_include_dirs dir if File.directory? dir
-
- gem "minitest"
- require "minitest"
- version = Minitest::VERSION.split(/\./).first(2).join(".")
-
- dependency "minitest", "~> #{version}", :development unless
- self.name == "minitest" or ENV["MT_NO_ISOLATE"]
- end
-
- def define_minitest_tasks
- self.testlib = :minitest
-
- # make sure we use the gemmed minitest on 1.9
- self.test_prelude = 'gem "minitest"' unless
- self.name == "minitest" or ENV["MT_NO_ISOLATE"]
- end
-end
diff --git a/src/main/resources/stdlib/io/bsd_console.rb b/src/main/resources/stdlib/io/bsd_console.rb
deleted file mode 100644
index d32804c..0000000
--- a/src/main/resources/stdlib/io/bsd_console.rb
+++ /dev/null
@@ -1,166 +0,0 @@
-require 'ffi'
-
-module IO::LibC
- extend FFI::Library
- ffi_lib FFI::Library::LIBC
-
- if RbConfig::CONFIG['host_os'].downcase =~ /darwin/
- typedef :ulong, :tcflag_t
- typedef :ulong, :speed_t
- else
- typedef :uint, :tcflag_t
- typedef :uint, :speed_t
- end
-
- # Special Control Characters
- VEOF = 0 # ICANON
- VEOL = 1 # ICANON
- VEOL2 = 2 # ICANON together with IEXTEN
- VERASE = 3 # ICANON
- VWERASE = 4 # ICANON together with IEXTEN
- VKILL = 5 # ICANON
- VREPRINT = 6 # ICANON together with IEXTEN
- VINTR = 8 # ISIG
- VQUIT = 9 # ISIG
- VSUSP = 10 # ISIG
- VDSUSP = 11 # ISIG together with IEXTEN
- VSTART = 12 # IXON, IXOFF
- VSTOP = 13 # IXON, IXOFF
- VLNEXT = 14 # IEXTEN
- VDISCARD = 15 # IEXTEN
- VMIN = 16 # !ICANON
- VTIME = 17 # !ICANON
- VSTATUS = 18 # ICANON together with IEXTEN
- NCCS = 20
-
- # Input flags - software input processing
- IGNBRK = 0x00000001 # ignore BREAK condition
- BRKINT = 0x00000002 # map BREAK to SIGINTR
- IGNPAR = 0x00000004 # ignore (discard) parity errors
- PARMRK = 0x00000008 # mark parity and framing errors
- INPCK = 0x00000010 # enable checking of parity errors
- ISTRIP = 0x00000020 # strip 8th bit off chars
- INLCR = 0x00000040 # map NL into CR
- IGNCR = 0x00000080 # ignore CR
- ICRNL = 0x00000100 # map CR to NL (ala CRMOD)
- IXON = 0x00000200 # enable output flow control
- IXOFF = 0x00000400 # enable input flow control
- IXANY = 0x00000800 # any char will restart after stop
- IMAXBEL = 0x00002000 # ring bell on input queue full
- IUTF8 = 0x00004000 # maintain state for UTF-8 VERASE
-
- # Output flags - software output processing
- OPOST = 0x00000001 # enable following output processing
- ONLCR = 0x00000002 # map NL to CR-NL (ala CRMOD)
- OXTABS = 0x00000004 # expand tabs to spaces
- ONOEOT = 0x00000008 # discard EOT's (^D) on output)
- OCRNL = 0x00000010 # map CR to NL on output
- ONOCR = 0x00000020 # no CR output at column 0
- ONLRET = 0x00000040 # NL performs CR function
-
- # Control flags - hardware control of terminal
- CIGNORE = 0x00000001 # ignore control flags
- CSIZE = 0x00000300 # character size mask
- CS5 = 0x00000000 # 5 bits (pseudo)
- CS6 = 0x00000100 # 6 bits
- CS7 = 0x00000200 # 7 bits
- CS8 = 0x00000300 # 8 bits
- CSTOPB = 0x00000400 # send 2 stop bits
- CREAD = 0x00000800 # enable receiver
- PARENB = 0x00001000 # parity enable
- PARODD = 0x00002000 # odd parity, else even
- HUPCL = 0x00004000 # hang up on last close
- CLOCAL = 0x00008000 # ignore modem status lines
- CCTS_OFLOW = 0x00010000 # CTS flow control of output
- CRTS_IFLOW = 0x00020000 # RTS flow control of input
- CDTR_IFLOW = 0x00040000 # DTR flow control of input
- CDSR_OFLOW = 0x00080000 # DSR flow control of output
- CCAR_OFLOW = 0x00100000 # DCD flow control of output
- CRTSCTS = CCTS_OFLOW | CRTS_IFLOW
- MDMBUF = 0x00100000 # old name for CCAR_OFLOW
-
-
- # "Local" flags - dumping ground for other state
- ECHOKE = 0x00000001 # visual erase for line kill
- ECHOE = 0x00000002 # visually erase chars
- ECHOK = 0x00000004 # echo NL after line kill
- ECHO = 0x00000008 # enable echoing
- ECHONL = 0x00000010 # echo NL even if ECHO is off
- ECHOPRT = 0x00000020 # visual erase mode for hardcopy
- ECHOCTL = 0x00000040 # echo control chars as ^(Char)
- ISIG = 0x00000080 # enable signals INTR, QUIT, [D]SUSP
- ICANON = 0x00000100 # canonicalize input lines
- ALTWERASE = 0x00000200 # use alternate WERASE algorithm
- IEXTEN = 0x00000400 # enable DISCARD and LNEXT
- EXTPROC = 0x00000800 # external processing
- TOSTOP = 0x00400000 # stop background jobs from output
- FLUSHO = 0x00800000 # output being flushed (state)
- NOKERNINFO = 0x02000000 # no kernel output from VSTATUS
- PENDIN = 0x20000000 # XXX retype pending input (state)
- NOFLSH = 0x80000000 # don't flush after interrupt
-
-
- # Commands passed to tcsetattr() for setting the termios structure.
- TCSANOW = 0 # make change immediate
- TCSADRAIN = 1 # drain output, then change
- TCSAFLUSH = 2 # drain output, flush input
- TCSASOFT = 0x10 # flag - don't alter h.w. state
-
-
- TCIFLUSH = 1
- TCOFLUSH = 2
- TCIOFLUSH = 3
- TCOOFF = 1
- TCOON = 2
- TCIOFF = 3
- TCION = 4
-
- IOCPARM_MASK = 0x1fff
- IOC_OUT = 0x40000000
- IOC_IN = 0x80000000
-
- def self._IOC(inout,group,num,len)
- inout | ((len & IOCPARM_MASK) << 16) | ((group.ord << 8) | num)
- end
-
- def self._IOR(g,n,t)
- self._IOC(IOC_OUT, g, n, find_type(t).size)
- end
-
- def self._IOW(g,n,t)
- self._IOC(IOC_IN, g, n, find_type(t).size)
- end
-
-
- class Termios < FFI::Struct
- layout \
- :c_iflag, :tcflag_t,
- :c_oflag, :tcflag_t,
- :c_cflag, :tcflag_t,
- :c_lflag, :tcflag_t,
- :cc_c, [ :uchar, NCCS ],
- :c_ispeed, :speed_t,
- :c_ospeed, :speed_t
- end
-
- class Winsize < FFI::Struct
- layout \
- :ws_row, :ushort,
- :ws_col, :ushort,
- :ws_xpixel, :ushort,
- :ws_ypixel, :ushort
- end
-
- TIOCGWINSZ = _IOR('t', 104, Winsize) # get window size
- TIOCSWINSZ = _IOW('t', 103, Winsize) # set window size
-
- attach_function :tcsetattr, [ :int, :int, Termios ], :int
- attach_function :tcgetattr, [ :int, Termios ], :int
- attach_function :cfgetispeed, [ Termios ], :speed_t
- attach_function :cfgetospeed, [ Termios ], :speed_t
- attach_function :cfsetispeed, [ Termios, :speed_t ], :int
- attach_function :cfsetospeed, [ Termios, :speed_t ], :int
- attach_function :cfmakeraw, [ Termios ], :int
- attach_function :tcflush, [ :int, :int ], :int
- attach_function :ioctl, [ :int, :ulong, :varargs ], :int
-end
diff --git a/src/main/resources/stdlib/io/console.rb b/src/main/resources/stdlib/io/console.rb
deleted file mode 100644
index 22f9cc7..0000000
--- a/src/main/resources/stdlib/io/console.rb
+++ /dev/null
@@ -1,337 +0,0 @@
-# This implementation of io/console is a little hacky. It shells out to `stty`
-# for most operations, which does not work on Windows, in secured environments,
-# and so on. In addition, because on Java 6 we can't actually launch
-# subprocesses with tty control, stty will not actually manipulate the
-# controlling terminal.
-#
-# For platforms where shelling to stty does not work, most operations will
-# just be pass-throughs. This allows them to function, but does not actually
-# change any tty flags.
-#
-# Finally, since we're using stty to shell out, we can only manipulate stdin/
-# stdout tty rather than manipulating whatever terminal is actually associated
-# with the IO we're calling against. This will produce surprising results if
-# anyone is actually using io/console against non-stdio ttys...but that case
-# seems like it would be pretty rare.
-#
-# Note: we are incorporating this into 1.7.0 since RubyGems uses io/console
-# when pushing gems, in order to mask the password entry. Worst case is that
-# we don't actually disable echo and the password is shown...we will try to
-# do a better version of this in 1.7.1.
-
-# attempt to call stty; if failure, fall back on stubbed version
-
-if RbConfig::CONFIG['host_os'].downcase =~ /darwin|openbsd|freebsd|netbsd|linux/
- require 'java'
-
- result = begin
- if RbConfig::CONFIG['host_os'].downcase =~ /darwin|openbsd|freebsd|netbsd/
- require File.join(File.dirname(__FILE__), 'bsd_console')
-
- elsif RbConfig::CONFIG['host_os'].downcase =~ /linux/
- require File.join(File.dirname(__FILE__), 'linux_console')
-
- else
- raise LoadError.new("no native io/console support")
- end
-
- class IO
- def ttymode
- termios = LibC::Termios.new
- if LibC.tcgetattr(self.fileno, termios) != 0
- raise SystemCallError.new("tcgetattr", FFI.errno)
- end
-
- if block_given?
- yield tmp = termios.dup
- if LibC.tcsetattr(self.fileno, LibC::TCSADRAIN, tmp) != 0
- raise SystemCallError.new("tcsetattr", FFI.errno)
- end
- end
- termios
- end
-
- def ttymode_yield(block, &setup)
- begin
- orig_termios = ttymode { |t| setup.call(t) }
- block.call(self)
- ensure
- if orig_termios && LibC.tcsetattr(self.fileno, LibC::TCSADRAIN, orig_termios) != 0
- raise SystemCallError.new("tcsetattr", FFI.errno)
- end
- end
- end
-
- TTY_RAW = Proc.new do |t|
- LibC.cfmakeraw(t)
- t[:c_lflag] &= ~(LibC::ECHOE|LibC::ECHOK)
- end
-
- def raw(*, &block)
- ttymode_yield(block, &TTY_RAW)
- end
-
- def raw!(*)
- ttymode(&TTY_RAW)
- end
-
- TTY_COOKED = Proc.new do |t|
- t[:c_iflag] |= (LibC::BRKINT|LibC::ISTRIP|LibC::ICRNL|LibC::IXON)
- t[:c_oflag] |= LibC::OPOST
- t[:c_lflag] |= (LibC::ECHO|LibC::ECHOE|LibC::ECHOK|LibC::ECHONL|LibC::ICANON|LibC::ISIG|LibC::IEXTEN)
- end
-
- def cooked(*, &block)
- ttymode_yield(block, &TTY_COOKED)
- end
-
- def cooked!(*)
- ttymode(&TTY_COOKED)
- end
-
- TTY_ECHO = LibC::ECHO | LibC::ECHOE | LibC::ECHOK | LibC::ECHONL
- def echo=(echo)
- ttymode do |t|
- if echo
- t[:c_lflag] |= TTY_ECHO
- else
- t[:c_lflag] &= ~TTY_ECHO
- end
- end
- end
-
- def echo?
- (ttymode[:c_lflag] & (LibC::ECHO | LibC::ECHONL)) != 0
- end
-
- def noecho(&block)
- ttymode_yield(block) { |t| t[:c_lflag] &= ~(TTY_ECHO) }
- end
-
- def getch(*)
- raw do
- getc
- end
- end
-
- def winsize
- ws = LibC::Winsize.new
- if LibC.ioctl(self.fileno, LibC::TIOCGWINSZ, :pointer, ws.pointer) != 0
- raise SystemCallError.new("ioctl(TIOCGWINSZ)", FFI.errno)
- end
- [ ws[:ws_row], ws[:ws_col] ]
- end
-
- def winsize=(size)
- ws = LibC::Winsize.new
- if LibC.ioctl(self.fileno, LibC::TIOCGWINSZ, :pointer, ws.pointer) != 0
- raise SystemCallError.new("ioctl(TIOCGWINSZ)", FFI.errno)
- end
-
- ws[:ws_row] = size[0]
- ws[:ws_col] = size[1]
- if LibC.ioctl(self.fileno, LibC::TIOCSWINSZ, :pointer, ws.pointer) != 0
- raise SystemCallError.new("ioctl(TIOCSWINSZ)", FFI.errno)
- end
- end
-
- def iflush
- raise SystemCallError.new("tcflush(TCIFLUSH)", FFI.errno) unless LibC.tcflush(self.fileno, LibC::TCIFLUSH) == 0
- end
-
- def oflush
- raise SystemCallError.new("tcflush(TCOFLUSH)", FFI.errno) unless LibC.tcflush(self.fileno, LibC::TCOFLUSH) == 0
- end
-
- def ioflush
- raise SystemCallError.new("tcflush(TCIOFLUSH)", FFI.errno) unless LibC.tcflush(self.fileno, LibC::TCIOFLUSH) == 0
- end
-
- # TODO: Windows version uses "conin$" and "conout$" instead of /dev/tty
- def self.console(sym = nil)
- raise TypeError, "expected Symbol, got #{sym.class}" unless sym.nil? || sym.kind_of?(Symbol)
- klass = self == IO ? File : self
-
- if defined?(@console) # using ivar instead of hidden const as in MRI
- con = @console
- end
-
- if !con.kind_of?(File) || !con.open? || !con.readable? # MRI checks IO internals here
- remove_instance_variable :@console if defined?(@console)
- con = nil
- end
-
- if sym
- if sym == :close
- if con
- con.close
- remove_instance_variable :@console if defined?(@console)
- con = nil
- end
- return nil
- end
- end
-
- if con.nil?
- con = File.open('/dev/tty', 'r+')
- @console = con
- end
-
- return con
- end
- end
- true
- rescue Exception => ex
- warn "failed to load native console support: #{ex}" if $VERBOSE
- begin
- `stty 2> /dev/null`
- $?.exitstatus != 0
- rescue Exception
- nil
- end
- end
-elsif RbConfig::CONFIG['host_os'] !~ /(mswin)|(win32)|(ming)/
- result = begin
- old_stderr = $stderr.dup
- $stderr.reopen('/dev/null')
- `stty -a`
- $?.exitstatus != 0
- rescue Exception
- nil
- ensure
- $stderr.reopen(old_stderr)
- end
-end
-
-if !result || RbConfig::CONFIG['host_os'] =~ /(mswin)|(win32)|(ming)/
- warn "io/console not supported; tty will not be manipulated" if $VERBOSE
-
- # Windows version is always stubbed for now
- class IO
- def raw(*)
- yield self
- end
-
- def raw!(*)
- end
-
- def cooked(*)
- yield self
- end
-
- def cooked!(*)
- end
-
- def getch(*)
- getc
- end
-
- def echo=(echo)
- end
-
- def echo?
- true
- end
-
- def noecho
- yield self
- end
-
- def winsize
- [25, 80]
- end
-
- def winsize=(size)
- end
-
- def iflush
- end
-
- def oflush
- end
-
- def ioflush
- end
- end
-elsif !IO.method_defined?:ttymode
- warn "io/console on JRuby shells out to stty for most operations"
-
- # Non-Windows assumes stty command is available
- class IO
- if RbConfig::CONFIG['host_os'].downcase =~ /linux/ && File.exists?("/proc/#{Process.pid}/fd")
- def stty(*args)
- `stty #{args.join(' ')} < /proc/#{Process.pid}/fd/#{fileno}`
- end
- else
- def stty(*args)
- `stty #{args.join(' ')}`
- end
- end
-
- def raw(*)
- saved = stty('-g')
- stty('raw')
- yield self
- ensure
- stty(saved)
- end
-
- def raw!(*)
- stty('raw')
- end
-
- def cooked(*)
- saved = stty('-g')
- stty('-raw')
- yield self
- ensure
- stty(saved)
- end
-
- def cooked!(*)
- stty('-raw')
- end
-
- def getch(*)
- getc
- end
-
- def echo=(echo)
- stty(echo ? 'echo' : '-echo')
- end
-
- def echo?
- (stty('-a') =~ / -echo /) ? false : true
- end
-
- def noecho
- saved = stty('-g')
- stty('-echo')
- yield self
- ensure
- stty(saved)
- end
-
- # Not all systems return same format of stty -a output
- IEEE_STD_1003_2 = '(?\d+) rows; (?\d+) columns'
- UBUNTU = 'rows (?\d+); columns (?\d+)'
-
- def winsize
- match = stty('-a').match(/#{IEEE_STD_1003_2}|#{UBUNTU}/)
- [match[:rows].to_i, match[:columns].to_i]
- end
-
- def winsize=(size)
- stty("rows #{size[0]} cols #{size[1]}")
- end
-
- def iflush
- end
-
- def oflush
- end
-
- def ioflush
- end
- end
-end
diff --git a/src/main/resources/stdlib/io/linux_console.rb b/src/main/resources/stdlib/io/linux_console.rb
deleted file mode 100644
index bb6e43c..0000000
--- a/src/main/resources/stdlib/io/linux_console.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-require 'ffi'
-
-raise LoadError.new("native console only supported on i386, x86_64 and powerpc64") unless FFI::Platform::ARCH =~ /i386|x86_64|powerpc64/
-
-module IO::LibC
- extend FFI::Library
- ffi_lib FFI::Library::LIBC
-
- typedef :uint, :tcflag_t
- typedef :uint, :speed_t
-
- VINTR = 0
- VQUIT = 1
- VERASE = 2
- VKILL = 3
- VEOF = 4
- VTIME = 5
- VMIN = 6
- VSWTC = 7
- VSTART = 8
- VSTOP = 9
- VSUSP = 10
- VEOL = 11
- VREPRINT = 12
- VDISCARD = 13
- VWERASE = 14
- VLNEXT = 15
- VEOL2 = 16
-
- # c_iflag bits
- IGNBRK = 0000001
- BRKINT = 0000002
- IGNPAR = 0000004
- PARMRK = 0000010
- INPCK = 0000020
- ISTRIP = 0000040
- INLCR = 0000100
- IGNCR = 0000200
- ICRNL = 0000400
- IUCLC = 0001000
- IXON = 0002000
- IXANY = 0004000
- IXOFF = 0010000
- IMAXBEL = 0020000
- IUTF8 = 0040000
-
- # c_oflag bits
- OPOST = 0000001
- OLCUC = 0000002
- ONLCR = 0000004
- OCRNL = 0000010
- ONOCR = 0000020
- ONLRET = 0000040
- OFILL = 0000100
- OFDEL = 0000200
- NLDLY = 0000400
- NL0 = 0000000
- NL1 = 0000400
- CRDLY = 0003000
- CR0 = 0000000
- CR1 = 0001000
- CR2 = 0002000
- CR3 = 0003000
- TABDLY = 0014000
- TAB0 = 0000000
- TAB1 = 0004000
- TAB2 = 0010000
- TAB3 = 0014000
- XTABS = 0014000
- BSDLY = 0020000
- BS0 = 0000000
- BS1 = 0020000
- VTDLY = 0040000
- VT0 = 0000000
- VT1 = 0040000
- FFDLY = 0100000
- FF0 = 0000000
- FF1 = 0100000
-
- # c_cflag bit meaning
- CBAUD = 0010017
- B0 = 0000000
- B50 = 0000001
- B75 = 0000002
- B110 = 0000003
- B134 = 0000004
- B150 = 0000005
- B200 = 0000006
- B300 = 0000007
- B600 = 0000010
- B1200 = 0000011
- B1800 = 0000012
- B2400 = 0000013
- B4800 = 0000014
- B9600 = 0000015
- B19200 = 0000016
- B38400 = 0000017
- EXTA = B19200
- EXTB = B38400
- CSIZE = 0000060
- CS5 = 0000000
- CS6 = 0000020
- CS7 = 0000040
- CS8 = 0000060
- CSTOPB = 0000100
- CREAD = 0000200
- PARENB = 0000400
- PARODD = 0001000
- HUPCL = 0002000
- CLOCAL = 0004000
- CBAUDEX = 0010000
- BOTHER = 0010000
- B57600 = 0010001
- B115200 = 0010002
- B230400 = 0010003
- B460800 = 0010004
- B500000 = 0010005
- B576000 = 0010006
- B921600 = 0010007
- B1000000 = 0010010
- B1152000 = 0010011
- B1500000 = 0010012
- B2000000 = 0010013
- B2500000 = 0010014
- B3000000 = 0010015
- B3500000 = 0010016
- B4000000 = 0010017
- CIBAUD = 002003600000
- CMSPAR = 010000000000
- CRTSCTS = 020000000000
-
- IBSHIFT = 16
-
- # c_lflag bits
- ISIG = 0000001
- ICANON = 0000002
- XCASE = 0000004
- ECHO = 0000010
- ECHOE = 0000020
- ECHOK = 0000040
- ECHONL = 0000100
- NOFLSH = 0000200
- TOSTOP = 0000400
- ECHOCTL = 0001000
- ECHOPRT = 0002000
- ECHOKE = 0004000
- FLUSHO = 0010000
- PENDIN = 0040000
- IEXTEN = 0100000
-
- # tcflow() and TCXONC use these
- TCOOFF = 0
- TCOON = 1
- TCIOFF = 2
- TCION = 3
-
- # tcflush() and TCFLSH use these
- TCIFLUSH = 0
- TCOFLUSH = 1
- TCIOFLUSH = 2
-
- # tcsetattr uses these
- TCSANOW = 0
- TCSADRAIN = 1
- TCSAFLUSH = 2
- NCCS = 19
- class Termios < FFI::Struct
- layout \
- :c_iflag, :tcflag_t,
- :c_oflag, :tcflag_t,
- :c_cflag, :tcflag_t,
- :c_lflag, :tcflag_t,
- :c_line, :uchar,
- :cc_c, [ :uchar, NCCS ],
- :c_ispeed, :speed_t,
- :c_ospeed, :speed_t
- end
-
- class Winsize < FFI::Struct
- layout \
- :ws_row, :ushort,
- :ws_col, :ushort,
- :ws_xpixel, :ushort,
- :ws_ypixel, :ushort
- end
-
-
- TIOCGWINSZ = 0x5413
- TIOCSWINSZ = 0x5414
-
- attach_function :tcsetattr, [ :int, :int, Termios ], :int
- attach_function :tcgetattr, [ :int, Termios ], :int
- attach_function :cfgetispeed, [ Termios ], :speed_t
- attach_function :cfgetospeed, [ Termios ], :speed_t
- attach_function :cfsetispeed, [ Termios, :speed_t ], :int
- attach_function :cfsetospeed, [ Termios, :speed_t ], :int
- attach_function :cfmakeraw, [ Termios ], :int
- attach_function :tcflush, [ :int, :int ], :int
- attach_function :ioctl, [ :int, :ulong, :varargs ], :int
-end
diff --git a/src/main/resources/stdlib/io/nonblock.rb b/src/main/resources/stdlib/io/nonblock.rb
deleted file mode 100644
index e1cfaa2..0000000
--- a/src/main/resources/stdlib/io/nonblock.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class IO
- public
- def nonblock?
- !JRuby.reference(self).blocking?
- end
-
- def nonblock=(nonblocking)
- JRuby.reference(self).blocking = !nonblocking
- end
-
- def nonblock(nonblocking = true)
- JRuby.reference(self).blocking = !nonblocking;
- if block_given?
- begin
- yield self
- ensure
- JRuby.reference(self).blocking = nonblocking;
- end
- end
- end
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/ipaddr.rb b/src/main/resources/stdlib/ipaddr.rb
deleted file mode 100644
index 4b5f784..0000000
--- a/src/main/resources/stdlib/ipaddr.rb
+++ /dev/null
@@ -1,658 +0,0 @@
-#
-# ipaddr.rb - A class to manipulate an IP address
-#
-# Copyright (c) 2002 Hajimu UMEMOTO .
-# Copyright (c) 2007, 2009, 2012 Akinori MUSHA .
-# All rights reserved.
-#
-# You can redistribute and/or modify it under the same terms as Ruby.
-#
-# $Id$
-#
-# Contact:
-# - Akinori MUSHA (current maintainer)
-#
-# TODO:
-# - scope_id support
-#
-require 'socket'
-
-# IPAddr provides a set of methods to manipulate an IP address. Both IPv4 and
-# IPv6 are supported.
-#
-# == Example
-#
-# require 'ipaddr'
-#
-# ipaddr1 = IPAddr.new "3ffe:505:2::1"
-#
-# p ipaddr1 #=> #
-#
-# p ipaddr1.to_s #=> "3ffe:505:2::1"
-#
-# ipaddr2 = ipaddr1.mask(48) #=> #
-#
-# p ipaddr2.to_s #=> "3ffe:505:2::"
-#
-# ipaddr3 = IPAddr.new "192.168.2.0/24"
-#
-# p ipaddr3 #=> #
-
-class IPAddr
-
- # 32 bit mask for IPv4
- IN4MASK = 0xffffffff
- # 128 bit mask for IPv4
- IN6MASK = 0xffffffffffffffffffffffffffffffff
- # Format string for IPv6
- IN6FORMAT = (["%.4x"] * 8).join(':')
-
- # Regexp _internally_ used for parsing IPv4 address.
- RE_IPV4ADDRLIKE = %r{
- \A
- (\d+) \. (\d+) \. (\d+) \. (\d+)
- \z
- }x
-
- # Regexp _internally_ used for parsing IPv6 address.
- RE_IPV6ADDRLIKE_FULL = %r{
- \A
- (?:
- (?: [\da-f]{1,4} : ){7} [\da-f]{1,4}
- |
- ( (?: [\da-f]{1,4} : ){6} )
- (\d+) \. (\d+) \. (\d+) \. (\d+)
- )
- \z
- }xi
-
- # Regexp _internally_ used for parsing IPv6 address.
- RE_IPV6ADDRLIKE_COMPRESSED = %r{
- \A
- ( (?: (?: [\da-f]{1,4} : )* [\da-f]{1,4} )? )
- ::
- ( (?:
- ( (?: [\da-f]{1,4} : )* )
- (?:
- [\da-f]{1,4}
- |
- (\d+) \. (\d+) \. (\d+) \. (\d+)
- )
- )? )
- \z
- }xi
-
- # Generic IPAddr related error. Exceptions raised in this class should
- # inherit from Error.
- class Error < ArgumentError; end
-
- # Raised when the provided IP address is an invalid address.
- class InvalidAddressError < Error; end
-
- # Raised when the address family is invalid such as an address with an
- # unsupported family, an address with an inconsistent family, or an address
- # who's family cannot be determined.
- class AddressFamilyError < Error; end
-
- # Raised when the address is an invalid length.
- class InvalidPrefixError < InvalidAddressError; end
-
- # Returns the address family of this IP address.
- attr_reader :family
-
- # Creates a new ipaddr containing the given network byte ordered
- # string form of an IP address.
- def IPAddr::new_ntoh(addr)
- return IPAddr.new(IPAddr::ntop(addr))
- end
-
- # Convert a network byte ordered string form of an IP address into
- # human readable form.
- def IPAddr::ntop(addr)
- case addr.size
- when 4
- s = addr.unpack('C4').join('.')
- when 16
- s = IN6FORMAT % addr.unpack('n8')
- else
- raise AddressFamilyError, "unsupported address family"
- end
- return s
- end
-
- # Returns a new ipaddr built by bitwise AND.
- def &(other)
- return self.clone.set(@addr & coerce_other(other).to_i)
- end
-
- # Returns a new ipaddr built by bitwise OR.
- def |(other)
- return self.clone.set(@addr | coerce_other(other).to_i)
- end
-
- # Returns a new ipaddr built by bitwise right-shift.
- def >>(num)
- return self.clone.set(@addr >> num)
- end
-
- # Returns a new ipaddr built by bitwise left shift.
- def <<(num)
- return self.clone.set(addr_mask(@addr << num))
- end
-
- # Returns a new ipaddr built by bitwise negation.
- def ~
- return self.clone.set(addr_mask(~@addr))
- end
-
- # Returns true if two ipaddrs are equal.
- def ==(other)
- other = coerce_other(other)
- return @family == other.family && @addr == other.to_i
- end
-
- # Returns a new ipaddr built by masking IP address with the given
- # prefixlen/netmask. (e.g. 8, 64, "255.255.255.0", etc.)
- def mask(prefixlen)
- return self.clone.mask!(prefixlen)
- end
-
- # Returns true if the given ipaddr is in the range.
- #
- # e.g.:
- # require 'ipaddr'
- # net1 = IPAddr.new("192.168.2.0/24")
- # net2 = IPAddr.new("192.168.2.100")
- # net3 = IPAddr.new("192.168.3.0")
- # p net1.include?(net2) #=> true
- # p net1.include?(net3) #=> false
- def include?(other)
- other = coerce_other(other)
- if ipv4_mapped?
- if (@mask_addr >> 32) != 0xffffffffffffffffffffffff
- return false
- end
- mask_addr = (@mask_addr & IN4MASK)
- addr = (@addr & IN4MASK)
- family = Socket::AF_INET
- else
- mask_addr = @mask_addr
- addr = @addr
- family = @family
- end
- if other.ipv4_mapped?
- other_addr = (other.to_i & IN4MASK)
- other_family = Socket::AF_INET
- else
- other_addr = other.to_i
- other_family = other.family
- end
-
- if family != other_family
- return false
- end
- return ((addr & mask_addr) == (other_addr & mask_addr))
- end
- alias === include?
-
- # Returns the integer representation of the ipaddr.
- def to_i
- return @addr
- end
-
- # Returns a string containing the IP address representation.
- def to_s
- str = to_string
- return str if ipv4?
-
- str.gsub!(/\b0{1,3}([\da-f]+)\b/i, '\1')
- loop do
- break if str.sub!(/\A0:0:0:0:0:0:0:0\z/, '::')
- break if str.sub!(/\b0:0:0:0:0:0:0\b/, ':')
- break if str.sub!(/\b0:0:0:0:0:0\b/, ':')
- break if str.sub!(/\b0:0:0:0:0\b/, ':')
- break if str.sub!(/\b0:0:0:0\b/, ':')
- break if str.sub!(/\b0:0:0\b/, ':')
- break if str.sub!(/\b0:0\b/, ':')
- break
- end
- str.sub!(/:{3,}/, '::')
-
- if /\A::(ffff:)?([\da-f]{1,4}):([\da-f]{1,4})\z/i =~ str
- str = sprintf('::%s%d.%d.%d.%d', $1, $2.hex / 256, $2.hex % 256, $3.hex / 256, $3.hex % 256)
- end
-
- str
- end
-
- # Returns a string containing the IP address representation in
- # canonical form.
- def to_string
- return _to_string(@addr)
- end
-
- # Returns a network byte ordered string form of the IP address.
- def hton
- case @family
- when Socket::AF_INET
- return [@addr].pack('N')
- when Socket::AF_INET6
- return (0..7).map { |i|
- (@addr >> (112 - 16 * i)) & 0xffff
- }.pack('n8')
- else
- raise AddressFamilyError, "unsupported address family"
- end
- end
-
- # Returns true if the ipaddr is an IPv4 address.
- def ipv4?
- return @family == Socket::AF_INET
- end
-
- # Returns true if the ipaddr is an IPv6 address.
- def ipv6?
- return @family == Socket::AF_INET6
- end
-
- # Returns true if the ipaddr is an IPv4-mapped IPv6 address.
- def ipv4_mapped?
- return ipv6? && (@addr >> 32) == 0xffff
- end
-
- # Returns true if the ipaddr is an IPv4-compatible IPv6 address.
- def ipv4_compat?
- if !ipv6? || (@addr >> 32) != 0
- return false
- end
- a = (@addr & IN4MASK)
- return a != 0 && a != 1
- end
-
- # Returns a new ipaddr built by converting the native IPv4 address
- # into an IPv4-mapped IPv6 address.
- def ipv4_mapped
- if !ipv4?
- raise InvalidAddressError, "not an IPv4 address"
- end
- return self.clone.set(@addr | 0xffff00000000, Socket::AF_INET6)
- end
-
- # Returns a new ipaddr built by converting the native IPv4 address
- # into an IPv4-compatible IPv6 address.
- def ipv4_compat
- if !ipv4?
- raise InvalidAddressError, "not an IPv4 address"
- end
- return self.clone.set(@addr, Socket::AF_INET6)
- end
-
- # Returns a new ipaddr built by converting the IPv6 address into a
- # native IPv4 address. If the IP address is not an IPv4-mapped or
- # IPv4-compatible IPv6 address, returns self.
- def native
- if !ipv4_mapped? && !ipv4_compat?
- return self
- end
- return self.clone.set(@addr & IN4MASK, Socket::AF_INET)
- end
-
- # Returns a string for DNS reverse lookup. It returns a string in
- # RFC3172 form for an IPv6 address.
- def reverse
- case @family
- when Socket::AF_INET
- return _reverse + ".in-addr.arpa"
- when Socket::AF_INET6
- return ip6_arpa
- else
- raise AddressFamilyError, "unsupported address family"
- end
- end
-
- # Returns a string for DNS reverse lookup compatible with RFC3172.
- def ip6_arpa
- if !ipv6?
- raise InvalidAddressError, "not an IPv6 address"
- end
- return _reverse + ".ip6.arpa"
- end
-
- # Returns a string for DNS reverse lookup compatible with RFC1886.
- def ip6_int
- if !ipv6?
- raise InvalidAddressError, "not an IPv6 address"
- end
- return _reverse + ".ip6.int"
- end
-
- # Returns the successor to the ipaddr.
- def succ
- return self.clone.set(@addr + 1, @family)
- end
-
- # Compares the ipaddr with another.
- def <=>(other)
- other = coerce_other(other)
-
- return nil if other.family != @family
-
- return @addr <=> other.to_i
- end
- include Comparable
-
- # Checks equality used by Hash.
- def eql?(other)
- return self.class == other.class && self.hash == other.hash && self == other
- end
-
- # Returns a hash value used by Hash, Set, and Array classes
- def hash
- return ([@addr, @mask_addr].hash << 1) | (ipv4? ? 0 : 1)
- end
-
- # Creates a Range object for the network address.
- def to_range
- begin_addr = (@addr & @mask_addr)
-
- case @family
- when Socket::AF_INET
- end_addr = (@addr | (IN4MASK ^ @mask_addr))
- when Socket::AF_INET6
- end_addr = (@addr | (IN6MASK ^ @mask_addr))
- else
- raise AddressFamilyError, "unsupported address family"
- end
-
- return clone.set(begin_addr, @family)..clone.set(end_addr, @family)
- end
-
- # Returns a string containing a human-readable representation of the
- # ipaddr. ("#")
- def inspect
- case @family
- when Socket::AF_INET
- af = "IPv4"
- when Socket::AF_INET6
- af = "IPv6"
- else
- raise AddressFamilyError, "unsupported address family"
- end
- return sprintf("#<%s: %s:%s/%s>", self.class.name,
- af, _to_string(@addr), _to_string(@mask_addr))
- end
-
- protected
-
- # Set +@addr+, the internal stored ip address, to given +addr+. The
- # parameter +addr+ is validated using the first +family+ member,
- # which is +Socket::AF_INET+ or +Socket::AF_INET6+.
- def set(addr, *family)
- case family[0] ? family[0] : @family
- when Socket::AF_INET
- if addr < 0 || addr > IN4MASK
- raise InvalidAddressError, "invalid address"
- end
- when Socket::AF_INET6
- if addr < 0 || addr > IN6MASK
- raise InvalidAddressError, "invalid address"
- end
- else
- raise AddressFamilyError, "unsupported address family"
- end
- @addr = addr
- if family[0]
- @family = family[0]
- end
- return self
- end
-
- # Set current netmask to given mask.
- def mask!(mask)
- if mask.kind_of?(String)
- if mask =~ /^\d+$/
- prefixlen = mask.to_i
- else
- m = IPAddr.new(mask)
- if m.family != @family
- raise InvalidPrefixError, "address family is not same"
- end
- @mask_addr = m.to_i
- @addr &= @mask_addr
- return self
- end
- else
- prefixlen = mask
- end
- case @family
- when Socket::AF_INET
- if prefixlen < 0 || prefixlen > 32
- raise InvalidPrefixError, "invalid length"
- end
- masklen = 32 - prefixlen
- @mask_addr = ((IN4MASK >> masklen) << masklen)
- when Socket::AF_INET6
- if prefixlen < 0 || prefixlen > 128
- raise InvalidPrefixError, "invalid length"
- end
- masklen = 128 - prefixlen
- @mask_addr = ((IN6MASK >> masklen) << masklen)
- else
- raise AddressFamilyError, "unsupported address family"
- end
- @addr = ((@addr >> masklen) << masklen)
- return self
- end
-
- private
-
- # Creates a new ipaddr object either from a human readable IP
- # address representation in string, or from a packed in_addr value
- # followed by an address family.
- #
- # In the former case, the following are the valid formats that will
- # be recognized: "address", "address/prefixlen" and "address/mask",
- # where IPv6 address may be enclosed in square brackets (`[' and
- # `]'). If a prefixlen or a mask is specified, it returns a masked
- # IP address. Although the address family is determined
- # automatically from a specified string, you can specify one
- # explicitly by the optional second argument.
- #
- # Otherwise an IP address is generated from a packed in_addr value
- # and an address family.
- #
- # The IPAddr class defines many methods and operators, and some of
- # those, such as &, |, include? and ==, accept a string, or a packed
- # in_addr value instead of an IPAddr object.
- def initialize(addr = '::', family = Socket::AF_UNSPEC)
- if !addr.kind_of?(String)
- case family
- when Socket::AF_INET, Socket::AF_INET6
- set(addr.to_i, family)
- @mask_addr = (family == Socket::AF_INET) ? IN4MASK : IN6MASK
- return
- when Socket::AF_UNSPEC
- raise AddressFamilyError, "address family must be specified"
- else
- raise AddressFamilyError, "unsupported address family: #{family}"
- end
- end
- prefix, prefixlen = addr.split('/')
- if prefix =~ /^\[(.*)\]$/i
- prefix = $1
- family = Socket::AF_INET6
- end
- # It seems AI_NUMERICHOST doesn't do the job.
- #Socket.getaddrinfo(left, nil, Socket::AF_INET6, Socket::SOCK_STREAM, nil,
- # Socket::AI_NUMERICHOST)
- @addr = @family = nil
- if family == Socket::AF_UNSPEC || family == Socket::AF_INET
- @addr = in_addr(prefix)
- if @addr
- @family = Socket::AF_INET
- end
- end
- if !@addr && (family == Socket::AF_UNSPEC || family == Socket::AF_INET6)
- @addr = in6_addr(prefix)
- @family = Socket::AF_INET6
- end
- if family != Socket::AF_UNSPEC && @family != family
- raise AddressFamilyError, "address family mismatch"
- end
- if prefixlen
- mask!(prefixlen)
- else
- @mask_addr = (@family == Socket::AF_INET) ? IN4MASK : IN6MASK
- end
- end
-
- def coerce_other(other)
- case other
- when IPAddr
- other
- when String
- self.class.new(other)
- else
- self.class.new(other, @family)
- end
- end
-
- def in_addr(addr)
- case addr
- when Array
- octets = addr
- else
- m = RE_IPV4ADDRLIKE.match(addr) or return nil
- octets = m.captures
- end
- octets.inject(0) { |i, s|
- (n = s.to_i) < 256 or raise InvalidAddressError, "invalid address"
- s.match(/\A0./) and raise InvalidAddressError, "zero-filled number in IPv4 address is ambiguous"
- i << 8 | n
- }
- end
-
- def in6_addr(left)
- case left
- when RE_IPV6ADDRLIKE_FULL
- if $2
- addr = in_addr($~[2,4])
- left = $1 + ':'
- else
- addr = 0
- end
- right = ''
- when RE_IPV6ADDRLIKE_COMPRESSED
- if $4
- left.count(':') <= 6 or raise InvalidAddressError, "invalid address"
- addr = in_addr($~[4,4])
- left = $1
- right = $3 + '0:0'
- else
- left.count(':') <= ($1.empty? || $2.empty? ? 8 : 7) or
- raise InvalidAddressError, "invalid address"
- left = $1
- right = $2
- addr = 0
- end
- else
- raise InvalidAddressError, "invalid address"
- end
- l = left.split(':')
- r = right.split(':')
- rest = 8 - l.size - r.size
- if rest < 0
- return nil
- end
- (l + Array.new(rest, '0') + r).inject(0) { |i, s|
- i << 16 | s.hex
- } | addr
- end
-
- def addr_mask(addr)
- case @family
- when Socket::AF_INET
- return addr & IN4MASK
- when Socket::AF_INET6
- return addr & IN6MASK
- else
- raise AddressFamilyError, "unsupported address family"
- end
- end
-
- def _reverse
- case @family
- when Socket::AF_INET
- return (0..3).map { |i|
- (@addr >> (8 * i)) & 0xff
- }.join('.')
- when Socket::AF_INET6
- return ("%.32x" % @addr).reverse!.gsub!(/.(?!$)/, '\&.')
- else
- raise AddressFamilyError, "unsupported address family"
- end
- end
-
- def _to_string(addr)
- case @family
- when Socket::AF_INET
- return (0..3).map { |i|
- (addr >> (24 - 8 * i)) & 0xff
- }.join('.')
- when Socket::AF_INET6
- return (("%.32x" % addr).gsub!(/.{4}(?!$)/, '\&:'))
- else
- raise AddressFamilyError, "unsupported address family"
- end
- end
-
-end
-
-unless Socket.const_defined? :AF_INET6
- class Socket < BasicSocket
- # IPv6 protocol family
- AF_INET6 = Object.new
- end
-
- class << IPSocket
- private
-
- def valid_v6?(addr)
- case addr
- when IPAddr::RE_IPV6ADDRLIKE_FULL
- if $2
- $~[2,4].all? {|i| i.to_i < 256 }
- else
- true
- end
- when IPAddr::RE_IPV6ADDRLIKE_COMPRESSED
- if $4
- addr.count(':') <= 6 && $~[4,4].all? {|i| i.to_i < 256}
- else
- addr.count(':') <= 7
- end
- else
- false
- end
- end
-
- alias getaddress_orig getaddress
-
- public
-
- # Returns a +String+ based representation of a valid DNS hostname,
- # IPv4 or IPv6 address.
- #
- # IPSocket.getaddress 'localhost' #=> "::1"
- # IPSocket.getaddress 'broadcasthost' #=> "255.255.255.255"
- # IPSocket.getaddress 'www.ruby-lang.org' #=> "221.186.184.68"
- # IPSocket.getaddress 'www.ccc.de' #=> "2a00:1328:e102:ccc0::122"
- def getaddress(s)
- if valid_v6?(s)
- s
- else
- getaddress_orig(s)
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/irb.rb b/src/main/resources/stdlib/irb.rb
deleted file mode 100644
index 09556c8..0000000
--- a/src/main/resources/stdlib/irb.rb
+++ /dev/null
@@ -1,703 +0,0 @@
-#
-# irb.rb - irb main module
-# $Release Version: 0.9.6 $
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-require "e2mmap"
-
-require "irb/init"
-require "irb/context"
-require "irb/extend-command"
-
-require "irb/ruby-lex"
-require "irb/input-method"
-require "irb/locale"
-
-STDOUT.sync = true
-
-# IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby
-# expressions read from the standard input.
-#
-# The +irb+ command from your shell will start the interpreter.
-#
-# == Usage
-#
-# Use of irb is easy if you know Ruby.
-#
-# When executing irb, prompts are displayed as follows. Then, enter the Ruby
-# expression. An input is executed when it is syntactically complete.
-#
-# $ irb
-# irb(main):001:0> 1+2
-# #=> 3
-# irb(main):002:0> class Foo
-# irb(main):003:1> def foo
-# irb(main):004:2> print 1
-# irb(main):005:2> end
-# irb(main):006:1> end
-# #=> nil
-#
-# The Readline extension module can be used with irb. Use of Readline is
-# default if it's installed.
-#
-# == Command line options
-#
-# Usage: irb.rb [options] [programfile] [arguments]
-# -f Suppress read of ~/.irbrc
-# -m Bc mode (load mathn, fraction or matrix are available)
-# -d Set $DEBUG to true (same as `ruby -d')
-# -r load-module Same as `ruby -r'
-# -I path Specify $LOAD_PATH directory
-# -U Same as `ruby -U`
-# -E enc Same as `ruby -E`
-# -w Same as `ruby -w`
-# -W[level=2] Same as `ruby -W`
-# --inspect Use `inspect' for output (default except for bc mode)
-# --noinspect Don't use inspect for output
-# --readline Use Readline extension module
-# --noreadline Don't use Readline extension module
-# --prompt prompt-mode
-# --prompt-mode prompt-mode
-# Switch prompt mode. Pre-defined prompt modes are
-# `default', `simple', `xmp' and `inf-ruby'
-# --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
-# Suppresses --readline.
-# --simple-prompt Simple prompt mode
-# --noprompt No prompt mode
-# --tracer Display trace for each execution of commands.
-# --back-trace-limit n
-# Display backtrace top n and tail n. The default
-# value is 16.
-# --irb_debug n Set internal debug level to n (not for popular use)
-# -v, --version Print the version of irb
-#
-# == Configuration
-#
-# IRB reads from ~/.irbrc when it's invoked.
-#
-# If ~/.irbrc doesn't exist, +irb+ will try to read in the following order:
-#
-# * +.irbrc+
-# * +irb.rc+
-# * +_irbrc+
-# * $irbrc
-#
-# The following are alternatives to the command line options. To use them type
-# as follows in an +irb+ session:
-#
-# IRB.conf[:IRB_NAME]="irb"
-# IRB.conf[:MATH_MODE]=false
-# IRB.conf[:INSPECT_MODE]=nil
-# IRB.conf[:IRB_RC] = nil
-# IRB.conf[:BACK_TRACE_LIMIT]=16
-# IRB.conf[:USE_LOADER] = false
-# IRB.conf[:USE_READLINE] = nil
-# IRB.conf[:USE_TRACER] = false
-# IRB.conf[:IGNORE_SIGINT] = true
-# IRB.conf[:IGNORE_EOF] = false
-# IRB.conf[:PROMPT_MODE] = :DEFAULT
-# IRB.conf[:PROMPT] = {...}
-# IRB.conf[:DEBUG_LEVEL]=0
-#
-# === Auto indentation
-#
-# To enable auto-indent mode in irb, add the following to your +.irbrc+:
-#
-# IRB.conf[:AUTO_INDENT] = true
-#
-# === Autocompletion
-#
-# To enable autocompletion for irb, add the following to your +.irbrc+:
-#
-# require 'irb/completion'
-#
-# === History
-#
-# By default, irb disables history and will not store any commands you used.
-#
-# If you want to enable history, add the following to your +.irbrc+:
-#
-# IRB.conf[:SAVE_HISTORY] = 1000
-#
-# This will now store the last 1000 commands in ~/.irb_history.
-#
-# See IRB::Context#save_history= for more information.
-#
-# == Customizing the IRB Prompt
-#
-# In order to customize the prompt, you can change the following Hash:
-#
-# IRB.conf[:PROMPT]
-#
-# This example can be used in your +.irbrc+
-#
-# IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
-# :AUTO_INDENT => true, # enables auto-indent mode
-# :PROMPT_I => ">> ", # simple prompt
-# :PROMPT_S => nil, # prompt for continuated strings
-# :PROMPT_C => nil, # prompt for continuated statement
-# :RETURN => " ==>%s\n" # format to return value
-# }
-#
-# IRB.conf[:PROMPT_MODE] = :MY_PROMPT
-#
-# Or, invoke irb with the above prompt mode by:
-#
-# irb --prompt my-prompt
-#
-# Constants +PROMPT_I+, +PROMPT_S+ and +PROMPT_C+ specify the format. In the
-# prompt specification, some special strings are available:
-#
-# %N # command name which is running
-# %m # to_s of main object (self)
-# %M # inspect of main object (self)
-# %l # type of string(", ', /, ]), `]' is inner %w[...]
-# %NNi # indent level. NN is digits and means as same as printf("%NNd").
-# # It can be ommited
-# %NNn # line number.
-# %% # %
-#
-# For instance, the default prompt mode is defined as follows:
-#
-# IRB.conf[:PROMPT_MODE][:DEFAULT] = {
-# :PROMPT_I => "%N(%m):%03n:%i> ",
-# :PROMPT_S => "%N(%m):%03n:%i%l ",
-# :PROMPT_C => "%N(%m):%03n:%i* ",
-# :RETURN => "%s\n" # used to printf
-# }
-#
-# irb comes with a number of available modes:
-#
-# # :NULL:
-# # :PROMPT_I:
-# # :PROMPT_N:
-# # :PROMPT_S:
-# # :PROMPT_C:
-# # :RETURN: |
-# # %s
-# # :DEFAULT:
-# # :PROMPT_I: ! '%N(%m):%03n:%i> '
-# # :PROMPT_N: ! '%N(%m):%03n:%i> '
-# # :PROMPT_S: ! '%N(%m):%03n:%i%l '
-# # :PROMPT_C: ! '%N(%m):%03n:%i* '
-# # :RETURN: |
-# # => %s
-# # :CLASSIC:
-# # :PROMPT_I: ! '%N(%m):%03n:%i> '
-# # :PROMPT_N: ! '%N(%m):%03n:%i> '
-# # :PROMPT_S: ! '%N(%m):%03n:%i%l '
-# # :PROMPT_C: ! '%N(%m):%03n:%i* '
-# # :RETURN: |
-# # %s
-# # :SIMPLE:
-# # :PROMPT_I: ! '>> '
-# # :PROMPT_N: ! '>> '
-# # :PROMPT_S:
-# # :PROMPT_C: ! '?> '
-# # :RETURN: |
-# # => %s
-# # :INF_RUBY:
-# # :PROMPT_I: ! '%N(%m):%03n:%i> '
-# # :PROMPT_N:
-# # :PROMPT_S:
-# # :PROMPT_C:
-# # :RETURN: |
-# # %s
-# # :AUTO_INDENT: true
-# # :XMP:
-# # :PROMPT_I:
-# # :PROMPT_N:
-# # :PROMPT_S:
-# # :PROMPT_C:
-# # :RETURN: |2
-# # ==>%s
-#
-# == Restrictions
-#
-# Because irb evaluates input immediately after it is syntactically complete,
-# the results may be slightly different than directly using Ruby.
-#
-# == IRB Sessions
-#
-# IRB has a special feature, that allows you to manage many sessions at once.
-#
-# You can create new sessions with Irb.irb, and get a list of current sessions
-# with the +jobs+ command in the prompt.
-#
-# === Commands
-#
-# JobManager provides commands to handle the current sessions:
-#
-# jobs # List of current sessions
-# fg # Switches to the session of the given number
-# kill # Kills the session with the given number
-#
-# The +exit+ command, or ::irb_exit, will quit the current session and call any
-# exit hooks with IRB.irb_at_exit.
-#
-# A few commands for loading files within the session are also available:
-#
-# +source+::
-# Loads a given file in the current session and displays the source lines,
-# see IrbLoader#source_file
-# +irb_load+::
-# Loads the given file similarly to Kernel#load, see IrbLoader#irb_load
-# +irb_require+::
-# Loads the given file similarly to Kernel#require
-#
-# === Configuration
-#
-# The command line options, or IRB.conf, specify the default behavior of
-# Irb.irb.
-#
-# On the other hand, each conf in IRB@Command+line+options is used to
-# individually configure IRB.irb.
-#
-# If a proc is set for IRB.conf[:IRB_RC], its will be invoked after execution
-# of that proc with the context of the current session as its argument. Each
-# session can be configured using this mechanism.
-#
-# === Session variables
-#
-# There are a few variables in every Irb session that can come in handy:
-#
-# _::
-# The value command executed, as a local variable
-# __::
-# The history of evaluated commands
-# __[line_no]::
-# Returns the evaluation value at the given line number, +line_no+.
-# If +line_no+ is a negative, the return value +line_no+ many lines before
-# the most recent return value.
-#
-# === Example using IRB Sessions
-#
-# # invoke a new session
-# irb(main):001:0> irb
-# # list open sessions
-# irb.1(main):001:0> jobs
-# #0->irb on main (# : stop)
-# #1->irb#1 on main (# : running)
-#
-# # change the active session
-# irb.1(main):002:0> fg 0
-# # define class Foo in top-level session
-# irb(main):002:0> class Foo;end
-# # invoke a new session with the context of Foo
-# irb(main):003:0> irb Foo
-# # define Foo#foo
-# irb.2(Foo):001:0> def foo
-# irb.2(Foo):002:1> print 1
-# irb.2(Foo):003:1> end
-#
-# # change the active session
-# irb.2(Foo):004:0> fg 0
-# # list open sessions
-# irb(main):004:0> jobs
-# #0->irb on main (# : running)
-# #1->irb#1 on main (# : stop)
-# #2->irb#2 on Foo (# : stop)
-# # check if Foo#foo is available
-# irb(main):005:0> Foo.instance_methods #=> [:foo, ...]
-#
-# # change the active sesssion
-# irb(main):006:0> fg 2
-# # define Foo#bar in the context of Foo
-# irb.2(Foo):005:0> def bar
-# irb.2(Foo):006:1> print "bar"
-# irb.2(Foo):007:1> end
-# irb.2(Foo):010:0> Foo.instance_methods #=> [:bar, :foo, ...]
-#
-# # change the active session
-# irb.2(Foo):011:0> fg 0
-# irb(main):007:0> f = Foo.new #=> #
-# # invoke a new session with the context of f (instance of Foo)
-# irb(main):008:0> irb f
-# # list open sessions
-# irb.3():001:0> jobs
-# #0->irb on main (# : stop)
-# #1->irb#1 on main (# : stop)
-# #2->irb#2 on Foo (# : stop)
-# #3->irb#3 on # (# : running)
-# # evaluate f.foo
-# irb.3():002:0> foo #=> 1 => nil
-# # evaluate f.bar
-# irb.3():003:0> bar #=> bar => nil
-# # kill jobs 1, 2, and 3
-# irb.3():004:0> kill 1, 2, 3
-# # list open sesssions, should only include main session
-# irb(main):009:0> jobs
-# #0->irb on main (# : running)
-# # quit irb
-# irb(main):010:0> exit
-module IRB
-
- # An exception raised by IRB.irb_abort
- class Abort < Exception;end
-
- @CONF = {}
-
-
- # Displays current configuration.
- #
- # Modifing the configuration is achieved by sending a message to IRB.conf.
- #
- # See IRB@Configuration for more information.
- def IRB.conf
- @CONF
- end
-
- # Returns the current version of IRB, including release version and last
- # updated date.
- def IRB.version
- if v = @CONF[:VERSION] then return v end
-
- require "irb/version"
- rv = @RELEASE_VERSION.sub(/\.0/, "")
- @CONF[:VERSION] = format("irb %s(%s)", rv, @LAST_UPDATE_DATE)
- end
-
- # The current IRB::Context of the session, see IRB.conf
- #
- # irb
- # irb(main):001:0> IRB.CurrentContext.irb_name = "foo"
- # foo(main):002:0> IRB.conf[:MAIN_CONTEXT].irb_name #=> "foo"
- def IRB.CurrentContext
- IRB.conf[:MAIN_CONTEXT]
- end
-
- # Initializes IRB and creates a new Irb.irb object at the +TOPLEVEL_BINDING+
- def IRB.start(ap_path = nil)
- $0 = File::basename(ap_path, ".rb") if ap_path
-
- IRB.setup(ap_path)
-
- if @CONF[:SCRIPT]
- irb = Irb.new(nil, @CONF[:SCRIPT])
- else
- irb = Irb.new
- end
-
- @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
- @CONF[:MAIN_CONTEXT] = irb.context
-
- trap("SIGINT") do
- irb.signal_handle
- end
-
- begin
- catch(:IRB_EXIT) do
- irb.eval_input
- end
- ensure
- irb_at_exit
- end
- end
-
- # Calls each event hook of IRB.conf[:AT_EXIT] when the current session quits.
- def IRB.irb_at_exit
- @CONF[:AT_EXIT].each{|hook| hook.call}
- end
-
- # Quits irb
- def IRB.irb_exit(irb, ret)
- throw :IRB_EXIT, ret
- end
-
- # Aborts then interrupts irb.
- #
- # Will raise an Abort exception, or the given +exception+.
- def IRB.irb_abort(irb, exception = Abort)
- if defined? Thread
- irb.context.thread.raise exception, "abort then interrupt!"
- else
- raise exception, "abort then interrupt!"
- end
- end
-
- class Irb
- # Creates a new irb session
- def initialize(workspace = nil, input_method = nil, output_method = nil)
- @context = Context.new(self, workspace, input_method, output_method)
- @context.main.extend ExtendCommandBundle
- @signal_status = :IN_IRB
-
- @scanner = RubyLex.new
- @scanner.exception_on_syntax_error = false
- end
- # Returns the current context of this irb session
- attr_reader :context
- # The lexer used by this irb session
- attr_accessor :scanner
-
- # Evaluates input for this session.
- def eval_input
- @scanner.set_prompt do
- |ltype, indent, continue, line_no|
- if ltype
- f = @context.prompt_s
- elsif continue
- f = @context.prompt_c
- elsif indent > 0
- f = @context.prompt_n
- else
- f = @context.prompt_i
- end
- f = "" unless f
- if @context.prompting?
- @context.io.prompt = p = prompt(f, ltype, indent, line_no)
- else
- @context.io.prompt = p = ""
- end
- if @context.auto_indent_mode
- unless ltype
- ind = prompt(@context.prompt_i, ltype, indent, line_no)[/.*\z/].size +
- indent * 2 - p.size
- ind += 2 if continue
- @context.io.prompt = p + " " * ind if ind > 0
- end
- end
- end
-
- @scanner.set_input(@context.io) do
- signal_status(:IN_INPUT) do
- if l = @context.io.gets
- print l if @context.verbose?
- else
- if @context.ignore_eof? and @context.io.readable_after_eof?
- l = "\n"
- if @context.verbose?
- printf "Use \"exit\" to leave %s\n", @context.ap_name
- end
- else
- print "\n"
- end
- end
- l
- end
- end
-
- @scanner.each_top_level_statement do |line, line_no|
- signal_status(:IN_EVAL) do
- begin
- line.untaint
- @context.evaluate(line, line_no)
- output_value if @context.echo?
- exc = nil
- rescue Interrupt => exc
- rescue SystemExit, SignalException
- raise
- rescue Exception => exc
- end
- if exc
- print exc.class, ": ", exc, "\n"
- if exc.backtrace && exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
- !(SyntaxError === exc)
- irb_bug = true
- else
- irb_bug = false
- end
-
- messages = []
- lasts = []
- levels = 0
- if exc.backtrace
- for m in exc.backtrace
- m = @context.workspace.filter_backtrace(m) unless irb_bug
- if m
- if messages.size < @context.back_trace_limit
- messages.push "\tfrom "+m
- else
- lasts.push "\tfrom "+m
- if lasts.size > @context.back_trace_limit
- lasts.shift
- levels += 1
- end
- end
- end
- end
- end
- print messages.join("\n"), "\n"
- unless lasts.empty?
- printf "... %d levels...\n", levels if levels > 0
- print lasts.join("\n")
- end
- print "Maybe IRB bug!\n" if irb_bug
- end
- if $SAFE > 2
- abort "Error: irb does not work for $SAFE level higher than 2"
- end
- end
- end
- end
-
- # Evaluates the given block using the given +path+ as the Context#irb_path
- # and +name+ as the Context#irb_name.
- #
- # Used by the irb command +source+, see IRB@IRB+Sessions for more
- # information.
- def suspend_name(path = nil, name = nil)
- @context.irb_path, back_path = path, @context.irb_path if path
- @context.irb_name, back_name = name, @context.irb_name if name
- begin
- yield back_path, back_name
- ensure
- @context.irb_path = back_path if path
- @context.irb_name = back_name if name
- end
- end
-
- # Evaluates the given block using the given +workspace+ as the
- # Context#workspace.
- #
- # Used by the irb command +irb_load+, see IRB@IRB+Sessions for more
- # information.
- def suspend_workspace(workspace)
- @context.workspace, back_workspace = workspace, @context.workspace
- begin
- yield back_workspace
- ensure
- @context.workspace = back_workspace
- end
- end
-
- # Evaluates the given block using the given +input_method+ as the
- # Context#io.
- #
- # Used by the irb commands +source+ and +irb_load+, see IRB@IRB+Sessions
- # for more information.
- def suspend_input_method(input_method)
- back_io = @context.io
- @context.instance_eval{@io = input_method}
- begin
- yield back_io
- ensure
- @context.instance_eval{@io = back_io}
- end
- end
-
- # Evaluates the given block using the given +context+ as the Context.
- def suspend_context(context)
- @context, back_context = context, @context
- begin
- yield back_context
- ensure
- @context = back_context
- end
- end
-
- # Handler for the signal SIGINT, see Kernel#trap for more information.
- def signal_handle
- unless @context.ignore_sigint?
- print "\nabort!\n" if @context.verbose?
- exit
- end
-
- case @signal_status
- when :IN_INPUT
- print "^C\n"
- raise RubyLex::TerminateLineInput
- when :IN_EVAL
- IRB.irb_abort(self)
- when :IN_LOAD
- IRB.irb_abort(self, LoadAbort)
- when :IN_IRB
- # ignore
- else
- # ignore other cases as well
- end
- end
-
- # Evaluates the given block using the given +status+.
- def signal_status(status)
- return yield if @signal_status == :IN_LOAD
-
- signal_status_back = @signal_status
- @signal_status = status
- begin
- yield
- ensure
- @signal_status = signal_status_back
- end
- end
-
- def prompt(prompt, ltype, indent, line_no) # :nodoc:
- p = prompt.dup
- p.gsub!(/%([0-9]+)?([a-zA-Z])/) do
- case $2
- when "N"
- @context.irb_name
- when "m"
- @context.main.to_s
- when "M"
- @context.main.inspect
- when "l"
- ltype
- when "i"
- if $1
- format("%" + $1 + "d", indent)
- else
- indent.to_s
- end
- when "n"
- if $1
- format("%" + $1 + "d", line_no)
- else
- line_no.to_s
- end
- when "%"
- "%"
- end
- end
- p
- end
-
- def output_value # :nodoc:
- printf @context.return_format, @context.inspect_last_value
- end
-
- # Outputs the local variables to this current session, including
- # #signal_status and #context, using IRB::Locale.
- def inspect
- ary = []
- for iv in instance_variables
- case (iv = iv.to_s)
- when "@signal_status"
- ary.push format("%s=:%s", iv, @signal_status.id2name)
- when "@context"
- ary.push format("%s=%s", iv, eval(iv).__to_s__)
- else
- ary.push format("%s=%s", iv, eval(iv))
- end
- end
- format("#<%s: %s>", self.class, ary.join(", "))
- end
- end
-
- def @CONF.inspect
- IRB.version unless self[:VERSION]
-
- array = []
- for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name}
- case k
- when :MAIN_CONTEXT, :__TMP__EHV__
- array.push format("CONF[:%s]=...myself...", k.id2name)
- when :PROMPT
- s = v.collect{
- |kk, vv|
- ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"}
- format(":%s=>{%s}", kk.id2name, ss.join(", "))
- }
- array.push format("CONF[:%s]={%s}", k.id2name, s.join(", "))
- else
- array.push format("CONF[:%s]=%s", k.id2name, v.inspect)
- end
- end
- array.join("\n")
- end
-end
diff --git a/src/main/resources/stdlib/irb/cmd/chws.rb b/src/main/resources/stdlib/irb/cmd/chws.rb
deleted file mode 100644
index 8c02606..0000000
--- a/src/main/resources/stdlib/irb/cmd/chws.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# change-ws.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-require "irb/cmd/nop.rb"
-require "irb/ext/change-ws.rb"
-
-# :stopdoc:
-module IRB
- module ExtendCommand
-
- class CurrentWorkingWorkspace == === =~ > >= >> [] []= ^ ! != !~]
-
- def self.select_message(receiver, message, candidates, sep = ".")
- candidates.grep(/^#{message}/).collect do |e|
- case e
- when /^[a-zA-Z_]/
- receiver + sep + e
- when /^[0-9]/
- when *Operators
- #receiver + " " + e
- end
- end
- end
- end
-end
-
-if Readline.respond_to?("basic_word_break_characters=")
- Readline.basic_word_break_characters= " \t\n`><=;|&{("
-end
-Readline.completion_append_character = nil
-Readline.completion_proc = IRB::InputCompletor::CompletionProc
diff --git a/src/main/resources/stdlib/irb/context.rb b/src/main/resources/stdlib/irb/context.rb
deleted file mode 100644
index 9cf9600..0000000
--- a/src/main/resources/stdlib/irb/context.rb
+++ /dev/null
@@ -1,419 +0,0 @@
-#
-# irb/context.rb - irb context
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-require "irb/workspace"
-require "irb/inspector"
-
-module IRB
- # A class that wraps the current state of the irb session, including the
- # configuration of IRB.conf.
- class Context
- # Creates a new IRB context.
- #
- # The optional +input_method+ argument:
- #
- # +nil+:: uses stdin or Readline
- # +String+:: uses a File
- # +other+:: uses this as InputMethod
- def initialize(irb, workspace = nil, input_method = nil, output_method = nil)
- @irb = irb
- if workspace
- @workspace = workspace
- else
- @workspace = WorkSpace.new
- end
- @thread = Thread.current if defined? Thread
-
- # copy of default configuration
- @ap_name = IRB.conf[:AP_NAME]
- @rc = IRB.conf[:RC]
- @load_modules = IRB.conf[:LOAD_MODULES]
-
- @use_readline = IRB.conf[:USE_READLINE]
- @verbose = IRB.conf[:VERBOSE]
- @io = nil
-
- self.inspect_mode = IRB.conf[:INSPECT_MODE]
- self.math_mode = IRB.conf[:MATH_MODE] if IRB.conf[:MATH_MODE]
- self.use_tracer = IRB.conf[:USE_TRACER] if IRB.conf[:USE_TRACER]
- self.use_loader = IRB.conf[:USE_LOADER] if IRB.conf[:USE_LOADER]
- self.eval_history = IRB.conf[:EVAL_HISTORY] if IRB.conf[:EVAL_HISTORY]
-
- @ignore_sigint = IRB.conf[:IGNORE_SIGINT]
- @ignore_eof = IRB.conf[:IGNORE_EOF]
-
- @back_trace_limit = IRB.conf[:BACK_TRACE_LIMIT]
-
- self.prompt_mode = IRB.conf[:PROMPT_MODE]
-
- if IRB.conf[:SINGLE_IRB] or !defined?(IRB::JobManager)
- @irb_name = IRB.conf[:IRB_NAME]
- else
- @irb_name = IRB.conf[:IRB_NAME]+"#"+IRB.JobManager.n_jobs.to_s
- end
- @irb_path = "(" + @irb_name + ")"
-
- case input_method
- when nil
- case use_readline?
- when nil
- if (defined?(ReadlineInputMethod) && STDIN.tty? &&
- IRB.conf[:PROMPT_MODE] != :INF_RUBY)
- @io = ReadlineInputMethod.new
- else
- @io = StdioInputMethod.new
- end
- when false
- @io = StdioInputMethod.new
- when true
- if defined?(ReadlineInputMethod)
- @io = ReadlineInputMethod.new
- else
- @io = StdioInputMethod.new
- end
- end
-
- when String
- @io = FileInputMethod.new(input_method)
- @irb_name = File.basename(input_method)
- @irb_path = input_method
- else
- @io = input_method
- end
- self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]
-
- if output_method
- @output_method = output_method
- else
- @output_method = StdioOutputMethod.new
- end
-
- @echo = IRB.conf[:ECHO]
- if @echo.nil?
- @echo = true
- end
- self.debug_level = IRB.conf[:DEBUG_LEVEL]
- end
-
- # The top-level workspace, see WorkSpace#main
- def main
- @workspace.main
- end
-
- # The toplevel workspace, see #home_workspace
- attr_reader :workspace_home
- # WorkSpace in the current context
- attr_accessor :workspace
- # The current thread in this context
- attr_reader :thread
- # The current input method
- #
- # Can be either StdioInputMethod, ReadlineInputMethod, FileInputMethod or
- # other specified when the context is created. See ::new for more
- # information on +input_method+.
- attr_accessor :io
-
- # Current irb session
- attr_accessor :irb
- # A copy of the default IRB.conf[:AP_NAME]
- attr_accessor :ap_name
- # A copy of the default IRB.conf[:RC]
- attr_accessor :rc
- # A copy of the default IRB.conf[:LOAD_MODULES]
- attr_accessor :load_modules
- # Can be either name from IRB.conf[:IRB_NAME], or the number of
- # the current job set by JobManager, such as irb#2
- attr_accessor :irb_name
- # Can be either the #irb_name surrounded by parenthesis, or the
- # +input_method+ passed to Context.new
- attr_accessor :irb_path
-
- # Whether +Readline+ is enabled or not.
- #
- # A copy of the default IRB.conf[:USE_READLINE]
- #
- # See #use_readline= for more information.
- attr_reader :use_readline
- # A copy of the default IRB.conf[:INSPECT_MODE]
- attr_reader :inspect_mode
-
- # A copy of the default IRB.conf[:PROMPT_MODE]
- attr_reader :prompt_mode
- # Standard IRB prompt
- #
- # See IRB@Customizing+the+IRB+Prompt for more information.
- attr_accessor :prompt_i
- # IRB prompt for continuated strings
- #
- # See IRB@Customizing+the+IRB+Prompt for more information.
- attr_accessor :prompt_s
- # IRB prompt for continuated statement (e.g. immediately after an +if+)
- #
- # See IRB@Customizing+the+IRB+Prompt for more information.
- attr_accessor :prompt_c
- # See IRB@Customizing+the+IRB+Prompt for more information.
- attr_accessor :prompt_n
- # Can be either the default IRB.conf[:AUTO_INDENT], or the
- # mode set by #prompt_mode=
- #
- # To enable auto-indentation in irb:
- #
- # IRB.conf[:AUTO_INDENT] = true
- #
- # or
- #
- # irb_context.auto_indent_mode = true
- #
- # or
- #
- # IRB.CurrentContext.auto_indent_mode = true
- #
- # See IRB@Configuration for more information.
- attr_accessor :auto_indent_mode
- # The format of the return statement, set by #prompt_mode= using the
- # +:RETURN+ of the +mode+ passed to set the current #prompt_mode.
- attr_accessor :return_format
-
- # Whether ^C (+control-c+) will be ignored or not.
- #
- # If set to +false+, ^C will quit irb.
- #
- # If set to +true+,
- #
- # * during input: cancel input then return to top level.
- # * during execute: abandon current execution.
- attr_accessor :ignore_sigint
- # Whether ^D (+control-d+) will be ignored or not.
- #
- # If set to +false+, ^D will quit irb.
- attr_accessor :ignore_eof
- # Whether to echo the return value to output or not.
- #
- # Uses IRB.conf[:ECHO] if available, or defaults to +true+.
- #
- # puts "hello"
- # # hello
- # #=> nil
- # IRB.CurrentContext.echo = false
- # puts "omg"
- # # omg
- attr_accessor :echo
- # Whether verbose messages are displayed or not.
- #
- # A copy of the default IRB.conf[:VERBOSE]
- attr_accessor :verbose
- # The debug level of irb
- #
- # See #debug_level= for more information.
- attr_reader :debug_level
-
- # The limit of backtrace lines displayed as top +n+ and tail +n+.
- #
- # The default value is 16.
- #
- # Can also be set using the +--back-trace-limit+ command line option.
- #
- # See IRB@Command+line+options for more command line options.
- attr_accessor :back_trace_limit
-
- # Alias for #use_readline
- alias use_readline? use_readline
- # Alias for #rc
- alias rc? rc
- alias ignore_sigint? ignore_sigint
- alias ignore_eof? ignore_eof
- alias echo? echo
-
- # Returns whether messages are displayed or not.
- def verbose?
- if @verbose.nil?
- if defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
- false
- elsif !STDIN.tty? or @io.kind_of?(FileInputMethod)
- true
- else
- false
- end
- else
- @verbose
- end
- end
-
- # Whether #verbose? is +true+, and +input_method+ is either
- # StdioInputMethod or ReadlineInputMethod, see #io for more information.
- def prompting?
- verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
- (defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
- end
-
- # The return value of the last statement evaluated.
- attr_reader :last_value
-
- # Sets the return value from the last statement evaluated in this context
- # to #last_value.
- def set_last_value(value)
- @last_value = value
- @workspace.evaluate self, "_ = IRB.CurrentContext.last_value"
- end
-
- # Sets the +mode+ of the prompt in this context.
- #
- # See IRB@Customizing+the+IRB+Prompt for more information.
- def prompt_mode=(mode)
- @prompt_mode = mode
- pconf = IRB.conf[:PROMPT][mode]
- @prompt_i = pconf[:PROMPT_I]
- @prompt_s = pconf[:PROMPT_S]
- @prompt_c = pconf[:PROMPT_C]
- @prompt_n = pconf[:PROMPT_N]
- @return_format = pconf[:RETURN]
- if ai = pconf.include?(:AUTO_INDENT)
- @auto_indent_mode = ai
- else
- @auto_indent_mode = IRB.conf[:AUTO_INDENT]
- end
- end
-
- # Whether #inspect_mode is set or not, see #inspect_mode= for more detail.
- def inspect?
- @inspect_mode.nil? or @inspect_mode
- end
-
- # Whether #io uses a File for the +input_method+ passed when creating the
- # current context, see ::new
- def file_input?
- @io.class == FileInputMethod
- end
-
- # Specifies the inspect mode with +opt+:
- #
- # +true+:: display +inspect+
- # +false+:: display +to_s+
- # +nil+:: inspect mode in non-math mode,
- # non-inspect mode in math mode
- #
- # See IRB::Inspector for more information.
- #
- # Can also be set using the +--inspect+ and +--noinspect+ command line
- # options.
- #
- # See IRB@Command+line+options for more command line options.
- def inspect_mode=(opt)
-
- if i = Inspector::INSPECTORS[opt]
- @inspect_mode = opt
- @inspect_method = i
- i.init
- else
- case opt
- when nil
- if Inspector.keys_with_inspector(Inspector::INSPECTORS[true]).include?(@inspect_mode)
- self.inspect_mode = false
- elsif Inspector.keys_with_inspector(Inspector::INSPECTORS[false]).include?(@inspect_mode)
- self.inspect_mode = true
- else
- puts "Can't switch inspect mode."
- return
- end
- when /^\s*\{.*\}\s*$/
- begin
- inspector = eval "proc#{opt}"
- rescue Exception
- puts "Can't switch inspect mode(#{opt})."
- return
- end
- self.inspect_mode = inspector
- when Proc
- self.inspect_mode = IRB::Inspector(opt)
- when Inspector
- prefix = "usr%d"
- i = 1
- while Inspector::INSPECTORS[format(prefix, i)]; i += 1; end
- @inspect_mode = format(prefix, i)
- @inspect_method = opt
- Inspector.def_inspector(format(prefix, i), @inspect_method)
- else
- puts "Can't switch inspect mode(#{opt})."
- return
- end
- end
- print "Switch to#{unless @inspect_mode; ' non';end} inspect mode.\n" if verbose?
- @inspect_mode
- end
-
- # Obsolete method.
- #
- # Can be set using the +--noreadline+ and +--readline+ command line
- # options.
- #
- # See IRB@Command+line+options for more command line options.
- def use_readline=(opt)
- print "This method is obsolete."
- print "Do nothing."
- end
-
- # Sets the debug level of irb
- #
- # Can also be set using the +--irb_debug+ command line option.
- #
- # See IRB@Command+line+options for more command line options.
- def debug_level=(value)
- @debug_level = value
- RubyLex.debug_level = value
- end
-
- # Whether or not debug mode is enabled, see #debug_level=.
- def debug?
- @debug_level > 0
- end
-
- def evaluate(line, line_no) # :nodoc:
- @line_no = line_no
- set_last_value(@workspace.evaluate(self, line, irb_path, line_no))
- end
-
- def inspect_last_value # :nodoc:
- @inspect_method.inspect_value(@last_value)
- end
-
- alias __exit__ exit
- # Exits the current session, see IRB.irb_exit
- def exit(ret = 0)
- IRB.irb_exit(@irb, ret)
- end
-
- NOPRINTING_IVARS = ["@last_value"] # :nodoc:
- NO_INSPECTING_IVARS = ["@irb", "@io"] # :nodoc:
- IDNAME_IVARS = ["@prompt_mode"] # :nodoc:
-
- alias __inspect__ inspect
- def inspect # :nodoc:
- array = []
- for ivar in instance_variables.sort{|e1, e2| e1 <=> e2}
- ivar = ivar.to_s
- name = ivar.sub(/^@(.*)$/, '\1')
- val = instance_eval(ivar)
- case ivar
- when *NOPRINTING_IVARS
- array.push format("conf.%s=%s", name, "...")
- when *NO_INSPECTING_IVARS
- array.push format("conf.%s=%s", name, val.to_s)
- when *IDNAME_IVARS
- array.push format("conf.%s=:%s", name, val.id2name)
- else
- array.push format("conf.%s=%s", name, val.inspect)
- end
- end
- array.join("\n")
- end
- alias __to_s__ to_s
- alias to_s inspect
- end
-end
diff --git a/src/main/resources/stdlib/irb/ext/change-ws.rb b/src/main/resources/stdlib/irb/ext/change-ws.rb
deleted file mode 100644
index 0ae9097..0000000
--- a/src/main/resources/stdlib/irb/ext/change-ws.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# irb/ext/cb.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-module IRB # :nodoc:
- class Context
-
- # Inherited from +TOPLEVEL_BINDING+.
- def home_workspace
- if defined? @home_workspace
- @home_workspace
- else
- @home_workspace = @workspace
- end
- end
-
- # Changes the current workspace to given object or binding.
- #
- # If the optional argument is omitted, the workspace will be
- # #home_workspace which is inherited from +TOPLEVEL_BINDING+ or the main
- # object, IRB.conf[:MAIN_CONTEXT] when irb was initialized.
- #
- # See IRB::WorkSpace.new for more information.
- def change_workspace(*_main)
- if _main.empty?
- @workspace = home_workspace
- return main
- end
-
- @workspace = WorkSpace.new(_main[0])
-
- if !(class<= 0
- @contents.find{|no, val| no == idx}[1]
- else
- @contents[idx][1]
- end
- rescue NameError
- nil
- end
- end
-
- def push(no, val)
- @contents.push [no, val]
- @contents.shift if @size != 0 && @contents.size > @size
- end
-
- alias real_inspect inspect
-
- def inspect
- if @contents.empty?
- return real_inspect
- end
-
- unless (last = @contents.pop)[1].equal?(self)
- @contents.push last
- last = nil
- end
- str = @contents.collect{|no, val|
- if val.equal?(self)
- "#{no} ...self-history..."
- else
- "#{no} #{val.inspect}"
- end
- }.join("\n")
- if str == ""
- str = "Empty."
- end
- @contents.push last if last
- str
- end
- end
-end
-
-
diff --git a/src/main/resources/stdlib/irb/ext/loader.rb b/src/main/resources/stdlib/irb/ext/loader.rb
deleted file mode 100644
index 821538c..0000000
--- a/src/main/resources/stdlib/irb/ext/loader.rb
+++ /dev/null
@@ -1,128 +0,0 @@
-#
-# loader.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-
-module IRB # :nodoc:
- # Raised in the event of an exception in a file loaded from an Irb session
- class LoadAbort < Exception;end
-
- # Provides a few commands for loading files within an irb session.
- #
- # See ExtendCommandBundle for more information.
- module IrbLoader
-
- alias ruby_load load
- alias ruby_require require
-
- # Loads the given file similarly to Kernel#load
- def irb_load(fn, priv = nil)
- path = search_file_from_ruby_path(fn)
- raise LoadError, "No such file to load -- #{fn}" unless path
-
- load_file(path, priv)
- end
-
- def search_file_from_ruby_path(fn) # :nodoc:
- if /^#{Regexp.quote(File::Separator)}/ =~ fn
- return fn if File.exist?(fn)
- return nil
- end
-
- for path in $:
- if File.exist?(f = File.join(path, fn))
- return f
- end
- end
- return nil
- end
-
- # Loads a given file in the current session and displays the source lines
- #
- # See Irb#suspend_input_method for more information.
- def source_file(path)
- irb.suspend_name(path, File.basename(path)) do
- irb.suspend_input_method(FileInputMethod.new(path)) do
- |back_io|
- irb.signal_status(:IN_LOAD) do
- if back_io.kind_of?(FileInputMethod)
- irb.eval_input
- else
- begin
- irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
- end
- end
- end
-
- # Loads the given file in the current session's context and evaluates it.
- #
- # See Irb#suspend_input_method for more information.
- def load_file(path, priv = nil)
- irb.suspend_name(path, File.basename(path)) do
-
- if priv
- ws = WorkSpace.new(Module.new)
- else
- ws = WorkSpace.new
- end
- irb.suspend_workspace(ws) do
- irb.suspend_input_method(FileInputMethod.new(path)) do
- |back_io|
- irb.signal_status(:IN_LOAD) do
- if back_io.kind_of?(FileInputMethod)
- irb.eval_input
- else
- begin
- irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
- end
- end
- end
- end
-
- def old # :nodoc:
- back_io = @io
- back_path = @irb_path
- back_name = @irb_name
- back_scanner = @irb.scanner
- begin
- @io = FileInputMethod.new(path)
- @irb_name = File.basename(path)
- @irb_path = path
- @irb.signal_status(:IN_LOAD) do
- if back_io.kind_of?(FileInputMethod)
- @irb.eval_input
- else
- begin
- @irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
- ensure
- @io = back_io
- @irb_name = back_name
- @irb_path = back_path
- @irb.scanner = back_scanner
- end
- end
- end
-end
-
diff --git a/src/main/resources/stdlib/irb/ext/math-mode.rb b/src/main/resources/stdlib/irb/ext/math-mode.rb
deleted file mode 100644
index 01bd24a..0000000
--- a/src/main/resources/stdlib/irb/ext/math-mode.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# math-mode.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-require "mathn"
-
-module IRB
- class Context
- # Returns whether bc mode is enabled.
- #
- # See #math_mode=
- attr_reader :math_mode
- # Alias for #math_mode
- alias math? math_mode
-
- # Sets bc mode, which loads +lib/mathn.rb+ so fractions or matrix are
- # available.
- #
- # Also available as the +-m+ command line option.
- #
- # See IRB@Command+line+options and the unix manpage bc(1) for
- # more information.
- def math_mode=(opt)
- if @math_mode == true && !opt
- IRB.fail CantReturnToNormalMode
- return
- end
-
- @math_mode = opt
- if math_mode
- main.extend Math
- print "start math mode\n" if verbose?
- end
- end
-
- def inspect?
- @inspect_mode.nil? && !@math_mode or @inspect_mode
- end
- end
-end
-
diff --git a/src/main/resources/stdlib/irb/ext/multi-irb.rb b/src/main/resources/stdlib/irb/ext/multi-irb.rb
deleted file mode 100644
index 52f6fda..0000000
--- a/src/main/resources/stdlib/irb/ext/multi-irb.rb
+++ /dev/null
@@ -1,265 +0,0 @@
-#
-# irb/multi-irb.rb - multiple irb module
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-IRB.fail CantShiftToMultiIrbMode unless defined?(Thread)
-require "thread"
-
-module IRB
- class JobManager
-
- # Creates a new JobManager object
- def initialize
- @jobs = []
- @current_job = nil
- end
-
- # The active irb session
- attr_accessor :current_job
-
- # The total number of irb sessions, used to set +irb_name+ of the current
- # Context.
- def n_jobs
- @jobs.size
- end
-
- # Returns the thread for the given +key+ object, see #search for more
- # information.
- def thread(key)
- th, = search(key)
- th
- end
-
- # Returns the irb session for the given +key+ object, see #search for more
- # information.
- def irb(key)
- _, irb = search(key)
- irb
- end
-
- # Returns the top level thread.
- def main_thread
- @jobs[0][0]
- end
-
- # Returns the top level irb session.
- def main_irb
- @jobs[0][1]
- end
-
- # Add the given +irb+ session to the jobs Array.
- def insert(irb)
- @jobs.push [Thread.current, irb]
- end
-
- # Changes the current active irb session to the given +key+ in the jobs
- # Array.
- #
- # Raises an IrbAlreadyDead exception if the given +key+ is no longer alive.
- #
- # If the given irb session is already active, an IrbSwitchedToCurrentThread
- # exception is raised.
- def switch(key)
- th, irb = search(key)
- IRB.fail IrbAlreadyDead unless th.alive?
- IRB.fail IrbSwitchedToCurrentThread if th == Thread.current
- @current_job = irb
- th.run
- Thread.stop
- @current_job = irb(Thread.current)
- end
-
- # Terminates the irb sessions specified by the given +keys+.
- #
- # Raises an IrbAlreadyDead exception if one of the given +keys+ is already
- # terminated.
- #
- # See Thread#exit for more information.
- def kill(*keys)
- for key in keys
- th, _ = search(key)
- IRB.fail IrbAlreadyDead unless th.alive?
- th.exit
- end
- end
-
- # Returns the associated job for the given +key+.
- #
- # If given an Integer, it will return the +key+ index for the jobs Array.
- #
- # When an instance of Irb is given, it will return the irb session
- # associated with +key+.
- #
- # If given an instance of Thread, it will return the associated thread
- # +key+ using Object#=== on the jobs Array.
- #
- # Otherwise returns the irb session with the same top-level binding as the
- # given +key+.
- #
- # Raises a NoSuchJob exception if no job can be found with the given +key+.
- def search(key)
- job = case key
- when Integer
- @jobs[key]
- when Irb
- @jobs.find{|k, v| v.equal?(key)}
- when Thread
- @jobs.assoc(key)
- else
- @jobs.find{|k, v| v.context.main.equal?(key)}
- end
- IRB.fail NoSuchJob, key if job.nil?
- job
- end
-
- # Deletes the job at the given +key+.
- def delete(key)
- case key
- when Integer
- IRB.fail NoSuchJob, key unless @jobs[key]
- @jobs[key] = nil
- else
- catch(:EXISTS) do
- @jobs.each_index do
- |i|
- if @jobs[i] and (@jobs[i][0] == key ||
- @jobs[i][1] == key ||
- @jobs[i][1].context.main.equal?(key))
- @jobs[i] = nil
- throw :EXISTS
- end
- end
- IRB.fail NoSuchJob, key
- end
- end
- until assoc = @jobs.pop; end unless @jobs.empty?
- @jobs.push assoc
- end
-
- # Outputs a list of jobs, see the irb command +irb_jobs+, or +jobs+.
- def inspect
- ary = []
- @jobs.each_index do
- |i|
- th, irb = @jobs[i]
- next if th.nil?
-
- if th.alive?
- if th.stop?
- t_status = "stop"
- else
- t_status = "running"
- end
- else
- t_status = "exited"
- end
- ary.push format("#%d->%s on %s (%s: %s)",
- i,
- irb.context.irb_name,
- irb.context.main,
- th,
- t_status)
- end
- ary.join("\n")
- end
- end
-
- @JobManager = JobManager.new
-
- # The current JobManager in the session
- def IRB.JobManager
- @JobManager
- end
-
- # The current Context in this session
- def IRB.CurrentContext
- IRB.JobManager.irb(Thread.current).context
- end
-
- # Creates a new IRB session, see Irb.new.
- #
- # The optional +file+ argument is given to Context.new, along with the
- # workspace created with the remaining arguments, see WorkSpace.new
- def IRB.irb(file = nil, *main)
- workspace = WorkSpace.new(*main)
- parent_thread = Thread.current
- Thread.start do
- begin
- irb = Irb.new(workspace, file)
- rescue
- print "Subirb can't start with context(self): ", workspace.main.inspect, "\n"
- print "return to main irb\n"
- Thread.pass
- Thread.main.wakeup
- Thread.exit
- end
- @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
- @JobManager.insert(irb)
- @JobManager.current_job = irb
- begin
- system_exit = false
- catch(:IRB_EXIT) do
- irb.eval_input
- end
- rescue SystemExit
- system_exit = true
- raise
- #fail
- ensure
- unless system_exit
- @JobManager.delete(irb)
- if @JobManager.current_job == irb
- if parent_thread.alive?
- @JobManager.current_job = @JobManager.irb(parent_thread)
- parent_thread.run
- else
- @JobManager.current_job = @JobManager.main_irb
- @JobManager.main_thread.run
- end
- end
- end
- end
- end
- Thread.stop
- @JobManager.current_job = @JobManager.irb(Thread.current)
- end
-
- @CONF[:SINGLE_IRB_MODE] = false
- @JobManager.insert(@CONF[:MAIN_CONTEXT].irb)
- @JobManager.current_job = @CONF[:MAIN_CONTEXT].irb
-
- class Irb
- def signal_handle
- unless @context.ignore_sigint?
- print "\nabort!!\n" if @context.verbose?
- exit
- end
-
- case @signal_status
- when :IN_INPUT
- print "^C\n"
- IRB.JobManager.thread(self).raise RubyLex::TerminateLineInput
- when :IN_EVAL
- IRB.irb_abort(self)
- when :IN_LOAD
- IRB.irb_abort(self, LoadAbort)
- when :IN_IRB
- # ignore
- else
- # ignore other cases as well
- end
- end
- end
-
- trap("SIGINT") do
- @JobManager.current_job.signal_handle
- Thread.stop
- end
-
-end
diff --git a/src/main/resources/stdlib/irb/ext/save-history.rb b/src/main/resources/stdlib/irb/ext/save-history.rb
deleted file mode 100644
index 4477d18..0000000
--- a/src/main/resources/stdlib/irb/ext/save-history.rb
+++ /dev/null
@@ -1,103 +0,0 @@
-# save-history.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-require "readline"
-
-module IRB
- module HistorySavingAbility # :nodoc:
- end
-
- class Context
- def init_save_history# :nodoc:
- unless (class<<@io;self;end).include?(HistorySavingAbility)
- @io.extend(HistorySavingAbility)
- end
- end
-
- # A copy of the default IRB.conf[:SAVE_HISTORY]
- def save_history
- IRB.conf[:SAVE_HISTORY]
- end
-
- # Sets IRB.conf[:SAVE_HISTORY] to the given +val+ and calls
- # #init_save_history with this context.
- #
- # Will store the number of +val+ entries of history in the #history_file
- #
- # Add the following to your +.irbrc+ to change the number of history
- # entries stored to 1000:
- #
- # IRB.conf[:SAVE_HISTORY] = 1000
- def save_history=(val)
- IRB.conf[:SAVE_HISTORY] = val
- if val
- main_context = IRB.conf[:MAIN_CONTEXT]
- main_context = self unless main_context
- main_context.init_save_history
- end
- end
-
- # A copy of the default IRB.conf[:HISTORY_FILE]
- def history_file
- IRB.conf[:HISTORY_FILE]
- end
-
- # Set IRB.conf[:HISTORY_FILE] to the given +hist+.
- def history_file=(hist)
- IRB.conf[:HISTORY_FILE] = hist
- end
- end
-
- module HistorySavingAbility # :nodoc:
- include Readline
-
- def HistorySavingAbility.extended(obj)
- IRB.conf[:AT_EXIT].push proc{obj.save_history}
- obj.load_history
- obj
- end
-
- def load_history
- if history_file = IRB.conf[:HISTORY_FILE]
- history_file = File.expand_path(history_file)
- end
- history_file = IRB.rc_file("_history") unless history_file
- if File.exist?(history_file)
- open(history_file) do |f|
- f.each {|l| HISTORY << l.chomp}
- end
- end
- end
-
- def save_history
- if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
- if history_file = IRB.conf[:HISTORY_FILE]
- history_file = File.expand_path(history_file)
- end
- history_file = IRB.rc_file("_history") unless history_file
-
- # Change the permission of a file that already exists[BUG #7694]
- begin
- if File.stat(history_file).mode & 066 != 0
- File.chmod(0600, history_file)
- end
- rescue Errno::ENOENT
- rescue
- raise
- end
-
- open(history_file, 'w', 0600 ) do |f|
- hist = HISTORY.to_a
- f.puts(hist[-num..-1] || hist)
- end
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/irb/ext/tracer.rb b/src/main/resources/stdlib/irb/ext/tracer.rb
deleted file mode 100644
index c145cf5..0000000
--- a/src/main/resources/stdlib/irb/ext/tracer.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# irb/lib/tracer.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-require "tracer"
-
-module IRB
-
- # initialize tracing function
- def IRB.initialize_tracer
- Tracer.verbose = false
- Tracer.add_filter {
- |event, file, line, id, binding, *rests|
- /^#{Regexp.quote(@CONF[:IRB_LIB_PATH])}/ !~ file and
- File::basename(file) != "irb.rb"
- }
- end
-
- class Context
- # Whether Tracer is used when evaluating statements in this context.
- #
- # See +lib/tracer.rb+ for more information.
- attr_reader :use_tracer
- alias use_tracer? use_tracer
-
- # Sets whether or not to use the Tracer library when evaluating statements
- # in this context.
- #
- # See +lib/tracer.rb+ for more information.
- def use_tracer=(opt)
- if opt
- Tracer.set_get_line_procs(@irb_path) {
- |line_no, *rests|
- @io.line(line_no)
- }
- elsif !opt && @use_tracer
- Tracer.off
- end
- @use_tracer=opt
- end
- end
-
- class WorkSpace
- alias __evaluate__ evaluate
- # Evaluate the context of this workspace and use the Tracer library to
- # output the exact lines of code are being executed in chronological order.
- #
- # See +lib/tracer.rb+ for more information.
- def evaluate(context, statements, file = nil, line = nil)
- if context.use_tracer? && file != nil && line != nil
- Tracer.on
- begin
- __evaluate__(context, statements, file, line)
- ensure
- Tracer.off
- end
- else
- __evaluate__(context, statements, file || __FILE__, line || __LINE__)
- end
- end
- end
-
- IRB.initialize_tracer
-end
-
diff --git a/src/main/resources/stdlib/irb/ext/use-loader.rb b/src/main/resources/stdlib/irb/ext/use-loader.rb
deleted file mode 100644
index 99e76b7..0000000
--- a/src/main/resources/stdlib/irb/ext/use-loader.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-#
-# use-loader.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-require "irb/cmd/load"
-require "irb/ext/loader"
-
-class Object
- alias __original__load__IRB_use_loader__ load
- alias __original__require__IRB_use_loader__ require
-end
-
-module IRB
- module ExtendCommandBundle
- # Loads the given file similarly to Kernel#load, see IrbLoader#irb_load
- def irb_load(*opts, &b)
- ExtendCommand::Load.execute(irb_context, *opts, &b)
- end
- # Loads the given file similarly to Kernel#require
- def irb_require(*opts, &b)
- ExtendCommand::Require.execute(irb_context, *opts, &b)
- end
- end
-
- class Context
-
- IRB.conf[:USE_LOADER] = false
-
- # Returns whether +irb+'s own file reader method is used by
- # +load+/+require+ or not.
- #
- # This mode is globally affected (irb-wide).
- def use_loader
- IRB.conf[:USE_LOADER]
- end
-
- alias use_loader? use_loader
-
- # Sets IRB.conf[:USE_LOADER]
- #
- # See #use_loader for more information.
- def use_loader=(opt)
-
- if IRB.conf[:USE_LOADER] != opt
- IRB.conf[:USE_LOADER] = opt
- if opt
- if !$".include?("irb/cmd/load")
- end
- (class<<@workspace.main;self;end).instance_eval {
- alias_method :load, :irb_load
- alias_method :require, :irb_require
- }
- else
- (class<<@workspace.main;self;end).instance_eval {
- alias_method :load, :__original__load__IRB_use_loader__
- alias_method :require, :__original__require__IRB_use_loader__
- }
- end
- end
- print "Switch to load/require#{unless use_loader; ' non';end} trace mode.\n" if verbose?
- opt
- end
- end
-end
-
-
diff --git a/src/main/resources/stdlib/irb/ext/workspaces.rb b/src/main/resources/stdlib/irb/ext/workspaces.rb
deleted file mode 100644
index 4237037..0000000
--- a/src/main/resources/stdlib/irb/ext/workspaces.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# push-ws.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-module IRB # :nodoc:
- class Context
-
- # Size of the current WorkSpace stack
- def irb_level
- workspace_stack.size
- end
-
- # WorkSpaces in the current stack
- def workspaces
- if defined? @workspaces
- @workspaces
- else
- @workspaces = []
- end
- end
-
- # Creates a new workspace with the given object or binding, and appends it
- # onto the current #workspaces stack.
- #
- # See IRB::Context#change_workspace and IRB::WorkSpace.new for more
- # information.
- def push_workspace(*_main)
- if _main.empty?
- if workspaces.empty?
- print "No other workspace\n"
- return nil
- end
- ws = workspaces.pop
- workspaces.push @workspace
- @workspace = ws
- return workspaces
- end
-
- workspaces.push @workspace
- @workspace = WorkSpace.new(@workspace.binding, _main[0])
- if !(class<IRB.CurrentContext.exit.
- def irb_exit(ret = 0)
- irb_context.exit(ret)
- end
-
- # Displays current configuration.
- #
- # Modifing the configuration is achieved by sending a message to IRB.conf.
- def irb_context
- IRB.CurrentContext
- end
-
- @ALIASES = [
- [:context, :irb_context, NO_OVERRIDE],
- [:conf, :irb_context, NO_OVERRIDE],
- [:irb_quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
- [:exit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
- [:quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
- ]
-
- @EXTEND_COMMANDS = [
- [:irb_current_working_workspace, :CurrentWorkingWorkspace, "irb/cmd/chws",
- [:irb_print_working_workspace, OVERRIDE_ALL],
- [:irb_cwws, OVERRIDE_ALL],
- [:irb_pwws, OVERRIDE_ALL],
- [:cwws, NO_OVERRIDE],
- [:pwws, NO_OVERRIDE],
- [:irb_current_working_binding, OVERRIDE_ALL],
- [:irb_print_working_binding, OVERRIDE_ALL],
- [:irb_cwb, OVERRIDE_ALL],
- [:irb_pwb, OVERRIDE_ALL],
- ],
- [:irb_change_workspace, :ChangeWorkspace, "irb/cmd/chws",
- [:irb_chws, OVERRIDE_ALL],
- [:irb_cws, OVERRIDE_ALL],
- [:chws, NO_OVERRIDE],
- [:cws, NO_OVERRIDE],
- [:irb_change_binding, OVERRIDE_ALL],
- [:irb_cb, OVERRIDE_ALL],
- [:cb, NO_OVERRIDE]],
-
- [:irb_workspaces, :Workspaces, "irb/cmd/pushws",
- [:workspaces, NO_OVERRIDE],
- [:irb_bindings, OVERRIDE_ALL],
- [:bindings, NO_OVERRIDE]],
- [:irb_push_workspace, :PushWorkspace, "irb/cmd/pushws",
- [:irb_pushws, OVERRIDE_ALL],
- [:pushws, NO_OVERRIDE],
- [:irb_push_binding, OVERRIDE_ALL],
- [:irb_pushb, OVERRIDE_ALL],
- [:pushb, NO_OVERRIDE]],
- [:irb_pop_workspace, :PopWorkspace, "irb/cmd/pushws",
- [:irb_popws, OVERRIDE_ALL],
- [:popws, NO_OVERRIDE],
- [:irb_pop_binding, OVERRIDE_ALL],
- [:irb_popb, OVERRIDE_ALL],
- [:popb, NO_OVERRIDE]],
-
- [:irb_load, :Load, "irb/cmd/load"],
- [:irb_require, :Require, "irb/cmd/load"],
- [:irb_source, :Source, "irb/cmd/load",
- [:source, NO_OVERRIDE]],
-
- [:irb, :IrbCommand, "irb/cmd/subirb"],
- [:irb_jobs, :Jobs, "irb/cmd/subirb",
- [:jobs, NO_OVERRIDE]],
- [:irb_fg, :Foreground, "irb/cmd/subirb",
- [:fg, NO_OVERRIDE]],
- [:irb_kill, :Kill, "irb/cmd/subirb",
- [:kill, OVERRIDE_PRIVATE_ONLY]],
-
- [:irb_help, :Help, "irb/cmd/help",
- [:help, NO_OVERRIDE]],
-
- ]
-
- # Installs the default irb commands:
- #
- # +irb_current_working_workspace+:: Context#main
- # +irb_change_workspace+:: Context#change_workspace
- # +irb_workspaces+:: Context#workspaces
- # +irb_push_workspace+:: Context#push_workspace
- # +irb_pop_workspace+:: Context#pop_workspace
- # +irb_load+:: #irb_load
- # +irb_require+:: #irb_require
- # +irb_source+:: IrbLoader#source_file
- # +irb+:: IRB.irb
- # +irb_jobs+:: JobManager
- # +irb_fg+:: JobManager#switch
- # +irb_kill+:: JobManager#kill
- # +irb_help+:: IRB@Command+line+options
- def self.install_extend_commands
- for args in @EXTEND_COMMANDS
- def_extend_command(*args)
- end
- end
-
- # Evaluate the given +cmd_name+ on the given +cmd_class+ Class.
- #
- # Will also define any given +aliases+ for the method.
- #
- # The optional +load_file+ parameter will be required within the method
- # definition.
- def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
- case cmd_class
- when Symbol
- cmd_class = cmd_class.id2name
- when String
- when Class
- cmd_class = cmd_class.name
- end
-
- if load_file
- line = __LINE__; eval %[
- def #{cmd_name}(*opts, &b)
- require "#{load_file}"
- arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
- args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
- args << "*opts" if arity < 0
- args << "&block"
- args = args.join(", ")
- line = __LINE__; eval %[
- def #{cmd_name}(\#{args})
- ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
- end
- ], nil, __FILE__, line
- send :#{cmd_name}, *opts, &b
- end
- ], nil, __FILE__, line
- else
- line = __LINE__; eval %[
- def #{cmd_name}(*opts, &b)
- ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
- end
- ], nil, __FILE__, line
- end
-
- for ali, flag in aliases
- @ALIASES.push [ali, cmd_name, flag]
- end
- end
-
- # Installs alias methods for the default irb commands, see
- # ::install_extend_commands.
- def install_alias_method(to, from, override = NO_OVERRIDE)
- to = to.id2name unless to.kind_of?(String)
- from = from.id2name unless from.kind_of?(String)
-
- if override == OVERRIDE_ALL or
- (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or
- (override == NO_OVERRIDE) && !respond_to?(to, true)
- target = self
- (class << self; self; end).instance_eval{
- if target.respond_to?(to, true) &&
- !target.respond_to?(EXCB.irb_original_method_name(to), true)
- alias_method(EXCB.irb_original_method_name(to), to)
- end
- alias_method to, from
- }
- else
- print "irb: warn: can't alias #{to} from #{from}.\n"
- end
- end
-
- def self.irb_original_method_name(method_name) # :nodoc:
- "irb_" + method_name + "_org"
- end
-
- # Installs alias methods for the default irb commands on the given object
- # using #install_alias_method.
- def self.extend_object(obj)
- unless (class << obj; ancestors; end).include?(EXCB)
- super
- for ali, com, flg in @ALIASES
- obj.install_alias_method(ali, com, flg)
- end
- end
- end
-
- install_extend_commands
- end
-
- # Extends methods for the Context module
- module ContextExtender
- CE = ContextExtender # :nodoc:
-
- @EXTEND_COMMANDS = [
- [:eval_history=, "irb/ext/history.rb"],
- [:use_tracer=, "irb/ext/tracer.rb"],
- [:math_mode=, "irb/ext/math-mode.rb"],
- [:use_loader=, "irb/ext/use-loader.rb"],
- [:save_history=, "irb/ext/save-history.rb"],
- ]
-
- # Installs the default context extensions as irb commands:
- #
- # Context#eval_history=:: +irb/ext/history.rb+
- # Context#use_tracer=:: +irb/ext/tracer.rb+
- # Context#math_mode=:: +irb/ext/math-mode.rb+
- # Context#use_loader=:: +irb/ext/use-loader.rb+
- # Context#save_history=:: +irb/ext/save-history.rb+
- def self.install_extend_commands
- for args in @EXTEND_COMMANDS
- def_extend_command(*args)
- end
- end
-
- # Evaluate the given +command+ from the given +load_file+ on the Context
- # module.
- #
- # Will also define any given +aliases+ for the method.
- def self.def_extend_command(cmd_name, load_file, *aliases)
- line = __LINE__; Context.module_eval %[
- def #{cmd_name}(*opts, &b)
- Context.module_eval {remove_method(:#{cmd_name})}
- require "#{load_file}"
- send :#{cmd_name}, *opts, &b
- end
- for ali in aliases
- alias_method ali, cmd_name
- end
- ], __FILE__, line
- end
-
- CE.install_extend_commands
- end
-
- # A convenience module for extending Ruby methods.
- module MethodExtender
- # Extends the given +base_method+ with a prefix call to the given
- # +extend_method+.
- def def_pre_proc(base_method, extend_method)
- base_method = base_method.to_s
- extend_method = extend_method.to_s
-
- alias_name = new_alias_name(base_method)
- module_eval %[
- alias_method alias_name, base_method
- def #{base_method}(*opts)
- send :#{extend_method}, *opts
- send :#{alias_name}, *opts
- end
- ]
- end
-
- # Extends the given +base_method+ with a postfix call to the given
- # +extend_method+.
- def def_post_proc(base_method, extend_method)
- base_method = base_method.to_s
- extend_method = extend_method.to_s
-
- alias_name = new_alias_name(base_method)
- module_eval %[
- alias_method alias_name, base_method
- def #{base_method}(*opts)
- send :#{alias_name}, *opts
- send :#{extend_method}, *opts
- end
- ]
- end
-
- # Returns a unique method name to use as an alias for the given +name+.
- #
- # Usually returns #{prefix}#{name}#{postfix}, example:
- #
- # new_alias_name('foo') #=> __alias_of__foo__
- # def bar; end
- # new_alias_name('bar') #=> __alias_of__bar__2
- def new_alias_name(name, prefix = "__alias_of__", postfix = "__")
- base_name = "#{prefix}#{name}#{postfix}"
- all_methods = instance_methods(true) + private_instance_methods(true)
- same_methods = all_methods.grep(/^#{Regexp.quote(base_name)}[0-9]*$/)
- return base_name if same_methods.empty?
- no = same_methods.size
- while !same_methods.include?(alias_name = base_name + no)
- no += 1
- end
- alias_name
- end
- end
-end
-
diff --git a/src/main/resources/stdlib/irb/frame.rb b/src/main/resources/stdlib/irb/frame.rb
deleted file mode 100644
index 64dd63d..0000000
--- a/src/main/resources/stdlib/irb/frame.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-#
-# frame.rb -
-# $Release Version: 0.9$
-# $Revision$
-# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
-#
-# --
-#
-#
-#
-
-require "e2mmap"
-
-module IRB
- class Frame
- extend Exception2MessageMapper
- def_exception :FrameOverflow, "frame overflow"
- def_exception :FrameUnderflow, "frame underflow"
-
- # Default number of stack frames
- INIT_STACK_TIMES = 3
- # Default number of frames offset
- CALL_STACK_OFFSET = 3
-
- # Creates a new stack frame
- def initialize
- @frames = [TOPLEVEL_BINDING] * INIT_STACK_TIMES
- end
-
- # Used by Kernel#set_trace_func to register each event in the call stack
- def trace_func(event, file, line, id, binding)
- case event
- when 'call', 'class'
- @frames.push binding
- when 'return', 'end'
- @frames.pop
- end
- end
-
- # Returns the +n+ number of frames on the call stack from the last frame
- # initialized.
- #
- # Raises FrameUnderflow if there are no frames in the given stack range.
- def top(n = 0)
- bind = @frames[-(n + CALL_STACK_OFFSET)]
- Fail FrameUnderflow unless bind
- bind
- end
-
- # Returns the +n+ number of frames on the call stack from the first frame
- # initialized.
- #
- # Raises FrameOverflow if there are no frames in the given stack range.
- def bottom(n = 0)
- bind = @frames[n]
- Fail FrameOverflow unless bind
- bind
- end
-
- # Convenience method for Frame#bottom
- def Frame.bottom(n = 0)
- @backtrace.bottom(n)
- end
-
- # Convenience method for Frame#top
- def Frame.top(n = 0)
- @backtrace.top(n)
- end
-
- # Returns the binding context of the caller from the last frame initialized
- def Frame.sender
- eval "self", @backtrace.top
- end
-
- @backtrace = Frame.new
- set_trace_func proc{|event, file, line, id, binding, klass|
- @backtrace.trace_func(event, file, line, id, binding)
- }
- end
-end
diff --git a/src/main/resources/stdlib/irb/help.rb b/src/main/resources/stdlib/irb/help.rb
deleted file mode 100644
index b9ebfb1..0000000
--- a/src/main/resources/stdlib/irb/help.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# irb/help.rb - print usage module
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ishitsuka.com)
-#
-# --
-#
-#
-#
-
-require 'irb/magic-file'
-
-module IRB
- # Outputs the irb help message, see IRB@Command+line+options.
- def IRB.print_usage
- lc = IRB.conf[:LC_MESSAGES]
- path = lc.find("irb/help-message")
- space_line = false
- IRB::MagicFile.open(path){|f|
- f.each_line do |l|
- if /^\s*$/ =~ l
- lc.puts l unless space_line
- space_line = true
- next
- end
- space_line = false
-
- l.sub!(/#.*$/, "")
- next if /^\s*$/ =~ l
- lc.puts l
- end
- }
- end
-end
-
diff --git a/src/main/resources/stdlib/irb/init.rb b/src/main/resources/stdlib/irb/init.rb
deleted file mode 100644
index af9c363..0000000
--- a/src/main/resources/stdlib/irb/init.rb
+++ /dev/null
@@ -1,304 +0,0 @@
-#
-# irb/init.rb - irb initialize module
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-module IRB # :nodoc:
-
- # initialize config
- def IRB.setup(ap_path)
- IRB.init_config(ap_path)
- IRB.init_error
- IRB.parse_opts
- IRB.run_config
- IRB.load_modules
-
- unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
- IRB.fail(UndefinedPromptMode, @CONF[:PROMPT_MODE])
- end
- end
-
- # @CONF default setting
- def IRB.init_config(ap_path)
- # class instance variables
- @TRACER_INITIALIZED = false
-
- # default configurations
- unless ap_path and @CONF[:AP_NAME]
- ap_path = File.join(File.dirname(File.dirname(__FILE__)), "irb.rb")
- end
- @CONF[:AP_NAME] = File::basename(ap_path, ".rb")
-
- @CONF[:IRB_NAME] = "irb"
- @CONF[:IRB_LIB_PATH] = File.dirname(__FILE__)
-
- @CONF[:RC] = true
- @CONF[:LOAD_MODULES] = []
- @CONF[:IRB_RC] = nil
-
- @CONF[:MATH_MODE] = false
- @CONF[:USE_READLINE] = false unless defined?(ReadlineInputMethod)
- @CONF[:INSPECT_MODE] = true
- @CONF[:USE_TRACER] = false
- @CONF[:USE_LOADER] = false
- @CONF[:IGNORE_SIGINT] = true
- @CONF[:IGNORE_EOF] = false
- @CONF[:ECHO] = nil
- @CONF[:VERBOSE] = nil
-
- @CONF[:EVAL_HISTORY] = nil
- @CONF[:SAVE_HISTORY] = nil
-
- @CONF[:BACK_TRACE_LIMIT] = 16
-
- @CONF[:PROMPT] = {
- :NULL => {
- :PROMPT_I => nil,
- :PROMPT_N => nil,
- :PROMPT_S => nil,
- :PROMPT_C => nil,
- :RETURN => "%s\n"
- },
- :DEFAULT => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => "%N(%m):%03n:%i> ",
- :PROMPT_S => "%N(%m):%03n:%i%l ",
- :PROMPT_C => "%N(%m):%03n:%i* ",
- :RETURN => "=> %s\n"
- },
- :CLASSIC => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => "%N(%m):%03n:%i> ",
- :PROMPT_S => "%N(%m):%03n:%i%l ",
- :PROMPT_C => "%N(%m):%03n:%i* ",
- :RETURN => "%s\n"
- },
- :SIMPLE => {
- :PROMPT_I => ">> ",
- :PROMPT_N => ">> ",
- :PROMPT_S => nil,
- :PROMPT_C => "?> ",
- :RETURN => "=> %s\n"
- },
- :INF_RUBY => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => nil,
- :PROMPT_S => nil,
- :PROMPT_C => nil,
- :RETURN => "%s\n",
- :AUTO_INDENT => true
- },
- :XMP => {
- :PROMPT_I => nil,
- :PROMPT_N => nil,
- :PROMPT_S => nil,
- :PROMPT_C => nil,
- :RETURN => " ==>%s\n"
- }
- }
-
- @CONF[:PROMPT_MODE] = (STDIN.tty? ? :DEFAULT : :NULL)
- @CONF[:AUTO_INDENT] = false
-
- @CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING
- @CONF[:SINGLE_IRB] = false
-
- @CONF[:LC_MESSAGES] = Locale.new
-
- @CONF[:AT_EXIT] = []
-
- @CONF[:DEBUG_LEVEL] = 0
- end
-
- def IRB.init_error
- @CONF[:LC_MESSAGES].load("irb/error.rb")
- end
-
- # option analyzing
- def IRB.parse_opts
- load_path = []
- while opt = ARGV.shift
- case opt
- when "-f"
- @CONF[:RC] = false
- when "-m"
- @CONF[:MATH_MODE] = true
- when "-d"
- $DEBUG = true
- $VERBOSE = true
- when "-w"
- $VERBOSE = true
- when /^-W(.+)?/
- opt = $1 || ARGV.shift
- case opt
- when "0"
- $VERBOSE = nil
- when "1"
- $VERBOSE = false
- else
- $VERBOSE = true
- end
- when /^-r(.+)?/
- opt = $1 || ARGV.shift
- @CONF[:LOAD_MODULES].push opt if opt
- when /^-I(.+)?/
- opt = $1 || ARGV.shift
- load_path.concat(opt.split(File::PATH_SEPARATOR)) if opt
- when '-U'
- set_encoding("UTF-8", "UTF-8")
- when /^-E(.+)?/, /^--encoding(?:=(.+))?/
- opt = $1 || ARGV.shift
- set_encoding(*opt.split(':', 2))
- when "--inspect"
- if /^-/ !~ ARGV.first
- @CONF[:INSPECT_MODE] = ARGV.shift
- else
- @CONF[:INSPECT_MODE] = true
- end
- when "--noinspect"
- @CONF[:INSPECT_MODE] = false
- when "--readline"
- @CONF[:USE_READLINE] = true
- when "--noreadline"
- @CONF[:USE_READLINE] = false
- when "--echo"
- @CONF[:ECHO] = true
- when "--noecho"
- @CONF[:ECHO] = false
- when "--verbose"
- @CONF[:VERBOSE] = true
- when "--noverbose"
- @CONF[:VERBOSE] = false
- when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
- opt = $1 || ARGV.shift
- prompt_mode = opt.upcase.tr("-", "_").intern
- @CONF[:PROMPT_MODE] = prompt_mode
- when "--noprompt"
- @CONF[:PROMPT_MODE] = :NULL
- when "--inf-ruby-mode"
- @CONF[:PROMPT_MODE] = :INF_RUBY
- when "--sample-book-mode", "--simple-prompt"
- @CONF[:PROMPT_MODE] = :SIMPLE
- when "--tracer"
- @CONF[:USE_TRACER] = true
- when /^--back-trace-limit(?:=(.+))?/
- @CONF[:BACK_TRACE_LIMIT] = ($1 || ARGV.shift).to_i
- when /^--context-mode(?:=(.+))?/
- @CONF[:CONTEXT_MODE] = ($1 || ARGV.shift).to_i
- when "--single-irb"
- @CONF[:SINGLE_IRB] = true
- when /^--irb_debug(?:=(.+))?/
- @CONF[:DEBUG_LEVEL] = ($1 || ARGV.shift).to_i
- when "-v", "--version"
- print IRB.version, "\n"
- exit 0
- when "-h", "--help"
- require "irb/help"
- IRB.print_usage
- exit 0
- when "--"
- if opt = ARGV.shift
- @CONF[:SCRIPT] = opt
- $0 = opt
- end
- break
- when /^-/
- IRB.fail UnrecognizedSwitch, opt
- else
- @CONF[:SCRIPT] = opt
- $0 = opt
- break
- end
- end
- load_path.collect! do |path|
- /\A\.\// =~ path ? path : File.expand_path(path)
- end
- $LOAD_PATH.unshift(*load_path)
-
- end
-
- # running config
- def IRB.run_config
- if @CONF[:RC]
- begin
- load rc_file
- rescue LoadError, Errno::ENOENT
- rescue # StandardError, ScriptError
- print "load error: #{rc_file}\n"
- print $!.class, ": ", $!, "\n"
- for err in $@[0, $@.size - 2]
- print "\t", err, "\n"
- end
- end
- end
- end
-
- IRBRC_EXT = "rc"
- def IRB.rc_file(ext = IRBRC_EXT)
- if !@CONF[:RC_NAME_GENERATOR]
- rc_file_generators do |rcgen|
- @CONF[:RC_NAME_GENERATOR] ||= rcgen
- if File.exist?(rcgen.call(IRBRC_EXT))
- @CONF[:RC_NAME_GENERATOR] = rcgen
- break
- end
- end
- end
- case rc_file = @CONF[:RC_NAME_GENERATOR].call(ext)
- when String
- return rc_file
- else
- IRB.fail IllegalRCNameGenerator
- end
- end
-
- # enumerate possible rc-file base name generators
- def IRB.rc_file_generators
- if irbrc = ENV["IRBRC"]
- yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
- end
- if home = ENV["HOME"]
- yield proc{|rc| home+"/.irb#{rc}"}
- end
- home = Dir.pwd
- yield proc{|rc| home+"/.irb#{rc}"}
- yield proc{|rc| home+"/irb#{rc.sub(/\A_?/, '.')}"}
- yield proc{|rc| home+"/_irb#{rc}"}
- yield proc{|rc| home+"/$irb#{rc}"}
- end
-
- # loading modules
- def IRB.load_modules
- for m in @CONF[:LOAD_MODULES]
- begin
- require m
- rescue LoadError => err
- warn err.backtrace[0] << ":#{err.class}: #{err}"
- end
- end
- end
-
-
- DefaultEncodings = Struct.new(:external, :internal)
- class << IRB
- private
- def set_encoding(extern, intern = nil)
- verbose, $VERBOSE = $VERBOSE, nil
- Encoding.default_external = extern unless extern.nil? || extern.empty?
- Encoding.default_internal = intern unless intern.nil? || intern.empty?
- @CONF[:ENCODINGS] = IRB::DefaultEncodings.new(extern, intern)
- [$stdin, $stdout, $stderr].each do |io|
- io.set_encoding(extern, intern)
- end
- @CONF[:LC_MESSAGES].instance_variable_set(:@encoding, extern)
- ensure
- $VERBOSE = verbose
- end
- end
-end
diff --git a/src/main/resources/stdlib/irb/input-method.rb b/src/main/resources/stdlib/irb/input-method.rb
deleted file mode 100644
index 4ea3f58..0000000
--- a/src/main/resources/stdlib/irb/input-method.rb
+++ /dev/null
@@ -1,191 +0,0 @@
-#
-# irb/input-method.rb - input methods used irb
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-require 'irb/src_encoding'
-require 'irb/magic-file'
-
-module IRB
- STDIN_FILE_NAME = "(line)" # :nodoc:
- class InputMethod
-
- # Creates a new input method object
- def initialize(file = STDIN_FILE_NAME)
- @file_name = file
- end
- # The file name of this input method, usually given during initialization.
- attr_reader :file_name
-
- # The irb prompt associated with this input method
- attr_accessor :prompt
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- IRB.fail NotImplementedError, "gets"
- end
- public :gets
-
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- false
- end
- end
-
- class StdioInputMethod < InputMethod
- # Creates a new input method object
- def initialize
- super
- @line_no = 0
- @line = []
- @stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- @stdout = IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- end
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- print @prompt
- line = @stdin.gets
- @line[@line_no += 1] = line
- end
-
- # Whether the end of this input method has been reached, returns +true+ if
- # there is no more data to read.
- #
- # See IO#eof? for more information.
- def eof?
- @stdin.eof?
- end
-
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- true
- end
-
- # Returns the current line number for #io.
- #
- # #line counts the number of times #gets is called.
- #
- # See IO#lineno for more information.
- def line(line_no)
- @line[line_no]
- end
-
- # The external encoding for standard input.
- def encoding
- @stdin.external_encoding
- end
- end
-
- # Use a File for IO with irb, see InputMethod
- class FileInputMethod < InputMethod
- # Creates a new input method object
- def initialize(file)
- super
- @io = IRB::MagicFile.open(file)
- end
- # The file name of this input method, usually given during initialization.
- attr_reader :file_name
-
- # Whether the end of this input method has been reached, returns +true+ if
- # there is no more data to read.
- #
- # See IO#eof? for more information.
- def eof?
- @io.eof?
- end
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- print @prompt
- l = @io.gets
- l
- end
-
- # The external encoding for standard input.
- def encoding
- @io.external_encoding
- end
- end
-
- begin
- require "readline"
- class ReadlineInputMethod < InputMethod
- include Readline
- # Creates a new input method object using Readline
- def initialize
- super
-
- @line_no = 0
- @line = []
- @eof = false
-
- @stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- @stdout = IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- end
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- Readline.input = @stdin
- Readline.output = @stdout
- if l = readline(@prompt, false)
- HISTORY.push(l) if !l.empty?
- @line[@line_no += 1] = l + "\n"
- else
- @eof = true
- l
- end
- end
-
- # Whether the end of this input method has been reached, returns +true+
- # if there is no more data to read.
- #
- # See IO#eof? for more information.
- def eof?
- @eof
- end
-
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- true
- end
-
- # Returns the current line number for #io.
- #
- # #line counts the number of times #gets is called.
- #
- # See IO#lineno for more information.
- def line(line_no)
- @line[line_no]
- end
-
- # The external encoding for standard input.
- def encoding
- @stdin.external_encoding
- end
- end
- rescue LoadError
- end
-end
diff --git a/src/main/resources/stdlib/irb/inspector.rb b/src/main/resources/stdlib/irb/inspector.rb
deleted file mode 100644
index f09b129..0000000
--- a/src/main/resources/stdlib/irb/inspector.rb
+++ /dev/null
@@ -1,131 +0,0 @@
-#
-# irb/inspector.rb - inspect methods
-# $Release Version: 0.9.6$
-# $Revision: 1.19 $
-# $Date: 2002/06/11 07:51:31 $
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-module IRB # :nodoc:
-
-
- # Convenience method to create a new Inspector, using the given +inspect+
- # proc, and optional +init+ proc and passes them to Inspector.new
- #
- # irb(main):001:0> ins = IRB::Inspector(proc{ |v| "omg! #{v}" })
- # irb(main):001:0> IRB.CurrentContext.inspect_mode = ins # => omg! #
- # irb(main):001:0> "what?" #=> omg! what?
- #
- def IRB::Inspector(inspect, init = nil)
- Inspector.new(inspect, init)
- end
-
- # An irb inspector
- #
- # In order to create your own custom inspector there are two things you
- # should be aware of:
- #
- # Inspector uses #inspect_value, or +inspect_proc+, for output of return values.
- #
- # This also allows for an optional #init+, or +init_proc+, which is called
- # when the inspector is activated.
- #
- # Knowing this, you can create a rudimentary inspector as follows:
- #
- # irb(main):001:0> ins = IRB::Inspector.new(proc{ |v| "omg! #{v}" })
- # irb(main):001:0> IRB.CurrentContext.inspect_mode = ins # => omg! #
- # irb(main):001:0> "what?" #=> omg! what?
- #
- class Inspector
- # Default inspectors available to irb, this includes:
- #
- # +:pp+:: Using Kernel#pretty_inspect
- # +:yaml+:: Using YAML.dump
- # +:marshal+:: Using Marshal.dump
- INSPECTORS = {}
-
- # Determines the inspector to use where +inspector+ is one of the keys passed
- # during inspector definition.
- def self.keys_with_inspector(inspector)
- INSPECTORS.select{|k,v| v == inspector}.collect{|k, v| k}
- end
-
- # Example
- #
- # Inspector.def_inspector(key, init_p=nil){|v| v.inspect}
- # Inspector.def_inspector([key1,..], init_p=nil){|v| v.inspect}
- # Inspector.def_inspector(key, inspector)
- # Inspector.def_inspector([key1,...], inspector)
- def self.def_inspector(key, arg=nil, &block)
- if block_given?
- inspector = IRB::Inspector(block, arg)
- else
- inspector = arg
- end
-
- case key
- when Array
- for k in key
- def_inspector(k, inspector)
- end
- when Symbol
- INSPECTORS[key] = inspector
- INSPECTORS[key.to_s] = inspector
- when String
- INSPECTORS[key] = inspector
- INSPECTORS[key.intern] = inspector
- else
- INSPECTORS[key] = inspector
- end
- end
-
- # Creates a new inspector object, using the given +inspect_proc+ when
- # output return values in irb.
- def initialize(inspect_proc, init_proc = nil)
- @init = init_proc
- @inspect = inspect_proc
- end
-
- # Proc to call when the inspector is activated, good for requiring
- # dependent libraries.
- def init
- @init.call if @init
- end
-
- # Proc to call when the input is evaluated and output in irb.
- def inspect_value(v)
- @inspect.call(v)
- end
- end
-
- Inspector.def_inspector([false, :to_s, :raw]){|v| v.to_s}
- Inspector.def_inspector([true, :p, :inspect]){|v|
- begin
- v.inspect
- rescue NoMethodError
- puts "(Object doesn't support #inspect)"
- end
- }
- Inspector.def_inspector([:pp, :pretty_inspect], proc{require "pp"}){|v| v.pretty_inspect.chomp}
- Inspector.def_inspector([:yaml, :YAML], proc{require "yaml"}){|v|
- begin
- YAML.dump(v)
- rescue
- puts "(can't dump yaml. use inspect)"
- v.inspect
- end
- }
-
- Inspector.def_inspector([:marshal, :Marshal, :MARSHAL, Marshal]){|v|
- Marshal.dump(v)
- }
-end
-
-
-
-
-
diff --git a/src/main/resources/stdlib/irb/lc/error.rb b/src/main/resources/stdlib/irb/lc/error.rb
deleted file mode 100644
index c0c6c30..0000000
--- a/src/main/resources/stdlib/irb/lc/error.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# irb/lc/error.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-require "e2mmap"
-
-# :stopdoc:
-module IRB
-
- # exceptions
- extend Exception2MessageMapper
- def_exception :UnrecognizedSwitch, "Unrecognized switch: %s"
- def_exception :NotImplementedError, "Need to define `%s'"
- def_exception :CantReturnToNormalMode, "Can't return to normal mode."
- def_exception :IllegalParameter, "Invalid parameter(%s)."
- def_exception :IrbAlreadyDead, "Irb is already dead."
- def_exception :IrbSwitchedToCurrentThread, "Switched to current thread."
- def_exception :NoSuchJob, "No such job(%s)."
- def_exception :CantShiftToMultiIrbMode, "Can't shift to multi irb mode."
- def_exception :CantChangeBinding, "Can't change binding to (%s)."
- def_exception :UndefinedPromptMode, "Undefined prompt mode(%s)."
- def_exception :IllegalRCGenerator, 'Define illegal RC_NAME_GENERATOR.'
-
-end
-# :startdoc:
diff --git a/src/main/resources/stdlib/irb/lc/help-message b/src/main/resources/stdlib/irb/lc/help-message
deleted file mode 100644
index 5853693..0000000
--- a/src/main/resources/stdlib/irb/lc/help-message
+++ /dev/null
@@ -1,50 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# irb/lc/help-message.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-Usage: irb.rb [options] [programfile] [arguments]
- -f Suppress read of ~/.irbrc
- -m Bc mode (load mathn, fraction or matrix are available)
- -d Set $DEBUG to true (same as `ruby -d')
- -r load-module Same as `ruby -r'
- -I path Specify $LOAD_PATH directory
- -U Same as `ruby -U`
- -E enc Same as `ruby -E`
- -w Same as `ruby -w`
- -W[level=2] Same as `ruby -W`
- --context-mode n Set n[0-3] to method to create Binding Object,
- when new workspace was created
- --echo Show result(default)
- --noecho Don't show result
- --inspect Use `inspect' for output (default except for bc mode)
- --noinspect Don't use inspect for output
- --readline Use Readline extension module
- --noreadline Don't use Readline extension module
- --prompt prompt-mode/--prompt-mode prompt-mode
- Switch prompt mode. Pre-defined prompt modes are
- `default', `simple', `xmp' and `inf-ruby'
- --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
- Suppresses --readline.
- --sample-book-mode/--simple-prompt
- Simple prompt mode
- --noprompt No prompt mode
- --single-irb Share self with sub-irb.
- --tracer Display trace for each execution of commands.
- --back-trace-limit n
- Display backtrace top n and tail n. The default
- value is 16.
- --irb_debug n Set internal debug level to n (not for popular use)
- --verbose Show details
- --noverbose Don't show details
- -v, --version Print the version of irb
- -h, --help Print help
- -- Separate options of irb from the list of command-line args
-
-# vim:fileencoding=utf-8
diff --git a/src/main/resources/stdlib/irb/lc/ja/encoding_aliases.rb b/src/main/resources/stdlib/irb/lc/ja/encoding_aliases.rb
deleted file mode 100644
index 5bef32e..0000000
--- a/src/main/resources/stdlib/irb/lc/ja/encoding_aliases.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# :stopdoc:
-module IRB
- class Locale
- @@legacy_encoding_alias_map = {
- 'ujis' => Encoding::EUC_JP,
- 'euc' => Encoding::EUC_JP
- }.freeze
- end
-end
-# :startdoc:
diff --git a/src/main/resources/stdlib/irb/lc/ja/error.rb b/src/main/resources/stdlib/irb/lc/ja/error.rb
deleted file mode 100644
index 4f09d78..0000000
--- a/src/main/resources/stdlib/irb/lc/ja/error.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- coding: utf-8 -*-
-# irb/lc/ja/error.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-require "e2mmap"
-
-# :stopdoc:
-module IRB
- # exceptions
- extend Exception2MessageMapper
- def_exception :UnrecognizedSwitch, 'スイッチ(%s)が分りません'
- def_exception :NotImplementedError, '`%s\'の定義が必要です'
- def_exception :CantReturnToNormalMode, 'Normalモードに戻れません.'
- def_exception :IllegalParameter, 'パラメータ(%s)が間違っています.'
- def_exception :IrbAlreadyDead, 'Irbは既に死んでいます.'
- def_exception :IrbSwitchedToCurrentThread, 'カレントスレッドに切り替わりました.'
- def_exception :NoSuchJob, 'そのようなジョブ(%s)はありません.'
- def_exception :CantShiftToMultiIrbMode, 'multi-irb modeに移れません.'
- def_exception :CantChangeBinding, 'バインディング(%s)に変更できません.'
- def_exception :UndefinedPromptMode, 'プロンプトモード(%s)は定義されていません.'
- def_exception :IllegalRCNameGenerator, 'RC_NAME_GENERATORが正しく定義されていません.'
-end
-# :startdoc:
-# vim:fileencoding=utf-8
diff --git a/src/main/resources/stdlib/irb/lc/ja/help-message b/src/main/resources/stdlib/irb/lc/ja/help-message
deleted file mode 100644
index 288eb52..0000000
--- a/src/main/resources/stdlib/irb/lc/ja/help-message
+++ /dev/null
@@ -1,53 +0,0 @@
-# -*- coding: utf-8 -*-
-# irb/lc/ja/help-message.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-Usage: irb.rb [options] [programfile] [arguments]
- -f ~/.irbrc を読み込まない.
- -m bcモード(分数, 行列の計算ができる)
- -d $DEBUG をtrueにする(ruby -d と同じ)
- -r load-module ruby -r と同じ.
- -I path $LOAD_PATH に path を追加する.
- -U ruby -U と同じ.
- -E enc ruby -E と同じ.
- -w ruby -w と同じ.
- -W[level=2] ruby -W と同じ.
- --context-mode n 新しいワークスペースを作成した時に関連する Binding
- オブジェクトの作成方法を 0 から 3 のいずれかに設定する.
- --echo 実行結果を表示する(デフォルト).
- --noecho 実行結果を表示しない.
- --inspect 結果出力にinspectを用いる(bcモード以外はデフォルト).
- --noinspect 結果出力にinspectを用いない.
- --readline readlineライブラリを利用する.
- --noreadline readlineライブラリを利用しない.
- --prompt prompt-mode/--prompt-mode prompt-mode
- プロンプトモードを切替えます. 現在定義されているプ
- ロンプトモードは, default, simple, xmp, inf-rubyが
- 用意されています.
- --inf-ruby-mode emacsのinf-ruby-mode用のプロンプト表示を行なう. 特
- に指定がない限り, readlineライブラリは使わなくなる.
- --sample-book-mode/--simple-prompt
- 非常にシンプルなプロンプトを用いるモードです.
- --noprompt プロンプト表示を行なわない.
- --single-irb irb 中で self を実行して得られるオブジェクトをサ
- ブ irb と共有する.
- --tracer コマンド実行時にトレースを行なう.
- --back-trace-limit n
- バックトレース表示をバックトレースの頭から n, 後ろ
- からnだけ行なう. デフォルトは16
-
- --irb_debug n irbのデバッグレベルをnに設定する(非推奨).
-
- --verbose 詳細なメッセージを出力する.
- --noverbose 詳細なメッセージを出力しない(デフォルト).
- -v, --version irbのバージョンを表示する.
- -h, --help irb のヘルプを表示する.
- -- 以降のコマンドライン引数をオプションとして扱わない.
-
-# vim:fileencoding=utf-8
diff --git a/src/main/resources/stdlib/irb/locale.rb b/src/main/resources/stdlib/irb/locale.rb
deleted file mode 100644
index 9f40188..0000000
--- a/src/main/resources/stdlib/irb/locale.rb
+++ /dev/null
@@ -1,181 +0,0 @@
-#
-# irb/locale.rb - internationalization module
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-module IRB # :nodoc:
- class Locale
-
- LOCALE_NAME_RE = %r[
- (?[[:alpha:]]{2,3})
- (?:_ (?[[:alpha:]]{2,3}) )?
- (?:\. (?[^@]+) )?
- (?:@ (?.*) )?
- ]x
- LOCALE_DIR = "/lc/"
-
- @@legacy_encoding_alias_map = {}.freeze
-
- def initialize(locale = nil)
- @lang = @territory = @encoding_name = @modifier = nil
- @locale = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
- if m = LOCALE_NAME_RE.match(@locale)
- @lang, @territory, @encoding_name, @modifier = m[:language], m[:territory], m[:codeset], m[:modifier]
-
- if @encoding_name
- begin load 'irb/encoding_aliases.rb'; rescue LoadError; end
- if @encoding = @@legacy_encoding_alias_map[@encoding_name]
- warn "%s is obsolete. use %s" % ["#{@lang}_#{@territory}.#{@encoding_name}", "#{@lang}_#{@territory}.#{@encoding.name}"]
- end
- @encoding = Encoding.find(@encoding_name) rescue nil
- end
- end
- @encoding ||= (Encoding.find('locale') rescue Encoding::ASCII_8BIT)
- end
-
- attr_reader :lang, :territory, :encoding, :modifier
-
- def String(mes)
- mes = super(mes)
- if @encoding
- mes.encode(@encoding, undef: :replace)
- else
- mes
- end
- end
-
- def format(*opts)
- String(super(*opts))
- end
-
- def gets(*rs)
- String(super(*rs))
- end
-
- def readline(*rs)
- String(super(*rs))
- end
-
- def print(*opts)
- ary = opts.collect{|opt| String(opt)}
- super(*ary)
- end
-
- def printf(*opts)
- s = format(*opts)
- print s
- end
-
- def puts(*opts)
- ary = opts.collect{|opt| String(opt)}
- super(*ary)
- end
-
- def require(file, priv = nil)
- rex = Regexp.new("lc/#{Regexp.quote(file)}\.(so|o|sl|rb)?")
- return false if $".find{|f| f =~ rex}
-
- case file
- when /\.rb$/
- begin
- load(file, priv)
- $".push file
- return true
- rescue LoadError
- end
- when /\.(so|o|sl)$/
- return super
- end
-
- begin
- load(f = file + ".rb")
- $".push f #"
- return true
- rescue LoadError
- return ruby_require(file)
- end
- end
-
- alias toplevel_load load
-
- def load(file, priv=nil)
- found = find(file)
- if found
- return real_load(found, priv)
- else
- raise LoadError, "No such file to load -- #{file}"
- end
- end
-
- def find(file , paths = $:)
- dir = File.dirname(file)
- dir = "" if dir == "."
- base = File.basename(file)
-
- if dir.start_with?('/')
- return each_localized_path(dir, base).find{|full_path| File.readable? full_path}
- else
- return search_file(paths, dir, base)
- end
- end
-
- private
- def real_load(path, priv)
- src = MagicFile.open(path){|f| f.read}
- if priv
- eval("self", TOPLEVEL_BINDING).extend(Module.new {eval(src, nil, path)})
- else
- eval(src, TOPLEVEL_BINDING, path)
- end
- end
-
- # @param paths load paths in which IRB find a localized file.
- # @param dir directory
- # @param file basename to be localized
- #
- # typically, for the parameters and a in paths, it searches
- # ///
- def search_file(lib_paths, dir, file)
- each_localized_path(dir, file) do |lc_path|
- lib_paths.each do |libpath|
- full_path = File.join(libpath, lc_path)
- return full_path if File.readable?(full_path)
- end
- redo if defined?(Gem) and Gem.try_activate(lc_path)
- end
- nil
- end
-
- def each_localized_path(dir, file)
- return enum_for(:each_localized_path) unless block_given?
- each_sublocale do |lc|
- yield lc.nil? ? File.join(dir, LOCALE_DIR, file) : File.join(dir, LOCALE_DIR, lc, file)
- end
- end
-
- def each_sublocale
- if @lang
- if @territory
- if @encoding_name
- yield "#{@lang}_#{@territory}.#{@encoding_name}@#{@modifier}" if @modifier
- yield "#{@lang}_#{@territory}.#{@encoding_name}"
- end
- yield "#{@lang}_#{@territory}@#{@modifier}" if @modifier
- yield "#{@lang}_#{@territory}"
- end
- if @encoding_name
- yield "#{@lang}.#{@encoding_name}@#{@modifier}" if @modifier
- yield "#{@lang}.#{@encoding_name}"
- end
- yield "#{@lang}@#{@modifier}" if @modifier
- yield "#{@lang}"
- end
- yield nil
- end
- end
-end
diff --git a/src/main/resources/stdlib/irb/magic-file.rb b/src/main/resources/stdlib/irb/magic-file.rb
deleted file mode 100644
index 160681c..0000000
--- a/src/main/resources/stdlib/irb/magic-file.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-module IRB
- class << (MagicFile = Object.new)
- # see parser_magic_comment in parse.y
- ENCODING_SPEC_RE = %r"coding\s*[=:]\s*([[:alnum:]\-_]+)"
-
- def open(path)
- io = File.open(path, 'rb')
- line = io.gets
- line = io.gets if line[0,2] == "#!"
- encoding = detect_encoding(line)
- internal_encoding = encoding
- encoding ||= default_src_encoding
- begin
- io.rewind
- rescue Errno::EPIPE
- # ignore unseekable streams
- end
- io.set_encoding(encoding, internal_encoding)
-
- if block_given?
- begin
- return (yield io)
- ensure
- io.close
- end
- else
- return io
- end
- end
-
- private
- def detect_encoding(line)
- return unless line[0] == ?#
- line = line[1..-1]
- line = $1 if line[/-\*-\s*(.*?)\s*-*-$/]
- return nil unless ENCODING_SPEC_RE =~ line
- encoding = $1
- return encoding.sub(/-(?:mac|dos|unix)/i, '')
- end
- end
-end
diff --git a/src/main/resources/stdlib/irb/notifier.rb b/src/main/resources/stdlib/irb/notifier.rb
deleted file mode 100644
index d5981df..0000000
--- a/src/main/resources/stdlib/irb/notifier.rb
+++ /dev/null
@@ -1,231 +0,0 @@
-#
-# notifier.rb - output methods used by irb
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-require "e2mmap"
-require "irb/output-method"
-
-module IRB
- # An output formatter used internally by the lexer.
- module Notifier
- extend Exception2MessageMapper
- def_exception :ErrUndefinedNotifier,
- "undefined notifier level: %d is specified"
- def_exception :ErrUnrecognizedLevel,
- "unrecognized notifier level: %s is specified"
-
- # Define a new Notifier output source, returning a new CompositeNotifier
- # with the given +prefix+ and +output_method+.
- #
- # The optional +prefix+ will be appended to all objects being inspected
- # during output, using the given +output_method+ as the output source. If
- # no +output_method+ is given, StdioOutputMethod will be used, and all
- # expressions will be sent directly to STDOUT without any additional
- # formatting.
- def def_notifier(prefix = "", output_method = StdioOutputMethod.new)
- CompositeNotifier.new(prefix, output_method)
- end
- module_function :def_notifier
-
- # An abstract class, or superclass, for CompositeNotifier and
- # LeveledNotifier to inherit. It provides several wrapper methods for the
- # OutputMethod object used by the Notifier.
- class AbstractNotifier
- # Creates a new Notifier object
- def initialize(prefix, base_notifier)
- @prefix = prefix
- @base_notifier = base_notifier
- end
-
- # The +prefix+ for this Notifier, which is appended to all objects being
- # inspected during output.
- attr_reader :prefix
-
- # A wrapper method used to determine whether notifications are enabled.
- #
- # Defaults to +true+.
- def notify?
- true
- end
-
- # See OutputMethod#print for more detail.
- def print(*opts)
- @base_notifier.print prefix, *opts if notify?
- end
-
- # See OutputMethod#printn for more detail.
- def printn(*opts)
- @base_notifier.printn prefix, *opts if notify?
- end
-
- # See OutputMethod#printf for more detail.
- def printf(format, *opts)
- @base_notifier.printf(prefix + format, *opts) if notify?
- end
-
- # See OutputMethod#puts for more detail.
- def puts(*objs)
- if notify?
- @base_notifier.puts(*objs.collect{|obj| prefix + obj.to_s})
- end
- end
-
- # Same as #ppx, except it uses the #prefix given during object
- # initialization.
- # See OutputMethod#ppx for more detail.
- def pp(*objs)
- if notify?
- @base_notifier.ppx @prefix, *objs
- end
- end
-
- # Same as #pp, except it concatenates the given +prefix+ with the #prefix
- # given during object initialization.
- #
- # See OutputMethod#ppx for more detail.
- def ppx(prefix, *objs)
- if notify?
- @base_notifier.ppx @prefix+prefix, *objs
- end
- end
-
- # Execute the given block if notifications are enabled.
- def exec_if
- yield(@base_notifier) if notify?
- end
- end
-
- # A class that can be used to create a group of notifier objects with the
- # intent of representing a leveled notification system for irb.
- #
- # This class will allow you to generate other notifiers, and assign them
- # the appropriate level for output.
- #
- # The Notifier class provides a class-method Notifier.def_notifier to
- # create a new composite notifier. Using the first composite notifier
- # object you create, sibling notifiers can be initialized with
- # #def_notifier.
- class CompositeNotifier(other)
- @level <=> other.level
- end
-
- # Whether to output messages to the output method, depending on the level
- # of this notifier object.
- def notify?
- @base_notifier.level >= self
- end
- end
-
- # NoMsgNotifier is a LeveledNotifier that's used as the default notifier
- # when creating a new CompositeNotifier.
- #
- # This notifier is used as the +zero+ index, or level +0+, for
- # CompositeNotifier#notifiers, and will not output messages of any sort.
- class NoMsgNotifier [#0- +]
- # (\*|\*[1-9][0-9]*\$|[1-9][0-9]*)
- # .(\*|\*[1-9][0-9]*\$|[1-9][0-9]*|)?
- # #(hh|h|l|ll|L|q|j|z|t)
- # [diouxXeEfgGcsb%]
- def parse_printf_format(format, opts)
- return format, opts if $1.size % 2 == 1
- end
-
- # Calls #print on each element in the given +objs+, followed by a newline
- # character.
- def puts(*objs)
- for obj in objs
- print(*obj)
- print "\n"
- end
- end
-
- # Prints the given +objs+ calling Object#inspect on each.
- #
- # See #puts for more detail.
- def pp(*objs)
- puts(*objs.collect{|obj| obj.inspect})
- end
-
- # Prints the given +objs+ calling Object#inspect on each and appending the
- # given +prefix+.
- #
- # See #puts for more detail.
- def ppx(prefix, *objs)
- puts(*objs.collect{|obj| prefix+obj.inspect})
- end
-
- end
-
- # A standard output printer
- class StdioOutputMethod 0
- end
- end
- @debug_level = 0
-
- def initialize
- lex_init
- set_input(STDIN)
-
- @seek = 0
- @exp_line_no = @line_no = 1
- @base_char_no = 0
- @char_no = 0
- @rests = []
- @readed = []
- @here_readed = []
-
- @indent = 0
- @indent_stack = []
- @lex_state = EXPR_BEG
- @space_seen = false
- @here_header = false
- @post_symbeg = false
-
- @continue = false
- @line = ""
-
- @skip_space = false
- @readed_auto_clean_up = false
- @exception_on_syntax_error = true
-
- @prompt = nil
- end
-
- attr_accessor :skip_space
- attr_accessor :readed_auto_clean_up
- attr_accessor :exception_on_syntax_error
-
- attr_reader :seek
- attr_reader :char_no
- attr_reader :line_no
- attr_reader :indent
-
- # io functions
- def set_input(io, p = nil, &block)
- @io = io
- if p.respond_to?(:call)
- @input = p
- elsif block_given?
- @input = block
- else
- @input = Proc.new{@io.gets}
- end
- end
-
- def get_readed
- if idx = @readed.rindex("\n")
- @base_char_no = @readed.size - (idx + 1)
- else
- @base_char_no += @readed.size
- end
-
- readed = @readed.join("")
- @readed = []
- readed
- end
-
- def getc
- while @rests.empty?
- @rests.push nil unless buf_input
- end
- c = @rests.shift
- if @here_header
- @here_readed.push c
- else
- @readed.push c
- end
- @seek += 1
- if c == "\n"
- @line_no += 1
- @char_no = 0
- else
- @char_no += 1
- end
- c
- end
-
- def gets
- l = ""
- while c = getc
- l.concat(c)
- break if c == "\n"
- end
- return nil if l == "" and c.nil?
- l
- end
-
- def eof?
- @io.eof?
- end
-
- def getc_of_rests
- if @rests.empty?
- nil
- else
- getc
- end
- end
-
- def ungetc(c = nil)
- if @here_readed.empty?
- c2 = @readed.pop
- else
- c2 = @here_readed.pop
- end
- c = c2 unless c
- @rests.unshift c #c =
- @seek -= 1
- if c == "\n"
- @line_no -= 1
- if idx = @readed.rindex("\n")
- @char_no = idx + 1
- else
- @char_no = @base_char_no + @readed.size
- end
- else
- @char_no -= 1
- end
- end
-
- def peek_equal?(str)
- chrs = str.split(//)
- until @rests.size >= chrs.size
- return false unless buf_input
- end
- @rests[0, chrs.size] == chrs
- end
-
- def peek_match?(regexp)
- while @rests.empty?
- return false unless buf_input
- end
- regexp =~ @rests.join("")
- end
-
- def peek(i = 0)
- while @rests.size <= i
- return nil unless buf_input
- end
- @rests[i]
- end
-
- def buf_input
- prompt
- line = @input.call
- return nil unless line
- @rests.concat line.chars.to_a
- true
- end
- private :buf_input
-
- def set_prompt(p = nil, &block)
- p = block if block_given?
- if p.respond_to?(:call)
- @prompt = p
- else
- @prompt = Proc.new{print p}
- end
- end
-
- def prompt
- if @prompt
- @prompt.call(@ltype, @indent, @continue, @line_no)
- end
- end
-
- def initialize_input
- @ltype = nil
- @quoted = nil
- @indent = 0
- @indent_stack = []
- @lex_state = EXPR_BEG
- @space_seen = false
- @here_header = false
-
- @continue = false
- @post_symbeg = false
-
- prompt
-
- @line = ""
- @exp_line_no = @line_no
- end
-
- def each_top_level_statement
- initialize_input
- catch(:TERM_INPUT) do
- loop do
- begin
- @continue = false
- prompt
- unless l = lex
- throw :TERM_INPUT if @line == ''
- else
- @line.concat l
- if @ltype or @continue or @indent > 0
- next
- end
- end
- if @line != "\n"
- @line.force_encoding(@io.encoding)
- yield @line, @exp_line_no
- end
- break unless l
- @line = ''
- @exp_line_no = @line_no
-
- @indent = 0
- @indent_stack = []
- prompt
- rescue TerminateLineInput
- initialize_input
- prompt
- get_readed
- end
- end
- end
- end
-
- def lex
- until (((tk = token).kind_of?(TkNL) || tk.kind_of?(TkEND_OF_SCRIPT)) &&
- !@continue or
- tk.nil?)
- end
- line = get_readed
- if line == "" and tk.kind_of?(TkEND_OF_SCRIPT) || tk.nil?
- nil
- else
- line
- end
- end
-
- def token
- @prev_seek = @seek
- @prev_line_no = @line_no
- @prev_char_no = @char_no
- begin
- begin
- tk = @OP.match(self)
- @space_seen = tk.kind_of?(TkSPACE)
- @lex_state = EXPR_END if @post_symbeg && tk.kind_of?(TkOp)
- @post_symbeg = tk.kind_of?(TkSYMBEG)
- rescue SyntaxError
- raise if @exception_on_syntax_error
- tk = TkError.new(@seek, @line_no, @char_no)
- end
- end while @skip_space and tk.kind_of?(TkSPACE)
- if @readed_auto_clean_up
- get_readed
- end
- tk
- end
-
- ENINDENT_CLAUSE = [
- "case", "class", "def", "do", "for", "if",
- "module", "unless", "until", "while", "begin"
- ]
- DEINDENT_CLAUSE = ["end"
- ]
-
- PERCENT_LTYPE = {
- "q" => "\'",
- "Q" => "\"",
- "x" => "\`",
- "r" => "/",
- "w" => "]",
- "W" => "]",
- "i" => "]",
- "I" => "]",
- "s" => ":"
- }
-
- PERCENT_PAREN = {
- "{" => "}",
- "[" => "]",
- "<" => ">",
- "(" => ")"
- }
-
- Ltype2Token = {
- "\'" => TkSTRING,
- "\"" => TkSTRING,
- "\`" => TkXSTRING,
- "/" => TkREGEXP,
- "]" => TkDSTRING,
- ":" => TkSYMBOL
- }
- DLtype2Token = {
- "\"" => TkDSTRING,
- "\`" => TkDXSTRING,
- "/" => TkDREGEXP,
- }
-
- def lex_init()
- @OP = IRB::SLex.new
- @OP.def_rules("\0", "\004", "\032") do |op, io|
- Token(TkEND_OF_SCRIPT)
- end
-
- @OP.def_rules(" ", "\t", "\f", "\r", "\13") do |op, io|
- @space_seen = true
- while getc =~ /[ \t\f\r\13]/; end
- ungetc
- Token(TkSPACE)
- end
-
- @OP.def_rule("#") do |op, io|
- identify_comment
- end
-
- @OP.def_rule("=begin",
- proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
- |op, io|
- @ltype = "="
- until getc == "\n"; end
- until peek_equal?("=end") && peek(4) =~ /\s/
- until getc == "\n"; end
- end
- gets
- @ltype = nil
- Token(TkRD_COMMENT)
- end
-
- @OP.def_rule("\n") do |op, io|
- print "\\n\n" if RubyLex.debug?
- case @lex_state
- when EXPR_BEG, EXPR_FNAME, EXPR_DOT
- @continue = true
- else
- @continue = false
- @lex_state = EXPR_BEG
- until (@indent_stack.empty? ||
- [TkLPAREN, TkLBRACK, TkLBRACE,
- TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
- @indent_stack.pop
- end
- end
- @here_header = false
- @here_readed = []
- Token(TkNL)
- end
-
- @OP.def_rules("*", "**",
- "=", "==", "===",
- "=~", "<=>",
- "<", "<=",
- ">", ">=", ">>",
- "!", "!=", "!~") do
- |op, io|
- case @lex_state
- when EXPR_FNAME, EXPR_DOT
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_BEG
- end
- Token(op)
- end
-
- @OP.def_rules("<<") do
- |op, io|
- tk = nil
- if @lex_state != EXPR_END && @lex_state != EXPR_CLASS &&
- (@lex_state != EXPR_ARG || @space_seen)
- c = peek(0)
- if /\S/ =~ c && (/["'`]/ =~ c || /\w/ =~ c || c == "-")
- tk = identify_here_document
- end
- end
- unless tk
- tk = Token(op)
- case @lex_state
- when EXPR_FNAME, EXPR_DOT
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_BEG
- end
- end
- tk
- end
-
- @OP.def_rules("'", '"') do
- |op, io|
- identify_string(op)
- end
-
- @OP.def_rules("`") do
- |op, io|
- if @lex_state == EXPR_FNAME
- @lex_state = EXPR_END
- Token(op)
- else
- identify_string(op)
- end
- end
-
- @OP.def_rules('?') do
- |op, io|
- if @lex_state == EXPR_END
- @lex_state = EXPR_BEG
- Token(TkQUESTION)
- else
- ch = getc
- if @lex_state == EXPR_ARG && ch =~ /\s/
- ungetc
- @lex_state = EXPR_BEG;
- Token(TkQUESTION)
- else
- if (ch == '\\')
- read_escape
- end
- @lex_state = EXPR_END
- Token(TkINTEGER)
- end
- end
- end
-
- @OP.def_rules("&", "&&", "|", "||") do
- |op, io|
- @lex_state = EXPR_BEG
- Token(op)
- end
-
- @OP.def_rules("+=", "-=", "*=", "**=",
- "&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
- |op, io|
- @lex_state = EXPR_BEG
- op =~ /^(.*)=$/
- Token(TkOPASGN, $1)
- end
-
- @OP.def_rule("+@", proc{|op, io| @lex_state == EXPR_FNAME}) do
- |op, io|
- @lex_state = EXPR_ARG
- Token(op)
- end
-
- @OP.def_rule("-@", proc{|op, io| @lex_state == EXPR_FNAME}) do
- |op, io|
- @lex_state = EXPR_ARG
- Token(op)
- end
-
- @OP.def_rules("+", "-") do
- |op, io|
- catch(:RET) do
- if @lex_state == EXPR_ARG
- if @space_seen and peek(0) =~ /[0-9]/
- throw :RET, identify_number
- else
- @lex_state = EXPR_BEG
- end
- elsif @lex_state != EXPR_END and peek(0) =~ /[0-9]/
- throw :RET, identify_number
- else
- @lex_state = EXPR_BEG
- end
- Token(op)
- end
- end
-
- @OP.def_rule(".") do
- |op, io|
- @lex_state = EXPR_BEG
- if peek(0) =~ /[0-9]/
- ungetc
- identify_number
- else
- # for "obj.if" etc.
- @lex_state = EXPR_DOT
- Token(TkDOT)
- end
- end
-
- @OP.def_rules("..", "...") do
- |op, io|
- @lex_state = EXPR_BEG
- Token(op)
- end
-
- lex_int2
- end
-
- def lex_int2
- @OP.def_rules("]", "}", ")") do
- |op, io|
- @lex_state = EXPR_END
- @indent -= 1
- @indent_stack.pop
- Token(op)
- end
-
- @OP.def_rule(":") do
- |op, io|
- if @lex_state == EXPR_END || peek(0) =~ /\s/
- @lex_state = EXPR_BEG
- Token(TkCOLON)
- else
- @lex_state = EXPR_FNAME
- Token(TkSYMBEG)
- end
- end
-
- @OP.def_rule("::") do
- |op, io|
- if @lex_state == EXPR_BEG or @lex_state == EXPR_ARG && @space_seen
- @lex_state = EXPR_BEG
- Token(TkCOLON3)
- else
- @lex_state = EXPR_DOT
- Token(TkCOLON2)
- end
- end
-
- @OP.def_rule("/") do
- |op, io|
- if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
- identify_string(op)
- elsif peek(0) == '='
- getc
- @lex_state = EXPR_BEG
- Token(TkOPASGN, "/") #/)
- elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
- identify_string(op)
- else
- @lex_state = EXPR_BEG
- Token("/") #/)
- end
- end
-
- @OP.def_rules("^") do
- |op, io|
- @lex_state = EXPR_BEG
- Token("^")
- end
-
- @OP.def_rules(",") do
- |op, io|
- @lex_state = EXPR_BEG
- Token(op)
- end
-
- @OP.def_rules(";") do
- |op, io|
- @lex_state = EXPR_BEG
- until (@indent_stack.empty? ||
- [TkLPAREN, TkLBRACK, TkLBRACE,
- TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
- @indent_stack.pop
- end
- Token(op)
- end
-
- @OP.def_rule("~") do
- |op, io|
- @lex_state = EXPR_BEG
- Token("~")
- end
-
- @OP.def_rule("~@", proc{|op, io| @lex_state == EXPR_FNAME}) do
- |op, io|
- @lex_state = EXPR_BEG
- Token("~")
- end
-
- @OP.def_rule("(") do
- |op, io|
- @indent += 1
- if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
- @lex_state = EXPR_BEG
- tk_c = TkfLPAREN
- else
- @lex_state = EXPR_BEG
- tk_c = TkLPAREN
- end
- @indent_stack.push tk_c
- Token(tk_c)
- end
-
- @OP.def_rule("[]", proc{|op, io| @lex_state == EXPR_FNAME}) do
- |op, io|
- @lex_state = EXPR_ARG
- Token("[]")
- end
-
- @OP.def_rule("[]=", proc{|op, io| @lex_state == EXPR_FNAME}) do
- |op, io|
- @lex_state = EXPR_ARG
- Token("[]=")
- end
-
- @OP.def_rule("[") do
- |op, io|
- @indent += 1
- if @lex_state == EXPR_FNAME
- tk_c = TkfLBRACK
- else
- if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
- tk_c = TkLBRACK
- elsif @lex_state == EXPR_ARG && @space_seen
- tk_c = TkLBRACK
- else
- tk_c = TkfLBRACK
- end
- @lex_state = EXPR_BEG
- end
- @indent_stack.push tk_c
- Token(tk_c)
- end
-
- @OP.def_rule("{") do
- |op, io|
- @indent += 1
- if @lex_state != EXPR_END && @lex_state != EXPR_ARG
- tk_c = TkLBRACE
- else
- tk_c = TkfLBRACE
- end
- @lex_state = EXPR_BEG
- @indent_stack.push tk_c
- Token(tk_c)
- end
-
- @OP.def_rule('\\') do
- |op, io|
- if getc == "\n"
- @space_seen = true
- @continue = true
- Token(TkSPACE)
- else
- read_escape
- Token("\\")
- end
- end
-
- @OP.def_rule('%') do
- |op, io|
- if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
- identify_quotation
- elsif peek(0) == '='
- getc
- Token(TkOPASGN, :%)
- elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
- identify_quotation
- else
- @lex_state = EXPR_BEG
- Token("%") #))
- end
- end
-
- @OP.def_rule('$') do
- |op, io|
- identify_gvar
- end
-
- @OP.def_rule('@') do
- |op, io|
- if peek(0) =~ /[\w@]/
- ungetc
- identify_identifier
- else
- Token("@")
- end
- end
-
- @OP.def_rule("") do
- |op, io|
- printf "MATCH: start %s: %s\n", op, io.inspect if RubyLex.debug?
- if peek(0) =~ /[0-9]/
- t = identify_number
- elsif peek(0) =~ /[^\x00-\/:-@\[-^`{-\x7F]/
- t = identify_identifier
- end
- printf "MATCH: end %s: %s\n", op, io.inspect if RubyLex.debug?
- t
- end
-
- p @OP if RubyLex.debug?
- end
-
- def identify_gvar
- @lex_state = EXPR_END
-
- case ch = getc
- when /[~_*$?!@\/\\;,=:<>".]/ #"
- Token(TkGVAR, "$" + ch)
- when "-"
- Token(TkGVAR, "$-" + getc)
- when "&", "`", "'", "+"
- Token(TkBACK_REF, "$"+ch)
- when /[1-9]/
- while getc =~ /[0-9]/; end
- ungetc
- Token(TkNTH_REF)
- when /\w/
- ungetc
- ungetc
- identify_identifier
- else
- ungetc
- Token("$")
- end
- end
-
- def identify_identifier
- token = ""
- if peek(0) =~ /[$@]/
- token.concat(c = getc)
- if c == "@" and peek(0) == "@"
- token.concat getc
- end
- end
-
- while (ch = getc) =~ /[^\x00-\/:-@\[-^`{-\x7F]/
- print ":", ch, ":" if RubyLex.debug?
- token.concat ch
- end
- ungetc
-
- if (ch == "!" || ch == "?") && token[0,1] =~ /\w/ && peek(0) != "="
- token.concat getc
- end
-
- # almost fix token
-
- case token
- when /^\$/
- return Token(TkGVAR, token)
- when /^\@\@/
- @lex_state = EXPR_END
- # p Token(TkCVAR, token)
- return Token(TkCVAR, token)
- when /^\@/
- @lex_state = EXPR_END
- return Token(TkIVAR, token)
- end
-
- if @lex_state != EXPR_DOT
- print token, "\n" if RubyLex.debug?
-
- token_c, *trans = TkReading2Token[token]
- if token_c
- # reserved word?
-
- if (@lex_state != EXPR_BEG &&
- @lex_state != EXPR_FNAME &&
- trans[1])
- # modifiers
- token_c = TkSymbol2Token[trans[1]]
- @lex_state = trans[0]
- else
- if @lex_state != EXPR_FNAME
- if ENINDENT_CLAUSE.include?(token)
- # check for ``class = val'' etc.
- valid = true
- case token
- when "class"
- valid = false unless peek_match?(/^\s*(<<|\w|::)/)
- when "def"
- valid = false if peek_match?(/^\s*(([+\-\/*&\|^]|<<|>>|\|\||\&\&)=|\&\&|\|\|)/)
- when "do"
- valid = false if peek_match?(/^\s*([+\-\/*]?=|\*|<|>|\&)/)
- when *ENINDENT_CLAUSE
- valid = false if peek_match?(/^\s*([+\-\/*]?=|\*|<|>|\&|\|)/)
- else
- # no nothing
- end
- if valid
- if token == "do"
- if ![TkFOR, TkWHILE, TkUNTIL].include?(@indent_stack.last)
- @indent += 1
- @indent_stack.push token_c
- end
- else
- @indent += 1
- @indent_stack.push token_c
- end
- end
-
- elsif DEINDENT_CLAUSE.include?(token)
- @indent -= 1
- @indent_stack.pop
- end
- @lex_state = trans[0]
- else
- @lex_state = EXPR_END
- end
- end
- return Token(token_c, token)
- end
- end
-
- if @lex_state == EXPR_FNAME
- @lex_state = EXPR_END
- if peek(0) == '='
- token.concat getc
- end
- elsif @lex_state == EXPR_BEG || @lex_state == EXPR_DOT
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_END
- end
-
- if token[0, 1] =~ /[A-Z]/
- return Token(TkCONSTANT, token)
- elsif token[token.size - 1, 1] =~ /[!?]/
- return Token(TkFID, token)
- else
- return Token(TkIDENTIFIER, token)
- end
- end
-
- def identify_here_document
- ch = getc
- if ch == "-"
- ch = getc
- indent = true
- end
- if /['"`]/ =~ ch
- lt = ch
- quoted = ""
- while (c = getc) && c != lt
- quoted.concat c
- end
- else
- lt = '"'
- quoted = ch.dup
- while (c = getc) && c =~ /\w/
- quoted.concat c
- end
- ungetc
- end
-
- ltback, @ltype = @ltype, lt
- reserve = []
- while ch = getc
- reserve.push ch
- if ch == "\\"
- reserve.push ch = getc
- elsif ch == "\n"
- break
- end
- end
-
- @here_header = false
-
- line = ""
- while ch = getc
- if ch == "\n"
- if line == quoted
- break
- end
- line = ""
- else
- line.concat ch unless indent && line == "" && /\s/ =~ ch
- if @ltype != "'" && ch == "#" && peek(0) == "{"
- identify_string_dvar
- end
- end
- end
-
- @here_header = true
- @here_readed.concat reserve
- while ch = reserve.pop
- ungetc ch
- end
-
- @ltype = ltback
- @lex_state = EXPR_END
- Token(Ltype2Token[lt])
- end
-
- def identify_quotation
- ch = getc
- if lt = PERCENT_LTYPE[ch]
- ch = getc
- elsif ch =~ /\W/
- lt = "\""
- else
- RubyLex.fail SyntaxError, "unknown type of %string"
- end
- @quoted = ch unless @quoted = PERCENT_PAREN[ch]
- identify_string(lt, @quoted)
- end
-
- def identify_number
- @lex_state = EXPR_END
-
- if peek(0) == "0" && peek(1) !~ /[.eE]/
- getc
- case peek(0)
- when /[xX]/
- ch = getc
- match = /[0-9a-fA-F_]/
- when /[bB]/
- ch = getc
- match = /[01_]/
- when /[oO]/
- ch = getc
- match = /[0-7_]/
- when /[dD]/
- ch = getc
- match = /[0-9_]/
- when /[0-7]/
- match = /[0-7_]/
- when /[89]/
- RubyLex.fail SyntaxError, "Invalid octal digit"
- else
- return Token(TkINTEGER)
- end
-
- len0 = true
- non_digit = false
- while ch = getc
- if match =~ ch
- if ch == "_"
- if non_digit
- RubyLex.fail SyntaxError, "trailing `#{ch}' in number"
- else
- non_digit = ch
- end
- else
- non_digit = false
- len0 = false
- end
- else
- ungetc
- if len0
- RubyLex.fail SyntaxError, "numeric literal without digits"
- end
- if non_digit
- RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
- end
- break
- end
- end
- return Token(TkINTEGER)
- end
-
- type = TkINTEGER
- allow_point = true
- allow_e = true
- non_digit = false
- while ch = getc
- case ch
- when /[0-9]/
- non_digit = false
- when "_"
- non_digit = ch
- when allow_point && "."
- if non_digit
- RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
- end
- type = TkFLOAT
- if peek(0) !~ /[0-9]/
- type = TkINTEGER
- ungetc
- break
- end
- allow_point = false
- when allow_e && "e", allow_e && "E"
- if non_digit
- RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
- end
- type = TkFLOAT
- if peek(0) =~ /[+-]/
- getc
- end
- allow_e = false
- allow_point = false
- non_digit = ch
- else
- if non_digit
- RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
- end
- ungetc
- break
- end
- end
- Token(type)
- end
-
- def identify_string(ltype, quoted = ltype)
- @ltype = ltype
- @quoted = quoted
- subtype = nil
- begin
- nest = 0
- while ch = getc
- if @quoted == ch and nest == 0
- break
- elsif @ltype != "'" && ch == "#" && peek(0) == "{"
- identify_string_dvar
- elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
- subtype = true
- elsif ch == '\\' and @ltype == "'" #'
- case ch = getc
- when "\\", "\n", "'"
- else
- ungetc
- end
- elsif ch == '\\' #'
- read_escape
- end
- if PERCENT_PAREN.values.include?(@quoted)
- if PERCENT_PAREN[ch] == @quoted
- nest += 1
- elsif ch == @quoted
- nest -= 1
- end
- end
- end
- if @ltype == "/"
- while /[imxoesun]/ =~ peek(0)
- getc
- end
- end
- if subtype
- Token(DLtype2Token[ltype])
- else
- Token(Ltype2Token[ltype])
- end
- ensure
- @ltype = nil
- @quoted = nil
- @lex_state = EXPR_END
- end
- end
-
- def identify_string_dvar
- begin
- getc
-
- reserve_continue = @continue
- reserve_ltype = @ltype
- reserve_indent = @indent
- reserve_indent_stack = @indent_stack
- reserve_state = @lex_state
- reserve_quoted = @quoted
-
- @ltype = nil
- @quoted = nil
- @indent = 0
- @indent_stack = []
- @lex_state = EXPR_BEG
-
- loop do
- @continue = false
- prompt
- tk = token
- if @ltype or @continue or @indent >= 0
- next
- end
- break if tk.kind_of?(TkRBRACE)
- end
- ensure
- @continue = reserve_continue
- @ltype = reserve_ltype
- @indent = reserve_indent
- @indent_stack = reserve_indent_stack
- @lex_state = reserve_state
- @quoted = reserve_quoted
- end
- end
-
- def identify_comment
- @ltype = "#"
-
- while ch = getc
- if ch == "\n"
- @ltype = nil
- ungetc
- break
- end
- end
- return Token(TkCOMMENT)
- end
-
- def read_escape
- case ch = getc
- when "\n", "\r", "\f"
- when "\\", "n", "t", "r", "f", "v", "a", "e", "b", "s" #"
- when /[0-7]/
- ungetc ch
- 3.times do
- case ch = getc
- when /[0-7]/
- when nil
- break
- else
- ungetc
- break
- end
- end
-
- when "x"
- 2.times do
- case ch = getc
- when /[0-9a-fA-F]/
- when nil
- break
- else
- ungetc
- break
- end
- end
-
- when "M"
- if (ch = getc) != '-'
- ungetc
- else
- if (ch = getc) == "\\" #"
- read_escape
- end
- end
-
- when "C", "c" #, "^"
- if ch == "C" and (ch = getc) != "-"
- ungetc
- elsif (ch = getc) == "\\" #"
- read_escape
- end
- else
- # other characters
- end
- end
-end
-# :startdoc:
diff --git a/src/main/resources/stdlib/irb/ruby-token.rb b/src/main/resources/stdlib/irb/ruby-token.rb
deleted file mode 100644
index a80d81c..0000000
--- a/src/main/resources/stdlib/irb/ruby-token.rb
+++ /dev/null
@@ -1,266 +0,0 @@
-#
-# irb/ruby-token.rb - ruby tokens
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-# :stopdoc:
-module RubyToken
- EXPR_BEG = :EXPR_BEG
- EXPR_MID = :EXPR_MID
- EXPR_END = :EXPR_END
- EXPR_ARG = :EXPR_ARG
- EXPR_FNAME = :EXPR_FNAME
- EXPR_DOT = :EXPR_DOT
- EXPR_CLASS = :EXPR_CLASS
-
- class Token
- def initialize(seek, line_no, char_no)
- @seek = seek
- @line_no = line_no
- @char_no = char_no
- end
- attr_reader :seek, :line_no, :char_no
- end
-
- class TkNode < Token
- def initialize(seek, line_no, char_no)
- super
- end
- attr_reader :node
- end
-
- class TkId < Token
- def initialize(seek, line_no, char_no, name)
- super(seek, line_no, char_no)
- @name = name
- end
- attr_reader :name
- end
-
- class TkVal < Token
- def initialize(seek, line_no, char_no, value = nil)
- super(seek, line_no, char_no)
- @value = value
- end
- attr_reader :value
- end
-
- class TkOp < Token
- attr_accessor :name
- end
-
- class TkOPASGN < TkOp
- def initialize(seek, line_no, char_no, op)
- super(seek, line_no, char_no)
- op = TkReading2Token[op][0] unless op.kind_of?(Symbol)
- @op = op
- end
- attr_reader :op
- end
-
- class TkUnknownChar < Token
- def initialize(seek, line_no, char_no, id)
- super(seek, line_no, char_no)
- @name = name
- end
- attr_reader :name
- end
-
- class TkError < Token
- end
-
- def Token(token, value = nil)
- case token
- when String
- if (tk = TkReading2Token[token]).nil?
- IRB.fail TkReading2TokenNoKey, token
- end
- tk = Token(tk[0], value)
- if tk.kind_of?(TkOp)
- tk.name = token
- end
- return tk
- when Symbol
- if (tk = TkSymbol2Token[token]).nil?
- IRB.fail TkSymbol2TokenNoKey, token
- end
- return Token(tk[0], value)
- else
- if (token.ancestors & [TkId, TkVal, TkOPASGN, TkUnknownChar]).empty?
- token.new(@prev_seek, @prev_line_no, @prev_char_no)
- else
- token.new(@prev_seek, @prev_line_no, @prev_char_no, value)
- end
- end
- end
-
- TokenDefinitions = [
- [:TkCLASS, TkId, "class", EXPR_CLASS],
- [:TkMODULE, TkId, "module", EXPR_BEG],
- [:TkDEF, TkId, "def", EXPR_FNAME],
- [:TkUNDEF, TkId, "undef", EXPR_FNAME],
- [:TkBEGIN, TkId, "begin", EXPR_BEG],
- [:TkRESCUE, TkId, "rescue", EXPR_MID],
- [:TkENSURE, TkId, "ensure", EXPR_BEG],
- [:TkEND, TkId, "end", EXPR_END],
- [:TkIF, TkId, "if", EXPR_BEG, :TkIF_MOD],
- [:TkUNLESS, TkId, "unless", EXPR_BEG, :TkUNLESS_MOD],
- [:TkTHEN, TkId, "then", EXPR_BEG],
- [:TkELSIF, TkId, "elsif", EXPR_BEG],
- [:TkELSE, TkId, "else", EXPR_BEG],
- [:TkCASE, TkId, "case", EXPR_BEG],
- [:TkWHEN, TkId, "when", EXPR_BEG],
- [:TkWHILE, TkId, "while", EXPR_BEG, :TkWHILE_MOD],
- [:TkUNTIL, TkId, "until", EXPR_BEG, :TkUNTIL_MOD],
- [:TkFOR, TkId, "for", EXPR_BEG],
- [:TkBREAK, TkId, "break", EXPR_END],
- [:TkNEXT, TkId, "next", EXPR_END],
- [:TkREDO, TkId, "redo", EXPR_END],
- [:TkRETRY, TkId, "retry", EXPR_END],
- [:TkIN, TkId, "in", EXPR_BEG],
- [:TkDO, TkId, "do", EXPR_BEG],
- [:TkRETURN, TkId, "return", EXPR_MID],
- [:TkYIELD, TkId, "yield", EXPR_END],
- [:TkSUPER, TkId, "super", EXPR_END],
- [:TkSELF, TkId, "self", EXPR_END],
- [:TkNIL, TkId, "nil", EXPR_END],
- [:TkTRUE, TkId, "true", EXPR_END],
- [:TkFALSE, TkId, "false", EXPR_END],
- [:TkAND, TkId, "and", EXPR_BEG],
- [:TkOR, TkId, "or", EXPR_BEG],
- [:TkNOT, TkId, "not", EXPR_BEG],
- [:TkIF_MOD, TkId],
- [:TkUNLESS_MOD, TkId],
- [:TkWHILE_MOD, TkId],
- [:TkUNTIL_MOD, TkId],
- [:TkALIAS, TkId, "alias", EXPR_FNAME],
- [:TkDEFINED, TkId, "defined?", EXPR_END],
- [:TklBEGIN, TkId, "BEGIN", EXPR_END],
- [:TklEND, TkId, "END", EXPR_END],
- [:Tk__LINE__, TkId, "__LINE__", EXPR_END],
- [:Tk__FILE__, TkId, "__FILE__", EXPR_END],
-
- [:TkIDENTIFIER, TkId],
- [:TkFID, TkId],
- [:TkGVAR, TkId],
- [:TkCVAR, TkId],
- [:TkIVAR, TkId],
- [:TkCONSTANT, TkId],
-
- [:TkINTEGER, TkVal],
- [:TkFLOAT, TkVal],
- [:TkSTRING, TkVal],
- [:TkXSTRING, TkVal],
- [:TkREGEXP, TkVal],
- [:TkSYMBOL, TkVal],
-
- [:TkDSTRING, TkNode],
- [:TkDXSTRING, TkNode],
- [:TkDREGEXP, TkNode],
- [:TkNTH_REF, TkNode],
- [:TkBACK_REF, TkNode],
-
- [:TkUPLUS, TkOp, "+@"],
- [:TkUMINUS, TkOp, "-@"],
- [:TkPOW, TkOp, "**"],
- [:TkCMP, TkOp, "<=>"],
- [:TkEQ, TkOp, "=="],
- [:TkEQQ, TkOp, "==="],
- [:TkNEQ, TkOp, "!="],
- [:TkGEQ, TkOp, ">="],
- [:TkLEQ, TkOp, "<="],
- [:TkANDOP, TkOp, "&&"],
- [:TkOROP, TkOp, "||"],
- [:TkMATCH, TkOp, "=~"],
- [:TkNMATCH, TkOp, "!~"],
- [:TkDOT2, TkOp, ".."],
- [:TkDOT3, TkOp, "..."],
- [:TkAREF, TkOp, "[]"],
- [:TkASET, TkOp, "[]="],
- [:TkLSHFT, TkOp, "<<"],
- [:TkRSHFT, TkOp, ">>"],
- [:TkCOLON2, TkOp],
- [:TkCOLON3, TkOp],
- [:TkASSOC, TkOp, "=>"],
- [:TkQUESTION, TkOp, "?"], #?
- [:TkCOLON, TkOp, ":"], #:
-
- [:TkfLPAREN], # func( #
- [:TkfLBRACK], # func[ #
- [:TkfLBRACE], # func{ #
- [:TkSTAR], # *arg
- [:TkAMPER], # &arg #
- [:TkSYMBEG], # :SYMBOL
-
- [:TkGT, TkOp, ">"],
- [:TkLT, TkOp, "<"],
- [:TkPLUS, TkOp, "+"],
- [:TkMINUS, TkOp, "-"],
- [:TkMULT, TkOp, "*"],
- [:TkDIV, TkOp, "/"],
- [:TkMOD, TkOp, "%"],
- [:TkBITOR, TkOp, "|"],
- [:TkBITXOR, TkOp, "^"],
- [:TkBITAND, TkOp, "&"],
- [:TkBITNOT, TkOp, "~"],
- [:TkNOTOP, TkOp, "!"],
-
- [:TkBACKQUOTE, TkOp, "`"],
-
- [:TkASSIGN, Token, "="],
- [:TkDOT, Token, "."],
- [:TkLPAREN, Token, "("], #(exp)
- [:TkLBRACK, Token, "["], #[arry]
- [:TkLBRACE, Token, "{"], #{hash}
- [:TkRPAREN, Token, ")"],
- [:TkRBRACK, Token, "]"],
- [:TkRBRACE, Token, "}"],
- [:TkCOMMA, Token, ","],
- [:TkSEMICOLON, Token, ";"],
-
- [:TkCOMMENT],
- [:TkRD_COMMENT],
- [:TkSPACE],
- [:TkNL],
- [:TkEND_OF_SCRIPT],
-
- [:TkBACKSLASH, TkUnknownChar, "\\"],
- [:TkAT, TkUnknownChar, "@"],
- [:TkDOLLAR, TkUnknownChar, "$"],
- ]
-
- # {reading => token_class}
- # {reading => [token_class, *opt]}
- TkReading2Token = {}
- TkSymbol2Token = {}
-
- def RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)
- token_n = token_n.id2name if token_n.kind_of?(Symbol)
- if RubyToken.const_defined?(token_n)
- IRB.fail AlreadyDefinedToken, token_n
- end
- token_c = eval("class #{token_n} < #{super_token}; end; #{token_n}")
-
- if reading
- if TkReading2Token[reading]
- IRB.fail TkReading2TokenDuplicateError, token_n, reading
- end
- if opts.empty?
- TkReading2Token[reading] = [token_c]
- else
- TkReading2Token[reading] = [token_c].concat(opts)
- end
- end
- TkSymbol2Token[token_n.intern] = token_c
- end
-
- for defs in TokenDefinitions
- def_token(*defs)
- end
-end
-# :startdoc:
diff --git a/src/main/resources/stdlib/irb/slex.rb b/src/main/resources/stdlib/irb/slex.rb
deleted file mode 100644
index f6c2bd9..0000000
--- a/src/main/resources/stdlib/irb/slex.rb
+++ /dev/null
@@ -1,281 +0,0 @@
-#
-# irb/slex.rb - simple lex analyzer
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-require "e2mmap"
-require "irb/notifier"
-
-# :stopdoc:
-module IRB
- class SLex
-
- extend Exception2MessageMapper
- def_exception :ErrNodeNothing, "node nothing"
- def_exception :ErrNodeAlreadyExists, "node already exists"
-
- DOUT = Notifier::def_notifier("SLex::")
- D_WARN = DOUT::def_notifier(1, "Warn: ")
- D_DEBUG = DOUT::def_notifier(2, "Debug: ")
- D_DETAIL = DOUT::def_notifier(4, "Detail: ")
-
- DOUT.level = Notifier::D_NOMSG
-
- def initialize
- @head = Node.new("")
- end
-
- def def_rule(token, preproc = nil, postproc = nil, &block)
- D_DETAIL.pp token
-
- postproc = block if block_given?
- create(token, preproc, postproc)
- end
-
- def def_rules(*tokens, &block)
- if block_given?
- p = block
- end
- for token in tokens
- def_rule(token, nil, p)
- end
- end
-
- def preproc(token, proc)
- node = search(token)
- node.preproc=proc
- end
-
- #$BMW%A%'%C%/(B?
- def postproc(token)
- node = search(token, proc)
- node.postproc=proc
- end
-
- def search(token)
- @head.search(token.split(//))
- end
-
- def create(token, preproc = nil, postproc = nil)
- @head.create_subnode(token.split(//), preproc, postproc)
- end
-
- def match(token)
- case token
- when Array
- when String
- return match(token.split(//))
- else
- return @head.match_io(token)
- end
- ret = @head.match(token)
- D_DETAIL.exec_if{D_DETAIL.printf "match end: %s:%s\n", ret, token.inspect}
- ret
- end
-
- def inspect
- format("", @head.inspect)
- end
-
- #----------------------------------------------------------------------
- #
- # class Node -
- #
- #----------------------------------------------------------------------
- class Node
- # if postproc is nil, this node is an abstract node.
- # if postproc is non-nil, this node is a real node.
- def initialize(preproc = nil, postproc = nil)
- @Tree = {}
- @preproc = preproc
- @postproc = postproc
- end
-
- attr_accessor :preproc
- attr_accessor :postproc
-
- def search(chrs, opt = nil)
- return self if chrs.empty?
- ch = chrs.shift
- if node = @Tree[ch]
- node.search(chrs, opt)
- else
- if opt
- chrs.unshift ch
- self.create_subnode(chrs)
- else
- SLex.fail ErrNodeNothing
- end
- end
- end
-
- def create_subnode(chrs, preproc = nil, postproc = nil)
- if chrs.empty?
- if @postproc
- D_DETAIL.pp node
- SLex.fail ErrNodeAlreadyExists
- else
- D_DEBUG.puts "change abstract node to real node."
- @preproc = preproc
- @postproc = postproc
- end
- return self
- end
-
- ch = chrs.shift
- if node = @Tree[ch]
- if chrs.empty?
- if node.postproc
- DebugLogger.pp node
- DebugLogger.pp self
- DebugLogger.pp ch
- DebugLogger.pp chrs
- SLex.fail ErrNodeAlreadyExists
- else
- D_WARN.puts "change abstract node to real node"
- node.preproc = preproc
- node.postproc = postproc
- end
- else
- node.create_subnode(chrs, preproc, postproc)
- end
- else
- if chrs.empty?
- node = Node.new(preproc, postproc)
- else
- node = Node.new
- node.create_subnode(chrs, preproc, postproc)
- end
- @Tree[ch] = node
- end
- node
- end
-
- #
- # chrs: String
- # character array
- # io must have getc()/ungetc(); and ungetc() must be
- # able to be called arbitrary number of times.
- #
- def match(chrs, op = "")
- D_DETAIL.print "match>: ", chrs, "op:", op, "\n"
- if chrs.empty?
- if @preproc.nil? || @preproc.call(op, chrs)
- DOUT.printf(D_DETAIL, "op1: %s\n", op)
- @postproc.call(op, chrs)
- else
- nil
- end
- else
- ch = chrs.shift
- if node = @Tree[ch]
- if ret = node.match(chrs, op+ch)
- return ret
- else
- chrs.unshift ch
- if @postproc and @preproc.nil? || @preproc.call(op, chrs)
- DOUT.printf(D_DETAIL, "op2: %s\n", op.inspect)
- ret = @postproc.call(op, chrs)
- return ret
- else
- return nil
- end
- end
- else
- chrs.unshift ch
- if @postproc and @preproc.nil? || @preproc.call(op, chrs)
- DOUT.printf(D_DETAIL, "op3: %s\n", op)
- @postproc.call(op, chrs)
- return ""
- else
- return nil
- end
- end
- end
- end
-
- def match_io(io, op = "")
- if op == ""
- ch = io.getc
- if ch == nil
- return nil
- end
- else
- ch = io.getc_of_rests
- end
- if ch.nil?
- if @preproc.nil? || @preproc.call(op, io)
- D_DETAIL.printf("op1: %s\n", op)
- @postproc.call(op, io)
- else
- nil
- end
- else
- if node = @Tree[ch]
- if ret = node.match_io(io, op+ch)
- ret
- else
- io.ungetc ch
- if @postproc and @preproc.nil? || @preproc.call(op, io)
- DOUT.exec_if{D_DETAIL.printf "op2: %s\n", op.inspect}
- @postproc.call(op, io)
- else
- nil
- end
- end
- else
- io.ungetc ch
- if @postproc and @preproc.nil? || @preproc.call(op, io)
- D_DETAIL.printf("op3: %s\n", op)
- @postproc.call(op, io)
- else
- nil
- end
- end
- end
- end
- end
- end
-end
-# :startdoc:
-
-if $0 == __FILE__
- case $1
- when "1"
- tr = SLex.new
- print "0: ", tr.inspect, "\n"
- tr.def_rule("=") {print "=\n"}
- print "1: ", tr.inspect, "\n"
- tr.def_rule("==") {print "==\n"}
- print "2: ", tr.inspect, "\n"
-
- print "case 1:\n"
- print tr.match("="), "\n"
- print "case 2:\n"
- print tr.match("=="), "\n"
- print "case 3:\n"
- print tr.match("=>"), "\n"
-
- when "2"
- tr = SLex.new
- print "0: ", tr.inspect, "\n"
- tr.def_rule("=") {print "=\n"}
- print "1: ", tr.inspect, "\n"
- tr.def_rule("==", proc{false}) {print "==\n"}
- print "2: ", tr.inspect, "\n"
-
- print "case 1:\n"
- print tr.match("="), "\n"
- print "case 2:\n"
- print tr.match("=="), "\n"
- print "case 3:\n"
- print tr.match("=>"), "\n"
- end
- exit
-end
diff --git a/src/main/resources/stdlib/irb/src_encoding.rb b/src/main/resources/stdlib/irb/src_encoding.rb
deleted file mode 100644
index 958cef1..0000000
--- a/src/main/resources/stdlib/irb/src_encoding.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# DO NOT WRITE ANY MAGIC COMMENT HERE.
-def default_src_encoding
- return __ENCODING__
-end
diff --git a/src/main/resources/stdlib/irb/version.rb b/src/main/resources/stdlib/irb/version.rb
deleted file mode 100644
index bb998db..0000000
--- a/src/main/resources/stdlib/irb/version.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# irb/version.rb - irb version definition file
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ishitsuka.com)
-#
-# --
-#
-#
-#
-
-module IRB # :nodoc:
- @RELEASE_VERSION = "0.9.6"
- @LAST_UPDATE_DATE = "09/06/30"
-end
diff --git a/src/main/resources/stdlib/irb/workspace.rb b/src/main/resources/stdlib/irb/workspace.rb
deleted file mode 100644
index e05c3bb..0000000
--- a/src/main/resources/stdlib/irb/workspace.rb
+++ /dev/null
@@ -1,114 +0,0 @@
-#
-# irb/workspace-binding.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-module IRB # :nodoc:
- class WorkSpace
- # Creates a new workspace.
- #
- # set self to main if specified, otherwise
- # inherit main from TOPLEVEL_BINDING.
- def initialize(*main)
- if main[0].kind_of?(Binding)
- @binding = main.shift
- elsif IRB.conf[:SINGLE_IRB]
- @binding = TOPLEVEL_BINDING
- else
- case IRB.conf[:CONTEXT_MODE]
- when 0 # binding in proc on TOPLEVEL_BINDING
- @binding = eval("proc{binding}.call",
- TOPLEVEL_BINDING,
- __FILE__,
- __LINE__)
- when 1 # binding in loaded file
- require "tempfile"
- f = Tempfile.open("irb-binding")
- f.print <IRB.conf[:__MAIN__]
- attr_reader :main
-
- # Evaluate the given +statements+ within the context of this workspace.
- def evaluate(context, statements, file = __FILE__, line = __LINE__)
- eval(statements, @binding, file, line)
- end
-
- # error message manipulator
- def filter_backtrace(bt)
- case IRB.conf[:CONTEXT_MODE]
- when 0
- return nil if bt =~ /\(irb_local_binding\)/
- when 1
- if(bt =~ %r!/tmp/irb-binding! or
- bt =~ %r!irb/.*\.rb! or
- bt =~ /irb\.rb/)
- return nil
- end
- when 2
- return nil if bt =~ /irb\/.*\.rb/
- return nil if bt =~ /irb\.rb/
- when 3
- return nil if bt =~ /irb\/.*\.rb/
- return nil if bt =~ /irb\.rb/
- bt = bt.sub(/:\s*in `irb_binding'/, '')
- end
- bt
- end
-
- def IRB.delete_caller
- end
- end
-end
diff --git a/src/main/resources/stdlib/irb/ws-for-case-2.rb b/src/main/resources/stdlib/irb/ws-for-case-2.rb
deleted file mode 100644
index 9f3af49..0000000
--- a/src/main/resources/stdlib/irb/ws-for-case-2.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# irb/ws-for-case-2.rb -
-# $Release Version: 0.9.6$
-# $Revision$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-# --
-#
-#
-#
-
-while true
- IRB::BINDING_QUEUE.push _ = binding
-end
diff --git a/src/main/resources/stdlib/irb/xmp.rb b/src/main/resources/stdlib/irb/xmp.rb
deleted file mode 100644
index 449f043..0000000
--- a/src/main/resources/stdlib/irb/xmp.rb
+++ /dev/null
@@ -1,169 +0,0 @@
-#
-# xmp.rb - irb version of gotoken xmp
-# $Release Version: 0.9$
-# $Revision$
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
-#
-# --
-#
-#
-#
-
-require "irb"
-require "irb/frame"
-
-# An example printer for irb.
-#
-# It's much like the standard library PrettyPrint, that shows the value of each
-# expression as it runs.
-#
-# In order to use this library, you must first require it:
-#
-# require 'irb/xmp'
-#
-# Now, you can take advantage of the Object#xmp convenience method.
-#
-# xmp < foo = "bar"
-# #==>"bar"
-# #=> baz = 42
-# #==>42
-#
-# You can also create an XMP object, with an optional binding to print
-# expressions in the given binding:
-#
-# ctx = binding
-# x = XMP.new ctx
-# x.puts
-# #=> today = "a good day"
-# #==>"a good day"
-# ctx.eval 'today # is what?'
-# #=> "a good day"
-class XMP
-
- # Creates a new XMP object.
- #
- # The top-level binding or, optional +bind+ parameter will be used when
- # creating the workspace. See WorkSpace.new for more information.
- #
- # This uses the +:XMP+ prompt mode, see IRB@Customizing+the+IRB+Prompt for
- # full detail.
- def initialize(bind = nil)
- IRB.init_config(nil)
-
- IRB.conf[:PROMPT_MODE] = :XMP
-
- bind = IRB::Frame.top(1) unless bind
- ws = IRB::WorkSpace.new(bind)
- @io = StringInputMethod.new
- @irb = IRB::Irb.new(ws, @io)
- @irb.context.ignore_sigint = false
-
- IRB.conf[:MAIN_CONTEXT] = @irb.context
- end
-
- # Evaluates the given +exps+, for example:
- #
- # require 'irb/xmp'
- # x = XMP.new
- #
- # x.puts '{:a => 1, :b => 2, :c => 3}'
- # #=> {:a => 1, :b => 2, :c => 3}
- # # ==>{:a=>1, :b=>2, :c=>3}
- # x.puts 'foo = "bar"'
- # # => foo = "bar"
- # # ==>"bar"
- def puts(exps)
- @io.puts exps
-
- if @irb.context.ignore_sigint
- begin
- trap_proc_b = trap("SIGINT"){@irb.signal_handle}
- catch(:IRB_EXIT) do
- @irb.eval_input
- end
- ensure
- trap("SIGINT", trap_proc_b)
- end
- else
- catch(:IRB_EXIT) do
- @irb.eval_input
- end
- end
- end
-
- # A custom InputMethod class used by XMP for evaluating string io.
- class StringInputMethod < IRB::InputMethod
- # Creates a new StringInputMethod object
- def initialize
- super
- @exps = []
- end
-
- # Whether there are any expressions left in this printer.
- def eof?
- @exps.empty?
- end
-
- # Reads the next expression from this printer.
- #
- # See IO#gets for more information.
- def gets
- while l = @exps.shift
- next if /^\s+$/ =~ l
- l.concat "\n"
- print @prompt, l
- break
- end
- l
- end
-
- # Concatenates all expressions in this printer, separated by newlines.
- #
- # An Encoding::CompatibilityError is raised of the given +exps+'s encoding
- # doesn't match the previous expression evaluated.
- def puts(exps)
- if @encoding and exps.encoding != @encoding
- enc = Encoding.compatible?(@exps.join("\n"), exps)
- if enc.nil?
- raise Encoding::CompatibilityError, "Encoding in which the passed expression is encoded is not compatible to the preceding's one"
- else
- @encoding = enc
- end
- else
- @encoding = exps.encoding
- end
- @exps.concat exps.split(/\n/)
- end
-
- # Returns the encoding of last expression printed by #puts.
- attr_reader :encoding
- end
-end
-
-# A convenience method that's only available when the you require the IRB::XMP standard library.
-#
-# Creates a new XMP object, using the given expressions as the +exps+
-# parameter, and optional binding as +bind+ or uses the top-level binding. Then
-# evaluates the given expressions using the +:XMP+ prompt mode.
-#
-# For example:
-#
-# require 'irb/xmp'
-# ctx = binding
-# xmp 'foo = "bar"', ctx
-# #=> foo = "bar"
-# #==>"bar"
-# ctx.eval 'foo'
-# #=> "bar"
-#
-# See XMP.new for more information.
-def xmp(exps, bind = nil)
- bind = IRB::Frame.top(1) unless bind
- xmp = XMP.new(bind)
- xmp.puts exps
- xmp
-end
diff --git a/src/main/resources/stdlib/jar-dependencies.rb b/src/main/resources/stdlib/jar-dependencies.rb
deleted file mode 100644
index b298894..0000000
--- a/src/main/resources/stdlib/jar-dependencies.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Copyright (C) 2014 Christian Meier
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-# the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-require 'jar_dependencies'
diff --git a/src/main/resources/stdlib/jar_dependencies.rb b/src/main/resources/stdlib/jar_dependencies.rb
deleted file mode 100644
index 7b3f809..0000000
--- a/src/main/resources/stdlib/jar_dependencies.rb
+++ /dev/null
@@ -1,304 +0,0 @@
-#
-# Copyright (C) 2014 Christian Meier
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-# the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-module Jars
- unless defined? Jars::MAVEN_SETTINGS
- MAVEN_SETTINGS = 'JARS_MAVEN_SETTINGS'.freeze
- LOCAL_MAVEN_REPO = 'JARS_LOCAL_MAVEN_REPO'.freeze
- # lock file to use
- LOCK = 'JARS_LOCK'.freeze
- # where the locally stored jars are search for or stored
- HOME = 'JARS_HOME'.freeze
- # skip the gem post install hook
- SKIP = 'JARS_SKIP'.freeze
- # do not require any jars if set to false
- REQUIRE = 'JARS_REQUIRE'.freeze
- # @private
- NO_REQUIRE = 'JARS_NO_REQUIRE'.freeze
- # no more warnings on conflict. this still requires jars but will
- # not warn. it is needed to load jars from (default) gems which
- # do contribute to any dependency manager (maven, gradle, jbundler)
- QUIET = 'JARS_QUIET'.freeze
- # show maven output
- VERBOSE = 'JARS_VERBOSE'.freeze
- # maven debug
- DEBUG = 'JARS_DEBUG'.freeze
- # vendor jars inside gem when installing gem
- VENDOR = 'JARS_VENDOR'.freeze
- # resolve jars from Jars.lock
- RESOLVE = 'JARS_RESOLVE'.freeze
- end
-
- class << self
-
- if defined? JRUBY_VERSION
- def to_prop( key )
- key = key.gsub( '_', '.' )
- ENV_JAVA[ ( key.downcase!; key ) ] ||
- ENV[ ( key.gsub!( '.', '_' ); key.upcase!; key ) ]
- end
- else
- def to_prop( key )
- ENV[ key.gsub( '.', '_' ).upcase ]
- end
- end
-
- def to_boolean( key )
- return nil if ( prop = to_prop( key ) ).nil?
- prop.empty? || prop.eql?('true')
- end
-
- def skip?
- to_boolean( SKIP )
- end
-
- def require?
- @require = nil unless instance_variable_defined?(:@require)
- if @require.nil?
- if ( require = to_boolean( REQUIRE ) ).nil?
- no_require = to_boolean( NO_REQUIRE )
- @require = no_require.nil? ? true : ! no_require
- else
- @require = require
- end
- end
- @require
- end
- attr_writer :require
-
- def quiet?
- ( @silent ||= false ) || to_boolean( QUIET )
- end
-
- # @deprecated
- def no_require?; ! require? end
-
- def verbose?
- to_boolean( VERBOSE )
- end
-
- def debug?
- to_boolean( DEBUG )
- end
-
- def vendor?
- to_boolean( VENDOR )
- end
-
- def resolve?
- to_boolean( RESOLVE )
- end
-
- def no_more_warnings
- @silent = true
- end
-
- def freeze_loading
- self.require = false
- end
-
- def lock
- to_prop( LOCK ) || 'Jars.lock'
- end
-
- def lock_path( basedir = nil )
- deps = self.lock
- return deps if File.exists?( deps )
- deps = File.join( basedir || '.', self.lock )
- deps if File.exists?( deps )
- end
-
- def local_maven_repo
- to_prop( LOCAL_MAVEN_REPO ) || home
- end
-
- def reset
- instance_variables.each { |var| instance_variable_set(var, nil) }
- ( @@jars ||= {} ).clear
- end
-
- def maven_user_settings
- unless instance_variable_defined?(:@_jars_maven_user_settings_)
- @_jars_maven_user_settings_ = nil
- end
- if ( @_jars_maven_user_settings_ ||= nil ).nil?
- if settings = absolute( to_prop( MAVEN_SETTINGS ) )
- unless File.exists?(settings)
- warn "configured ENV['#{MAVEN_SETTINGS}'] = '#{settings}' not found"
- settings = false
- end
- else # use maven default (user) settings
- settings = File.join( user_home, '.m2', 'settings.xml' )
- settings = false unless File.exists?(settings)
- end
- @_jars_maven_user_settings_ = settings
- end
- @_jars_maven_user_settings_ || nil
- end
- alias maven_settings maven_user_settings
-
- def maven_global_settings
- unless instance_variable_defined?(:@_jars_maven_global_settings_)
- @_jars_maven_global_settings_ = nil
- end
- if @_jars_maven_global_settings_.nil?
- if mvn_home = ENV[ 'M2_HOME' ] || ENV[ 'MAVEN_HOME' ]
- settings = File.join( mvn_home, 'conf/settings.xml' )
- settings = false unless File.exists?(settings)
- else
- settings = false
- end
- @_jars_maven_global_settings_ = settings
- end
- @_jars_maven_global_settings_ || nil
- end
-
- def home
- @_jars_home_ ||= absolute(to_prop(HOME)) ||
- detect_local_repository(maven_user_settings) ||
- detect_local_repository(maven_global_settings) ||
- File.join( user_home, '.m2', 'repository' )
- end
-
- def require_jars_lock!( scope = :runtime )
- if jars_lock = Jars.lock_path
- @@jars_lock = jars_lock
- # funny error during spec where it tries to load it again
- # and finds it as gem instead of the LOAD_PATH
- require 'jars/classpath' unless defined? Jars::Classpath
- classpath = Jars::Classpath.new( nil, jars_lock )
- classpath.require( scope )
- no_more_warnings
- end
- end
-
- def require_jars_lock
- @@jars_lock ||= false
- unless @@jars_lock
- require_jars_lock!
- @@jars_lock ||= true
- end
- end
-
- def mark_as_required( group_id, artifact_id, *classifier_version )
- require_jar_with_block( group_id, artifact_id, *classifier_version ) do
- end
- end
-
- def require_jar( group_id, artifact_id, *classifier_version )
- require_jars_lock
- require_jar_with_block( group_id, artifact_id, *classifier_version ) do |group_id, artifact_id, version, classifier|
- do_require( group_id, artifact_id, version, classifier )
- end
- end
-
- def warn(msg)
- Kernel.warn(msg) unless quiet?
- end
-
- private
-
- def require_jar_with_block( group_id, artifact_id, *classifier_version )
- version = classifier_version[ -1 ]
- classifier = classifier_version[ -2 ]
-
- @@jars ||= {}
- coordinate = "#{group_id}:#{artifact_id}"
- coordinate << ":#{classifier}" if classifier
- if @@jars.key? coordinate
- if @@jars[ coordinate ] == version
- false
- else
- @@jars[ coordinate ] # version of already registered jar
- end
- else
- yield group_id, artifact_id, version, classifier
- @@jars[ coordinate ] = version
- return true
- end
- end
-
- def absolute( file )
- File.expand_path( file ) if file
- end
-
- def user_home
- ENV[ 'HOME' ] || begin
- user_home = Dir.home if Dir.respond_to?(:home)
- unless user_home
- user_home = ENV_JAVA[ 'user.home' ] if Object.const_defined?(:ENV_JAVA)
- end
- user_home
- end
- end
-
- def detect_local_repository(settings)
- return nil unless settings
-
- doc = File.read( settings )
- # TODO filter out xml comments
- local_repo = doc.sub( /<\/localRepository>.*/m, '' ).sub( /.*/m, '' )
- # replace maven like system properties embedded into the string
- local_repo.gsub!( /\$\{[a-zA-Z.]+\}/ ) do |a|
- ENV_JAVA[ a[2..-2] ] || a
- end
- if local_repo.empty? or not File.exists?( local_repo )
- local_repo = nil
- end
- local_repo
- rescue
- warn "error reading or parsing #{settings}"
- nil
- end
-
- def to_jar( group_id, artifact_id, version, classifier = nil )
- file = "#{group_id.gsub( '.', '/' )}/#{artifact_id}/#{version}/#{artifact_id}-#{version}"
- file << "-#{classifier}" if classifier
- file << '.jar'
- file
- end
-
- def do_require( *args )
- jar = to_jar( *args )
- file = File.join( home, jar )
- # use jar from local repository if exists
- if File.exists?( file )
- require file
- else
- # otherwise try to find it on the load path
- require jar
- end
- rescue LoadError => e
- raise "\n\n\tyou might need to reinstall the gem which depends on the missing jar or in case there is Jars.lock then JARS_RESOLVE=true will install the missing jars\n\n" + e.message + " (LoadError)"
- end
-
- end # class << self
-
-end
-
-def require_jar( *args )
- return nil unless Jars.require?
- result = Jars.require_jar( *args )
- if result.is_a? String
- Jars.warn "jar coordinate #{args[0..-2].join( ':' )} already loaded with version #{result}"
- return false
- end
- result
-end
diff --git a/src/main/resources/stdlib/jar_install_post_install_hook.rb b/src/main/resources/stdlib/jar_install_post_install_hook.rb
deleted file mode 100644
index ef3a7a6..0000000
--- a/src/main/resources/stdlib/jar_install_post_install_hook.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright (C) 2014 Christian Meier
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-# the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-require 'jars/post_install_hook'
diff --git a/src/main/resources/stdlib/jar_installer.rb b/src/main/resources/stdlib/jar_installer.rb
deleted file mode 100644
index 8b52d2c..0000000
--- a/src/main/resources/stdlib/jar_installer.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'jars/installer'
diff --git a/src/main/resources/stdlib/jars/classpath.rb b/src/main/resources/stdlib/jars/classpath.rb
deleted file mode 100644
index f07ba74..0000000
--- a/src/main/resources/stdlib/jars/classpath.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require 'jars/maven_exec'
-require 'jars/lock'
-require 'fileutils'
-
-module Jars
-
- class Classpath
-
- def initialize( spec = nil, deps = nil )
- @spec = spec
- @deps = deps
- end
-
- def mvn
- @mvn ||= MavenExec.new( @spec )
- end
-
- def workdir( dirname )
- dir = File.join( mvn.basedir, dirname )
- dir if File.directory?( dir )
- end
-
- def dependencies_list
- if @deps ||= Jars.lock_path( mvn.basedir )
- mvn.resolve_dependencies( @deps ) if Jars.resolve?
- @deps
- else
- resolve_dependencies
- end
- end
- private :dependencies_list
-
- DEPENDENCY_LIST = 'dependencies.list'
- def resolve_dependencies
- basedir = workdir( 'pkg' ) || workdir( 'target' ) || workdir( '' )
- deps = File.join( basedir, DEPENDENCY_LIST )
- mvn.resolve_dependencies_list( deps )
- deps
- end
- private :resolve_dependencies
-
- def require( scope = nil )
- process( scope ) do |jar|
- if jar.scope == :system
- Kernel.require jar.path
- else
- require_jar( *jar.gacv )
- end
- end
- if scope == nil || scope == :runtime
- process( :provided ) do |jar|
- Jars.mark_as_required( *jar.gacv )
- end
- end
- end
-
- def classpath( scope = nil )
- classpath = []
- process( scope ) do |jar|
- classpath << jar.file
- end
- classpath
- end
-
- def process( scope, &block )
- deps = dependencies_list
- Lock.new( deps ).process( scope, &block )
- ensure
- FileUtils.rm_f( DEPENDENCY_LIST ) if deps
- end
- private :process
-
- def classpath_string( scope = nil )
- classpath( scope ).join( File::PATH_SEPARATOR )
- end
- end
-end
diff --git a/src/main/resources/stdlib/jars/installer.rb b/src/main/resources/stdlib/jars/installer.rb
deleted file mode 100644
index 127162d..0000000
--- a/src/main/resources/stdlib/jars/installer.rb
+++ /dev/null
@@ -1,197 +0,0 @@
-require 'jar_dependencies'
-require 'jars/maven_exec'
-
-module Jars
- class Installer
-
- class Dependency
-
- attr_reader :path, :file, :gav, :scope, :type, :coord
-
- def self.new( line )
- if line.match /:jar:|:pom:/
- super
- end
- end
-
- def setup_type( line )
- if line.index(':pom:')
- @type = :pom
- elsif line.index(':jar:')
- @type = :jar
- end
- end
- private :setup_type
-
- def setup_scope( line )
- @scope =
- case line
- when /:provided:/
- :provided
- when /:test:/
- :test
- else
- :runtime
- end
- end
- private :setup_scope
-
- def initialize( line )
- setup_type( line )
-
- line.sub!( /^\s+/, empty = '' )
- @coord = line.sub( /:[^:]+:([A-Z]:\\)?[^:]+$/, empty )
- first, second = @coord.split( /:#{type}:/ )
- group_id, artifact_id = first.split( /:/ )
- parts = group_id.split( '.' )
- parts << artifact_id
- parts << second.split( ':' )[ -1 ]
- parts << File.basename( line.sub( /.:/, empty ) )
- @path = File.join( parts ).strip
-
- setup_scope( line )
-
- reg = /:jar:|:pom:|:test:|:compile:|:runtime:|:provided:|:system:/
- @file = line.slice(@coord.length, line.length).sub(reg, empty).strip
- @system = line.index(':system:') != nil
- @gav = @coord.sub(reg, ':')
- end
-
- def system?
- @system
- end
- end
-
- def self.install_jars( write_require_file = false )
- new.install_jars( write_require_file )
- end
-
- def self.vendor_jars( write_require_file = false )
- new.vendor_jars( write_require_file )
- end
-
- def self.load_from_maven( file )
- result = []
- File.read( file ).each_line do |line|
- dep = Dependency.new( line )
- result << dep if dep && dep.scope == :runtime
- end
- result
- end
-
- def self.write_require_file( require_filename )
- FileUtils.mkdir_p( File.dirname( require_filename ) )
- comment = '# this is a generated file, to avoid over-writing it just delete this comment'
- if ! File.exists?( require_filename ) || File.read( require_filename ).match( comment )
- f = File.open( require_filename, 'w' )
- f.puts comment
- f.puts "require 'jar_dependencies'"
- f.puts
- f
- end
- end
-
- def self.vendor_file( dir, dep )
- vendored = File.join( dir, dep.path )
- FileUtils.mkdir_p( File.dirname( vendored ) )
- FileUtils.cp( dep.file, vendored ) unless dep.system?
- end
-
- def self.write_dep( file, dir, dep, vendor )
- return if dep.type != :jar || dep.scope != :runtime
- if dep.system?
- file.puts( "require( '#{dep.file}' )" ) if file
- elsif dep.scope == :runtime
- vendor_file( dir, dep ) if vendor
- file.puts( "require_jar( '#{dep.gav.gsub( ':', "', '" )}' )" ) if file
- end
- end
-
- def self.install_deps( deps, dir, require_filename, vendor )
- f = write_require_file( require_filename ) if require_filename
- deps.each do |dep|
- write_dep( f, dir, dep, vendor )
- end
- yield f if block_given? and f
- ensure
- f.close if f
- end
-
- def initialize( spec = nil )
- @mvn = MavenExec.new( spec )
- end
-
- def spec; @mvn.spec end
-
- def vendor_jars( write_require_file = true )
- return unless has_jars?
- case Jars.to_prop( Jars::VENDOR )
- when 'true'
- do_vendor = true
- when 'false'
- do_vendor = false
- else
- # if the spec_file does not exists this means it is a local gem
- # coming via bundle :path or :git
- do_vendor = File.exists?( spec.spec_file )
- end
- do_install( do_vendor, write_require_file )
- end
-
- def install_jars( write_require_file = true )
- return unless has_jars?
- do_install( false, write_require_file )
- end
-
- def ruby_maven_install_options=( options )
- @mvn.ruby_maven_install_options=( options )
- end
-
- def has_jars?
- # first look if there are any requirements in the spec
- # and then if gem depends on jar-dependencies for runtime.
- # only then install the jars declared in the requirements
- result = ( spec = self.spec ) && ! spec.requirements.empty? &&
- spec.dependencies.detect { |d| d.name == 'jar-dependencies' && d.type == :runtime } != nil
- if result && spec.platform.to_s != 'java'
- Jars.warn "\njar dependencies found on non-java platform gem - do not install jars\n"
- false
- else
- result
- end
- end
- alias_method :jars?, :has_jars?
-
- private
-
- def do_install( vendor, write_require_file )
- vendor_dir = File.join( @mvn.basedir, spec.require_path )
- jars_file = File.join( vendor_dir, "#{spec.name}_jars.rb" )
-
- # write out new jars_file it write_require_file is true or
- # check timestamps:
- # do not generate file if specfile is older then the generated file
- if ! write_require_file &&
- File.exists?( jars_file ) &&
- File.mtime( @mvn.specfile ) < File.mtime( jars_file )
- # leave jars_file as is
- jars_file = nil
- end
- self.class.install_deps( install_dependencies, vendor_dir,
- jars_file, vendor )
- end
-
- def install_dependencies
- deps = File.join( @mvn.basedir, 'deps.lst' )
-
- puts " jar dependencies for #{spec.spec_name} . . ." unless Jars.quiet?
- @mvn.resolve_dependencies_list( deps )
-
- self.class.load_from_maven( deps )
- ensure
- FileUtils.rm_f( deps ) if deps
- end
- end
- # to stay backward compatible
- JarInstaller = Installer unless defined? JarInstaller
-end
diff --git a/src/main/resources/stdlib/jars/jar_pom.rb b/src/main/resources/stdlib/jars/jar_pom.rb
deleted file mode 100644
index b921f70..0000000
--- a/src/main/resources/stdlib/jars/jar_pom.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# this file is maven DSL and used by maven via jars/maven_exec.rb
-
-specfile = java.lang.System.getProperty('jars.specfile')
-
-# needed since the gemspec does not allow absolute files
-basedir( File.dirname( specfile ) )
-
-# add jruby as provided for compilation when used vi Jars::Classpath#classpath
-jar 'org.jruby:jruby-core', JRUBY_VERSION, :scope => :provided
-
-# get ALL dependencies from the specfile
-gemspec File.basename( specfile )
-
-# we do not want those gem dependencies, each gem takes care of its
-# own jar dependencies
-gems = model.dependencies.select do |d|
- d.group_id == 'rubygems'
-end
-gems.each do |d|
- model.dependencies.remove( d )
-end
-
-# some output
-model.dependencies.each do |d|
- puts " " + d.group_id + ':' + d.artifact_id + (d.classifier ? ":" + d.classifier : "" ) + ":" + d.version unless d.artifact_id == 'jruby-core'
-end
diff --git a/src/main/resources/stdlib/jars/jars_lock_pom.rb b/src/main/resources/stdlib/jars/jars_lock_pom.rb
deleted file mode 100644
index 7954a42..0000000
--- a/src/main/resources/stdlib/jars/jars_lock_pom.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# this file is maven DSL and used by maven via jars/maven_exec.rb
-
-require_relative 'lock'
-require_relative '../jar_dependencies'
-
-lock = Jars::Lock.new( ENV_JAVA['jars.lock'] )
-
-lock.process( :all ) do |coord|
-
- options = { :scope => coord.scope }
- options[ :systemPath ] = coord[ -1 ] if coord.scope == :system
- options[ :classifier ] = coord.classifier
-
- jar coord.group_id, coord.artifact_id, coord.version, options
-
-end
diff --git a/src/main/resources/stdlib/jars/lock.rb b/src/main/resources/stdlib/jars/lock.rb
deleted file mode 100644
index 5bab6f9..0000000
--- a/src/main/resources/stdlib/jars/lock.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-require 'jars/maven_exec'
-
-module Jars
- class JarDetails < Array
-
- def scope
- self[ -2 ].to_sym
- end
-
- def file
- file = self[ -1 ].strip
- file.empty? ? path : file
- end
-
- def group_id
- self[ 0 ]
- end
-
- def artifact_id
- self[ 1 ]
- end
-
- def version
- self[ -3 ]
- end
-
- def classifier
- size == 5 ? nil : self[ 2 ]
- end
-
- def gacv
- classifier ? self[ 0..3 ] : self[ 0..2 ]
- end
-
- def path
- if scope == :system
- # replace maven like system properties embedded into the string
- self[ -1 ].gsub( /\$\{[a-zA-Z.]+\}/ ) do |a|
- ENV_JAVA[ a[2..-2] ] || a
- end
- else
- File.join( Jars.home, group_id.gsub(/[.]/, '/'), artifact_id, version, gacv[ 1..-1 ].join( '-' ) + '.jar' )
- end
- end
- end
-
- class Lock
-
- def initialize( file )
- @file = file
- end
-
- def process( scope )
- scope ||= :runtime
- File.read( @file ).each_line do |line|
- next if not line =~ /:.+:/
- jar = JarDetails.new( line.strip.sub( /:jar:/, ':' ).sub( /:$/, ': ' ).split( /:/ ) )
- case scope
- when :all
- yield jar
- when :compile
- # jar.scope is maven scope
- yield jar if jar.scope != :test
- when :provided
- # jar.scope is maven scope
- yield jar if jar.scope == :provided
- when :runtime
- # jar.scope is maven scope
- yield jar if jar.scope != :test and jar.scope != :provided
- when :test
- yield jar
- end
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/jars/maven_exec.rb b/src/main/resources/stdlib/jars/maven_exec.rb
deleted file mode 100644
index cec577a..0000000
--- a/src/main/resources/stdlib/jars/maven_exec.rb
+++ /dev/null
@@ -1,153 +0,0 @@
-require 'jar_dependencies'
-
-module Jars
- class MavenExec
-
- def find_spec( allow_no_file )
- specs = Dir[ '*.gemspec' ]
- case specs.size
- when 0
- raise 'no gemspec found' unless allow_no_file
- when 1
- specs.first
- else
- raise 'more then one gemspec found. please specify a specfile' unless allow_no_file
- end
- end
- private :find_spec
-
- attr_reader :basedir, :spec, :specfile
-
- def initialize( spec = nil )
- setup( spec )
- end
-
- def setup( spec = nil, allow_no_file = false )
- spec ||= find_spec( allow_no_file )
-
- case spec
- when String
- @specfile = File.expand_path( spec )
- @basedir = File.dirname( @specfile )
- spec = Dir.chdir( File.dirname(@specfile) ) do
- eval( File.read( @specfile ) )
- end
- when Gem::Specification
- if File.exists?( spec.spec_file )
- @basedir = spec.gem_dir
- @specfile = spec.spec_file
- else
- # this happens with bundle and local gems
- # there the spec_file is "not installed" but inside
- # the gem_dir directory
- Dir.chdir( spec.gem_dir ) do
- setup( nil, true )
- end
- end
- when NilClass
- else
- raise 'spec must be either String or Gem::Specification'
- end
-
- @spec = spec
- rescue
- # for all those strange gemspec we skip looking for jar-dependencies
- end
-
- def ruby_maven_install_options=( options )
- @options = options.dup
- @options.delete( :ignore_dependencies )
- end
-
- def resolve_dependencies_list( file )
- do_resolve_dependencies( *setup_arguments( 'jar_pom.rb', 'dependency:copy-dependencies', 'dependency:list', "-DoutputFile=#{file}" ) )
- end
-
- def resolve_dependencies( file )
- do_resolve_dependencies( *setup_arguments( 'jars_lock_pom.rb', 'dependency:copy-dependencies', '-DexcludeTransitive=true' , "-Djars.lock=#{file}") )
- end
-
- private
-
- def do_resolve_dependencies( *args )
- lazy_load_maven
-
- maven = Maven::Ruby::Maven.new
- maven.verbose = Jars.verbose?
- maven.exec( *args )
- end
-
- def setup_arguments( pom, *goals )
- args = goals.dup
- args << '-DoutputAbsoluteArtifactFilename=true'
- args << '-DincludeTypes=jar'
- args << '-DoutputScope=true'
- args << '-DuseRepositoryLayout=true'
- args << "-DoutputDirectory=#{Jars.home}"
- args << '-f' << "#{File.dirname( __FILE__ )}/#{pom}"
- args << "-Djars.specfile=#{@specfile}"
-
- if Jars.debug?
- args << '-X'
- elsif not Jars.verbose?
- args << '--quiet'
- end
-
- # TODO what todo with https proxy ?
- # FIX this proxy settings seems not to work
- if (proxy = Gem.configuration[ :http_proxy ]).is_a?( String )
- require 'uri'; uri = URI.parse( proxy )
- args << "-DproxySet=true"
- args << "-DproxyHost=#{uri.host}"
- args << "-DproxyPort=#{uri.port}"
- end
-
- if Jars.maven_settings
- args << '-s'
- args << Jars.maven_settings
- end
-
- args << "-Dmaven.repo.local=#{java.io.File.new( Jars.local_maven_repo ).absolute_path}"
-
- args
- end
-
- def lazy_load_maven
- add_gem_to_load_path( 'ruby-maven-libs' )
- add_gem_to_load_path( 'ruby-maven' )
- require 'maven/ruby/maven'
- end
-
- def find_spec_via_rubygems( name )
- require 'rubygems/dependency'
- dep = Gem::Dependency.new( name )
- dep.matching_specs( true ).last
- end
-
- def add_gem_to_load_path( name )
- # if the gem is already activated => good
- return if Gem.loaded_specs[ name ]
- # just install gem if needed and add it to the load_path
- # and leave activated gems as they are
- unless spec = find_spec_via_rubygems( name )
- spec = install_gem( name )
- end
- unless spec
- raise "failed to resolve gem '#{name}' if you're using Bundler add it as a dependency"
- end
- $LOAD_PATH << File.join( spec.full_gem_path, spec.require_path )
- end
-
- def install_gem( name )
- require 'rubygems/dependency_installer'
- jars = Gem.loaded_specs[ 'jar-dependencies' ]
- dep = jars.dependencies.detect { |d| d.name == name }
- req = dep.nil? ? Gem::Requirement.create( '>0' ) : dep.requirement
- inst = Gem::DependencyInstaller.new( @options ||= {} )
- inst.install( name, req ).first
- rescue => e
- warn e.backtrace.join( "\n" ) if Jars.verbose?
- raise "there was an error installing '#{name}'. please install it manually: #{e.inspect}"
- end
- end
-end
diff --git a/src/main/resources/stdlib/jars/post_install_hook.rb b/src/main/resources/stdlib/jars/post_install_hook.rb
deleted file mode 100644
index bc4b6ed..0000000
--- a/src/main/resources/stdlib/jars/post_install_hook.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2014 Christian Meier
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-# the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-if defined?( JRUBY_VERSION ) && Gem.post_install_hooks.empty?
- Gem.post_install do |gem_installer|
- unless (ENV['JARS_SKIP'] || ENV_JAVA['jars.skip']) == 'true'
- require 'jars/installer'
- jars = Jars::Installer.new( gem_installer.spec )
- jars.ruby_maven_install_options = gem_installer.options || {}
- jars.vendor_jars
- end
- end
-end
diff --git a/src/main/resources/stdlib/jars/setup.rb b/src/main/resources/stdlib/jars/setup.rb
deleted file mode 100644
index 965462f..0000000
--- a/src/main/resources/stdlib/jars/setup.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# to do as bundler does and allow to load Jars.lock via
-# require 'jars/setup'. can be useful via commandline -rjars/setup
-# or tell bundler autorequire to load it
-
-require 'jar_dependencies'
-
-Jars.require_jars_lock!
diff --git a/src/main/resources/stdlib/jars/version.rb b/src/main/resources/stdlib/jars/version.rb
deleted file mode 100644
index 55d64b2..0000000
--- a/src/main/resources/stdlib/jars/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Jars
- VERSION = '0.1.15'.freeze
-end
diff --git a/src/main/resources/stdlib/java/inspect.rb b/src/main/resources/stdlib/java/inspect.rb
deleted file mode 100644
index b64fe6c..0000000
--- a/src/main/resources/stdlib/java/inspect.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'jruby'
-
-class Java::JavaLang::Object
- def inspect()
- # '<#Java::MyPackage::TheClass:0xDECAFBAD '
- header = "#<#{self.class}:0x#{Java::JavaLang::System::identity_hash_code(self).to_s(16)} "
- # Bail quickly if looping
- return header + "...>" if JRuby.runtime.inspecting?(self)
- begin
- fs = self.java_class.declared_fields # get fields
- fvals = []
- JRuby.runtime.register_inspecting(self) # loop protection
- fs.each do |f|
- f.accessible=true # let us prod everything. Invasive :-(
- fvals << "@#{f.name} = #{f.value(self).inspect}" if !f.static?
- end
- header + "#{fvals.join(', ')}>"
- ensure
- JRuby.runtime.unregister_inspecting(self) # undo loop protection
- end
- end
-end
diff --git a/src/main/resources/stdlib/jline/jline/2.11/jline-2.11.jar b/src/main/resources/stdlib/jline/jline/2.11/jline-2.11.jar
deleted file mode 100644
index 9604bd2..0000000
Binary files a/src/main/resources/stdlib/jline/jline/2.11/jline-2.11.jar and /dev/null differ
diff --git a/src/main/resources/stdlib/jopenssl.jar b/src/main/resources/stdlib/jopenssl.jar
deleted file mode 100644
index 515b137..0000000
Binary files a/src/main/resources/stdlib/jopenssl.jar and /dev/null differ
diff --git a/src/main/resources/stdlib/jopenssl/load.rb b/src/main/resources/stdlib/jopenssl/load.rb
deleted file mode 100644
index 3cabe2c..0000000
--- a/src/main/resources/stdlib/jopenssl/load.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-warn 'Loading jruby-openssl in a non-JRuby interpreter' unless defined? JRUBY_VERSION
-
-require 'java'
-require 'jopenssl/version'
-
-version = Jopenssl::Version::BOUNCY_CASTLE_VERSION
-bc_jars = nil
-begin
- # if we have jar-dependencies we let it track the jars
- require_jar( 'org.bouncycastle', 'bcpkix-jdk15on', version )
- require_jar( 'org.bouncycastle', 'bcprov-jdk15on', version )
- bc_jars = true
-rescue LoadError
-end if defined?(Jars) && ( ! Jars.skip? ) rescue nil
-unless bc_jars
- load "org/bouncycastle/bcpkix-jdk15on/#{version}/bcpkix-jdk15on-#{version}.jar"
- load "org/bouncycastle/bcprov-jdk15on/#{version}/bcprov-jdk15on-#{version}.jar"
-end
-
-require 'jruby'
-require 'jopenssl.jar'
-org.jruby.ext.openssl.OpenSSL.load(JRuby.runtime)
-
-if RUBY_VERSION >= '2.1.0'
- load('jopenssl21/openssl.rb')
-elsif RUBY_VERSION >= '1.9.0'
- load('jopenssl19/openssl.rb')
-else
- load('jopenssl18/openssl.rb')
-end
-
-require 'openssl/pkcs12'
diff --git a/src/main/resources/stdlib/jopenssl/version.rb b/src/main/resources/stdlib/jopenssl/version.rb
deleted file mode 100644
index 8769020..0000000
--- a/src/main/resources/stdlib/jopenssl/version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Jopenssl
- module Version
- VERSION = '0.9.7'
- BOUNCY_CASTLE_VERSION = '1.50'
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl18/openssl.rb b/src/main/resources/stdlib/jopenssl18/openssl.rb
deleted file mode 100644
index 2469634..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-=begin
-= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2002 Michal Rokos
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id: openssl.rb 12496 2007-06-08 15:02:04Z technorama $
-=end
-
-require 'openssl/bn'
-require 'openssl/cipher'
-require 'openssl/config'
-require 'openssl/digest'
-require 'openssl/pkcs7'
-require 'openssl/ssl-internal'
-require 'openssl/x509-internal'
diff --git a/src/main/resources/stdlib/jopenssl18/openssl/bn.rb b/src/main/resources/stdlib/jopenssl18/openssl/bn.rb
deleted file mode 100644
index 2c38224..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl/bn.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-=begin
-= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for BN
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2002 Michal Rokos
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-##
-# Add double dispatch to Integer
-#
-class Integer
- def to_bn
- OpenSSL::BN::new(self.to_s(16), 16)
- end
-end # Integer
-
diff --git a/src/main/resources/stdlib/jopenssl18/openssl/buffering.rb b/src/main/resources/stdlib/jopenssl18/openssl/buffering.rb
deleted file mode 100644
index c83b92b..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl/buffering.rb
+++ /dev/null
@@ -1,241 +0,0 @@
-=begin
-= $RCSfile$ -- Buffering mix-in module.
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2001 GOTOU YUUZOU
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-module OpenSSL
-module Buffering
- include Enumerable
- attr_accessor :sync
- BLOCK_SIZE = 1024*16
-
- def initialize(*args)
- @eof = false
- @rbuffer = ""
- @sync = @io.sync
- end
-
- #
- # for reading.
- #
- private
-
- def fill_rbuff
- begin
- @rbuffer << self.sysread(BLOCK_SIZE)
- rescue Errno::EAGAIN
- retry
- rescue EOFError
- @eof = true
- end
- end
-
- def consume_rbuff(size=nil)
- if @rbuffer.empty?
- nil
- else
- size = @rbuffer.size unless size
- ret = @rbuffer[0, size]
- @rbuffer[0, size] = ""
- ret
- end
- end
-
- public
-
- def read(size=nil, buf=nil)
- if size == 0
- if buf
- buf.clear
- else
- buf = ""
- end
- return @eof ? nil : buf
- end
- until @eof
- break if size && size <= @rbuffer.size
- fill_rbuff
- end
- ret = consume_rbuff(size) || ""
- if buf
- buf.replace(ret)
- ret = buf
- end
- (size && ret.empty?) ? nil : ret
- end
-
- def readpartial(maxlen, buf=nil)
- if maxlen == 0
- if buf
- buf.clear
- else
- buf = ""
- end
- return @eof ? nil : buf
- end
- if @rbuffer.empty?
- begin
- return sysread(maxlen, buf)
- rescue Errno::EAGAIN
- retry
- end
- end
- ret = consume_rbuff(maxlen)
- if buf
- buf.replace(ret)
- ret = buf
- end
- raise EOFError if ret.empty?
- ret
- end
-
- def gets(eol=$/)
- idx = @rbuffer.index(eol)
- until @eof
- break if idx
- fill_rbuff
- idx = @rbuffer.index(eol)
- end
- if eol.is_a?(Regexp)
- size = idx ? idx+$&.size : nil
- else
- size = idx ? idx+eol.size : nil
- end
- consume_rbuff(size)
- end
-
- def each(eol=$/)
- while line = self.gets(eol)
- yield line
- end
- end
- alias each_line each
-
- def readlines(eol=$/)
- ary = []
- while line = self.gets(eol)
- ary << line
- end
- ary
- end
-
- def readline(eol=$/)
- raise EOFError if eof?
- gets(eol)
- end
-
- def getc
- c = read(1)
- c ? c[0] : nil
- end
-
- def each_byte
- while c = getc
- yield(c)
- end
- end
-
- def readchar
- raise EOFError if eof?
- getc
- end
-
- def ungetc(c)
- @rbuffer[0,0] = c.chr
- end
-
- def eof?
- fill_rbuff if !@eof && @rbuffer.empty?
- @eof && @rbuffer.empty?
- end
- alias eof eof?
-
- #
- # for writing.
- #
- private
-
- def do_write(s)
- @wbuffer = "" unless defined? @wbuffer
- @wbuffer << s
- @sync ||= false
- if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
- remain = idx ? idx + $/.size : @wbuffer.length
- nwritten = 0
- while remain > 0
- str = @wbuffer[nwritten,remain]
- begin
- nwrote = syswrite(str)
- rescue Errno::EAGAIN
- retry
- end
- remain -= nwrote
- nwritten += nwrote
- end
- @wbuffer[0,nwritten] = ""
- end
- end
-
- public
-
- def write(s)
- do_write(s)
- s.length
- end
-
- def << (s)
- do_write(s)
- self
- end
-
- def puts(*args)
- s = ""
- if args.empty?
- s << "\n"
- end
- args.each{|arg|
- s << arg.to_s
- if $/ && /\n\z/ !~ s
- s << "\n"
- end
- }
- do_write(s)
- nil
- end
-
- def print(*args)
- s = ""
- args.each{ |arg| s << arg.to_s }
- do_write(s)
- nil
- end
-
- def printf(s, *args)
- do_write(s % args)
- nil
- end
-
- def flush
- osync = @sync
- @sync = true
- do_write ""
- @sync = osync
- end
-
- def close
- flush rescue nil
- sysclose
- end
-end
-end
diff --git a/src/main/resources/stdlib/jopenssl18/openssl/cipher.rb b/src/main/resources/stdlib/jopenssl18/openssl/cipher.rb
deleted file mode 100644
index 3e8307f..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl/cipher.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-=begin
-= $RCSfile$ -- Ruby-space predefined Cipher subclasses
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2002 Michal Rokos
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-##
-# Should we care what if somebody require this file directly?
-#require 'openssl'
-
-module OpenSSL
- class Cipher
- # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
- class Cipher < Cipher
- # add warning
- end
- end # Cipher
-end # OpenSSL
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jopenssl18/openssl/config.rb b/src/main/resources/stdlib/jopenssl18/openssl/config.rb
deleted file mode 100644
index 21c98b7..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl/config.rb
+++ /dev/null
@@ -1,316 +0,0 @@
-=begin
-= Ruby-space definitions that completes C-space funcs for Config
-
-= Info
- Copyright (C) 2010 Hiroshi Nakamura
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-=end
-
-##
-# Should we care what if somebody require this file directly?
-#require 'openssl'
-require 'stringio'
-
-module OpenSSL
- class Config
- include Enumerable
-
- class << self
- def parse(str)
- c = new()
- parse_config(StringIO.new(str)).each do |section, hash|
- c[section] = hash
- end
- c
- end
-
- alias load new
-
- def parse_config(io)
- begin
- parse_config_lines(io)
- rescue ConfigError => e
- e.message.replace("error in line #{io.lineno}: " + e.message)
- raise
- end
- end
-
- def get_key_string(data, section, key) # :nodoc:
- if v = data[section] && data[section][key]
- return v
- elsif section == 'ENV'
- if v = ENV[key]
- return v
- end
- end
- if v = data['default'] && data['default'][key]
- return v
- end
- end
-
- private
-
- def parse_config_lines(io)
- section = 'default'
- data = {section => {}}
- while definition = get_definition(io)
- definition = clear_comments(definition)
- next if definition.empty?
- if definition[0] == ?[
- if /\[([^\]]*)\]/ =~ definition
- section = $1.strip
- data[section] ||= {}
- else
- raise ConfigError, "missing close square bracket"
- end
- else
- if /\A([^:\s]*)(?:::([^:\s]*))?\s*=(.*)\z/ =~ definition
- if $2
- section = $1
- key = $2
- else
- key = $1
- end
- value = unescape_value(data, section, $3)
- (data[section] ||= {})[key] = value.strip
- else
- raise ConfigError, "missing equal sign"
- end
- end
- end
- data
- end
-
- # escape with backslash
- QUOTE_REGEXP_SQ = /\A([^'\\]*(?:\\.[^'\\]*)*)'/
- # escape with backslash and doubled dq
- QUOTE_REGEXP_DQ = /\A([^"\\]*(?:""[^"\\]*|\\.[^"\\]*)*)"/
- # escaped char map
- ESCAPE_MAP = {
- "r" => "\r",
- "n" => "\n",
- "b" => "\b",
- "t" => "\t",
- }
-
- def unescape_value(data, section, value)
- scanned = []
- while m = value.match(/['"\\$]/)
- scanned << m.pre_match
- c = m[0]
- value = m.post_match
- case c
- when "'"
- if m = value.match(QUOTE_REGEXP_SQ)
- scanned << m[1].gsub(/\\(.)/, '\\1')
- value = m.post_match
- else
- break
- end
- when '"'
- if m = value.match(QUOTE_REGEXP_DQ)
- scanned << m[1].gsub(/""/, '').gsub(/\\(.)/, '\\1')
- value = m.post_match
- else
- break
- end
- when "\\"
- c = value.slice!(0, 1)
- scanned << (ESCAPE_MAP[c] || c)
- when "$"
- ref, value = extract_reference(value)
- refsec = section
- if ref.index('::')
- refsec, ref = ref.split('::', 2)
- end
- if v = get_key_string(data, refsec, ref)
- scanned << v
- else
- raise ConfigError, "variable has no value"
- end
- else
- raise 'must not reaced'
- end
- end
- scanned << value
- scanned.join
- end
-
- def extract_reference(value)
- rest = ''
- if m = value.match(/\(([^)]*)\)|\{([^}]*)\}/)
- value = m[1] || m[2]
- rest = m.post_match
- elsif [?(, ?{].include?(value[0])
- raise ConfigError, "no close brace"
- end
- if m = value.match(/[a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]*)?/)
- return m[0], m.post_match + rest
- else
- raise
- end
- end
-
- def clear_comments(line)
- # FCOMMENT
- if m = line.match(/\A([\t\n\f ]*);.*\z/)
- return m[1]
- end
- # COMMENT
- scanned = []
- while m = line.match(/[#'"\\]/)
- scanned << m.pre_match
- c = m[0]
- line = m.post_match
- case c
- when '#'
- line = nil
- break
- when "'", '"'
- regexp = (c == "'") ? QUOTE_REGEXP_SQ : QUOTE_REGEXP_DQ
- scanned << c
- if m = line.match(regexp)
- scanned << m[0]
- line = m.post_match
- else
- scanned << line
- line = nil
- break
- end
- when "\\"
- scanned << c
- scanned << line.slice!(0, 1)
- else
- raise 'must not reaced'
- end
- end
- scanned << line
- scanned.join
- end
-
- def get_definition(io)
- if line = get_line(io)
- while /[^\\]\\\z/ =~ line
- if extra = get_line(io)
- line += extra
- else
- break
- end
- end
- return line.strip
- end
- end
-
- def get_line(io)
- if line = io.gets
- line.gsub(/[\r\n]*/, '')
- end
- end
- end
-
- def initialize(filename = nil)
- @data = {}
- if filename
- File.open(filename.to_s) do |file|
- Config.parse_config(file).each do |section, hash|
- self[section] = hash
- end
- end
- end
- end
-
- def get_value(section, key)
- if section.nil?
- raise TypeError.new('nil not allowed')
- end
- section = 'default' if section.empty?
- get_key_string(section, key)
- end
-
- def value(arg1, arg2 = nil)
- warn('Config#value is deprecated; use Config#get_value')
- if arg2.nil?
- section, key = 'default', arg1
- else
- section, key = arg1, arg2
- end
- section ||= 'default'
- section = 'default' if section.empty?
- get_key_string(section, key)
- end
-
- def add_value(section, key, value)
- check_modify
- (@data[section] ||= {})[key] = value
- end
-
- def [](section)
- @data[section] || {}
- end
-
- def section(name)
- warn('Config#section is deprecated; use Config#[]')
- @data[name] || {}
- end
-
- def []=(section, pairs)
- check_modify
- @data[section] ||= {}
- pairs.each do |key, value|
- self.add_value(section, key, value)
- end
- end
-
- def sections
- @data.keys
- end
-
- def to_s
- ary = []
- @data.keys.sort.each do |section|
- ary << "[ #{section} ]\n"
- @data[section].keys.each do |key|
- ary << "#{key}=#{@data[section][key]}\n"
- end
- ary << "\n"
- end
- ary.join
- end
-
- def each
- @data.each do |section, hash|
- hash.each do |key, value|
- yield(section, key, value)
- end
- end
- end
-
- def inspect
- "#<#{self.class.name} sections=#{sections.inspect}>"
- end
-
- protected
-
- def data
- @data
- end
-
- private
-
- def initialize_copy(other)
- @data = other.data.dup
- end
-
- def check_modify
- raise TypeError.new("Insecure: can't modify OpenSSL config") if frozen?
- end
-
- def get_key_string(section, key)
- Config.get_key_string(@data, section, key)
- end
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl18/openssl/digest.rb b/src/main/resources/stdlib/jopenssl18/openssl/digest.rb
deleted file mode 100644
index 1229008..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl/digest.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-=begin
-= $RCSfile$ -- Ruby-space predefined Digest subclasses
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2002 Michal Rokos
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-##
-# Should we care what if somebody require this file directly?
-#require 'openssl'
-
-module OpenSSL
- class Digest
- # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
- class Digest < Digest
- def initialize(*args)
- # add warning
- super(*args)
- end
- end
- end # Digest
-end # OpenSSL
-
diff --git a/src/main/resources/stdlib/jopenssl18/openssl/pkcs7.rb b/src/main/resources/stdlib/jopenssl18/openssl/pkcs7.rb
deleted file mode 100644
index 1f88c1d..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl/pkcs7.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-=begin
-= $RCSfile$ -- PKCS7
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id: digest.rb 12148 2007-04-05 05:59:22Z technorama $
-=end
-
-module OpenSSL
- class PKCS7
- # This class is only provided for backwards compatibility. Use OpenSSL::PKCS7 in the future.
- class PKCS7 < PKCS7
- def initialize(*args)
- super(*args)
-
- warn("Warning: OpenSSL::PKCS7::PKCS7 is deprecated after Ruby 1.9; use OpenSSL::PKCS7 instead")
- end
- end
-
- end # PKCS7
-end # OpenSSL
-
diff --git a/src/main/resources/stdlib/jopenssl18/openssl/ssl-internal.rb b/src/main/resources/stdlib/jopenssl18/openssl/ssl-internal.rb
deleted file mode 100644
index 95d8b5d..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl/ssl-internal.rb
+++ /dev/null
@@ -1,155 +0,0 @@
-=begin
-= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2001 GOTOU YUUZOU
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-require "openssl/buffering"
-require "fcntl"
-
-module OpenSSL
- module SSL
- module SocketForwarder
- def addr
- to_io.addr
- end
-
- def peeraddr
- to_io.peeraddr
- end
-
- def setsockopt(level, optname, optval)
- to_io.setsockopt(level, optname, optval)
- end
-
- def getsockopt(level, optname)
- to_io.getsockopt(level, optname)
- end
-
- def fcntl(*args)
- to_io.fcntl(*args)
- end
-
- def closed?
- to_io.closed?
- end
-
- def do_not_reverse_lookup=(flag)
- to_io.do_not_reverse_lookup = flag
- end
- end
-
- module Nonblock
- def initialize(*args)
- flag = File::NONBLOCK
- flag |= @io.fcntl(Fcntl::F_GETFL) if defined?(Fcntl::F_GETFL)
- @io.fcntl(Fcntl::F_SETFL, flag)
- super
- end
- end
-
- def verify_certificate_identity(cert, hostname)
- should_verify_common_name = true
- cert.extensions.each{|ext|
- next if ext.oid != "subjectAltName"
- ext.value.split(/,\s+/).each{|general_name|
- if /\ADNS:(.*)/ =~ general_name
- should_verify_common_name = false
- reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- # NOTE: somehow we need the IP: canonical form
- # seems there were failures elsewhere when not
- # not sure how that's possible possible to-do!
- elsif /\AIP(?: Address)?:(.*)/ =~ general_name
- #elsif /\AIP Address:(.*)/ =~ general_name
- should_verify_common_name = false
- return true if $1 == hostname
- end
- }
- }
- if should_verify_common_name
- cert.subject.to_a.each{|oid, value|
- if oid == "CN"
- reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- end
- }
- end
- return false
- end
- module_function :verify_certificate_identity
-
- class SSLSocket
- include Buffering
- include SocketForwarder
- include Nonblock
-
- def post_connection_check(hostname)
- unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname)
- raise SSLError, "hostname was not match with the server certificate"
- end
- return true
- end
-
- def session
- SSL::Session.new(self)
- rescue SSL::Session::SessionError
- nil
- end
- end
-
- class SSLServer
- include SocketForwarder
- attr_accessor :start_immediately
-
- def initialize(svr, ctx)
- @svr = svr
- @ctx = ctx
- unless ctx.session_id_context
- session_id = OpenSSL::Digest::MD5.hexdigest($0)
- @ctx.session_id_context = session_id
- end
- @start_immediately = true
- end
-
- def to_io
- @svr
- end
-
- def listen(backlog=5)
- @svr.listen(backlog)
- end
-
- def shutdown(how=Socket::SHUT_RDWR)
- @svr.shutdown(how)
- end
-
- def accept
- sock = @svr.accept
- begin
- ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
- ssl.sync_close = true
- ssl.accept if @start_immediately
- ssl
- rescue SSLError => ex
- sock.close
- raise ex
- end
- end
-
- def close
- @svr.close
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl18/openssl/ssl.rb b/src/main/resources/stdlib/jopenssl18/openssl/ssl.rb
deleted file mode 100644
index 3f17f5a..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl/ssl.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'openssl'
diff --git a/src/main/resources/stdlib/jopenssl18/openssl/x509-internal.rb b/src/main/resources/stdlib/jopenssl18/openssl/x509-internal.rb
deleted file mode 100644
index d1c30e8..0000000
--- a/src/main/resources/stdlib/jopenssl18/openssl/x509-internal.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-=begin
-= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for X509 and subclasses
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2002 Michal Rokos
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-module OpenSSL
- module X509
- class Name
- module RFC2253DN
- Special = ',=+<>#;'
- HexChar = /[0-9a-fA-F]/
- HexPair = /#{HexChar}#{HexChar}/
- HexString = /#{HexPair}+/
- Pair = /\\(?:[#{Special}]|\\|"|#{HexPair})/
- StringChar = /[^#{Special}\\"]/
- QuoteChar = /[^\\"]/
- AttributeType = /[a-zA-Z][0-9a-zA-Z]*|[0-9]+(?:\.[0-9]+)*/
- AttributeValue = /
- (?!["#])((?:#{StringChar}|#{Pair})*)|
- \#(#{HexString})|
- "((?:#{QuoteChar}|#{Pair})*)"
- /x
- TypeAndValue = /\A(#{AttributeType})=#{AttributeValue}/
-
- module_function
-
- def expand_pair(str)
- return nil unless str
- return str.gsub(Pair){
- pair = $&
- case pair.size
- when 2 then pair[1,1]
- when 3 then Integer("0x#{pair[1,2]}").chr
- else raise OpenSSL::X509::NameError, "invalid pair: #{str}"
- end
- }
- end
-
- def expand_hexstring(str)
- return nil unless str
- der = str.gsub(HexPair){$&.to_i(16).chr }
- a1 = OpenSSL::ASN1.decode(der)
- return a1.value, a1.tag
- end
-
- def expand_value(str1, str2, str3)
- value = expand_pair(str1)
- value, tag = expand_hexstring(str2) unless value
- value = expand_pair(str3) unless value
- return value, tag
- end
-
- def scan(dn)
- str = dn
- ary = []
- while true
- if md = TypeAndValue.match(str)
- matched = md.to_s
- remain = md.post_match
- type = md[1]
- value, tag = expand_value(md[2], md[3], md[4]) rescue nil
- if value
- type_and_value = [type, value]
- type_and_value.push(tag) if tag
- ary.unshift(type_and_value)
- if remain.length > 2 && remain[0] == ?,
- str = remain[1..-1]
- next
- elsif remain.length > 2 && remain[0] == ?+
- raise OpenSSL::X509::NameError,
- "multi-valued RDN is not supported: #{dn}"
- elsif remain.empty?
- break
- end
- end
- end
- msg_dn = dn[0, dn.length - str.length] + " =>" + str
- raise OpenSSL::X509::NameError, "malformed RDN: #{msg_dn}"
- end
- return ary
- end
- end
-
- class <
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-require 'openssl/bn'
-require 'openssl/cipher'
-require 'openssl/config'
-require 'openssl/digest'
-require 'openssl/ssl-internal'
-require 'openssl/x509-internal'
diff --git a/src/main/resources/stdlib/jopenssl19/openssl/bn.rb b/src/main/resources/stdlib/jopenssl19/openssl/bn.rb
deleted file mode 100644
index 3933ee3..0000000
--- a/src/main/resources/stdlib/jopenssl19/openssl/bn.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-#--
-#
-# $RCSfile$
-#
-# = Ruby-space definitions that completes C-space funcs for BN
-#
-# = Info
-# 'OpenSSL for Ruby 2' project
-# Copyright (C) 2002 Michal Rokos
-# All rights reserved.
-#
-# = Licence
-# This program is licenced under the same licence as Ruby.
-# (See the file 'LICENCE'.)
-#
-# = Version
-# $Id$
-#
-#++
-
-##
-# Add double dispatch to Integer
-#
-class Integer
- def to_bn
- OpenSSL::BN::new(self)
- end
-end # Integer
-
diff --git a/src/main/resources/stdlib/jopenssl19/openssl/buffering.rb b/src/main/resources/stdlib/jopenssl19/openssl/buffering.rb
deleted file mode 100644
index 51bc968..0000000
--- a/src/main/resources/stdlib/jopenssl19/openssl/buffering.rb
+++ /dev/null
@@ -1,449 +0,0 @@
-=begin
-= $RCSfile$ -- Buffering mix-in module.
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2001 GOTOU YUUZOU
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-##
-# OpenSSL IO buffering mix-in module.
-#
-# This module allows an OpenSSL::SSL::SSLSocket to behave like an IO.
-
-module OpenSSL::Buffering
- include Enumerable
-
- ##
- # The "sync mode" of the SSLSocket.
- #
- # See IO#sync for full details.
-
- attr_accessor :sync
-
- ##
- # Default size to read from or write to the SSLSocket for buffer operations.
-
- BLOCK_SIZE = 1024*16
-
- def initialize(*args)
- @eof = false
- @rbuffer = ""
- @sync = @io.sync
- end
-
- #
- # for reading.
- #
- private
-
- ##
- # Fills the buffer from the underlying SSLSocket
-
- def fill_rbuff
- begin
- @rbuffer << self.sysread(BLOCK_SIZE)
- rescue Errno::EAGAIN
- retry
- rescue EOFError
- @eof = true
- end
- end
-
- ##
- # Consumes +size+ bytes from the buffer
-
- def consume_rbuff(size=nil)
- if @rbuffer.empty?
- nil
- else
- size = @rbuffer.size unless size
- ret = @rbuffer[0, size]
- @rbuffer[0, size] = ""
- ret
- end
- end
-
- public
-
- ##
- # Reads +size+ bytes from the stream. If +buf+ is provided it must
- # reference a string which will receive the data.
- #
- # See IO#read for full details.
-
- def read(size=nil, buf=nil)
- if size == 0
- if buf
- buf.clear
- return buf
- else
- return ""
- end
- end
- until @eof
- break if size && size <= @rbuffer.size
- fill_rbuff
- end
- ret = consume_rbuff(size) || ""
- if buf
- buf.replace(ret)
- ret = buf
- end
- (size && ret.empty?) ? nil : ret
- end
-
- ##
- # Reads at most +maxlen+ bytes from the stream. If +buf+ is provided it
- # must reference a string which will receive the data.
- #
- # See IO#readpartial for full details.
-
- def readpartial(maxlen, buf=nil)
- if maxlen == 0
- if buf
- buf.clear
- return buf
- else
- return ""
- end
- end
- if @rbuffer.empty?
- begin
- return sysread(maxlen, buf)
- rescue Errno::EAGAIN
- retry
- end
- end
- ret = consume_rbuff(maxlen)
- if buf
- buf.replace(ret)
- ret = buf
- end
- raise EOFError if ret.empty?
- ret
- end
-
- ##
- # Reads at most +maxlen+ bytes in the non-blocking manner.
- #
- # When no data can be read without blocking it raises
- # OpenSSL::SSL::SSLError extended by IO::WaitReadable or IO::WaitWritable.
- #
- # IO::WaitReadable means SSL needs to read internally so read_nonblock
- # should be called again when the underlying IO is readable.
- #
- # IO::WaitWritable means SSL needs to write internally so read_nonblock
- # should be called again after the underlying IO is writable.
- #
- # OpenSSL::Buffering#read_nonblock needs two rescue clause as follows:
- #
- # # emulates blocking read (readpartial).
- # begin
- # result = ssl.read_nonblock(maxlen)
- # rescue IO::WaitReadable
- # IO.select([io])
- # retry
- # rescue IO::WaitWritable
- # IO.select(nil, [io])
- # retry
- # end
- #
- # Note that one reason that read_nonblock writes to the underlying IO is
- # when the peer requests a new TLS/SSL handshake. See openssl the FAQ for
- # more details. http://www.openssl.org/support/faq.html
-
- def read_nonblock(maxlen, buf=nil)
- if maxlen == 0
- if buf
- buf.clear
- return buf
- else
- return ""
- end
- end
- if @rbuffer.empty?
- return sysread_nonblock(maxlen, buf)
- end
- ret = consume_rbuff(maxlen)
- if buf
- buf.replace(ret)
- ret = buf
- end
- raise EOFError if ret.empty?
- ret
- end
-
- ##
- # Reads the next "line+ from the stream. Lines are separated by +eol+. If
- # +limit+ is provided the result will not be longer than the given number of
- # bytes.
- #
- # +eol+ may be a String or Regexp.
- #
- # Unlike IO#gets the line read will not be assigned to +$_+.
- #
- # Unlike IO#gets the separator must be provided if a limit is provided.
-
- def gets(eol=$/, limit=nil)
- idx = @rbuffer.index(eol)
- until @eof
- break if idx
- fill_rbuff
- idx = @rbuffer.index(eol)
- end
- if eol.is_a?(Regexp)
- size = idx ? idx+$&.size : nil
- else
- size = idx ? idx+eol.size : nil
- end
- if limit and limit >= 0
- size = [size, limit].min
- end
- consume_rbuff(size)
- end
-
- ##
- # Executes the block for every line in the stream where lines are separated
- # by +eol+.
- #
- # See also #gets
-
- def each(eol=$/)
- while line = self.gets(eol)
- yield line
- end
- end
- alias each_line each
-
- ##
- # Reads lines from the stream which are separated by +eol+.
- #
- # See also #gets
-
- def readlines(eol=$/)
- ary = []
- while line = self.gets(eol)
- ary << line
- end
- ary
- end
-
- ##
- # Reads a line from the stream which is separated by +eol+.
- #
- # Raises EOFError if at end of file.
-
- def readline(eol=$/)
- raise EOFError if eof?
- gets(eol)
- end
-
- ##
- # Reads one character from the stream. Returns nil if called at end of
- # file.
-
- def getc
- read(1)
- end
-
- ##
- # Calls the given block once for each byte in the stream.
-
- def each_byte # :yields: byte
- while c = getc
- yield(c.ord)
- end
- end
-
- ##
- # Reads a one-character string from the stream. Raises an EOFError at end
- # of file.
-
- def readchar
- raise EOFError if eof?
- getc
- end
-
- ##
- # Pushes character +c+ back onto the stream such that a subsequent buffered
- # character read will return it.
- #
- # Unlike IO#getc multiple bytes may be pushed back onto the stream.
- #
- # Has no effect on unbuffered reads (such as #sysread).
-
- def ungetc(c)
- @rbuffer[0,0] = c.chr
- end
-
- ##
- # Returns true if the stream is at file which means there is no more data to
- # be read.
-
- def eof?
- fill_rbuff if !@eof && @rbuffer.empty?
- @eof && @rbuffer.empty?
- end
- alias eof eof?
-
- #
- # for writing.
- #
- private
-
- ##
- # Writes +s+ to the buffer. When the buffer is full or #sync is true the
- # buffer is flushed to the underlying socket.
-
- def do_write(s)
- @wbuffer = "" unless defined? @wbuffer
- @wbuffer << s
- @wbuffer.force_encoding(Encoding::BINARY)
- @sync ||= false
- if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
- remain = idx ? idx + $/.size : @wbuffer.length
- nwritten = 0
- while remain > 0
- str = @wbuffer[nwritten,remain]
- begin
- nwrote = syswrite(str)
- rescue Errno::EAGAIN
- retry
- end
- remain -= nwrote
- nwritten += nwrote
- end
- @wbuffer[0,nwritten] = ""
- end
- end
-
- public
-
- ##
- # Writes +s+ to the stream. If the argument is not a string it will be
- # converted using String#to_s. Returns the number of bytes written.
-
- def write(s)
- do_write(s)
- s.bytesize
- end
-
- ##
- # Writes +str+ in the non-blocking manner.
- #
- # If there is buffered data, it is flushed first. This may block.
- #
- # write_nonblock returns number of bytes written to the SSL connection.
- #
- # When no data can be written without blocking it raises
- # OpenSSL::SSL::SSLError extended by IO::WaitReadable or IO::WaitWritable.
- #
- # IO::WaitReadable means SSL needs to read internally so write_nonblock
- # should be called again after the underlying IO is readable.
- #
- # IO::WaitWritable means SSL needs to write internally so write_nonblock
- # should be called again after underlying IO is writable.
- #
- # So OpenSSL::Buffering#write_nonblock needs two rescue clause as follows.
- #
- # # emulates blocking write.
- # begin
- # result = ssl.write_nonblock(str)
- # rescue IO::WaitReadable
- # IO.select([io])
- # retry
- # rescue IO::WaitWritable
- # IO.select(nil, [io])
- # retry
- # end
- #
- # Note that one reason that write_nonblock reads from the underlying IO
- # is when the peer requests a new TLS/SSL handshake. See the openssl FAQ
- # for more details. http://www.openssl.org/support/faq.html
-
- def write_nonblock(s)
- flush
- syswrite_nonblock(s)
- end
-
- ##
- # Writes +s+ to the stream. +s+ will be converted to a String using
- # String#to_s.
-
- def << (s)
- do_write(s)
- self
- end
-
- ##
- # Writes +args+ to the stream along with a record separator.
- #
- # See IO#puts for full details.
-
- def puts(*args)
- s = ""
- if args.empty?
- s << "\n"
- end
- args.each{|arg|
- s << arg.to_s
- if $/ && /\n\z/ !~ s
- s << "\n"
- end
- }
- do_write(s)
- nil
- end
-
- ##
- # Writes +args+ to the stream.
- #
- # See IO#print for full details.
-
- def print(*args)
- s = ""
- args.each{ |arg| s << arg.to_s }
- do_write(s)
- nil
- end
-
- ##
- # Formats and writes to the stream converting parameters under control of
- # the format string.
- #
- # See Kernel#sprintf for format string details.
-
- def printf(s, *args)
- do_write(s % args)
- nil
- end
-
- ##
- # Flushes buffered data to the SSLSocket.
-
- def flush
- osync = @sync
- @sync = true
- do_write ""
- return self
- ensure
- @sync = osync
- end
-
- ##
- # Closes the SSLSocket and flushes any unwritten data.
-
- def close
- flush rescue nil
- sysclose
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl19/openssl/cipher.rb b/src/main/resources/stdlib/jopenssl19/openssl/cipher.rb
deleted file mode 100644
index b254a23..0000000
--- a/src/main/resources/stdlib/jopenssl19/openssl/cipher.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-#--
-#
-# $RCSfile$
-#
-# = Ruby-space predefined Cipher subclasses
-#
-# = Info
-# 'OpenSSL for Ruby 2' project
-# Copyright (C) 2002 Michal Rokos
-# All rights reserved.
-#
-# = Licence
-# This program is licenced under the same licence as Ruby.
-# (See the file 'LICENCE'.)
-#
-# = Version
-# $Id$
-#
-#++
-
-module OpenSSL
- class Cipher
- # This class is only provided for backwards compatibility. Use OpenSSL::Cipher in the future.
- class Cipher < Cipher
- # add warning
- end
- end # Cipher
-end # OpenSSL
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jopenssl19/openssl/config.rb b/src/main/resources/stdlib/jopenssl19/openssl/config.rb
deleted file mode 100644
index 24a54c9..0000000
--- a/src/main/resources/stdlib/jopenssl19/openssl/config.rb
+++ /dev/null
@@ -1,313 +0,0 @@
-=begin
-= Ruby-space definitions that completes C-space funcs for Config
-
-= Info
- Copyright (C) 2010 Hiroshi Nakamura
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-=end
-
-require 'stringio'
-
-module OpenSSL
- class Config
- include Enumerable
-
- class << self
- def parse(str)
- c = new()
- parse_config(StringIO.new(str)).each do |section, hash|
- c[section] = hash
- end
- c
- end
-
- alias load new
-
- def parse_config(io)
- begin
- parse_config_lines(io)
- rescue ConfigError => e
- e.message.replace("error in line #{io.lineno}: " + e.message)
- raise
- end
- end
-
- def get_key_string(data, section, key) # :nodoc:
- if v = data[section] && data[section][key]
- return v
- elsif section == 'ENV'
- if v = ENV[key]
- return v
- end
- end
- if v = data['default'] && data['default'][key]
- return v
- end
- end
-
- private
-
- def parse_config_lines(io)
- section = 'default'
- data = {section => {}}
- while definition = get_definition(io)
- definition = clear_comments(definition)
- next if definition.empty?
- if definition[0] == ?[
- if /\[([^\]]*)\]/ =~ definition
- section = $1.strip
- data[section] ||= {}
- else
- raise ConfigError, "missing close square bracket"
- end
- else
- if /\A([^:\s]*)(?:::([^:\s]*))?\s*=(.*)\z/ =~ definition
- if $2
- section = $1
- key = $2
- else
- key = $1
- end
- value = unescape_value(data, section, $3)
- (data[section] ||= {})[key] = value.strip
- else
- raise ConfigError, "missing equal sign"
- end
- end
- end
- data
- end
-
- # escape with backslash
- QUOTE_REGEXP_SQ = /\A([^'\\]*(?:\\.[^'\\]*)*)'/
- # escape with backslash and doubled dq
- QUOTE_REGEXP_DQ = /\A([^"\\]*(?:""[^"\\]*|\\.[^"\\]*)*)"/
- # escaped char map
- ESCAPE_MAP = {
- "r" => "\r",
- "n" => "\n",
- "b" => "\b",
- "t" => "\t",
- }
-
- def unescape_value(data, section, value)
- scanned = []
- while m = value.match(/['"\\$]/)
- scanned << m.pre_match
- c = m[0]
- value = m.post_match
- case c
- when "'"
- if m = value.match(QUOTE_REGEXP_SQ)
- scanned << m[1].gsub(/\\(.)/, '\\1')
- value = m.post_match
- else
- break
- end
- when '"'
- if m = value.match(QUOTE_REGEXP_DQ)
- scanned << m[1].gsub(/""/, '').gsub(/\\(.)/, '\\1')
- value = m.post_match
- else
- break
- end
- when "\\"
- c = value.slice!(0, 1)
- scanned << (ESCAPE_MAP[c] || c)
- when "$"
- ref, value = extract_reference(value)
- refsec = section
- if ref.index('::')
- refsec, ref = ref.split('::', 2)
- end
- if v = get_key_string(data, refsec, ref)
- scanned << v
- else
- raise ConfigError, "variable has no value"
- end
- else
- raise 'must not reaced'
- end
- end
- scanned << value
- scanned.join
- end
-
- def extract_reference(value)
- rest = ''
- if m = value.match(/\(([^)]*)\)|\{([^}]*)\}/)
- value = m[1] || m[2]
- rest = m.post_match
- elsif [?(, ?{].include?(value[0])
- raise ConfigError, "no close brace"
- end
- if m = value.match(/[a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]*)?/)
- return m[0], m.post_match + rest
- else
- raise
- end
- end
-
- def clear_comments(line)
- # FCOMMENT
- if m = line.match(/\A([\t\n\f ]*);.*\z/)
- return m[1]
- end
- # COMMENT
- scanned = []
- while m = line.match(/[#'"\\]/)
- scanned << m.pre_match
- c = m[0]
- line = m.post_match
- case c
- when '#'
- line = nil
- break
- when "'", '"'
- regexp = (c == "'") ? QUOTE_REGEXP_SQ : QUOTE_REGEXP_DQ
- scanned << c
- if m = line.match(regexp)
- scanned << m[0]
- line = m.post_match
- else
- scanned << line
- line = nil
- break
- end
- when "\\"
- scanned << c
- scanned << line.slice!(0, 1)
- else
- raise 'must not reaced'
- end
- end
- scanned << line
- scanned.join
- end
-
- def get_definition(io)
- if line = get_line(io)
- while /[^\\]\\\z/ =~ line
- if extra = get_line(io)
- line += extra
- else
- break
- end
- end
- return line.strip
- end
- end
-
- def get_line(io)
- if line = io.gets
- line.gsub(/[\r\n]*/, '')
- end
- end
- end
-
- def initialize(filename = nil)
- @data = {}
- if filename
- File.open(filename.to_s) do |file|
- Config.parse_config(file).each do |section, hash|
- self[section] = hash
- end
- end
- end
- end
-
- def get_value(section, key)
- if section.nil?
- raise TypeError.new('nil not allowed')
- end
- section = 'default' if section.empty?
- get_key_string(section, key)
- end
-
- def value(arg1, arg2 = nil)
- warn('Config#value is deprecated; use Config#get_value')
- if arg2.nil?
- section, key = 'default', arg1
- else
- section, key = arg1, arg2
- end
- section ||= 'default'
- section = 'default' if section.empty?
- get_key_string(section, key)
- end
-
- def add_value(section, key, value)
- check_modify
- (@data[section] ||= {})[key] = value
- end
-
- def [](section)
- @data[section] || {}
- end
-
- def section(name)
- warn('Config#section is deprecated; use Config#[]')
- @data[name] || {}
- end
-
- def []=(section, pairs)
- check_modify
- @data[section] ||= {}
- pairs.each do |key, value|
- self.add_value(section, key, value)
- end
- end
-
- def sections
- @data.keys
- end
-
- def to_s
- ary = []
- @data.keys.sort.each do |section|
- ary << "[ #{section} ]\n"
- @data[section].keys.each do |key|
- ary << "#{key}=#{@data[section][key]}\n"
- end
- ary << "\n"
- end
- ary.join
- end
-
- def each
- @data.each do |section, hash|
- hash.each do |key, value|
- yield [section, key, value]
- end
- end
- end
-
- def inspect
- "#<#{self.class.name} sections=#{sections.inspect}>"
- end
-
- protected
-
- def data
- @data
- end
-
- private
-
- def initialize_copy(other)
- @data = other.data.dup
- end
-
- def check_modify
- raise TypeError.new("Insecure: can't modify OpenSSL config") if frozen?
- end
-
- def get_key_string(section, key)
- Config.get_key_string(@data, section, key)
- end
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl19/openssl/digest.rb b/src/main/resources/stdlib/jopenssl19/openssl/digest.rb
deleted file mode 100644
index d62993b..0000000
--- a/src/main/resources/stdlib/jopenssl19/openssl/digest.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#--
-#
-# $RCSfile$
-#
-# = Ruby-space predefined Digest subclasses
-#
-# = Info
-# 'OpenSSL for Ruby 2' project
-# Copyright (C) 2002 Michal Rokos
-# All rights reserved.
-#
-# = Licence
-# This program is licenced under the same licence as Ruby.
-# (See the file 'LICENCE'.)
-#
-# = Version
-# $Id$
-#
-#++
-
-module OpenSSL
- class Digest
- # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
- class Digest < Digest
- def initialize(*args)
- # add warning
- super(*args)
- end
- end
- end # Digest
-end # OpenSSL
-
diff --git a/src/main/resources/stdlib/jopenssl19/openssl/ssl-internal.rb b/src/main/resources/stdlib/jopenssl19/openssl/ssl-internal.rb
deleted file mode 100644
index 6fb8eae..0000000
--- a/src/main/resources/stdlib/jopenssl19/openssl/ssl-internal.rb
+++ /dev/null
@@ -1,155 +0,0 @@
-=begin
-= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2001 GOTOU YUUZOU
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-require "openssl/buffering"
-require "fcntl"
-
-module OpenSSL
- module SSL
- module SocketForwarder
- def addr
- to_io.addr
- end
-
- def peeraddr
- to_io.peeraddr
- end
-
- def setsockopt(level, optname, optval)
- to_io.setsockopt(level, optname, optval)
- end
-
- def getsockopt(level, optname)
- to_io.getsockopt(level, optname)
- end
-
- def fcntl(*args)
- to_io.fcntl(*args)
- end
-
- def closed?
- to_io.closed?
- end
-
- def do_not_reverse_lookup=(flag)
- to_io.do_not_reverse_lookup = flag
- end
- end
-
- module Nonblock
- def initialize(*args)
- flag = File::NONBLOCK
- flag |= @io.fcntl(Fcntl::F_GETFL) if defined?(Fcntl::F_GETFL)
- @io.fcntl(Fcntl::F_SETFL, flag)
- super
- end
- end
-
- def verify_certificate_identity(cert, hostname)
- should_verify_common_name = true
- cert.extensions.each{|ext|
- next if ext.oid != "subjectAltName"
- ext.value.split(/,\s+/).each{|general_name|
- if /\ADNS:(.*)/ =~ general_name
- should_verify_common_name = false
- reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- # NOTE: somehow we need the IP: canonical form
- # seems there were failures elsewhere when not
- # not sure how that's possible possible to-do!
- elsif /\AIP(?: Address)?:(.*)/ =~ general_name
- #elsif /\AIP Address:(.*)/ =~ general_name
- should_verify_common_name = false
- return true if $1 == hostname
- end
- }
- }
- if should_verify_common_name
- cert.subject.to_a.each{|oid, value|
- if oid == "CN"
- reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- end
- }
- end
- return false
- end
- module_function :verify_certificate_identity
-
- class SSLSocket
- include Buffering
- include SocketForwarder
- include Nonblock
-
- def post_connection_check(hostname)
- unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname)
- raise SSLError, "hostname does not match the server certificate"
- end
- return true
- end
-
- def session
- SSL::Session.new(self)
- rescue SSL::Session::SessionError
- nil
- end
- end
-
- class SSLServer
- include SocketForwarder
- attr_accessor :start_immediately
-
- def initialize(svr, ctx)
- @svr = svr
- @ctx = ctx
- unless ctx.session_id_context
- session_id = OpenSSL::Digest::MD5.hexdigest($0)
- @ctx.session_id_context = session_id
- end
- @start_immediately = true
- end
-
- def to_io
- @svr
- end
-
- def listen(backlog=5)
- @svr.listen(backlog)
- end
-
- def shutdown(how=Socket::SHUT_RDWR)
- @svr.shutdown(how)
- end
-
- def accept
- sock = @svr.accept
- begin
- ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
- ssl.sync_close = true
- ssl.accept if @start_immediately
- ssl
- rescue SSLError => ex
- sock.close
- raise ex
- end
- end
-
- def close
- @svr.close
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl19/openssl/ssl.rb b/src/main/resources/stdlib/jopenssl19/openssl/ssl.rb
deleted file mode 100644
index 15f42d6..0000000
--- a/src/main/resources/stdlib/jopenssl19/openssl/ssl.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-warn 'deprecated openssl/ssl use: require "openssl" instead of "openssl/ssl"'
-require 'openssl'
diff --git a/src/main/resources/stdlib/jopenssl19/openssl/x509-internal.rb b/src/main/resources/stdlib/jopenssl19/openssl/x509-internal.rb
deleted file mode 100644
index 24eeff7..0000000
--- a/src/main/resources/stdlib/jopenssl19/openssl/x509-internal.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-=begin
-= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for X509 and subclasses
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2002 Michal Rokos
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-module OpenSSL
- module X509
- class Name
- module RFC2253DN
- Special = ',=+<>#;'
- HexChar = /[0-9a-fA-F]/
- HexPair = /#{HexChar}#{HexChar}/
- HexString = /#{HexPair}+/
- Pair = /\\(?:[#{Special}]|\\|"|#{HexPair})/
- StringChar = /[^#{Special}\\"]/
- QuoteChar = /[^\\"]/
- AttributeType = /[a-zA-Z][0-9a-zA-Z]*|[0-9]+(?:\.[0-9]+)*/
- AttributeValue = /
- (?!["#])((?:#{StringChar}|#{Pair})*)|
- \#(#{HexString})|
- "((?:#{QuoteChar}|#{Pair})*)"
- /x
- TypeAndValue = /\A(#{AttributeType})=#{AttributeValue}/
-
- module_function
-
- def expand_pair(str)
- return nil unless str
- return str.gsub(Pair){
- pair = $&
- case pair.size
- when 2 then pair[1,1]
- when 3 then Integer("0x#{pair[1,2]}").chr
- else raise OpenSSL::X509::NameError, "invalid pair: #{str}"
- end
- }
- end
-
- def expand_hexstring(str)
- return nil unless str
- der = str.gsub(HexPair){$&.to_i(16).chr }
- a1 = OpenSSL::ASN1.decode(der)
- return a1.value, a1.tag
- end
-
- def expand_value(str1, str2, str3)
- value = expand_pair(str1)
- value, tag = expand_hexstring(str2) unless value
- value = expand_pair(str3) unless value
- return value, tag
- end
-
- def scan(dn)
- str = dn
- ary = []
- while true
- if md = TypeAndValue.match(str)
- remain = md.post_match
- type = md[1]
- value, tag = expand_value(md[2], md[3], md[4]) rescue nil
- if value
- type_and_value = [type, value]
- type_and_value.push(tag) if tag
- ary.unshift(type_and_value)
- if remain.length > 2 && remain[0] == ?,
- str = remain[1..-1]
- next
- elsif remain.length > 2 && remain[0] == ?+
- raise OpenSSL::X509::NameError,
- "multi-valued RDN is not supported: #{dn}"
- elsif remain.empty?
- break
- end
- end
- end
- msg_dn = dn[0, dn.length - str.length] + " =>" + str
- raise OpenSSL::X509::NameError, "malformed RDN: #{msg_dn}"
- end
- return ary
- end
- end
-
- class << self
- def parse_rfc2253(str, template=OBJECT_TYPE_TEMPLATE)
- ary = OpenSSL::X509::Name::RFC2253DN.scan(str)
- self.new(ary, template)
- end
-
- def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
- ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) }
- self.new(ary, template)
- end
-
- alias parse parse_openssl
- end
- end
-
- class StoreContext
- def cleanup
- warn "(#{caller.first}) OpenSSL::X509::StoreContext#cleanup is deprecated with no replacement" if $VERBOSE
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl19/openssl/x509.rb b/src/main/resources/stdlib/jopenssl19/openssl/x509.rb
deleted file mode 100644
index f1777cd..0000000
--- a/src/main/resources/stdlib/jopenssl19/openssl/x509.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-warn 'deprecated openssl/x509 use: require "openssl" instead of "openssl/x509"'
-require 'openssl'
diff --git a/src/main/resources/stdlib/jopenssl21/openssl.rb b/src/main/resources/stdlib/jopenssl21/openssl.rb
deleted file mode 100644
index b1d7406..0000000
--- a/src/main/resources/stdlib/jopenssl21/openssl.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-=begin
-= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2002 Michal Rokos
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-require 'openssl/bn'
-require 'openssl/cipher'
-require 'openssl/config'
-require 'openssl/digest'
-require 'openssl/x509'
-require 'openssl/ssl'
diff --git a/src/main/resources/stdlib/jopenssl21/openssl/bn.rb b/src/main/resources/stdlib/jopenssl21/openssl/bn.rb
deleted file mode 100644
index 3933ee3..0000000
--- a/src/main/resources/stdlib/jopenssl21/openssl/bn.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-#--
-#
-# $RCSfile$
-#
-# = Ruby-space definitions that completes C-space funcs for BN
-#
-# = Info
-# 'OpenSSL for Ruby 2' project
-# Copyright (C) 2002 Michal Rokos
-# All rights reserved.
-#
-# = Licence
-# This program is licenced under the same licence as Ruby.
-# (See the file 'LICENCE'.)
-#
-# = Version
-# $Id$
-#
-#++
-
-##
-# Add double dispatch to Integer
-#
-class Integer
- def to_bn
- OpenSSL::BN::new(self)
- end
-end # Integer
-
diff --git a/src/main/resources/stdlib/jopenssl21/openssl/buffering.rb b/src/main/resources/stdlib/jopenssl21/openssl/buffering.rb
deleted file mode 100644
index e40dfee..0000000
--- a/src/main/resources/stdlib/jopenssl21/openssl/buffering.rb
+++ /dev/null
@@ -1,449 +0,0 @@
-=begin
-= $RCSfile$ -- Buffering mix-in module.
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2001 GOTOU YUUZOU
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-##
-# OpenSSL IO buffering mix-in module.
-#
-# This module allows an OpenSSL::SSL::SSLSocket to behave like an IO.
-
-module OpenSSL::Buffering
- include Enumerable
-
- ##
- # The "sync mode" of the SSLSocket.
- #
- # See IO#sync for full details.
-
- attr_accessor :sync
-
- ##
- # Default size to read from or write to the SSLSocket for buffer operations.
-
- BLOCK_SIZE = 1024*16
-
- def initialize(*args)
- @eof = false
- @rbuffer = ""
- @sync = @io.sync
- end
-
- #
- # for reading.
- #
- private
-
- ##
- # Fills the buffer from the underlying SSLSocket
-
- def fill_rbuff
- begin
- @rbuffer << self.sysread(BLOCK_SIZE)
- rescue Errno::EAGAIN
- retry
- rescue EOFError
- @eof = true
- end
- end
-
- ##
- # Consumes +size+ bytes from the buffer
-
- def consume_rbuff(size=nil)
- if @rbuffer.empty?
- nil
- else
- size = @rbuffer.size unless size
- ret = @rbuffer[0, size]
- @rbuffer[0, size] = ""
- ret
- end
- end
-
- public
-
- ##
- # Reads +size+ bytes from the stream. If +buf+ is provided it must
- # reference a string which will receive the data.
- #
- # See IO#read for full details.
-
- def read(size=nil, buf=nil)
- if size == 0
- if buf
- buf.clear
- return buf
- else
- return ""
- end
- end
- until @eof
- break if size && size <= @rbuffer.size
- fill_rbuff
- end
- ret = consume_rbuff(size) || ""
- if buf
- buf.replace(ret)
- ret = buf
- end
- (size && ret.empty?) ? nil : ret
- end
-
- ##
- # Reads at most +maxlen+ bytes from the stream. If +buf+ is provided it
- # must reference a string which will receive the data.
- #
- # See IO#readpartial for full details.
-
- def readpartial(maxlen, buf=nil)
- if maxlen == 0
- if buf
- buf.clear
- return buf
- else
- return ""
- end
- end
- if @rbuffer.empty?
- begin
- return sysread(maxlen, buf)
- rescue Errno::EAGAIN
- retry
- end
- end
- ret = consume_rbuff(maxlen)
- if buf
- buf.replace(ret)
- ret = buf
- end
- raise EOFError if ret.empty?
- ret
- end
-
- ##
- # Reads at most +maxlen+ bytes in the non-blocking manner.
- #
- # When no data can be read without blocking it raises
- # OpenSSL::SSL::SSLError extended by IO::WaitReadable or IO::WaitWritable.
- #
- # IO::WaitReadable means SSL needs to read internally so read_nonblock
- # should be called again when the underlying IO is readable.
- #
- # IO::WaitWritable means SSL needs to write internally so read_nonblock
- # should be called again after the underlying IO is writable.
- #
- # OpenSSL::Buffering#read_nonblock needs two rescue clause as follows:
- #
- # # emulates blocking read (readpartial).
- # begin
- # result = ssl.read_nonblock(maxlen)
- # rescue IO::WaitReadable
- # IO.select([io])
- # retry
- # rescue IO::WaitWritable
- # IO.select(nil, [io])
- # retry
- # end
- #
- # Note that one reason that read_nonblock writes to the underlying IO is
- # when the peer requests a new TLS/SSL handshake. See openssl the FAQ for
- # more details. http://www.openssl.org/support/faq.html
-
- def read_nonblock(maxlen, buf=nil, exception: true)
- if maxlen == 0
- if buf
- buf.clear
- return buf
- else
- return ""
- end
- end
- if @rbuffer.empty?
- return sysread_nonblock(maxlen, buf, exception: exception)
- end
- ret = consume_rbuff(maxlen)
- if buf
- buf.replace(ret)
- ret = buf
- end
- raise EOFError if ret.empty?
- ret
- end
-
- ##
- # Reads the next "line+ from the stream. Lines are separated by +eol+. If
- # +limit+ is provided the result will not be longer than the given number of
- # bytes.
- #
- # +eol+ may be a String or Regexp.
- #
- # Unlike IO#gets the line read will not be assigned to +$_+.
- #
- # Unlike IO#gets the separator must be provided if a limit is provided.
-
- def gets(eol=$/, limit=nil)
- idx = @rbuffer.index(eol)
- until @eof
- break if idx
- fill_rbuff
- idx = @rbuffer.index(eol)
- end
- if eol.is_a?(Regexp)
- size = idx ? idx+$&.size : nil
- else
- size = idx ? idx+eol.size : nil
- end
- if limit and limit >= 0
- size = [size, limit].min
- end
- consume_rbuff(size)
- end
-
- ##
- # Executes the block for every line in the stream where lines are separated
- # by +eol+.
- #
- # See also #gets
-
- def each(eol=$/)
- while line = self.gets(eol)
- yield line
- end
- end
- alias each_line each
-
- ##
- # Reads lines from the stream which are separated by +eol+.
- #
- # See also #gets
-
- def readlines(eol=$/)
- ary = []
- while line = self.gets(eol)
- ary << line
- end
- ary
- end
-
- ##
- # Reads a line from the stream which is separated by +eol+.
- #
- # Raises EOFError if at end of file.
-
- def readline(eol=$/)
- raise EOFError if eof?
- gets(eol)
- end
-
- ##
- # Reads one character from the stream. Returns nil if called at end of
- # file.
-
- def getc
- read(1)
- end
-
- ##
- # Calls the given block once for each byte in the stream.
-
- def each_byte # :yields: byte
- while c = getc
- yield(c.ord)
- end
- end
-
- ##
- # Reads a one-character string from the stream. Raises an EOFError at end
- # of file.
-
- def readchar
- raise EOFError if eof?
- getc
- end
-
- ##
- # Pushes character +c+ back onto the stream such that a subsequent buffered
- # character read will return it.
- #
- # Unlike IO#getc multiple bytes may be pushed back onto the stream.
- #
- # Has no effect on unbuffered reads (such as #sysread).
-
- def ungetc(c)
- @rbuffer[0,0] = c.chr
- end
-
- ##
- # Returns true if the stream is at file which means there is no more data to
- # be read.
-
- def eof?
- fill_rbuff if !@eof && @rbuffer.empty?
- @eof && @rbuffer.empty?
- end
- alias eof eof?
-
- #
- # for writing.
- #
- private
-
- ##
- # Writes +s+ to the buffer. When the buffer is full or #sync is true the
- # buffer is flushed to the underlying socket.
-
- def do_write(s)
- @wbuffer = "" unless defined? @wbuffer
- @wbuffer << s
- @wbuffer.force_encoding(Encoding::BINARY)
- @sync ||= false
- if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
- remain = idx ? idx + $/.size : @wbuffer.length
- nwritten = 0
- while remain > 0
- str = @wbuffer[nwritten,remain]
- begin
- nwrote = syswrite(str)
- rescue Errno::EAGAIN
- retry
- end
- remain -= nwrote
- nwritten += nwrote
- end
- @wbuffer[0,nwritten] = ""
- end
- end
-
- public
-
- ##
- # Writes +s+ to the stream. If the argument is not a string it will be
- # converted using String#to_s. Returns the number of bytes written.
-
- def write(s)
- do_write(s)
- s.bytesize
- end
-
- ##
- # Writes +str+ in the non-blocking manner.
- #
- # If there is buffered data, it is flushed first. This may block.
- #
- # write_nonblock returns number of bytes written to the SSL connection.
- #
- # When no data can be written without blocking it raises
- # OpenSSL::SSL::SSLError extended by IO::WaitReadable or IO::WaitWritable.
- #
- # IO::WaitReadable means SSL needs to read internally so write_nonblock
- # should be called again after the underlying IO is readable.
- #
- # IO::WaitWritable means SSL needs to write internally so write_nonblock
- # should be called again after underlying IO is writable.
- #
- # So OpenSSL::Buffering#write_nonblock needs two rescue clause as follows.
- #
- # # emulates blocking write.
- # begin
- # result = ssl.write_nonblock(str)
- # rescue IO::WaitReadable
- # IO.select([io])
- # retry
- # rescue IO::WaitWritable
- # IO.select(nil, [io])
- # retry
- # end
- #
- # Note that one reason that write_nonblock reads from the underlying IO
- # is when the peer requests a new TLS/SSL handshake. See the openssl FAQ
- # for more details. http://www.openssl.org/support/faq.html
-
- def write_nonblock(s, exception: true)
- flush
- syswrite_nonblock(s, exception: exception)
- end
-
- ##
- # Writes +s+ to the stream. +s+ will be converted to a String using
- # String#to_s.
-
- def << (s)
- do_write(s)
- self
- end
-
- ##
- # Writes +args+ to the stream along with a record separator.
- #
- # See IO#puts for full details.
-
- def puts(*args)
- s = ""
- if args.empty?
- s << "\n"
- end
- args.each{|arg|
- s << arg.to_s
- if $/ && /\n\z/ !~ s
- s << "\n"
- end
- }
- do_write(s)
- nil
- end
-
- ##
- # Writes +args+ to the stream.
- #
- # See IO#print for full details.
-
- def print(*args)
- s = ""
- args.each{ |arg| s << arg.to_s }
- do_write(s)
- nil
- end
-
- ##
- # Formats and writes to the stream converting parameters under control of
- # the format string.
- #
- # See Kernel#sprintf for format string details.
-
- def printf(s, *args)
- do_write(s % args)
- nil
- end
-
- ##
- # Flushes buffered data to the SSLSocket.
-
- def flush
- osync = @sync
- @sync = true
- do_write ""
- return self
- ensure
- @sync = osync
- end
-
- ##
- # Closes the SSLSocket and flushes any unwritten data.
-
- def close
- flush rescue nil
- sysclose
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl21/openssl/cipher.rb b/src/main/resources/stdlib/jopenssl21/openssl/cipher.rb
deleted file mode 100644
index b254a23..0000000
--- a/src/main/resources/stdlib/jopenssl21/openssl/cipher.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-#--
-#
-# $RCSfile$
-#
-# = Ruby-space predefined Cipher subclasses
-#
-# = Info
-# 'OpenSSL for Ruby 2' project
-# Copyright (C) 2002 Michal Rokos
-# All rights reserved.
-#
-# = Licence
-# This program is licenced under the same licence as Ruby.
-# (See the file 'LICENCE'.)
-#
-# = Version
-# $Id$
-#
-#++
-
-module OpenSSL
- class Cipher
- # This class is only provided for backwards compatibility. Use OpenSSL::Cipher in the future.
- class Cipher < Cipher
- # add warning
- end
- end # Cipher
-end # OpenSSL
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jopenssl21/openssl/config.rb b/src/main/resources/stdlib/jopenssl21/openssl/config.rb
deleted file mode 100644
index 24a54c9..0000000
--- a/src/main/resources/stdlib/jopenssl21/openssl/config.rb
+++ /dev/null
@@ -1,313 +0,0 @@
-=begin
-= Ruby-space definitions that completes C-space funcs for Config
-
-= Info
- Copyright (C) 2010 Hiroshi Nakamura
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-=end
-
-require 'stringio'
-
-module OpenSSL
- class Config
- include Enumerable
-
- class << self
- def parse(str)
- c = new()
- parse_config(StringIO.new(str)).each do |section, hash|
- c[section] = hash
- end
- c
- end
-
- alias load new
-
- def parse_config(io)
- begin
- parse_config_lines(io)
- rescue ConfigError => e
- e.message.replace("error in line #{io.lineno}: " + e.message)
- raise
- end
- end
-
- def get_key_string(data, section, key) # :nodoc:
- if v = data[section] && data[section][key]
- return v
- elsif section == 'ENV'
- if v = ENV[key]
- return v
- end
- end
- if v = data['default'] && data['default'][key]
- return v
- end
- end
-
- private
-
- def parse_config_lines(io)
- section = 'default'
- data = {section => {}}
- while definition = get_definition(io)
- definition = clear_comments(definition)
- next if definition.empty?
- if definition[0] == ?[
- if /\[([^\]]*)\]/ =~ definition
- section = $1.strip
- data[section] ||= {}
- else
- raise ConfigError, "missing close square bracket"
- end
- else
- if /\A([^:\s]*)(?:::([^:\s]*))?\s*=(.*)\z/ =~ definition
- if $2
- section = $1
- key = $2
- else
- key = $1
- end
- value = unescape_value(data, section, $3)
- (data[section] ||= {})[key] = value.strip
- else
- raise ConfigError, "missing equal sign"
- end
- end
- end
- data
- end
-
- # escape with backslash
- QUOTE_REGEXP_SQ = /\A([^'\\]*(?:\\.[^'\\]*)*)'/
- # escape with backslash and doubled dq
- QUOTE_REGEXP_DQ = /\A([^"\\]*(?:""[^"\\]*|\\.[^"\\]*)*)"/
- # escaped char map
- ESCAPE_MAP = {
- "r" => "\r",
- "n" => "\n",
- "b" => "\b",
- "t" => "\t",
- }
-
- def unescape_value(data, section, value)
- scanned = []
- while m = value.match(/['"\\$]/)
- scanned << m.pre_match
- c = m[0]
- value = m.post_match
- case c
- when "'"
- if m = value.match(QUOTE_REGEXP_SQ)
- scanned << m[1].gsub(/\\(.)/, '\\1')
- value = m.post_match
- else
- break
- end
- when '"'
- if m = value.match(QUOTE_REGEXP_DQ)
- scanned << m[1].gsub(/""/, '').gsub(/\\(.)/, '\\1')
- value = m.post_match
- else
- break
- end
- when "\\"
- c = value.slice!(0, 1)
- scanned << (ESCAPE_MAP[c] || c)
- when "$"
- ref, value = extract_reference(value)
- refsec = section
- if ref.index('::')
- refsec, ref = ref.split('::', 2)
- end
- if v = get_key_string(data, refsec, ref)
- scanned << v
- else
- raise ConfigError, "variable has no value"
- end
- else
- raise 'must not reaced'
- end
- end
- scanned << value
- scanned.join
- end
-
- def extract_reference(value)
- rest = ''
- if m = value.match(/\(([^)]*)\)|\{([^}]*)\}/)
- value = m[1] || m[2]
- rest = m.post_match
- elsif [?(, ?{].include?(value[0])
- raise ConfigError, "no close brace"
- end
- if m = value.match(/[a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]*)?/)
- return m[0], m.post_match + rest
- else
- raise
- end
- end
-
- def clear_comments(line)
- # FCOMMENT
- if m = line.match(/\A([\t\n\f ]*);.*\z/)
- return m[1]
- end
- # COMMENT
- scanned = []
- while m = line.match(/[#'"\\]/)
- scanned << m.pre_match
- c = m[0]
- line = m.post_match
- case c
- when '#'
- line = nil
- break
- when "'", '"'
- regexp = (c == "'") ? QUOTE_REGEXP_SQ : QUOTE_REGEXP_DQ
- scanned << c
- if m = line.match(regexp)
- scanned << m[0]
- line = m.post_match
- else
- scanned << line
- line = nil
- break
- end
- when "\\"
- scanned << c
- scanned << line.slice!(0, 1)
- else
- raise 'must not reaced'
- end
- end
- scanned << line
- scanned.join
- end
-
- def get_definition(io)
- if line = get_line(io)
- while /[^\\]\\\z/ =~ line
- if extra = get_line(io)
- line += extra
- else
- break
- end
- end
- return line.strip
- end
- end
-
- def get_line(io)
- if line = io.gets
- line.gsub(/[\r\n]*/, '')
- end
- end
- end
-
- def initialize(filename = nil)
- @data = {}
- if filename
- File.open(filename.to_s) do |file|
- Config.parse_config(file).each do |section, hash|
- self[section] = hash
- end
- end
- end
- end
-
- def get_value(section, key)
- if section.nil?
- raise TypeError.new('nil not allowed')
- end
- section = 'default' if section.empty?
- get_key_string(section, key)
- end
-
- def value(arg1, arg2 = nil)
- warn('Config#value is deprecated; use Config#get_value')
- if arg2.nil?
- section, key = 'default', arg1
- else
- section, key = arg1, arg2
- end
- section ||= 'default'
- section = 'default' if section.empty?
- get_key_string(section, key)
- end
-
- def add_value(section, key, value)
- check_modify
- (@data[section] ||= {})[key] = value
- end
-
- def [](section)
- @data[section] || {}
- end
-
- def section(name)
- warn('Config#section is deprecated; use Config#[]')
- @data[name] || {}
- end
-
- def []=(section, pairs)
- check_modify
- @data[section] ||= {}
- pairs.each do |key, value|
- self.add_value(section, key, value)
- end
- end
-
- def sections
- @data.keys
- end
-
- def to_s
- ary = []
- @data.keys.sort.each do |section|
- ary << "[ #{section} ]\n"
- @data[section].keys.each do |key|
- ary << "#{key}=#{@data[section][key]}\n"
- end
- ary << "\n"
- end
- ary.join
- end
-
- def each
- @data.each do |section, hash|
- hash.each do |key, value|
- yield [section, key, value]
- end
- end
- end
-
- def inspect
- "#<#{self.class.name} sections=#{sections.inspect}>"
- end
-
- protected
-
- def data
- @data
- end
-
- private
-
- def initialize_copy(other)
- @data = other.data.dup
- end
-
- def check_modify
- raise TypeError.new("Insecure: can't modify OpenSSL config") if frozen?
- end
-
- def get_key_string(section, key)
- Config.get_key_string(@data, section, key)
- end
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl21/openssl/digest.rb b/src/main/resources/stdlib/jopenssl21/openssl/digest.rb
deleted file mode 100644
index 615aa79..0000000
--- a/src/main/resources/stdlib/jopenssl21/openssl/digest.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-#--
-#
-# $RCSfile$
-#
-# = Ruby-space predefined Digest subclasses
-#
-# = Info
-# 'OpenSSL for Ruby 2' project
-# Copyright (C) 2002 Michal Rokos
-# All rights reserved.
-#
-# = Licence
-# This program is licenced under the same licence as Ruby.
-# (See the file 'LICENCE'.)
-#
-# = Version
-# $Id$
-#
-#++
-
-module OpenSSL
- class Digest
- # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
- class Digest < Digest
- def initialize(*args)
- # add warning
- super(*args)
- end
- end
- end # Digest
-
- # Returns a Digest subclass by +name+.
- #
- # require 'openssl'
- #
- # OpenSSL::Digest("MD5")
- # # => OpenSSL::Digest::MD5
- #
- # Digest("Foo")
- # # => NameError: wrong constant name Foo
-
- def Digest(name)
- OpenSSL::Digest.const_get(name)
- end
-
- module_function :Digest
-
-end # OpenSSL
-
diff --git a/src/main/resources/stdlib/jopenssl21/openssl/ssl.rb b/src/main/resources/stdlib/jopenssl21/openssl/ssl.rb
deleted file mode 100644
index 456f426..0000000
--- a/src/main/resources/stdlib/jopenssl21/openssl/ssl.rb
+++ /dev/null
@@ -1,205 +0,0 @@
-=begin
-= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2001 GOTOU YUUZOU
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Version
- $Id$
-=end
-
-require "openssl/buffering"
-require "fcntl"
-
-module OpenSSL
- module SSL
- module SocketForwarder
- def addr
- to_io.addr
- end
-
- def peeraddr
- to_io.peeraddr
- end
-
- def setsockopt(level, optname, optval)
- to_io.setsockopt(level, optname, optval)
- end
-
- def getsockopt(level, optname)
- to_io.getsockopt(level, optname)
- end
-
- def fcntl(*args)
- to_io.fcntl(*args)
- end
-
- def closed?
- to_io.closed?
- end
-
- def do_not_reverse_lookup=(flag)
- to_io.do_not_reverse_lookup = flag
- end
- end
-
- module Nonblock
- def initialize(*args)
- flag = File::NONBLOCK
- flag |= @io.fcntl(Fcntl::F_GETFL) if defined?(Fcntl::F_GETFL)
- @io.fcntl(Fcntl::F_SETFL, flag)
- super
- end
- end
-
- # FIXME: Using the old non-ASN1 logic here because our ASN1 appears to
- # return the wrong types for some decoded objects. See #1102
- def verify_certificate_identity(cert, hostname)
- should_verify_common_name = true
- cert.extensions.each{|ext|
- next if ext.oid != "subjectAltName"
- ext.value.split(/,\s+/).each{|general_name|
- if /\ADNS:(.*)/ =~ general_name
- should_verify_common_name = false
- reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- # NOTE: somehow we need the IP: canonical form
- # seems there were failures elsewhere when not
- # not sure how that's possible possible to-do!
- elsif /\AIP(?: Address)?:(.*)/ =~ general_name
- #elsif /\AIP Address:(.*)/ =~ general_name
- should_verify_common_name = false
- return true if $1 == hostname
- end
- }
- }
- if should_verify_common_name
- cert.subject.to_a.each{|oid, value|
- if oid == "CN"
- reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- end
- }
- end
- return false
- end
-=begin
- def verify_certificate_identity(cert, hostname)
- should_verify_common_name = true
- cert.extensions.each{|ext|
- next if ext.oid != "subjectAltName"
- ostr = OpenSSL::ASN1.decode(ext.to_der).value.last
- sequence = OpenSSL::ASN1.decode(ostr.value)
- sequence.value.each{|san|
- case san.tag
- when 2 # dNSName in GeneralName (RFC5280)
- should_verify_common_name = false
- reg = Regexp.escape(san.value).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- when 7 # iPAddress in GeneralName (RFC5280)
- should_verify_common_name = false
- # follows GENERAL_NAME_print() in x509v3/v3_alt.c
- if san.value.size == 4
- return true if san.value.unpack('C*').join('.') == hostname
- elsif san.value.size == 16
- return true if san.value.unpack('n*').map { |e| sprintf("%X", e) }.join(':') == hostname
- end
- end
- }
- }
- if should_verify_common_name
- cert.subject.to_a.each{|oid, value|
- if oid == "CN"
- reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
- return true if /\A#{reg}\z/i =~ hostname
- end
- }
- end
- return false
- end
-=end
- module_function :verify_certificate_identity
-
- class SSLSocket
- include Buffering
- include SocketForwarder
- include Nonblock
-
- def post_connection_check(hostname)
- unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname)
- raise SSLError, "hostname \"#{hostname}\" does not match the server certificate"
- end
- return true
- end
-
- def session
- SSL::Session.new(self)
- rescue SSL::Session::SessionError
- nil
- end
- end
-
- ##
- # SSLServer represents a TCP/IP server socket with Secure Sockets Layer.
- class SSLServer
- include SocketForwarder
- # When true then #accept works exactly the same as TCPServer#accept
- attr_accessor :start_immediately
-
- # Creates a new instance of SSLServer.
- # * +srv+ is an instance of TCPServer.
- # * +ctx+ is an instance of OpenSSL::SSL::SSLContext.
- def initialize(svr, ctx)
- @svr = svr
- @ctx = ctx
- unless ctx.session_id_context
- # see #6137 - session id may not exceed 32 bytes
- prng = ::Random.new($0.hash)
- session_id = prng.bytes(16).unpack('H*')[0]
- @ctx.session_id_context = session_id
- end
- @start_immediately = true
- end
-
- # Returns the TCPServer passed to the SSLServer when initialized.
- def to_io
- @svr
- end
-
- # See TCPServer#listen for details.
- def listen(backlog=5)
- @svr.listen(backlog)
- end
-
- # See BasicSocket#shutdown for details.
- def shutdown(how=Socket::SHUT_RDWR)
- @svr.shutdown(how)
- end
-
- # Works similar to TCPServer#accept.
- def accept
- sock = @svr.accept
- begin
- ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
- ssl.sync_close = true
- ssl.accept if @start_immediately
- ssl
- rescue SSLError => ex
- sock.close
- raise ex
- end
- end
-
- # See IO#close for details.
- def close
- @svr.close
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/jopenssl21/openssl/x509.rb b/src/main/resources/stdlib/jopenssl21/openssl/x509.rb
deleted file mode 100644
index eabd676..0000000
--- a/src/main/resources/stdlib/jopenssl21/openssl/x509.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-#--
-#
-# $RCSfile$
-#
-# = Ruby-space definitions that completes C-space funcs for X509 and subclasses
-#
-# = Info
-# 'OpenSSL for Ruby 2' project
-# Copyright (C) 2002 Michal Rokos
-# All rights reserved.
-#
-# = Licence
-# This program is licenced under the same licence as Ruby.
-# (See the file 'LICENCE'.)
-#
-# = Version
-# $Id$
-#
-#++
-
-module OpenSSL
- module X509
- class Name
- module RFC2253DN
- Special = ',=+<>#;'
- HexChar = /[0-9a-fA-F]/
- HexPair = /#{HexChar}#{HexChar}/
- HexString = /#{HexPair}+/
- Pair = /\\(?:[#{Special}]|\\|"|#{HexPair})/
- StringChar = /[^#{Special}\\"]/
- QuoteChar = /[^\\"]/
- AttributeType = /[a-zA-Z][0-9a-zA-Z]*|[0-9]+(?:\.[0-9]+)*/
- AttributeValue = /
- (?!["#])((?:#{StringChar}|#{Pair})*)|
- \#(#{HexString})|
- "((?:#{QuoteChar}|#{Pair})*)"
- /x
- TypeAndValue = /\A(#{AttributeType})=#{AttributeValue}/
-
- module_function
-
- def expand_pair(str)
- return nil unless str
- return str.gsub(Pair){
- pair = $&
- case pair.size
- when 2 then pair[1,1]
- when 3 then Integer("0x#{pair[1,2]}").chr
- else raise OpenSSL::X509::NameError, "invalid pair: #{str}"
- end
- }
- end
-
- def expand_hexstring(str)
- return nil unless str
- der = str.gsub(HexPair){$&.to_i(16).chr }
- a1 = OpenSSL::ASN1.decode(der)
- return a1.value, a1.tag
- end
-
- def expand_value(str1, str2, str3)
- value = expand_pair(str1)
- value, tag = expand_hexstring(str2) unless value
- value = expand_pair(str3) unless value
- return value, tag
- end
-
- def scan(dn)
- str = dn
- ary = []
- while true
- if md = TypeAndValue.match(str)
- remain = md.post_match
- type = md[1]
- value, tag = expand_value(md[2], md[3], md[4]) rescue nil
- if value
- type_and_value = [type, value]
- type_and_value.push(tag) if tag
- ary.unshift(type_and_value)
- if remain.length > 2 && remain[0] == ?,
- str = remain[1..-1]
- next
- elsif remain.length > 2 && remain[0] == ?+
- raise OpenSSL::X509::NameError,
- "multi-valued RDN is not supported: #{dn}"
- elsif remain.empty?
- break
- end
- end
- end
- msg_dn = dn[0, dn.length - str.length] + " =>" + str
- raise OpenSSL::X509::NameError, "malformed RDN: #{msg_dn}"
- end
- return ary
- end
- end
-
- class << self
- def parse_rfc2253(str, template=OBJECT_TYPE_TEMPLATE)
- ary = OpenSSL::X509::Name::RFC2253DN.scan(str)
- self.new(ary, template)
- end
-
- def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
- ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) }
- self.new(ary, template)
- end
-
- alias parse parse_openssl
- end
- end
-
- class StoreContext
- def cleanup
- warn "(#{caller.first}) OpenSSL::X509::StoreContext#cleanup is deprecated with no replacement" if $VERBOSE
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/jruby/compiler.rb b/src/main/resources/stdlib/jruby/compiler.rb
deleted file mode 100644
index 0c8d243..0000000
--- a/src/main/resources/stdlib/jruby/compiler.rb
+++ /dev/null
@@ -1,305 +0,0 @@
-require 'optparse'
-require 'fileutils'
-require 'digest/sha1'
-require 'jruby'
-require 'jruby/compiler/java_class'
-
-module JRuby::Compiler
- BAIS = java.io.ByteArrayInputStream
- Mangler = org.jruby.util.JavaNameMangler
- Opcodes = org.objectweb.asm.Opcodes rescue org.jruby.org.objectweb.asm.Opcodes
- ClassWriter = org.objectweb.asm.ClassWriter rescue org.jruby.org.objectweb.asm.ClassWriter
- SkinnyMethodAdapter = org.jruby.compiler.impl.SkinnyMethodAdapter
- ByteArrayOutputStream = java.io.ByteArrayOutputStream
- IRWriterStream = org.jruby.ir.persistence.IRWriterStream
- IRWriter = org.jruby.ir.persistence.IRWriter
- JavaFile = java.io.File
- MethodSignatureNode = org.jruby.ast.java_signature.MethodSignatureNode
- DEFAULT_PREFIX = ""
-
- def default_options
- {
- :basedir => Dir.pwd,
- :prefix => DEFAULT_PREFIX,
- :target => Dir.pwd,
- :java => false,
- :javac => false,
- :classpath => [],
- :javac_options => [],
- :sha1 => false,
- :handles => false,
- :verbose => false
- }
- end
- module_function :default_options
-
- def compile_argv(argv)
- options = default_options
-
- OptionParser.new("", 24, ' ') do |opts|
- opts.banner = "jrubyc [options] (FILE|DIRECTORY)"
- opts.separator ""
-
- opts.on("-d", "--dir DIR", "Use DIR as the base path") do |dir|
- options[:basedir] = dir
- end
-
- opts.on("-p", "--prefix PREFIX", "Prepend PREFIX to the file path and package. Default is no prefix.") do |pre|
- options[:prefix] = pre
- end
-
- opts.on("-t", "--target TARGET", "Output files to TARGET directory") do |tgt|
- options[:target] = tgt
- end
-
- opts.on("-J OPTION", "Pass OPTION to javac for javac compiles") do |tgt|
- options[:javac_options] << tgt
- end
-
- opts.on("-5"," --jdk5", "Generate JDK 5 classes (version 49)") do |x|
- options[:jdk5] = true
- end
-
- opts.on("--java", "Generate .java classes to accompany the script") do
- options[:java] = true
- end
-
- opts.on("--javac", "Generate and compile .java classes to accompany the script") do
- options[:javac] = true
- end
-
- opts.on("-c", "--classpath CLASSPATH", "Add a jar to the classpath for building") do |cp|
- options[:classpath].concat cp.split(':')
- end
-
- opts.on("--sha1", "Compile to a class named using the SHA1 hash of the source file") do
- options[:sha1] = true
- end
-
- opts.on("--handles", "Also generate all direct handle classes for the source file") do
- options[:handles] = true
- end
-
- opts.on("--verbose", "Log verbose output while compile") do
- options[:verbose] = true
- end
-
- opts.parse!(argv)
- end
-
- if (argv.length == 0)
- raise "No files or directories specified"
- end
-
- compile_files_with_options(argv, options)
- end
- module_function :compile_argv
-
- # deprecated, but retained for backward compatibility
- def compile_files(filenames, basedir = Dir.pwd, prefix = DEFAULT_PREFIX, target = Dir.pwd, java = false, javac = false, javac_options = [], classpath = [])
- compile_files_with_options(
- filenames,
- :basedir => basedir,
- :prefix => prefix,
- :target => target,
- :java => java,
- :javac => javac,
- :javac_options => javac_options,
- :classpath => classpath,
- :sha1 => false,
- :handles => false,
- :verbose => false
- )
- end
- module_function :compile_files
-
- def compile_files_with_options(filenames, options = default_options)
- runtime = JRuby.runtime
-
- unless File.exist? options[:target]
- raise "Target dir not found: #{options[:target]}"
- end
-
- files = []
-
- # The compilation code
- compile_proc = proc do |filename|
- begin
- file = File.open(filename)
-
- if options[:sha1]
- pathname = "ruby.jit.FILE_" + Digest::SHA1.hexdigest(File.read(filename)).upcase
- else
- pathname = Mangler.mangle_filename_for_classpath(filename, options[:basedir], options[:prefix], true, false)
- end
-
- source = file.read
-
- if options[:java] || options[:javac]
- node = runtime.parse_file(BAIS.new(source.to_java_bytes), filename, nil)
-
- ruby_script = JavaGenerator.generate_java(node, filename)
- ruby_script.classes.each do |cls|
- java_dir = File.join(options[:target], cls.package.gsub('.', '/'))
-
- FileUtils.mkdir_p java_dir
-
- java_src = File.join(java_dir, cls.name + ".java")
- puts "Generating Java class #{cls.name} to #{java_src}" if options[:verbose]
-
- files << java_src
-
- File.open(java_src, 'w') do |f|
- f.write(cls.to_s)
- end
- end
- else
- puts "Compiling #{filename}" if options[:verbose]
-
- scope = JRuby.compile_ir(source, filename)
- bytes = ByteArrayOutputStream.new
- stream = IRWriterStream.new(bytes)
- IRWriter.persist(stream, scope)
- string = String.from_java_bytes(bytes.to_byte_array, 'BINARY')
-
- # bust it up into 32k-1 chunks
- pieces = string.scan(/.{1,32767}/m)
-
- cls = ClassWriter.new(ClassWriter::COMPUTE_MAXS | ClassWriter::COMPUTE_FRAMES)
- cls.visit(
- Opcodes::V1_7,
- Opcodes::ACC_PUBLIC,
- pathname.gsub(".", "/"),
- nil,
- "java/lang/Object",
- nil
- )
- cls.visit_source filename, nil
-
- cls.visit_field(
- Opcodes::ACC_PRIVATE | Opcodes::ACC_STATIC | Opcodes::ACC_FINAL,
- "script_ir",
- "Ljava/lang/String;",
- nil,
- nil
- )
-
- static = SkinnyMethodAdapter.new(
- cls,
- Opcodes::ACC_PUBLIC | Opcodes::ACC_STATIC,
- "",
- "()V",
- nil,
- nil)
- static.start
-
- # put String back together
- static.newobj("java/lang/StringBuilder")
- static.dup
- static.invokespecial("java/lang/StringBuilder", "", "()V")
- pieces.each do |piece|
- static.ldc(piece)
- static.invokevirtual("java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;")
- end
- static.invokevirtual("java/lang/Object", "toString", "()Ljava/lang/String;")
- static.putstatic(pathname, "script_ir", "Ljava/lang/String;")
- static.voidreturn
- static.end
-
- main = SkinnyMethodAdapter.new(
- cls,
- Opcodes::ACC_PUBLIC | Opcodes::ACC_STATIC,
- "main",
- "([Ljava/lang/String;)V",
- nil,
- nil)
- main.start
- main.invokestatic("org/jruby/Ruby", "newInstance", "()Lorg/jruby/Ruby;")
- main.astore(1)
- main.aload(1)
- main.aload(1)
-
- main.getstatic(pathname, "script_ir", "Ljava/lang/String;")
-
- main.ldc("ISO-8859-1")
- main.invokevirtual("java/lang/String", "getBytes", "(Ljava/lang/String;)[B")
- main.ldc(filename) # TODO: can we determine actual path to this class?
- main.invokestatic("org/jruby/ir/runtime/IRRuntimeHelpers", "decodeScopeFromBytes", "(Lorg/jruby/Ruby;[BLjava/lang/String;)Lorg/jruby/ir/IRScope;")
- main.invokevirtual("org/jruby/Ruby", "runInterpreter", "(Lorg/jruby/ParseResult;)Lorg/jruby/runtime/builtin/IRubyObject;")
- main.voidreturn
- main.end
-
- loadIR = SkinnyMethodAdapter.new(
- cls,
- Opcodes::ACC_PUBLIC | Opcodes::ACC_STATIC,
- "loadIR",
- "(Lorg/jruby/Ruby;Ljava/lang/String;)Lorg/jruby/ir/IRScope;",
- nil,
- nil)
- loadIR.start
- loadIR.aload(0)
-
- loadIR.getstatic(pathname, "script_ir", "Ljava/lang/String;")
-
- loadIR.ldc("ISO-8859-1")
- loadIR.invokevirtual("java/lang/String", "getBytes", "(Ljava/lang/String;)[B")
- loadIR.aload(1)
- loadIR.invokestatic("org/jruby/ir/runtime/IRRuntimeHelpers", "decodeScopeFromBytes", "(Lorg/jruby/Ruby;[BLjava/lang/String;)Lorg/jruby/ir/IRScope;")
- loadIR.areturn
- loadIR.end
-
- # prepare target
- class_filename = filename.sub(/(\.rb)?$/, '.class')
- target_file = File.join(options[:target], class_filename)
- target_dir = File.dirname(target_file)
- FileUtils.mkdir_p(target_dir)
-
- # write class
- File.open(target_file, 'wb') do |f|
- f.write(cls.to_byte_array)
- end
- end
-
- 0
- # rescue Exception
- # puts "Failure during compilation of file #{filename}:\n#{$!}"
- # puts $!.backtrace
- # 1
- ensure
- file.close unless file.nil?
- end
- end
-
- errors = 0
- # Process all the file arguments
- Dir[*filenames].each do |filename|
- unless File.exists? filename
- puts "Error -- file not found: #{filename}"
- errors += 1
- next
- end
-
- if (File.directory?(filename))
- puts "Compiling all in '#{File.expand_path(filename)}'..." if options[:verbose]
- Dir.glob(filename + "/**/*.rb").each { |filename|
- errors += compile_proc[filename]
- }
- else
- if filename =~ /\.java$/
- files << filename
- else
- errors += compile_proc[filename]
- end
- end
- end
-
- if options[:javac]
- javac_string = JavaGenerator.generate_javac(files, options)
- puts javac_string if options[:verbose]
- system javac_string
- end
-
- errors
- end
- module_function :compile_files_with_options
-end
diff --git a/src/main/resources/stdlib/jruby/compiler/extending.rb b/src/main/resources/stdlib/jruby/compiler/extending.rb
deleted file mode 100644
index 8e02a77..0000000
--- a/src/main/resources/stdlib/jruby/compiler/extending.rb
+++ /dev/null
@@ -1,243 +0,0 @@
-module JRuby::Compiler
- EXTENSION_STRING = <> variables) {
- return org.jruby.BasicObjectStub.syncVariables(this, variables);
- }
-
- public List> getVariableList() {
- return org.jruby.BasicObjectStub.getVariableList(this);
- }
-
- public InstanceVariables getInstanceVariables() {
- return org.jruby.BasicObjectStub.getInstanceVariables(this);
- }
-
- public InternalVariables getInternalVariables() {
- return org.jruby.BasicObjectStub.getInternalVariables(this);
- }
-
- public List getVariableNameList() {
- return org.jruby.BasicObjectStub.getVariableNameList(this);
- }
-
- public void copySpecialInstanceVariables(IRubyObject clone) {
- return org.jruby.BasicObjectStub.copySpecialInstanceVariables(this);
- }
-
- public Object getVariable(int index) {
- return org.jruby.BasicObjectStub.getVariable(this, index);
- }
-
- public void setVariable(int index, Object value) {
- return org.jruby.BasicObjectStub.setVariable(this, index, value);
- }
-JAVA
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jruby/compiler/java_class.rb b/src/main/resources/stdlib/jruby/compiler/java_class.rb
deleted file mode 100644
index ee0d1b8..0000000
--- a/src/main/resources/stdlib/jruby/compiler/java_class.rb
+++ /dev/null
@@ -1,697 +0,0 @@
-module JRuby::Compiler
- module JavaGenerator
- module_function
-
- def generate_java(node, script_name = nil)
- walker = ClassNodeWalker.new(script_name)
-
- node.accept(walker)
-
- walker.script
- end
-
- def generate_javac(files, options)
- files_string = files.join(' ')
- jruby_jar, = ['jruby.jar', 'jruby-complete.jar'].select do |jar|
- File.exist? "#{ENV_JAVA['jruby.home']}/lib/#{jar}"
- end
- separator = File::PATH_SEPARATOR
- classpath_string = options[:classpath].size > 0 ? options[:classpath].join(separator) : "."
- javac_opts = options[:javac_options].join(' ')
- target = options[:target]
- java_home = ENV_JAVA['jruby.home']
-
- compile_string = "javac #{javac_opts} -d #{target} -cp #{java_home}/lib/#{jruby_jar}#{separator}#{classpath_string} #{files_string}"
-
- compile_string
- end
- end
-
- module VisitorBuilder
- def visit(name, &block)
- define_method :"visit_#{name}_node" do |node|
- log "entering: #{node.node_type}"
- with_node(node) do
- instance_eval(&block)
- end
- end
- end
-
- def visit_default(&block)
- define_method :method_missing do |name, node|
- super unless name.to_s =~ /^visit/
-
- with_node(node) do
- block.call
- end
- end
- end
- end
-
- class ClassNodeWalker
- AST = org.jruby.ast
-
- include AST::visitor::NodeVisitor
-
- java_import AST::NodeType
- java_import org.jruby.parser.JavaSignatureParser
- java_import java.io.ByteArrayInputStream
-
- extend VisitorBuilder
-
- attr_accessor :class_stack, :method_stack, :signature, :script, :annotations, :node
-
- def initialize(script_name = nil)
- @script = RubyScript.new(script_name)
- @class_stack = []
- @method_stack = []
- @signature = nil
- @annotations = []
- @name = nil
- @node = nil
- end
-
- def add_imports(nodes)
- nodes.each do |n|
- @script.add_import(name_or_value(n))
- end
- end
-
- def set_signature(name)
- @signature = name
- end
-
- def add_annotation(nodes)
- nodes.each do
- name = name_or_value(nodes[0])
- @annotations << name
- end
- end
-
- def add_interface(*ifc_nodes)
- ifc_nodes.
- map {|ifc| defined?(ifc.name) ? ifc.name : ifc.value}.
- each {|ifc| current_class.add_interface(ifc)}
- end
-
- def new_class(name)
- cls = @script.new_class(name, @annotations)
- @annotations = []
-
- class_stack.push(cls)
- end
-
- def current_class
- class_stack[0]
- end
-
- def pop_class
- class_stack.pop
- @signature = nil
- @annotations = []
- end
-
- def new_method(name)
- method = current_class.new_method(name, @signature, @annotations)
- @signature = nil
- @annotations = []
-
- method_stack.push(method)
- end
-
- def new_static_method(name)
- method = current_class.new_method(name, @signature, @annotations)
- method.static = true
- @signature = nil
- @annotations = []
-
- method_stack.push(method)
- end
-
- def current_method
- method_stack[0]
- end
-
- def pop_method
- method_stack.pop
- end
-
- def build_signature(signature)
- if signature.kind_of? String
- bytes = signature.to_java_bytes
- return JavaSignatureParser.parse(ByteArrayInputStream.new(bytes))
- else
- raise "java_signature must take a literal string"
- end
- end
-
- def add_field(signature)
- if signature.kind_of? String
- current_class.new_field(signature, @annotations)
- @annotations = []
- else
- raise "java_field must take a literal string"
- end
- end
-
- def build_args_signature(params)
- sig = ["Object"]
- param_strings = params.child_nodes.map do |param|
- if param.respond_to? :type_node
- type_node = param.type_node
- next name_or_value(type_node)
- end
- raise 'unknown signature element: ' + param.to_s
- end
- sig.concat(param_strings)
-
- sig
- end
-
- def add_requires(*requires)
- requires.each {|r| @script.add_require(name_or_value(r))}
- end
-
- def set_package(package)
- @script.package = name_or_value(package)
- end
-
- def name_or_value(node)
- return node.name if defined? node.name
- return node.value if defined? node.value
- raise "unknown node :" + node.to_s
- end
-
- def with_node(node)
- begin
- old, @node = @node, node
- yield
- ensure
- @node = old
- end
- end
-
- def error(message)
- long_message = "#{node.position}: #{message}"
- raise long_message
- end
-
- def log(str)
- puts "[jrubyc] #{str}" if $VERBOSE
- end
-
- visit :args do
- # Duby-style arg specification, only pre supported for now
- if node.pre && node.pre.child_nodes.find {|pre_arg| pre_arg.respond_to? :type_node}
- current_method.java_signature = build_args_signature(node.pre)
- end
- node.pre && node.pre.child_nodes.each do |pre_arg|
- current_method.args << pre_arg.name
- end
- node.opt_args && node.opt_args.child_nodes.each do |pre_arg|
- current_method.args << pre_arg.name
- end
- node.post && node.post.child_nodes.each do |post_arg|
- current_method.args << post_arg.name
- end
- if node.has_rest_arg
- current_method.args << node.rest_arg_node.name
- end
- if node.block
- current_method.args << node.block.name
- end
-
- # if method still has no signature, generate one
- unless current_method.java_signature
- args_string = current_method.args.map{|a| "Object #{a}"}.join(",")
- sig_string = "Object #{current_method.name}(#{args_string})"
- current_method.java_signature = build_signature(sig_string)
- end
- end
-
- visit :class do
- new_class(node.cpath.name)
- node.body_node.accept(self)
- pop_class
- end
-
- visit :defn do
- new_method(node.name)
- node.args_node.accept(self)
- pop_method
- end
-
- visit :defs do
- new_static_method(node.name)
- node.args_node.accept(self)
- pop_method
- end
-
- visit :fcall do
- case node.name
- when 'java_import'
- add_imports node.args_node.child_nodes
- when 'java_signature'
- set_signature build_signature(node.args_node.child_nodes[0].value)
- when 'java_annotation'
- add_annotation(node.args_node.child_nodes)
- when 'java_implements'
- add_interface(*node.args_node.child_nodes)
- when "java_require"
- add_requires(*node.args_node.child_nodes)
- when "java_package"
- set_package(*node.args_node.child_nodes)
- when "java_field"
- add_field(node.args_node.child_nodes[0].value)
- end
- end
-
- visit :block do
- node.child_nodes.each {|n| n.accept self}
- end
-
- visit :newline do
- node.next_node.accept(self)
- end
-
- visit :nil do
- end
-
- visit :root do
- node.body_node.accept(self)
- end
-
- visit_default do |node|
- # ignore other nodes
- end
- end
-
- class RubyScript
- BASE_IMPORTS = [
- "org.jruby.Ruby",
- "org.jruby.RubyObject",
- "org.jruby.runtime.Helpers",
- "org.jruby.runtime.builtin.IRubyObject",
- "org.jruby.javasupport.JavaUtil",
- "org.jruby.RubyClass"
- ]
-
- def initialize(script_name, imports = BASE_IMPORTS)
- @classes = []
- @script_name = script_name
- @imports = imports.dup
- @requires = []
- @package = ""
- end
-
- attr_accessor :classes, :imports, :script_name, :requires, :package
-
- def add_import(name)
- @imports << name
- end
-
- def add_require(require)
- @requires << require
- end
-
- def new_class(name, annotations = [])
- cls = RubyClass.new(name, imports, script_name, annotations, requires, package)
- @classes << cls
- cls
- end
-
- def to_s
- str = ""
- @classes.each do |cls|
- str << cls.to_s
- end
- str
- end
- end
-
- class RubyClass
- def initialize(name, imports = [], script_name = nil, annotations = [], requires = [], package = "")
- @name = name
- @imports = imports
- @script_name = script_name
- @fields = []
- @methods = []
- @annotations = annotations
- @interfaces = []
- @requires = requires
- @package = package
- @has_constructor = false;
- end
-
- attr_accessor :methods, :name, :script_name, :fields, :annotations, :interfaces, :requires, :package, :sourcefile
-
- def constructor?
- @has_constructor
- end
-
- def new_field(java_signature, annotations = [])
- fields << [java_signature, annotations]
- end
-
- def new_method(name, java_signature = nil, annotations = [])
- is_constructor = name == "initialize" ||
- java_signature.is_a?(Java::OrgJrubyAstJava_signature::ConstructorSignatureNode)
- @has_constructor ||= is_constructor
-
- if is_constructor
- method = RubyConstructor.new(self, java_signature, annotations)
- else
- method = RubyMethod.new(self, name, java_signature, annotations)
- end
-
- methods << method
- method
- end
-
- def add_interface(ifc)
- @interfaces << ifc
- end
-
- def interface_string
- if @interfaces.size > 0
- "implements " + @interfaces.join('.')
- else
- ""
- end
- end
-
- def static_init
- return < 0
- visibility_str = "#{visibilities[0]}"
- else
- visibility_str = 'public'
- end
-
- annotations = java_signature.modifiers.select(&:annotation?).map(&:to_s).join(" ")
-
- "#{annotations}#{visibility_str}#{static_str}#{final_str}#{abstract_str}#{strictfp_str}#{native_str}#{synchronized_str}"
- end
-
- def typed_args
- return @typed_args if @typed_args
-
- i = 0;
- @typed_args = java_signature.parameters.map do |a|
- type = a.type.name
- if a.variable_name
- var_name = a.variable_name
- else
- var_name = args[i]
- i+=1
- end
-
- {:name => var_name, :type => type}
- end
- end
-
- def throws_exceptions
- if java_signature.throws && !java_signature.throws.empty?
- 'throws ' + java_signature.throws.join(', ') + ' '
- else
- ''
- end
- end
-
- def declared_args
- @declared_args ||= typed_args.map { |a| "#{a[:type]} #{a[:name]}" }.join(', ')
- end
-
- def var_names
- @var_names ||= typed_args.map {|a| a[:name]}
- end
-
- def passed_args
- return @passed_args if @passed_args
-
- if arity <= MAX_UNBOXED_ARITY_LENGTH
- @passed_args = var_names.map {|a| "ruby_arg_#{a}"}.join(', ')
- @passed_args = ', ' + @passed_args if args.size > 0
- else
- @passed_args = ", ruby_args";
- end
- end
-
- def return_type
- if java_signature
- java_signature.return_type
- else
- raise "no java_signature has been set for method #{name}"
- end
- end
-
- def return_string
- if java_signature
- if return_type.void?
- "return;"
- else
- # Can't return wrapped array as primitive array
- cast_to = return_type.is_array ? return_type.fully_typed_name : return_type.wrapper_name
- "return (#{cast_to})ruby_result.toJava(#{return_type.name}.class);"
- end
- else
- raise "no java_signature has been set for method #{name}"
- end
- end
-
- def java_name
- if java_signature
- java_signature.name
- else
- raise "no java_signature has been set for method #{name}"
- end
- end
- end
-
- class RubyConstructor < RubyMethod
- def initialize(ruby_class, java_signature = nil, annotations = [])
- super(ruby_class, 'initialize', java_signature, annotations)
- end
-
- def constructor?
- true
- end
-
- def java_name
- @ruby_class.name
- end
-
- def return_type
- ''
- end
-
- def to_s
- declarator_string do
- <<-JAVA
- this(__ruby__, __metaclass__);
-#{conversion_string(var_names)}
- Helpers.invoke(__ruby__.getCurrentContext(), this, \"initialize\"#{passed_args});
- JAVA
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/jruby/compiler/java_signature.rb b/src/main/resources/stdlib/jruby/compiler/java_signature.rb
deleted file mode 100644
index 42b0cf9..0000000
--- a/src/main/resources/stdlib/jruby/compiler/java_signature.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-require 'java'
-
-module JRuby
- class JavaSignature
- def initialize(string, ast)
- @string, @ast = string, ast
- end
-
- def name
- @ast.name
- end
-
- # FIXME: Can make this accept whole list too if that is actual contract
- # FIXME: Can be literals too
- def as_java_type(string)
- type = primitive? string
- return type if type
-
- if string.is_a?(Java::OrgJrubyAstJava_signature::ReferenceTypeNode)
- return eval make_class_jiable(string.getFullyTypedName())
- end
-
- # If annotation makes it in strip @ before we try and match it.
- string = string[1..-1] if string.start_with? '@'
-
- eval make_class_jiable(string)
- end
-
-
- ##
- # return live JI proxy for return type
- def return_type
- as_java_type(@ast.return_type)
- end
-
- ##
- # {org.bukkit.event.EventHandler => {}, }
- def annotations
- annotations = @ast.modifiers.select(&:is_annotation?)
- annotations.inject({}) do |hash, anno_node|
- hash[as_java_type(anno_node.name)] = process_annotation_params(anno_node)
- hash
- end
- end
-
- def modifiers
- @ast.modifiers.reject(&:is_annotation?)
- end
-
- ##
- # return JI proxies for all parameters (excluding return_type)
- def parameters
- @ast.parameters.map { |p| as_java_type(p.type) }
- end
-
- ##
- # {return_type, *parameters} tuple (JI proxies)
- def types
- [return_type, *parameters]
- end
-
- def to_s
- @string
- end
-
- def to_s_ast
- @ast
- end
-
- def inspect
- <<-EOS
-name : #{name}
-modifiers : #{modifiers.join(', ')}
-annotations: #{annotations.join(', ')}
-parameters : #{parameters.join(', ')}
-return_type: #{return_type}
- EOS
- end
-
- def self.parse(signature)
- stream = java.io.ByteArrayInputStream.new(signature.to_s.to_java_bytes)
- ast = org.jruby.parser.JavaSignatureParser.parse(stream)
- new signature, ast
- end
-
- def process_annotation_params(anno_node)
- anno_node.parameters.inject({}) do |hash, param|
- # ??? default will be nil/null name here.
- hash[param.name] = as_java_type(expr)
- hash
- end
- end
- private :process_annotation_params
-
- # FIXME: Somewhere must have this already?
- PRIMITIVES = {
- "void" => Java::java.lang.Void::TYPE,
- "int" => Java::java.lang.Integer::TYPE,
- "long" => Java::java.lang.Long::TYPE,
- "double" => Java::java.lang.Double::TYPE,
- "float" => Java::java.lang.Float::TYPE,
- "boolean" => Java::java.lang.Boolean::TYPE
- }
-
- def primitive?(string)
- PRIMITIVES[string.to_s]
- end
-
- def make_class_jiable(string)
- new_list = []
- string.split(/\./).inject(false) do |last_cap, segment|
- if segment =~ /[A-Z]/
- if last_cap
- new_list << "::" + segment
- else
- new_list << "." + segment
- end
- last_cap = true
- else
- new_list << "." + segment
- last_cap = false
- end
- end
- "Java::#{new_list.join("")[1..-1]}"
- end
- end
-end
diff --git a/src/main/resources/stdlib/jruby/core_ext.rb b/src/main/resources/stdlib/jruby/core_ext.rb
deleted file mode 100644
index 2121c5c..0000000
--- a/src/main/resources/stdlib/jruby/core_ext.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-require 'jruby/core_ext/class'
-require 'jruby/core_ext/string'
-require 'jruby/core_ext/thread'
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jruby/core_ext/class.rb b/src/main/resources/stdlib/jruby/core_ext/class.rb
deleted file mode 100644
index 76cfe58..0000000
--- a/src/main/resources/stdlib/jruby/core_ext/class.rb
+++ /dev/null
@@ -1,233 +0,0 @@
-require 'java'
-require 'jruby'
-require 'jruby/compiler/java_signature'
-
-##
-# Convenience methods added to class when you want to be able to
-# reify a Ruby class into a honest to goodness type. Typically, it would look
-# like:
-# :call-seq:
-#
-# class Foo
-# java_signature '@org.foo.EventHandler(@org.foo.Priority.High) void foo(int)'
-# def foo(number)
-# end
-# become_java!
-# end
-#
-# Although this will still just be an instance of a IRubyObject versus a
-# specific type, you can still use this facility for:
-# 1. Adding runtime annotations to methods
-# 2. Making a class still reflectable from Java reflection APIs.
-#
-# Case #1 above is also a useful combination with implementing Java interfaces.
-#
-class Class
- JClass = java.lang.Class
-
- ##
- # Get an array of all known subclasses of this class. If recursive == true,
- # include all descendants.
- def subclasses(recursive = false)
- JRuby.reference0(self).subclasses(recursive).to_a.freeze
- end
-
- ##
- # java_signature will take the argument and annotate the method of the
- # same name with the Java type and annotation signatures.
- #
- # :call-seq:
- # java_signature '@Override void foo(int)'
- # java_signature '@Override void foo(int foo, org.foo.Bar bar)'
- def java_signature(signature_source)
- signature = JRuby::JavaSignature.parse signature_source.to_s
- add_method_signature signature.name, signature.types
-
- annotations = signature.annotations
- add_method_annotation signature.name, annotations if annotations
- end
-
- ##
- # Generate a native Java class for this Ruby class. If dump_dir is specified,
- # dump the JVM bytecode there for inspection. If child_loader is false, do not
- # generate the class into its own classloader (use the parent's loader).
- #
- # :call-seq:
- # become_java!
- # become_java!(dump_dir)
- # become_java!(dump_dir, child_loader)
- # become_java!(child_loader)
- # become_java!(child_loader, dump_dir)
- def become_java!(*args)
- self_r = JRuby.reference0(self)
-
- if args.size > 0
- dump_dir = nil
- child_loader = true
- if args[0].kind_of? String
- dump_dir = args[0].to_s
- if args.size > 1
- child_loader = args[1]
- end
- else
- child_loader = args[0]
- if args.size > 1
- dump_dir = args[1].to_s
- end
- end
-
- self_r.reify_with_ancestors(dump_dir, child_loader)
- else
- self_r.reify_with_ancestors
- end
-
- generate_java_fields
-
- self_r.reified_class
- end
-
- ##
- # Get the native or reified (a la become_java!) class for this Ruby class.
- def java_class
- self_r = JRuby.reference0(self)
- current = self_r
- while current
- reified = current.reified_class
- return reified if reified
- current = JRuby.reference0(current.super_class)
- end
-
- nil
- end
-
- def _anno_class(cls)
- if cls.kind_of? JClass
- cls
- elsif cls.respond_to? :java_class
- cls.java_class.to_java :object
- else
- raise TypeError, "expected a Java class, got #{cls}"
- end
- end
- private :_anno_class
-
- ##
- # Add annotations to the named method. Annotations are specified as a Hash
- # from the annotation classes to Hashes of name/value pairs for their
- # parameters. Please refrain from using this in favor of java_signature.
- # :call-seq:
- #
- # add_method_annotation :foo, {java.lang.Override => {}}
- #
- def add_method_annotation(name, annotations = {})
- name = name.to_s
- self_r = JRuby.reference0(self)
-
- for cls, params in annotations
- params ||= {}
- self_r.add_method_annotation(name, _anno_class(cls), params)
- end
-
- nil
- end
-
- ##
- # Add annotations to the parameters of the named method. Annotations are
- # specified as a parameter-list-length Array of Hashes from annotation classes
- # to Hashes of name/value pairs for their parameters.
- def add_parameter_annotation(name, annotations = [])
- name = name.to_s
- self_r = JRuby.reference0(self)
-
- annotations.each_with_index do |param_annos, i|
- for cls, params in param_annos
- params ||= {}
- self_r.add_parameter_annotation(name, i, _anno_class(cls), params)
- end
- end
-
- nil
- end
-
- ##
- # Add annotations to this class. Annotations are specified as a Hash of
- # annotation classes to Hashes of name/value pairs for their parameters.
- # :call-seq:
- #
- # add_class_annotation java.lang.TypeAnno => {"type" => @com.foo.GoodOne}
- #
- def add_class_annotations(annotations = {})
- self_r = JRuby.reference0(self)
-
- for cls, params in annotations
- params ||= {}
-
- self_r.add_class_annotation(_anno_class(cls), params)
- end
-
- nil
- end
-
- ##
- # Add a Java signaturefor the named method. The signature is specified as
- # an array of Java classes where the first class specifies the return
- # type.
- # :call-seq:
- #
- # add_method_signature :foo, [:void, :int, java.lang.Thread]
- #
- def add_method_signature(name, classes)
- name, self_r = name.to_s, JRuby.reference0(self)
- types = classes.inject([]) {|arr, cls| arr << _anno_class(cls) }
-
- self_r.add_method_signature(name, types.to_java(JClass))
-
- nil
- end
-
- def java_field(signature)
- signature = signature.to_s
-
- signature = signature.split(/\s/)
-
- raise "Java Field must be specified as a string with the format " if signature.size != 2
-
- type, name = signature
- java_fields << name
- add_field_signature(name, type)
- end
-
-
- def add_field_signature(name, type)
- self_r = JRuby.reference0(self)
-
- signature = JRuby::JavaSignature.new(nil, nil)
- java_return_type = signature.as_java_type(type)
-
- self_r.add_field_signature(name, java_return_type.to_java(JClass))
- end
-
- def add_field_annotation(name, annotations = {})
- name = name.to_s
- self_r = JRuby.reference0(self)
-
- for cls, params in annotations
- params ||= {}
- self_r.add_field_annotation(name, _anno_class(cls), params)
- end
-
- nil
- end
-
- def generate_java_fields
- java_fields.each do |field_name|
- field = java_class.get_declared_field(field_name)
- define_method(field_name) { field.get(self) }
- define_method(:"#{field_name}=") { |v| field.set(self, v) }
- end
- end
-
- def java_fields
- @java_fields ||= []
- end
-end
diff --git a/src/main/resources/stdlib/jruby/core_ext/method.rb b/src/main/resources/stdlib/jruby/core_ext/method.rb
deleted file mode 100644
index 1819fb9..0000000
--- a/src/main/resources/stdlib/jruby/core_ext/method.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'jruby'
-
-class Method
- def parameters
- self_r = JRuby.reference0(self)
- method = self_r.get_method
- args_ary = []
-
- case method
- when MethodArgs2
- return Helpers.parameter_list_to_parameters(JRuby.runtime, method.parameter_list, true)
- else
- if method.arity == Arity::OPTIONAL
- args_ary << [:rest]
- end
- end
-
- args_ary
- end
-end
diff --git a/src/main/resources/stdlib/jruby/core_ext/string.rb b/src/main/resources/stdlib/jruby/core_ext/string.rb
deleted file mode 100644
index 69fe3bd..0000000
--- a/src/main/resources/stdlib/jruby/core_ext/string.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'java'
-require 'jruby'
-
-class String
- RubyString = org.jruby.RubyString
-
- # Construct a new string with a buffer of the specified size. The buffer is
- # filled with null bytes to start.
- #
- # May be useful in cases where you know how large a string will grow, and want
- # to pre-allocate the buffer for that size.
- def self.alloc(size)
- RubyString.new_string_light(JRuby.runtime, size)
- end
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jruby/core_ext/thread.rb b/src/main/resources/stdlib/jruby/core_ext/thread.rb
deleted file mode 100644
index 9099adb..0000000
--- a/src/main/resources/stdlib/jruby/core_ext/thread.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'java'
-
-class Thread
- ThreadBean = java.lang.management.ManagementFactory.thread_mx_bean
-
- # Get true CPU times for the current thread.
- def times
- cpu = ThreadBean.current_thread_cpu_time
- user = ThreadBean.curent_thread_user_time
-
- cpu = 0 if cpu < 0
- user = 0 if user < 0
-
- system_f = (cpu - user) / 1000000000.0
- user_f = user / 1000000000.0
-
- Struct::Tms.new user_f, system_f, 0.0, 0.0
- end
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jruby/ext.rb b/src/main/resources/stdlib/jruby/ext.rb
deleted file mode 100644
index 72f4b13..0000000
--- a/src/main/resources/stdlib/jruby/ext.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require 'java'
-require 'jruby'
-
-module JRuby
- MethodArgs2 = org.jruby.internal.runtime.methods.MethodArgs2
- IRMethodArgs = org.jruby.internal.runtime.methods.IRMethodArgs
- Helpers = org.jruby.runtime.Helpers
- Arity = org.jruby.runtime.Arity
-
- # Extensions only provides one feature right now: stealing methods from one
- # class/module and inserting them into another.
- module Extensions
-
- # Transplant the named method from the given type into self. If self is a
- # module/class, it will gain the method. If self is not a module/class, then
- # the self object's singleton class will be used.
- def steal_method(type, method_name)
- if self.kind_of? Module
- to_add = self
- else
- to_add = JRuby.reference0(self).singleton_class
- end
-
- method_name = method_name.to_str
-
- raise TypeError, "first argument must be a module/class" unless type.kind_of? Module
-
- method = JRuby.reference0(type).search_method(method_name)
-
- if !method || method.undefined?
- raise ArgumentError, "no such method `#{method_name}' on type #{type}"
- end
-
- JRuby.reference0(to_add).add_method(method)
-
- nil
- end
- module_function :steal_method
-
- # Transplant all named methods from the given type into self. See
- # JRuby::Extensions.steal_method
- def steal_methods(type, *method_names)
- for method_name in method_names do
- steal_method(type, method_name)
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/jruby/jrubyc.rb b/src/main/resources/stdlib/jruby/jrubyc.rb
deleted file mode 100644
index 76f81df..0000000
--- a/src/main/resources/stdlib/jruby/jrubyc.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'jruby/compiler'
-
-# For compatibility with libraries that used it directly in 1.4-
-JRubyCompiler = JRuby::Compiler
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jruby/open3_windows.rb b/src/main/resources/stdlib/jruby/open3_windows.rb
deleted file mode 100644
index 736c3a7..0000000
--- a/src/main/resources/stdlib/jruby/open3_windows.rb
+++ /dev/null
@@ -1,731 +0,0 @@
-#
-# = open3.rb: Popen, but with stderr, too
-#
-# Author:: Yukihiro Matsumoto
-# Documentation:: Konrad Meyer
-#
-# Open3 gives you access to stdin, stdout, and stderr when running other
-# programs.
-#
-
-#
-# Open3 grants you access to stdin, stdout, stderr and a thread to wait the
-# child process when running another program.
-# You can specify various attributes, redirections, current directory, etc., of
-# the program as Process.spawn.
-#
-# - Open3.popen3 : pipes for stdin, stdout, stderr
-# - Open3.popen2 : pipes for stdin, stdout
-# - Open3.popen2e : pipes for stdin, merged stdout and stderr
-# - Open3.capture3 : give a string for stdin. get strings for stdout, stderr
-# - Open3.capture2 : give a string for stdin. get a string for stdout
-# - Open3.capture2e : give a string for stdin. get a string for merged stdout and stderr
-# - Open3.pipeline_rw : pipes for first stdin and last stdout of a pipeline
-# - Open3.pipeline_r : pipe for last stdout of a pipeline
-# - Open3.pipeline_w : pipe for first stdin of a pipeline
-# - Open3.pipeline_start : a pipeline
-# - Open3.pipeline : run a pipline and wait
-#
-
-module Open3
-
- # Open stdin, stdout, and stderr streams and start external executable.
- # In addition, a thread for waiting the started process is noticed.
- # The thread has a pid method and thread variable :pid which is the pid of
- # the started process.
- #
- # Block form:
- #
- # Open3.popen3([env,] cmd... [, opts]) {|stdin, stdout, stderr, wait_thr|
- # pid = wait_thr.pid # pid of the started process.
- # ...
- # exit_status = wait_thr.value # Process::Status object returned.
- # }
- #
- # Non-block form:
- #
- # stdin, stdout, stderr, wait_thr = Open3.popen3([env,] cmd... [, opts])
- # pid = wait_thr[:pid] # pid of the started process.
- # ...
- # stdin.close # stdin, stdout and stderr should be closed explicitly in this form.
- # stdout.close
- # stderr.close
- # exit_status = wait_thr.value # Process::Status object returned.
- #
- # The parameters +cmd...+ is passed to Process.spawn.
- # So a commandline string and list of argument strings can be accepted as follows.
- #
- # Open3.popen3("echo a") {|i, o, e, t| ... }
- # Open3.popen3("echo", "a") {|i, o, e, t| ... }
- # Open3.popen3(["echo", "argv0"], "a") {|i, o, e, t| ... }
- #
- # If the last parameter, opts, is a Hash, it is recognized as an option for Process.spawn.
- #
- # Open3.popen3("pwd", :chdir=>"/") {|i,o,e,t|
- # p o.read.chomp #=> "/"
- # }
- #
- # wait_thr.value waits the termination of the process.
- # The block form also waits the process when it returns.
- #
- # Closing stdin, stdout and stderr does not wait the process.
- #
- def popen3(*cmd, &block)
- return IO::popen3(*cmd, &block) if RUBY_ENGINE == 'jruby'
-
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
- in_r, in_w = IO.pipe
- opts[:in] = in_r
- in_w.sync = true
-
- out_r, out_w = IO.pipe
- opts[:out] = out_w
-
- err_r, err_w = IO.pipe
- opts[:err] = err_w
-
- popen_run(cmd, opts, [in_r, out_w, err_w], [in_w, out_r, err_r], &block)
- end
- module_function :popen3
-
- # Open3.popen2 is similer to Open3.popen3 except it doesn't make a pipe for
- # the standard error stream.
- #
- # Block form:
- #
- # Open3.popen2([env,] cmd... [, opts]) {|stdin, stdout, wait_thr|
- # pid = wait_thr.pid # pid of the started process.
- # ...
- # exit_status = wait_thr.value # Process::Status object returned.
- # }
- #
- # Non-block form:
- #
- # stdin, stdout, wait_thr = Open3.popen2([env,] cmd... [, opts])
- # ...
- # stdin.close # stdin and stdout should be closed explicitly in this form.
- # stdout.close
- #
- # See Process.spawn for the optional hash arguments _env_ and _opts_.
- #
- # Example:
- #
- # Open3.popen2("wc -c") {|i,o,t|
- # i.print "answer to life the universe and everything"
- # i.close
- # p o.gets #=> "42\n"
- # }
- #
- # Open3.popen2("bc -q") {|i,o,t|
- # i.puts "obase=13"
- # i.puts "6 * 9"
- # p o.gets #=> "42\n"
- # }
- #
- # Open3.popen2("dc") {|i,o,t|
- # i.print "42P"
- # i.close
- # p o.read #=> "*"
- # }
- #
- def popen2(*cmd, &block)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
- in_r, in_w = IO.pipe
- opts[:in] = in_r
- in_w.sync = true
-
- out_r, out_w = IO.pipe
- opts[:out] = out_w
-
- popen_run(cmd, opts, [in_r, out_w], [in_w, out_r], &block)
- end
- module_function :popen2
-
- # Open3.popen2e is similer to Open3.popen3 except it merges
- # the standard output stream and the standard error stream.
- #
- # Block form:
- #
- # Open3.popen2e([env,] cmd... [, opts]) {|stdin, stdout_and_stderr, wait_thr|
- # pid = wait_thr.pid # pid of the started process.
- # ...
- # exit_status = wait_thr.value # Process::Status object returned.
- # }
- #
- # Non-block form:
- #
- # stdin, stdout_and_stderr, wait_thr = Open3.popen2e([env,] cmd... [, opts])
- # ...
- # stdin.close # stdin and stdout_and_stderr should be closed explicitly in this form.
- # stdout_and_stderr.close
- #
- # See Process.spawn for the optional hash arguments _env_ and _opts_.
- #
- # Example:
- # # check gcc warnings
- # source = "foo.c"
- # Open3.popen2e("gcc", "-Wall", source) {|i,oe,t|
- # oe.each {|line|
- # if /warning/ =~ line
- # ...
- # end
- # }
- # }
- #
- def popen2e(*cmd, &block)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
- in_r, in_w = IO.pipe
- opts[:in] = in_r
- in_w.sync = true
-
- out_r, out_w = IO.pipe
- opts[[:out, :err]] = out_w
-
- popen_run(cmd, opts, [in_r, out_w], [in_w, out_r], &block)
- end
- module_function :popen2e
-
- def popen_run(cmd, opts, child_io, parent_io) # :nodoc:
- pid = spawn(*cmd, opts)
- wait_thr = Process.detach(pid)
- child_io.each {|io| io.close }
- result = [*parent_io, wait_thr]
- if defined? yield
- begin
- return yield(*result)
- ensure
- parent_io.each{|io| io.close unless io.closed?}
- wait_thr.join
- end
- end
- result
- end
- module_function :popen_run
- class << self
- private :popen_run
- end
-
- # Open3.capture3 captures the standard output and the standard error of a command.
- #
- # stdout_str, stderr_str, status = Open3.capture3([env,] cmd... [, opts])
- #
- # The arguments env, cmd and opts are passed to Open3.popen3 except
- # opts[:stdin_data] and opts[:binmode]. See Process.spawn.
- #
- # If opts[:stdin_data] is specified, it is sent to the command's standard input.
- #
- # If opts[:binmode] is true, internal pipes are set to binary mode.
- #
- # Example:
- #
- # # dot is a command of graphviz.
- # graph = <<'End'
- # digraph g {
- # a -> b
- # }
- # End
- # layouted_graph, dot_log = Open3.capture3("dot -v", :stdin_data=>graph)
- #
- # o, e, s = Open3.capture3("echo a; sort >&2", :stdin_data=>"foo\nbar\nbaz\n")
- # p o #=> "a\n"
- # p e #=> "bar\nbaz\nfoo\n"
- # p s #=> #
- #
- # # generate a thumnail image using the convert command of ImageMagick.
- # # However, if the image stored really in a file,
- # # system("convert", "-thumbnail", "80", "png:#{filename}", "png:-") is better
- # # because memory consumption.
- # # But if the image is stored in a DB or generated by gnuplot Open3.capture2 example,
- # # Open3.capture3 is considerable.
- # #
- # image = File.read("/usr/share/openclipart/png/animals/mammals/sheep-md-v0.1.png", :binmode=>true)
- # thumnail, err, s = Open3.capture3("convert -thumbnail 80 png:- png:-", :stdin_data=>image, :binmode=>true)
- # if s.success?
- # STDOUT.binmode; print thumnail
- # end
- #
- def capture3(*cmd)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
- stdin_data = opts.delete(:stdin_data) || ''
- binmode = opts.delete(:binmode)
-
- popen3(*cmd, opts) {|i, o, e, t|
- if binmode
- i.binmode
- o.binmode
- e.binmode
- end
- out_reader = Thread.new { o.read }
- err_reader = Thread.new { e.read }
- i.write stdin_data
- i.close
- [out_reader.value, err_reader.value, t.value]
- }
- end
- module_function :capture3
-
- # Open3.capture2 captures the standard output of a command.
- #
- # stdout_str, status = Open3.capture2([env,] cmd... [, opts])
- #
- # The arguments env, cmd and opts are passed to Open3.popen3 except
- # opts[:stdin_data] and opts[:binmode]. See Process.spawn.
- #
- # If opts[:stdin_data] is specified, it is sent to the command's standard input.
- #
- # If opts[:binmode] is true, internal pipes are set to binary mode.
- #
- # Example:
- #
- # # factor is a command for integer factorization.
- # o, s = Open3.capture2("factor", :stdin_data=>"42")
- # p o #=> "42: 2 3 7\n"
- #
- # # generate x**2 graph in png using gnuplot.
- # gnuplot_commands = <<"End"
- # set terminal png
- # plot x**2, "-" with lines
- # 1 14
- # 2 1
- # 3 8
- # 4 5
- # e
- # End
- # image, s = Open3.capture2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true)
- #
- def capture2(*cmd)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
- stdin_data = opts.delete(:stdin_data) || ''
- binmode = opts.delete(:binmode)
-
- popen2(*cmd, opts) {|i, o, t|
- if binmode
- i.binmode
- o.binmode
- end
- out_reader = Thread.new { o.read }
- i.write stdin_data
- i.close
- [out_reader.value, t.value]
- }
- end
- module_function :capture2
-
- # Open3.capture2e captures the standard output and the standard error of a command.
- #
- # stdout_and_stderr_str, status = Open3.capture2e([env,] cmd... [, opts])
- #
- # The arguments env, cmd and opts are passed to Open3.popen3 except
- # opts[:stdin_data] and opts[:binmode]. See Process.spawn.
- #
- # If opts[:stdin_data] is specified, it is sent to the command's standard input.
- #
- # If opts[:binmode] is true, internal pipes are set to binary mode.
- #
- # Example:
- #
- # # capture make log
- # make_log, s = Open3.capture2e("make")
- #
- def capture2e(*cmd)
- if Hash === cmd.last
- opts = cmd.pop.dup
- else
- opts = {}
- end
-
- stdin_data = opts.delete(:stdin_data) || ''
- binmode = opts.delete(:binmode)
-
- popen2e(*cmd, opts) {|i, oe, t|
- if binmode
- i.binmode
- oe.binmode
- end
- outerr_reader = Thread.new { oe.read }
- i.write stdin_data
- i.close
- [outerr_reader.value, t.value]
- }
- end
- module_function :capture2e
-
- # Open3.pipeline_rw starts a list of commands as a pipeline with pipes
- # which connects stdin of the first command and stdout of the last command.
- #
- # Open3.pipeline_rw(cmd1, cmd2, ... [, opts]) {|first_stdin, last_stdout, wait_threads|
- # ...
- # }
- #
- # first_stdin, last_stdout, wait_threads = Open3.pipeline_rw(cmd1, cmd2, ... [, opts])
- # ...
- # first_stdin.close
- # last_stdout.close
- #
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
- #
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
- #
- # Note that env and opts are optional, as Process.spawn.
- #
- # The option to pass Process.spawn is constructed by merging
- # +opts+, the last hash element of the array and
- # specification for the pipe between each commands.
- #
- # Example:
- #
- # Open3.pipeline_rw("tr -dc A-Za-z", "wc -c") {|i,o,ts|
- # i.puts "All persons more than a mile high to leave the court."
- # i.close
- # p o.gets #=> "42\n"
- # }
- #
- # Open3.pipeline_rw("sort", "cat -n") {|stdin, stdout, wait_thrs|
- # stdin.puts "foo"
- # stdin.puts "bar"
- # stdin.puts "baz"
- # stdin.close # send EOF to sort.
- # p stdout.read #=> " 1\tbar\n 2\tbaz\n 3\tfoo\n"
- # }
- def pipeline_rw(*cmds, &block)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
- in_r, in_w = IO.pipe
- opts[:in] = in_r
- in_w.sync = true
-
- out_r, out_w = IO.pipe
- opts[:out] = out_w
-
- pipeline_run(cmds, opts, [in_r, out_w], [in_w, out_r], &block)
- end
- module_function :pipeline_rw
-
- # Open3.pipeline_r starts a list of commands as a pipeline with a pipe
- # which connects stdout of the last command.
- #
- # Open3.pipeline_r(cmd1, cmd2, ... [, opts]) {|last_stdout, wait_threads|
- # ...
- # }
- #
- # last_stdout, wait_threads = Open3.pipeline_r(cmd1, cmd2, ... [, opts])
- # ...
- # last_stdout.close
- #
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
- #
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
- #
- # Note that env and opts are optional, as Process.spawn.
- #
- # Example:
- #
- # Open3.pipeline_r("zcat /var/log/apache2/access.log.*.gz",
- # [{"LANG"=>"C"}, "grep", "GET /favicon.ico"],
- # "logresolve") {|o, ts|
- # o.each_line {|line|
- # ...
- # }
- # }
- #
- # Open3.pipeline_r("yes", "head -10") {|o, ts|
- # p o.read #=> "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"
- # p ts[0].value #=> #
- # p ts[1].value #=> #
- # }
- #
- def pipeline_r(*cmds, &block)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
- out_r, out_w = IO.pipe
- opts[:out] = out_w
-
- pipeline_run(cmds, opts, [out_w], [out_r], &block)
- end
- module_function :pipeline_r
-
- # Open3.pipeline_w starts a list of commands as a pipeline with a pipe
- # which connects stdin of the first command.
- #
- # Open3.pipeline_w(cmd1, cmd2, ... [, opts]) {|first_stdin, wait_threads|
- # ...
- # }
- #
- # first_stdin, wait_threads = Open3.pipeline_w(cmd1, cmd2, ... [, opts])
- # ...
- # first_stdin.close
- #
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
- #
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
- #
- # Note that env and opts are optional, as Process.spawn.
- #
- # Example:
- #
- # Open3.pipeline_w("bzip2 -c", :out=>"/tmp/hello.bz2") {|i, ts|
- # i.puts "hello"
- # }
- #
- def pipeline_w(*cmds, &block)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
- in_r, in_w = IO.pipe
- opts[:in] = in_r
- in_w.sync = true
-
- pipeline_run(cmds, opts, [in_r], [in_w], &block)
- end
- module_function :pipeline_w
-
- # Open3.pipeline_start starts a list of commands as a pipeline.
- # No pipe made for stdin of the first command and
- # stdout of the last command.
- #
- # Open3.pipeline_start(cmd1, cmd2, ... [, opts]) {|wait_threads|
- # ...
- # }
- #
- # wait_threads = Open3.pipeline_start(cmd1, cmd2, ... [, opts])
- # ...
- #
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
- #
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
- #
- # Note that env and opts are optional, as Process.spawn.
- #
- # Example:
- #
- # # run xeyes in 10 seconds.
- # Open3.pipeline_start("xeyes") {|ts|
- # sleep 10
- # t = ts[0]
- # Process.kill("TERM", t.pid)
- # p t.value #=> #
- # }
- #
- # # convert pdf to ps and send it to a printer.
- # # collect error message of pdftops and lpr.
- # pdf_file = "paper.pdf"
- # printer = "printer-name"
- # err_r, err_w = IO.pipe
- # Open3.pipeline_start(["pdftops", pdf_file, "-"],
- # ["lpr", "-P#{printer}"],
- # :err=>err_w) {|ts|
- # err_w.close
- # p err_r.read # error messages of pdftops and lpr.
- # }
- #
- def pipeline_start(*cmds, &block)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
- if block
- pipeline_run(cmds, opts, [], [], &block)
- else
- ts, = pipeline_run(cmds, opts, [], [])
- ts
- end
- end
- module_function :pipeline_start
-
- # Open3.pipeline starts a list of commands as a pipeline.
- # It waits the finish of the commands.
- # No pipe made for stdin of the first command and
- # stdout of the last command.
- #
- # status_list = Open3.pipeline(cmd1, cmd2, ... [, opts])
- #
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
- #
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
- #
- # Note that env and opts are optional, as Process.spawn.
- #
- # Example:
- #
- # fname = "/usr/share/man/man1/ruby.1.gz"
- # p Open3.pipeline(["zcat", fname], "nroff -man", "less")
- # #=> [#,
- # # #,
- # # #]
- #
- # fname = "/usr/share/man/man1/ls.1.gz"
- # Open3.pipeline(["zcat", fname], "nroff -man", "colcrt")
- #
- # # convert PDF to PS and send to a printer by lpr
- # pdf_file = "paper.pdf"
- # printer = "printer-name"
- # Open3.pipeline(["pdftops", pdf_file, "-"],
- # ["lpr", "-P#{printer}"])
- #
- # # count lines
- # Open3.pipeline("sort", "uniq -c", :in=>"names.txt", :out=>"count")
- #
- # # cyclic pipeline
- # r,w = IO.pipe
- # w.print "ibase=14\n10\n"
- # Open3.pipeline("bc", "tee /dev/tty", :in=>r, :out=>w)
- # #=> 14
- # # 18
- # # 22
- # # 30
- # # 42
- # # 58
- # # 78
- # # 106
- # # 202
- #
- def pipeline(*cmds)
- if Hash === cmds.last
- opts = cmds.pop.dup
- else
- opts = {}
- end
-
- pipeline_run(cmds, opts, [], []) {|ts|
- ts.map {|t| t.value }
- }
- end
- module_function :pipeline
-
- def pipeline_run(cmds, pipeline_opts, child_io, parent_io) # :nodoc:
- if cmds.empty?
- raise ArgumentError, "no commands"
- end
-
- opts_base = pipeline_opts.dup
- opts_base.delete :in
- opts_base.delete :out
-
- wait_thrs = []
- r = nil
- cmds.each_with_index {|cmd, i|
- cmd_opts = opts_base.dup
- if String === cmd
- cmd = [cmd]
- else
- cmd_opts.update cmd.pop if Hash === cmd.last
- end
- if i == 0
- if !cmd_opts.include?(:in)
- if pipeline_opts.include?(:in)
- cmd_opts[:in] = pipeline_opts[:in]
- end
- end
- else
- cmd_opts[:in] = r
- end
- if i != cmds.length - 1
- r2, w2 = IO.pipe
- cmd_opts[:out] = w2
- else
- if !cmd_opts.include?(:out)
- if pipeline_opts.include?(:out)
- cmd_opts[:out] = pipeline_opts[:out]
- end
- end
- end
- pid = spawn(*cmd, cmd_opts)
- wait_thrs << Process.detach(pid)
- r.close if r
- w2.close if w2
- r = r2
- }
- result = parent_io + [wait_thrs]
- child_io.each {|io| io.close }
- if defined? yield
- begin
- return yield(*result)
- ensure
- parent_io.each{|io| io.close unless io.closed?}
- wait_thrs.each {|t| t.join }
- end
- end
- result
- end
- module_function :pipeline_run
- class << self
- private :pipeline_run
- end
-
-end
-
-if $0 == __FILE__
- a = Open3.popen3("nroff -man")
- Thread.start do
- while line = gets
- a[0].print line
- end
- a[0].close
- end
- while line = a[1].gets
- print ":", line
- end
-end
diff --git a/src/main/resources/stdlib/jruby/profiler.rb b/src/main/resources/stdlib/jruby/profiler.rb
deleted file mode 100644
index 807aae3..0000000
--- a/src/main/resources/stdlib/jruby/profiler.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-
-require 'java'
-
-module JRuby
- module Profiler
- java_import org.jruby.runtime.profile.builtin.ProfilePrinter
- java_import org.jruby.runtime.profile.builtin.FlatProfilePrinter
- java_import org.jruby.runtime.profile.builtin.GraphProfilePrinter
- java_import org.jruby.runtime.profile.builtin.HtmlProfilePrinter
- java_import org.jruby.runtime.profile.builtin.JsonProfilePrinter
-
- def self.profile(&block)
- unless runtime.instance_config.is_profiling
- raise RuntimeError.new "Profiling not enabled in runtime"
- end
-
- start
- profiled_code(&block)
- stop
- end
-
- def self.profiled_code
- yield
- end
-
- def self.clear
- profile_data.clear
- end
-
- protected
-
- def self.start
- current_thread_context.start_profiling
- clear
- end
-
- def self.stop
- current_thread_context.stop_profiling
- profile_data
- end
-
- def self.profile_data
- current_thread_context.profile_collection
- end
-
- private
-
- def self.runtime
- JRuby.runtime
- end
-
- def self.current_thread_context
- runtime.get_thread_service.get_current_context
- end
-
- end
-end
diff --git a/src/main/resources/stdlib/jruby/profiler/shutdown_hook.rb b/src/main/resources/stdlib/jruby/profiler/shutdown_hook.rb
deleted file mode 100644
index c9f5ff7..0000000
--- a/src/main/resources/stdlib/jruby/profiler/shutdown_hook.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'jruby'
-
-trap 'INT' do
- runtime = JRuby.runtime
- runtime.thread_service.ruby_thread_map.each do |t, rubythread|
- context = JRuby.reference(rubythread).context
- runtime.printProfileData(context.profile_collection)
- end
- exit
-end
-STDERR.puts "Profiling enabled; ^C shutdown will now dump profile info"
diff --git a/src/main/resources/stdlib/jruby/synchronized.rb b/src/main/resources/stdlib/jruby/synchronized.rb
deleted file mode 100644
index b86fc0c..0000000
--- a/src/main/resources/stdlib/jruby/synchronized.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'jruby'
-
-module JRuby
- # Include into a class to make all of that class's instance methods be
- # "synchronized" against the object itself. In Ruby parlance, it is as if
- # each method on the class locks against a reentrant, per-object Mutex.
- module Synchronized
- def self.append_features(cls)
- raise TypeError, "#{self} can only be included into classes" unless Class === cls
- cls_r = JRuby.reference0(cls)
- cls_r.become_synchronized
-
- super
- end
-
- def self.extend_object(obj)
- obj_r = JRuby.reference0(obj)
- singleton_class = obj_r.singleton_class
- JRuby.reference(singleton_class).become_synchronized
-
- super
- end
- end
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jruby/thread_dump.rb b/src/main/resources/stdlib/jruby/thread_dump.rb
deleted file mode 100644
index 1e81ff7..0000000
--- a/src/main/resources/stdlib/jruby/thread_dump.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'jruby'
-
-begin
- handler = proc do
- cur_thread = Thread.current
-
- $stderr.puts "\nRuby Thread Dump\n================\n"
-
- thread_service = JRuby.runtime.thread_service
- trace_type = org.jruby.runtime.backtrace.TraceType
-
- for thread in thread_service.active_ruby_threads
- next if thread == cur_thread
-
- thread_r = JRuby.reference(thread)
-
- $stderr.puts "* Thread: #{thread_r.native_thread.name}"
- $stderr.puts "* Stack:"
-
- thread_r = JRuby.reference(thread)
- thread_context = thread_r.context
-
- unless thread_context
- $stderr.puts " [dead]\n"
- next
- end
-
- ex = RuntimeError.new('thread dump')
- ex_r = JRuby.reference(ex)
-
- gather = trace_type::Gather::NORMAL
- format = trace_type::Format::JRUBY
-
- ex_r.backtrace_data = gather.get_backtrace_data(thread_context, thread_r.native_thread.stack_trace, true)
- $stderr.puts format.print_backtrace(ex, false)
-
- $stderr.puts
- end
- end
-
- Signal.__jtrap_kernel(handler, 'USR2')
-rescue ArgumentError
- $stderr.puts "failed handling USR2; 'jruby -J-XX:+UseAltSigs ...' to disable JVM's handler"
-rescue Exception
- warn $!.message
- warning $!.backtrace
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jruby/vm.rb b/src/main/resources/stdlib/jruby/vm.rb
deleted file mode 100644
index 148b1de..0000000
--- a/src/main/resources/stdlib/jruby/vm.rb
+++ /dev/null
@@ -1,197 +0,0 @@
-require 'java'
-require 'jruby'
-
-module JRuby
- class VM
- class << self
- def stats
- raise NotImplementedError
- end
-
- def load_library(path, name)
- raise NotImplementedError
- end
-
- def reset_method_cache(sym)
- raise NotImplementedError
- end
-
- def save_encloser_path
- raise NotImplementedError
- end
-
- def restore_encloser_path
- raise NotImplementedError
- end
-
- def coerce_to_array(object)
- raise NotImplementedError
- end
-
- # Semantics of this are very important. ret MUST be returned.
- def perform_hook(obj, meth, arg, ret)
- raise NotImplementedError
- end
-
- def join(id)
- MAP[id].join
- end
-
- def poll_message
- CURRENT.queue.poll
- end
-
- def send_message(id, obj)
- MAP[id].send(obj)
- end
-
- def spawn(*args)
- new_vm = ChildVM.new(args)
- MAP[new_vm.id] = new_vm
- end
-
- def get_message
- CURRENT.queue.take
- end
-
- def each_message
- while true
- yield get_message
- end
- end
- end
-
- attr_reader :id
- attr_reader :main
- attr_reader :queue
-
- def send(obj)
- case obj
- when String
- @queue.put obj
- when Fixnum
- @queue.put obj
- end
- end
-
- def join
- @main.join
- end
-
- def <<(obj)
- send obj
- end
- end
-
- java_import java.util.concurrent.LinkedBlockingQueue
- java_import java.util.HashMap
-
- class ChildVM < VM
- JThread = java.lang.Thread
- Runnable = java.lang.Runnable
- java_import org.jruby.RubyInstanceConfig
- java_import org.jruby.Ruby
- java_import org.jruby.RubyIO
- java_import java.nio.channels.Pipe
- java_import java.nio.channels.Channels
- java_import java.io.PrintStream
-
- attr_reader :stdin
- attr_reader :stdout
- attr_reader :stderr
-
- def initialize(args)
- @config = RubyInstanceConfig.new
- inpipe = Pipe.open
- outpipe = Pipe.open
- errpipe = Pipe.open
-
- @config.input = Channels.new_input_stream inpipe.source
- @config.output = PrintStream.new(Channels.new_output_stream outpipe.sink)
- @config.error = PrintStream.new(Channels.new_output_stream errpipe.sink)
-
- @stdin = RubyIO.newIO(JRuby.runtime, inpipe.sink)
- @stdout = RubyIO.newIO(JRuby.runtime, outpipe.source)
- @stderr = RubyIO.newIO(JRuby.runtime, errpipe.source)
-
- # stdin should not be buffered, immediately write to pipe
- @stdin.sync = true
-
- @config.process_arguments(args.to_java :string)
-
- @id = hash
-
- # set up queue
- @queue = LinkedBlockingQueue.new
- end
-
- def start
- if @started
- raise RuntimeError, "already started VM"
- end
-
- # Create the main thread for the child VM
- @main = JThread.new do
- begin
- @runtime = Ruby.new_instance(@config)
- @runtime.load_service.require('jruby/vm')
- vm_class = JRuby.reference(@runtime.get_class_from_path("JRuby::VM"))
- vm_class.set_constant("CURRENT", self)
- vm_class.set_constant("MAP", JRuby.reference(MAP))
-
- script = @config.script_source
- filename = @config.displayed_file_name
- @runtime.run_from_main(script, filename)
-
- # shut down the streams
- @config.input.close
- @config.output.close
- @config.error.close
- rescue Exception => e
- e.printStackTrace
- end
- end
-
- @main.start
- @started = true
- end
-
- def send(obj)
- _check_started
- super
- end
-
- def join
- _check_started
- super
- end
-
- def <<(obj)
- _check_started
- super
- end
-
- private
- def _check_started
- raise RuntimeError, "child VM not started" unless @started
- end
- end
-
- class MainVM < VM
- def initialize()
- # set up queue
- @queue = LinkedBlockingQueue.new
- @main = JRuby.runtime.thread_service.main_thread
- end
- end
-
- VM_ID = JRuby.runtime.hashCode
- CURRENT = MainVM.new
- MAP ||= HashMap.new
- MAP[VM_ID] = CURRENT
-end
-
-module Rubinius
- VM = JRuby::VM
- VM_ID = JRuby::VM_ID
-end
\ No newline at end of file
diff --git a/src/main/resources/stdlib/jruby/win32ole/stub.rb b/src/main/resources/stdlib/jruby/win32ole/stub.rb
deleted file mode 100644
index 733d227..0000000
--- a/src/main/resources/stdlib/jruby/win32ole/stub.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-tried_gem = false
-begin
- require 'jruby-win32ole'
-rescue LoadError
- if tried_gem
- warn "!!!! Missing jruby-win32ole gem: jruby -S gem install jruby-win32ole"
- raise $!
- end
- require 'rubygems'
- begin
- gem 'jruby-win32ole'
- rescue LoadError
- end
- tried_gem = true
- retry
-end
diff --git a/src/main/resources/stdlib/json.rb b/src/main/resources/stdlib/json.rb
deleted file mode 100644
index 24aa385..0000000
--- a/src/main/resources/stdlib/json.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'json/common'
-
-##
-# = JavaScript Object Notation (JSON)
-#
-# JSON is a lightweight data-interchange format. It is easy for us
-# humans to read and write. Plus, equally simple for machines to generate or parse.
-# JSON is completely language agnostic, making it the ideal interchange format.
-#
-# Built on two universally available structures:
-# 1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array.
-# 2. An ordered list of values. More commonly called an _array_, vector, sequence or list.
-#
-# To read more about JSON visit: http://json.org
-#
-# == Parsing JSON
-#
-# To parse a JSON string received by another application or generated within
-# your existing application:
-#
-# require 'json'
-#
-# my_hash = JSON.parse('{"hello": "goodbye"}')
-# puts my_hash["hello"] => "goodbye"
-#
-# Notice the extra quotes '' around the hash notation. Ruby expects
-# the argument to be a string and can't convert objects like a hash or array.
-#
-# Ruby converts your string into a hash
-#
-# == Generating JSON
-#
-# Creating a JSON string for communication or serialization is
-# just as simple.
-#
-# require 'json'
-#
-# my_hash = {:hello => "goodbye"}
-# puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}"
-#
-# Or an alternative way:
-#
-# require 'json'
-# puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}"
-#
-# JSON.generate only allows objects or arrays to be converted
-# to JSON syntax. to_json, however, accepts many Ruby classes
-# even though it acts only as a method for serialization:
-#
-# require 'json'
-#
-# 1.to_json => "1"
-#
-module JSON
- require 'json/version'
-
- begin
- require 'json/ext'
- rescue LoadError
- require 'json/pure'
- end
-end
diff --git a/src/main/resources/stdlib/json/add/bigdecimal.rb b/src/main/resources/stdlib/json/add/bigdecimal.rb
deleted file mode 100644
index 0ef69f1..0000000
--- a/src/main/resources/stdlib/json/add/bigdecimal.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-defined?(::BigDecimal) or require 'bigdecimal'
-
-class BigDecimal
- # Import a JSON Marshalled object.
- #
- # method used for JSON marshalling support.
- def self.json_create(object)
- BigDecimal._load object['b']
- end
-
- # Marshal the object to JSON.
- #
- # method used for JSON marshalling support.
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 'b' => _dump,
- }
- end
-
- # return the JSON value
- def to_json(*)
- as_json.to_json
- end
-end
diff --git a/src/main/resources/stdlib/json/add/complex.rb b/src/main/resources/stdlib/json/add/complex.rb
deleted file mode 100644
index d7ebebf..0000000
--- a/src/main/resources/stdlib/json/add/complex.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-defined?(::Complex) or require 'complex'
-
-class Complex
- def self.json_create(object)
- Complex(object['r'], object['i'])
- end
-
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 'r' => real,
- 'i' => imag,
- }
- end
-
- def to_json(*)
- as_json.to_json
- end
-end
diff --git a/src/main/resources/stdlib/json/add/core.rb b/src/main/resources/stdlib/json/add/core.rb
deleted file mode 100644
index 77d9dc0..0000000
--- a/src/main/resources/stdlib/json/add/core.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# This file requires the implementations of ruby core's custom objects for
-# serialisation/deserialisation.
-
-require 'json/add/date'
-require 'json/add/date_time'
-require 'json/add/exception'
-require 'json/add/range'
-require 'json/add/regexp'
-require 'json/add/struct'
-require 'json/add/symbol'
-require 'json/add/time'
diff --git a/src/main/resources/stdlib/json/add/date.rb b/src/main/resources/stdlib/json/add/date.rb
deleted file mode 100644
index 4288237..0000000
--- a/src/main/resources/stdlib/json/add/date.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-require 'date'
-
-# Date serialization/deserialization
-class Date
-
- # Deserializes JSON string by converting Julian year y, month
- # m, day d and Day of Calendar Reform sg to Date.
- def self.json_create(object)
- civil(*object.values_at('y', 'm', 'd', 'sg'))
- end
-
- alias start sg unless method_defined?(:start)
-
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 'y' => year,
- 'm' => month,
- 'd' => day,
- 'sg' => start,
- }
- end
-
- # Stores class name (Date) with Julian year y, month m, day
- # d and Day of Calendar Reform sg as JSON string
- def to_json(*args)
- as_json.to_json(*args)
- end
-end
diff --git a/src/main/resources/stdlib/json/add/date_time.rb b/src/main/resources/stdlib/json/add/date_time.rb
deleted file mode 100644
index 5ea42ea..0000000
--- a/src/main/resources/stdlib/json/add/date_time.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-require 'date'
-
-# DateTime serialization/deserialization
-class DateTime
-
- # Deserializes JSON string by converting year y, month m,
- # day d, hour H, minute M, second S,
- # offset of and Day of Calendar Reform sg to DateTime.
- def self.json_create(object)
- args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
- of_a, of_b = object['of'].split('/')
- if of_b and of_b != '0'
- args << Rational(of_a.to_i, of_b.to_i)
- else
- args << of_a
- end
- args << object['sg']
- civil(*args)
- end
-
- alias start sg unless method_defined?(:start)
-
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 'y' => year,
- 'm' => month,
- 'd' => day,
- 'H' => hour,
- 'M' => min,
- 'S' => sec,
- 'of' => offset.to_s,
- 'sg' => start,
- }
- end
-
- # Stores class name (DateTime) with Julian year y, month m,
- # day d, hour H, minute M, second S,
- # offset of and Day of Calendar Reform sg as JSON string
- def to_json(*args)
- as_json.to_json(*args)
- end
-end
-
-
diff --git a/src/main/resources/stdlib/json/add/exception.rb b/src/main/resources/stdlib/json/add/exception.rb
deleted file mode 100644
index e6ad257..0000000
--- a/src/main/resources/stdlib/json/add/exception.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-
-# Exception serialization/deserialization
-class Exception
-
- # Deserializes JSON string by constructing new Exception object with message
- # m and backtrace b serialized with to_json
- def self.json_create(object)
- result = new(object['m'])
- result.set_backtrace object['b']
- result
- end
-
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 'm' => message,
- 'b' => backtrace,
- }
- end
-
- # Stores class name (Exception) with message m and backtrace array
- # b as JSON string
- def to_json(*args)
- as_json.to_json(*args)
- end
-end
diff --git a/src/main/resources/stdlib/json/add/ostruct.rb b/src/main/resources/stdlib/json/add/ostruct.rb
deleted file mode 100644
index da81e10..0000000
--- a/src/main/resources/stdlib/json/add/ostruct.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-require 'ostruct'
-
-# OpenStruct serialization/deserialization
-class OpenStruct
-
- # Deserializes JSON string by constructing new Struct object with values
- # v serialized by to_json.
- def self.json_create(object)
- new(object['t'] || object[:t])
- end
-
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
- def as_json(*)
- klass = self.class.name
- klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
- {
- JSON.create_id => klass,
- 't' => table,
- }
- end
-
- # Stores class name (OpenStruct) with this struct's values v as a
- # JSON string.
- def to_json(*args)
- as_json.to_json(*args)
- end
-end
diff --git a/src/main/resources/stdlib/json/add/range.rb b/src/main/resources/stdlib/json/add/range.rb
deleted file mode 100644
index e61e553..0000000
--- a/src/main/resources/stdlib/json/add/range.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-
-# Range serialization/deserialization
-class Range
-
- # Deserializes JSON string by constructing new Range object with arguments
- # a serialized by to_json.
- def self.json_create(object)
- new(*object['a'])
- end
-
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 'a' => [ first, last, exclude_end? ]
- }
- end
-
- # Stores class name (Range) with JSON array of arguments a which
- # include first (integer), last (integer), and
- # exclude_end? (boolean) as JSON string.
- def to_json(*args)
- as_json.to_json(*args)
- end
-end
diff --git a/src/main/resources/stdlib/json/add/rational.rb b/src/main/resources/stdlib/json/add/rational.rb
deleted file mode 100644
index 867cd92..0000000
--- a/src/main/resources/stdlib/json/add/rational.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-defined?(::Rational) or require 'rational'
-
-class Rational
- def self.json_create(object)
- Rational(object['n'], object['d'])
- end
-
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 'n' => numerator,
- 'd' => denominator,
- }
- end
-
- def to_json(*)
- as_json.to_json
- end
-end
diff --git a/src/main/resources/stdlib/json/add/regexp.rb b/src/main/resources/stdlib/json/add/regexp.rb
deleted file mode 100644
index 2fcbb6f..0000000
--- a/src/main/resources/stdlib/json/add/regexp.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-
-# Regexp serialization/deserialization
-class Regexp
-
- # Deserializes JSON string by constructing new Regexp object with source
- # s (Regexp or String) and options o serialized by
- # to_json
- def self.json_create(object)
- new(object['s'], object['o'])
- end
-
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 'o' => options,
- 's' => source,
- }
- end
-
- # Stores class name (Regexp) with options o and source s
- # (Regexp or String) as JSON string
- def to_json(*)
- as_json.to_json
- end
-end
diff --git a/src/main/resources/stdlib/json/add/struct.rb b/src/main/resources/stdlib/json/add/struct.rb
deleted file mode 100644
index 6847cde..0000000
--- a/src/main/resources/stdlib/json/add/struct.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-
-# Struct serialization/deserialization
-class Struct
-
- # Deserializes JSON string by constructing new Struct object with values
- # v serialized by to_json.
- def self.json_create(object)
- new(*object['v'])
- end
-
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
- def as_json(*)
- klass = self.class.name
- klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
- {
- JSON.create_id => klass,
- 'v' => values,
- }
- end
-
- # Stores class name (Struct) with Struct values v as a JSON string.
- # Only named structs are supported.
- def to_json(*args)
- as_json.to_json(*args)
- end
-end
diff --git a/src/main/resources/stdlib/json/add/symbol.rb b/src/main/resources/stdlib/json/add/symbol.rb
deleted file mode 100644
index 03dc9a5..0000000
--- a/src/main/resources/stdlib/json/add/symbol.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-
-# Symbol serialization/deserialization
-class Symbol
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
- def as_json(*)
- {
- JSON.create_id => self.class.name,
- 's' => to_s,
- }
- end
-
- # Stores class name (Symbol) with String representation of Symbol as a JSON string.
- def to_json(*a)
- as_json.to_json(*a)
- end
-
- # Deserializes JSON string by converting the string value stored in the object to a Symbol
- def self.json_create(o)
- o['s'].to_sym
- end
-end
diff --git a/src/main/resources/stdlib/json/add/time.rb b/src/main/resources/stdlib/json/add/time.rb
deleted file mode 100644
index 338209d..0000000
--- a/src/main/resources/stdlib/json/add/time.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
- require 'json'
-end
-
-# Time serialization/deserialization
-class Time
-
- # Deserializes JSON string by converting time since epoch to Time
- def self.json_create(object)
- if usec = object.delete('u') # used to be tv_usec -> tv_nsec
- object['n'] = usec * 1000
- end
- if instance_methods.include?(:tv_nsec)
- at(object['s'], Rational(object['n'], 1000))
- else
- at(object['s'], object['n'] / 1000)
- end
- end
-
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
- def as_json(*)
- nanoseconds = [ tv_usec * 1000 ]
- respond_to?(:tv_nsec) and nanoseconds << tv_nsec
- nanoseconds = nanoseconds.max
- {
- JSON.create_id => self.class.name,
- 's' => tv_sec,
- 'n' => nanoseconds,
- }
- end
-
- # Stores class name (Time) with number of seconds since epoch and number of
- # microseconds for Time as JSON string
- def to_json(*args)
- as_json.to_json(*args)
- end
-end
diff --git a/src/main/resources/stdlib/json/common.rb b/src/main/resources/stdlib/json/common.rb
deleted file mode 100644
index 65a74a1..0000000
--- a/src/main/resources/stdlib/json/common.rb
+++ /dev/null
@@ -1,487 +0,0 @@
-require 'json/version'
-require 'json/generic_object'
-
-module JSON
- class << self
- # If _object_ is string-like, parse the string and return the parsed result
- # as a Ruby data structure. Otherwise generate a JSON text from the Ruby
- # data structure object and return it.
- #
- # The _opts_ argument is passed through to generate/parse respectively. See
- # generate and parse for their documentation.
- def [](object, opts = {})
- if object.respond_to? :to_str
- JSON.parse(object.to_str, opts)
- else
- JSON.generate(object, opts)
- end
- end
-
- # Returns the JSON parser class that is used by JSON. This is either
- # JSON::Ext::Parser or JSON::Pure::Parser.
- attr_reader :parser
-
- # Set the JSON parser class _parser_ to be used by JSON.
- def parser=(parser) # :nodoc:
- @parser = parser
- remove_const :Parser if JSON.const_defined_in?(self, :Parser)
- const_set :Parser, parser
- end
-
- # Return the constant located at _path_. The format of _path_ has to be
- # either ::A::B::C or A::B::C. In any case, A has to be located at the top
- # level (absolute namespace path?). If there doesn't exist a constant at
- # the given path, an ArgumentError is raised.
- def deep_const_get(path) # :nodoc:
- path.to_s.split(/::/).inject(Object) do |p, c|
- case
- when c.empty? then p
- when JSON.const_defined_in?(p, c) then p.const_get(c)
- else
- begin
- p.const_missing(c)
- rescue NameError => e
- raise ArgumentError, "can't get const #{path}: #{e}"
- end
- end
- end
- end
-
- # Set the module _generator_ to be used by JSON.
- def generator=(generator) # :nodoc:
- old, $VERBOSE = $VERBOSE, nil
- @generator = generator
- generator_methods = generator::GeneratorMethods
- for const in generator_methods.constants
- klass = deep_const_get(const)
- modul = generator_methods.const_get(const)
- klass.class_eval do
- instance_methods(false).each do |m|
- m.to_s == 'to_json' and remove_method m
- end
- include modul
- end
- end
- self.state = generator::State
- const_set :State, self.state
- const_set :SAFE_STATE_PROTOTYPE, State.new
- const_set :FAST_STATE_PROTOTYPE, State.new(
- :indent => '',
- :space => '',
- :object_nl => "",
- :array_nl => "",
- :max_nesting => false
- )
- const_set :PRETTY_STATE_PROTOTYPE, State.new(
- :indent => ' ',
- :space => ' ',
- :object_nl => "\n",
- :array_nl => "\n"
- )
- ensure
- $VERBOSE = old
- end
-
- # Returns the JSON generator module that is used by JSON. This is
- # either JSON::Ext::Generator or JSON::Pure::Generator.
- attr_reader :generator
-
- # Returns the JSON generator state class that is used by JSON. This is
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State.
- attr_accessor :state
-
- # This is create identifier, which is used to decide if the _json_create_
- # hook of a class should be called. It defaults to 'json_class'.
- attr_accessor :create_id
- end
- self.create_id = 'json_class'
-
- NaN = 0.0/0
-
- Infinity = 1.0/0
-
- MinusInfinity = -Infinity
-
- # The base exception for JSON errors.
- class JSONError < StandardError
- def self.wrap(exception)
- obj = new("Wrapped(#{exception.class}): #{exception.message.inspect}")
- obj.set_backtrace exception.backtrace
- obj
- end
- end
-
- # This exception is raised if a parser error occurs.
- class ParserError < JSONError; end
-
- # This exception is raised if the nesting of parsed data structures is too
- # deep.
- class NestingError < ParserError; end
-
- # :stopdoc:
- class CircularDatastructure < NestingError; end
- # :startdoc:
-
- # This exception is raised if a generator or unparser error occurs.
- class GeneratorError < JSONError; end
- # For backwards compatibility
- UnparserError = GeneratorError
-
- # This exception is raised if the required unicode support is missing on the
- # system. Usually this means that the iconv library is not installed.
- class MissingUnicodeSupport < JSONError; end
-
- module_function
-
- # Parse the JSON document _source_ into a Ruby data structure and return it.
- #
- # _opts_ can have the following
- # keys:
- # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- # structures. Disable depth checking with :max_nesting => false. It defaults
- # to 100.
- # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
- # defiance of RFC 4627 to be parsed by the Parser. This option defaults
- # to false.
- # * *symbolize_names*: If set to true, returns symbols for the names
- # (keys) in a JSON object. Otherwise strings are returned. Strings are
- # the default.
- # * *create_additions*: If set to false, the Parser doesn't create
- # additions even if a matching class and create_id was found. This option
- # defaults to true.
- # * *object_class*: Defaults to Hash
- # * *array_class*: Defaults to Array
- def parse(source, opts = {})
- Parser.new(source, opts).parse
- end
-
- # Parse the JSON document _source_ into a Ruby data structure and return it.
- # The bang version of the parse method defaults to the more dangerous values
- # for the _opts_ hash, so be sure only to parse trusted _source_ documents.
- #
- # _opts_ can have the following keys:
- # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- # structures. Enable depth checking with :max_nesting => anInteger. The parse!
- # methods defaults to not doing max depth checking: This can be dangerous
- # if someone wants to fill up your stack.
- # * *allow_nan*: If set to true, allow NaN, Infinity, and -Infinity in
- # defiance of RFC 4627 to be parsed by the Parser. This option defaults
- # to true.
- # * *create_additions*: If set to false, the Parser doesn't create
- # additions even if a matching class and create_id was found. This option
- # defaults to true.
- def parse!(source, opts = {})
- opts = {
- :max_nesting => false,
- :allow_nan => true
- }.update(opts)
- Parser.new(source, opts).parse
- end
-
- # Generate a JSON document from the Ruby data structure _obj_ and return
- # it. _state_ is * a JSON::State object,
- # * or a Hash like object (responding to to_hash),
- # * an object convertible into a hash by a to_h method,
- # that is used as or to configure a State object.
- #
- # It defaults to a state object, that creates the shortest possible JSON text
- # in one line, checks for circular data structures and doesn't allow NaN,
- # Infinity, and -Infinity.
- #
- # A _state_ hash can have the following keys:
- # * *indent*: a string used to indent levels (default: ''),
- # * *space*: a string that is put after, a : or , delimiter (default: ''),
- # * *space_before*: a string that is put before a : pair delimiter (default: ''),
- # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
- # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
- # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
- # generated, otherwise an exception is thrown if these values are
- # encountered. This options defaults to false.
- # * *max_nesting*: The maximum depth of nesting allowed in the data
- # structures from which JSON is to be generated. Disable depth checking
- # with :max_nesting => false, it defaults to 100.
- #
- # See also the fast_generate for the fastest creation method with the least
- # amount of sanity checks, and the pretty_generate method for some
- # defaults for pretty output.
- def generate(obj, opts = nil)
- if State === opts
- state, opts = opts, nil
- else
- state = SAFE_STATE_PROTOTYPE.dup
- end
- if opts
- if opts.respond_to? :to_hash
- opts = opts.to_hash
- elsif opts.respond_to? :to_h
- opts = opts.to_h
- else
- raise TypeError, "can't convert #{opts.class} into Hash"
- end
- state = state.configure(opts)
- end
- state.generate(obj)
- end
-
- # :stopdoc:
- # I want to deprecate these later, so I'll first be silent about them, and
- # later delete them.
- alias unparse generate
- module_function :unparse
- # :startdoc:
-
- # Generate a JSON document from the Ruby data structure _obj_ and return it.
- # This method disables the checks for circles in Ruby objects.
- #
- # *WARNING*: Be careful not to pass any Ruby data structures with circles as
- # _obj_ argument because this will cause JSON to go into an infinite loop.
- def fast_generate(obj, opts = nil)
- if State === opts
- state, opts = opts, nil
- else
- state = FAST_STATE_PROTOTYPE.dup
- end
- if opts
- if opts.respond_to? :to_hash
- opts = opts.to_hash
- elsif opts.respond_to? :to_h
- opts = opts.to_h
- else
- raise TypeError, "can't convert #{opts.class} into Hash"
- end
- state.configure(opts)
- end
- state.generate(obj)
- end
-
- # :stopdoc:
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
- alias fast_unparse fast_generate
- module_function :fast_unparse
- # :startdoc:
-
- # Generate a JSON document from the Ruby data structure _obj_ and return it.
- # The returned document is a prettier form of the document returned by
- # #unparse.
- #
- # The _opts_ argument can be used to configure the generator. See the
- # generate method for a more detailed explanation.
- def pretty_generate(obj, opts = nil)
- if State === opts
- state, opts = opts, nil
- else
- state = PRETTY_STATE_PROTOTYPE.dup
- end
- if opts
- if opts.respond_to? :to_hash
- opts = opts.to_hash
- elsif opts.respond_to? :to_h
- opts = opts.to_h
- else
- raise TypeError, "can't convert #{opts.class} into Hash"
- end
- state.configure(opts)
- end
- state.generate(obj)
- end
-
- # :stopdoc:
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
- alias pretty_unparse pretty_generate
- module_function :pretty_unparse
- # :startdoc:
-
- class << self
- # The global default options for the JSON.load method:
- # :max_nesting: false
- # :allow_nan: true
- # :quirks_mode: true
- attr_accessor :load_default_options
- end
- self.load_default_options = {
- :max_nesting => false,
- :allow_nan => true,
- :quirks_mode => true,
- :create_additions => true,
- }
-
- # Load a ruby data structure from a JSON _source_ and return it. A source can
- # either be a string-like object, an IO-like object, or an object responding
- # to the read method. If _proc_ was given, it will be called with any nested
- # Ruby object as an argument recursively in depth first order. To modify the
- # default options pass in the optional _options_ argument as well.
- #
- # BEWARE: This method is meant to serialise data from trusted user input,
- # like from your own database server or clients under your control, it could
- # be dangerous to allow untrusted users to pass JSON sources into it. The
- # default options for the parser can be changed via the load_default_options
- # method.
- #
- # This method is part of the implementation of the load/dump interface of
- # Marshal and YAML.
- def load(source, proc = nil, options = {})
- opts = load_default_options.merge options
- if source.respond_to? :to_str
- source = source.to_str
- elsif source.respond_to? :to_io
- source = source.to_io.read
- elsif source.respond_to?(:read)
- source = source.read
- end
- if opts[:quirks_mode] && (source.nil? || source.empty?)
- source = 'null'
- end
- result = parse(source, opts)
- recurse_proc(result, &proc) if proc
- result
- end
-
- # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
- def recurse_proc(result, &proc)
- case result
- when Array
- result.each { |x| recurse_proc x, &proc }
- proc.call result
- when Hash
- result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc }
- proc.call result
- else
- proc.call result
- end
- end
-
- alias restore load
- module_function :restore
-
- class << self
- # The global default options for the JSON.dump method:
- # :max_nesting: false
- # :allow_nan: true
- # :quirks_mode: true
- attr_accessor :dump_default_options
- end
- self.dump_default_options = {
- :max_nesting => false,
- :allow_nan => true,
- :quirks_mode => true,
- }
-
- # Dumps _obj_ as a JSON string, i.e. calls generate on the object and returns
- # the result.
- #
- # If anIO (an IO-like object or an object that responds to the write method)
- # was given, the resulting JSON is written to it.
- #
- # If the number of nested arrays or objects exceeds _limit_, an ArgumentError
- # exception is raised. This argument is similar (but not exactly the
- # same!) to the _limit_ argument in Marshal.dump.
- #
- # The default options for the generator can be changed via the
- # dump_default_options method.
- #
- # This method is part of the implementation of the load/dump interface of
- # Marshal and YAML.
- def dump(obj, anIO = nil, limit = nil)
- if anIO and limit.nil?
- anIO = anIO.to_io if anIO.respond_to?(:to_io)
- unless anIO.respond_to?(:write)
- limit = anIO
- anIO = nil
- end
- end
- opts = JSON.dump_default_options
- limit and opts.update(:max_nesting => limit)
- result = generate(obj, opts)
- if anIO
- anIO.write result
- anIO
- else
- result
- end
- rescue JSON::NestingError
- raise ArgumentError, "exceed depth limit"
- end
-
- # Swap consecutive bytes of _string_ in place.
- def self.swap!(string) # :nodoc:
- 0.upto(string.size / 2) do |i|
- break unless string[2 * i + 1]
- string[2 * i], string[2 * i + 1] = string[2 * i + 1], string[2 * i]
- end
- string
- end
-
- # Shortuct for iconv.
- if ::String.method_defined?(:encode) &&
- # XXX Rubinius doesn't support ruby 1.9 encoding yet
- defined?(RUBY_ENGINE) && RUBY_ENGINE != 'rbx'
- then
- # Encodes string using Ruby's _String.encode_
- def self.iconv(to, from, string)
- string.encode(to, from)
- end
- else
- require 'iconv'
- # Encodes string using _iconv_ library
- def self.iconv(to, from, string)
- Iconv.conv(to, from, string)
- end
- end
-
- if ::Object.method(:const_defined?).arity == 1
- def self.const_defined_in?(modul, constant)
- modul.const_defined?(constant)
- end
- else
- def self.const_defined_in?(modul, constant)
- modul.const_defined?(constant, false)
- end
- end
-end
-
-module ::Kernel
- private
-
- # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
- # one line.
- def j(*objs)
- objs.each do |obj|
- puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
- end
- nil
- end
-
- # Ouputs _objs_ to STDOUT as JSON strings in a pretty format, with
- # indentation and over many lines.
- def jj(*objs)
- objs.each do |obj|
- puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
- end
- nil
- end
-
- # If _object_ is string-like, parse the string and return the parsed result as
- # a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
- # structure object and return it.
- #
- # The _opts_ argument is passed through to generate/parse respectively. See
- # generate and parse for their documentation.
- def JSON(object, *args)
- if object.respond_to? :to_str
- JSON.parse(object.to_str, args.first)
- else
- JSON.generate(object, args.first)
- end
- end
-end
-
-# Extends any Class to include _json_creatable?_ method.
-class ::Class
- # Returns true if this class can be used to create an instance
- # from a serialised JSON string. The class has to implement a class
- # method _json_create_ that expects a hash as first parameter. The hash
- # should include the required data.
- def json_creatable?
- respond_to?(:json_create)
- end
-end
diff --git a/src/main/resources/stdlib/json/ext.rb b/src/main/resources/stdlib/json/ext.rb
deleted file mode 100644
index c5f8131..0000000
--- a/src/main/resources/stdlib/json/ext.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-if ENV['SIMPLECOV_COVERAGE'].to_i == 1
- require 'simplecov'
- SimpleCov.start do
- add_filter "/tests/"
- end
-end
-require 'json/common'
-
-module JSON
- # This module holds all the modules/classes that implement JSON's
- # functionality as C extensions.
- module Ext
- require 'json/ext/parser'
- require 'json/ext/generator'
- $DEBUG and warn "Using Ext extension for JSON."
- JSON.parser = Parser
- JSON.generator = Generator
- end
-
- JSON_LOADED = true unless defined?(::JSON::JSON_LOADED)
-end
diff --git a/src/main/resources/stdlib/json/ext/generator.jar b/src/main/resources/stdlib/json/ext/generator.jar
deleted file mode 100644
index 4109442..0000000
Binary files a/src/main/resources/stdlib/json/ext/generator.jar and /dev/null differ
diff --git a/src/main/resources/stdlib/json/ext/parser.jar b/src/main/resources/stdlib/json/ext/parser.jar
deleted file mode 100644
index d954fd8..0000000
Binary files a/src/main/resources/stdlib/json/ext/parser.jar and /dev/null differ
diff --git a/src/main/resources/stdlib/json/generic_object.rb b/src/main/resources/stdlib/json/generic_object.rb
deleted file mode 100644
index 8b8fd53..0000000
--- a/src/main/resources/stdlib/json/generic_object.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-require 'ostruct'
-
-module JSON
- class GenericObject < OpenStruct
- class << self
- alias [] new
-
- def json_creatable?
- @json_creatable
- end
-
- attr_writer :json_creatable
-
- def json_create(data)
- data = data.dup
- data.delete JSON.create_id
- self[data]
- end
-
- def from_hash(object)
- case
- when object.respond_to?(:to_hash)
- result = new
- object.to_hash.each do |key, value|
- result[key] = from_hash(value)
- end
- result
- when object.respond_to?(:to_ary)
- object.to_ary.map { |a| from_hash(a) }
- else
- object
- end
- end
-
- def load(source, proc = nil, opts = {})
- result = ::JSON.load(source, proc, opts.merge(:object_class => self))
- result.nil? ? new : result
- end
-
- def dump(obj, *args)
- ::JSON.dump(obj, *args)
- end
- end
- self.json_creatable = false
-
- def to_hash
- table
- end
-
- def [](name)
- table[name.to_sym]
- end
-
- def []=(name, value)
- __send__ "#{name}=", value
- end
-
- def |(other)
- self.class[other.to_hash.merge(to_hash)]
- end
-
- def as_json(*)
- { JSON.create_id => self.class.name }.merge to_hash
- end
-
- def to_json(*a)
- as_json.to_json(*a)
- end
- end
-end
diff --git a/src/main/resources/stdlib/json/pure.rb b/src/main/resources/stdlib/json/pure.rb
deleted file mode 100644
index b68668b..0000000
--- a/src/main/resources/stdlib/json/pure.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-if ENV['SIMPLECOV_COVERAGE'].to_i == 1
- require 'simplecov'
- SimpleCov.start do
- add_filter "/tests/"
- end
-end
-require 'json/common'
-require 'json/pure/parser'
-require 'json/pure/generator'
-
-module JSON
- # This module holds all the modules/classes that implement JSON's
- # functionality in pure ruby.
- module Pure
- $DEBUG and warn "Using Pure library for JSON."
- JSON.parser = Parser
- JSON.generator = Generator
- end
-
- JSON_LOADED = true unless defined?(::JSON::JSON_LOADED)
-end
diff --git a/src/main/resources/stdlib/json/pure/generator.rb b/src/main/resources/stdlib/json/pure/generator.rb
deleted file mode 100644
index 9056a5d..0000000
--- a/src/main/resources/stdlib/json/pure/generator.rb
+++ /dev/null
@@ -1,522 +0,0 @@
-module JSON
- MAP = {
- "\x0" => '\u0000',
- "\x1" => '\u0001',
- "\x2" => '\u0002',
- "\x3" => '\u0003',
- "\x4" => '\u0004',
- "\x5" => '\u0005',
- "\x6" => '\u0006',
- "\x7" => '\u0007',
- "\b" => '\b',
- "\t" => '\t',
- "\n" => '\n',
- "\xb" => '\u000b',
- "\f" => '\f',
- "\r" => '\r',
- "\xe" => '\u000e',
- "\xf" => '\u000f',
- "\x10" => '\u0010',
- "\x11" => '\u0011',
- "\x12" => '\u0012',
- "\x13" => '\u0013',
- "\x14" => '\u0014',
- "\x15" => '\u0015',
- "\x16" => '\u0016',
- "\x17" => '\u0017',
- "\x18" => '\u0018',
- "\x19" => '\u0019',
- "\x1a" => '\u001a',
- "\x1b" => '\u001b',
- "\x1c" => '\u001c',
- "\x1d" => '\u001d',
- "\x1e" => '\u001e',
- "\x1f" => '\u001f',
- '"' => '\"',
- '\\' => '\\\\',
- } # :nodoc:
-
- # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
- # UTF16 big endian characters as \u????, and return it.
- if defined?(::Encoding)
- def utf8_to_json(string) # :nodoc:
- string = string.dup
- string.force_encoding(::Encoding::ASCII_8BIT)
- string.gsub!(/["\\\x0-\x1f]/) { MAP[$&] }
- string.force_encoding(::Encoding::UTF_8)
- string
- end
-
- def utf8_to_json_ascii(string) # :nodoc:
- string = string.dup
- string.force_encoding(::Encoding::ASCII_8BIT)
- string.gsub!(/["\\\x0-\x1f]/n) { MAP[$&] }
- string.gsub!(/(
- (?:
- [\xc2-\xdf][\x80-\xbf] |
- [\xe0-\xef][\x80-\xbf]{2} |
- [\xf0-\xf4][\x80-\xbf]{3}
- )+ |
- [\x80-\xc1\xf5-\xff] # invalid
- )/nx) { |c|
- c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
- s = JSON.iconv('utf-16be', 'utf-8', c).unpack('H*')[0]
- s.force_encoding(::Encoding::ASCII_8BIT)
- s.gsub!(/.{4}/n, '\\\\u\&')
- s.force_encoding(::Encoding::UTF_8)
- }
- string.force_encoding(::Encoding::UTF_8)
- string
- rescue => e
- raise GeneratorError.wrap(e)
- end
-
- def valid_utf8?(string)
- encoding = string.encoding
- (encoding == Encoding::UTF_8 || encoding == Encoding::ASCII) &&
- string.valid_encoding?
- end
- module_function :valid_utf8?
- else
- def utf8_to_json(string) # :nodoc:
- string.gsub(/["\\\x0-\x1f]/n) { MAP[$&] }
- end
-
- def utf8_to_json_ascii(string) # :nodoc:
- string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] }
- string.gsub!(/(
- (?:
- [\xc2-\xdf][\x80-\xbf] |
- [\xe0-\xef][\x80-\xbf]{2} |
- [\xf0-\xf4][\x80-\xbf]{3}
- )+ |
- [\x80-\xc1\xf5-\xff] # invalid
- )/nx) { |c|
- c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
- s = JSON.iconv('utf-16be', 'utf-8', c).unpack('H*')[0]
- s.gsub!(/.{4}/n, '\\\\u\&')
- }
- string
- rescue => e
- raise GeneratorError.wrap(e)
- end
-
- def valid_utf8?(string)
- string =~
- /\A( [\x09\x0a\x0d\x20-\x7e] # ASCII
- | [\xc2-\xdf][\x80-\xbf] # non-overlong 2-byte
- | \xe0[\xa0-\xbf][\x80-\xbf] # excluding overlongs
- | [\xe1-\xec\xee\xef][\x80-\xbf]{2} # straight 3-byte
- | \xed[\x80-\x9f][\x80-\xbf] # excluding surrogates
- | \xf0[\x90-\xbf][\x80-\xbf]{2} # planes 1-3
- | [\xf1-\xf3][\x80-\xbf]{3} # planes 4-15
- | \xf4[\x80-\x8f][\x80-\xbf]{2} # plane 16
- )*\z/nx
- end
- end
- module_function :utf8_to_json, :utf8_to_json_ascii, :valid_utf8?
-
-
- module Pure
- module Generator
- # This class is used to create State instances, that are use to hold data
- # while generating a JSON text from a Ruby data structure.
- class State
- # Creates a State object from _opts_, which ought to be Hash to create
- # a new State instance configured by _opts_, something else to create
- # an unconfigured instance. If _opts_ is a State object, it is just
- # returned.
- def self.from_state(opts)
- case
- when self === opts
- opts
- when opts.respond_to?(:to_hash)
- new(opts.to_hash)
- when opts.respond_to?(:to_h)
- new(opts.to_h)
- else
- SAFE_STATE_PROTOTYPE.dup
- end
- end
-
- # Instantiates a new State object, configured by _opts_.
- #
- # _opts_ can have the following keys:
- #
- # * *indent*: a string used to indent levels (default: ''),
- # * *space*: a string that is put after, a : or , delimiter (default: ''),
- # * *space_before*: a string that is put before a : pair delimiter (default: ''),
- # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
- # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
- # * *check_circular*: is deprecated now, use the :max_nesting option instead,
- # * *max_nesting*: sets the maximum level of data structure nesting in
- # the generated JSON, max_nesting = 0 if no maximum should be checked.
- # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
- # generated, otherwise an exception is thrown, if these values are
- # encountered. This options defaults to false.
- # * *quirks_mode*: Enables quirks_mode for parser, that is for example
- # generating single JSON values instead of documents is possible.
- def initialize(opts = {})
- @indent = ''
- @space = ''
- @space_before = ''
- @object_nl = ''
- @array_nl = ''
- @allow_nan = false
- @ascii_only = false
- @quirks_mode = false
- @buffer_initial_length = 1024
- configure opts
- end
-
- # This string is used to indent levels in the JSON text.
- attr_accessor :indent
-
- # This string is used to insert a space between the tokens in a JSON
- # string.
- attr_accessor :space
-
- # This string is used to insert a space before the ':' in JSON objects.
- attr_accessor :space_before
-
- # This string is put at the end of a line that holds a JSON object (or
- # Hash).
- attr_accessor :object_nl
-
- # This string is put at the end of a line that holds a JSON array.
- attr_accessor :array_nl
-
- # This integer returns the maximum level of data structure nesting in
- # the generated JSON, max_nesting = 0 if no maximum is checked.
- attr_accessor :max_nesting
-
- # If this attribute is set to true, quirks mode is enabled, otherwise
- # it's disabled.
- attr_accessor :quirks_mode
-
- # :stopdoc:
- attr_reader :buffer_initial_length
-
- def buffer_initial_length=(length)
- if length > 0
- @buffer_initial_length = length
- end
- end
- # :startdoc:
-
- # This integer returns the current depth data structure nesting in the
- # generated JSON.
- attr_accessor :depth
-
- def check_max_nesting # :nodoc:
- return if @max_nesting.zero?
- current_nesting = depth + 1
- current_nesting > @max_nesting and
- raise NestingError, "nesting of #{current_nesting} is too deep"
- end
-
- # Returns true, if circular data structures are checked,
- # otherwise returns false.
- def check_circular?
- !@max_nesting.zero?
- end
-
- # Returns true if NaN, Infinity, and -Infinity should be considered as
- # valid JSON and output.
- def allow_nan?
- @allow_nan
- end
-
- # Returns true, if only ASCII characters should be generated. Otherwise
- # returns false.
- def ascii_only?
- @ascii_only
- end
-
- # Returns true, if quirks mode is enabled. Otherwise returns false.
- def quirks_mode?
- @quirks_mode
- end
-
- # Configure this State instance with the Hash _opts_, and return
- # itself.
- def configure(opts)
- if opts.respond_to?(:to_hash)
- opts = opts.to_hash
- elsif opts.respond_to?(:to_h)
- opts = opts.to_h
- else
- raise TypeError, "can't convert #{opts.class} into Hash"
- end
- for key, value in opts
- instance_variable_set "@#{key}", value
- end
- @indent = opts[:indent] if opts.key?(:indent)
- @space = opts[:space] if opts.key?(:space)
- @space_before = opts[:space_before] if opts.key?(:space_before)
- @object_nl = opts[:object_nl] if opts.key?(:object_nl)
- @array_nl = opts[:array_nl] if opts.key?(:array_nl)
- @allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
- @ascii_only = opts[:ascii_only] if opts.key?(:ascii_only)
- @depth = opts[:depth] || 0
- @quirks_mode = opts[:quirks_mode] if opts.key?(:quirks_mode)
- @buffer_initial_length ||= opts[:buffer_initial_length]
-
- if !opts.key?(:max_nesting) # defaults to 100
- @max_nesting = 100
- elsif opts[:max_nesting]
- @max_nesting = opts[:max_nesting]
- else
- @max_nesting = 0
- end
- self
- end
- alias merge configure
-
- # Returns the configuration instance variables as a hash, that can be
- # passed to the configure method.
- def to_h
- result = {}
- for iv in instance_variables
- iv = iv.to_s[1..-1]
- result[iv.to_sym] = self[iv]
- end
- result
- end
-
- alias to_hash to_h
-
- # Generates a valid JSON document from object +obj+ and returns the
- # result. If no valid JSON document can be created this method raises a
- # GeneratorError exception.
- def generate(obj)
- result = obj.to_json(self)
- JSON.valid_utf8?(result) or raise GeneratorError,
- "source sequence #{result.inspect} is illegal/malformed utf-8"
- unless @quirks_mode
- unless result =~ /\A\s*\[/ && result =~ /\]\s*\Z/ ||
- result =~ /\A\s*\{/ && result =~ /\}\s*\Z/
- then
- raise GeneratorError, "only generation of JSON objects or arrays allowed"
- end
- end
- result
- end
-
- # Return the value returned by method +name+.
- def [](name)
- if respond_to?(name)
- __send__(name)
- else
- instance_variable_get("@#{name}")
- end
- end
-
- def []=(name, value)
- if respond_to?(name_writer = "#{name}=")
- __send__ name_writer, value
- else
- instance_variable_set "@#{name}", value
- end
- end
- end
-
- module GeneratorMethods
- module Object
- # Converts this object to a string (calling #to_s), converts
- # it to a JSON string, and returns the result. This is a fallback, if no
- # special method #to_json was defined for some object.
- def to_json(*) to_s.to_json end
- end
-
- module Hash
- # Returns a JSON string containing a JSON object, that is unparsed from
- # this Hash instance.
- # _state_ is a JSON::State object, that can also be used to configure the
- # produced JSON string output further.
- # _depth_ is used to find out nesting depth, to indent accordingly.
- def to_json(state = nil, *)
- state = State.from_state(state)
- state.check_max_nesting
- json_transform(state)
- end
-
- private
-
- def json_shift(state)
- state.object_nl.empty? or return ''
- state.indent * state.depth
- end
-
- def json_transform(state)
- delim = ','
- delim << state.object_nl
- result = '{'
- result << state.object_nl
- depth = state.depth += 1
- first = true
- indent = !state.object_nl.empty?
- each { |key,value|
- result << delim unless first
- result << state.indent * depth if indent
- result << key.to_s.to_json(state)
- result << state.space_before
- result << ':'
- result << state.space
- result << value.to_json(state)
- first = false
- }
- depth = state.depth -= 1
- result << state.object_nl
- result << state.indent * depth if indent
- result << '}'
- result
- end
- end
-
- module Array
- # Returns a JSON string containing a JSON array, that is unparsed from
- # this Array instance.
- # _state_ is a JSON::State object, that can also be used to configure the
- # produced JSON string output further.
- def to_json(state = nil, *)
- state = State.from_state(state)
- state.check_max_nesting
- json_transform(state)
- end
-
- private
-
- def json_transform(state)
- delim = ','
- delim << state.array_nl
- result = '['
- result << state.array_nl
- depth = state.depth += 1
- first = true
- indent = !state.array_nl.empty?
- each { |value|
- result << delim unless first
- result << state.indent * depth if indent
- result << value.to_json(state)
- first = false
- }
- depth = state.depth -= 1
- result << state.array_nl
- result << state.indent * depth if indent
- result << ']'
- end
- end
-
- module Integer
- # Returns a JSON string representation for this Integer number.
- def to_json(*) to_s end
- end
-
- module Float
- # Returns a JSON string representation for this Float number.
- def to_json(state = nil, *)
- state = State.from_state(state)
- case
- when infinite?
- if state.allow_nan?
- to_s
- else
- raise GeneratorError, "#{self} not allowed in JSON"
- end
- when nan?
- if state.allow_nan?
- to_s
- else
- raise GeneratorError, "#{self} not allowed in JSON"
- end
- else
- to_s
- end
- end
- end
-
- module String
- if defined?(::Encoding)
- # This string should be encoded with UTF-8 A call to this method
- # returns a JSON string encoded with UTF16 big endian characters as
- # \u????.
- def to_json(state = nil, *args)
- state = State.from_state(state)
- if encoding == ::Encoding::UTF_8
- string = self
- else
- string = encode(::Encoding::UTF_8)
- end
- if state.ascii_only?
- '"' << JSON.utf8_to_json_ascii(string) << '"'
- else
- '"' << JSON.utf8_to_json(string) << '"'
- end
- end
- else
- # This string should be encoded with UTF-8 A call to this method
- # returns a JSON string encoded with UTF16 big endian characters as
- # \u????.
- def to_json(state = nil, *args)
- state = State.from_state(state)
- if state.ascii_only?
- '"' << JSON.utf8_to_json_ascii(self) << '"'
- else
- '"' << JSON.utf8_to_json(self) << '"'
- end
- end
- end
-
- # Module that holds the extinding methods if, the String module is
- # included.
- module Extend
- # Raw Strings are JSON Objects (the raw bytes are stored in an
- # array for the key "raw"). The Ruby String can be created by this
- # module method.
- def json_create(o)
- o['raw'].pack('C*')
- end
- end
-
- # Extends _modul_ with the String::Extend module.
- def self.included(modul)
- modul.extend Extend
- end
-
- # This method creates a raw object hash, that can be nested into
- # other data structures and will be unparsed as a raw string. This
- # method should be used, if you want to convert raw strings to JSON
- # instead of UTF-8 strings, e. g. binary data.
- def to_json_raw_object
- {
- JSON.create_id => self.class.name,
- 'raw' => self.unpack('C*'),
- }
- end
-
- # This method creates a JSON text from the result of
- # a call to to_json_raw_object of this String.
- def to_json_raw(*args)
- to_json_raw_object.to_json(*args)
- end
- end
-
- module TrueClass
- # Returns a JSON string for true: 'true'.
- def to_json(*) 'true' end
- end
-
- module FalseClass
- # Returns a JSON string for false: 'false'.
- def to_json(*) 'false' end
- end
-
- module NilClass
- # Returns a JSON string for nil: 'null'.
- def to_json(*) 'null' end
- end
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/json/pure/parser.rb b/src/main/resources/stdlib/json/pure/parser.rb
deleted file mode 100644
index a41d1ee..0000000
--- a/src/main/resources/stdlib/json/pure/parser.rb
+++ /dev/null
@@ -1,359 +0,0 @@
-require 'strscan'
-
-module JSON
- module Pure
- # This class implements the JSON parser that is used to parse a JSON string
- # into a Ruby data structure.
- class Parser < StringScanner
- STRING = /" ((?:[^\x0-\x1f"\\] |
- # escaped special characters:
- \\["\\\/bfnrt] |
- \\u[0-9a-fA-F]{4} |
- # match all but escaped special characters:
- \\[\x20-\x21\x23-\x2e\x30-\x5b\x5d-\x61\x63-\x65\x67-\x6d\x6f-\x71\x73\x75-\xff])*)
- "/nx
- INTEGER = /(-?0|-?[1-9]\d*)/
- FLOAT = /(-?
- (?:0|[1-9]\d*)
- (?:
- \.\d+(?i:e[+-]?\d+) |
- \.\d+ |
- (?i:e[+-]?\d+)
- )
- )/x
- NAN = /NaN/
- INFINITY = /Infinity/
- MINUS_INFINITY = /-Infinity/
- OBJECT_OPEN = /\{/
- OBJECT_CLOSE = /\}/
- ARRAY_OPEN = /\[/
- ARRAY_CLOSE = /\]/
- PAIR_DELIMITER = /:/
- COLLECTION_DELIMITER = /,/
- TRUE = /true/
- FALSE = /false/
- NULL = /null/
- IGNORE = %r(
- (?:
- //[^\n\r]*[\n\r]| # line comments
- /\* # c-style comments
- (?:
- [^*/]| # normal chars
- /[^*]| # slashes that do not start a nested comment
- \*[^/]| # asterisks that do not end this comment
- /(?=\*/) # single slash before this comment's end
- )*
- \*/ # the End of this comment
- |[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr
- )+
- )mx
-
- UNPARSED = Object.new
-
- # Creates a new JSON::Pure::Parser instance for the string _source_.
- #
- # It will be configured by the _opts_ hash. _opts_ can have the following
- # keys:
- # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- # structures. Disable depth checking with :max_nesting => false|nil|0,
- # it defaults to 100.
- # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
- # defiance of RFC 4627 to be parsed by the Parser. This option defaults
- # to false.
- # * *symbolize_names*: If set to true, returns symbols for the names
- # (keys) in a JSON object. Otherwise strings are returned, which is also
- # the default.
- # * *create_additions*: If set to true, the Parser creates
- # additions when if a matching class and create_id was found. This
- # option defaults to false.
- # * *object_class*: Defaults to Hash
- # * *array_class*: Defaults to Array
- # * *quirks_mode*: Enables quirks_mode for parser, that is for example
- # parsing single JSON values instead of documents is possible.
- def initialize(source, opts = {})
- opts ||= {}
- unless @quirks_mode = opts[:quirks_mode]
- source = convert_encoding source
- end
- super source
- if !opts.key?(:max_nesting) # defaults to 100
- @max_nesting = 100
- elsif opts[:max_nesting]
- @max_nesting = opts[:max_nesting]
- else
- @max_nesting = 0
- end
- @allow_nan = !!opts[:allow_nan]
- @symbolize_names = !!opts[:symbolize_names]
- if opts.key?(:create_additions)
- @create_additions = !!opts[:create_additions]
- else
- @create_additions = false
- end
- @create_id = @create_additions ? JSON.create_id : nil
- @object_class = opts[:object_class] || Hash
- @array_class = opts[:array_class] || Array
- @match_string = opts[:match_string]
- end
-
- alias source string
-
- def quirks_mode?
- !!@quirks_mode
- end
-
- def reset
- super
- @current_nesting = 0
- end
-
- # Parses the current JSON string _source_ and returns the complete data
- # structure as a result.
- def parse
- reset
- obj = nil
- if @quirks_mode
- while !eos? && skip(IGNORE)
- end
- if eos?
- raise ParserError, "source did not contain any JSON!"
- else
- obj = parse_value
- obj == UNPARSED and raise ParserError, "source did not contain any JSON!"
- end
- else
- until eos?
- case
- when scan(OBJECT_OPEN)
- obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
- @current_nesting = 1
- obj = parse_object
- when scan(ARRAY_OPEN)
- obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
- @current_nesting = 1
- obj = parse_array
- when skip(IGNORE)
- ;
- else
- raise ParserError, "source '#{peek(20)}' not in JSON!"
- end
- end
- obj or raise ParserError, "source did not contain any JSON!"
- end
- obj
- end
-
- private
-
- def convert_encoding(source)
- if source.respond_to?(:to_str)
- source = source.to_str
- else
- raise TypeError, "#{source.inspect} is not like a string"
- end
- if defined?(::Encoding)
- if source.encoding == ::Encoding::ASCII_8BIT
- b = source[0, 4].bytes.to_a
- source =
- case
- when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
- source.dup.force_encoding(::Encoding::UTF_32BE).encode!(::Encoding::UTF_8)
- when b.size >= 4 && b[0] == 0 && b[2] == 0
- source.dup.force_encoding(::Encoding::UTF_16BE).encode!(::Encoding::UTF_8)
- when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
- source.dup.force_encoding(::Encoding::UTF_32LE).encode!(::Encoding::UTF_8)
- when b.size >= 4 && b[1] == 0 && b[3] == 0
- source.dup.force_encoding(::Encoding::UTF_16LE).encode!(::Encoding::UTF_8)
- else
- source.dup
- end
- else
- source = source.encode(::Encoding::UTF_8)
- end
- source.force_encoding(::Encoding::ASCII_8BIT)
- else
- b = source
- source =
- case
- when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
- JSON.iconv('utf-8', 'utf-32be', b)
- when b.size >= 4 && b[0] == 0 && b[2] == 0
- JSON.iconv('utf-8', 'utf-16be', b)
- when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
- JSON.iconv('utf-8', 'utf-32le', b)
- when b.size >= 4 && b[1] == 0 && b[3] == 0
- JSON.iconv('utf-8', 'utf-16le', b)
- else
- b
- end
- end
- source
- end
-
- # Unescape characters in strings.
- UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
- UNESCAPE_MAP.update({
- ?" => '"',
- ?\\ => '\\',
- ?/ => '/',
- ?b => "\b",
- ?f => "\f",
- ?n => "\n",
- ?r => "\r",
- ?t => "\t",
- ?u => nil,
- })
-
- EMPTY_8BIT_STRING = ''
- if ::String.method_defined?(:encode)
- EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT
- end
-
- def parse_string
- if scan(STRING)
- return '' if self[1].empty?
- string = self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
- if u = UNESCAPE_MAP[$&[1]]
- u
- else # \uXXXX
- bytes = EMPTY_8BIT_STRING.dup
- i = 0
- while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
- bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
- i += 1
- end
- JSON.iconv('utf-8', 'utf-16be', bytes)
- end
- end
- if string.respond_to?(:force_encoding)
- string.force_encoding(::Encoding::UTF_8)
- end
- if @create_additions and @match_string
- for (regexp, klass) in @match_string
- klass.json_creatable? or next
- string =~ regexp and return klass.json_create(string)
- end
- end
- string
- else
- UNPARSED
- end
- rescue => e
- raise ParserError, "Caught #{e.class} at '#{peek(20)}': #{e}"
- end
-
- def parse_value
- case
- when scan(FLOAT)
- Float(self[1])
- when scan(INTEGER)
- Integer(self[1])
- when scan(TRUE)
- true
- when scan(FALSE)
- false
- when scan(NULL)
- nil
- when (string = parse_string) != UNPARSED
- string
- when scan(ARRAY_OPEN)
- @current_nesting += 1
- ary = parse_array
- @current_nesting -= 1
- ary
- when scan(OBJECT_OPEN)
- @current_nesting += 1
- obj = parse_object
- @current_nesting -= 1
- obj
- when @allow_nan && scan(NAN)
- NaN
- when @allow_nan && scan(INFINITY)
- Infinity
- when @allow_nan && scan(MINUS_INFINITY)
- MinusInfinity
- else
- UNPARSED
- end
- end
-
- def parse_array
- raise NestingError, "nesting of #@current_nesting is too deep" if
- @max_nesting.nonzero? && @current_nesting > @max_nesting
- result = @array_class.new
- delim = false
- until eos?
- case
- when (value = parse_value) != UNPARSED
- delim = false
- result << value
- skip(IGNORE)
- if scan(COLLECTION_DELIMITER)
- delim = true
- elsif match?(ARRAY_CLOSE)
- ;
- else
- raise ParserError, "expected ',' or ']' in array at '#{peek(20)}'!"
- end
- when scan(ARRAY_CLOSE)
- if delim
- raise ParserError, "expected next element in array at '#{peek(20)}'!"
- end
- break
- when skip(IGNORE)
- ;
- else
- raise ParserError, "unexpected token in array at '#{peek(20)}'!"
- end
- end
- result
- end
-
- def parse_object
- raise NestingError, "nesting of #@current_nesting is too deep" if
- @max_nesting.nonzero? && @current_nesting > @max_nesting
- result = @object_class.new
- delim = false
- until eos?
- case
- when (string = parse_string) != UNPARSED
- skip(IGNORE)
- unless scan(PAIR_DELIMITER)
- raise ParserError, "expected ':' in object at '#{peek(20)}'!"
- end
- skip(IGNORE)
- unless (value = parse_value).equal? UNPARSED
- result[@symbolize_names ? string.to_sym : string] = value
- delim = false
- skip(IGNORE)
- if scan(COLLECTION_DELIMITER)
- delim = true
- elsif match?(OBJECT_CLOSE)
- ;
- else
- raise ParserError, "expected ',' or '}' in object at '#{peek(20)}'!"
- end
- else
- raise ParserError, "expected value in object at '#{peek(20)}'!"
- end
- when scan(OBJECT_CLOSE)
- if delim
- raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!"
- end
- if @create_additions and klassname = result[@create_id]
- klass = JSON.deep_const_get klassname
- break unless klass and klass.json_creatable?
- result = klass.json_create(result)
- end
- break
- when skip(IGNORE)
- ;
- else
- raise ParserError, "unexpected token in object at '#{peek(20)}'!"
- end
- end
- result
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/json/version.rb b/src/main/resources/stdlib/json/version.rb
deleted file mode 100644
index 9354845..0000000
--- a/src/main/resources/stdlib/json/version.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-module JSON
- # JSON version
- VERSION = '1.8.0'
- VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
- VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
- VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
- VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
-end
diff --git a/src/main/resources/stdlib/kconv.rb b/src/main/resources/stdlib/kconv.rb
deleted file mode 100644
index f8c1ae8..0000000
--- a/src/main/resources/stdlib/kconv.rb
+++ /dev/null
@@ -1,282 +0,0 @@
-#
-# kconv.rb - Kanji Converter.
-#
-# $Id$
-#
-# ----
-#
-# kconv.rb implements the Kconv class for Kanji Converter. Additionally,
-# some methods in String classes are added to allow easy conversion.
-#
-
-require 'nkf'
-
-#
-# Kanji Converter for Ruby.
-#
-module Kconv
- #
- # Public Constants
- #
-
- #Constant of Encoding
-
- # Auto-Detect
- AUTO = NKF::AUTO
- # ISO-2022-JP
- JIS = NKF::JIS
- # EUC-JP
- EUC = NKF::EUC
- # Shift_JIS
- SJIS = NKF::SJIS
- # BINARY
- BINARY = NKF::BINARY
- # NOCONV
- NOCONV = NKF::NOCONV
- # ASCII
- ASCII = NKF::ASCII
- # UTF-8
- UTF8 = NKF::UTF8
- # UTF-16
- UTF16 = NKF::UTF16
- # UTF-32
- UTF32 = NKF::UTF32
- # UNKNOWN
- UNKNOWN = NKF::UNKNOWN
-
- #
- # Public Methods
- #
-
- # call-seq:
- # Kconv.kconv(str, to_enc, from_enc=nil)
- #
- # Convert str to to_enc.
- # to_enc and from_enc are given as constants of Kconv or Encoding objects.
- def kconv(str, to_enc, from_enc=nil)
- opt = ''
- opt += ' --ic=' + from_enc.to_s if from_enc
- opt += ' --oc=' + to_enc.to_s if to_enc
-
- ::NKF::nkf(opt, str)
- end
- module_function :kconv
-
- #
- # Encode to
- #
-
- # call-seq:
- # Kconv.tojis(str) => string
- #
- # Convert str to ISO-2022-JP
- def tojis(str)
- kconv(str, JIS)
- end
- module_function :tojis
-
- # call-seq:
- # Kconv.toeuc(str) => string
- #
- # Convert str to EUC-JP
- def toeuc(str)
- kconv(str, EUC)
- end
- module_function :toeuc
-
- # call-seq:
- # Kconv.tosjis(str) => string
- #
- # Convert str to Shift_JIS
- def tosjis(str)
- kconv(str, SJIS)
- end
- module_function :tosjis
-
- # call-seq:
- # Kconv.toutf8(str) => string
- #
- # Convert str to UTF-8
- def toutf8(str)
- kconv(str, UTF8)
- end
- module_function :toutf8
-
- # call-seq:
- # Kconv.toutf16(str) => string
- #
- # Convert str to UTF-16
- def toutf16(str)
- kconv(str, UTF16)
- end
- module_function :toutf16
-
- # call-seq:
- # Kconv.toutf32(str) => string
- #
- # Convert str to UTF-32
- def toutf32(str)
- kconv(str, UTF32)
- end
- module_function :toutf32
-
- # call-seq:
- # Kconv.tolocale => string
- #
- # Convert self to locale encoding
- def tolocale(str)
- kconv(str, Encoding.locale_charmap)
- end
- module_function :tolocale
-
- #
- # guess
- #
-
- # call-seq:
- # Kconv.guess(str) => encoding
- #
- # Guess input encoding by NKF.guess
- def guess(str)
- ::NKF::guess(str)
- end
- module_function :guess
-
- #
- # isEncoding
- #
-
- # call-seq:
- # Kconv.iseuc(str) => true or false
- #
- # Returns whether input encoding is EUC-JP or not.
- #
- # *Note* don't expect this return value is MatchData.
- def iseuc(str)
- str.dup.force_encoding(EUC).valid_encoding?
- end
- module_function :iseuc
-
- # call-seq:
- # Kconv.issjis(str) => true or false
- #
- # Returns whether input encoding is Shift_JIS or not.
- def issjis(str)
- str.dup.force_encoding(SJIS).valid_encoding?
- end
- module_function :issjis
-
- # call-seq:
- # Kconv.isjis(str) => true or false
- #
- # Returns whether input encoding is ISO-2022-JP or not.
- def isjis(str)
- /\A [\t\n\r\x20-\x7E]*
- (?:
- (?:\x1b \x28 I [\x21-\x7E]*
- |\x1b \x28 J [\x21-\x7E]*
- |\x1b \x24 @ (?:[\x21-\x7E]{2})*
- |\x1b \x24 B (?:[\x21-\x7E]{2})*
- |\x1b \x24 \x28 D (?:[\x21-\x7E]{2})*
- )*
- \x1b \x28 B [\t\n\r\x20-\x7E]*
- )*
- \z/nox =~ str.dup.force_encoding('BINARY') ? true : false
- end
- module_function :isjis
-
- # call-seq:
- # Kconv.isutf8(str) => true or false
- #
- # Returns whether input encoding is UTF-8 or not.
- def isutf8(str)
- str.dup.force_encoding(UTF8).valid_encoding?
- end
- module_function :isutf8
-end
-
-class String
- # call-seq:
- # String#kconv(to_enc, from_enc)
- #
- # Convert self to to_enc.
- # to_enc and from_enc are given as constants of Kconv or Encoding objects.
- def kconv(to_enc, from_enc=nil)
- from_enc = self.encoding if !from_enc && self.encoding != Encoding.list[0]
- Kconv::kconv(self, to_enc, from_enc)
- end
-
- #
- # to Encoding
- #
-
- # call-seq:
- # String#tojis => string
- #
- # Convert self to ISO-2022-JP
- def tojis; Kconv.tojis(self) end
-
- # call-seq:
- # String#toeuc => string
- #
- # Convert self to EUC-JP
- def toeuc; Kconv.toeuc(self) end
-
- # call-seq:
- # String#tosjis => string
- #
- # Convert self to Shift_JIS
- def tosjis; Kconv.tosjis(self) end
-
- # call-seq:
- # String#toutf8 => string
- #
- # Convert self to UTF-8
- def toutf8; Kconv.toutf8(self) end
-
- # call-seq:
- # String#toutf16 => string
- #
- # Convert self to UTF-16
- def toutf16; Kconv.toutf16(self) end
-
- # call-seq:
- # String#toutf32 => string
- #
- # Convert self to UTF-32
- def toutf32; Kconv.toutf32(self) end
-
- # call-seq:
- # String#tolocale => string
- #
- # Convert self to locale encoding
- def tolocale; Kconv.tolocale(self) end
-
- #
- # is Encoding
- #
-
- # call-seq:
- # String#iseuc => true or false
- #
- # Returns whether self's encoding is EUC-JP or not.
- def iseuc; Kconv.iseuc(self) end
-
- # call-seq:
- # String#issjis => true or false
- #
- # Returns whether self's encoding is Shift_JIS or not.
- def issjis; Kconv.issjis(self) end
-
- # call-seq:
- # String#isjis => true or false
- #
- # Returns whether self's encoding is ISO-2022-JP or not.
- def isjis; Kconv.isjis(self) end
-
- # call-seq:
- # String#isutf8 => true or false
- #
- # Returns whether self's encoding is UTF-8 or not.
- def isutf8; Kconv.isutf8(self) end
-end
diff --git a/src/main/resources/stdlib/logger.rb b/src/main/resources/stdlib/logger.rb
deleted file mode 100644
index 530b718..0000000
--- a/src/main/resources/stdlib/logger.rb
+++ /dev/null
@@ -1,737 +0,0 @@
-# logger.rb - simple logging utility
-# Copyright (C) 2000-2003, 2005, 2008, 2011 NAKAMURA, Hiroshi .
-#
-# Documentation:: NAKAMURA, Hiroshi and Gavin Sinclair
-# License::
-# You can redistribute it and/or modify it under the same terms of Ruby's
-# license; either the dual license version in 2003, or any later version.
-# Revision:: $Id$
-#
-# A simple system for logging messages. See Logger for more documentation.
-
-require 'monitor'
-
-# == Description
-#
-# The Logger class provides a simple but sophisticated logging utility that
-# you can use to output messages.
-#
-# The messages have associated levels, such as +INFO+ or +ERROR+ that indicate
-# their importance. You can then give the Logger a level, and only messages
-# at that level or higher will be printed.
-#
-# The levels are:
-#
-# +UNKNOWN+:: An unknown message that should always be logged.
-# +FATAL+:: An unhandleable error that results in a program crash.
-# +ERROR+:: A handleable error condition.
-# +WARN+:: A warning.
-# +INFO+:: Generic (useful) information about system operation.
-# +DEBUG+:: Low-level information for developers.
-#
-# For instance, in a production system, you may have your Logger set to
-# +INFO+ or even +WARN+.
-# When you are developing the system, however, you probably
-# want to know about the program's internal state, and would set the Logger to
-# +DEBUG+.
-#
-# *Note*: Logger does not escape or sanitize any messages passed to it.
-# Developers should be aware of when potentially malicious data (user-input)
-# is passed to Logger, and manually escape the untrusted data:
-#
-# logger.info("User-input: #{input.dump}")
-# logger.info("User-input: %p" % input)
-#
-# You can use #formatter= for escaping all data.
-#
-# original_formatter = Logger::Formatter.new
-# logger.formatter = proc { |severity, datetime, progname, msg|
-# original_formatter.call(severity, datetime, progname, msg.dump)
-# }
-# logger.info(input)
-#
-# === Example
-#
-# This creates a Logger that outputs to the standard output stream, with a
-# level of +WARN+:
-#
-# require 'logger'
-#
-# logger = Logger.new(STDOUT)
-# logger.level = Logger::WARN
-#
-# logger.debug("Created logger")
-# logger.info("Program started")
-# logger.warn("Nothing to do!")
-#
-# path = "a_non_existent_file"
-#
-# begin
-# File.foreach(path) do |line|
-# unless line =~ /^(\w+) = (.*)$/
-# logger.error("Line in wrong format: #{line.chomp}")
-# end
-# end
-# rescue => err
-# logger.fatal("Caught exception; exiting")
-# logger.fatal(err)
-# end
-#
-# Because the Logger's level is set to +WARN+, only the warning, error, and
-# fatal messages are recorded. The debug and info messages are silently
-# discarded.
-#
-# === Features
-#
-# There are several interesting features that Logger provides, like
-# auto-rolling of log files, setting the format of log messages, and
-# specifying a program name in conjunction with the message. The next section
-# shows you how to achieve these things.
-#
-#
-# == HOWTOs
-#
-# === How to create a logger
-#
-# The options below give you various choices, in more or less increasing
-# complexity.
-#
-# 1. Create a logger which logs messages to STDERR/STDOUT.
-#
-# logger = Logger.new(STDERR)
-# logger = Logger.new(STDOUT)
-#
-# 2. Create a logger for the file which has the specified name.
-#
-# logger = Logger.new('logfile.log')
-#
-# 3. Create a logger for the specified file.
-#
-# file = File.open('foo.log', File::WRONLY | File::APPEND)
-# # To create new (and to remove old) logfile, add File::CREAT like:
-# # file = File.open('foo.log', File::WRONLY | File::APPEND | File::CREAT)
-# logger = Logger.new(file)
-#
-# 4. Create a logger which ages the logfile once it reaches a certain size.
-# Leave 10 "old" log files where each file is about 1,024,000 bytes.
-#
-# logger = Logger.new('foo.log', 10, 1024000)
-#
-# 5. Create a logger which ages the logfile daily/weekly/monthly.
-#
-# logger = Logger.new('foo.log', 'daily')
-# logger = Logger.new('foo.log', 'weekly')
-# logger = Logger.new('foo.log', 'monthly')
-#
-# === How to log a message
-#
-# Notice the different methods (+fatal+, +error+, +info+) being used to log
-# messages of various levels? Other methods in this family are +warn+ and
-# +debug+. +add+ is used below to log a message of an arbitrary (perhaps
-# dynamic) level.
-#
-# 1. Message in a block.
-#
-# logger.fatal { "Argument 'foo' not given." }
-#
-# 2. Message as a string.
-#
-# logger.error "Argument #{@foo} mismatch."
-#
-# 3. With progname.
-#
-# logger.info('initialize') { "Initializing..." }
-#
-# 4. With severity.
-#
-# logger.add(Logger::FATAL) { 'Fatal error!' }
-#
-# The block form allows you to create potentially complex log messages,
-# but to delay their evaluation until and unless the message is
-# logged. For example, if we have the following:
-#
-# logger.debug { "This is a " + potentially + " expensive operation" }
-#
-# If the logger's level is +INFO+ or higher, no debug messages will be logged,
-# and the entire block will not even be evaluated. Compare to this:
-#
-# logger.debug("This is a " + potentially + " expensive operation")
-#
-# Here, the string concatenation is done every time, even if the log
-# level is not set to show the debug message.
-#
-# === How to close a logger
-#
-# logger.close
-#
-# === Setting severity threshold
-#
-# 1. Original interface.
-#
-# logger.sev_threshold = Logger::WARN
-#
-# 2. Log4r (somewhat) compatible interface.
-#
-# logger.level = Logger::INFO
-#
-# # DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
-#
-# == Format
-#
-# Log messages are rendered in the output stream in a certain format by
-# default. The default format and a sample are shown below:
-#
-# Log format:
-# SeverityID, [DateTime #pid] SeverityLabel -- ProgName: message
-#
-# Log sample:
-# I, [1999-03-03T02:34:24.895701 #19074] INFO -- Main: info.
-#
-# You may change the date and time format via #datetime_format=.
-#
-# logger.datetime_format = '%Y-%m-%d %H:%M:%S'
-# # e.g. "2004-01-03 00:54:26"
-#
-# Or, you may change the overall format via the #formatter= method.
-#
-# logger.formatter = proc do |severity, datetime, progname, msg|
-# "#{datetime}: #{msg}\n"
-# end
-# # e.g. "2005-09-22 08:51:08 +0900: hello world"
-#
-class Logger
- VERSION = "1.2.7"
- _, name, rev = %w$Id$
- if name
- name = name.chomp(",v")
- else
- name = File.basename(__FILE__)
- end
- rev ||= "v#{VERSION}"
- ProgName = "#{name}/#{rev}"
-
- class Error < RuntimeError # :nodoc:
- end
- # not used after 1.2.7. just for compat.
- class ShiftingError < Error # :nodoc:
- end
-
- # Logging severity.
- module Severity
- # Low-level information, mostly for developers.
- DEBUG = 0
- # Generic (useful) information about system operation.
- INFO = 1
- # A warning.
- WARN = 2
- # A handleable error condition.
- ERROR = 3
- # An unhandleable error that results in a program crash.
- FATAL = 4
- # An unknown message that should always be logged.
- UNKNOWN = 5
- end
- include Severity
-
- # Logging severity threshold (e.g. Logger::INFO).
- attr_accessor :level
-
- # Program name to include in log messages.
- attr_accessor :progname
-
- # Set date-time format.
- #
- # +datetime_format+:: A string suitable for passing to +strftime+.
- def datetime_format=(datetime_format)
- @default_formatter.datetime_format = datetime_format
- end
-
- # Returns the date format being used. See #datetime_format=
- def datetime_format
- @default_formatter.datetime_format
- end
-
- # Logging formatter, as a +Proc+ that will take four arguments and
- # return the formatted message. The arguments are:
- #
- # +severity+:: The Severity of the log message.
- # +time+:: A Time instance representing when the message was logged.
- # +progname+:: The #progname configured, or passed to the logger method.
- # +msg+:: The _Object_ the user passed to the log message; not necessarily a
- # String.
- #
- # The block should return an Object that can be written to the logging
- # device via +write+. The default formatter is used when no formatter is
- # set.
- attr_accessor :formatter
-
- alias sev_threshold level
- alias sev_threshold= level=
-
- # Returns +true+ iff the current severity level allows for the printing of
- # +DEBUG+ messages.
- def debug?; @level <= DEBUG; end
-
- # Returns +true+ iff the current severity level allows for the printing of
- # +INFO+ messages.
- def info?; @level <= INFO; end
-
- # Returns +true+ iff the current severity level allows for the printing of
- # +WARN+ messages.
- def warn?; @level <= WARN; end
-
- # Returns +true+ iff the current severity level allows for the printing of
- # +ERROR+ messages.
- def error?; @level <= ERROR; end
-
- # Returns +true+ iff the current severity level allows for the printing of
- # +FATAL+ messages.
- def fatal?; @level <= FATAL; end
-
- #
- # :call-seq:
- # Logger.new(logdev, shift_age = 7, shift_size = 1048576)
- # Logger.new(logdev, shift_age = 'weekly')
- #
- # === Args
- #
- # +logdev+::
- # The log device. This is a filename (String) or IO object (typically
- # +STDOUT+, +STDERR+, or an open file).
- # +shift_age+::
- # Number of old log files to keep, *or* frequency of rotation (+daily+,
- # +weekly+ or +monthly+).
- # +shift_size+::
- # Maximum logfile size (only applies when +shift_age+ is a number).
- #
- # === Description
- #
- # Create an instance.
- #
- def initialize(logdev, shift_age = 0, shift_size = 1048576)
- @progname = nil
- @level = DEBUG
- @default_formatter = Formatter.new
- @formatter = nil
- @logdev = nil
- if logdev
- @logdev = LogDevice.new(logdev, :shift_age => shift_age,
- :shift_size => shift_size)
- end
- end
-
- #
- # :call-seq:
- # Logger#add(severity, message = nil, progname = nil) { ... }
- #
- # === Args
- #
- # +severity+::
- # Severity. Constants are defined in Logger namespace: +DEBUG+, +INFO+,
- # +WARN+, +ERROR+, +FATAL+, or +UNKNOWN+.
- # +message+::
- # The log message. A String or Exception.
- # +progname+::
- # Program name string. Can be omitted. Treated as a message if no
- # +message+ and +block+ are given.
- # +block+::
- # Can be omitted. Called to get a message string if +message+ is nil.
- #
- # === Return
- #
- # When the given severity is not high enough (for this particular logger),
- # log no message, and return +true+.
- #
- # === Description
- #
- # Log a message if the given severity is high enough. This is the generic
- # logging method. Users will be more inclined to use #debug, #info, #warn,
- # #error, and #fatal.
- #
- # Message format: +message+ can be any object, but it has to be
- # converted to a String in order to log it. Generally, +inspect+ is used
- # if the given object is not a String.
- # A special case is an +Exception+ object, which will be printed in detail,
- # including message, class, and backtrace. See #msg2str for the
- # implementation if required.
- #
- # === Bugs
- #
- # * Logfile is not locked.
- # * Append open does not need to lock file.
- # * If the OS supports multi I/O, records possibly may be mixed.
- #
- def add(severity, message = nil, progname = nil, &block)
- severity ||= UNKNOWN
- if @logdev.nil? or severity < @level
- return true
- end
- progname ||= @progname
- if message.nil?
- if block_given?
- message = yield
- else
- message = progname
- progname = @progname
- end
- end
- @logdev.write(
- format_message(format_severity(severity), Time.now, progname, message))
- true
- end
- alias log add
-
- #
- # Dump given message to the log device without any formatting. If no log
- # device exists, return +nil+.
- #
- def <<(msg)
- unless @logdev.nil?
- @logdev.write(msg)
- end
- end
-
- #
- # Log a +DEBUG+ message.
- #
- # See #info for more information.
- #
- def debug(progname = nil, &block)
- add(DEBUG, nil, progname, &block)
- end
-
- #
- # :call-seq:
- # info(message)
- # info(progname, &block)
- #
- # Log an +INFO+ message.
- #
- # +message+:: The message to log; does not need to be a String.
- # +progname+:: In the block form, this is the #progname to use in the
- # log message. The default can be set with #progname=.
- # +block+:: Evaluates to the message to log. This is not evaluated unless
- # the logger's level is sufficient to log the message. This
- # allows you to create potentially expensive logging messages that
- # are only called when the logger is configured to show them.
- #
- # === Examples
- #
- # logger.info("MainApp") { "Received connection from #{ip}" }
- # # ...
- # logger.info "Waiting for input from user"
- # # ...
- # logger.info { "User typed #{input}" }
- #
- # You'll probably stick to the second form above, unless you want to provide a
- # program name (which you can do with #progname= as well).
- #
- # === Return
- #
- # See #add.
- #
- def info(progname = nil, &block)
- add(INFO, nil, progname, &block)
- end
-
- #
- # Log a +WARN+ message.
- #
- # See #info for more information.
- #
- def warn(progname = nil, &block)
- add(WARN, nil, progname, &block)
- end
-
- #
- # Log an +ERROR+ message.
- #
- # See #info for more information.
- #
- def error(progname = nil, &block)
- add(ERROR, nil, progname, &block)
- end
-
- #
- # Log a +FATAL+ message.
- #
- # See #info for more information.
- #
- def fatal(progname = nil, &block)
- add(FATAL, nil, progname, &block)
- end
-
- #
- # Log an +UNKNOWN+ message. This will be printed no matter what the logger's
- # level is.
- #
- # See #info for more information.
- #
- def unknown(progname = nil, &block)
- add(UNKNOWN, nil, progname, &block)
- end
-
- #
- # Close the logging device.
- #
- def close
- @logdev.close if @logdev
- end
-
-private
-
- # Severity label for logging (max 5 chars).
- SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY)
-
- def format_severity(severity)
- SEV_LABEL[severity] || 'ANY'
- end
-
- def format_message(severity, datetime, progname, msg)
- (@formatter || @default_formatter).call(severity, datetime, progname, msg)
- end
-
-
- # Default formatter for log messages.
- class Formatter
- Format = "%s, [%s#%d] %5s -- %s: %s\n"
-
- attr_accessor :datetime_format
-
- def initialize
- @datetime_format = nil
- end
-
- def call(severity, time, progname, msg)
- Format % [severity[0..0], format_datetime(time), $$, severity, progname,
- msg2str(msg)]
- end
-
- private
-
- def format_datetime(time)
- time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ".freeze)
- end
-
- def msg2str(msg)
- case msg
- when ::String
- msg
- when ::Exception
- "#{ msg.message } (#{ msg.class })\n" <<
- (msg.backtrace || []).join("\n")
- else
- msg.inspect
- end
- end
- end
-
- module Period
- module_function
-
- SiD = 24 * 60 * 60
-
- def next_rotate_time(now, shift_age)
- case shift_age
- when /^daily$/
- t = Time.mktime(now.year, now.month, now.mday) + SiD
- when /^weekly$/
- t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
- when /^monthly$/
- t = Time.mktime(now.year, now.month, 1) + SiD * 31
- mday = (1 if t.mday > 1)
- else
- return now
- end
- if mday or t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
- t = Time.mktime(t.year, t.month, mday || (t.mday + (t.hour > 12 ? 1 : 0)))
- end
- t
- end
-
- def previous_period_end(now, shift_age)
- case shift_age
- when /^daily$/
- t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
- when /^weekly$/
- t = Time.mktime(now.year, now.month, now.mday) - (SiD * (now.wday + 1) + SiD / 2)
- when /^monthly$/
- t = Time.mktime(now.year, now.month, 1) - SiD / 2
- else
- return now
- end
- Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
- end
- end
-
- # Device used for logging messages.
- class LogDevice
- include Period
-
- attr_reader :dev
- attr_reader :filename
-
- class LogDeviceMutex
- include MonitorMixin
- end
-
- def initialize(log = nil, opt = {})
- @dev = @filename = @shift_age = @shift_size = nil
- @mutex = LogDeviceMutex.new
- if log.respond_to?(:write) and log.respond_to?(:close)
- @dev = log
- else
- @dev = open_logfile(log)
- @dev.sync = true
- @filename = log
- @shift_age = opt[:shift_age] || 7
- @shift_size = opt[:shift_size] || 1048576
- @next_rotate_time = next_rotate_time(Time.now, @shift_age) unless @shift_age.is_a?(Integer)
- end
- end
-
- def write(message)
- begin
- @mutex.synchronize do
- if @shift_age and @dev.respond_to?(:stat)
- begin
- check_shift_log
- rescue
- warn("log shifting failed. #{$!}")
- end
- end
- begin
- @dev.write(message)
- rescue
- warn("log writing failed. #{$!}")
- end
- end
- rescue Exception => ignored
- warn("log writing failed. #{ignored}")
- end
- end
-
- def close
- begin
- @mutex.synchronize do
- @dev.close rescue nil
- end
- rescue Exception
- @dev.close rescue nil
- end
- end
-
- private
-
- def open_logfile(filename)
- begin
- open(filename, (File::WRONLY | File::APPEND))
- rescue Errno::ENOENT
- create_logfile(filename)
- end
- end
-
- def create_logfile(filename)
- begin
- logdev = open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL))
- logdev.flock(File::LOCK_EX)
- logdev.sync = true
- add_log_header(logdev)
- logdev.flock(File::LOCK_UN)
- rescue Errno::EEXIST
- # file is created by another process
- logdev = open_logfile(filename)
- logdev.sync = true
- end
- logdev
- end
-
- def add_log_header(file)
- file.write(
- "# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName]
- ) if file.size == 0
- end
-
- def check_shift_log
- if @shift_age.is_a?(Integer)
- # Note: always returns false if '0'.
- if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size)
- lock_shift_log { shift_log_age }
- end
- else
- now = Time.now
- if now >= @next_rotate_time
- @next_rotate_time = next_rotate_time(now, @shift_age)
- lock_shift_log { shift_log_period(previous_period_end(now, @shift_age)) }
- end
- end
- end
-
- if /mswin|mingw/ =~ RUBY_PLATFORM
- def lock_shift_log
- yield
- end
- else
- def lock_shift_log
- retry_limit = 8
- retry_sleep = 0.1
- begin
- File.open(@filename, File::WRONLY | File::APPEND) do |lock|
- lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file
- if File.identical?(@filename, lock) and File.identical?(lock, @dev)
- yield # log shifting
- else
- # log shifted by another process (i-node before locking and i-node after locking are different)
- @dev.close rescue nil
- @dev = open_logfile(@filename)
- @dev.sync = true
- end
- end
- rescue Errno::ENOENT
- # @filename file would not exist right after #rename and before #create_logfile
- if retry_limit <= 0
- warn("log rotation inter-process lock failed. #{$!}")
- else
- sleep retry_sleep
- retry_limit -= 1
- retry_sleep *= 2
- retry
- end
- end
- rescue
- warn("log rotation inter-process lock failed. #{$!}")
- end
- end
-
- def shift_log_age
- (@shift_age-3).downto(0) do |i|
- if FileTest.exist?("#{@filename}.#{i}")
- File.rename("#{@filename}.#{i}", "#{@filename}.#{i+1}")
- end
- end
- @dev.close rescue nil
- File.rename("#{@filename}", "#{@filename}.0")
- @dev = create_logfile(@filename)
- return true
- end
-
- def shift_log_period(period_end)
- postfix = period_end.strftime("%Y%m%d") # YYYYMMDD
- age_file = "#{@filename}.#{postfix}"
- if FileTest.exist?(age_file)
- # try to avoid filename crash caused by Timestamp change.
- idx = 0
- # .99 can be overridden; avoid too much file search with 'loop do'
- while idx < 100
- idx += 1
- age_file = "#{@filename}.#{postfix}.#{idx}"
- break unless FileTest.exist?(age_file)
- end
- end
- @dev.close rescue nil
- File.rename("#{@filename}", age_file)
- @dev = create_logfile(@filename)
- return true
- end
- end
-end
diff --git a/src/main/resources/stdlib/mathn.rb b/src/main/resources/stdlib/mathn.rb
deleted file mode 100644
index 315e543..0000000
--- a/src/main/resources/stdlib/mathn.rb
+++ /dev/null
@@ -1,191 +0,0 @@
-#--
-# $Release Version: 0.5 $
-# $Revision: 1.1.1.1.4.1 $
-
-##
-# = mathn
-#
-# mathn serves to make mathematical operations more precise in Ruby
-# and to integrate other mathematical standard libraries.
-#
-# Without mathn:
-#
-# 3 / 2 => 1 # Integer
-#
-# With mathn:
-#
-# 3 / 2 => 3/2 # Rational
-#
-# mathn keeps value in exact terms.
-#
-# Without mathn:
-#
-# 20 / 9 * 3 * 14 / 7 * 3 / 2 # => 18
-#
-# With mathn:
-#
-# 20 / 9 * 3 * 14 / 7 * 3 / 2 # => 20
-#
-#
-# When you require 'mathn', the libraries for Prime, CMath, Matrix and Vector
-# are also loaded.
-#
-# == Copyright
-#
-# Author: Keiju ISHITSUKA (SHL Japan Inc.)
-#--
-# class Numeric follows to make this documentation findable in a reasonable
-# location
-
-warn('lib/mathn.rb is deprecated') if $VERBOSE
-
-class Numeric; end
-
-require "cmath.rb"
-require "matrix.rb"
-require "prime.rb"
-
-require "mathn/rational"
-require "mathn/complex"
-
-unless defined?(Math.exp!)
- Object.instance_eval{remove_const :Math}
- Math = CMath # :nodoc:
-end
-
-##
-# When mathn is required, Fixnum's division is enhanced to
-# return more precise values from mathematical expressions.
-#
-# 2/3*3 # => 0
-# require 'mathn'
-# 2/3*3 # => 2
-
-class Fixnum
- remove_method :/
-
- ##
- # +/+ defines the Rational division for Fixnum.
- #
- # 1/3 # => (1/3)
-
- alias / quo
-end
-
-##
-# When mathn is required Bignum's division is enhanced to
-# return more precise values from mathematical expressions.
-#
-# (2**72) / ((2**70) * 3) # => 4/3
-
-class Bignum
- remove_method :/
-
- ##
- # +/+ defines the Rational division for Bignum.
- #
- # (2**72) / ((2**70) * 3) # => 4/3
-
- alias / quo
-end
-
-##
-# When mathn is required, the Math module changes as follows:
-#
-# Standard Math module behaviour:
-# Math.sqrt(4/9) # => 0.0
-# Math.sqrt(4.0/9.0) # => 0.666666666666667
-# Math.sqrt(- 4/9) # => Errno::EDOM: Numerical argument out of domain - sqrt
-#
-# After require 'mathn', this is changed to:
-#
-# require 'mathn'
-# Math.sqrt(4/9) # => 2/3
-# Math.sqrt(4.0/9.0) # => 0.666666666666667
-# Math.sqrt(- 4/9) # => Complex(0, 2/3)
-
-module Math
- remove_method(:sqrt)
-
- ##
- # Computes the square root of +a+. It makes use of Complex and
- # Rational to have no rounding errors if possible.
- #
- # Math.sqrt(4/9) # => 2/3
- # Math.sqrt(- 4/9) # => Complex(0, 2/3)
- # Math.sqrt(4.0/9.0) # => 0.666666666666667
-
- def sqrt(a)
- if a.kind_of?(Complex)
- abs = sqrt(a.real*a.real + a.imag*a.imag)
- x = sqrt((a.real + abs)/Rational(2))
- y = sqrt((-a.real + abs)/Rational(2))
- if a.imag >= 0
- Complex(x, y)
- else
- Complex(x, -y)
- end
- elsif a.respond_to?(:nan?) and a.nan?
- a
- elsif a >= 0
- rsqrt(a)
- else
- Complex(0,rsqrt(-a))
- end
- end
-
- ##
- # Compute square root of a non negative number. This method is
- # internally used by +Math.sqrt+.
-
- def rsqrt(a)
- if a.kind_of?(Float)
- sqrt!(a)
- elsif a.kind_of?(Rational)
- rsqrt(a.numerator)/rsqrt(a.denominator)
- else
- src = a
- max = 2 ** 32
- byte_a = [src & 0xffffffff]
- # ruby's bug
- while (src >= max) and (src >>= 32)
- byte_a.unshift src & 0xffffffff
- end
-
- answer = 0
- main = 0
- side = 0
- for elm in byte_a
- main = (main << 32) + elm
- side <<= 16
- if answer != 0
- if main * 4 < side * side
- applo = main.div(side)
- else
- applo = ((sqrt!(side * side + 4 * main) - side)/2.0).to_i + 1
- end
- else
- applo = sqrt!(main).to_i + 1
- end
-
- while (x = (side + applo) * applo) > main
- applo -= 1
- end
- main -= x
- answer = (answer << 16) + applo
- side += applo * 2
- end
- if main == 0
- answer
- else
- sqrt!(a)
- end
- end
- end
-
- class << self
- remove_method(:sqrt)
- end
- module_function :sqrt
- module_function :rsqrt
-end
diff --git a/src/main/resources/stdlib/matrix.rb b/src/main/resources/stdlib/matrix.rb
deleted file mode 100644
index fb98d09..0000000
--- a/src/main/resources/stdlib/matrix.rb
+++ /dev/null
@@ -1,2161 +0,0 @@
-# encoding: utf-8
-#
-# = matrix.rb
-#
-# An implementation of Matrix and Vector classes.
-#
-# See classes Matrix and Vector for documentation.
-#
-# Current Maintainer:: Marc-André Lafortune
-# Original Author:: Keiju ISHITSUKA
-# Original Documentation:: Gavin Sinclair (sourced from Ruby in a Nutshell (Matsumoto, O'Reilly))
-##
-
-require "e2mmap.rb"
-
-module ExceptionForMatrix # :nodoc:
- extend Exception2MessageMapper
- def_e2message(TypeError, "wrong argument type %s (expected %s)")
- def_e2message(ArgumentError, "Wrong # of arguments(%d for %d)")
-
- def_exception("ErrDimensionMismatch", "\#{self.name} dimension mismatch")
- def_exception("ErrNotRegular", "Not Regular Matrix")
- def_exception("ErrOperationNotDefined", "Operation(%s) can\\'t be defined: %s op %s")
- def_exception("ErrOperationNotImplemented", "Sorry, Operation(%s) not implemented: %s op %s")
-end
-
-#
-# The +Matrix+ class represents a mathematical matrix. It provides methods for creating
-# matrices, operating on them arithmetically and algebraically,
-# and determining their mathematical properties (trace, rank, inverse, determinant).
-#
-# == Method Catalogue
-#
-# To create a matrix:
-# * Matrix[*rows]
-# * Matrix.[](*rows)
-# * Matrix.rows(rows, copy = true)
-# * Matrix.columns(columns)
-# * Matrix.build(row_count, column_count, &block)
-# * Matrix.diagonal(*values)
-# * Matrix.scalar(n, value)
-# * Matrix.identity(n)
-# * Matrix.unit(n)
-# * Matrix.I(n)
-# * Matrix.zero(n)
-# * Matrix.row_vector(row)
-# * Matrix.column_vector(column)
-# * Matrix.hstack(*matrices)
-# * Matrix.vstack(*matrices)
-#
-# To access Matrix elements/columns/rows/submatrices/properties:
-# * #[](i, j)
-# * #row_count (row_size)
-# * #column_count (column_size)
-# * #row(i)
-# * #column(j)
-# * #collect
-# * #map
-# * #each
-# * #each_with_index
-# * #find_index
-# * #minor(*param)
-# * #first_minor(row, column)
-# * #cofactor(row, column)
-# * #adjugate
-# * #laplace_expansion(row_or_column: num)
-# * #cofactor_expansion(row_or_column: num)
-#
-# Properties of a matrix:
-# * #diagonal?
-# * #empty?
-# * #hermitian?
-# * #lower_triangular?
-# * #normal?
-# * #orthogonal?
-# * #permutation?
-# * #real?
-# * #regular?
-# * #singular?
-# * #square?
-# * #symmetric?
-# * #unitary?
-# * #upper_triangular?
-# * #zero?
-#
-# Matrix arithmetic:
-# * #*(m)
-# * #+(m)
-# * #-(m)
-# * #/(m)
-# * #inverse
-# * #inv
-# * #**
-# * #+@
-# * #-@
-#
-# Matrix functions:
-# * #determinant
-# * #det
-# * #hstack(*matrices)
-# * #rank
-# * #round
-# * #trace
-# * #tr
-# * #transpose
-# * #t
-# * #vstack(*matrices)
-#
-# Matrix decompositions:
-# * #eigen
-# * #eigensystem
-# * #lup
-# * #lup_decomposition
-#
-# Complex arithmetic:
-# * conj
-# * conjugate
-# * imag
-# * imaginary
-# * real
-# * rect
-# * rectangular
-#
-# Conversion to other data types:
-# * #coerce(other)
-# * #row_vectors
-# * #column_vectors
-# * #to_a
-#
-# String representations:
-# * #to_s
-# * #inspect
-#
-class Matrix
- include Enumerable
- include ExceptionForMatrix
- autoload :EigenvalueDecomposition, "matrix/eigenvalue_decomposition"
- autoload :LUPDecomposition, "matrix/lup_decomposition"
-
- # instance creations
- private_class_method :new
- attr_reader :rows
- protected :rows
-
- #
- # Creates a matrix where each argument is a row.
- # Matrix[ [25, 93], [-1, 66] ]
- # => 25 93
- # -1 66
- #
- def Matrix.[](*rows)
- rows(rows, false)
- end
-
- #
- # Creates a matrix where +rows+ is an array of arrays, each of which is a row
- # of the matrix. If the optional argument +copy+ is false, use the given
- # arrays as the internal structure of the matrix without copying.
- # Matrix.rows([[25, 93], [-1, 66]])
- # => 25 93
- # -1 66
- #
- def Matrix.rows(rows, copy = true)
- rows = convert_to_array(rows, copy)
- rows.map! do |row|
- convert_to_array(row, copy)
- end
- size = (rows[0] || []).size
- rows.each do |row|
- raise ErrDimensionMismatch, "row size differs (#{row.size} should be #{size})" unless row.size == size
- end
- new rows, size
- end
-
- #
- # Creates a matrix using +columns+ as an array of column vectors.
- # Matrix.columns([[25, 93], [-1, 66]])
- # => 25 -1
- # 93 66
- #
- def Matrix.columns(columns)
- rows(columns, false).transpose
- end
-
- #
- # Creates a matrix of size +row_count+ x +column_count+.
- # It fills the values by calling the given block,
- # passing the current row and column.
- # Returns an enumerator if no block is given.
- #
- # m = Matrix.build(2, 4) {|row, col| col - row }
- # => Matrix[[0, 1, 2, 3], [-1, 0, 1, 2]]
- # m = Matrix.build(3) { rand }
- # => a 3x3 matrix with random elements
- #
- def Matrix.build(row_count, column_count = row_count)
- row_count = CoercionHelper.coerce_to_int(row_count)
- column_count = CoercionHelper.coerce_to_int(column_count)
- raise ArgumentError if row_count < 0 || column_count < 0
- return to_enum :build, row_count, column_count unless block_given?
- rows = Array.new(row_count) do |i|
- Array.new(column_count) do |j|
- yield i, j
- end
- end
- new rows, column_count
- end
-
- #
- # Creates a matrix where the diagonal elements are composed of +values+.
- # Matrix.diagonal(9, 5, -3)
- # => 9 0 0
- # 0 5 0
- # 0 0 -3
- #
- def Matrix.diagonal(*values)
- size = values.size
- return Matrix.empty if size == 0
- rows = Array.new(size) {|j|
- row = Array.new(size, 0)
- row[j] = values[j]
- row
- }
- new rows
- end
-
- #
- # Creates an +n+ by +n+ diagonal matrix where each diagonal element is
- # +value+.
- # Matrix.scalar(2, 5)
- # => 5 0
- # 0 5
- #
- def Matrix.scalar(n, value)
- diagonal(*Array.new(n, value))
- end
-
- #
- # Creates an +n+ by +n+ identity matrix.
- # Matrix.identity(2)
- # => 1 0
- # 0 1
- #
- def Matrix.identity(n)
- scalar(n, 1)
- end
- class << Matrix
- alias unit identity
- alias I identity
- end
-
- #
- # Creates a zero matrix.
- # Matrix.zero(2)
- # => 0 0
- # 0 0
- #
- def Matrix.zero(row_count, column_count = row_count)
- rows = Array.new(row_count){Array.new(column_count, 0)}
- new rows, column_count
- end
-
- #
- # Creates a single-row matrix where the values of that row are as given in
- # +row+.
- # Matrix.row_vector([4,5,6])
- # => 4 5 6
- #
- def Matrix.row_vector(row)
- row = convert_to_array(row)
- new [row]
- end
-
- #
- # Creates a single-column matrix where the values of that column are as given
- # in +column+.
- # Matrix.column_vector([4,5,6])
- # => 4
- # 5
- # 6
- #
- def Matrix.column_vector(column)
- column = convert_to_array(column)
- new [column].transpose, 1
- end
-
- #
- # Creates a empty matrix of +row_count+ x +column_count+.
- # At least one of +row_count+ or +column_count+ must be 0.
- #
- # m = Matrix.empty(2, 0)
- # m == Matrix[ [], [] ]
- # => true
- # n = Matrix.empty(0, 3)
- # n == Matrix.columns([ [], [], [] ])
- # => true
- # m * n
- # => Matrix[[0, 0, 0], [0, 0, 0]]
- #
- def Matrix.empty(row_count = 0, column_count = 0)
- raise ArgumentError, "One size must be 0" if column_count != 0 && row_count != 0
- raise ArgumentError, "Negative size" if column_count < 0 || row_count < 0
-
- new([[]]*row_count, column_count)
- end
-
- #
- # Create a matrix by stacking matrices vertically
- #
- # x = Matrix[[1, 2], [3, 4]]
- # y = Matrix[[5, 6], [7, 8]]
- # Matrix.vstack(x, y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]
- #
- def Matrix.vstack(x, *matrices)
- raise TypeError, "Expected a Matrix, got a #{x.class}" unless x.is_a?(Matrix)
- result = x.send(:rows).map(&:dup)
- matrices.each do |m|
- raise TypeError, "Expected a Matrix, got a #{m.class}" unless m.is_a?(Matrix)
- if m.column_count != x.column_count
- raise ErrDimensionMismatch, "The given matrices must have #{x.column_count} columns, but one has #{m.column_count}"
- end
- result.concat(m.send(:rows))
- end
- new result, x.column_count
- end
-
-
- #
- # Create a matrix by stacking matrices horizontally
- #
- # x = Matrix[[1, 2], [3, 4]]
- # y = Matrix[[5, 6], [7, 8]]
- # Matrix.hstack(x, y) # => Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]
- #
- def Matrix.hstack(x, *matrices)
- raise TypeError, "Expected a Matrix, got a #{x.class}" unless x.is_a?(Matrix)
- result = x.send(:rows).map(&:dup)
- total_column_count = x.column_count
- matrices.each do |m|
- raise TypeError, "Expected a Matrix, got a #{m.class}" unless m.is_a?(Matrix)
- if m.row_count != x.row_count
- raise ErrDimensionMismatch, "The given matrices must have #{x.row_count} rows, but one has #{m.row_count}"
- end
- result.each_with_index do |row, i|
- row.concat m.send(:rows)[i]
- end
- total_column_count += m.column_count
- end
- new result, total_column_count
- end
-
- #
- # Matrix.new is private; use Matrix.rows, columns, [], etc... to create.
- #
- def initialize(rows, column_count = rows[0].size)
- # No checking is done at this point. rows must be an Array of Arrays.
- # column_count must be the size of the first row, if there is one,
- # otherwise it *must* be specified and can be any integer >= 0
- @rows = rows
- @column_count = column_count
- end
-
- def new_matrix(rows, column_count = rows[0].size) # :nodoc:
- self.class.send(:new, rows, column_count) # bypass privacy of Matrix.new
- end
- private :new_matrix
-
- #
- # Returns element (+i+,+j+) of the matrix. That is: row +i+, column +j+.
- #
- def [](i, j)
- @rows.fetch(i){return nil}[j]
- end
- alias element []
- alias component []
-
- def []=(i, j, v)
- @rows[i][j] = v
- end
- alias set_element []=
- alias set_component []=
- private :[]=, :set_element, :set_component
-
- #
- # Returns the number of rows.
- #
- def row_count
- @rows.size
- end
-
- alias_method :row_size, :row_count
- #
- # Returns the number of columns.
- #
- attr_reader :column_count
- alias_method :column_size, :column_count
-
- #
- # Returns row vector number +i+ of the matrix as a Vector (starting at 0 like
- # an array). When a block is given, the elements of that vector are iterated.
- #
- def row(i, &block) # :yield: e
- if block_given?
- @rows.fetch(i){return self}.each(&block)
- self
- else
- Vector.elements(@rows.fetch(i){return nil})
- end
- end
-
- #
- # Returns column vector number +j+ of the matrix as a Vector (starting at 0
- # like an array). When a block is given, the elements of that vector are
- # iterated.
- #
- def column(j) # :yield: e
- if block_given?
- return self if j >= column_count || j < -column_count
- row_count.times do |i|
- yield @rows[i][j]
- end
- self
- else
- return nil if j >= column_count || j < -column_count
- col = Array.new(row_count) {|i|
- @rows[i][j]
- }
- Vector.elements(col, false)
- end
- end
-
- #
- # Returns a matrix that is the result of iteration of the given block over all
- # elements of the matrix.
- # Matrix[ [1,2], [3,4] ].collect { |e| e**2 }
- # => 1 4
- # 9 16
- #
- def collect(&block) # :yield: e
- return to_enum(:collect) unless block_given?
- rows = @rows.collect{|row| row.collect(&block)}
- new_matrix rows, column_count
- end
- alias map collect
-
- #
- # Yields all elements of the matrix, starting with those of the first row,
- # or returns an Enumerator if no block given.
- # Elements can be restricted by passing an argument:
- # * :all (default): yields all elements
- # * :diagonal: yields only elements on the diagonal
- # * :off_diagonal: yields all elements except on the diagonal
- # * :lower: yields only elements on or below the diagonal
- # * :strict_lower: yields only elements below the diagonal
- # * :strict_upper: yields only elements above the diagonal
- # * :upper: yields only elements on or above the diagonal
- #
- # Matrix[ [1,2], [3,4] ].each { |e| puts e }
- # # => prints the numbers 1 to 4
- # Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3]
- #
- def each(which = :all) # :yield: e
- return to_enum :each, which unless block_given?
- last = column_count - 1
- case which
- when :all
- block = Proc.new
- @rows.each do |row|
- row.each(&block)
- end
- when :diagonal
- @rows.each_with_index do |row, row_index|
- yield row.fetch(row_index){return self}
- end
- when :off_diagonal
- @rows.each_with_index do |row, row_index|
- column_count.times do |col_index|
- yield row[col_index] unless row_index == col_index
- end
- end
- when :lower
- @rows.each_with_index do |row, row_index|
- 0.upto([row_index, last].min) do |col_index|
- yield row[col_index]
- end
- end
- when :strict_lower
- @rows.each_with_index do |row, row_index|
- [row_index, column_count].min.times do |col_index|
- yield row[col_index]
- end
- end
- when :strict_upper
- @rows.each_with_index do |row, row_index|
- (row_index+1).upto(last) do |col_index|
- yield row[col_index]
- end
- end
- when :upper
- @rows.each_with_index do |row, row_index|
- row_index.upto(last) do |col_index|
- yield row[col_index]
- end
- end
- else
- raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
- end
- self
- end
-
- #
- # Same as #each, but the row index and column index in addition to the element
- #
- # Matrix[ [1,2], [3,4] ].each_with_index do |e, row, col|
- # puts "#{e} at #{row}, #{col}"
- # end
- # # => Prints:
- # # 1 at 0, 0
- # # 2 at 0, 1
- # # 3 at 1, 0
- # # 4 at 1, 1
- #
- def each_with_index(which = :all) # :yield: e, row, column
- return to_enum :each_with_index, which unless block_given?
- last = column_count - 1
- case which
- when :all
- @rows.each_with_index do |row, row_index|
- row.each_with_index do |e, col_index|
- yield e, row_index, col_index
- end
- end
- when :diagonal
- @rows.each_with_index do |row, row_index|
- yield row.fetch(row_index){return self}, row_index, row_index
- end
- when :off_diagonal
- @rows.each_with_index do |row, row_index|
- column_count.times do |col_index|
- yield row[col_index], row_index, col_index unless row_index == col_index
- end
- end
- when :lower
- @rows.each_with_index do |row, row_index|
- 0.upto([row_index, last].min) do |col_index|
- yield row[col_index], row_index, col_index
- end
- end
- when :strict_lower
- @rows.each_with_index do |row, row_index|
- [row_index, column_count].min.times do |col_index|
- yield row[col_index], row_index, col_index
- end
- end
- when :strict_upper
- @rows.each_with_index do |row, row_index|
- (row_index+1).upto(last) do |col_index|
- yield row[col_index], row_index, col_index
- end
- end
- when :upper
- @rows.each_with_index do |row, row_index|
- row_index.upto(last) do |col_index|
- yield row[col_index], row_index, col_index
- end
- end
- else
- raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
- end
- self
- end
-
- SELECTORS = {all: true, diagonal: true, off_diagonal: true, lower: true, strict_lower: true, strict_upper: true, upper: true}.freeze
- #
- # :call-seq:
- # index(value, selector = :all) -> [row, column]
- # index(selector = :all){ block } -> [row, column]
- # index(selector = :all) -> an_enumerator
- #
- # The index method is specialized to return the index as [row, column]
- # It also accepts an optional +selector+ argument, see #each for details.
- #
- # Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
- # Matrix[ [1,1], [1,1] ].index(1, :strict_lower) # => [1, 0]
- #
- def index(*args)
- raise ArgumentError, "wrong number of arguments(#{args.size} for 0-2)" if args.size > 2
- which = (args.size == 2 || SELECTORS.include?(args.last)) ? args.pop : :all
- return to_enum :find_index, which, *args unless block_given? || args.size == 1
- if args.size == 1
- value = args.first
- each_with_index(which) do |e, row_index, col_index|
- return row_index, col_index if e == value
- end
- else
- each_with_index(which) do |e, row_index, col_index|
- return row_index, col_index if yield e
- end
- end
- nil
- end
- alias_method :find_index, :index
-
- #
- # Returns a section of the matrix. The parameters are either:
- # * start_row, nrows, start_col, ncols; OR
- # * row_range, col_range
- #
- # Matrix.diagonal(9, 5, -3).minor(0..1, 0..2)
- # => 9 0 0
- # 0 5 0
- #
- # Like Array#[], negative indices count backward from the end of the
- # row or column (-1 is the last element). Returns nil if the starting
- # row or column is greater than row_count or column_count respectively.
- #
- def minor(*param)
- case param.size
- when 2
- row_range, col_range = param
- from_row = row_range.first
- from_row += row_count if from_row < 0
- to_row = row_range.end
- to_row += row_count if to_row < 0
- to_row += 1 unless row_range.exclude_end?
- size_row = to_row - from_row
-
- from_col = col_range.first
- from_col += column_count if from_col < 0
- to_col = col_range.end
- to_col += column_count if to_col < 0
- to_col += 1 unless col_range.exclude_end?
- size_col = to_col - from_col
- when 4
- from_row, size_row, from_col, size_col = param
- return nil if size_row < 0 || size_col < 0
- from_row += row_count if from_row < 0
- from_col += column_count if from_col < 0
- else
- raise ArgumentError, param.inspect
- end
-
- return nil if from_row > row_count || from_col > column_count || from_row < 0 || from_col < 0
- rows = @rows[from_row, size_row].collect{|row|
- row[from_col, size_col]
- }
- new_matrix rows, [column_count - from_col, size_col].min
- end
-
- #
- # Returns the submatrix obtained by deleting the specified row and column.
- #
- # Matrix.diagonal(9, 5, -3, 4).first_minor(1, 2)
- # => 9 0 0
- # 0 0 0
- # 0 0 4
- #
- def first_minor(row, column)
- raise RuntimeError, "first_minor of empty matrix is not defined" if empty?
-
- unless 0 <= row && row < row_count
- raise ArgumentError, "invalid row (#{row.inspect} for 0..#{row_count - 1})"
- end
-
- unless 0 <= column && column < column_count
- raise ArgumentError, "invalid column (#{column.inspect} for 0..#{column_count - 1})"
- end
-
- arrays = to_a
- arrays.delete_at(row)
- arrays.each do |array|
- array.delete_at(column)
- end
-
- new_matrix arrays, column_count - 1
- end
-
- #
- # Returns the (row, column) cofactor which is obtained by multiplying
- # the first minor by (-1)**(row + column).
- #
- # Matrix.diagonal(9, 5, -3, 4).cofactor(1, 1)
- # => -108
- #
- def cofactor(row, column)
- raise RuntimeError, "cofactor of empty matrix is not defined" if empty?
- Matrix.Raise ErrDimensionMismatch unless square?
-
- det_of_minor = first_minor(row, column).determinant
- det_of_minor * (-1) ** (row + column)
- end
-
- #
- # Returns the adjugate of the matrix.
- #
- # Matrix[ [7,6],[3,9] ].adjugate
- # => 9 -6
- # -3 7
- #
- def adjugate
- Matrix.Raise ErrDimensionMismatch unless square?
- Matrix.build(row_count, column_count) do |row, column|
- cofactor(column, row)
- end
- end
-
- #
- # Returns the Laplace expansion along given row or column.
- #
- # Matrix[[7,6], [3,9]].laplace_expansion(column: 1)
- # => 45
- #
- # Matrix[[Vector[1, 0], Vector[0, 1]], [2, 3]].laplace_expansion(row: 0)
- # => Vector[3, -2]
- #
- #
- def laplace_expansion(row: nil, column: nil)
- num = row || column
-
- if !num || (row && column)
- raise ArgumentError, "exactly one the row or column arguments must be specified"
- end
-
- Matrix.Raise ErrDimensionMismatch unless square?
- raise RuntimeError, "laplace_expansion of empty matrix is not defined" if empty?
-
- unless 0 <= num && num < row_count
- raise ArgumentError, "invalid num (#{num.inspect} for 0..#{row_count - 1})"
- end
-
- send(row ? :row : :column, num).map.with_index { |e, k|
- e * cofactor(*(row ? [num, k] : [k,num]))
- }.inject(:+)
- end
- alias_method :cofactor_expansion, :laplace_expansion
-
-
- #--
- # TESTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Returns +true+ if this is a diagonal matrix.
- # Raises an error if matrix is not square.
- #
- def diagonal?
- Matrix.Raise ErrDimensionMismatch unless square?
- each(:off_diagonal).all?(&:zero?)
- end
-
- #
- # Returns +true+ if this is an empty matrix, i.e. if the number of rows
- # or the number of columns is 0.
- #
- def empty?
- column_count == 0 || row_count == 0
- end
-
- #
- # Returns +true+ if this is an hermitian matrix.
- # Raises an error if matrix is not square.
- #
- def hermitian?
- Matrix.Raise ErrDimensionMismatch unless square?
- each_with_index(:upper).all? do |e, row, col|
- e == rows[col][row].conj
- end
- end
-
- #
- # Returns +true+ if this is a lower triangular matrix.
- #
- def lower_triangular?
- each(:strict_upper).all?(&:zero?)
- end
-
- #
- # Returns +true+ if this is a normal matrix.
- # Raises an error if matrix is not square.
- #
- def normal?
- Matrix.Raise ErrDimensionMismatch unless square?
- rows.each_with_index do |row_i, i|
- rows.each_with_index do |row_j, j|
- s = 0
- rows.each_with_index do |row_k, k|
- s += row_i[k] * row_j[k].conj - row_k[i].conj * row_k[j]
- end
- return false unless s == 0
- end
- end
- true
- end
-
- #
- # Returns +true+ if this is an orthogonal matrix
- # Raises an error if matrix is not square.
- #
- def orthogonal?
- Matrix.Raise ErrDimensionMismatch unless square?
- rows.each_with_index do |row, i|
- column_count.times do |j|
- s = 0
- row_count.times do |k|
- s += row[k] * rows[k][j]
- end
- return false unless s == (i == j ? 1 : 0)
- end
- end
- true
- end
-
- #
- # Returns +true+ if this is a permutation matrix
- # Raises an error if matrix is not square.
- #
- def permutation?
- Matrix.Raise ErrDimensionMismatch unless square?
- cols = Array.new(column_count)
- rows.each_with_index do |row, i|
- found = false
- row.each_with_index do |e, j|
- if e == 1
- return false if found || cols[j]
- found = cols[j] = true
- elsif e != 0
- return false
- end
- end
- return false unless found
- end
- true
- end
-
- #
- # Returns +true+ if all entries of the matrix are real.
- #
- def real?
- all?(&:real?)
- end
-
- #
- # Returns +true+ if this is a regular (i.e. non-singular) matrix.
- #
- def regular?
- not singular?
- end
-
- #
- # Returns +true+ if this is a singular matrix.
- #
- def singular?
- determinant == 0
- end
-
- #
- # Returns +true+ if this is a square matrix.
- #
- def square?
- column_count == row_count
- end
-
- #
- # Returns +true+ if this is a symmetric matrix.
- # Raises an error if matrix is not square.
- #
- def symmetric?
- Matrix.Raise ErrDimensionMismatch unless square?
- each_with_index(:strict_upper) do |e, row, col|
- return false if e != rows[col][row]
- end
- true
- end
-
- #
- # Returns +true+ if this is a unitary matrix
- # Raises an error if matrix is not square.
- #
- def unitary?
- Matrix.Raise ErrDimensionMismatch unless square?
- rows.each_with_index do |row, i|
- column_count.times do |j|
- s = 0
- row_count.times do |k|
- s += row[k].conj * rows[k][j]
- end
- return false unless s == (i == j ? 1 : 0)
- end
- end
- true
- end
-
- #
- # Returns +true+ if this is an upper triangular matrix.
- #
- def upper_triangular?
- each(:strict_lower).all?(&:zero?)
- end
-
- #
- # Returns +true+ if this is a matrix with only zero elements
- #
- def zero?
- all?(&:zero?)
- end
-
- #--
- # OBJECT METHODS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Returns +true+ if and only if the two matrices contain equal elements.
- #
- def ==(other)
- return false unless Matrix === other &&
- column_count == other.column_count # necessary for empty matrices
- rows == other.rows
- end
-
- def eql?(other)
- return false unless Matrix === other &&
- column_count == other.column_count # necessary for empty matrices
- rows.eql? other.rows
- end
-
- #
- # Returns a clone of the matrix, so that the contents of each do not reference
- # identical objects.
- # There should be no good reason to do this since Matrices are immutable.
- #
- def clone
- new_matrix @rows.map(&:dup), column_count
- end
-
- #
- # Returns a hash-code for the matrix.
- #
- def hash
- @rows.hash
- end
-
- #--
- # ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Matrix multiplication.
- # Matrix[[2,4], [6,8]] * Matrix.identity(2)
- # => 2 4
- # 6 8
- #
- def *(m) # m is matrix or vector or number
- case(m)
- when Numeric
- rows = @rows.collect {|row|
- row.collect {|e| e * m }
- }
- return new_matrix rows, column_count
- when Vector
- m = self.class.column_vector(m)
- r = self * m
- return r.column(0)
- when Matrix
- Matrix.Raise ErrDimensionMismatch if column_count != m.row_count
-
- rows = Array.new(row_count) {|i|
- Array.new(m.column_count) {|j|
- (0 ... column_count).inject(0) do |vij, k|
- vij + self[i, k] * m[k, j]
- end
- }
- }
- return new_matrix rows, m.column_count
- else
- return apply_through_coercion(m, __method__)
- end
- end
-
- #
- # Matrix addition.
- # Matrix.scalar(2,5) + Matrix[[1,0], [-4,7]]
- # => 6 0
- # -4 12
- #
- def +(m)
- case m
- when Numeric
- Matrix.Raise ErrOperationNotDefined, "+", self.class, m.class
- when Vector
- m = self.class.column_vector(m)
- when Matrix
- else
- return apply_through_coercion(m, __method__)
- end
-
- Matrix.Raise ErrDimensionMismatch unless row_count == m.row_count && column_count == m.column_count
-
- rows = Array.new(row_count) {|i|
- Array.new(column_count) {|j|
- self[i, j] + m[i, j]
- }
- }
- new_matrix rows, column_count
- end
-
- #
- # Matrix subtraction.
- # Matrix[[1,5], [4,2]] - Matrix[[9,3], [-4,1]]
- # => -8 2
- # 8 1
- #
- def -(m)
- case m
- when Numeric
- Matrix.Raise ErrOperationNotDefined, "-", self.class, m.class
- when Vector
- m = self.class.column_vector(m)
- when Matrix
- else
- return apply_through_coercion(m, __method__)
- end
-
- Matrix.Raise ErrDimensionMismatch unless row_count == m.row_count && column_count == m.column_count
-
- rows = Array.new(row_count) {|i|
- Array.new(column_count) {|j|
- self[i, j] - m[i, j]
- }
- }
- new_matrix rows, column_count
- end
-
- #
- # Matrix division (multiplication by the inverse).
- # Matrix[[7,6], [3,9]] / Matrix[[2,9], [3,1]]
- # => -7 1
- # -3 -6
- #
- def /(other)
- case other
- when Numeric
- rows = @rows.collect {|row|
- row.collect {|e| e / other }
- }
- return new_matrix rows, column_count
- when Matrix
- return self * other.inverse
- else
- return apply_through_coercion(other, __method__)
- end
- end
-
- #
- # Returns the inverse of the matrix.
- # Matrix[[-1, -1], [0, -1]].inverse
- # => -1 1
- # 0 -1
- #
- def inverse
- Matrix.Raise ErrDimensionMismatch unless square?
- self.class.I(row_count).send(:inverse_from, self)
- end
- alias inv inverse
-
- def inverse_from(src) # :nodoc:
- last = row_count - 1
- a = src.to_a
-
- 0.upto(last) do |k|
- i = k
- akk = a[k][k].abs
- (k+1).upto(last) do |j|
- v = a[j][k].abs
- if v > akk
- i = j
- akk = v
- end
- end
- Matrix.Raise ErrNotRegular if akk == 0
- if i != k
- a[i], a[k] = a[k], a[i]
- @rows[i], @rows[k] = @rows[k], @rows[i]
- end
- akk = a[k][k]
-
- 0.upto(last) do |ii|
- next if ii == k
- q = a[ii][k].quo(akk)
- a[ii][k] = 0
-
- (k + 1).upto(last) do |j|
- a[ii][j] -= a[k][j] * q
- end
- 0.upto(last) do |j|
- @rows[ii][j] -= @rows[k][j] * q
- end
- end
-
- (k+1).upto(last) do |j|
- a[k][j] = a[k][j].quo(akk)
- end
- 0.upto(last) do |j|
- @rows[k][j] = @rows[k][j].quo(akk)
- end
- end
- self
- end
- private :inverse_from
-
- #
- # Matrix exponentiation.
- # Equivalent to multiplying the matrix by itself N times.
- # Non integer exponents will be handled by diagonalizing the matrix.
- #
- # Matrix[[7,6], [3,9]] ** 2
- # => 67 96
- # 48 99
- #
- def ** (other)
- case other
- when Integer
- x = self
- if other <= 0
- x = self.inverse
- return self.class.identity(self.column_count) if other == 0
- other = -other
- end
- z = nil
- loop do
- z = z ? z * x : x if other[0] == 1
- return z if (other >>= 1).zero?
- x *= x
- end
- when Numeric
- v, d, v_inv = eigensystem
- v * self.class.diagonal(*d.each(:diagonal).map{|e| e ** other}) * v_inv
- else
- Matrix.Raise ErrOperationNotDefined, "**", self.class, other.class
- end
- end
-
- def +@
- self
- end
-
- def -@
- collect {|e| -e }
- end
-
- #--
- # MATRIX FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Returns the determinant of the matrix.
- #
- # Beware that using Float values can yield erroneous results
- # because of their lack of precision.
- # Consider using exact types like Rational or BigDecimal instead.
- #
- # Matrix[[7,6], [3,9]].determinant
- # => 45
- #
- def determinant
- Matrix.Raise ErrDimensionMismatch unless square?
- m = @rows
- case row_count
- # Up to 4x4, give result using Laplacian expansion by minors.
- # This will typically be faster, as well as giving good results
- # in case of Floats
- when 0
- +1
- when 1
- + m[0][0]
- when 2
- + m[0][0] * m[1][1] - m[0][1] * m[1][0]
- when 3
- m0, m1, m2 = m
- + m0[0] * m1[1] * m2[2] - m0[0] * m1[2] * m2[1] \
- - m0[1] * m1[0] * m2[2] + m0[1] * m1[2] * m2[0] \
- + m0[2] * m1[0] * m2[1] - m0[2] * m1[1] * m2[0]
- when 4
- m0, m1, m2, m3 = m
- + m0[0] * m1[1] * m2[2] * m3[3] - m0[0] * m1[1] * m2[3] * m3[2] \
- - m0[0] * m1[2] * m2[1] * m3[3] + m0[0] * m1[2] * m2[3] * m3[1] \
- + m0[0] * m1[3] * m2[1] * m3[2] - m0[0] * m1[3] * m2[2] * m3[1] \
- - m0[1] * m1[0] * m2[2] * m3[3] + m0[1] * m1[0] * m2[3] * m3[2] \
- + m0[1] * m1[2] * m2[0] * m3[3] - m0[1] * m1[2] * m2[3] * m3[0] \
- - m0[1] * m1[3] * m2[0] * m3[2] + m0[1] * m1[3] * m2[2] * m3[0] \
- + m0[2] * m1[0] * m2[1] * m3[3] - m0[2] * m1[0] * m2[3] * m3[1] \
- - m0[2] * m1[1] * m2[0] * m3[3] + m0[2] * m1[1] * m2[3] * m3[0] \
- + m0[2] * m1[3] * m2[0] * m3[1] - m0[2] * m1[3] * m2[1] * m3[0] \
- - m0[3] * m1[0] * m2[1] * m3[2] + m0[3] * m1[0] * m2[2] * m3[1] \
- + m0[3] * m1[1] * m2[0] * m3[2] - m0[3] * m1[1] * m2[2] * m3[0] \
- - m0[3] * m1[2] * m2[0] * m3[1] + m0[3] * m1[2] * m2[1] * m3[0]
- else
- # For bigger matrices, use an efficient and general algorithm.
- # Currently, we use the Gauss-Bareiss algorithm
- determinant_bareiss
- end
- end
- alias_method :det, :determinant
-
- #
- # Private. Use Matrix#determinant
- #
- # Returns the determinant of the matrix, using
- # Bareiss' multistep integer-preserving gaussian elimination.
- # It has the same computational cost order O(n^3) as standard Gaussian elimination.
- # Intermediate results are fraction free and of lower complexity.
- # A matrix of Integers will have thus intermediate results that are also Integers,
- # with smaller bignums (if any), while a matrix of Float will usually have
- # intermediate results with better precision.
- #
- def determinant_bareiss
- size = row_count
- last = size - 1
- a = to_a
- no_pivot = Proc.new{ return 0 }
- sign = +1
- pivot = 1
- size.times do |k|
- previous_pivot = pivot
- if (pivot = a[k][k]) == 0
- switch = (k+1 ... size).find(no_pivot) {|row|
- a[row][k] != 0
- }
- a[switch], a[k] = a[k], a[switch]
- pivot = a[k][k]
- sign = -sign
- end
- (k+1).upto(last) do |i|
- ai = a[i]
- (k+1).upto(last) do |j|
- ai[j] = (pivot * ai[j] - ai[k] * a[k][j]) / previous_pivot
- end
- end
- end
- sign * pivot
- end
- private :determinant_bareiss
-
- #
- # deprecated; use Matrix#determinant
- #
- def determinant_e
- warn "#{caller(1)[0]}: warning: Matrix#determinant_e is deprecated; use #determinant"
- determinant
- end
- alias det_e determinant_e
-
- #
- # Returns a new matrix resulting by stacking horizontally
- # the receiver with the given matrices
- #
- # x = Matrix[[1, 2], [3, 4]]
- # y = Matrix[[5, 6], [7, 8]]
- # x.hstack(y) # => Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]
- #
- def hstack(*matrices)
- self.class.hstack(self, *matrices)
- end
-
- #
- # Returns the rank of the matrix.
- # Beware that using Float values can yield erroneous results
- # because of their lack of precision.
- # Consider using exact types like Rational or BigDecimal instead.
- #
- # Matrix[[7,6], [3,9]].rank
- # => 2
- #
- def rank
- # We currently use Bareiss' multistep integer-preserving gaussian elimination
- # (see comments on determinant)
- a = to_a
- last_column = column_count - 1
- last_row = row_count - 1
- pivot_row = 0
- previous_pivot = 1
- 0.upto(last_column) do |k|
- switch_row = (pivot_row .. last_row).find {|row|
- a[row][k] != 0
- }
- if switch_row
- a[switch_row], a[pivot_row] = a[pivot_row], a[switch_row] unless pivot_row == switch_row
- pivot = a[pivot_row][k]
- (pivot_row+1).upto(last_row) do |i|
- ai = a[i]
- (k+1).upto(last_column) do |j|
- ai[j] = (pivot * ai[j] - ai[k] * a[pivot_row][j]) / previous_pivot
- end
- end
- pivot_row += 1
- previous_pivot = pivot
- end
- end
- pivot_row
- end
-
- #
- # deprecated; use Matrix#rank
- #
- def rank_e
- warn "#{caller(1)[0]}: warning: Matrix#rank_e is deprecated; use #rank"
- rank
- end
-
- # Returns a matrix with entries rounded to the given precision
- # (see Float#round)
- #
- def round(ndigits=0)
- map{|e| e.round(ndigits)}
- end
-
- #
- # Returns the trace (sum of diagonal elements) of the matrix.
- # Matrix[[7,6], [3,9]].trace
- # => 16
- #
- def trace
- Matrix.Raise ErrDimensionMismatch unless square?
- (0...column_count).inject(0) do |tr, i|
- tr + @rows[i][i]
- end
- end
- alias tr trace
-
- #
- # Returns the transpose of the matrix.
- # Matrix[[1,2], [3,4], [5,6]]
- # => 1 2
- # 3 4
- # 5 6
- # Matrix[[1,2], [3,4], [5,6]].transpose
- # => 1 3 5
- # 2 4 6
- #
- def transpose
- return self.class.empty(column_count, 0) if row_count.zero?
- new_matrix @rows.transpose, row_count
- end
- alias t transpose
-
- #
- # Returns a new matrix resulting by stacking vertically
- # the receiver with the given matrices
- #
- # x = Matrix[[1, 2], [3, 4]]
- # y = Matrix[[5, 6], [7, 8]]
- # x.vstack(y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]
- #
- def vstack(*matrices)
- self.class.vstack(self, *matrices)
- end
-
- #--
- # DECOMPOSITIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- #++
-
- #
- # Returns the Eigensystem of the matrix; see +EigenvalueDecomposition+.
- # m = Matrix[[1, 2], [3, 4]]
- # v, d, v_inv = m.eigensystem
- # d.diagonal? # => true
- # v.inv == v_inv # => true
- # (v * d * v_inv).round(5) == m # => true
- #
- def eigensystem
- EigenvalueDecomposition.new(self)
- end
- alias eigen eigensystem
-
- #
- # Returns the LUP decomposition of the matrix; see +LUPDecomposition+.
- # a = Matrix[[1, 2], [3, 4]]
- # l, u, p = a.lup
- # l.lower_triangular? # => true
- # u.upper_triangular? # => true
- # p.permutation? # => true
- # l * u == p * a # => true
- # a.lup.solve([2, 5]) # => Vector[(1/1), (1/2)]
- #
- def lup
- LUPDecomposition.new(self)
- end
- alias lup_decomposition lup
-
- #--
- # COMPLEX ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- #++
-
- #
- # Returns the conjugate of the matrix.
- # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
- # => 1+2i i 0
- # 1 2 3
- # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].conjugate
- # => 1-2i -i 0
- # 1 2 3
- #
- def conjugate
- collect(&:conjugate)
- end
- alias conj conjugate
-
- #
- # Returns the imaginary part of the matrix.
- # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
- # => 1+2i i 0
- # 1 2 3
- # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].imaginary
- # => 2i i 0
- # 0 0 0
- #
- def imaginary
- collect(&:imaginary)
- end
- alias imag imaginary
-
- #
- # Returns the real part of the matrix.
- # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
- # => 1+2i i 0
- # 1 2 3
- # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].real
- # => 1 0 0
- # 1 2 3
- #
- def real
- collect(&:real)
- end
-
- #
- # Returns an array containing matrices corresponding to the real and imaginary
- # parts of the matrix
- #
- # m.rect == [m.real, m.imag] # ==> true for all matrices m
- #
- def rect
- [real, imag]
- end
- alias rectangular rect
-
- #--
- # CONVERTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # The coerce method provides support for Ruby type coercion.
- # This coercion mechanism is used by Ruby to handle mixed-type
- # numeric operations: it is intended to find a compatible common
- # type between the two operands of the operator.
- # See also Numeric#coerce.
- #
- def coerce(other)
- case other
- when Numeric
- return Scalar.new(other), self
- else
- raise TypeError, "#{self.class} can't be coerced into #{other.class}"
- end
- end
-
- #
- # Returns an array of the row vectors of the matrix. See Vector.
- #
- def row_vectors
- Array.new(row_count) {|i|
- row(i)
- }
- end
-
- #
- # Returns an array of the column vectors of the matrix. See Vector.
- #
- def column_vectors
- Array.new(column_count) {|i|
- column(i)
- }
- end
-
- #
- # Returns an array of arrays that describe the rows of the matrix.
- #
- def to_a
- @rows.collect(&:dup)
- end
-
- def elements_to_f
- warn "#{caller(1)[0]}: warning: Matrix#elements_to_f is deprecated, use map(&:to_f)"
- map(&:to_f)
- end
-
- def elements_to_i
- warn "#{caller(1)[0]}: warning: Matrix#elements_to_i is deprecated, use map(&:to_i)"
- map(&:to_i)
- end
-
- def elements_to_r
- warn "#{caller(1)[0]}: warning: Matrix#elements_to_r is deprecated, use map(&:to_r)"
- map(&:to_r)
- end
-
- #--
- # PRINTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Overrides Object#to_s
- #
- def to_s
- if empty?
- "#{self.class}.empty(#{row_count}, #{column_count})"
- else
- "#{self.class}[" + @rows.collect{|row|
- "[" + row.collect{|e| e.to_s}.join(", ") + "]"
- }.join(", ")+"]"
- end
- end
-
- #
- # Overrides Object#inspect
- #
- def inspect
- if empty?
- "#{self.class}.empty(#{row_count}, #{column_count})"
- else
- "#{self.class}#{@rows.inspect}"
- end
- end
-
- # Private helper modules
-
- module ConversionHelper # :nodoc:
- #
- # Converts the obj to an Array. If copy is set to true
- # a copy of obj will be made if necessary.
- #
- def convert_to_array(obj, copy = false) # :nodoc:
- case obj
- when Array
- copy ? obj.dup : obj
- when Vector
- obj.to_a
- else
- begin
- converted = obj.to_ary
- rescue Exception => e
- raise TypeError, "can't convert #{obj.class} into an Array (#{e.message})"
- end
- raise TypeError, "#{obj.class}#to_ary should return an Array" unless converted.is_a? Array
- converted
- end
- end
- private :convert_to_array
- end
-
- extend ConversionHelper
-
- module CoercionHelper # :nodoc:
- #
- # Applies the operator +oper+ with argument +obj+
- # through coercion of +obj+
- #
- def apply_through_coercion(obj, oper)
- coercion = obj.coerce(self)
- raise TypeError unless coercion.is_a?(Array) && coercion.length == 2
- coercion[0].public_send(oper, coercion[1])
- rescue
- raise TypeError, "#{obj.inspect} can't be coerced into #{self.class}"
- end
- private :apply_through_coercion
-
- #
- # Helper method to coerce a value into a specific class.
- # Raises a TypeError if the coercion fails or the returned value
- # is not of the right class.
- # (from Rubinius)
- #
- def self.coerce_to(obj, cls, meth) # :nodoc:
- return obj if obj.kind_of?(cls)
-
- begin
- ret = obj.__send__(meth)
- rescue Exception => e
- raise TypeError, "Coercion error: #{obj.inspect}.#{meth} => #{cls} failed:\n" \
- "(#{e.message})"
- end
- raise TypeError, "Coercion error: obj.#{meth} did NOT return a #{cls} (was #{ret.class})" unless ret.kind_of? cls
- ret
- end
-
- def self.coerce_to_int(obj)
- coerce_to(obj, Integer, :to_int)
- end
- end
-
- include CoercionHelper
-
- # Private CLASS
-
- class Scalar < Numeric # :nodoc:
- include ExceptionForMatrix
- include CoercionHelper
-
- def initialize(value)
- @value = value
- end
-
- # ARITHMETIC
- def +(other)
- case other
- when Numeric
- Scalar.new(@value + other)
- when Vector, Matrix
- Scalar.Raise ErrOperationNotDefined, "+", @value.class, other.class
- else
- apply_through_coercion(other, __method__)
- end
- end
-
- def -(other)
- case other
- when Numeric
- Scalar.new(@value - other)
- when Vector, Matrix
- Scalar.Raise ErrOperationNotDefined, "-", @value.class, other.class
- else
- apply_through_coercion(other, __method__)
- end
- end
-
- def *(other)
- case other
- when Numeric
- Scalar.new(@value * other)
- when Vector, Matrix
- other.collect{|e| @value * e}
- else
- apply_through_coercion(other, __method__)
- end
- end
-
- def / (other)
- case other
- when Numeric
- Scalar.new(@value / other)
- when Vector
- Scalar.Raise ErrOperationNotDefined, "/", @value.class, other.class
- when Matrix
- self * other.inverse
- else
- apply_through_coercion(other, __method__)
- end
- end
-
- def ** (other)
- case other
- when Numeric
- Scalar.new(@value ** other)
- when Vector
- Scalar.Raise ErrOperationNotDefined, "**", @value.class, other.class
- when Matrix
- #other.powered_by(self)
- Scalar.Raise ErrOperationNotImplemented, "**", @value.class, other.class
- else
- apply_through_coercion(other, __method__)
- end
- end
- end
-
-end
-
-
-#
-# The +Vector+ class represents a mathematical vector, which is useful in its own right, and
-# also constitutes a row or column of a Matrix.
-#
-# == Method Catalogue
-#
-# To create a Vector:
-# * Vector.[](*array)
-# * Vector.elements(array, copy = true)
-# * Vector.basis(size: n, index: k)
-#
-# To access elements:
-# * #[](i)
-#
-# To enumerate the elements:
-# * #each2(v)
-# * #collect2(v)
-#
-# Properties of vectors:
-# * #angle_with(v)
-# * Vector.independent?(*vs)
-# * #independent?(*vs)
-#
-# Vector arithmetic:
-# * #*(x) "is matrix or number"
-# * #+(v)
-# * #-(v)
-# * #+@
-# * #-@
-#
-# Vector functions:
-# * #inner_product(v), dot(v)
-# * #cross_product(v), cross(v)
-# * #collect
-# * #magnitude
-# * #map
-# * #map2(v)
-# * #norm
-# * #normalize
-# * #r
-# * #size
-#
-# Conversion to other data types:
-# * #covector
-# * #to_a
-# * #coerce(other)
-#
-# String representations:
-# * #to_s
-# * #inspect
-#
-class Vector
- include ExceptionForMatrix
- include Enumerable
- include Matrix::CoercionHelper
- extend Matrix::ConversionHelper
- #INSTANCE CREATION
-
- private_class_method :new
- attr_reader :elements
- protected :elements
-
- #
- # Creates a Vector from a list of elements.
- # Vector[7, 4, ...]
- #
- def Vector.[](*array)
- new convert_to_array(array, false)
- end
-
- #
- # Creates a vector from an Array. The optional second argument specifies
- # whether the array itself or a copy is used internally.
- #
- def Vector.elements(array, copy = true)
- new convert_to_array(array, copy)
- end
-
- #
- # Returns a standard basis +n+-vector, where k is the index.
- #
- # Vector.basis(size:, index:) # => Vector[0, 1, 0]
- #
- def Vector.basis(size:, index:)
- raise ArgumentError, "invalid size (#{size} for 1..)" if size < 1
- raise ArgumentError, "invalid index (#{index} for 0...#{size})" unless 0 <= index && index < size
- array = Array.new(size, 0)
- array[index] = 1
- new convert_to_array(array, false)
- end
-
- #
- # Vector.new is private; use Vector[] or Vector.elements to create.
- #
- def initialize(array)
- # No checking is done at this point.
- @elements = array
- end
-
- # ACCESSING
-
- #
- # Returns element number +i+ (starting at zero) of the vector.
- #
- def [](i)
- @elements[i]
- end
- alias element []
- alias component []
-
- def []=(i, v)
- @elements[i]= v
- end
- alias set_element []=
- alias set_component []=
- private :[]=, :set_element, :set_component
-
- #
- # Returns the number of elements in the vector.
- #
- def size
- @elements.size
- end
-
- #--
- # ENUMERATIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Iterate over the elements of this vector
- #
- def each(&block)
- return to_enum(:each) unless block_given?
- @elements.each(&block)
- self
- end
-
- #
- # Iterate over the elements of this vector and +v+ in conjunction.
- #
- def each2(v) # :yield: e1, e2
- raise TypeError, "Integer is not like Vector" if v.kind_of?(Integer)
- Vector.Raise ErrDimensionMismatch if size != v.size
- return to_enum(:each2, v) unless block_given?
- size.times do |i|
- yield @elements[i], v[i]
- end
- self
- end
-
- #
- # Collects (as in Enumerable#collect) over the elements of this vector and +v+
- # in conjunction.
- #
- def collect2(v) # :yield: e1, e2
- raise TypeError, "Integer is not like Vector" if v.kind_of?(Integer)
- Vector.Raise ErrDimensionMismatch if size != v.size
- return to_enum(:collect2, v) unless block_given?
- Array.new(size) do |i|
- yield @elements[i], v[i]
- end
- end
-
- #--
- # PROPERTIES -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Returns +true+ iff all of vectors are linearly independent.
- #
- # Vector.independent?(Vector[1,0], Vector[0,1])
- # => true
- #
- # Vector.independent?(Vector[1,2], Vector[2,4])
- # => false
- #
- def Vector.independent?(*vs)
- vs.each do |v|
- raise TypeError, "expected Vector, got #{v.class}" unless v.is_a?(Vector)
- Vector.Raise ErrDimensionMismatch unless v.size == vs.first.size
- end
- return false if vs.count > vs.first.size
- Matrix[*vs].rank.eql?(vs.count)
- end
-
- #
- # Returns +true+ iff all of vectors are linearly independent.
- #
- # Vector[1,0].independent?(Vector[0,1])
- # => true
- #
- # Vector[1,2].independent?(Vector[2,4])
- # => false
- #
- def independent?(*vs)
- self.class.independent?(self, *vs)
- end
-
- #--
- # COMPARING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Returns +true+ iff the two vectors have the same elements in the same order.
- #
- def ==(other)
- return false unless Vector === other
- @elements == other.elements
- end
-
- def eql?(other)
- return false unless Vector === other
- @elements.eql? other.elements
- end
-
- #
- # Returns a copy of the vector.
- #
- def clone
- self.class.elements(@elements)
- end
-
- #
- # Returns a hash-code for the vector.
- #
- def hash
- @elements.hash
- end
-
- #--
- # ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Multiplies the vector by +x+, where +x+ is a number or another vector.
- #
- def *(x)
- case x
- when Numeric
- els = @elements.collect{|e| e * x}
- self.class.elements(els, false)
- when Matrix
- Matrix.column_vector(self) * x
- when Vector
- Vector.Raise ErrOperationNotDefined, "*", self.class, x.class
- else
- apply_through_coercion(x, __method__)
- end
- end
-
- #
- # Vector addition.
- #
- def +(v)
- case v
- when Vector
- Vector.Raise ErrDimensionMismatch if size != v.size
- els = collect2(v) {|v1, v2|
- v1 + v2
- }
- self.class.elements(els, false)
- when Matrix
- Matrix.column_vector(self) + v
- else
- apply_through_coercion(v, __method__)
- end
- end
-
- #
- # Vector subtraction.
- #
- def -(v)
- case v
- when Vector
- Vector.Raise ErrDimensionMismatch if size != v.size
- els = collect2(v) {|v1, v2|
- v1 - v2
- }
- self.class.elements(els, false)
- when Matrix
- Matrix.column_vector(self) - v
- else
- apply_through_coercion(v, __method__)
- end
- end
-
- #
- # Vector division.
- #
- def /(x)
- case x
- when Numeric
- els = @elements.collect{|e| e / x}
- self.class.elements(els, false)
- when Matrix, Vector
- Vector.Raise ErrOperationNotDefined, "/", self.class, x.class
- else
- apply_through_coercion(x, __method__)
- end
- end
-
- def +@
- self
- end
-
- def -@
- collect {|e| -e }
- end
-
- #--
- # VECTOR FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Returns the inner product of this vector with the other.
- # Vector[4,7].inner_product Vector[10,1] => 47
- #
- def inner_product(v)
- Vector.Raise ErrDimensionMismatch if size != v.size
-
- p = 0
- each2(v) {|v1, v2|
- p += v1 * v2.conj
- }
- p
- end
- alias_method :dot, :inner_product
-
- #
- # Returns the cross product of this vector with the others.
- # Vector[1, 0, 0].cross_product Vector[0, 1, 0] => Vector[0, 0, 1]
- #
- # It is generalized to other dimensions to return a vector perpendicular
- # to the arguments.
- # Vector[1, 2].cross_product # => Vector[-2, 1]
- # Vector[1, 0, 0, 0].cross_product(
- # Vector[0, 1, 0, 0],
- # Vector[0, 0, 1, 0]
- # ) #=> Vector[0, 0, 0, 1]
- #
- def cross_product(*vs)
- raise ErrOperationNotDefined, "cross product is not defined on vectors of dimension #{size}" unless size >= 2
- raise ArgumentError, "wrong number of arguments (#{vs.size} for #{size - 2})" unless vs.size == size - 2
- vs.each do |v|
- raise TypeError, "expected Vector, got #{v.class}" unless v.is_a? Vector
- Vector.Raise ErrDimensionMismatch unless v.size == size
- end
- case size
- when 2
- Vector[-@elements[1], @elements[0]]
- when 3
- v = vs[0]
- Vector[ v[2]*@elements[1] - v[1]*@elements[2],
- v[0]*@elements[2] - v[2]*@elements[0],
- v[1]*@elements[0] - v[0]*@elements[1] ]
- else
- rows = self, *vs, Array.new(size) {|i| Vector.basis(size: size, index: i) }
- Matrix.rows(rows).laplace_expansion(row: size - 1)
- end
- end
- alias_method :cross, :cross_product
-
- #
- # Like Array#collect.
- #
- def collect(&block) # :yield: e
- return to_enum(:collect) unless block_given?
- els = @elements.collect(&block)
- self.class.elements(els, false)
- end
- alias map collect
-
- #
- # Returns the modulus (Pythagorean distance) of the vector.
- # Vector[5,8,2].r => 9.643650761
- #
- def magnitude
- Math.sqrt(@elements.inject(0) {|v, e| v + e.abs2})
- end
- alias r magnitude
- alias norm magnitude
-
- #
- # Like Vector#collect2, but returns a Vector instead of an Array.
- #
- def map2(v, &block) # :yield: e1, e2
- return to_enum(:map2, v) unless block_given?
- els = collect2(v, &block)
- self.class.elements(els, false)
- end
-
- class ZeroVectorError < StandardError
- end
- #
- # Returns a new vector with the same direction but with norm 1.
- # v = Vector[5,8,2].normalize
- # # => Vector[0.5184758473652127, 0.8295613557843402, 0.20739033894608505]
- # v.norm => 1.0
- #
- def normalize
- n = magnitude
- raise ZeroVectorError, "Zero vectors can not be normalized" if n == 0
- self / n
- end
-
- #
- # Returns an angle with another vector. Result is within the [0...Math::PI].
- # Vector[1,0].angle_with(Vector[0,1])
- # # => Math::PI / 2
- #
- def angle_with(v)
- raise TypeError, "Expected a Vector, got a #{v.class}" unless v.is_a?(Vector)
- Vector.Raise ErrDimensionMismatch if size != v.size
- prod = magnitude * v.magnitude
- raise ZeroVectorError, "Can't get angle of zero vector" if prod == 0
-
- Math.acos( inner_product(v) / prod )
- end
-
- #--
- # CONVERTING
- #++
-
- #
- # Creates a single-row matrix from this vector.
- #
- def covector
- Matrix.row_vector(self)
- end
-
- #
- # Returns the elements of the vector in an array.
- #
- def to_a
- @elements.dup
- end
-
- def elements_to_f
- warn "#{caller(1)[0]}: warning: Vector#elements_to_f is deprecated"
- map(&:to_f)
- end
-
- def elements_to_i
- warn "#{caller(1)[0]}: warning: Vector#elements_to_i is deprecated"
- map(&:to_i)
- end
-
- def elements_to_r
- warn "#{caller(1)[0]}: warning: Vector#elements_to_r is deprecated"
- map(&:to_r)
- end
-
- #
- # The coerce method provides support for Ruby type coercion.
- # This coercion mechanism is used by Ruby to handle mixed-type
- # numeric operations: it is intended to find a compatible common
- # type between the two operands of the operator.
- # See also Numeric#coerce.
- #
- def coerce(other)
- case other
- when Numeric
- return Matrix::Scalar.new(other), self
- else
- raise TypeError, "#{self.class} can't be coerced into #{other.class}"
- end
- end
-
- #--
- # PRINTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #++
-
- #
- # Overrides Object#to_s
- #
- def to_s
- "Vector[" + @elements.join(", ") + "]"
- end
-
- #
- # Overrides Object#inspect
- #
- def inspect
- "Vector" + @elements.inspect
- end
-end
diff --git a/src/main/resources/stdlib/matrix/eigenvalue_decomposition.rb b/src/main/resources/stdlib/matrix/eigenvalue_decomposition.rb
deleted file mode 100644
index ab353ec..0000000
--- a/src/main/resources/stdlib/matrix/eigenvalue_decomposition.rb
+++ /dev/null
@@ -1,882 +0,0 @@
-class Matrix
- # Adapted from JAMA: http://math.nist.gov/javanumerics/jama/
-
- # Eigenvalues and eigenvectors of a real matrix.
- #
- # Computes the eigenvalues and eigenvectors of a matrix A.
- #
- # If A is diagonalizable, this provides matrices V and D
- # such that A = V*D*V.inv, where D is the diagonal matrix with entries
- # equal to the eigenvalues and V is formed by the eigenvectors.
- #
- # If A is symmetric, then V is orthogonal and thus A = V*D*V.t
-
- class EigenvalueDecomposition
-
- # Constructs the eigenvalue decomposition for a square matrix +A+
- #
- def initialize(a)
- # @d, @e: Arrays for internal storage of eigenvalues.
- # @v: Array for internal storage of eigenvectors.
- # @h: Array for internal storage of nonsymmetric Hessenberg form.
- raise TypeError, "Expected Matrix but got #{a.class}" unless a.is_a?(Matrix)
- @size = a.row_count
- @d = Array.new(@size, 0)
- @e = Array.new(@size, 0)
-
- if (@symmetric = a.symmetric?)
- @v = a.to_a
- tridiagonalize
- diagonalize
- else
- @v = Array.new(@size) { Array.new(@size, 0) }
- @h = a.to_a
- @ort = Array.new(@size, 0)
- reduce_to_hessenberg
- hessenberg_to_real_schur
- end
- end
-
- # Returns the eigenvector matrix +V+
- #
- def eigenvector_matrix
- Matrix.send(:new, build_eigenvectors.transpose)
- end
- alias v eigenvector_matrix
-
- # Returns the inverse of the eigenvector matrix +V+
- #
- def eigenvector_matrix_inv
- r = Matrix.send(:new, build_eigenvectors)
- r = r.transpose.inverse unless @symmetric
- r
- end
- alias v_inv eigenvector_matrix_inv
-
- # Returns the eigenvalues in an array
- #
- def eigenvalues
- values = @d.dup
- @e.each_with_index{|imag, i| values[i] = Complex(values[i], imag) unless imag == 0}
- values
- end
-
- # Returns an array of the eigenvectors
- #
- def eigenvectors
- build_eigenvectors.map{|ev| Vector.send(:new, ev)}
- end
-
- # Returns the block diagonal eigenvalue matrix +D+
- #
- def eigenvalue_matrix
- Matrix.diagonal(*eigenvalues)
- end
- alias d eigenvalue_matrix
-
- # Returns [eigenvector_matrix, eigenvalue_matrix, eigenvector_matrix_inv]
- #
- def to_ary
- [v, d, v_inv]
- end
- alias_method :to_a, :to_ary
-
- private
- def build_eigenvectors
- # JAMA stores complex eigenvectors in a strange way
- # See http://web.archive.org/web/20111016032731/http://cio.nist.gov/esd/emaildir/lists/jama/msg01021.html
- @e.each_with_index.map do |imag, i|
- if imag == 0
- Array.new(@size){|j| @v[j][i]}
- elsif imag > 0
- Array.new(@size){|j| Complex(@v[j][i], @v[j][i+1])}
- else
- Array.new(@size){|j| Complex(@v[j][i-1], -@v[j][i])}
- end
- end
- end
- # Complex scalar division.
-
- def cdiv(xr, xi, yr, yi)
- if (yr.abs > yi.abs)
- r = yi/yr
- d = yr + r*yi
- [(xr + r*xi)/d, (xi - r*xr)/d]
- else
- r = yr/yi
- d = yi + r*yr
- [(r*xr + xi)/d, (r*xi - xr)/d]
- end
- end
-
-
- # Symmetric Householder reduction to tridiagonal form.
-
- def tridiagonalize
-
- # This is derived from the Algol procedures tred2 by
- # Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
- # Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
- # Fortran subroutine in EISPACK.
-
- @size.times do |j|
- @d[j] = @v[@size-1][j]
- end
-
- # Householder reduction to tridiagonal form.
-
- (@size-1).downto(0+1) do |i|
-
- # Scale to avoid under/overflow.
-
- scale = 0.0
- h = 0.0
- i.times do |k|
- scale = scale + @d[k].abs
- end
- if (scale == 0.0)
- @e[i] = @d[i-1]
- i.times do |j|
- @d[j] = @v[i-1][j]
- @v[i][j] = 0.0
- @v[j][i] = 0.0
- end
- else
-
- # Generate Householder vector.
-
- i.times do |k|
- @d[k] /= scale
- h += @d[k] * @d[k]
- end
- f = @d[i-1]
- g = Math.sqrt(h)
- if (f > 0)
- g = -g
- end
- @e[i] = scale * g
- h -= f * g
- @d[i-1] = f - g
- i.times do |j|
- @e[j] = 0.0
- end
-
- # Apply similarity transformation to remaining columns.
-
- i.times do |j|
- f = @d[j]
- @v[j][i] = f
- g = @e[j] + @v[j][j] * f
- (j+1).upto(i-1) do |k|
- g += @v[k][j] * @d[k]
- @e[k] += @v[k][j] * f
- end
- @e[j] = g
- end
- f = 0.0
- i.times do |j|
- @e[j] /= h
- f += @e[j] * @d[j]
- end
- hh = f / (h + h)
- i.times do |j|
- @e[j] -= hh * @d[j]
- end
- i.times do |j|
- f = @d[j]
- g = @e[j]
- j.upto(i-1) do |k|
- @v[k][j] -= (f * @e[k] + g * @d[k])
- end
- @d[j] = @v[i-1][j]
- @v[i][j] = 0.0
- end
- end
- @d[i] = h
- end
-
- # Accumulate transformations.
-
- 0.upto(@size-1-1) do |i|
- @v[@size-1][i] = @v[i][i]
- @v[i][i] = 1.0
- h = @d[i+1]
- if (h != 0.0)
- 0.upto(i) do |k|
- @d[k] = @v[k][i+1] / h
- end
- 0.upto(i) do |j|
- g = 0.0
- 0.upto(i) do |k|
- g += @v[k][i+1] * @v[k][j]
- end
- 0.upto(i) do |k|
- @v[k][j] -= g * @d[k]
- end
- end
- end
- 0.upto(i) do |k|
- @v[k][i+1] = 0.0
- end
- end
- @size.times do |j|
- @d[j] = @v[@size-1][j]
- @v[@size-1][j] = 0.0
- end
- @v[@size-1][@size-1] = 1.0
- @e[0] = 0.0
- end
-
-
- # Symmetric tridiagonal QL algorithm.
-
- def diagonalize
- # This is derived from the Algol procedures tql2, by
- # Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
- # Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
- # Fortran subroutine in EISPACK.
-
- 1.upto(@size-1) do |i|
- @e[i-1] = @e[i]
- end
- @e[@size-1] = 0.0
-
- f = 0.0
- tst1 = 0.0
- eps = Float::EPSILON
- @size.times do |l|
-
- # Find small subdiagonal element
-
- tst1 = [tst1, @d[l].abs + @e[l].abs].max
- m = l
- while (m < @size) do
- if (@e[m].abs <= eps*tst1)
- break
- end
- m+=1
- end
-
- # If m == l, @d[l] is an eigenvalue,
- # otherwise, iterate.
-
- if (m > l)
- iter = 0
- begin
- iter = iter + 1 # (Could check iteration count here.)
-
- # Compute implicit shift
-
- g = @d[l]
- p = (@d[l+1] - g) / (2.0 * @e[l])
- r = Math.hypot(p, 1.0)
- if (p < 0)
- r = -r
- end
- @d[l] = @e[l] / (p + r)
- @d[l+1] = @e[l] * (p + r)
- dl1 = @d[l+1]
- h = g - @d[l]
- (l+2).upto(@size-1) do |i|
- @d[i] -= h
- end
- f += h
-
- # Implicit QL transformation.
-
- p = @d[m]
- c = 1.0
- c2 = c
- c3 = c
- el1 = @e[l+1]
- s = 0.0
- s2 = 0.0
- (m-1).downto(l) do |i|
- c3 = c2
- c2 = c
- s2 = s
- g = c * @e[i]
- h = c * p
- r = Math.hypot(p, @e[i])
- @e[i+1] = s * r
- s = @e[i] / r
- c = p / r
- p = c * @d[i] - s * g
- @d[i+1] = h + s * (c * g + s * @d[i])
-
- # Accumulate transformation.
-
- @size.times do |k|
- h = @v[k][i+1]
- @v[k][i+1] = s * @v[k][i] + c * h
- @v[k][i] = c * @v[k][i] - s * h
- end
- end
- p = -s * s2 * c3 * el1 * @e[l] / dl1
- @e[l] = s * p
- @d[l] = c * p
-
- # Check for convergence.
-
- end while (@e[l].abs > eps*tst1)
- end
- @d[l] = @d[l] + f
- @e[l] = 0.0
- end
-
- # Sort eigenvalues and corresponding vectors.
-
- 0.upto(@size-2) do |i|
- k = i
- p = @d[i]
- (i+1).upto(@size-1) do |j|
- if (@d[j] < p)
- k = j
- p = @d[j]
- end
- end
- if (k != i)
- @d[k] = @d[i]
- @d[i] = p
- @size.times do |j|
- p = @v[j][i]
- @v[j][i] = @v[j][k]
- @v[j][k] = p
- end
- end
- end
- end
-
- # Nonsymmetric reduction to Hessenberg form.
-
- def reduce_to_hessenberg
- # This is derived from the Algol procedures orthes and ortran,
- # by Martin and Wilkinson, Handbook for Auto. Comp.,
- # Vol.ii-Linear Algebra, and the corresponding
- # Fortran subroutines in EISPACK.
-
- low = 0
- high = @size-1
-
- (low+1).upto(high-1) do |m|
-
- # Scale column.
-
- scale = 0.0
- m.upto(high) do |i|
- scale = scale + @h[i][m-1].abs
- end
- if (scale != 0.0)
-
- # Compute Householder transformation.
-
- h = 0.0
- high.downto(m) do |i|
- @ort[i] = @h[i][m-1]/scale
- h += @ort[i] * @ort[i]
- end
- g = Math.sqrt(h)
- if (@ort[m] > 0)
- g = -g
- end
- h -= @ort[m] * g
- @ort[m] = @ort[m] - g
-
- # Apply Householder similarity transformation
- # @h = (I-u*u'/h)*@h*(I-u*u')/h)
-
- m.upto(@size-1) do |j|
- f = 0.0
- high.downto(m) do |i|
- f += @ort[i]*@h[i][j]
- end
- f = f/h
- m.upto(high) do |i|
- @h[i][j] -= f*@ort[i]
- end
- end
-
- 0.upto(high) do |i|
- f = 0.0
- high.downto(m) do |j|
- f += @ort[j]*@h[i][j]
- end
- f = f/h
- m.upto(high) do |j|
- @h[i][j] -= f*@ort[j]
- end
- end
- @ort[m] = scale*@ort[m]
- @h[m][m-1] = scale*g
- end
- end
-
- # Accumulate transformations (Algol's ortran).
-
- @size.times do |i|
- @size.times do |j|
- @v[i][j] = (i == j ? 1.0 : 0.0)
- end
- end
-
- (high-1).downto(low+1) do |m|
- if (@h[m][m-1] != 0.0)
- (m+1).upto(high) do |i|
- @ort[i] = @h[i][m-1]
- end
- m.upto(high) do |j|
- g = 0.0
- m.upto(high) do |i|
- g += @ort[i] * @v[i][j]
- end
- # Double division avoids possible underflow
- g = (g / @ort[m]) / @h[m][m-1]
- m.upto(high) do |i|
- @v[i][j] += g * @ort[i]
- end
- end
- end
- end
- end
-
-
-
- # Nonsymmetric reduction from Hessenberg to real Schur form.
-
- def hessenberg_to_real_schur
-
- # This is derived from the Algol procedure hqr2,
- # by Martin and Wilkinson, Handbook for Auto. Comp.,
- # Vol.ii-Linear Algebra, and the corresponding
- # Fortran subroutine in EISPACK.
-
- # Initialize
-
- nn = @size
- n = nn-1
- low = 0
- high = nn-1
- eps = Float::EPSILON
- exshift = 0.0
- p=q=r=s=z=0
-
- # Store roots isolated by balanc and compute matrix norm
-
- norm = 0.0
- nn.times do |i|
- if (i < low || i > high)
- @d[i] = @h[i][i]
- @e[i] = 0.0
- end
- ([i-1, 0].max).upto(nn-1) do |j|
- norm = norm + @h[i][j].abs
- end
- end
-
- # Outer loop over eigenvalue index
-
- iter = 0
- while (n >= low) do
-
- # Look for single small sub-diagonal element
-
- l = n
- while (l > low) do
- s = @h[l-1][l-1].abs + @h[l][l].abs
- if (s == 0.0)
- s = norm
- end
- if (@h[l][l-1].abs < eps * s)
- break
- end
- l-=1
- end
-
- # Check for convergence
- # One root found
-
- if (l == n)
- @h[n][n] = @h[n][n] + exshift
- @d[n] = @h[n][n]
- @e[n] = 0.0
- n-=1
- iter = 0
-
- # Two roots found
-
- elsif (l == n-1)
- w = @h[n][n-1] * @h[n-1][n]
- p = (@h[n-1][n-1] - @h[n][n]) / 2.0
- q = p * p + w
- z = Math.sqrt(q.abs)
- @h[n][n] = @h[n][n] + exshift
- @h[n-1][n-1] = @h[n-1][n-1] + exshift
- x = @h[n][n]
-
- # Real pair
-
- if (q >= 0)
- if (p >= 0)
- z = p + z
- else
- z = p - z
- end
- @d[n-1] = x + z
- @d[n] = @d[n-1]
- if (z != 0.0)
- @d[n] = x - w / z
- end
- @e[n-1] = 0.0
- @e[n] = 0.0
- x = @h[n][n-1]
- s = x.abs + z.abs
- p = x / s
- q = z / s
- r = Math.sqrt(p * p+q * q)
- p /= r
- q /= r
-
- # Row modification
-
- (n-1).upto(nn-1) do |j|
- z = @h[n-1][j]
- @h[n-1][j] = q * z + p * @h[n][j]
- @h[n][j] = q * @h[n][j] - p * z
- end
-
- # Column modification
-
- 0.upto(n) do |i|
- z = @h[i][n-1]
- @h[i][n-1] = q * z + p * @h[i][n]
- @h[i][n] = q * @h[i][n] - p * z
- end
-
- # Accumulate transformations
-
- low.upto(high) do |i|
- z = @v[i][n-1]
- @v[i][n-1] = q * z + p * @v[i][n]
- @v[i][n] = q * @v[i][n] - p * z
- end
-
- # Complex pair
-
- else
- @d[n-1] = x + p
- @d[n] = x + p
- @e[n-1] = z
- @e[n] = -z
- end
- n -= 2
- iter = 0
-
- # No convergence yet
-
- else
-
- # Form shift
-
- x = @h[n][n]
- y = 0.0
- w = 0.0
- if (l < n)
- y = @h[n-1][n-1]
- w = @h[n][n-1] * @h[n-1][n]
- end
-
- # Wilkinson's original ad hoc shift
-
- if (iter == 10)
- exshift += x
- low.upto(n) do |i|
- @h[i][i] -= x
- end
- s = @h[n][n-1].abs + @h[n-1][n-2].abs
- x = y = 0.75 * s
- w = -0.4375 * s * s
- end
-
- # MATLAB's new ad hoc shift
-
- if (iter == 30)
- s = (y - x) / 2.0
- s *= s + w
- if (s > 0)
- s = Math.sqrt(s)
- if (y < x)
- s = -s
- end
- s = x - w / ((y - x) / 2.0 + s)
- low.upto(n) do |i|
- @h[i][i] -= s
- end
- exshift += s
- x = y = w = 0.964
- end
- end
-
- iter = iter + 1 # (Could check iteration count here.)
-
- # Look for two consecutive small sub-diagonal elements
-
- m = n-2
- while (m >= l) do
- z = @h[m][m]
- r = x - z
- s = y - z
- p = (r * s - w) / @h[m+1][m] + @h[m][m+1]
- q = @h[m+1][m+1] - z - r - s
- r = @h[m+2][m+1]
- s = p.abs + q.abs + r.abs
- p /= s
- q /= s
- r /= s
- if (m == l)
- break
- end
- if (@h[m][m-1].abs * (q.abs + r.abs) <
- eps * (p.abs * (@h[m-1][m-1].abs + z.abs +
- @h[m+1][m+1].abs)))
- break
- end
- m-=1
- end
-
- (m+2).upto(n) do |i|
- @h[i][i-2] = 0.0
- if (i > m+2)
- @h[i][i-3] = 0.0
- end
- end
-
- # Double QR step involving rows l:n and columns m:n
-
- m.upto(n-1) do |k|
- notlast = (k != n-1)
- if (k != m)
- p = @h[k][k-1]
- q = @h[k+1][k-1]
- r = (notlast ? @h[k+2][k-1] : 0.0)
- x = p.abs + q.abs + r.abs
- next if x == 0
- p /= x
- q /= x
- r /= x
- end
- s = Math.sqrt(p * p + q * q + r * r)
- if (p < 0)
- s = -s
- end
- if (s != 0)
- if (k != m)
- @h[k][k-1] = -s * x
- elsif (l != m)
- @h[k][k-1] = -@h[k][k-1]
- end
- p += s
- x = p / s
- y = q / s
- z = r / s
- q /= p
- r /= p
-
- # Row modification
-
- k.upto(nn-1) do |j|
- p = @h[k][j] + q * @h[k+1][j]
- if (notlast)
- p += r * @h[k+2][j]
- @h[k+2][j] = @h[k+2][j] - p * z
- end
- @h[k][j] = @h[k][j] - p * x
- @h[k+1][j] = @h[k+1][j] - p * y
- end
-
- # Column modification
-
- 0.upto([n, k+3].min) do |i|
- p = x * @h[i][k] + y * @h[i][k+1]
- if (notlast)
- p += z * @h[i][k+2]
- @h[i][k+2] = @h[i][k+2] - p * r
- end
- @h[i][k] = @h[i][k] - p
- @h[i][k+1] = @h[i][k+1] - p * q
- end
-
- # Accumulate transformations
-
- low.upto(high) do |i|
- p = x * @v[i][k] + y * @v[i][k+1]
- if (notlast)
- p += z * @v[i][k+2]
- @v[i][k+2] = @v[i][k+2] - p * r
- end
- @v[i][k] = @v[i][k] - p
- @v[i][k+1] = @v[i][k+1] - p * q
- end
- end # (s != 0)
- end # k loop
- end # check convergence
- end # while (n >= low)
-
- # Backsubstitute to find vectors of upper triangular form
-
- if (norm == 0.0)
- return
- end
-
- (nn-1).downto(0) do |n|
- p = @d[n]
- q = @e[n]
-
- # Real vector
-
- if (q == 0)
- l = n
- @h[n][n] = 1.0
- (n-1).downto(0) do |i|
- w = @h[i][i] - p
- r = 0.0
- l.upto(n) do |j|
- r += @h[i][j] * @h[j][n]
- end
- if (@e[i] < 0.0)
- z = w
- s = r
- else
- l = i
- if (@e[i] == 0.0)
- if (w != 0.0)
- @h[i][n] = -r / w
- else
- @h[i][n] = -r / (eps * norm)
- end
-
- # Solve real equations
-
- else
- x = @h[i][i+1]
- y = @h[i+1][i]
- q = (@d[i] - p) * (@d[i] - p) + @e[i] * @e[i]
- t = (x * s - z * r) / q
- @h[i][n] = t
- if (x.abs > z.abs)
- @h[i+1][n] = (-r - w * t) / x
- else
- @h[i+1][n] = (-s - y * t) / z
- end
- end
-
- # Overflow control
-
- t = @h[i][n].abs
- if ((eps * t) * t > 1)
- i.upto(n) do |j|
- @h[j][n] = @h[j][n] / t
- end
- end
- end
- end
-
- # Complex vector
-
- elsif (q < 0)
- l = n-1
-
- # Last vector component imaginary so matrix is triangular
-
- if (@h[n][n-1].abs > @h[n-1][n].abs)
- @h[n-1][n-1] = q / @h[n][n-1]
- @h[n-1][n] = -(@h[n][n] - p) / @h[n][n-1]
- else
- cdivr, cdivi = cdiv(0.0, -@h[n-1][n], @h[n-1][n-1]-p, q)
- @h[n-1][n-1] = cdivr
- @h[n-1][n] = cdivi
- end
- @h[n][n-1] = 0.0
- @h[n][n] = 1.0
- (n-2).downto(0) do |i|
- ra = 0.0
- sa = 0.0
- l.upto(n) do |j|
- ra = ra + @h[i][j] * @h[j][n-1]
- sa = sa + @h[i][j] * @h[j][n]
- end
- w = @h[i][i] - p
-
- if (@e[i] < 0.0)
- z = w
- r = ra
- s = sa
- else
- l = i
- if (@e[i] == 0)
- cdivr, cdivi = cdiv(-ra, -sa, w, q)
- @h[i][n-1] = cdivr
- @h[i][n] = cdivi
- else
-
- # Solve complex equations
-
- x = @h[i][i+1]
- y = @h[i+1][i]
- vr = (@d[i] - p) * (@d[i] - p) + @e[i] * @e[i] - q * q
- vi = (@d[i] - p) * 2.0 * q
- if (vr == 0.0 && vi == 0.0)
- vr = eps * norm * (w.abs + q.abs +
- x.abs + y.abs + z.abs)
- end
- cdivr, cdivi = cdiv(x*r-z*ra+q*sa, x*s-z*sa-q*ra, vr, vi)
- @h[i][n-1] = cdivr
- @h[i][n] = cdivi
- if (x.abs > (z.abs + q.abs))
- @h[i+1][n-1] = (-ra - w * @h[i][n-1] + q * @h[i][n]) / x
- @h[i+1][n] = (-sa - w * @h[i][n] - q * @h[i][n-1]) / x
- else
- cdivr, cdivi = cdiv(-r-y*@h[i][n-1], -s-y*@h[i][n], z, q)
- @h[i+1][n-1] = cdivr
- @h[i+1][n] = cdivi
- end
- end
-
- # Overflow control
-
- t = [@h[i][n-1].abs, @h[i][n].abs].max
- if ((eps * t) * t > 1)
- i.upto(n) do |j|
- @h[j][n-1] = @h[j][n-1] / t
- @h[j][n] = @h[j][n] / t
- end
- end
- end
- end
- end
- end
-
- # Vectors of isolated roots
-
- nn.times do |i|
- if (i < low || i > high)
- i.upto(nn-1) do |j|
- @v[i][j] = @h[i][j]
- end
- end
- end
-
- # Back transformation to get eigenvectors of original matrix
-
- (nn-1).downto(low) do |j|
- low.upto(high) do |i|
- z = 0.0
- low.upto([j, high].min) do |k|
- z += @v[i][k] * @h[k][j]
- end
- @v[i][j] = z
- end
- end
- end
-
- end
-end
diff --git a/src/main/resources/stdlib/matrix/lup_decomposition.rb b/src/main/resources/stdlib/matrix/lup_decomposition.rb
deleted file mode 100644
index 30f3276..0000000
--- a/src/main/resources/stdlib/matrix/lup_decomposition.rb
+++ /dev/null
@@ -1,218 +0,0 @@
-class Matrix
- # Adapted from JAMA: http://math.nist.gov/javanumerics/jama/
-
- #
- # For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n
- # unit lower triangular matrix L, an n-by-n upper triangular matrix U,
- # and a m-by-m permutation matrix P so that L*U = P*A.
- # If m < n, then L is m-by-m and U is m-by-n.
- #
- # The LUP decomposition with pivoting always exists, even if the matrix is
- # singular, so the constructor will never fail. The primary use of the
- # LU decomposition is in the solution of square systems of simultaneous
- # linear equations. This will fail if singular? returns true.
- #
-
- class LUPDecomposition
- # Returns the lower triangular factor +L+
-
- include Matrix::ConversionHelper
-
- def l
- Matrix.build(@row_count, [@column_count, @row_count].min) do |i, j|
- if (i > j)
- @lu[i][j]
- elsif (i == j)
- 1
- else
- 0
- end
- end
- end
-
- # Returns the upper triangular factor +U+
-
- def u
- Matrix.build([@column_count, @row_count].min, @column_count) do |i, j|
- if (i <= j)
- @lu[i][j]
- else
- 0
- end
- end
- end
-
- # Returns the permutation matrix +P+
-
- def p
- rows = Array.new(@row_count){Array.new(@row_count, 0)}
- @pivots.each_with_index{|p, i| rows[i][p] = 1}
- Matrix.send :new, rows, @row_count
- end
-
- # Returns +L+, +U+, +P+ in an array
-
- def to_ary
- [l, u, p]
- end
- alias_method :to_a, :to_ary
-
- # Returns the pivoting indices
-
- attr_reader :pivots
-
- # Returns +true+ if +U+, and hence +A+, is singular.
-
- def singular? ()
- @column_count.times do |j|
- if (@lu[j][j] == 0)
- return true
- end
- end
- false
- end
-
- # Returns the determinant of +A+, calculated efficiently
- # from the factorization.
-
- def det
- if (@row_count != @column_count)
- Matrix.Raise Matrix::ErrDimensionMismatch
- end
- d = @pivot_sign
- @column_count.times do |j|
- d *= @lu[j][j]
- end
- d
- end
- alias_method :determinant, :det
-
- # Returns +m+ so that A*m = b,
- # or equivalently so that L*U*m = P*b
- # +b+ can be a Matrix or a Vector
-
- def solve b
- if (singular?)
- Matrix.Raise Matrix::ErrNotRegular, "Matrix is singular."
- end
- if b.is_a? Matrix
- if (b.row_count != @row_count)
- Matrix.Raise Matrix::ErrDimensionMismatch
- end
-
- # Copy right hand side with pivoting
- nx = b.column_count
- m = @pivots.map{|row| b.row(row).to_a}
-
- # Solve L*Y = P*b
- @column_count.times do |k|
- (k+1).upto(@column_count-1) do |i|
- nx.times do |j|
- m[i][j] -= m[k][j]*@lu[i][k]
- end
- end
- end
- # Solve U*m = Y
- (@column_count-1).downto(0) do |k|
- nx.times do |j|
- m[k][j] = m[k][j].quo(@lu[k][k])
- end
- k.times do |i|
- nx.times do |j|
- m[i][j] -= m[k][j]*@lu[i][k]
- end
- end
- end
- Matrix.send :new, m, nx
- else # same algorithm, specialized for simpler case of a vector
- b = convert_to_array(b)
- if (b.size != @row_count)
- Matrix.Raise Matrix::ErrDimensionMismatch
- end
-
- # Copy right hand side with pivoting
- m = b.values_at(*@pivots)
-
- # Solve L*Y = P*b
- @column_count.times do |k|
- (k+1).upto(@column_count-1) do |i|
- m[i] -= m[k]*@lu[i][k]
- end
- end
- # Solve U*m = Y
- (@column_count-1).downto(0) do |k|
- m[k] = m[k].quo(@lu[k][k])
- k.times do |i|
- m[i] -= m[k]*@lu[i][k]
- end
- end
- Vector.elements(m, false)
- end
- end
-
- def initialize a
- raise TypeError, "Expected Matrix but got #{a.class}" unless a.is_a?(Matrix)
- # Use a "left-looking", dot-product, Crout/Doolittle algorithm.
- @lu = a.to_a
- @row_count = a.row_count
- @column_count = a.column_count
- @pivots = Array.new(@row_count)
- @row_count.times do |i|
- @pivots[i] = i
- end
- @pivot_sign = 1
- lu_col_j = Array.new(@row_count)
-
- # Outer loop.
-
- @column_count.times do |j|
-
- # Make a copy of the j-th column to localize references.
-
- @row_count.times do |i|
- lu_col_j[i] = @lu[i][j]
- end
-
- # Apply previous transformations.
-
- @row_count.times do |i|
- lu_row_i = @lu[i]
-
- # Most of the time is spent in the following dot product.
-
- kmax = [i, j].min
- s = 0
- kmax.times do |k|
- s += lu_row_i[k]*lu_col_j[k]
- end
-
- lu_row_i[j] = lu_col_j[i] -= s
- end
-
- # Find pivot and exchange if necessary.
-
- p = j
- (j+1).upto(@row_count-1) do |i|
- if (lu_col_j[i].abs > lu_col_j[p].abs)
- p = i
- end
- end
- if (p != j)
- @column_count.times do |k|
- t = @lu[p][k]; @lu[p][k] = @lu[j][k]; @lu[j][k] = t
- end
- k = @pivots[p]; @pivots[p] = @pivots[j]; @pivots[j] = k
- @pivot_sign = -@pivot_sign
- end
-
- # Compute multipliers.
-
- if (j < @row_count && @lu[j][j] != 0)
- (j+1).upto(@row_count-1) do |i|
- @lu[i][j] = @lu[i][j].quo(@lu[j][j])
- end
- end
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/maven.rb b/src/main/resources/stdlib/maven.rb
deleted file mode 100644
index ee46b3f..0000000
--- a/src/main/resources/stdlib/maven.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-module Maven
-
- VERSION = '3.3.3'.freeze
-
- def self.exec( *args )
- if args.member?( '-Dverbose=true' ) || args.member?( '-Dverbose' ) || args.member?( '-X' )
- puts "mvn #{args.join(' ')}"
- end
- system "#{Maven.bin( 'mvn' )} #{args.join( ' ' )}"
- end
-
- def self.home
- @home ||= begin
- dir = File.dirname( File.expand_path( __FILE__ ) )
- File.expand_path( "#{dir}/../maven-home" )
- end
- end
-
- def self.bin( file = nil )
- if file
- File.join( path( 'bin' ), file )
- else
- path( 'bin' )
- end
- end
-
- def self.lib
- path( 'lib' )
- end
-
- def self.conf
- path( 'conf' )
- end
-
- def self.boot
- path( 'boot' )
- end
-
- private
-
- def self.path( name )
- File.join( home, name )
- end
-end
diff --git a/src/main/resources/stdlib/maven/ruby.rb b/src/main/resources/stdlib/maven/ruby.rb
deleted file mode 100644
index 716a770..0000000
--- a/src/main/resources/stdlib/maven/ruby.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright (C) 2013 Christian Meier
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-# the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-require 'maven/ruby/maven'
diff --git a/src/main/resources/stdlib/maven/ruby/maven.rb b/src/main/resources/stdlib/maven/ruby/maven.rb
deleted file mode 100644
index 4488d0b..0000000
--- a/src/main/resources/stdlib/maven/ruby/maven.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-#
-# Copyright (C) 2013 Christian Meier
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-# the Software, and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-require 'ruby_maven'
-require 'fileutils'
-
-module Maven
- module Ruby
- class Maven
-
- attr_accessor :embedded
-
- private
-
- def options_array
- options.collect do |k,v|
- if k =~ /^-D/
- v = "=#{v}" unless v.nil?
- "#{k}#{v}"
- else
- if v.nil?
- "#{k}"
- else
- ["#{k}", "#{v}"]
- end
- end
- end.flatten
- end
-
- public
-
- def initialize( project = nil, temp_pom = nil )
- super()
-
- if project
- warn 'deprecated: End Of Life - just tell maven where your (ruby) pom is'
- begin
- require 'maven/tools/model'
- require 'maven/tools/visitor'
- rescue LoadError => e
- warn 'maven-tools gem is not a direct dependency anymore'
- raise e
- end
- f = File.expand_path( temp_pom || '.pom.xml' )
- v = ::Maven::Tools::Visitor.new( File.open( f, 'w' ) )
- # parse project and write out to temp_pom file
- v.accept_project( project )
- # tell maven to use the generated file
- options[ '-f' ] = f
- @embedded = true
- end
- end
-
- def options
- @options ||= {}
- end
-
- def <<( v )
- options[ v ] = nil
- end
-
- def verbose= v
- @verbose = v
- end
-
- def property(key, value = nil)
- options["-D#{key}"] = value
- end
- alias :[]= :property
-
- def verbose
- if @verbose.nil?
- @verbose = options.delete('-Dverbose').to_s == 'true'
- else
- @verbose
- end
- end
-
- def exec(*args)
- if verbose
- puts "mvn #{args.join(' ')}"
- end
-
- result = RubyMaven.exec( *(args + options_array) )
- if @embedded and not result
- # TODO remove this when the embedded case is gone
- raise "error in executing maven #{result}"
- else
- result
- end
- end
-
- def method_missing( method, *args )
- method = method.to_s.gsub( /_/, '-' ).to_sym
- exec( *([ method ] + args) )
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/maven/ruby/tasks.rb b/src/main/resources/stdlib/maven/ruby/tasks.rb
deleted file mode 100644
index 08e1a9b..0000000
--- a/src/main/resources/stdlib/maven/ruby/tasks.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require 'maven/ruby/maven'
-require 'rake'
-
-warn 'deprecated: maven rake tasks is enf of life'
-
-module Maven
- class Tasks
- include Rake::DSL
-
- def install
-
- desc "Setup Maven instance."
- task :maven do
- end
-
- desc "Clean up the build directory."
- task :clean => :maven do
- maven.clean
- end
-
- desc "Run the java unit tests from src/test/java directory."
- task :junit => :maven do
- maven.exec( 'compile', 'resources:testResources', 'compiler:testCompile', 'surefire:test' )
- end
-
- desc "Build gem into the pkg directory."
- task :build => :maven do
- maven.package( '-Dmaven.test.skip' )
- end
-
- desc "Compile any java source configured - default java files are in src/main/java."
- task :compile => :maven do
- maven.compile
- end
-
- desc "Package jar-file with the compiled classes - default jar-file lib/{name}.jar"
- task :jar => :maven do
- maven.prepare_package( '-Dmaven.test.skip' )
- end
-
- desc "Push gem to rubygems.org"
- task :push => :maven do
- maven.deploy( '-Dmaven.test.skip' )
- end
- end
- end
- Tasks.new.install
-end
-
-def maven
- unless @__maven__
- @__maven__ = Maven::Ruby::Maven.new
- @__maven__.embedded = true
- end
- @__maven__
-end
diff --git a/src/main/resources/stdlib/maven/ruby/version.rb b/src/main/resources/stdlib/maven/ruby/version.rb
deleted file mode 100644
index f680606..0000000
--- a/src/main/resources/stdlib/maven/ruby/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module Maven
- module Ruby
- VERSION = '3.3.3'.freeze
- end
-end
diff --git a/src/main/resources/stdlib/minitest.rb b/src/main/resources/stdlib/minitest.rb
deleted file mode 100644
index 5f06005..0000000
--- a/src/main/resources/stdlib/minitest.rb
+++ /dev/null
@@ -1,765 +0,0 @@
-require "optparse"
-require "thread"
-require "mutex_m"
-require "minitest/parallel"
-
-##
-# :include: README.txt
-
-module Minitest
- VERSION = "5.4.1" # :nodoc:
-
- @@installed_at_exit ||= false
- @@after_run = []
- @extensions = []
-
- mc = (class << self; self; end)
-
- ##
- # Parallel test executor
-
- mc.send :attr_accessor, :parallel_executor
- self.parallel_executor = Parallel::Executor.new((ENV['N'] || 2).to_i)
-
- ##
- # Filter object for backtraces.
-
- mc.send :attr_accessor, :backtrace_filter
-
- ##
- # Reporter object to be used for all runs.
- #
- # NOTE: This accessor is only available during setup, not during runs.
-
- mc.send :attr_accessor, :reporter
-
- ##
- # Names of known extension plugins.
-
- mc.send :attr_accessor, :extensions
-
- ##
- # Registers Minitest to run at process exit
-
- def self.autorun
- at_exit {
- next if $! and not ($!.kind_of? SystemExit and $!.success?)
-
- exit_code = nil
-
- at_exit {
- @@after_run.reverse_each(&:call)
- exit exit_code || false
- }
-
- exit_code = Minitest.run ARGV
- } unless @@installed_at_exit
- @@installed_at_exit = true
- end
-
- ##
- # A simple hook allowing you to run a block of code after everything
- # is done running. Eg:
- #
- # Minitest.after_run { p $debugging_info }
-
- def self.after_run &block
- @@after_run << block
- end
-
- def self.init_plugins options # :nodoc:
- self.extensions.each do |name|
- msg = "plugin_#{name}_init"
- send msg, options if self.respond_to? msg
- end
- end
-
- def self.load_plugins # :nodoc:
- return unless self.extensions.empty?
-
- seen = {}
-
- require "rubygems" unless defined? Gem
-
- Gem.find_files("minitest/*_plugin.rb").each do |plugin_path|
- name = File.basename plugin_path, "_plugin.rb"
-
- next if seen[name]
- seen[name] = true
-
- require plugin_path
- self.extensions << name
- end
- end
-
- ##
- # This is the top-level run method. Everything starts from here. It
- # tells each Runnable sub-class to run, and each of those are
- # responsible for doing whatever they do.
- #
- # The overall structure of a run looks like this:
- #
- # Minitest.autorun
- # Minitest.run(args)
- # Minitest.__run(reporter, options)
- # Runnable.runnables.each
- # runnable.run(reporter, options)
- # self.runnable_methods.each
- # self.run_one_method(self, runnable_method, reporter)
- # Minitest.run_one_method(klass, runnable_method, reporter)
- # klass.new(runnable_method).run
-
- def self.run args = []
- self.load_plugins
-
- options = process_args args
-
- reporter = CompositeReporter.new
- reporter << SummaryReporter.new(options[:io], options)
- reporter << ProgressReporter.new(options[:io], options)
-
- self.reporter = reporter # this makes it available to plugins
- self.init_plugins options
- self.reporter = nil # runnables shouldn't depend on the reporter, ever
-
- reporter.start
- __run reporter, options
- self.parallel_executor.shutdown
- reporter.report
-
- reporter.passed?
- end
-
- ##
- # Internal run method. Responsible for telling all Runnable
- # sub-classes to run.
- #
- # NOTE: this method is redefined in parallel_each.rb, which is
- # loaded if a Runnable calls parallelize_me!.
-
- def self.__run reporter, options
- suites = Runnable.runnables.shuffle
- parallel, serial = suites.partition { |s| s.test_order == :parallel }
-
- # If we run the parallel tests before the serial tests, the parallel tests
- # could run in parallel with the serial tests. This would be bad because
- # the serial tests won't lock around Reporter#record. Run the serial tests
- # first, so that after they complete, the parallel tests will lock when
- # recording results.
- serial.map { |suite| suite.run reporter, options } +
- parallel.map { |suite| suite.run reporter, options }
- end
-
- def self.process_args args = [] # :nodoc:
- options = {
- :io => $stdout,
- }
- orig_args = args.dup
-
- OptionParser.new do |opts|
- opts.banner = "minitest options:"
- opts.version = Minitest::VERSION
-
- opts.on "-h", "--help", "Display this help." do
- puts opts
- exit
- end
-
- opts.on "-s", "--seed SEED", Integer, "Sets random seed" do |m|
- options[:seed] = m.to_i
- end
-
- opts.on "-v", "--verbose", "Verbose. Show progress processing files." do
- options[:verbose] = true
- end
-
- opts.on "-n", "--name PATTERN","Filter run on /pattern/ or string." do |a|
- options[:filter] = a
- end
-
- unless extensions.empty?
- opts.separator ""
- opts.separator "Known extensions: #{extensions.join(', ')}"
-
- extensions.each do |meth|
- msg = "plugin_#{meth}_options"
- send msg, opts, options if self.respond_to?(msg)
- end
- end
-
- begin
- opts.parse! args
- rescue OptionParser::InvalidOption => e
- puts
- puts e
- puts
- puts opts
- exit 1
- end
-
- orig_args -= args
- end
-
- unless options[:seed] then
- srand
- options[:seed] = srand % 0xFFFF
- orig_args << "--seed" << options[:seed].to_s
- end
-
- srand options[:seed]
-
- options[:args] = orig_args.map { |s|
- s =~ /[\s|&<>$()]/ ? s.inspect : s
- }.join " "
-
- options
- end
-
- def self.filter_backtrace bt # :nodoc:
- backtrace_filter.filter bt
- end
-
- ##
- # Represents anything "runnable", like Test, Spec, Benchmark, or
- # whatever you can dream up.
- #
- # Subclasses of this are automatically registered and available in
- # Runnable.runnables.
-
- class Runnable
- ##
- # Number of assertions executed in this run.
-
- attr_accessor :assertions
-
- ##
- # An assertion raised during the run, if any.
-
- attr_accessor :failures
-
- ##
- # Name of the run.
-
- def name
- @NAME
- end
-
- ##
- # Set the name of the run.
-
- def name= o
- @NAME = o
- end
-
- def self.inherited klass # :nodoc:
- self.runnables << klass
- super
- end
-
- ##
- # Returns all instance methods matching the pattern +re+.
-
- def self.methods_matching re
- public_instance_methods(true).grep(re).map(&:to_s)
- end
-
- def self.reset # :nodoc:
- @@runnables = []
- end
-
- reset
-
- ##
- # Responsible for running all runnable methods in a given class,
- # each in its own instance. Each instance is passed to the
- # reporter to record.
-
- def self.run reporter, options = {}
- filter = options[:filter] || '/./'
- filter = Regexp.new $1 if filter =~ /\/(.*)\//
-
- filtered_methods = self.runnable_methods.find_all { |m|
- filter === m || filter === "#{self}##{m}"
- }
-
- with_info_handler reporter do
- filtered_methods.each do |method_name|
- run_one_method self, method_name, reporter
- end
- end
- end
-
- def self.run_one_method klass, method_name, reporter
- reporter.record Minitest.run_one_method(klass, method_name)
- end
-
- def self.with_info_handler reporter, &block # :nodoc:
- handler = lambda do
- unless reporter.passed? then
- warn "Current results:"
- warn ""
- warn reporter.reporters.first
- warn ""
- end
- end
-
- on_signal "INFO", handler, &block
- end
-
- def self.on_signal name, action # :nodoc:
- supported = Signal.list[name]
-
- old_trap = trap name do
- old_trap.call if old_trap.respond_to? :call
- action.call
- end if supported
-
- yield
- ensure
- trap name, old_trap if supported
- end
-
- ##
- # Each subclass of Runnable is responsible for overriding this
- # method to return all runnable methods. See #methods_matching.
-
- def self.runnable_methods
- raise NotImplementedError, "subclass responsibility"
- end
-
- ##
- # Returns all subclasses of Runnable.
-
- def self.runnables
- @@runnables
- end
-
- def marshal_dump # :nodoc:
- [self.name, self.failures, self.assertions]
- end
-
- def marshal_load ary # :nodoc:
- self.name, self.failures, self.assertions = ary
- end
-
- def failure # :nodoc:
- self.failures.first
- end
-
- def initialize name # :nodoc:
- self.name = name
- self.failures = []
- self.assertions = 0
- end
-
- ##
- # Runs a single method. Needs to return self.
-
- def run
- raise NotImplementedError, "subclass responsibility"
- end
-
- ##
- # Did this run pass?
- #
- # Note: skipped runs are not considered passing, but they don't
- # cause the process to exit non-zero.
-
- def passed?
- raise NotImplementedError, "subclass responsibility"
- end
-
- ##
- # Returns a single character string to print based on the result
- # of the run. Eg ".", "F", or "E".
-
- def result_code
- raise NotImplementedError, "subclass responsibility"
- end
-
- ##
- # Was this run skipped? See #passed? for more information.
-
- def skipped?
- raise NotImplementedError, "subclass responsibility"
- end
- end
-
- ##
- # Defines the API for Reporters. Subclass this and override whatever
- # you want. Go nuts.
-
- class AbstractReporter
- include Mutex_m
-
- ##
- # Starts reporting on the run.
-
- def start
- end
-
- ##
- # Record a result and output the Runnable#result_code. Stores the
- # result of the run if the run did not pass.
-
- def record result
- end
-
- ##
- # Outputs the summary of the run.
-
- def report
- end
-
- ##
- # Did this run pass?
-
- def passed?
- true
- end
- end
-
- class Reporter < AbstractReporter # :nodoc:
- ##
- # The IO used to report.
-
- attr_accessor :io
-
- ##
- # Command-line options for this run.
-
- attr_accessor :options
-
- def initialize io = $stdout, options = {} # :nodoc:
- super()
- self.io = io
- self.options = options
- end
- end
-
- ##
- # A very simple reporter that prints the "dots" during the run.
- #
- # This is added to the top-level CompositeReporter at the start of
- # the run. If you want to change the output of minitest via a
- # plugin, pull this out of the composite and replace it with your
- # own.
-
- class ProgressReporter < Reporter
- def record result # :nodoc:
- io.print "%s#%s = %.2f s = " % [result.class, result.name, result.time] if
- options[:verbose]
- io.print result.result_code
- io.puts if options[:verbose]
- end
- end
-
- ##
- # A reporter that gathers statistics about a test run. Does not do
- # any IO because meant to be used as a parent class for a reporter
- # that does.
- #
- # If you want to create an entirely different type of output (eg,
- # CI, HTML, etc), this is the place to start.
-
- class StatisticsReporter < Reporter
- # :stopdoc:
- attr_accessor :assertions
- attr_accessor :count
- attr_accessor :results
- attr_accessor :start_time
- attr_accessor :total_time
- attr_accessor :failures
- attr_accessor :errors
- attr_accessor :skips
- # :startdoc:
-
- def initialize io = $stdout, options = {} # :nodoc:
- super
-
- self.assertions = 0
- self.count = 0
- self.results = []
- self.start_time = nil
- self.total_time = nil
- self.failures = nil
- self.errors = nil
- self.skips = nil
- end
-
- def passed? # :nodoc:
- results.all?(&:skipped?)
- end
-
- def start # :nodoc:
- self.start_time = Time.now
- end
-
- def record result # :nodoc:
- self.count += 1
- self.assertions += result.assertions
-
- results << result if not result.passed? or result.skipped?
- end
-
- def report # :nodoc:
- aggregate = results.group_by { |r| r.failure.class }
- aggregate.default = [] # dumb. group_by should provide this
-
- self.total_time = Time.now - start_time
- self.failures = aggregate[Assertion].size
- self.errors = aggregate[UnexpectedError].size
- self.skips = aggregate[Skip].size
- end
- end
-
- ##
- # A reporter that prints the header, summary, and failure details at
- # the end of the run.
- #
- # This is added to the top-level CompositeReporter at the start of
- # the run. If you want to change the output of minitest via a
- # plugin, pull this out of the composite and replace it with your
- # own.
-
- class SummaryReporter < StatisticsReporter
- # :stopdoc:
- attr_accessor :sync
- attr_accessor :old_sync
- # :startdoc:
-
- def start # :nodoc:
- super
-
- io.puts "Run options: #{options[:args]}"
- io.puts
- io.puts "# Running:"
- io.puts
-
- self.sync = io.respond_to? :"sync=" # stupid emacs
- self.old_sync, io.sync = io.sync, true if self.sync
- end
-
- def report # :nodoc:
- super
-
- io.sync = self.old_sync
-
- io.puts unless options[:verbose] # finish the dots
- io.puts
- io.puts statistics
- io.puts aggregated_results
- io.puts summary
- end
-
- def statistics # :nodoc:
- "Finished in %.6fs, %.4f runs/s, %.4f assertions/s." %
- [total_time, count / total_time, assertions / total_time]
- end
-
- def aggregated_results # :nodoc:
- filtered_results = results.dup
- filtered_results.reject!(&:skipped?) unless options[:verbose]
-
- filtered_results.each_with_index.map do |result, i|
- "\n%3d) %s" % [i+1, result]
- end.join("\n") + "\n"
- end
-
- alias to_s aggregated_results
-
- def summary # :nodoc:
- extra = ""
-
- extra = "\n\nYou have skipped tests. Run with --verbose for details." if
- results.any?(&:skipped?) unless options[:verbose] or ENV["MT_NO_SKIP_MSG"]
-
- "%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
- [count, assertions, failures, errors, skips, extra]
- end
- end
-
- ##
- # Dispatch to multiple reporters as one.
-
- class CompositeReporter < AbstractReporter
- ##
- # The list of reporters to dispatch to.
-
- attr_accessor :reporters
-
- def initialize *reporters # :nodoc:
- super()
- self.reporters = reporters
- end
-
- ##
- # Add another reporter to the mix.
-
- def << reporter
- self.reporters << reporter
- end
-
- def passed? # :nodoc:
- self.reporters.all?(&:passed?)
- end
-
- def start # :nodoc:
- self.reporters.each(&:start)
- end
-
- def record result # :nodoc:
- self.reporters.each do |reporter|
- reporter.record result
- end
- end
-
- def report # :nodoc:
- self.reporters.each(&:report)
- end
- end
-
- ##
- # Represents run failures.
-
- class Assertion < Exception
- def error # :nodoc:
- self
- end
-
- ##
- # Where was this run before an assertion was raised?
-
- def location
- last_before_assertion = ""
- self.backtrace.reverse_each do |s|
- break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
- last_before_assertion = s
- end
- last_before_assertion.sub(/:in .*$/, "")
- end
-
- def result_code # :nodoc:
- result_label[0, 1]
- end
-
- def result_label # :nodoc:
- "Failure"
- end
- end
-
- ##
- # Assertion raised when skipping a run.
-
- class Skip < Assertion
- def result_label # :nodoc:
- "Skipped"
- end
- end
-
- ##
- # Assertion wrapping an unexpected error that was raised during a run.
-
- class UnexpectedError < Assertion
- attr_accessor :exception # :nodoc:
-
- def initialize exception # :nodoc:
- super
- self.exception = exception
- end
-
- def backtrace # :nodoc:
- self.exception.backtrace
- end
-
- def error # :nodoc:
- self.exception
- end
-
- def message # :nodoc:
- bt = Minitest::filter_backtrace(self.backtrace).join "\n "
- "#{self.exception.class}: #{self.exception.message}\n #{bt}"
- end
-
- def result_label # :nodoc:
- "Error"
- end
- end
-
- ##
- # Provides a simple set of guards that you can use in your tests
- # to skip execution if it is not applicable. These methods are
- # mixed into Test as both instance and class methods so you
- # can use them inside or outside of the test methods.
- #
- # def test_something_for_mri
- # skip "bug 1234" if jruby?
- # # ...
- # end
- #
- # if windows? then
- # # ... lots of test methods ...
- # end
-
- module Guard
-
- ##
- # Is this running on jruby?
-
- def jruby? platform = RUBY_PLATFORM
- "java" == platform
- end
-
- ##
- # Is this running on maglev?
-
- def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
- "maglev" == platform
- end
-
- ##
- # Is this running on mri?
-
- def mri? platform = RUBY_DESCRIPTION
- /^ruby/ =~ platform
- end
-
- ##
- # Is this running on rubinius?
-
- def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
- "rbx" == platform
- end
-
- ##
- # Is this running on windows?
-
- def windows? platform = RUBY_PLATFORM
- /mswin|mingw/ =~ platform
- end
- end
-
- class BacktraceFilter # :nodoc:
- def filter bt
- return ["No backtrace"] unless bt
-
- return bt.dup if $DEBUG
-
- new_bt = bt.take_while { |line| line !~ /lib\/minitest/ }
- new_bt = bt.select { |line| line !~ /lib\/minitest/ } if new_bt.empty?
- new_bt = bt.dup if new_bt.empty?
-
- new_bt
- end
- end
-
- self.backtrace_filter = BacktraceFilter.new
-
- def self.run_one_method klass, method_name # :nodoc:
- result = klass.new(method_name).run
- raise "#{klass}#run _must_ return self" unless klass === result
- result
- end
-end
-
-require "minitest/test"
diff --git a/src/main/resources/stdlib/minitest/assertions.rb b/src/main/resources/stdlib/minitest/assertions.rb
deleted file mode 100644
index 9864d38..0000000
--- a/src/main/resources/stdlib/minitest/assertions.rb
+++ /dev/null
@@ -1,661 +0,0 @@
-require "rbconfig"
-
-module Minitest
- ##
- # Minitest Assertions. All assertion methods accept a +msg+ which is
- # printed if the assertion fails.
- #
- # Protocol: Nearly everything here boils up to +assert+, which
- # expects to be able to increment an instance accessor named
- # +assertions+. This is not provided by Assertions and must be
- # provided by the thing including Assertions. See Minitest::Runnable
- # for an example.
-
- module Assertions
- UNDEFINED = Object.new # :nodoc:
-
- def UNDEFINED.inspect # :nodoc:
- "UNDEFINED" # again with the rdoc bugs... :(
- end
-
- ##
- # Returns the diff command to use in #diff. Tries to intelligently
- # figure out what diff to use.
-
- def self.diff
- @diff = if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ &&
- system("diff.exe", __FILE__, __FILE__)) then
- "diff.exe -u"
- elsif Minitest::Test.maglev? then
- "diff -u"
- elsif system("gdiff", __FILE__, __FILE__)
- "gdiff -u" # solaris and kin suck
- elsif system("diff", __FILE__, __FILE__)
- "diff -u"
- else
- nil
- end unless defined? @diff
-
- @diff
- end
-
- ##
- # Set the diff command to use in #diff.
-
- def self.diff= o
- @diff = o
- end
-
- ##
- # Returns a diff between +exp+ and +act+. If there is no known
- # diff command or if it doesn't make sense to diff the output
- # (single line, short output), then it simply returns a basic
- # comparison between the two.
-
- def diff exp, act
- require "tempfile"
-
- expect = mu_pp_for_diff exp
- butwas = mu_pp_for_diff act
- result = nil
-
- need_to_diff =
- Minitest::Assertions.diff &&
- (expect.include?("\n") ||
- butwas.include?("\n") ||
- expect.size > 30 ||
- butwas.size > 30 ||
- expect == butwas)
-
- return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
- need_to_diff
-
- Tempfile.open("expect") do |a|
- a.puts expect
- a.flush
-
- Tempfile.open("butwas") do |b|
- b.puts butwas
- b.flush
-
- result = `#{Minitest::Assertions.diff} #{a.path} #{b.path}`
- result.sub!(/^\-\-\- .+/, "--- expected")
- result.sub!(/^\+\+\+ .+/, "+++ actual")
-
- if result.empty? then
- klass = exp.class
- result = [
- "No visible difference in the #{klass}#inspect output.\n",
- "You should look at the implementation of #== on ",
- "#{klass} or its members.\n",
- expect,
- ].join
- end
- end
- end
-
- result
- end
-
- ##
- # This returns a human-readable version of +obj+. By default
- # #inspect is called. You can override this to use #pretty_print
- # if you want.
-
- def mu_pp obj
- s = obj.inspect
- s = s.encode Encoding.default_external if defined? Encoding
- s
- end
-
- ##
- # This returns a diff-able human-readable version of +obj+. This
- # differs from the regular mu_pp because it expands escaped
- # newlines and makes hex-values generic (like object_ids). This
- # uses mu_pp to do the first pass and then cleans it up.
-
- def mu_pp_for_diff obj
- mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ':0xXXXXXX')
- end
-
- ##
- # Fails unless +test+ is truthy.
-
- def assert test, msg = nil
- msg ||= "Failed assertion, no message given."
- self.assertions += 1
- unless test then
- msg = msg.call if Proc === msg
- raise Minitest::Assertion, msg
- end
- true
- end
-
- def _synchronize # :nodoc:
- yield
- end
-
- ##
- # Fails unless +obj+ is empty.
-
- def assert_empty obj, msg = nil
- msg = message(msg) { "Expected #{mu_pp(obj)} to be empty" }
- assert_respond_to obj, :empty?
- assert obj.empty?, msg
- end
-
- ##
- # Fails unless exp == act printing the difference between
- # the two, if possible.
- #
- # If there is no visible difference but the assertion fails, you
- # should suspect that your #== is buggy, or your inspect output is
- # missing crucial details.
- #
- # For floats use assert_in_delta.
- #
- # See also: Minitest::Assertions.diff
-
- def assert_equal exp, act, msg = nil
- msg = message(msg, "") { diff exp, act }
- assert exp == act, msg
- end
-
- ##
- # For comparing Floats. Fails unless +exp+ and +act+ are within +delta+
- # of each other.
- #
- # assert_in_delta Math::PI, (22.0 / 7.0), 0.01
-
- def assert_in_delta exp, act, delta = 0.001, msg = nil
- n = (exp - act).abs
- msg = message(msg) {
- "Expected |#{exp} - #{act}| (#{n}) to be <= #{delta}"
- }
- assert delta >= n, msg
- end
-
- ##
- # For comparing Floats. Fails unless +exp+ and +act+ have a relative
- # error less than +epsilon+.
-
- def assert_in_epsilon a, b, epsilon = 0.001, msg = nil
- assert_in_delta a, b, [a.abs, b.abs].min * epsilon, msg
- end
-
- ##
- # Fails unless +collection+ includes +obj+.
-
- def assert_includes collection, obj, msg = nil
- msg = message(msg) {
- "Expected #{mu_pp(collection)} to include #{mu_pp(obj)}"
- }
- assert_respond_to collection, :include?
- assert collection.include?(obj), msg
- end
-
- ##
- # Fails unless +obj+ is an instance of +cls+.
-
- def assert_instance_of cls, obj, msg = nil
- msg = message(msg) {
- "Expected #{mu_pp(obj)} to be an instance of #{cls}, not #{obj.class}"
- }
-
- assert obj.instance_of?(cls), msg
- end
-
- ##
- # Fails unless +obj+ is a kind of +cls+.
-
- def assert_kind_of cls, obj, msg = nil
- msg = message(msg) {
- "Expected #{mu_pp(obj)} to be a kind of #{cls}, not #{obj.class}" }
-
- assert obj.kind_of?(cls), msg
- end
-
- ##
- # Fails unless +matcher+ =~ +obj+.
-
- def assert_match matcher, obj, msg = nil
- msg = message(msg) { "Expected #{mu_pp matcher} to match #{mu_pp obj}" }
- assert_respond_to matcher, :"=~"
- matcher = Regexp.new Regexp.escape matcher if String === matcher
- assert matcher =~ obj, msg
- end
-
- ##
- # Fails unless +obj+ is nil
-
- def assert_nil obj, msg = nil
- msg = message(msg) { "Expected #{mu_pp(obj)} to be nil" }
- assert obj.nil?, msg
- end
-
- ##
- # For testing with binary operators. Eg:
- #
- # assert_operator 5, :<=, 4
-
- def assert_operator o1, op, o2 = UNDEFINED, msg = nil
- return assert_predicate o1, op, msg if UNDEFINED == o2
- msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op} #{mu_pp(o2)}" }
- assert o1.__send__(op, o2), msg
- end
-
- ##
- # Fails if stdout or stderr do not output the expected results.
- # Pass in nil if you don't care about that streams output. Pass in
- # "" if you require it to be silent. Pass in a regexp if you want
- # to pattern match.
- #
- # NOTE: this uses #capture_io, not #capture_subprocess_io.
- #
- # See also: #assert_silent
-
- def assert_output stdout = nil, stderr = nil
- out, err = capture_io do
- yield
- end
-
- err_msg = Regexp === stderr ? :assert_match : :assert_equal if stderr
- out_msg = Regexp === stdout ? :assert_match : :assert_equal if stdout
-
- y = send err_msg, stderr, err, "In stderr" if err_msg
- x = send out_msg, stdout, out, "In stdout" if out_msg
-
- (!stdout || x) && (!stderr || y)
- end
-
- ##
- # For testing with predicates. Eg:
- #
- # assert_predicate str, :empty?
- #
- # This is really meant for specs and is front-ended by assert_operator:
- #
- # str.must_be :empty?
-
- def assert_predicate o1, op, msg = nil
- msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op}" }
- assert o1.__send__(op), msg
- end
-
- ##
- # Fails unless the block raises one of +exp+. Returns the
- # exception matched so you can check the message, attributes, etc.
-
- def assert_raises *exp
- msg = "#{exp.pop}.\n" if String === exp.last
-
- begin
- yield
- rescue Minitest::Skip => e
- return e if exp.include? Minitest::Skip
- raise e
- rescue Exception => e
- expected = exp.any? { |ex|
- if ex.instance_of? Module then
- e.kind_of? ex
- else
- e.instance_of? ex
- end
- }
-
- assert expected, proc {
- exception_details(e, "#{msg}#{mu_pp(exp)} exception expected, not")
- }
-
- return e
- end
-
- exp = exp.first if exp.size == 1
-
- flunk "#{msg}#{mu_pp(exp)} expected but nothing was raised."
- end
-
- ##
- # Fails unless +obj+ responds to +meth+.
-
- def assert_respond_to obj, meth, msg = nil
- msg = message(msg) {
- "Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
- }
- assert obj.respond_to?(meth), msg
- end
-
- ##
- # Fails unless +exp+ and +act+ are #equal?
-
- def assert_same exp, act, msg = nil
- msg = message(msg) {
- data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
- "Expected %s (oid=%d) to be the same as %s (oid=%d)" % data
- }
- assert exp.equal?(act), msg
- end
-
- ##
- # +send_ary+ is a receiver, message and arguments.
- #
- # Fails unless the call returns a true value
-
- def assert_send send_ary, m = nil
- recv, msg, *args = send_ary
- m = message(m) {
- "Expected #{mu_pp(recv)}.#{msg}(*#{mu_pp(args)}) to return true" }
- assert recv.__send__(msg, *args), m
- end
-
- ##
- # Fails if the block outputs anything to stderr or stdout.
- #
- # See also: #assert_output
-
- def assert_silent
- assert_output "", "" do
- yield
- end
- end
-
- ##
- # Fails unless the block throws +sym+
-
- def assert_throws sym, msg = nil
- default = "Expected #{mu_pp(sym)} to have been thrown"
- caught = true
- catch(sym) do
- begin
- yield
- rescue ThreadError => e # wtf?!? 1.8 + threads == suck
- default += ", not \:#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
- rescue ArgumentError => e # 1.9 exception
- default += ", not #{e.message.split(/ /).last}"
- rescue NameError => e # 1.8 exception
- default += ", not #{e.name.inspect}"
- end
- caught = false
- end
-
- assert caught, message(msg) { default }
- end
-
- ##
- # Captures $stdout and $stderr into strings:
- #
- # out, err = capture_io do
- # puts "Some info"
- # warn "You did a bad thing"
- # end
- #
- # assert_match %r%info%, out
- # assert_match %r%bad%, err
- #
- # NOTE: For efficiency, this method uses StringIO and does not
- # capture IO for subprocesses. Use #capture_subprocess_io for
- # that.
-
- def capture_io
- _synchronize do
- begin
- require 'stringio'
-
- captured_stdout, captured_stderr = StringIO.new, StringIO.new
-
- orig_stdout, orig_stderr = $stdout, $stderr
- $stdout, $stderr = captured_stdout, captured_stderr
-
- yield
-
- return captured_stdout.string, captured_stderr.string
- ensure
- $stdout = orig_stdout
- $stderr = orig_stderr
- end
- end
- end
-
- ##
- # Captures $stdout and $stderr into strings, using Tempfile to
- # ensure that subprocess IO is captured as well.
- #
- # out, err = capture_subprocess_io do
- # system "echo Some info"
- # system "echo You did a bad thing 1>&2"
- # end
- #
- # assert_match %r%info%, out
- # assert_match %r%bad%, err
- #
- # NOTE: This method is approximately 10x slower than #capture_io so
- # only use it when you need to test the output of a subprocess.
-
- def capture_subprocess_io
- _synchronize do
- begin
- require 'tempfile'
-
- captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
-
- orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
- $stdout.reopen captured_stdout
- $stderr.reopen captured_stderr
-
- yield
-
- $stdout.rewind
- $stderr.rewind
-
- return captured_stdout.read, captured_stderr.read
- ensure
- captured_stdout.unlink
- captured_stderr.unlink
- $stdout.reopen orig_stdout
- $stderr.reopen orig_stderr
- end
- end
- end
-
- ##
- # Returns details for exception +e+
-
- def exception_details e, msg
- [
- "#{msg}",
- "Class: <#{e.class}>",
- "Message: <#{e.message.inspect}>",
- "---Backtrace---",
- "#{Minitest::filter_backtrace(e.backtrace).join("\n")}",
- "---------------",
- ].join "\n"
- end
-
- ##
- # Fails with +msg+
-
- def flunk msg = nil
- msg ||= "Epic Fail!"
- assert false, msg
- end
-
- ##
- # Returns a proc that will output +msg+ along with the default message.
-
- def message msg = nil, ending = ".", &default
- proc {
- msg = msg.call.chomp(".") if Proc === msg
- custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
- "#{custom_message}#{default.call}#{ending}"
- }
- end
-
- ##
- # used for counting assertions
-
- def pass msg = nil
- assert true
- end
-
- ##
- # Fails if +test+ is truthy.
-
- def refute test, msg = nil
- msg ||= "Failed refutation, no message given"
- not assert(! test, msg)
- end
-
- ##
- # Fails if +obj+ is empty.
-
- def refute_empty obj, msg = nil
- msg = message(msg) { "Expected #{mu_pp(obj)} to not be empty" }
- assert_respond_to obj, :empty?
- refute obj.empty?, msg
- end
-
- ##
- # Fails if exp == act.
- #
- # For floats use refute_in_delta.
-
- def refute_equal exp, act, msg = nil
- msg = message(msg) {
- "Expected #{mu_pp(act)} to not be equal to #{mu_pp(exp)}"
- }
- refute exp == act, msg
- end
-
- ##
- # For comparing Floats. Fails if +exp+ is within +delta+ of +act+.
- #
- # refute_in_delta Math::PI, (22.0 / 7.0)
-
- def refute_in_delta exp, act, delta = 0.001, msg = nil
- n = (exp - act).abs
- msg = message(msg) {
- "Expected |#{exp} - #{act}| (#{n}) to not be <= #{delta}"
- }
- refute delta >= n, msg
- end
-
- ##
- # For comparing Floats. Fails if +exp+ and +act+ have a relative error
- # less than +epsilon+.
-
- def refute_in_epsilon a, b, epsilon = 0.001, msg = nil
- refute_in_delta a, b, a * epsilon, msg
- end
-
- ##
- # Fails if +collection+ includes +obj+.
-
- def refute_includes collection, obj, msg = nil
- msg = message(msg) {
- "Expected #{mu_pp(collection)} to not include #{mu_pp(obj)}"
- }
- assert_respond_to collection, :include?
- refute collection.include?(obj), msg
- end
-
- ##
- # Fails if +obj+ is an instance of +cls+.
-
- def refute_instance_of cls, obj, msg = nil
- msg = message(msg) {
- "Expected #{mu_pp(obj)} to not be an instance of #{cls}"
- }
- refute obj.instance_of?(cls), msg
- end
-
- ##
- # Fails if +obj+ is a kind of +cls+.
-
- def refute_kind_of cls, obj, msg = nil
- msg = message(msg) { "Expected #{mu_pp(obj)} to not be a kind of #{cls}" }
- refute obj.kind_of?(cls), msg
- end
-
- ##
- # Fails if +matcher+ =~ +obj+.
-
- def refute_match matcher, obj, msg = nil
- msg = message(msg) {"Expected #{mu_pp matcher} to not match #{mu_pp obj}"}
- assert_respond_to matcher, :"=~"
- matcher = Regexp.new Regexp.escape matcher if String === matcher
- refute matcher =~ obj, msg
- end
-
- ##
- # Fails if +obj+ is nil.
-
- def refute_nil obj, msg = nil
- msg = message(msg) { "Expected #{mu_pp(obj)} to not be nil" }
- refute obj.nil?, msg
- end
-
- ##
- # Fails if +o1+ is not +op+ +o2+. Eg:
- #
- # refute_operator 1, :>, 2 #=> pass
- # refute_operator 1, :<, 2 #=> fail
-
- def refute_operator o1, op, o2 = UNDEFINED, msg = nil
- return refute_predicate o1, op, msg if UNDEFINED == o2
- msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op} #{mu_pp(o2)}"}
- refute o1.__send__(op, o2), msg
- end
-
- ##
- # For testing with predicates.
- #
- # refute_predicate str, :empty?
- #
- # This is really meant for specs and is front-ended by refute_operator:
- #
- # str.wont_be :empty?
-
- def refute_predicate o1, op, msg = nil
- msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op}" }
- refute o1.__send__(op), msg
- end
-
- ##
- # Fails if +obj+ responds to the message +meth+.
-
- def refute_respond_to obj, meth, msg = nil
- msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
-
- refute obj.respond_to?(meth), msg
- end
-
- ##
- # Fails if +exp+ is the same (by object identity) as +act+.
-
- def refute_same exp, act, msg = nil
- msg = message(msg) {
- data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
- "Expected %s (oid=%d) to not be the same as %s (oid=%d)" % data
- }
- refute exp.equal?(act), msg
- end
-
- ##
- # Skips the current run. If run in verbose-mode, the skipped run
- # gets listed at the end of the run but doesn't cause a failure
- # exit code.
-
- def skip msg = nil, bt = caller
- msg ||= "Skipped, no message given"
- @skip = true
- raise Minitest::Skip, msg, bt
- end
-
- ##
- # Was this testcase skipped? Meant for #teardown.
-
- def skipped?
- defined?(@skip) and @skip
- end
- end
-end
diff --git a/src/main/resources/stdlib/minitest/autorun.rb b/src/main/resources/stdlib/minitest/autorun.rb
deleted file mode 100644
index a02659d..0000000
--- a/src/main/resources/stdlib/minitest/autorun.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-begin
- require "rubygems"
- gem "minitest"
-rescue Gem::LoadError
- # do nothing
-end
-
-require "minitest"
-require "minitest/spec"
-require "minitest/mock"
-
-Minitest.autorun
diff --git a/src/main/resources/stdlib/minitest/benchmark.rb b/src/main/resources/stdlib/minitest/benchmark.rb
deleted file mode 100644
index ea827f0..0000000
--- a/src/main/resources/stdlib/minitest/benchmark.rb
+++ /dev/null
@@ -1,423 +0,0 @@
-require 'minitest/unit'
-require 'minitest/spec'
-
-module Minitest
- ##
- # Subclass Benchmark to create your own benchmark runs. Methods
- # starting with "bench_" get executed on a per-class.
- #
- # See Minitest::Assertions
-
- class Benchmark < Test
- def self.io # :nodoc:
- @io
- end
-
- def io # :nodoc:
- self.class.io
- end
-
- def self.run reporter, options = {} # :nodoc:
- # NOTE: this is truly horrible... but I don't see a way around this ATM.
- @io = reporter.reporters.first.io
- super
- end
-
- def self.runnable_methods # :nodoc:
- methods_matching(/^bench_/)
- end
-
- ##
- # Returns a set of ranges stepped exponentially from +min+ to
- # +max+ by powers of +base+. Eg:
- #
- # bench_exp(2, 16, 2) # => [2, 4, 8, 16]
-
- def self.bench_exp min, max, base = 10
- min = (Math.log10(min) / Math.log10(base)).to_i
- max = (Math.log10(max) / Math.log10(base)).to_i
-
- (min..max).map { |m| base ** m }.to_a
- end
-
- ##
- # Returns a set of ranges stepped linearly from +min+ to +max+ by
- # +step+. Eg:
- #
- # bench_linear(20, 40, 10) # => [20, 30, 40]
-
- def self.bench_linear min, max, step = 10
- (min..max).step(step).to_a
- rescue LocalJumpError # 1.8.6
- r = []; (min..max).step(step) { |n| r << n }; r
- end
-
- ##
- # Specifies the ranges used for benchmarking for that class.
- # Defaults to exponential growth from 1 to 10k by powers of 10.
- # Override if you need different ranges for your benchmarks.
- #
- # See also: ::bench_exp and ::bench_linear.
-
- def self.bench_range
- bench_exp 1, 10_000
- end
-
- ##
- # Runs the given +work+, gathering the times of each run. Range
- # and times are then passed to a given +validation+ proc. Outputs
- # the benchmark name and times in tab-separated format, making it
- # easy to paste into a spreadsheet for graphing or further
- # analysis.
- #
- # Ranges are specified by ::bench_range.
- #
- # Eg:
- #
- # def bench_algorithm
- # validation = proc { |x, y| ... }
- # assert_performance validation do |n|
- # @obj.algorithm(n)
- # end
- # end
-
- def assert_performance validation, &work
- range = self.class.bench_range
-
- io.print "#{self.name}"
-
- times = []
-
- range.each do |x|
- GC.start
- t0 = Time.now
- instance_exec(x, &work)
- t = Time.now - t0
-
- io.print "\t%9.6f" % t
- times << t
- end
- io.puts
-
- validation[range, times]
- end
-
- ##
- # Runs the given +work+ and asserts that the times gathered fit to
- # match a constant rate (eg, linear slope == 0) within a given
- # +threshold+. Note: because we're testing for a slope of 0, R^2
- # is not a good determining factor for the fit, so the threshold
- # is applied against the slope itself. As such, you probably want
- # to tighten it from the default.
- #
- # See http://www.graphpad.com/curvefit/goodness_of_fit.htm for
- # more details.
- #
- # Fit is calculated by #fit_linear.
- #
- # Ranges are specified by ::bench_range.
- #
- # Eg:
- #
- # def bench_algorithm
- # assert_performance_constant 0.9999 do |n|
- # @obj.algorithm(n)
- # end
- # end
-
- def assert_performance_constant threshold = 0.99, &work
- validation = proc do |range, times|
- a, b, rr = fit_linear range, times
- assert_in_delta 0, b, 1 - threshold
- [a, b, rr]
- end
-
- assert_performance validation, &work
- end
-
- ##
- # Runs the given +work+ and asserts that the times gathered fit to
- # match a exponential curve within a given error +threshold+.
- #
- # Fit is calculated by #fit_exponential.
- #
- # Ranges are specified by ::bench_range.
- #
- # Eg:
- #
- # def bench_algorithm
- # assert_performance_exponential 0.9999 do |n|
- # @obj.algorithm(n)
- # end
- # end
-
- def assert_performance_exponential threshold = 0.99, &work
- assert_performance validation_for_fit(:exponential, threshold), &work
- end
-
- ##
- # Runs the given +work+ and asserts that the times gathered fit to
- # match a logarithmic curve within a given error +threshold+.
- #
- # Fit is calculated by #fit_logarithmic.
- #
- # Ranges are specified by ::bench_range.
- #
- # Eg:
- #
- # def bench_algorithm
- # assert_performance_logarithmic 0.9999 do |n|
- # @obj.algorithm(n)
- # end
- # end
-
- def assert_performance_logarithmic threshold = 0.99, &work
- assert_performance validation_for_fit(:logarithmic, threshold), &work
- end
-
- ##
- # Runs the given +work+ and asserts that the times gathered fit to
- # match a straight line within a given error +threshold+.
- #
- # Fit is calculated by #fit_linear.
- #
- # Ranges are specified by ::bench_range.
- #
- # Eg:
- #
- # def bench_algorithm
- # assert_performance_linear 0.9999 do |n|
- # @obj.algorithm(n)
- # end
- # end
-
- def assert_performance_linear threshold = 0.99, &work
- assert_performance validation_for_fit(:linear, threshold), &work
- end
-
- ##
- # Runs the given +work+ and asserts that the times gathered curve
- # fit to match a power curve within a given error +threshold+.
- #
- # Fit is calculated by #fit_power.
- #
- # Ranges are specified by ::bench_range.
- #
- # Eg:
- #
- # def bench_algorithm
- # assert_performance_power 0.9999 do |x|
- # @obj.algorithm
- # end
- # end
-
- def assert_performance_power threshold = 0.99, &work
- assert_performance validation_for_fit(:power, threshold), &work
- end
-
- ##
- # Takes an array of x/y pairs and calculates the general R^2 value.
- #
- # See: http://en.wikipedia.org/wiki/Coefficient_of_determination
-
- def fit_error xys
- y_bar = sigma(xys) { |x, y| y } / xys.size.to_f
- ss_tot = sigma(xys) { |x, y| (y - y_bar) ** 2 }
- ss_err = sigma(xys) { |x, y| (yield(x) - y) ** 2 }
-
- 1 - (ss_err / ss_tot)
- end
-
- ##
- # To fit a functional form: y = ae^(bx).
- #
- # Takes x and y values and returns [a, b, r^2].
- #
- # See: http://mathworld.wolfram.com/LeastSquaresFittingExponential.html
-
- def fit_exponential xs, ys
- n = xs.size
- xys = xs.zip(ys)
- sxlny = sigma(xys) { |x,y| x * Math.log(y) }
- slny = sigma(xys) { |x,y| Math.log(y) }
- sx2 = sigma(xys) { |x,y| x * x }
- sx = sigma xs
-
- c = n * sx2 - sx ** 2
- a = (slny * sx2 - sx * sxlny) / c
- b = ( n * sxlny - sx * slny ) / c
-
- return Math.exp(a), b, fit_error(xys) { |x| Math.exp(a + b * x) }
- end
-
- ##
- # To fit a functional form: y = a + b*ln(x).
- #
- # Takes x and y values and returns [a, b, r^2].
- #
- # See: http://mathworld.wolfram.com/LeastSquaresFittingLogarithmic.html
-
- def fit_logarithmic xs, ys
- n = xs.size
- xys = xs.zip(ys)
- slnx2 = sigma(xys) { |x,y| Math.log(x) ** 2 }
- slnx = sigma(xys) { |x,y| Math.log(x) }
- sylnx = sigma(xys) { |x,y| y * Math.log(x) }
- sy = sigma(xys) { |x,y| y }
-
- c = n * slnx2 - slnx ** 2
- b = ( n * sylnx - sy * slnx ) / c
- a = (sy - b * slnx) / n
-
- return a, b, fit_error(xys) { |x| a + b * Math.log(x) }
- end
-
-
- ##
- # Fits the functional form: a + bx.
- #
- # Takes x and y values and returns [a, b, r^2].
- #
- # See: http://mathworld.wolfram.com/LeastSquaresFitting.html
-
- def fit_linear xs, ys
- n = xs.size
- xys = xs.zip(ys)
- sx = sigma xs
- sy = sigma ys
- sx2 = sigma(xs) { |x| x ** 2 }
- sxy = sigma(xys) { |x,y| x * y }
-
- c = n * sx2 - sx**2
- a = (sy * sx2 - sx * sxy) / c
- b = ( n * sxy - sx * sy ) / c
-
- return a, b, fit_error(xys) { |x| a + b * x }
- end
-
- ##
- # To fit a functional form: y = ax^b.
- #
- # Takes x and y values and returns [a, b, r^2].
- #
- # See: http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html
-
- def fit_power xs, ys
- n = xs.size
- xys = xs.zip(ys)
- slnxlny = sigma(xys) { |x, y| Math.log(x) * Math.log(y) }
- slnx = sigma(xs) { |x | Math.log(x) }
- slny = sigma(ys) { | y| Math.log(y) }
- slnx2 = sigma(xs) { |x | Math.log(x) ** 2 }
-
- b = (n * slnxlny - slnx * slny) / (n * slnx2 - slnx ** 2);
- a = (slny - b * slnx) / n
-
- return Math.exp(a), b, fit_error(xys) { |x| (Math.exp(a) * (x ** b)) }
- end
-
- ##
- # Enumerates over +enum+ mapping +block+ if given, returning the
- # sum of the result. Eg:
- #
- # sigma([1, 2, 3]) # => 1 + 2 + 3 => 7
- # sigma([1, 2, 3]) { |n| n ** 2 } # => 1 + 4 + 9 => 14
-
- def sigma enum, &block
- enum = enum.map(&block) if block
- enum.inject { |sum, n| sum + n }
- end
-
- ##
- # Returns a proc that calls the specified fit method and asserts
- # that the error is within a tolerable threshold.
-
- def validation_for_fit msg, threshold
- proc do |range, times|
- a, b, rr = send "fit_#{msg}", range, times
- assert_operator rr, :>=, threshold
- [a, b, rr]
- end
- end
- end
-end
-
-module Minitest
- class BenchSpec < Benchmark
- extend Minitest::Spec::DSL
-
- ##
- # This is used to define a new benchmark method. You usually don't
- # use this directly and is intended for those needing to write new
- # performance curve fits (eg: you need a specific polynomial fit).
- #
- # See ::bench_performance_linear for an example of how to use this.
-
- def self.bench name, &block
- define_method "bench_#{name.gsub(/\W+/, '_')}", &block
- end
-
- ##
- # Specifies the ranges used for benchmarking for that class.
- #
- # bench_range do
- # bench_exp(2, 16, 2)
- # end
- #
- # See Minitest::Benchmark#bench_range for more details.
-
- def self.bench_range &block
- return super unless block
-
- meta = (class << self; self; end)
- meta.send :define_method, "bench_range", &block
- end
-
- ##
- # Create a benchmark that verifies that the performance is linear.
- #
- # describe "my class Bench" do
- # bench_performance_linear "fast_algorithm", 0.9999 do |n|
- # @obj.fast_algorithm(n)
- # end
- # end
-
- def self.bench_performance_linear name, threshold = 0.99, &work
- bench name do
- assert_performance_linear threshold, &work
- end
- end
-
- ##
- # Create a benchmark that verifies that the performance is constant.
- #
- # describe "my class Bench" do
- # bench_performance_constant "zoom_algorithm!" do |n|
- # @obj.zoom_algorithm!(n)
- # end
- # end
-
- def self.bench_performance_constant name, threshold = 0.99, &work
- bench name do
- assert_performance_constant threshold, &work
- end
- end
-
- ##
- # Create a benchmark that verifies that the performance is exponential.
- #
- # describe "my class Bench" do
- # bench_performance_exponential "algorithm" do |n|
- # @obj.algorithm(n)
- # end
- # end
-
- def self.bench_performance_exponential name, threshold = 0.99, &work
- bench name do
- assert_performance_exponential threshold, &work
- end
- end
- end
-
- Minitest::Spec.register_spec_type(/Bench(mark)?$/, Minitest::BenchSpec)
-end
diff --git a/src/main/resources/stdlib/minitest/expectations.rb b/src/main/resources/stdlib/minitest/expectations.rb
deleted file mode 100644
index 210ef2a..0000000
--- a/src/main/resources/stdlib/minitest/expectations.rb
+++ /dev/null
@@ -1,281 +0,0 @@
-##
-# It's where you hide your "assertions".
-#
-# Please note, because of the way that expectations are implemented,
-# all expectations (eg must_equal) are dependent upon a thread local
-# variable +:current_spec+. If your specs rely on mixing threads into
-# the specs themselves, you're better off using assertions. For
-# example:
-#
-# it "should still work in threads" do
-# my_threaded_thingy do
-# (1+1).must_equal 2 # bad
-# assert_equal 2, 1+1 # good
-# end
-# end
-
-module Minitest::Expectations
- ##
- # See Minitest::Assertions#assert_empty.
- #
- # collection.must_be_empty
- #
- # :method: must_be_empty
-
- infect_an_assertion :assert_empty, :must_be_empty, :unary
-
- ##
- # See Minitest::Assertions#assert_equal
- #
- # a.must_equal b
- #
- # :method: must_equal
-
- infect_an_assertion :assert_equal, :must_equal
-
- ##
- # See Minitest::Assertions#assert_in_delta
- #
- # n.must_be_close_to m [, delta]
- #
- # :method: must_be_close_to
-
- infect_an_assertion :assert_in_delta, :must_be_close_to
-
- alias :must_be_within_delta :must_be_close_to # :nodoc:
-
- ##
- # See Minitest::Assertions#assert_in_epsilon
- #
- # n.must_be_within_epsilon m [, epsilon]
- #
- # :method: must_be_within_epsilon
-
- infect_an_assertion :assert_in_epsilon, :must_be_within_epsilon
-
- ##
- # See Minitest::Assertions#assert_includes
- #
- # collection.must_include obj
- #
- # :method: must_include
-
- infect_an_assertion :assert_includes, :must_include, :reverse
-
- ##
- # See Minitest::Assertions#assert_instance_of
- #
- # obj.must_be_instance_of klass
- #
- # :method: must_be_instance_of
-
- infect_an_assertion :assert_instance_of, :must_be_instance_of
-
- ##
- # See Minitest::Assertions#assert_kind_of
- #
- # obj.must_be_kind_of mod
- #
- # :method: must_be_kind_of
-
- infect_an_assertion :assert_kind_of, :must_be_kind_of
-
- ##
- # See Minitest::Assertions#assert_match
- #
- # a.must_match b
- #
- # :method: must_match
-
- infect_an_assertion :assert_match, :must_match
-
- ##
- # See Minitest::Assertions#assert_nil
- #
- # obj.must_be_nil
- #
- # :method: must_be_nil
-
- infect_an_assertion :assert_nil, :must_be_nil, :unary
-
- ##
- # See Minitest::Assertions#assert_operator
- #
- # n.must_be :<=, 42
- #
- # This can also do predicates:
- #
- # str.must_be :empty?
- #
- # :method: must_be
-
- infect_an_assertion :assert_operator, :must_be, :reverse
-
- ##
- # See Minitest::Assertions#assert_output
- #
- # proc { ... }.must_output out_or_nil [, err]
- #
- # :method: must_output
-
- infect_an_assertion :assert_output, :must_output
-
- ##
- # See Minitest::Assertions#assert_raises
- #
- # proc { ... }.must_raise exception
- #
- # :method: must_raise
-
- infect_an_assertion :assert_raises, :must_raise
-
- ##
- # See Minitest::Assertions#assert_respond_to
- #
- # obj.must_respond_to msg
- #
- # :method: must_respond_to
-
- infect_an_assertion :assert_respond_to, :must_respond_to, :reverse
-
- ##
- # See Minitest::Assertions#assert_same
- #
- # a.must_be_same_as b
- #
- # :method: must_be_same_as
-
- infect_an_assertion :assert_same, :must_be_same_as
-
- ##
- # See Minitest::Assertions#assert_silent
- #
- # proc { ... }.must_be_silent
- #
- # :method: must_be_silent
-
- infect_an_assertion :assert_silent, :must_be_silent
-
- ##
- # See Minitest::Assertions#assert_throws
- #
- # proc { ... }.must_throw sym
- #
- # :method: must_throw
-
- infect_an_assertion :assert_throws, :must_throw
-
- ##
- # See Minitest::Assertions#refute_empty
- #
- # collection.wont_be_empty
- #
- # :method: wont_be_empty
-
- infect_an_assertion :refute_empty, :wont_be_empty, :unary
-
- ##
- # See Minitest::Assertions#refute_equal
- #
- # a.wont_equal b
- #
- # :method: wont_equal
-
- infect_an_assertion :refute_equal, :wont_equal
-
- ##
- # See Minitest::Assertions#refute_in_delta
- #
- # n.wont_be_close_to m [, delta]
- #
- # :method: wont_be_close_to
-
- infect_an_assertion :refute_in_delta, :wont_be_close_to
-
- alias :wont_be_within_delta :wont_be_close_to # :nodoc:
-
- ##
- # See Minitest::Assertions#refute_in_epsilon
- #
- # n.wont_be_within_epsilon m [, epsilon]
- #
- # :method: wont_be_within_epsilon
-
- infect_an_assertion :refute_in_epsilon, :wont_be_within_epsilon
-
- ##
- # See Minitest::Assertions#refute_includes
- #
- # collection.wont_include obj
- #
- # :method: wont_include
-
- infect_an_assertion :refute_includes, :wont_include, :reverse
-
- ##
- # See Minitest::Assertions#refute_instance_of
- #
- # obj.wont_be_instance_of klass
- #
- # :method: wont_be_instance_of
-
- infect_an_assertion :refute_instance_of, :wont_be_instance_of
-
- ##
- # See Minitest::Assertions#refute_kind_of
- #
- # obj.wont_be_kind_of mod
- #
- # :method: wont_be_kind_of
-
- infect_an_assertion :refute_kind_of, :wont_be_kind_of
-
- ##
- # See Minitest::Assertions#refute_match
- #
- # a.wont_match b
- #
- # :method: wont_match
-
- infect_an_assertion :refute_match, :wont_match
-
- ##
- # See Minitest::Assertions#refute_nil
- #
- # obj.wont_be_nil
- #
- # :method: wont_be_nil
-
- infect_an_assertion :refute_nil, :wont_be_nil, :unary
-
- ##
- # See Minitest::Assertions#refute_operator
- #
- # n.wont_be :<=, 42
- #
- # This can also do predicates:
- #
- # str.wont_be :empty?
- #
- # :method: wont_be
-
- infect_an_assertion :refute_operator, :wont_be, :reverse
-
- ##
- # See Minitest::Assertions#refute_respond_to
- #
- # obj.wont_respond_to msg
- #
- # :method: wont_respond_to
-
- infect_an_assertion :refute_respond_to, :wont_respond_to, :reverse
-
- ##
- # See Minitest::Assertions#refute_same
- #
- # a.wont_be_same_as b
- #
- # :method: wont_be_same_as
-
- infect_an_assertion :refute_same, :wont_be_same_as
-end
diff --git a/src/main/resources/stdlib/minitest/hell.rb b/src/main/resources/stdlib/minitest/hell.rb
deleted file mode 100644
index cbdc8c1..0000000
--- a/src/main/resources/stdlib/minitest/hell.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require "minitest/parallel"
-
-class Minitest::Test
- class << self
- alias :old_test_order :test_order # :nodoc:
-
- def test_order # :nodoc:
- :parallel
- end
- end
-end
diff --git a/src/main/resources/stdlib/minitest/mock.rb b/src/main/resources/stdlib/minitest/mock.rb
deleted file mode 100644
index bc07671..0000000
--- a/src/main/resources/stdlib/minitest/mock.rb
+++ /dev/null
@@ -1,220 +0,0 @@
-class MockExpectationError < StandardError; end # :nodoc:
-
-module Minitest # :nodoc:
-
- ##
- # A simple and clean mock object framework.
- #
- # All mock objects are an instance of Mock
-
- class Mock
- alias :__respond_to? :respond_to?
-
- overridden_methods = %w(
- ===
- inspect
- object_id
- public_send
- respond_to_missing?
- send
- to_s
- )
-
- instance_methods.each do |m|
- undef_method m unless overridden_methods.include?(m.to_s) || m =~ /^__/
- end
-
- overridden_methods.map(&:to_sym).each do |method_id|
- define_method method_id do |*args, &b|
- if @expected_calls.has_key? method_id then
- method_missing(method_id, *args, &b)
- else
- super(*args, &b)
- end
- end
- end
-
- def initialize # :nodoc:
- @expected_calls = Hash.new { |calls, name| calls[name] = [] }
- @actual_calls = Hash.new { |calls, name| calls[name] = [] }
- end
-
- ##
- # Expect that method +name+ is called, optionally with +args+ or a
- # +blk+, and returns +retval+.
- #
- # @mock.expect(:meaning_of_life, 42)
- # @mock.meaning_of_life # => 42
- #
- # @mock.expect(:do_something_with, true, [some_obj, true])
- # @mock.do_something_with(some_obj, true) # => true
- #
- # @mock.expect(:do_something_else, true) do |a1, a2|
- # a1 == "buggs" && a2 == :bunny
- # end
- #
- # +args+ is compared to the expected args using case equality (ie, the
- # '===' operator), allowing for less specific expectations.
- #
- # @mock.expect(:uses_any_string, true, [String])
- # @mock.uses_any_string("foo") # => true
- # @mock.verify # => true
- #
- # @mock.expect(:uses_one_string, true, ["foo"])
- # @mock.uses_one_string("bar") # => true
- # @mock.verify # => raises MockExpectationError
-
- def expect(name, retval, args=[], &blk)
- name = name.to_sym
-
- if block_given?
- raise ArgumentError, "args ignored when block given" unless args.empty?
- @expected_calls[name] << { :retval => retval, :block => blk }
- else
- raise ArgumentError, "args must be an array" unless Array === args
- @expected_calls[name] << { :retval => retval, :args => args }
- end
- self
- end
-
- def __call name, data # :nodoc:
- case data
- when Hash then
- "#{name}(#{data[:args].inspect[1..-2]}) => #{data[:retval].inspect}"
- else
- data.map { |d| __call name, d }.join ", "
- end
- end
-
- ##
- # Verify that all methods were called as expected. Raises
- # +MockExpectationError+ if the mock object was not called as
- # expected.
-
- def verify
- @expected_calls.each do |name, calls|
- calls.each do |expected|
- msg1 = "expected #{__call name, expected}"
- msg2 = "#{msg1}, got [#{__call name, @actual_calls[name]}]"
-
- raise MockExpectationError, msg2 if
- @actual_calls.has_key?(name) and
- not @actual_calls[name].include?(expected)
-
- raise MockExpectationError, msg1 unless
- @actual_calls.has_key?(name) and
- @actual_calls[name].include?(expected)
- end
- end
- true
- end
-
- def method_missing(sym, *args, &block) # :nodoc:
- unless @expected_calls.has_key?(sym) then
- raise NoMethodError, "unmocked method %p, expected one of %p" %
- [sym, @expected_calls.keys.sort_by(&:to_s)]
- end
-
- index = @actual_calls[sym].length
- expected_call = @expected_calls[sym][index]
-
- unless expected_call then
- raise MockExpectationError, "No more expects available for %p: %p" %
- [sym, args]
- end
-
- expected_args, retval, val_block =
- expected_call.values_at(:args, :retval, :block)
-
- if val_block then
- raise MockExpectationError, "mocked method %p failed block w/ %p" %
- [sym, args] unless val_block.call(*args, &block)
-
- # keep "verify" happy
- @actual_calls[sym] << expected_call
- return retval
- end
-
- if expected_args.size != args.size then
- raise ArgumentError, "mocked method %p expects %d arguments, got %d" %
- [sym, expected_args.size, args.size]
- end
-
- fully_matched = expected_args.zip(args).all? { |mod, a|
- mod === a or mod == a
- }
-
- unless fully_matched then
- raise MockExpectationError, "mocked method %p called with unexpected arguments %p" %
- [sym, args]
- end
-
- @actual_calls[sym] << {
- :retval => retval,
- :args => expected_args.zip(args).map { |mod, a| mod === a ? mod : a }
- }
-
- retval
- end
-
- def respond_to?(sym, include_private = false) # :nodoc:
- return true if @expected_calls.has_key? sym.to_sym
- return __respond_to?(sym, include_private)
- end
- end
-end
-
-class Object # :nodoc:
-
- ##
- # Add a temporary stubbed method replacing +name+ for the duration
- # of the +block+. If +val_or_callable+ responds to #call, then it
- # returns the result of calling it, otherwise returns the value
- # as-is. If stubbed method yields a block, +block_args+ will be
- # passed along. Cleans up the stub at the end of the +block+. The
- # method +name+ must exist before stubbing.
- #
- # def test_stale_eh
- # obj_under_test = Something.new
- # refute obj_under_test.stale?
- #
- # Time.stub :now, Time.at(0) do
- # assert obj_under_test.stale?
- # end
- # end
- #
-
- def stub name, val_or_callable, *block_args, &block
- new_name = "__minitest_stub__#{name}"
-
- metaclass = class << self; self; end
-
- if respond_to? name and not methods.map(&:to_s).include? name.to_s then
- metaclass.send :define_method, name do |*args|
- super(*args)
- end
- end
-
- metaclass.send :alias_method, new_name, name
-
- metaclass.send :define_method, name do |*args, &blk|
-
- ret = if val_or_callable.respond_to? :call then
- val_or_callable.call(*args)
- else
- val_or_callable
- end
-
- blk.call(*block_args) if blk
-
- ret
- end
-
- yield self
- ensure
- metaclass.send :undef_method, name
- metaclass.send :alias_method, name, new_name
- metaclass.send :undef_method, new_name
- end
-
-end
diff --git a/src/main/resources/stdlib/minitest/parallel.rb b/src/main/resources/stdlib/minitest/parallel.rb
deleted file mode 100644
index 71337a0..0000000
--- a/src/main/resources/stdlib/minitest/parallel.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-module Minitest
- module Parallel
- class Executor
- attr_reader :size
-
- def initialize size
- @size = size
- @queue = Queue.new
- @pool = size.times.map {
- Thread.new(@queue) do |queue|
- Thread.current.abort_on_exception = true
- while job = queue.pop
- klass, method, reporter = job
- result = Minitest.run_one_method klass, method
- reporter.synchronize { reporter.record result }
- end
- end
- }
- end
-
- def << work; @queue << work; end
-
- def shutdown
- size.times { @queue << nil }
- @pool.each(&:join)
- end
- end
-
- module Test
- def _synchronize; Test.io_lock.synchronize { yield }; end
-
- module ClassMethods
- def run_one_method klass, method_name, reporter
- Minitest.parallel_executor << [klass, method_name, reporter]
- end
- def test_order; :parallel; end
- end
- end
- end
-end
diff --git a/src/main/resources/stdlib/minitest/pride.rb b/src/main/resources/stdlib/minitest/pride.rb
deleted file mode 100644
index f3b8e47..0000000
--- a/src/main/resources/stdlib/minitest/pride.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require "minitest"
-
-Minitest.load_plugins
-Minitest::PrideIO.pride!
diff --git a/src/main/resources/stdlib/minitest/pride_plugin.rb b/src/main/resources/stdlib/minitest/pride_plugin.rb
deleted file mode 100644
index a8afd5e..0000000
--- a/src/main/resources/stdlib/minitest/pride_plugin.rb
+++ /dev/null
@@ -1,142 +0,0 @@
-require "minitest"
-
-module Minitest
- def self.plugin_pride_options opts, options # :nodoc:
- opts.on "-p", "--pride", "Pride. Show your testing pride!" do
- PrideIO.pride!
- end
- end
-
- def self.plugin_pride_init options # :nodoc:
- if PrideIO.pride? then
- klass = ENV["TERM"] =~ /^xterm|-256color$/ ? PrideLOL : PrideIO
- io = klass.new options[:io]
-
- self.reporter.reporters.grep(Minitest::Reporter).each do |rep|
- rep.io = io
- end
- end
- end
-
- ##
- # Show your testing pride!
-
- class PrideIO
- ##
- # Activate the pride plugin. Called from both -p option and minitest/pride
-
- def self.pride!
- @pride = true
- end
-
- ##
- # Are we showing our testing pride?
-
- def self.pride?
- @pride ||= false
- end
-
- # Start an escape sequence
- ESC = "\e["
-
- # End the escape sequence
- NND = "#{ESC}0m"
-
- # The IO we're going to pipe through.
- attr_reader :io
-
- def initialize io # :nodoc:
- @io = io
- # stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
- # also reference http://en.wikipedia.org/wiki/ANSI_escape_code
- @colors ||= (31..36).to_a
- @size = @colors.size
- @index = 0
- end
-
- ##
- # Wrap print to colorize the output.
-
- def print o
- case o
- when "." then
- io.print pride o
- when "E", "F" then
- io.print "#{ESC}41m#{ESC}37m#{o}#{NND}"
- when "S" then
- io.print pride o
- else
- io.print o
- end
- end
-
- def puts(*o) # :nodoc:
- o.map! { |s|
- s.to_s.sub(/Finished/) {
- @index = 0
- 'Fabulous run'.split(//).map { |c|
- pride(c)
- }.join
- }
- }
-
- io.puts(*o)
- end
-
- ##
- # Color a string.
-
- def pride string
- string = "*" if string == "."
- c = @colors[@index % @size]
- @index += 1
- "#{ESC}#{c}m#{string}#{NND}"
- end
-
- def method_missing msg, *args # :nodoc:
- io.send(msg, *args)
- end
- end
-
- ##
- # If you thought the PrideIO was colorful...
- #
- # (Inspired by lolcat, but with clean math)
-
- class PrideLOL < PrideIO
- PI_3 = Math::PI / 3 # :nodoc:
-
- def initialize io # :nodoc:
- # walk red, green, and blue around a circle separated by equal thirds.
- #
- # To visualize, type this into wolfram-alpha:
- #
- # plot (3*sin(x)+3), (3*sin(x+2*pi/3)+3), (3*sin(x+4*pi/3)+3)
-
- # 6 has wide pretty gradients. 3 == lolcat, about half the width
- @colors = (0...(6 * 7)).map { |n|
- n *= 1.0 / 6
- r = (3 * Math.sin(n ) + 3).to_i
- g = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
- b = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
-
- # Then we take rgb and encode them in a single number using base 6.
- # For some mysterious reason, we add 16... to clear the bottom 4 bits?
- # Yes... they're ugly.
-
- 36 * r + 6 * g + b + 16
- }
-
- super
- end
-
- ##
- # Make the string even more colorful. Damnit.
-
- def pride string
- c = @colors[@index % @size]
- @index += 1
- "#{ESC}38;5;#{c}m#{string}#{NND}"
- end
- end
-end
diff --git a/src/main/resources/stdlib/minitest/spec.rb b/src/main/resources/stdlib/minitest/spec.rb
deleted file mode 100644
index 3498524..0000000
--- a/src/main/resources/stdlib/minitest/spec.rb
+++ /dev/null
@@ -1,296 +0,0 @@
-require "minitest/test"
-
-class Module # :nodoc:
- def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
- # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
- self.class_eval <<-EOM
- def #{new_name} *args
- case
- when #{!!dont_flip} then
- Minitest::Spec.current.#{meth}(self, *args)
- when Proc === self then
- Minitest::Spec.current.#{meth}(*args, &self)
- else
- Minitest::Spec.current.#{meth}(args.first, self, *args[1..-1])
- end
- end
- EOM
- end
-end
-
-module Kernel # :nodoc:
- ##
- # Describe a series of expectations for a given target +desc+.
- #
- # Defines a test class subclassing from either Minitest::Spec or
- # from the surrounding describe's class. The surrounding class may
- # subclass Minitest::Spec manually in order to easily share code:
- #
- # class MySpec < Minitest::Spec
- # # ... shared code ...
- # end
- #
- # class TestStuff < MySpec
- # it "does stuff" do
- # # shared code available here
- # end
- # describe "inner stuff" do
- # it "still does stuff" do
- # # ...and here
- # end
- # end
- # end
- #
- # For more information on getting started with writing specs, see:
- #
- # http://www.rubyinside.com/a-minitestspec-tutorial-elegant-spec-style-testing-that-comes-with-ruby-5354.html
- #
- # For some suggestions on how to improve your specs, try:
- #
- # http://betterspecs.org
- #
- # but do note that several items there are debatable or specific to
- # rspec.
- #
- # For more information about expectations, see Minitest::Expectations.
-
- def describe desc, *additional_desc, &block # :doc:
- stack = Minitest::Spec.describe_stack
- name = [stack.last, desc, *additional_desc].compact.join("::")
- sclas = stack.last || if Class === self && is_a?(Minitest::Spec::DSL) then
- self
- else
- Minitest::Spec.spec_type desc, *additional_desc
- end
-
- cls = sclas.create name, desc
-
- stack.push cls
- cls.class_eval(&block)
- stack.pop
- cls
- end
- private :describe
-end
-
-##
-# Minitest::Spec -- The faster, better, less-magical spec framework!
-#
-# For a list of expectations, see Minitest::Expectations.
-
-class Minitest::Spec < Minitest::Test
-
- def self.current # :nodoc:
- Thread.current[:current_spec]
- end
-
- def initialize name # :nodoc:
- super
- Thread.current[:current_spec] = self
- end
-
- ##
- # Oh look! A Minitest::Spec::DSL module! Eat your heart out DHH.
-
- module DSL
- ##
- # Contains pairs of matchers and Spec classes to be used to
- # calculate the superclass of a top-level describe. This allows for
- # automatically customizable spec types.
- #
- # See: register_spec_type and spec_type
-
- TYPES = [[//, Minitest::Spec]]
-
- ##
- # Register a new type of spec that matches the spec's description.
- # This method can take either a Regexp and a spec class or a spec
- # class and a block that takes the description and returns true if
- # it matches.
- #
- # Eg:
- #
- # register_spec_type(/Controller$/, Minitest::Spec::Rails)
- #
- # or:
- #
- # register_spec_type(Minitest::Spec::RailsModel) do |desc|
- # desc.superclass == ActiveRecord::Base
- # end
-
- def register_spec_type(*args, &block)
- if block then
- matcher, klass = block, args.first
- else
- matcher, klass = *args
- end
- TYPES.unshift [matcher, klass]
- end
-
- ##
- # Figure out the spec class to use based on a spec's description. Eg:
- #
- # spec_type("BlahController") # => Minitest::Spec::Rails
-
- def spec_type desc, *additional
- TYPES.find { |matcher, klass|
- if matcher.respond_to? :call then
- matcher.call desc, *additional
- else
- matcher === desc.to_s
- end
- }.last
- end
-
- def describe_stack # :nodoc:
- Thread.current[:describe_stack] ||= []
- end
-
- ##
- # Returns the children of this spec.
-
- def children
- @children ||= []
- end
-
- def nuke_test_methods! # :nodoc:
- self.public_instance_methods.grep(/^test_/).each do |name|
- self.send :undef_method, name
- end
- end
-
- ##
- # Define a 'before' action. Inherits the way normal methods should.
- #
- # NOTE: +type+ is ignored and is only there to make porting easier.
- #
- # Equivalent to Minitest::Test#setup.
-
- def before type = nil, &block
- define_method :setup do
- super()
- self.instance_eval(&block)
- end
- end
-
- ##
- # Define an 'after' action. Inherits the way normal methods should.
- #
- # NOTE: +type+ is ignored and is only there to make porting easier.
- #
- # Equivalent to Minitest::Test#teardown.
-
- def after type = nil, &block
- define_method :teardown do
- self.instance_eval(&block)
- super()
- end
- end
-
- ##
- # Define an expectation with name +desc+. Name gets morphed to a
- # proper test method name. For some freakish reason, people who
- # write specs don't like class inheritance, so this goes way out of
- # its way to make sure that expectations aren't inherited.
- #
- # This is also aliased to #specify and doesn't require a +desc+ arg.
- #
- # Hint: If you _do_ want inheritance, use minitest/test. You can mix
- # and match between assertions and expectations as much as you want.
-
- def it desc = "anonymous", &block
- block ||= proc { skip "(no tests defined)" }
-
- @specs ||= 0
- @specs += 1
-
- name = "test_%04d_%s" % [ @specs, desc ]
-
- undef_klasses = self.children.reject { |c| c.public_method_defined? name }
-
- define_method name, &block
-
- undef_klasses.each do |undef_klass|
- undef_klass.send :undef_method, name
- end
-
- name
- end
-
- ##
- # Essentially, define an accessor for +name+ with +block+.
- #
- # Why use let instead of def? I honestly don't know.
-
- def let name, &block
- name = name.to_s
- pre, post = "let '#{name}' cannot ", ". Please use another name."
- methods = Minitest::Spec.instance_methods.map(&:to_s) - %w[subject]
- raise ArgumentError, "#{pre}begin with 'test'#{post}" if
- name =~ /\Atest/
- raise ArgumentError, "#{pre}override a method in Minitest::Spec#{post}" if
- methods.include? name
-
- define_method name do
- @_memoized ||= {}
- @_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
- end
- end
-
- ##
- # Another lazy man's accessor generator. Made even more lazy by
- # setting the name for you to +subject+.
-
- def subject &block
- let :subject, &block
- end
-
- def create name, desc # :nodoc:
- cls = Class.new(self) do
- @name = name
- @desc = desc
-
- nuke_test_methods!
- end
-
- children << cls
-
- cls
- end
-
- def name # :nodoc:
- defined?(@name) ? @name : super
- end
-
- def to_s # :nodoc:
- name # Can't alias due to 1.8.7, not sure why
- end
-
- # :stopdoc:
- attr_reader :desc
- alias :specify :it
-
- module InstanceMethods
- def before_setup
- super
- Thread.current[:current_spec] = self
- end
- end
-
- def self.extended obj
- obj.send :include, InstanceMethods
- end
-
- # :startdoc:
- end
-
- extend DSL
-
- TYPES = DSL::TYPES # :nodoc:
-end
-
-require "minitest/expectations"
-
-class Object # :nodoc:
- include Minitest::Expectations unless ENV["MT_NO_EXPECTATIONS"]
-end
diff --git a/src/main/resources/stdlib/minitest/test.rb b/src/main/resources/stdlib/minitest/test.rb
deleted file mode 100644
index bf26276..0000000
--- a/src/main/resources/stdlib/minitest/test.rb
+++ /dev/null
@@ -1,285 +0,0 @@
-require "minitest" unless defined? Minitest::Runnable
-
-module Minitest
- ##
- # Subclass Test to create your own tests. Typically you'll want a
- # Test subclass per implementation class.
- #
- # See Minitest::Assertions
-
- class Test < Runnable
- require "minitest/assertions"
- include Minitest::Assertions
-
- PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, # :nodoc:
- Interrupt, SystemExit]
-
- class << self; attr_accessor :io_lock; end
- self.io_lock = Mutex.new
-
- ##
- # Call this at the top of your tests when you absolutely
- # positively need to have ordered tests. In doing so, you're
- # admitting that you suck and your tests are weak.
-
- def self.i_suck_and_my_tests_are_order_dependent!
- class << self
- undef_method :test_order if method_defined? :test_order
- define_method :test_order do :alpha end
- end
- end
-
- ##
- # Make diffs for this Test use #pretty_inspect so that diff
- # in assert_equal can have more details. NOTE: this is much slower
- # than the regular inspect but much more usable for complex
- # objects.
-
- def self.make_my_diffs_pretty!
- require "pp"
-
- define_method :mu_pp do |o|
- o.pretty_inspect
- end
- end
-
- ##
- # Call this at the top of your tests when you want to run your
- # tests in parallel. In doing so, you're admitting that you rule
- # and your tests are awesome.
-
- def self.parallelize_me!
- include Minitest::Parallel::Test
- extend Minitest::Parallel::Test::ClassMethods
- end
-
- ##
- # Returns all instance methods starting with "test_". Based on
- # #test_order, the methods are either sorted, randomized
- # (default), or run in parallel.
-
- def self.runnable_methods
- methods = methods_matching(/^test_/)
-
- case self.test_order
- when :random, :parallel then
- max = methods.size
- methods.sort.sort_by { rand max }
- when :alpha, :sorted then
- methods.sort
- else
- raise "Unknown test_order: #{self.test_order.inspect}"
- end
- end
-
- ##
- # Defines the order to run tests (:random by default). Override
- # this or use a convenience method to change it for your tests.
-
- def self.test_order
- :random
- end
-
- ##
- # The time it took to run this test.
-
- attr_accessor :time
-
- def marshal_dump # :nodoc:
- super << self.time
- end
-
- def marshal_load ary # :nodoc:
- self.time = ary.pop
- super
- end
-
- ##
- # Runs a single test with setup/teardown hooks.
-
- def run
- with_info_handler do
- time_it do
- capture_exceptions do
- before_setup; setup; after_setup
-
- self.send self.name
- end
-
- %w{ before_teardown teardown after_teardown }.each do |hook|
- capture_exceptions do
- self.send hook
- end
- end
- end
- end
-
- self # per contract
- end
-
- ##
- # Provides before/after hooks for setup and teardown. These are
- # meant for library writers, NOT for regular test authors. See
- # #before_setup for an example.
-
- module LifecycleHooks
-
- ##
- # Runs before every test, before setup. This hook is meant for
- # libraries to extend minitest. It is not meant to be used by
- # test developers.
- #
- # As a simplistic example:
- #
- # module MyMinitestPlugin
- # def before_setup
- # super
- # # ... stuff to do before setup is run
- # end
- #
- # def after_setup
- # # ... stuff to do after setup is run
- # super
- # end
- #
- # def before_teardown
- # super
- # # ... stuff to do before teardown is run
- # end
- #
- # def after_teardown
- # # ... stuff to do after teardown is run
- # super
- # end
- # end
- #
- # class MiniTest::Test
- # include MyMinitestPlugin
- # end
-
- def before_setup; end
-
- ##
- # Runs before every test. Use this to set up before each test
- # run.
-
- def setup; end
-
- ##
- # Runs before every test, after setup. This hook is meant for
- # libraries to extend minitest. It is not meant to be used by
- # test developers.
- #
- # See #before_setup for an example.
-
- def after_setup; end
-
- ##
- # Runs after every test, before teardown. This hook is meant for
- # libraries to extend minitest. It is not meant to be used by
- # test developers.
- #
- # See #before_setup for an example.
-
- def before_teardown; end
-
- ##
- # Runs after every test. Use this to clean up after each test
- # run.
-
- def teardown; end
-
- ##
- # Runs after every test, after teardown. This hook is meant for
- # libraries to extend minitest. It is not meant to be used by
- # test developers.
- #
- # See #before_setup for an example.
-
- def after_teardown; end
- end # LifecycleHooks
-
- def capture_exceptions # :nodoc:
- begin
- yield
- rescue *PASSTHROUGH_EXCEPTIONS
- raise
- rescue Assertion => e
- self.failures << e
- rescue Exception => e
- self.failures << UnexpectedError.new(e)
- end
- end
-
- ##
- # Did this run error?
-
- def error?
- self.failures.any? { |f| UnexpectedError === f }
- end
-
- ##
- # The location identifier of this test.
-
- def location
- loc = " [#{self.failure.location}]" unless passed? or error?
- "#{self.class}##{self.name}#{loc}"
- end
-
- ##
- # Did this run pass?
- #
- # Note: skipped runs are not considered passing, but they don't
- # cause the process to exit non-zero.
-
- def passed?
- not self.failure
- end
-
- ##
- # Returns ".", "F", or "E" based on the result of the run.
-
- def result_code
- self.failure and self.failure.result_code or "."
- end
-
- ##
- # Was this run skipped?
-
- def skipped?
- self.failure and Skip === self.failure
- end
-
- def time_it # :nodoc:
- t0 = Time.now
-
- yield
- ensure
- self.time = Time.now - t0
- end
-
- def to_s # :nodoc:
- return location if passed? and not skipped?
-
- failures.map { |failure|
- "#{failure.result_label}:\n#{self.location}:\n#{failure.message}\n"
- }.join "\n"
- end
-
- def with_info_handler &block # :nodoc:
- t0 = Time.now
-
- handler = lambda do
- warn "\nCurrent: %s#%s %.2fs" % [self.class, self.name, Time.now - t0]
- end
-
- self.class.on_signal "INFO", handler, &block
- end
-
- include LifecycleHooks
- include Guard
- extend Guard
- end # Test
-end
-
-require "minitest/unit" unless defined?(MiniTest) # compatibility layer only
diff --git a/src/main/resources/stdlib/minitest/unit.rb b/src/main/resources/stdlib/minitest/unit.rb
deleted file mode 100644
index 28b549f..0000000
--- a/src/main/resources/stdlib/minitest/unit.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# :stopdoc:
-
-unless defined?(Minitest) then
- # all of this crap is just to avoid circular requires and is only
- # needed if a user requires "minitest/unit" directly instead of
- # "minitest/autorun", so we also warn
-
- from = caller.reject { |s| s =~ /rubygems/ }.join("\n ")
- warn "Warning: you should require 'minitest/autorun' instead."
- warn %(Warning: or add 'gem "minitest"' before 'require "minitest/autorun"')
- warn "From:\n #{from}"
-
- module Minitest; end
- MiniTest = Minitest # prevents minitest.rb from requiring back to us
- require "minitest"
-end
-
-MiniTest = Minitest unless defined?(MiniTest)
-
-module Minitest
- class Unit
- VERSION = Minitest::VERSION
- class TestCase < Minitest::Test
- def self.inherited klass # :nodoc:
- from = caller.first
- warn "MiniTest::Unit::TestCase is now Minitest::Test. From #{from}"
- super
- end
- end
-
- def self.autorun # :nodoc:
- from = caller.first
- warn "MiniTest::Unit.autorun is now Minitest.autorun. From #{from}"
- Minitest.autorun
- end
-
- def self.after_tests(&b)
- from = caller.first
- warn "MiniTest::Unit.after_tests is now Minitest.after_run. From #{from}"
- Minitest.after_run(&b)
- end
- end
-end
-
-# :startdoc:
diff --git a/src/main/resources/stdlib/mkmf.rb b/src/main/resources/stdlib/mkmf.rb
deleted file mode 100644
index 0c6c721..0000000
--- a/src/main/resources/stdlib/mkmf.rb
+++ /dev/null
@@ -1 +0,0 @@
-raise NotImplementedError, "C extensions are not supported"
diff --git a/src/main/resources/stdlib/monitor.rb b/src/main/resources/stdlib/monitor.rb
deleted file mode 100644
index 07394b5..0000000
--- a/src/main/resources/stdlib/monitor.rb
+++ /dev/null
@@ -1,300 +0,0 @@
-# = monitor.rb
-#
-# Copyright (C) 2001 Shugo Maeda
-#
-# This library is distributed under the terms of the Ruby license.
-# You can freely distribute/modify this library.
-#
-
-require 'thread'
-
-#
-# In concurrent programming, a monitor is an object or module intended to be
-# used safely by more than one thread. The defining characteristic of a
-# monitor is that its methods are executed with mutual exclusion. That is, at
-# each point in time, at most one thread may be executing any of its methods.
-# This mutual exclusion greatly simplifies reasoning about the implementation
-# of monitors compared to reasoning about parallel code that updates a data
-# structure.
-#
-# You can read more about the general principles on the Wikipedia page for
-# Monitors[http://en.wikipedia.org/wiki/Monitor_%28synchronization%29]
-#
-# == Examples
-#
-# === Simple object.extend
-#
-# require 'monitor.rb'
-#
-# buf = []
-# buf.extend(MonitorMixin)
-# empty_cond = buf.new_cond
-#
-# # consumer
-# Thread.start do
-# loop do
-# buf.synchronize do
-# empty_cond.wait_while { buf.empty? }
-# print buf.shift
-# end
-# end
-# end
-#
-# # producer
-# while line = ARGF.gets
-# buf.synchronize do
-# buf.push(line)
-# empty_cond.signal
-# end
-# end
-#
-# The consumer thread waits for the producer thread to push a line to buf
-# while buf.empty?. The producer thread (main thread) reads a
-# line from ARGF and pushes it into buf then calls empty_cond.signal
-# to notify the consumer thread of new data.
-#
-# === Simple Class include
-#
-# require 'monitor'
-#
-# class SynchronizedArray < Array
-#
-# include MonitorMixin
-#
-# def initialize(*args)
-# super(*args)
-# end
-#
-# alias :old_shift :shift
-# alias :old_unshift :unshift
-#
-# def shift(n=1)
-# self.synchronize do
-# self.old_shift(n)
-# end
-# end
-#
-# def unshift(item)
-# self.synchronize do
-# self.old_unshift(item)
-# end
-# end
-#
-# # other methods ...
-# end
-#
-# +SynchronizedArray+ implements an Array with synchronized access to items.
-# This Class is implemented as subclass of Array which includes the
-# MonitorMixin module.
-#
-module MonitorMixin
- #
- # FIXME: This isn't documented in Nutshell.
- #
- # Since MonitorMixin.new_cond returns a ConditionVariable, and the example
- # above calls while_wait and signal, this class should be documented.
- #
- class ConditionVariable
- class Timeout < Exception; end
-
- #
- # Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
- #
- # If +timeout+ is given, this method returns after +timeout+ seconds passed,
- # even if no other thread doesn't signal.
- #
- def wait(timeout = nil)
- @monitor.__send__(:mon_check_owner)
- count = @monitor.__send__(:mon_exit_for_cond)
- begin
- @cond.wait(@monitor.instance_variable_get(:@mon_mutex), timeout)
- return true
- ensure
- @monitor.__send__(:mon_enter_for_cond, count)
- end
- end
-
- #
- # Calls wait repeatedly while the given block yields a truthy value.
- #
- def wait_while
- while yield
- wait
- end
- end
-
- #
- # Calls wait repeatedly until the given block yields a truthy value.
- #
- def wait_until
- until yield
- wait
- end
- end
-
- #
- # Wakes up the first thread in line waiting for this lock.
- #
- def signal
- @monitor.__send__(:mon_check_owner)
- @cond.signal
- end
-
- #
- # Wakes up all threads waiting for this lock.
- #
- def broadcast
- @monitor.__send__(:mon_check_owner)
- @cond.broadcast
- end
-
- private
-
- def initialize(monitor)
- @monitor = monitor
- @cond = ::ConditionVariable.new
- end
- end
-
- def self.extend_object(obj)
- super(obj)
- obj.__send__(:mon_initialize)
- end
-
- #
- # Attempts to enter exclusive section. Returns +false+ if lock fails.
- #
- def mon_try_enter
- if @mon_owner != Thread.current
- unless @mon_mutex.try_lock
- return false
- end
- @mon_owner = Thread.current
- end
- @mon_count += 1
- return true
- end
- # For backward compatibility
- alias try_mon_enter mon_try_enter
-
- #
- # Enters exclusive section.
- #
- def mon_enter
- if @mon_owner != Thread.current
- @mon_mutex.lock
- @mon_owner = Thread.current
- end
- @mon_count += 1
- end
-
- #
- # Leaves exclusive section.
- #
- def mon_exit
- mon_check_owner
- @mon_count -=1
- if @mon_count == 0
- @mon_owner = nil
- @mon_mutex.unlock
- end
- end
-
- #
- # Enters exclusive section and executes the block. Leaves the exclusive
- # section automatically when the block exits. See example under
- # +MonitorMixin+.
- #
- def mon_synchronize
- mon_enter
- begin
- yield
- ensure
- mon_exit
- end
- end
- alias synchronize mon_synchronize
-
- #
- # Creates a new MonitorMixin::ConditionVariable associated with the
- # receiver.
- #
- def new_cond
- return ConditionVariable.new(self)
- end
-
- private
-
- # Use extend MonitorMixin or include MonitorMixin instead
- # of this constructor. Have look at the examples above to understand how to
- # use this module.
- def initialize(*args)
- super
- mon_initialize
- end
-
- # Initializes the MonitorMixin after being included in a class or when an
- # object has been extended with the MonitorMixin
- def mon_initialize
- @mon_owner = nil
- @mon_count = 0
- @mon_mutex = Mutex.new
- end
-
- def mon_check_owner
- if @mon_owner != Thread.current
- raise ThreadError, "current thread not owner"
- end
- end
-
- def mon_enter_for_cond(count)
- @mon_owner = Thread.current
- @mon_count = count
- end
-
- def mon_exit_for_cond
- count = @mon_count
- @mon_owner = nil
- @mon_count = 0
- return count
- end
-end
-
-# Use the Monitor class when you want to have a lock object for blocks with
-# mutual exclusion.
-#
-# require 'monitor'
-#
-# lock = Monitor.new
-# lock.synchronize do
-# # exclusive access
-# end
-#
-class Monitor
- include MonitorMixin
- alias try_enter try_mon_enter
- alias enter mon_enter
- alias exit mon_exit
-end
-
-
-# Documentation comments:
-# - All documentation comes from Nutshell.
-# - MonitorMixin.new_cond appears in the example, but is not documented in
-# Nutshell.
-# - All the internals (internal modules Accessible and Initializable, class
-# ConditionVariable) appear in RDoc. It might be good to hide them, by
-# making them private, or marking them :nodoc:, etc.
-# - RDoc doesn't recognise aliases, so we have mon_synchronize documented, but
-# not synchronize.
-# - mon_owner is in Nutshell, but appears as an accessor in a separate module
-# here, so is hard/impossible to RDoc. Some other useful accessors
-# (mon_count and some queue stuff) are also in this module, and don't appear
-# directly in the RDoc output.
-# - in short, it may be worth changing the code layout in this file to make the
-# documentation easier
-
-# Local variables:
-# mode: Ruby
-# tab-width: 8
-# End:
diff --git a/src/main/resources/stdlib/mutex_m.rb b/src/main/resources/stdlib/mutex_m.rb
deleted file mode 100644
index 6698cb5..0000000
--- a/src/main/resources/stdlib/mutex_m.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-#
-# mutex_m.rb -
-# $Release Version: 3.0$
-# $Revision: 1.7 $
-# Original from mutex.rb
-# by Keiju ISHITSUKA(keiju@ishitsuka.com)
-# modified by matz
-# patched by akira yamada
-#
-# --
-
-
-require 'thread'
-
-# = mutex_m.rb
-#
-# When 'mutex_m' is required, any object that extends or includes Mutex_m will
-# be treated like a Mutex.
-#
-# Start by requiring the standard library Mutex_m:
-#
-# require "mutex_m.rb"
-#
-# From here you can extend an object with Mutex instance methods:
-#
-# obj = Object.new
-# obj.extend Mutex_m
-#
-# Or mixin Mutex_m into your module to your class inherit Mutex instance
-# methods.
-#
-# class Foo
-# include Mutex_m
-# # ...
-# end
-# obj = Foo.new
-# # this obj can be handled like Mutex
-#
-module Mutex_m
- def Mutex_m.define_aliases(cl) # :nodoc:
- cl.module_eval %q{
- alias locked? mu_locked?
- alias lock mu_lock
- alias unlock mu_unlock
- alias try_lock mu_try_lock
- alias synchronize mu_synchronize
- }
- end
-
- def Mutex_m.append_features(cl) # :nodoc:
- super
- define_aliases(cl) unless cl.instance_of?(Module)
- end
-
- def Mutex_m.extend_object(obj) # :nodoc:
- super
- obj.mu_extended
- end
-
- def mu_extended # :nodoc:
- unless (defined? locked? and
- defined? lock and
- defined? unlock and
- defined? try_lock and
- defined? synchronize)
- Mutex_m.define_aliases(singleton_class)
- end
- mu_initialize
- end
-
- # See Mutex#synchronize
- def mu_synchronize(&block)
- @_mutex.synchronize(&block)
- end
-
- # See Mutex#locked?
- def mu_locked?
- @_mutex.locked?
- end
-
- # See Mutex#try_lock
- def mu_try_lock
- @_mutex.try_lock
- end
-
- # See Mutex#lock
- def mu_lock
- @_mutex.lock
- end
-
- # See Mutex#unlock
- def mu_unlock
- @_mutex.unlock
- end
-
- # See Mutex#sleep
- def sleep(timeout = nil)
- @_mutex.sleep(timeout)
- end
-
- private
-
- def mu_initialize # :nodoc:
- @_mutex = Mutex.new
- end
-
- def initialize(*args) # :nodoc:
- mu_initialize
- super
- end
-end
diff --git a/src/main/resources/stdlib/net/ftp.rb b/src/main/resources/stdlib/net/ftp.rb
deleted file mode 100644
index c64bb5c..0000000
--- a/src/main/resources/stdlib/net/ftp.rb
+++ /dev/null
@@ -1,1126 +0,0 @@
-#
-# = net/ftp.rb - FTP Client Library
-#
-# Written by Shugo Maeda .
-#
-# Documentation by Gavin Sinclair, sourced from "Programming Ruby" (Hunt/Thomas)
-# and "Ruby In a Nutshell" (Matsumoto), used with permission.
-#
-# This library is distributed under the terms of the Ruby license.
-# You can freely distribute/modify this library.
-#
-# It is included in the Ruby standard library.
-#
-# See the Net::FTP class for an overview.
-#
-
-require "socket"
-require "monitor"
-require "net/protocol"
-
-module Net
-
- # :stopdoc:
- class FTPError < StandardError; end
- class FTPReplyError < FTPError; end
- class FTPTempError < FTPError; end
- class FTPPermError < FTPError; end
- class FTPProtoError < FTPError; end
- class FTPConnectionError < FTPError; end
- # :startdoc:
-
- #
- # This class implements the File Transfer Protocol. If you have used a
- # command-line FTP program, and are familiar with the commands, you will be
- # able to use this class easily. Some extra features are included to take
- # advantage of Ruby's style and strengths.
- #
- # == Example
- #
- # require 'net/ftp'
- #
- # === Example 1
- #
- # ftp = Net::FTP.new('example.com')
- # ftp.login
- # files = ftp.chdir('pub/lang/ruby/contrib')
- # files = ftp.list('n*')
- # ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
- # ftp.close
- #
- # === Example 2
- #
- # Net::FTP.open('example.com') do |ftp|
- # ftp.login
- # files = ftp.chdir('pub/lang/ruby/contrib')
- # files = ftp.list('n*')
- # ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
- # end
- #
- # == Major Methods
- #
- # The following are the methods most likely to be useful to users:
- # - FTP.open
- # - #getbinaryfile
- # - #gettextfile
- # - #putbinaryfile
- # - #puttextfile
- # - #chdir
- # - #nlst
- # - #size
- # - #rename
- # - #delete
- #
- class FTP
- include MonitorMixin
-
- # :stopdoc:
- FTP_PORT = 21
- CRLF = "\r\n"
- DEFAULT_BLOCKSIZE = BufferedIO::BUFSIZE
- # :startdoc:
-
- # When +true+, transfers are performed in binary mode. Default: +true+.
- attr_reader :binary
-
- # When +true+, the connection is in passive mode. Default: +false+.
- attr_accessor :passive
-
- # When +true+, all traffic to and from the server is written
- # to +$stdout+. Default: +false+.
- attr_accessor :debug_mode
-
- # Sets or retrieves the +resume+ status, which decides whether incomplete
- # transfers are resumed or restarted. Default: +false+.
- attr_accessor :resume
-
- # Number of seconds to wait for the connection to open. Any number
- # may be used, including Floats for fractional seconds. If the FTP
- # object cannot open a connection in this many seconds, it raises a
- # Net::OpenTimeout exception. The default value is +nil+.
- attr_accessor :open_timeout
-
- # Number of seconds to wait for one block to be read (via one read(2)
- # call). Any number may be used, including Floats for fractional
- # seconds. If the FTP object cannot read data in this many seconds,
- # it raises a Timeout::Error exception. The default value is 60 seconds.
- attr_reader :read_timeout
-
- # Setter for the read_timeout attribute.
- def read_timeout=(sec)
- @sock.read_timeout = sec
- @read_timeout = sec
- end
-
- # The server's welcome message.
- attr_reader :welcome
-
- # The server's last response code.
- attr_reader :last_response_code
- alias lastresp last_response_code
-
- # The server's last response.
- attr_reader :last_response
-
- #
- # A synonym for FTP.new, but with a mandatory host parameter.
- #
- # If a block is given, it is passed the +FTP+ object, which will be closed
- # when the block finishes, or when an exception is raised.
- #
- def FTP.open(host, user = nil, passwd = nil, acct = nil)
- if block_given?
- ftp = new(host, user, passwd, acct)
- begin
- yield ftp
- ensure
- ftp.close
- end
- else
- new(host, user, passwd, acct)
- end
- end
-
- #
- # Creates and returns a new +FTP+ object. If a +host+ is given, a connection
- # is made. Additionally, if the +user+ is given, the given user name,
- # password, and (optionally) account are used to log in. See #login.
- #
- def initialize(host = nil, user = nil, passwd = nil, acct = nil)
- super()
- @binary = true
- @passive = false
- @debug_mode = false
- @resume = false
- @sock = NullSocket.new
- @logged_in = false
- @open_timeout = nil
- @read_timeout = 60
- if host
- connect(host)
- if user
- login(user, passwd, acct)
- end
- end
- end
-
- # A setter to toggle transfers in binary mode.
- # +newmode+ is either +true+ or +false+
- def binary=(newmode)
- if newmode != @binary
- @binary = newmode
- send_type_command if @logged_in
- end
- end
-
- # Sends a command to destination host, with the current binary sendmode
- # type.
- #
- # If binary mode is +true+, then "TYPE I" (image) is sent, otherwise "TYPE
- # A" (ascii) is sent.
- def send_type_command # :nodoc:
- if @binary
- voidcmd("TYPE I")
- else
- voidcmd("TYPE A")
- end
- end
- private :send_type_command
-
- # Toggles transfers in binary mode and yields to a block.
- # This preserves your current binary send mode, but allows a temporary
- # transaction with binary sendmode of +newmode+.
- #
- # +newmode+ is either +true+ or +false+
- def with_binary(newmode) # :nodoc:
- oldmode = binary
- self.binary = newmode
- begin
- yield
- ensure
- self.binary = oldmode
- end
- end
- private :with_binary
-
- # Obsolete
- def return_code # :nodoc:
- $stderr.puts("warning: Net::FTP#return_code is obsolete and do nothing")
- return "\n"
- end
-
- # Obsolete
- def return_code=(s) # :nodoc:
- $stderr.puts("warning: Net::FTP#return_code= is obsolete and do nothing")
- end
-
- # Constructs a socket with +host+ and +port+.
- #
- # If SOCKSSocket is defined and the environment (ENV) defines
- # SOCKS_SERVER, then a SOCKSSocket is returned, else a TCPSocket is
- # returned.
- def open_socket(host, port) # :nodoc:
- return Timeout.timeout(@open_timeout, Net::OpenTimeout) {
- if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
- @passive = true
- sock = SOCKSSocket.open(host, port)
- else
- sock = TCPSocket.open(host, port)
- end
- io = BufferedSocket.new(sock)
- io.read_timeout = @read_timeout
- io
- }
- end
- private :open_socket
-
- #
- # Establishes an FTP connection to host, optionally overriding the default
- # port. If the environment variable +SOCKS_SERVER+ is set, sets up the
- # connection through a SOCKS proxy. Raises an exception (typically
- # Errno::ECONNREFUSED) if the connection cannot be established.
- #
- def connect(host, port = FTP_PORT)
- if @debug_mode
- print "connect: ", host, ", ", port, "\n"
- end
- synchronize do
- @sock = open_socket(host, port)
- voidresp
- end
- end
-
- #
- # Set the socket used to connect to the FTP server.
- #
- # May raise FTPReplyError if +get_greeting+ is false.
- def set_socket(sock, get_greeting = true)
- synchronize do
- @sock = sock
- if get_greeting
- voidresp
- end
- end
- end
-
- # If string +s+ includes the PASS command (password), then the contents of
- # the password are cleaned from the string using "*"
- def sanitize(s) # :nodoc:
- if s =~ /^PASS /i
- return s[0, 5] + "*" * (s.length - 5)
- else
- return s
- end
- end
- private :sanitize
-
- # Ensures that +line+ has a control return / line feed (CRLF) and writes
- # it to the socket.
- def putline(line) # :nodoc:
- if @debug_mode
- print "put: ", sanitize(line), "\n"
- end
- line = line + CRLF
- @sock.write(line)
- end
- private :putline
-
- # Reads a line from the sock. If EOF, then it will raise EOFError
- def getline # :nodoc:
- line = @sock.readline # if get EOF, raise EOFError
- line.sub!(/(\r\n|\n|\r)\z/n, "")
- if @debug_mode
- print "get: ", sanitize(line), "\n"
- end
- return line
- end
- private :getline
-
- # Receive a section of lines until the response code's match.
- def getmultiline # :nodoc:
- line = getline
- buff = line
- if line[3] == ?-
- code = line[0, 3]
- begin
- line = getline
- buff << "\n" << line
- end until line[0, 3] == code and line[3] != ?-
- end
- return buff << "\n"
- end
- private :getmultiline
-
- # Receives a response from the destination host.
- #
- # Returns the response code or raises FTPTempError, FTPPermError, or
- # FTPProtoError
- def getresp # :nodoc:
- @last_response = getmultiline
- @last_response_code = @last_response[0, 3]
- case @last_response_code
- when /\A[123]/
- return @last_response
- when /\A4/
- raise FTPTempError, @last_response
- when /\A5/
- raise FTPPermError, @last_response
- else
- raise FTPProtoError, @last_response
- end
- end
- private :getresp
-
- # Receives a response.
- #
- # Raises FTPReplyError if the first position of the response code is not
- # equal 2.
- def voidresp # :nodoc:
- resp = getresp
- if resp[0] != ?2
- raise FTPReplyError, resp
- end
- end
- private :voidresp
-
- #
- # Sends a command and returns the response.
- #
- def sendcmd(cmd)
- synchronize do
- putline(cmd)
- return getresp
- end
- end
-
- #
- # Sends a command and expect a response beginning with '2'.
- #
- def voidcmd(cmd)
- synchronize do
- putline(cmd)
- voidresp
- end
- end
-
- # Constructs and send the appropriate PORT (or EPRT) command
- def sendport(host, port) # :nodoc:
- af = (@sock.peeraddr)[0]
- if af == "AF_INET"
- cmd = "PORT " + (host.split(".") + port.divmod(256)).join(",")
- elsif af == "AF_INET6"
- cmd = sprintf("EPRT |2|%s|%d|", host, port)
- else
- raise FTPProtoError, host
- end
- voidcmd(cmd)
- end
- private :sendport
-
- # Constructs a TCPServer socket, and sends it the PORT command
- #
- # Returns the constructed TCPServer socket
- def makeport # :nodoc:
- sock = TCPServer.open(@sock.addr[3], 0)
- port = sock.addr[1]
- host = sock.addr[3]
- sendport(host, port)
- return sock
- end
- private :makeport
-
- # sends the appropriate command to enable a passive connection
- def makepasv # :nodoc:
- if @sock.peeraddr[0] == "AF_INET"
- host, port = parse227(sendcmd("PASV"))
- else
- host, port = parse229(sendcmd("EPSV"))
- # host, port = parse228(sendcmd("LPSV"))
- end
- return host, port
- end
- private :makepasv
-
- # Constructs a connection for transferring data
- def transfercmd(cmd, rest_offset = nil) # :nodoc:
- if @passive
- host, port = makepasv
- conn = open_socket(host, port)
- if @resume and rest_offset
- resp = sendcmd("REST " + rest_offset.to_s)
- if resp[0] != ?3
- raise FTPReplyError, resp
- end
- end
- resp = sendcmd(cmd)
- # skip 2XX for some ftp servers
- resp = getresp if resp[0] == ?2
- if resp[0] != ?1
- raise FTPReplyError, resp
- end
- else
- sock = makeport
- begin
- if @resume and rest_offset
- resp = sendcmd("REST " + rest_offset.to_s)
- if resp[0] != ?3
- raise FTPReplyError, resp
- end
- end
- resp = sendcmd(cmd)
- # skip 2XX for some ftp servers
- resp = getresp if resp[0] == ?2
- if resp[0] != ?1
- raise FTPReplyError, resp
- end
- conn = BufferedSocket.new(sock.accept)
- conn.read_timeout = @read_timeout
- sock.shutdown(Socket::SHUT_WR) rescue nil
- sock.read rescue nil
- ensure
- sock.close
- end
- end
- return conn
- end
- private :transfercmd
-
- #
- # Logs in to the remote host. The session must have been
- # previously connected. If +user+ is the string "anonymous" and
- # the +password+ is +nil+, "anonymous@" is used as a password. If
- # the +acct+ parameter is not +nil+, an FTP ACCT command is sent
- # following the successful login. Raises an exception on error
- # (typically Net::FTPPermError).
- #
- def login(user = "anonymous", passwd = nil, acct = nil)
- if user == "anonymous" and passwd == nil
- passwd = "anonymous@"
- end
-
- resp = ""
- synchronize do
- resp = sendcmd('USER ' + user)
- if resp[0] == ?3
- raise FTPReplyError, resp if passwd.nil?
- resp = sendcmd('PASS ' + passwd)
- end
- if resp[0] == ?3
- raise FTPReplyError, resp if acct.nil?
- resp = sendcmd('ACCT ' + acct)
- end
- end
- if resp[0] != ?2
- raise FTPReplyError, resp
- end
- @welcome = resp
- send_type_command
- @logged_in = true
- end
-
- #
- # Puts the connection into binary (image) mode, issues the given command,
- # and fetches the data returned, passing it to the associated block in
- # chunks of +blocksize+ characters. Note that +cmd+ is a server command
- # (such as "RETR myfile").
- #
- def retrbinary(cmd, blocksize, rest_offset = nil) # :yield: data
- synchronize do
- with_binary(true) do
- begin
- conn = transfercmd(cmd, rest_offset)
- loop do
- data = conn.read(blocksize)
- break if data == nil
- yield(data)
- end
- conn.shutdown(Socket::SHUT_WR)
- conn.read_timeout = 1
- conn.read
- ensure
- conn.close if conn
- end
- voidresp
- end
- end
- end
-
- #
- # Puts the connection into ASCII (text) mode, issues the given command, and
- # passes the resulting data, one line at a time, to the associated block. If
- # no block is given, prints the lines. Note that +cmd+ is a server command
- # (such as "RETR myfile").
- #
- def retrlines(cmd) # :yield: line
- synchronize do
- with_binary(false) do
- begin
- conn = transfercmd(cmd)
- loop do
- line = conn.gets
- break if line == nil
- yield(line.sub(/\r?\n\z/, ""), !line.match(/\n\z/).nil?)
- end
- conn.shutdown(Socket::SHUT_WR)
- conn.read_timeout = 1
- conn.read
- ensure
- conn.close if conn
- end
- voidresp
- end
- end
- end
-
- #
- # Puts the connection into binary (image) mode, issues the given server-side
- # command (such as "STOR myfile"), and sends the contents of the file named
- # +file+ to the server. If the optional block is given, it also passes it
- # the data, in chunks of +blocksize+ characters.
- #
- def storbinary(cmd, file, blocksize, rest_offset = nil) # :yield: data
- if rest_offset
- file.seek(rest_offset, IO::SEEK_SET)
- end
- synchronize do
- with_binary(true) do
- conn = transfercmd(cmd)
- loop do
- buf = file.read(blocksize)
- break if buf == nil
- conn.write(buf)
- yield(buf) if block_given?
- end
- conn.close
- voidresp
- end
- end
- rescue Errno::EPIPE
- # EPIPE, in this case, means that the data connection was unexpectedly
- # terminated. Rather than just raising EPIPE to the caller, check the
- # response on the control connection. If getresp doesn't raise a more
- # appropriate exception, re-raise the original exception.
- getresp
- raise
- end
-
- #
- # Puts the connection into ASCII (text) mode, issues the given server-side
- # command (such as "STOR myfile"), and sends the contents of the file
- # named +file+ to the server, one line at a time. If the optional block is
- # given, it also passes it the lines.
- #
- def storlines(cmd, file) # :yield: line
- synchronize do
- with_binary(false) do
- conn = transfercmd(cmd)
- loop do
- buf = file.gets
- break if buf == nil
- if buf[-2, 2] != CRLF
- buf = buf.chomp + CRLF
- end
- conn.write(buf)
- yield(buf) if block_given?
- end
- conn.close
- voidresp
- end
- end
- rescue Errno::EPIPE
- # EPIPE, in this case, means that the data connection was unexpectedly
- # terminated. Rather than just raising EPIPE to the caller, check the
- # response on the control connection. If getresp doesn't raise a more
- # appropriate exception, re-raise the original exception.
- getresp
- raise
- end
-
- #
- # Retrieves +remotefile+ in binary mode, storing the result in +localfile+.
- # If +localfile+ is nil, returns retrieved data.
- # If a block is supplied, it is passed the retrieved data in +blocksize+
- # chunks.
- #
- def getbinaryfile(remotefile, localfile = File.basename(remotefile),
- blocksize = DEFAULT_BLOCKSIZE) # :yield: data
- result = nil
- if localfile
- if @resume
- rest_offset = File.size?(localfile)
- f = open(localfile, "a")
- else
- rest_offset = nil
- f = open(localfile, "w")
- end
- elsif !block_given?
- result = ""
- end
- begin
- f.binmode if localfile
- retrbinary("RETR " + remotefile.to_s, blocksize, rest_offset) do |data|
- f.write(data) if localfile
- yield(data) if block_given?
- result.concat(data) if result
- end
- return result
- ensure
- f.close if localfile
- end
- end
-
- #
- # Retrieves +remotefile+ in ASCII (text) mode, storing the result in
- # +localfile+.
- # If +localfile+ is nil, returns retrieved data.
- # If a block is supplied, it is passed the retrieved data one
- # line at a time.
- #
- def gettextfile(remotefile, localfile = File.basename(remotefile)) # :yield: line
- result = nil
- if localfile
- f = open(localfile, "w")
- elsif !block_given?
- result = ""
- end
- begin
- retrlines("RETR " + remotefile) do |line, newline|
- l = newline ? line + "\n" : line
- f.print(l) if localfile
- yield(line, newline) if block_given?
- result.concat(l) if result
- end
- return result
- ensure
- f.close if localfile
- end
- end
-
- #
- # Retrieves +remotefile+ in whatever mode the session is set (text or
- # binary). See #gettextfile and #getbinaryfile.
- #
- def get(remotefile, localfile = File.basename(remotefile),
- blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
- if @binary
- getbinaryfile(remotefile, localfile, blocksize, &block)
- else
- gettextfile(remotefile, localfile, &block)
- end
- end
-
- #
- # Transfers +localfile+ to the server in binary mode, storing the result in
- # +remotefile+. If a block is supplied, calls it, passing in the transmitted
- # data in +blocksize+ chunks.
- #
- def putbinaryfile(localfile, remotefile = File.basename(localfile),
- blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
- if @resume
- begin
- rest_offset = size(remotefile)
- rescue Net::FTPPermError
- rest_offset = nil
- end
- else
- rest_offset = nil
- end
- f = open(localfile)
- begin
- f.binmode
- if rest_offset
- storbinary("APPE " + remotefile, f, blocksize, rest_offset, &block)
- else
- storbinary("STOR " + remotefile, f, blocksize, rest_offset, &block)
- end
- ensure
- f.close
- end
- end
-
- #
- # Transfers +localfile+ to the server in ASCII (text) mode, storing the result
- # in +remotefile+. If callback or an associated block is supplied, calls it,
- # passing in the transmitted data one line at a time.
- #
- def puttextfile(localfile, remotefile = File.basename(localfile), &block) # :yield: line
- f = open(localfile)
- begin
- storlines("STOR " + remotefile, f, &block)
- ensure
- f.close
- end
- end
-
- #
- # Transfers +localfile+ to the server in whatever mode the session is set
- # (text or binary). See #puttextfile and #putbinaryfile.
- #
- def put(localfile, remotefile = File.basename(localfile),
- blocksize = DEFAULT_BLOCKSIZE, &block)
- if @binary
- putbinaryfile(localfile, remotefile, blocksize, &block)
- else
- puttextfile(localfile, remotefile, &block)
- end
- end
-
- #
- # Sends the ACCT command.
- #
- # This is a less common FTP command, to send account
- # information if the destination host requires it.
- #
- def acct(account)
- cmd = "ACCT " + account
- voidcmd(cmd)
- end
-
- #
- # Returns an array of filenames in the remote directory.
- #
- def nlst(dir = nil)
- cmd = "NLST"
- if dir
- cmd = cmd + " " + dir
- end
- files = []
- retrlines(cmd) do |line|
- files.push(line)
- end
- return files
- end
-
- #
- # Returns an array of file information in the directory (the output is like
- # `ls -l`). If a block is given, it iterates through the listing.
- #
- def list(*args, &block) # :yield: line
- cmd = "LIST"
- args.each do |arg|
- cmd = cmd + " " + arg.to_s
- end
- if block
- retrlines(cmd, &block)
- else
- lines = []
- retrlines(cmd) do |line|
- lines << line
- end
- return lines
- end
- end
- alias ls list
- alias dir list
-
- #
- # Renames a file on the server.
- #
- def rename(fromname, toname)
- resp = sendcmd("RNFR " + fromname)
- if resp[0] != ?3
- raise FTPReplyError, resp
- end
- voidcmd("RNTO " + toname)
- end
-
- #
- # Deletes a file on the server.
- #
- def delete(filename)
- resp = sendcmd("DELE " + filename)
- if resp[0, 3] == "250"
- return
- elsif resp[0] == ?5
- raise FTPPermError, resp
- else
- raise FTPReplyError, resp
- end
- end
-
- #
- # Changes the (remote) directory.
- #
- def chdir(dirname)
- if dirname == ".."
- begin
- voidcmd("CDUP")
- return
- rescue FTPPermError => e
- if e.message[0, 3] != "500"
- raise e
- end
- end
- end
- cmd = "CWD " + dirname
- voidcmd(cmd)
- end
-
- #
- # Returns the size of the given (remote) filename.
- #
- def size(filename)
- with_binary(true) do
- resp = sendcmd("SIZE " + filename)
- if resp[0, 3] != "213"
- raise FTPReplyError, resp
- end
- return resp[3..-1].strip.to_i
- end
- end
-
- MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/ # :nodoc:
-
- #
- # Returns the last modification time of the (remote) file. If +local+ is
- # +true+, it is returned as a local time, otherwise it's a UTC time.
- #
- def mtime(filename, local = false)
- str = mdtm(filename)
- ary = str.scan(MDTM_REGEXP)[0].collect {|i| i.to_i}
- return local ? Time.local(*ary) : Time.gm(*ary)
- end
-
- #
- # Creates a remote directory.
- #
- def mkdir(dirname)
- resp = sendcmd("MKD " + dirname)
- return parse257(resp)
- end
-
- #
- # Removes a remote directory.
- #
- def rmdir(dirname)
- voidcmd("RMD " + dirname)
- end
-
- #
- # Returns the current remote directory.
- #
- def pwd
- resp = sendcmd("PWD")
- return parse257(resp)
- end
- alias getdir pwd
-
- #
- # Returns system information.
- #
- def system
- resp = sendcmd("SYST")
- if resp[0, 3] != "215"
- raise FTPReplyError, resp
- end
- return resp[4 .. -1]
- end
-
- #
- # Aborts the previous command (ABOR command).
- #
- def abort
- line = "ABOR" + CRLF
- print "put: ABOR\n" if @debug_mode
- @sock.send(line, Socket::MSG_OOB)
- resp = getmultiline
- unless ["426", "226", "225"].include?(resp[0, 3])
- raise FTPProtoError, resp
- end
- return resp
- end
-
- #
- # Returns the status (STAT command).
- #
- def status
- line = "STAT" + CRLF
- print "put: STAT\n" if @debug_mode
- @sock.send(line, Socket::MSG_OOB)
- return getresp
- end
-
- #
- # Returns the raw last modification time of the (remote) file in the format
- # "YYYYMMDDhhmmss" (MDTM command).
- #
- # Use +mtime+ if you want a parsed Time instance.
- #
- def mdtm(filename)
- resp = sendcmd("MDTM " + filename)
- if resp[0, 3] == "213"
- return resp[3 .. -1].strip
- end
- end
-
- #
- # Issues the HELP command.
- #
- def help(arg = nil)
- cmd = "HELP"
- if arg
- cmd = cmd + " " + arg
- end
- sendcmd(cmd)
- end
-
- #
- # Exits the FTP session.
- #
- def quit
- voidcmd("QUIT")
- end
-
- #
- # Issues a NOOP command.
- #
- # Does nothing except return a response.
- #
- def noop
- voidcmd("NOOP")
- end
-
- #
- # Issues a SITE command.
- #
- def site(arg)
- cmd = "SITE " + arg
- voidcmd(cmd)
- end
-
- #
- # Closes the connection. Further operations are impossible until you open
- # a new connection with #connect.
- #
- def close
- if @sock and not @sock.closed?
- begin
- @sock.shutdown(Socket::SHUT_WR) rescue nil
- orig, self.read_timeout = self.read_timeout, 3
- @sock.read rescue nil
- ensure
- @sock.close
- self.read_timeout = orig
- end
- end
- end
-
- #
- # Returns +true+ iff the connection is closed.
- #
- def closed?
- @sock == nil or @sock.closed?
- end
-
- # handler for response code 227
- # (Entering Passive Mode (h1,h2,h3,h4,p1,p2))
- #
- # Returns host and port.
- def parse227(resp) # :nodoc:
- if resp[0, 3] != "227"
- raise FTPReplyError, resp
- end
- if m = /\((?\d+(,\d+){3}),(?\d+,\d+)\)/.match(resp)
- return parse_pasv_ipv4_host(m["host"]), parse_pasv_port(m["port"])
- else
- raise FTPProtoError, resp
- end
- end
- private :parse227
-
- # handler for response code 228
- # (Entering Long Passive Mode)
- #
- # Returns host and port.
- def parse228(resp) # :nodoc:
- if resp[0, 3] != "228"
- raise FTPReplyError, resp
- end
- if m = /\(4,4,(?\d+(,\d+){3}),2,(?\d+,\d+)\)/.match(resp)
- return parse_pasv_ipv4_host(m["host"]), parse_pasv_port(m["port"])
- elsif m = /\(6,16,(?\d+(,(\d+)){15}),2,(?\d+,\d+)\)/.match(resp)
- return parse_pasv_ipv6_host(m["host"]), parse_pasv_port(m["port"])
- else
- raise FTPProtoError, resp
- end
- end
- private :parse228
-
- def parse_pasv_ipv4_host(s)
- return s.tr(",", ".")
- end
- private :parse_pasv_ipv4_host
-
- def parse_pasv_ipv6_host(s)
- return s.split(/,/).map { |i|
- "%02x" % i.to_i
- }.each_slice(2).map(&:join).join(":")
- end
- private :parse_pasv_ipv6_host
-
- def parse_pasv_port(s)
- return s.split(/,/).map(&:to_i).inject { |x, y|
- (x << 8) + y
- }
- end
- private :parse_pasv_port
-
- # handler for response code 229
- # (Extended Passive Mode Entered)
- #
- # Returns host and port.
- def parse229(resp) # :nodoc:
- if resp[0, 3] != "229"
- raise FTPReplyError, resp
- end
- if m = /\((?[!-~])\k\k(?\d+)\k\)/.match(resp)
- return @sock.peeraddr[3], m["port"].to_i
- else
- raise FTPProtoError, resp
- end
- end
- private :parse229
-
- # handler for response code 257
- # ("PATHNAME" created)
- #
- # Returns host and port.
- def parse257(resp) # :nodoc:
- if resp[0, 3] != "257"
- raise FTPReplyError, resp
- end
- if resp[3, 2] != ' "'
- return ""
- end
- dirname = ""
- i = 5
- n = resp.length
- while i < n
- c = resp[i, 1]
- i = i + 1
- if c == '"'
- if i > n or resp[i, 1] != '"'
- break
- end
- i = i + 1
- end
- dirname = dirname + c
- end
- return dirname
- end
- private :parse257
-
- # :stopdoc:
- class NullSocket
- def read_timeout=(sec)
- end
-
- def close
- end
-
- def method_missing(mid, *args)
- raise FTPConnectionError, "not connected"
- end
- end
-
- class BufferedSocket < BufferedIO
- [:addr, :peeraddr, :send, :shutdown].each do |method|
- define_method(method) { |*args|
- @io.__send__(method, *args)
- }
- end
-
- def read(len = nil)
- if len
- s = super(len, "", true)
- return s.empty? ? nil : s
- else
- result = ""
- while s = super(DEFAULT_BLOCKSIZE, "", true)
- break if s.empty?
- result << s
- end
- return result
- end
- end
-
- def gets
- line = readuntil("\n", true)
- return line.empty? ? nil : line
- end
-
- def readline
- line = gets
- if line.nil?
- raise EOFError, "end of file reached"
- end
- return line
- end
- end
- # :startdoc:
- end
-end
-
-
-# Documentation comments:
-# - sourced from pickaxe and nutshell, with improvements (hopefully)
diff --git a/src/main/resources/stdlib/net/http.rb b/src/main/resources/stdlib/net/http.rb
deleted file mode 100644
index b75f2e8..0000000
--- a/src/main/resources/stdlib/net/http.rb
+++ /dev/null
@@ -1,1573 +0,0 @@
-#
-# = net/http.rb
-#
-# Copyright (c) 1999-2007 Yukihiro Matsumoto
-# Copyright (c) 1999-2007 Minero Aoki
-# Copyright (c) 2001 GOTOU Yuuzou
-#
-# Written and maintained by Minero Aoki .
-# HTTPS support added by GOTOU Yuuzou .
-#
-# This file is derived from "http-access.rb".
-#
-# Documented by Minero Aoki; converted to RDoc by William Webber.
-#
-# This program is free software. You can re-distribute and/or
-# modify this program under the same terms of ruby itself ---
-# Ruby Distribution License or GNU General Public License.
-#
-# See Net::HTTP for an overview and examples.
-#
-
-require 'net/protocol'
-require 'uri'
-
-module Net #:nodoc:
- autoload :OpenSSL, 'openssl'
-
- # :stopdoc:
- class HTTPBadResponse < StandardError; end
- class HTTPHeaderSyntaxError < StandardError; end
- # :startdoc:
-
- # == An HTTP client API for Ruby.
- #
- # Net::HTTP provides a rich library which can be used to build HTTP
- # user-agents. For more details about HTTP see
- # [RFC2616](http://www.ietf.org/rfc/rfc2616.txt)
- #
- # Net::HTTP is designed to work closely with URI. URI::HTTP#host,
- # URI::HTTP#port and URI::HTTP#request_uri are designed to work with
- # Net::HTTP.
- #
- # If you are only performing a few GET requests you should try OpenURI.
- #
- # == Simple Examples
- #
- # All examples assume you have loaded Net::HTTP with:
- #
- # require 'net/http'
- #
- # This will also require 'uri' so you don't need to require it separately.
- #
- # The Net::HTTP methods in the following section do not persist
- # connections. They are not recommended if you are performing many HTTP
- # requests.
- #
- # === GET
- #
- # Net::HTTP.get('example.com', '/index.html') # => String
- #
- # === GET by URI
- #
- # uri = URI('http://example.com/index.html?count=10')
- # Net::HTTP.get(uri) # => String
- #
- # === GET with Dynamic Parameters
- #
- # uri = URI('http://example.com/index.html')
- # params = { :limit => 10, :page => 3 }
- # uri.query = URI.encode_www_form(params)
- #
- # res = Net::HTTP.get_response(uri)
- # puts res.body if res.is_a?(Net::HTTPSuccess)
- #
- # === POST
- #
- # uri = URI('http://www.example.com/search.cgi')
- # res = Net::HTTP.post_form(uri, 'q' => 'ruby', 'max' => '50')
- # puts res.body
- #
- # === POST with Multiple Values
- #
- # uri = URI('http://www.example.com/search.cgi')
- # res = Net::HTTP.post_form(uri, 'q' => ['ruby', 'perl'], 'max' => '50')
- # puts res.body
- #
- # == How to use Net::HTTP
- #
- # The following example code can be used as the basis of a HTTP user-agent
- # which can perform a variety of request types using persistent
- # connections.
- #
- # uri = URI('http://example.com/some_path?query=string')
- #
- # Net::HTTP.start(uri.host, uri.port) do |http|
- # request = Net::HTTP::Get.new uri
- #
- # response = http.request request # Net::HTTPResponse object
- # end
- #
- # Net::HTTP::start immediately creates a connection to an HTTP server which
- # is kept open for the duration of the block. The connection will remain
- # open for multiple requests in the block if the server indicates it
- # supports persistent connections.
- #
- # The request types Net::HTTP supports are listed below in the section "HTTP
- # Request Classes".
- #
- # If you wish to re-use a connection across multiple HTTP requests without
- # automatically closing it you can use ::new instead of ::start. #request
- # will automatically open a connection to the server if one is not currently
- # open. You can manually close the connection with #finish.
- #
- # For all the Net::HTTP request objects and shortcut request methods you may
- # supply either a String for the request path or a URI from which Net::HTTP
- # will extract the request path.
- #
- # === Response Data
- #
- # uri = URI('http://example.com/index.html')
- # res = Net::HTTP.get_response(uri)
- #
- # # Headers
- # res['Set-Cookie'] # => String
- # res.get_fields('set-cookie') # => Array
- # res.to_hash['set-cookie'] # => Array
- # puts "Headers: #{res.to_hash.inspect}"
- #
- # # Status
- # puts res.code # => '200'
- # puts res.message # => 'OK'
- # puts res.class.name # => 'HTTPOK'
- #
- # # Body
- # puts res.body if res.response_body_permitted?
- #
- # === Following Redirection
- #
- # Each Net::HTTPResponse object belongs to a class for its response code.
- #
- # For example, all 2XX responses are instances of a Net::HTTPSuccess
- # subclass, a 3XX response is an instance of a Net::HTTPRedirection
- # subclass and a 200 response is an instance of the Net::HTTPOK class. For
- # details of response classes, see the section "HTTP Response Classes"
- # below.
- #
- # Using a case statement you can handle various types of responses properly:
- #
- # def fetch(uri_str, limit = 10)
- # # You should choose a better exception.
- # raise ArgumentError, 'too many HTTP redirects' if limit == 0
- #
- # response = Net::HTTP.get_response(URI(uri_str))
- #
- # case response
- # when Net::HTTPSuccess then
- # response
- # when Net::HTTPRedirection then
- # location = response['location']
- # warn "redirected to #{location}"
- # fetch(location, limit - 1)
- # else
- # response.value
- # end
- # end
- #
- # print fetch('http://www.ruby-lang.org')
- #
- # === POST
- #
- # A POST can be made using the Net::HTTP::Post request class. This example
- # creates a urlencoded POST body:
- #
- # uri = URI('http://www.example.com/todo.cgi')
- # req = Net::HTTP::Post.new(uri)
- # req.set_form_data('from' => '2005-01-01', 'to' => '2005-03-31')
- #
- # res = Net::HTTP.start(uri.hostname, uri.port) do |http|
- # http.request(req)
- # end
- #
- # case res
- # when Net::HTTPSuccess, Net::HTTPRedirection
- # # OK
- # else
- # res.value
- # end
- #
- # At this time Net::HTTP does not support multipart/form-data. To send
- # multipart/form-data use Net::HTTPRequest#body= and
- # Net::HTTPRequest#content_type=:
- #
- # req = Net::HTTP::Post.new(uri)
- # req.body = multipart_data
- # req.content_type = 'multipart/form-data'
- #
- # Other requests that can contain a body such as PUT can be created in the
- # same way using the corresponding request class (Net::HTTP::Put).
- #
- # === Setting Headers
- #
- # The following example performs a conditional GET using the
- # If-Modified-Since header. If the files has not been modified since the
- # time in the header a Not Modified response will be returned. See RFC 2616
- # section 9.3 for further details.
- #
- # uri = URI('http://example.com/cached_response')
- # file = File.stat 'cached_response'
- #
- # req = Net::HTTP::Get.new(uri)
- # req['If-Modified-Since'] = file.mtime.rfc2822
- #
- # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
- # http.request(req)
- # }
- #
- # open 'cached_response', 'w' do |io|
- # io.write res.body
- # end if res.is_a?(Net::HTTPSuccess)
- #
- # === Basic Authentication
- #
- # Basic authentication is performed according to
- # [RFC2617](http://www.ietf.org/rfc/rfc2617.txt)
- #
- # uri = URI('http://example.com/index.html?key=value')
- #
- # req = Net::HTTP::Get.new(uri)
- # req.basic_auth 'user', 'pass'
- #
- # res = Net::HTTP.start(uri.hostname, uri.port) {|http|
- # http.request(req)
- # }
- # puts res.body
- #
- # === Streaming Response Bodies
- #
- # By default Net::HTTP reads an entire response into memory. If you are
- # handling large files or wish to implement a progress bar you can instead
- # stream the body directly to an IO.
- #
- # uri = URI('http://example.com/large_file')
- #
- # Net::HTTP.start(uri.host, uri.port) do |http|
- # request = Net::HTTP::Get.new uri
- #
- # http.request request do |response|
- # open 'large_file', 'w' do |io|
- # response.read_body do |chunk|
- # io.write chunk
- # end
- # end
- # end
- # end
- #
- # === HTTPS
- #
- # HTTPS is enabled for an HTTP connection by Net::HTTP#use_ssl=.
- #
- # uri = URI('https://secure.example.com/some_path?query=string')
- #
- # Net::HTTP.start(uri.host, uri.port,
- # :use_ssl => uri.scheme == 'https') do |http|
- # request = Net::HTTP::Get.new uri
- #
- # response = http.request request # Net::HTTPResponse object
- # end
- #
- # In previous versions of Ruby you would need to require 'net/https' to use
- # HTTPS. This is no longer true.
- #
- # === Proxies
- #
- # Net::HTTP will automatically create a proxy from the +http_proxy+
- # environment variable if it is present. To disable use of +http_proxy+,
- # pass +nil+ for the proxy address.
- #
- # You may also create a custom proxy:
- #
- # proxy_addr = 'your.proxy.host'
- # proxy_port = 8080
- #
- # Net::HTTP.new('example.com', nil, proxy_addr, proxy_port).start { |http|
- # # always proxy via your.proxy.addr:8080
- # }
- #
- # See Net::HTTP.new for further details and examples such as proxies that
- # require a username and password.
- #
- # === Compression
- #
- # Net::HTTP automatically adds Accept-Encoding for compression of response
- # bodies and automatically decompresses gzip and deflate responses unless a
- # Range header was sent.
- #
- # Compression can be disabled through the Accept-Encoding: identity header.
- #
- # == HTTP Request Classes
- #
- # Here is the HTTP request class hierarchy.
- #
- # * Net::HTTPRequest
- # * Net::HTTP::Get
- # * Net::HTTP::Head
- # * Net::HTTP::Post
- # * Net::HTTP::Patch
- # * Net::HTTP::Put
- # * Net::HTTP::Proppatch
- # * Net::HTTP::Lock
- # * Net::HTTP::Unlock
- # * Net::HTTP::Options
- # * Net::HTTP::Propfind
- # * Net::HTTP::Delete
- # * Net::HTTP::Move
- # * Net::HTTP::Copy
- # * Net::HTTP::Mkcol
- # * Net::HTTP::Trace
- #
- # == HTTP Response Classes
- #
- # Here is HTTP response class hierarchy. All classes are defined in Net
- # module and are subclasses of Net::HTTPResponse.
- #
- # HTTPUnknownResponse:: For unhandled HTTP extensions
- # HTTPInformation:: 1xx
- # HTTPContinue:: 100
- # HTTPSwitchProtocol:: 101
- # HTTPSuccess:: 2xx
- # HTTPOK:: 200
- # HTTPCreated:: 201
- # HTTPAccepted:: 202
- # HTTPNonAuthoritativeInformation:: 203
- # HTTPNoContent:: 204
- # HTTPResetContent:: 205
- # HTTPPartialContent:: 206
- # HTTPMultiStatus:: 207
- # HTTPIMUsed:: 226
- # HTTPRedirection:: 3xx
- # HTTPMultipleChoices:: 300
- # HTTPMovedPermanently:: 301
- # HTTPFound:: 302
- # HTTPSeeOther:: 303
- # HTTPNotModified:: 304
- # HTTPUseProxy:: 305
- # HTTPTemporaryRedirect:: 307
- # HTTPClientError:: 4xx
- # HTTPBadRequest:: 400
- # HTTPUnauthorized:: 401
- # HTTPPaymentRequired:: 402
- # HTTPForbidden:: 403
- # HTTPNotFound:: 404
- # HTTPMethodNotAllowed:: 405
- # HTTPNotAcceptable:: 406
- # HTTPProxyAuthenticationRequired:: 407
- # HTTPRequestTimeOut:: 408
- # HTTPConflict:: 409
- # HTTPGone:: 410
- # HTTPLengthRequired:: 411
- # HTTPPreconditionFailed:: 412
- # HTTPRequestEntityTooLarge:: 413
- # HTTPRequestURITooLong:: 414
- # HTTPUnsupportedMediaType:: 415
- # HTTPRequestedRangeNotSatisfiable:: 416
- # HTTPExpectationFailed:: 417
- # HTTPUnprocessableEntity:: 422
- # HTTPLocked:: 423
- # HTTPFailedDependency:: 424
- # HTTPUpgradeRequired:: 426
- # HTTPPreconditionRequired:: 428
- # HTTPTooManyRequests:: 429
- # HTTPRequestHeaderFieldsTooLarge:: 431
- # HTTPServerError:: 5xx
- # HTTPInternalServerError:: 500
- # HTTPNotImplemented:: 501
- # HTTPBadGateway:: 502
- # HTTPServiceUnavailable:: 503
- # HTTPGatewayTimeOut:: 504
- # HTTPVersionNotSupported:: 505
- # HTTPInsufficientStorage:: 507
- # HTTPNetworkAuthenticationRequired:: 511
- #
- # There is also the Net::HTTPBadResponse exception which is raised when
- # there is a protocol error.
- #
- class HTTP < Protocol
-
- # :stopdoc:
- Revision = %q$Revision$.split[1]
- HTTPVersion = '1.1'
- begin
- require 'zlib'
- require 'stringio' #for our purposes (unpacking gzip) lump these together
- HAVE_ZLIB=true
- rescue LoadError
- HAVE_ZLIB=false
- end
- # :startdoc:
-
- # Turns on net/http 1.2 (Ruby 1.8) features.
- # Defaults to ON in Ruby 1.8 or later.
- def HTTP.version_1_2
- true
- end
-
- # Returns true if net/http is in version 1.2 mode.
- # Defaults to true.
- def HTTP.version_1_2?
- true
- end
-
- def HTTP.version_1_1? #:nodoc:
- false
- end
-
- class << HTTP
- alias is_version_1_1? version_1_1? #:nodoc:
- alias is_version_1_2? version_1_2? #:nodoc:
- end
-
- #
- # short cut methods
- #
-
- #
- # Gets the body text from the target and outputs it to $stdout. The
- # target can either be specified as
- # (+uri+), or as (+host+, +path+, +port+ = 80); so:
- #
- # Net::HTTP.get_print URI('http://www.example.com/index.html')
- #
- # or:
- #
- # Net::HTTP.get_print 'www.example.com', '/index.html'
- #
- def HTTP.get_print(uri_or_host, path = nil, port = nil)
- get_response(uri_or_host, path, port) {|res|
- res.read_body do |chunk|
- $stdout.print chunk
- end
- }
- nil
- end
-
- # Sends a GET request to the target and returns the HTTP response
- # as a string. The target can either be specified as
- # (+uri+), or as (+host+, +path+, +port+ = 80); so:
- #
- # print Net::HTTP.get(URI('http://www.example.com/index.html'))
- #
- # or:
- #
- # print Net::HTTP.get('www.example.com', '/index.html')
- #
- def HTTP.get(uri_or_host, path = nil, port = nil)
- get_response(uri_or_host, path, port).body
- end
-
- # Sends a GET request to the target and returns the HTTP response
- # as a Net::HTTPResponse object. The target can either be specified as
- # (+uri+), or as (+host+, +path+, +port+ = 80); so:
- #
- # res = Net::HTTP.get_response(URI('http://www.example.com/index.html'))
- # print res.body
- #
- # or:
- #
- # res = Net::HTTP.get_response('www.example.com', '/index.html')
- # print res.body
- #
- def HTTP.get_response(uri_or_host, path = nil, port = nil, &block)
- if path
- host = uri_or_host
- new(host, port || HTTP.default_port).start {|http|
- return http.request_get(path, &block)
- }
- else
- uri = uri_or_host
- start(uri.hostname, uri.port,
- :use_ssl => uri.scheme == 'https') {|http|
- return http.request_get(uri, &block)
- }
- end
- end
-
- # Posts HTML form data to the specified URI object.
- # The form data must be provided as a Hash mapping from String to String.
- # Example:
- #
- # { "cmd" => "search", "q" => "ruby", "max" => "50" }
- #
- # This method also does Basic Authentication iff +url+.user exists.
- # But userinfo for authentication is deprecated (RFC3986).
- # So this feature will be removed.
- #
- # Example:
- #
- # require 'net/http'
- # require 'uri'
- #
- # Net::HTTP.post_form URI('http://www.example.com/search.cgi'),
- # { "q" => "ruby", "max" => "50" }
- #
- def HTTP.post_form(url, params)
- req = Post.new(url)
- req.form_data = params
- req.basic_auth url.user, url.password if url.user
- start(url.hostname, url.port,
- :use_ssl => url.scheme == 'https' ) {|http|
- http.request(req)
- }
- end
-
- #
- # HTTP session management
- #
-
- # The default port to use for HTTP requests; defaults to 80.
- def HTTP.default_port
- http_default_port()
- end
-
- # The default port to use for HTTP requests; defaults to 80.
- def HTTP.http_default_port
- 80
- end
-
- # The default port to use for HTTPS requests; defaults to 443.
- def HTTP.https_default_port
- 443
- end
-
- def HTTP.socket_type #:nodoc: obsolete
- BufferedIO
- end
-
- # :call-seq:
- # HTTP.start(address, port, p_addr, p_port, p_user, p_pass, &block)
- # HTTP.start(address, port=nil, p_addr=nil, p_port=nil, p_user=nil, p_pass=nil, opt, &block)
- #
- # Creates a new Net::HTTP object, then additionally opens the TCP
- # connection and HTTP session.
- #
- # Arguments are the following:
- # _address_ :: hostname or IP address of the server
- # _port_ :: port of the server
- # _p_addr_ :: address of proxy
- # _p_port_ :: port of proxy
- # _p_user_ :: user of proxy
- # _p_pass_ :: pass of proxy
- # _opt_ :: optional hash
- #
- # _opt_ sets following values by its accessor.
- # The keys are ca_file, ca_path, cert, cert_store, ciphers,
- # close_on_empty_response, key, open_timeout, read_timeout, ssl_timeout,
- # ssl_version, use_ssl, verify_callback, verify_depth and verify_mode.
- # If you set :use_ssl as true, you can use https and default value of
- # verify_mode is set as OpenSSL::SSL::VERIFY_PEER.
- #
- # If the optional block is given, the newly
- # created Net::HTTP object is passed to it and closed when the
- # block finishes. In this case, the return value of this method
- # is the return value of the block. If no block is given, the
- # return value of this method is the newly created Net::HTTP object
- # itself, and the caller is responsible for closing it upon completion
- # using the finish() method.
- def HTTP.start(address, *arg, &block) # :yield: +http+
- arg.pop if opt = Hash.try_convert(arg[-1])
- port, p_addr, p_port, p_user, p_pass = *arg
- port = https_default_port if !port && opt && opt[:use_ssl]
- http = new(address, port, p_addr, p_port, p_user, p_pass)
-
- if opt
- if opt[:use_ssl]
- opt = {verify_mode: OpenSSL::SSL::VERIFY_PEER}.update(opt)
- end
- http.methods.grep(/\A(\w+)=\z/) do |meth|
- key = $1.to_sym
- opt.key?(key) or next
- http.__send__(meth, opt[key])
- end
- end
-
- http.start(&block)
- end
-
- class << HTTP
- alias newobj new # :nodoc:
- end
-
- # Creates a new Net::HTTP object without opening a TCP connection or
- # HTTP session.
- #
- # The +address+ should be a DNS hostname or IP address, the +port+ is the
- # port the server operates on. If no +port+ is given the default port for
- # HTTP or HTTPS is used.
- #
- # If none of the +p_+ arguments are given, the proxy host and port are
- # taken from the +http_proxy+ environment variable (or its uppercase
- # equivalent) if present. If the proxy requires authentication you must
- # supply it by hand. See URI::Generic#find_proxy for details of proxy
- # detection from the environment. To disable proxy detection set +p_addr+
- # to nil.
- #
- # If you are connecting to a custom proxy, +p_addr+ the DNS name or IP
- # address of the proxy host, +p_port+ the port to use to access the proxy,
- # and +p_user+ and +p_pass+ the username and password if authorization is
- # required to use the proxy.
- #
- # In JRuby, this will default to the JSE proxy settings provided in the
- # 'http.proxyHost' and 'http.proxyPort' Java system properties, if they
- # are set and no alternative proxy has been provided.
- #
- def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil)
- http = super address, port
-
- if proxy_class? then # from Net::HTTP::Proxy()
- http.proxy_from_env = @proxy_from_env
- http.proxy_address = @proxy_address
- http.proxy_port = @proxy_port
- http.proxy_user = @proxy_user
- http.proxy_pass = @proxy_pass
- elsif p_addr == :ENV then
- http.proxy_from_env = true
- else
- http.proxy_address = p_addr
- http.proxy_port = p_port || default_port
- http.proxy_user = p_user
- http.proxy_pass = p_pass
- end
-
- http
- end
-
- # Creates a new Net::HTTP object for the specified server address,
- # without opening the TCP connection or initializing the HTTP session.
- # The +address+ should be a DNS hostname or IP address.
- def initialize(address, port = nil)
- @address = address
- @port = (port || HTTP.default_port)
- @local_host = nil
- @local_port = nil
- @curr_http_version = HTTPVersion
- @keep_alive_timeout = 2
- @last_communicated = nil
- @close_on_empty_response = false
- @socket = nil
- @started = false
- @open_timeout = nil
- @read_timeout = 60
- @continue_timeout = nil
- @debug_output = nil
-
- @proxy_from_env = false
- @proxy_uri = nil
- @proxy_address = nil
- @proxy_port = nil
- @proxy_user = nil
- @proxy_pass = nil
-
- @use_ssl = false
- @ssl_context = nil
- @ssl_session = nil
- @enable_post_connection_check = true
- @sspi_enabled = false
- SSL_IVNAMES.each do |ivname|
- instance_variable_set ivname, nil
- end
- end
-
- def inspect
- "#<#{self.class} #{@address}:#{@port} open=#{started?}>"
- end
-
- # *WARNING* This method opens a serious security hole.
- # Never use this method in production code.
- #
- # Sets an output stream for debugging.
- #
- # http = Net::HTTP.new(hostname)
- # http.set_debug_output $stderr
- # http.start { .... }
- #
- def set_debug_output(output)
- warn 'Net::HTTP#set_debug_output called after HTTP started' if started?
- @debug_output = output
- end
-
- # The DNS host name or IP address to connect to.
- attr_reader :address
-
- # The port number to connect to.
- attr_reader :port
-
- # The local host used to establish the connection.
- attr_accessor :local_host
-
- # The local port used to establish the connection.
- attr_accessor :local_port
-
- attr_writer :proxy_from_env
- attr_writer :proxy_address
- attr_writer :proxy_port
- attr_writer :proxy_user
- attr_writer :proxy_pass
-
- # Number of seconds to wait for the connection to open. Any number
- # may be used, including Floats for fractional seconds. If the HTTP
- # object cannot open a connection in this many seconds, it raises a
- # Net::OpenTimeout exception. The default value is +nil+.
- attr_accessor :open_timeout
-
- # Number of seconds to wait for one block to be read (via one read(2)
- # call). Any number may be used, including Floats for fractional
- # seconds. If the HTTP object cannot read data in this many seconds,
- # it raises a Net::ReadTimeout exception. The default value is 60 seconds.
- attr_reader :read_timeout
-
- # Setter for the read_timeout attribute.
- def read_timeout=(sec)
- @socket.read_timeout = sec if @socket
- @read_timeout = sec
- end
-
- # Seconds to wait for 100 Continue response. If the HTTP object does not
- # receive a response in this many seconds it sends the request body. The
- # default value is +nil+.
- attr_reader :continue_timeout
-
- # Setter for the continue_timeout attribute.
- def continue_timeout=(sec)
- @socket.continue_timeout = sec if @socket
- @continue_timeout = sec
- end
-
- # Seconds to reuse the connection of the previous request.
- # If the idle time is less than this Keep-Alive Timeout,
- # Net::HTTP reuses the TCP/IP socket used by the previous communication.
- # The default value is 2 seconds.
- attr_accessor :keep_alive_timeout
-
- # Returns true if the HTTP session has been started.
- def started?
- @started
- end
-
- alias active? started? #:nodoc: obsolete
-
- attr_accessor :close_on_empty_response
-
- # Returns true if SSL/TLS is being used with HTTP.
- def use_ssl?
- @use_ssl
- end
-
- # Turn on/off SSL.
- # This flag must be set before starting session.
- # If you change use_ssl value after session started,
- # a Net::HTTP object raises IOError.
- def use_ssl=(flag)
- flag = flag ? true : false
- if started? and @use_ssl != flag
- raise IOError, "use_ssl value changed, but session already started"
- end
- @use_ssl = flag
- end
-
- SSL_IVNAMES = [
- :@ca_file,
- :@ca_path,
- :@cert,
- :@cert_store,
- :@ciphers,
- :@key,
- :@ssl_timeout,
- :@ssl_version,
- :@verify_callback,
- :@verify_depth,
- :@verify_mode,
- ]
- SSL_ATTRIBUTES = [
- :ca_file,
- :ca_path,
- :cert,
- :cert_store,
- :ciphers,
- :key,
- :ssl_timeout,
- :ssl_version,
- :verify_callback,
- :verify_depth,
- :verify_mode,
- ]
-
- # Sets path of a CA certification file in PEM format.
- #
- # The file can contain several CA certificates.
- attr_accessor :ca_file
-
- # Sets path of a CA certification directory containing certifications in
- # PEM format.
- attr_accessor :ca_path
-
- # Sets an OpenSSL::X509::Certificate object as client certificate.
- # (This method is appeared in Michal Rokos's OpenSSL extension).
- attr_accessor :cert
-
- # Sets the X509::Store to verify peer certificate.
- attr_accessor :cert_store
-
- # Sets the available ciphers. See OpenSSL::SSL::SSLContext#ciphers=
- attr_accessor :ciphers
-
- # Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
- # (This method is appeared in Michal Rokos's OpenSSL extension.)
- attr_accessor :key
-
- # Sets the SSL timeout seconds.
- attr_accessor :ssl_timeout
-
- # Sets the SSL version. See OpenSSL::SSL::SSLContext#ssl_version=
- attr_accessor :ssl_version
-
- # Sets the verify callback for the server certification verification.
- attr_accessor :verify_callback
-
- # Sets the maximum depth for the certificate chain verification.
- attr_accessor :verify_depth
-
- # Sets the flags for server the certification verification at beginning of
- # SSL/TLS session.
- #
- # OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER are acceptable.
- attr_accessor :verify_mode
-
- # Returns the X.509 certificates the server presented.
- def peer_cert
- if not use_ssl? or not @socket
- return nil
- end
- @socket.io.peer_cert
- end
-
- # Opens a TCP connection and HTTP session.
- #
- # When this method is called with a block, it passes the Net::HTTP
- # object to the block, and closes the TCP connection and HTTP session
- # after the block has been executed.
- #
- # When called with a block, it returns the return value of the
- # block; otherwise, it returns self.
- #
- def start # :yield: http
- raise IOError, 'HTTP session already opened' if @started
- if block_given?
- begin
- do_start
- return yield(self)
- ensure
- do_finish
- end
- end
- do_start
- self
- end
-
- def do_start
- connect
- @started = true
- end
- private :do_start
-
- def connect
- if proxy? then
- conn_address = proxy_address
- conn_port = proxy_port
- else
- conn_address = address
- conn_port = port
- end
-
- D "opening connection to #{conn_address}:#{conn_port}..."
- s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
- TCPSocket.open(conn_address, conn_port, @local_host, @local_port)
- }
- s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
- D "opened"
- if use_ssl?
- ssl_parameters = Hash.new
- iv_list = instance_variables
- SSL_IVNAMES.each_with_index do |ivname, i|
- if iv_list.include?(ivname) and
- value = instance_variable_get(ivname)
- ssl_parameters[SSL_ATTRIBUTES[i]] = value if value
- end
- end
- @ssl_context = OpenSSL::SSL::SSLContext.new
- @ssl_context.set_params(ssl_parameters)
- D "starting SSL for #{conn_address}:#{conn_port}..."
- s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
- s.sync_close = true
- D "SSL established"
- end
- @socket = BufferedIO.new(s)
- @socket.read_timeout = @read_timeout
- @socket.continue_timeout = @continue_timeout
- @socket.debug_output = @debug_output
- if use_ssl?
- begin
- if proxy?
- buf = "CONNECT #{@address}:#{@port} HTTP/#{HTTPVersion}\r\n"
- buf << "Host: #{@address}:#{@port}\r\n"
- if proxy_user
- credential = ["#{proxy_user}:#{proxy_pass}"].pack('m')
- credential.delete!("\r\n")
- buf << "Proxy-Authorization: Basic #{credential}\r\n"
- end
- buf << "\r\n"
- @socket.write(buf)
- HTTPResponse.read_new(@socket).value
- end
- if @ssl_session and
- Process.clock_gettime(Process::CLOCK_REALTIME) < @ssl_session.time.to_f + @ssl_session.timeout
- s.session = @ssl_session if @ssl_session
- end
- # Server Name Indication (SNI) RFC 3546
- s.hostname = @address if s.respond_to? :hostname=
- Timeout.timeout(@open_timeout, Net::OpenTimeout) { s.connect }
- if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
- s.post_connection_check(@address)
- end
- # Commented out until JRuby implements OpenSSL::SSL::Session
- #@ssl_session = s.session
- rescue => exception
- D "Conn close because of connect error #{exception}"
- @socket.close if @socket and not @socket.closed?
- raise exception
- end
- end
- on_connect
- end
- private :connect
-
- def on_connect
- end
- private :on_connect
-
- # Finishes the HTTP session and closes the TCP connection.
- # Raises IOError if the session has not been started.
- def finish
- raise IOError, 'HTTP session not yet started' unless started?
- do_finish
- end
-
- def do_finish
- @started = false
- @socket.close if @socket and not @socket.closed?
- @socket = nil
- end
- private :do_finish
-
- #
- # proxy
- #
-
- public
-
- # no proxy
- @is_proxy_class = false
- @proxy_from_env = false
- @proxy_addr = nil
- @proxy_port = nil
- @proxy_user = nil
- @proxy_pass = nil
-
- # Creates an HTTP proxy class which behaves like Net::HTTP, but
- # performs all access via the specified proxy.
- #
- # This class is obsolete. You may pass these same parameters directly to
- # Net::HTTP.new. See Net::HTTP.new for details of the arguments.
- #
- # In JRuby, this will default to the JSE proxy settings provided in the
- # 'http.proxyHost' and 'http.proxyPort' Java system properties, if they
- # are set and no alternative proxy has been provided.
- #
- def HTTP.Proxy(p_addr = :ENV, p_port = ENV_JAVA['http.proxyHost'], p_user = ENV_JAVA['http.proxyPort'], p_pass = nil)
- j_addr = ENV_JAVA['http.proxyHost']
- j_port = ENV_JAVA['http.proxyPort']
- p_addr = p_addr || j_addr
- p_port = p_port || j_port
- return self unless p_addr
-
- Class.new(self) {
- @is_proxy_class = true
-
- if p_addr == :ENV then
- @proxy_from_env = true
- @proxy_address = nil
- @proxy_port = nil
- else
- @proxy_from_env = false
- @proxy_address = p_addr
- @proxy_port = p_port || default_port
- end
-
- @proxy_user = p_user
- @proxy_pass = p_pass
- }
- end
-
- class << HTTP
- # returns true if self is a class which was created by HTTP::Proxy.
- def proxy_class?
- defined?(@is_proxy_class) ? @is_proxy_class : false
- end
-
- # Address of proxy host. If Net::HTTP does not use a proxy, nil.
- attr_reader :proxy_address
-
- # Port number of proxy host. If Net::HTTP does not use a proxy, nil.
- attr_reader :proxy_port
-
- # User name for accessing proxy. If Net::HTTP does not use a proxy, nil.
- attr_reader :proxy_user
-
- # User password for accessing proxy. If Net::HTTP does not use a proxy,
- # nil.
- attr_reader :proxy_pass
- end
-
- # True if requests for this connection will be proxied
- def proxy?
- !!if @proxy_from_env then
- proxy_uri
- else
- @proxy_address
- end
- end
-
- # True if the proxy for this connection is determined from the environment
- def proxy_from_env?
- @proxy_from_env
- end
-
- # The proxy URI determined from the environment for this connection.
- def proxy_uri # :nodoc:
- @proxy_uri ||= URI::HTTP.new(
- "http".freeze, nil, address, port, nil, nil, nil, nil, nil
- ).find_proxy
- end
-
- # The address of the proxy server, if one is configured.
- def proxy_address
- if @proxy_from_env then
- proxy_uri && proxy_uri.hostname
- else
- @proxy_address
- end
- end
-
- # The port of the proxy server, if one is configured.
- def proxy_port
- if @proxy_from_env then
- proxy_uri && proxy_uri.port
- else
- @proxy_port
- end
- end
-
- # The proxy username, if one is configured
- def proxy_user
- @proxy_user
- end
-
- # The proxy password, if one is configured
- def proxy_pass
- @proxy_pass
- end
-
- alias proxyaddr proxy_address #:nodoc: obsolete
- alias proxyport proxy_port #:nodoc: obsolete
-
- private
-
- # without proxy, obsolete
-
- def conn_address # :nodoc:
- address()
- end
-
- def conn_port # :nodoc:
- port()
- end
-
- def edit_path(path)
- if proxy? and not use_ssl? then
- "http://#{addr_port}#{path}"
- else
- path
- end
- end
-
- #
- # HTTP operations
- #
-
- public
-
- # Retrieves data from +path+ on the connected-to host which may be an
- # absolute path String or a URI to extract the path from.
- #
- # +initheader+ must be a Hash like { 'Accept' => '*/*', ... },
- # and it defaults to an empty hash.
- # If +initheader+ doesn't have the key 'accept-encoding', then
- # a value of "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" is used,
- # so that gzip compression is used in preference to deflate
- # compression, which is used in preference to no compression.
- # Ruby doesn't have libraries to support the compress (Lempel-Ziv)
- # compression, so that is not supported. The intent of this is
- # to reduce bandwidth by default. If this routine sets up
- # compression, then it does the decompression also, removing
- # the header as well to prevent confusion. Otherwise
- # it leaves the body as it found it.
- #
- # This method returns a Net::HTTPResponse object.
- #
- # If called with a block, yields each fragment of the
- # entity body in turn as a string as it is read from
- # the socket. Note that in this case, the returned response
- # object will *not* contain a (meaningful) body.
- #
- # +dest+ argument is obsolete.
- # It still works but you must not use it.
- #
- # This method never raises an exception.
- #
- # response = http.get('/index.html')
- #
- # # using block
- # File.open('result.txt', 'w') {|f|
- # http.get('/~foo/') do |str|
- # f.write str
- # end
- # }
- #
- def get(path, initheader = nil, dest = nil, &block) # :yield: +body_segment+
- res = nil
- request(Get.new(path, initheader)) {|r|
- r.read_body dest, &block
- res = r
- }
- res
- end
-
- # Gets only the header from +path+ on the connected-to host.
- # +header+ is a Hash like { 'Accept' => '*/*', ... }.
- #
- # This method returns a Net::HTTPResponse object.
- #
- # This method never raises an exception.
- #
- # response = nil
- # Net::HTTP.start('some.www.server', 80) {|http|
- # response = http.head('/index.html')
- # }
- # p response['content-type']
- #
- def head(path, initheader = nil)
- request(Head.new(path, initheader))
- end
-
- # Posts +data+ (must be a String) to +path+. +header+ must be a Hash
- # like { 'Accept' => '*/*', ... }.
- #
- # This method returns a Net::HTTPResponse object.
- #
- # If called with a block, yields each fragment of the
- # entity body in turn as a string as it is read from
- # the socket. Note that in this case, the returned response
- # object will *not* contain a (meaningful) body.
- #
- # +dest+ argument is obsolete.
- # It still works but you must not use it.
- #
- # This method never raises exception.
- #
- # response = http.post('/cgi-bin/search.rb', 'query=foo')
- #
- # # using block
- # File.open('result.txt', 'w') {|f|
- # http.post('/cgi-bin/search.rb', 'query=foo') do |str|
- # f.write str
- # end
- # }
- #
- # You should set Content-Type: header field for POST.
- # If no Content-Type: field given, this method uses
- # "application/x-www-form-urlencoded" by default.
- #
- def post(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
- send_entity(path, data, initheader, dest, Post, &block)
- end
-
- # Sends a PATCH request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
- send_entity(path, data, initheader, dest, Patch, &block)
- end
-
- def put(path, data, initheader = nil) #:nodoc:
- request(Put.new(path, initheader), data)
- end
-
- # Sends a PROPPATCH request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def proppatch(path, body, initheader = nil)
- request(Proppatch.new(path, initheader), body)
- end
-
- # Sends a LOCK request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def lock(path, body, initheader = nil)
- request(Lock.new(path, initheader), body)
- end
-
- # Sends a UNLOCK request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def unlock(path, body, initheader = nil)
- request(Unlock.new(path, initheader), body)
- end
-
- # Sends a OPTIONS request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def options(path, initheader = nil)
- request(Options.new(path, initheader))
- end
-
- # Sends a PROPFIND request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def propfind(path, body = nil, initheader = {'Depth' => '0'})
- request(Propfind.new(path, initheader), body)
- end
-
- # Sends a DELETE request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def delete(path, initheader = {'Depth' => 'Infinity'})
- request(Delete.new(path, initheader))
- end
-
- # Sends a MOVE request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def move(path, initheader = nil)
- request(Move.new(path, initheader))
- end
-
- # Sends a COPY request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def copy(path, initheader = nil)
- request(Copy.new(path, initheader))
- end
-
- # Sends a MKCOL request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def mkcol(path, body = nil, initheader = nil)
- request(Mkcol.new(path, initheader), body)
- end
-
- # Sends a TRACE request to the +path+ and gets a response,
- # as an HTTPResponse object.
- def trace(path, initheader = nil)
- request(Trace.new(path, initheader))
- end
-
- # Sends a GET request to the +path+.
- # Returns the response as a Net::HTTPResponse object.
- #
- # When called with a block, passes an HTTPResponse object to the block.
- # The body of the response will not have been read yet;
- # the block can process it using HTTPResponse#read_body,
- # if desired.
- #
- # Returns the response.
- #
- # This method never raises Net::* exceptions.
- #
- # response = http.request_get('/index.html')
- # # The entity body is already read in this case.
- # p response['content-type']
- # puts response.body
- #
- # # Using a block
- # http.request_get('/index.html') {|response|
- # p response['content-type']
- # response.read_body do |str| # read body now
- # print str
- # end
- # }
- #
- def request_get(path, initheader = nil, &block) # :yield: +response+
- request(Get.new(path, initheader), &block)
- end
-
- # Sends a HEAD request to the +path+ and returns the response
- # as a Net::HTTPResponse object.
- #
- # Returns the response.
- #
- # This method never raises Net::* exceptions.
- #
- # response = http.request_head('/index.html')
- # p response['content-type']
- #
- def request_head(path, initheader = nil, &block)
- request(Head.new(path, initheader), &block)
- end
-
- # Sends a POST request to the +path+.
- #
- # Returns the response as a Net::HTTPResponse object.
- #
- # When called with a block, the block is passed an HTTPResponse
- # object. The body of that response will not have been read yet;
- # the block can process it using HTTPResponse#read_body, if desired.
- #
- # Returns the response.
- #
- # This method never raises Net::* exceptions.
- #
- # # example
- # response = http.request_post('/cgi-bin/nice.rb', 'datadatadata...')
- # p response.status
- # puts response.body # body is already read in this case
- #
- # # using block
- # http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
- # p response.status
- # p response['content-type']
- # response.read_body do |str| # read body now
- # print str
- # end
- # }
- #
- def request_post(path, data, initheader = nil, &block) # :yield: +response+
- request Post.new(path, initheader), data, &block
- end
-
- def request_put(path, data, initheader = nil, &block) #:nodoc:
- request Put.new(path, initheader), data, &block
- end
-
- alias get2 request_get #:nodoc: obsolete
- alias head2 request_head #:nodoc: obsolete
- alias post2 request_post #:nodoc: obsolete
- alias put2 request_put #:nodoc: obsolete
-
-
- # Sends an HTTP request to the HTTP server.
- # Also sends a DATA string if +data+ is given.
- #
- # Returns a Net::HTTPResponse object.
- #
- # This method never raises Net::* exceptions.
- #
- # response = http.send_request('GET', '/index.html')
- # puts response.body
- #
- def send_request(name, path, data = nil, header = nil)
- has_response_body = name != 'HEAD'
- r = HTTPGenericRequest.new(name,(data ? true : false),has_response_body,path,header)
- request r, data
- end
-
- # Sends an HTTPRequest object +req+ to the HTTP server.
- #
- # If +req+ is a Net::HTTP::Post or Net::HTTP::Put request containing
- # data, the data is also sent. Providing data for a Net::HTTP::Head or
- # Net::HTTP::Get request results in an ArgumentError.
- #
- # Returns an HTTPResponse object.
- #
- # When called with a block, passes an HTTPResponse object to the block.
- # The body of the response will not have been read yet;
- # the block can process it using HTTPResponse#read_body,
- # if desired.
- #
- # This method never raises Net::* exceptions.
- #
- def request(req, body = nil, &block) # :yield: +response+
- unless started?
- start {
- req['connection'] ||= 'close'
- return request(req, body, &block)
- }
- end
- if proxy_user()
- req.proxy_basic_auth proxy_user(), proxy_pass() unless use_ssl?
- end
- req.set_body_internal body
- res = transport_request(req, &block)
- if sspi_auth?(res)
- sspi_auth(req)
- res = transport_request(req, &block)
- end
- res
- end
-
- private
-
- # Executes a request which uses a representation
- # and returns its body.
- def send_entity(path, data, initheader, dest, type, &block)
- res = nil
- request(type.new(path, initheader), data) {|r|
- r.read_body dest, &block
- res = r
- }
- res
- end
-
- IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/ # :nodoc:
-
- def transport_request(req)
- count = 0
- begin
- begin_transport req
- res = catch(:response) {
- req.exec @socket, @curr_http_version, edit_path(req.path)
- begin
- res = HTTPResponse.read_new(@socket)
- res.decode_content = req.decode_content
- end while res.kind_of?(HTTPContinue)
-
- res.uri = req.uri
-
- res.reading_body(@socket, req.response_body_permitted?) {
- yield res if block_given?
- }
- res
- }
- rescue Net::OpenTimeout
- raise
- rescue Net::ReadTimeout, IOError, EOFError,
- Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE,
- # avoid a dependency on OpenSSL
- defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : IOError,
- Timeout::Error => exception
- if count == 0 && IDEMPOTENT_METHODS_.include?(req.method)
- count += 1
- @socket.close if @socket and not @socket.closed?
- D "Conn close because of error #{exception}, and retry"
- retry
- end
- D "Conn close because of error #{exception}"
- @socket.close if @socket and not @socket.closed?
- raise
- end
-
- end_transport req, res
- res
- rescue => exception
- D "Conn close because of error #{exception}"
- @socket.close if @socket and not @socket.closed?
- raise exception
- end
-
- def begin_transport(req)
- if @socket.closed?
- connect
- elsif @last_communicated && @last_communicated + @keep_alive_timeout < Time.now
- D 'Conn close because of keep_alive_timeout'
- @socket.close
- connect
- end
-
- if not req.response_body_permitted? and @close_on_empty_response
- req['connection'] ||= 'close'
- end
-
- req.update_uri address, port, use_ssl?
- req['host'] ||= addr_port()
- end
-
- def end_transport(req, res)
- @curr_http_version = res.http_version
- @last_communicated = nil
- if @socket.closed?
- D 'Conn socket closed'
- elsif not res.body and @close_on_empty_response
- D 'Conn close'
- @socket.close
- elsif keep_alive?(req, res)
- D 'Conn keep-alive'
- @last_communicated = Time.now
- else
- D 'Conn close'
- @socket.close
- end
- end
-
- def keep_alive?(req, res)
- return false if req.connection_close?
- if @curr_http_version <= '1.0'
- res.connection_keep_alive?
- else # HTTP/1.1 or later
- not res.connection_close?
- end
- end
-
- def sspi_auth?(res)
- return false unless @sspi_enabled
- if res.kind_of?(HTTPProxyAuthenticationRequired) and
- proxy? and res["Proxy-Authenticate"].include?("Negotiate")
- begin
- require 'win32/sspi'
- true
- rescue LoadError
- false
- end
- else
- false
- end
- end
-
- def sspi_auth(req)
- n = Win32::SSPI::NegotiateAuth.new
- req["Proxy-Authorization"] = "Negotiate #{n.get_initial_token}"
- # Some versions of ISA will close the connection if this isn't present.
- req["Connection"] = "Keep-Alive"
- req["Proxy-Connection"] = "Keep-Alive"
- res = transport_request(req)
- authphrase = res["Proxy-Authenticate"] or return res
- req["Proxy-Authorization"] = "Negotiate #{n.complete_authentication(authphrase)}"
- rescue => err
- raise HTTPAuthenticationError.new('HTTP authentication failed', err)
- end
-
- #
- # utils
- #
-
- private
-
- def addr_port
- if use_ssl?
- address() + (port == HTTP.https_default_port ? '' : ":#{port()}")
- else
- address() + (port == HTTP.http_default_port ? '' : ":#{port()}")
- end
- end
-
- def D(msg)
- return unless @debug_output
- @debug_output << msg
- @debug_output << "\n"
- end
- end
-
-end
-
-require 'net/http/exceptions'
-
-require 'net/http/header'
-
-require 'net/http/generic_request'
-require 'net/http/request'
-require 'net/http/requests'
-
-require 'net/http/response'
-require 'net/http/responses'
-
-require 'net/http/proxy_delta'
-
-require 'net/http/backward'
-
diff --git a/src/main/resources/stdlib/net/http/backward.rb b/src/main/resources/stdlib/net/http/backward.rb
deleted file mode 100644
index faf47b8..0000000
--- a/src/main/resources/stdlib/net/http/backward.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# for backward compatibility
-
-# :enddoc:
-
-class Net::HTTP
- ProxyMod = ProxyDelta
-end
-
-module Net
- HTTPSession = Net::HTTP
-end
-
-module Net::NetPrivate
- HTTPRequest = ::Net::HTTPRequest
-end
-
-Net::HTTPInformationCode = Net::HTTPInformation
-Net::HTTPSuccessCode = Net::HTTPSuccess
-Net::HTTPRedirectionCode = Net::HTTPRedirection
-Net::HTTPRetriableCode = Net::HTTPRedirection
-Net::HTTPClientErrorCode = Net::HTTPClientError
-Net::HTTPFatalErrorCode = Net::HTTPClientError
-Net::HTTPServerErrorCode = Net::HTTPServerError
-Net::HTTPResponceReceiver = Net::HTTPResponse
-
diff --git a/src/main/resources/stdlib/net/http/exceptions.rb b/src/main/resources/stdlib/net/http/exceptions.rb
deleted file mode 100644
index 6c5d81c..0000000
--- a/src/main/resources/stdlib/net/http/exceptions.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# Net::HTTP exception class.
-# You cannot use Net::HTTPExceptions directly; instead, you must use
-# its subclasses.
-module Net::HTTPExceptions
- def initialize(msg, res) #:nodoc:
- super msg
- @response = res
- end
- attr_reader :response
- alias data response #:nodoc: obsolete
-end
-class Net::HTTPError < Net::ProtocolError
- include Net::HTTPExceptions
-end
-class Net::HTTPRetriableError < Net::ProtoRetriableError
- include Net::HTTPExceptions
-end
-class Net::HTTPServerException < Net::ProtoServerError
- # We cannot use the name "HTTPServerError", it is the name of the response.
- include Net::HTTPExceptions
-end
-class Net::HTTPFatalError < Net::ProtoFatalError
- include Net::HTTPExceptions
-end
-
diff --git a/src/main/resources/stdlib/net/http/generic_request.rb b/src/main/resources/stdlib/net/http/generic_request.rb
deleted file mode 100644
index 00ff434..0000000
--- a/src/main/resources/stdlib/net/http/generic_request.rb
+++ /dev/null
@@ -1,332 +0,0 @@
-# HTTPGenericRequest is the parent of the HTTPRequest class.
-# Do not use this directly; use a subclass of HTTPRequest.
-#
-# Mixes in the HTTPHeader module to provide easier access to HTTP headers.
-#
-class Net::HTTPGenericRequest
-
- include Net::HTTPHeader
-
- def initialize(m, reqbody, resbody, uri_or_path, initheader = nil)
- @method = m
- @request_has_body = reqbody
- @response_has_body = resbody
-
- if URI === uri_or_path then
- @uri = uri_or_path.dup
- host = @uri.hostname.dup
- host << ":".freeze << @uri.port.to_s if @uri.port != @uri.default_port
- @path = uri_or_path.request_uri
- raise ArgumentError, "no HTTP request path given" unless @path
- else
- @uri = nil
- host = nil
- raise ArgumentError, "no HTTP request path given" unless uri_or_path
- raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty?
- @path = uri_or_path.dup
- end
-
- @decode_content = false
-
- if @response_has_body and Net::HTTP::HAVE_ZLIB then
- if !initheader ||
- !initheader.keys.any? { |k|
- %w[accept-encoding range].include? k.downcase
- } then
- @decode_content = true
- initheader = initheader ? initheader.dup : {}
- initheader["accept-encoding"] =
- "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
- end
- end
-
- initialize_http_header initheader
- self['Accept'] ||= '*/*'
- self['User-Agent'] ||= 'Ruby'
- self['Host'] ||= host if host
- @body = nil
- @body_stream = nil
- @body_data = nil
- end
-
- attr_reader :method
- attr_reader :path
- attr_reader :uri
-
- # Automatically set to false if the user sets the Accept-Encoding header.
- # This indicates they wish to handle Content-encoding in responses
- # themselves.
- attr_reader :decode_content
-
- def inspect
- "\#<#{self.class} #{@method}>"
- end
-
- ##
- # Don't automatically decode response content-encoding if the user indicates
- # they want to handle it.
-
- def []=(key, val) # :nodoc:
- @decode_content = false if key.downcase == 'accept-encoding'
-
- super key, val
- end
-
- def request_body_permitted?
- @request_has_body
- end
-
- def response_body_permitted?
- @response_has_body
- end
-
- def body_exist?
- warn "Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?" if $VERBOSE
- response_body_permitted?
- end
-
- attr_reader :body
-
- def body=(str)
- @body = str
- @body_stream = nil
- @body_data = nil
- str
- end
-
- attr_reader :body_stream
-
- def body_stream=(input)
- @body = nil
- @body_stream = input
- @body_data = nil
- input
- end
-
- def set_body_internal(str) #:nodoc: internal use only
- raise ArgumentError, "both of body argument and HTTPRequest#body set" if str and (@body or @body_stream)
- self.body = str if str
- if @body.nil? && @body_stream.nil? && @body_data.nil? && request_body_permitted?
- self.body = ''
- end
- end
-
- #
- # write
- #
-
- def exec(sock, ver, path) #:nodoc: internal use only
- if @body
- send_request_with_body sock, ver, path, @body
- elsif @body_stream
- send_request_with_body_stream sock, ver, path, @body_stream
- elsif @body_data
- send_request_with_body_data sock, ver, path, @body_data
- else
- write_header sock, ver, path
- end
- end
-
- def update_uri(addr, port, ssl) # :nodoc: internal use only
- # reflect the connection and @path to @uri
- return unless @uri
-
- if ssl
- scheme = 'https'.freeze
- klass = URI::HTTPS
- else
- scheme = 'http'.freeze
- klass = URI::HTTP
- end
-
- if host = self['host']
- host.sub!(/:.*/s, ''.freeze)
- elsif host = @uri.host
- else
- host = addr
- end
- # convert the class of the URI
- if @uri.is_a?(klass)
- @uri.host = host
- @uri.port = port
- else
- @uri = klass.new(
- scheme, @uri.userinfo,
- host, port, nil,
- @uri.path, nil, @uri.query, nil)
- end
- end
-
- private
-
- class Chunker #:nodoc:
- def initialize(sock)
- @sock = sock
- @prev = nil
- end
-
- def write(buf)
- # avoid memcpy() of buf, buf can huge and eat memory bandwidth
- @sock.write("#{buf.bytesize.to_s(16)}\r\n")
- rv = @sock.write(buf)
- @sock.write("\r\n")
- rv
- end
-
- def finish
- @sock.write("0\r\n\r\n")
- end
- end
-
- def send_request_with_body(sock, ver, path, body)
- self.content_length = body.bytesize
- delete 'Transfer-Encoding'
- supply_default_content_type
- write_header sock, ver, path
- wait_for_continue sock, ver if sock.continue_timeout
- sock.write body
- end
-
- def send_request_with_body_stream(sock, ver, path, f)
- unless content_length() or chunked?
- raise ArgumentError,
- "Content-Length not given and Transfer-Encoding is not `chunked'"
- end
- supply_default_content_type
- write_header sock, ver, path
- wait_for_continue sock, ver if sock.continue_timeout
- if chunked?
- chunker = Chunker.new(sock)
- IO.copy_stream(f, chunker)
- chunker.finish
- else
- # copy_stream can sendfile() to sock.io unless we use SSL.
- # If sock.io is an SSLSocket, copy_stream will hit SSL_write()
- IO.copy_stream(f, sock.io)
- end
- end
-
- def send_request_with_body_data(sock, ver, path, params)
- if /\Amultipart\/form-data\z/i !~ self.content_type
- self.content_type = 'application/x-www-form-urlencoded'
- return send_request_with_body(sock, ver, path, URI.encode_www_form(params))
- end
-
- opt = @form_option.dup
- require 'securerandom' unless defined?(SecureRandom)
- opt[:boundary] ||= SecureRandom.urlsafe_base64(40)
- self.set_content_type(self.content_type, boundary: opt[:boundary])
- if chunked?
- write_header sock, ver, path
- encode_multipart_form_data(sock, params, opt)
- else
- require 'tempfile'
- file = Tempfile.new('multipart')
- file.binmode
- encode_multipart_form_data(file, params, opt)
- file.rewind
- self.content_length = file.size
- write_header sock, ver, path
- IO.copy_stream(file, sock)
- file.close(true)
- end
- end
-
- def encode_multipart_form_data(out, params, opt)
- charset = opt[:charset]
- boundary = opt[:boundary]
- require 'securerandom' unless defined?(SecureRandom)
- boundary ||= SecureRandom.urlsafe_base64(40)
- chunked_p = chunked?
-
- buf = ''
- params.each do |key, value, h={}|
- key = quote_string(key, charset)
- filename =
- h.key?(:filename) ? h[:filename] :
- value.respond_to?(:to_path) ? File.basename(value.to_path) :
- nil
-
- buf << "--#{boundary}\r\n"
- if filename
- filename = quote_string(filename, charset)
- type = h[:content_type] || 'application/octet-stream'
- buf << "Content-Disposition: form-data; " \
- "name=\"#{key}\"; filename=\"#{filename}\"\r\n" \
- "Content-Type: #{type}\r\n\r\n"
- if !out.respond_to?(:write) || !value.respond_to?(:read)
- # if +out+ is not an IO or +value+ is not an IO
- buf << (value.respond_to?(:read) ? value.read : value)
- elsif value.respond_to?(:size) && chunked_p
- # if +out+ is an IO and +value+ is a File, use IO.copy_stream
- flush_buffer(out, buf, chunked_p)
- out << "%x\r\n" % value.size if chunked_p
- IO.copy_stream(value, out)
- out << "\r\n" if chunked_p
- else
- # +out+ is an IO, and +value+ is not a File but an IO
- flush_buffer(out, buf, chunked_p)
- 1 while flush_buffer(out, value.read(4096), chunked_p)
- end
- else
- # non-file field:
- # HTML5 says, "The parts of the generated multipart/form-data
- # resource that correspond to non-file fields must not have a
- # Content-Type header specified."
- buf << "Content-Disposition: form-data; name=\"#{key}\"\r\n\r\n"
- buf << (value.respond_to?(:read) ? value.read : value)
- end
- buf << "\r\n"
- end
- buf << "--#{boundary}--\r\n"
- flush_buffer(out, buf, chunked_p)
- out << "0\r\n\r\n" if chunked_p
- end
-
- def quote_string(str, charset)
- str = str.encode(charset, fallback:->(c){'%d;'%c.encode("UTF-8").ord}) if charset
- str.gsub(/[\\"]/, '\\\\\&')
- end
-
- def flush_buffer(out, buf, chunked_p)
- return unless buf
- out << "%x\r\n"%buf.bytesize if chunked_p
- out << buf
- out << "\r\n" if chunked_p
- buf.clear
- end
-
- def supply_default_content_type
- return if content_type()
- warn 'net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded' if $VERBOSE
- set_content_type 'application/x-www-form-urlencoded'
- end
-
- ##
- # Waits up to the continue timeout for a response from the server provided
- # we're speaking HTTP 1.1 and are expecting a 100-continue response.
-
- def wait_for_continue(sock, ver)
- if ver >= '1.1' and @header['expect'] and
- @header['expect'].include?('100-continue')
- if IO.select([sock.io], nil, nil, sock.continue_timeout)
- res = Net::HTTPResponse.read_new(sock)
- unless res.kind_of?(Net::HTTPContinue)
- res.decode_content = @decode_content
- throw :response, res
- end
- end
- end
- end
-
- def write_header(sock, ver, path)
- buf = "#{@method} #{path} HTTP/#{ver}\r\n"
- each_capitalized do |k,v|
- buf << "#{k}: #{v}\r\n"
- end
- buf << "\r\n"
- sock.write buf
- end
-
-end
-
diff --git a/src/main/resources/stdlib/net/http/header.rb b/src/main/resources/stdlib/net/http/header.rb
deleted file mode 100644
index 912419d..0000000
--- a/src/main/resources/stdlib/net/http/header.rb
+++ /dev/null
@@ -1,452 +0,0 @@
-# The HTTPHeader module defines methods for reading and writing
-# HTTP headers.
-#
-# It is used as a mixin by other classes, to provide hash-like
-# access to HTTP header values. Unlike raw hash access, HTTPHeader
-# provides access via case-insensitive keys. It also provides
-# methods for accessing commonly-used HTTP header values in more
-# convenient formats.
-#
-module Net::HTTPHeader
-
- def initialize_http_header(initheader)
- @header = {}
- return unless initheader
- initheader.each do |key, value|
- warn "net/http: warning: duplicated HTTP header: #{key}" if key?(key) and $VERBOSE
- @header[key.downcase] = [value.strip]
- end
- end
-
- def size #:nodoc: obsolete
- @header.size
- end
-
- alias length size #:nodoc: obsolete
-
- # Returns the header field corresponding to the case-insensitive key.
- # For example, a key of "Content-Type" might return "text/html"
- def [](key)
- a = @header[key.downcase] or return nil
- a.join(', ')
- end
-
- # Sets the header field corresponding to the case-insensitive key.
- def []=(key, val)
- unless val
- @header.delete key.downcase
- return val
- end
- @header[key.downcase] = [val]
- end
-
- # [Ruby 1.8.3]
- # Adds a value to a named header field, instead of replacing its value.
- # Second argument +val+ must be a String.
- # See also #[]=, #[] and #get_fields.
- #
- # request.add_field 'X-My-Header', 'a'
- # p request['X-My-Header'] #=> "a"
- # p request.get_fields('X-My-Header') #=> ["a"]
- # request.add_field 'X-My-Header', 'b'
- # p request['X-My-Header'] #=> "a, b"
- # p request.get_fields('X-My-Header') #=> ["a", "b"]
- # request.add_field 'X-My-Header', 'c'
- # p request['X-My-Header'] #=> "a, b, c"
- # p request.get_fields('X-My-Header') #=> ["a", "b", "c"]
- #
- def add_field(key, val)
- if @header.key?(key.downcase)
- @header[key.downcase].push val
- else
- @header[key.downcase] = [val]
- end
- end
-
- # [Ruby 1.8.3]
- # Returns an array of header field strings corresponding to the
- # case-insensitive +key+. This method allows you to get duplicated
- # header fields without any processing. See also #[].
- #
- # p response.get_fields('Set-Cookie')
- # #=> ["session=al98axx; expires=Fri, 31-Dec-1999 23:58:23",
- # "query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"]
- # p response['Set-Cookie']
- # #=> "session=al98axx; expires=Fri, 31-Dec-1999 23:58:23, query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"
- #
- def get_fields(key)
- return nil unless @header[key.downcase]
- @header[key.downcase].dup
- end
-
- # Returns the header field corresponding to the case-insensitive key.
- # Returns the default value +args+, or the result of the block, or
- # raises an IndexError if there's no header field named +key+
- # See Hash#fetch
- def fetch(key, *args, &block) #:yield: +key+
- a = @header.fetch(key.downcase, *args, &block)
- a.kind_of?(Array) ? a.join(', ') : a
- end
-
- # Iterates through the header names and values, passing in the name
- # and value to the code block supplied.
- #
- # Example:
- #
- # response.header.each_header {|key,value| puts "#{key} = #{value}" }
- #
- def each_header #:yield: +key+, +value+
- block_given? or return enum_for(__method__)
- @header.each do |k,va|
- yield k, va.join(', ')
- end
- end
-
- alias each each_header
-
- # Iterates through the header names in the header, passing
- # each header name to the code block.
- def each_name(&block) #:yield: +key+
- block_given? or return enum_for(__method__)
- @header.each_key(&block)
- end
-
- alias each_key each_name
-
- # Iterates through the header names in the header, passing
- # capitalized header names to the code block.
- #
- # Note that header names are capitalized systematically;
- # capitalization may not match that used by the remote HTTP
- # server in its response.
- def each_capitalized_name #:yield: +key+
- block_given? or return enum_for(__method__)
- @header.each_key do |k|
- yield capitalize(k)
- end
- end
-
- # Iterates through header values, passing each value to the
- # code block.
- def each_value #:yield: +value+
- block_given? or return enum_for(__method__)
- @header.each_value do |va|
- yield va.join(', ')
- end
- end
-
- # Removes a header field, specified by case-insensitive key.
- def delete(key)
- @header.delete(key.downcase)
- end
-
- # true if +key+ header exists.
- def key?(key)
- @header.key?(key.downcase)
- end
-
- # Returns a Hash consisting of header names and array of values.
- # e.g.
- # {"cache-control" => ["private"],
- # "content-type" => ["text/html"],
- # "date" => ["Wed, 22 Jun 2005 22:11:50 GMT"]}
- def to_hash
- @header.dup
- end
-
- # As for #each_header, except the keys are provided in capitalized form.
- #
- # Note that header names are capitalized systematically;
- # capitalization may not match that used by the remote HTTP
- # server in its response.
- def each_capitalized
- block_given? or return enum_for(__method__)
- @header.each do |k,v|
- yield capitalize(k), v.join(', ')
- end
- end
-
- alias canonical_each each_capitalized
-
- def capitalize(name)
- name.split(/-/).map {|s| s.capitalize }.join('-')
- end
- private :capitalize
-
- # Returns an Array of Range objects which represent the Range:
- # HTTP header field, or +nil+ if there is no such header.
- def range
- return nil unless @header['range']
-
- value = self['Range']
- # byte-range-set = *( "," OWS ) ( byte-range-spec / suffix-byte-range-spec )
- # *( OWS "," [ OWS ( byte-range-spec / suffix-byte-range-spec ) ] )
- # corrected collected ABNF
- # http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-19#section-5.4.1
- # http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-19#appendix-C
- # http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-19#section-3.2.5
- unless /\Abytes=((?:,[ \t]*)*(?:\d+-\d*|-\d+)(?:[ \t]*,(?:[ \t]*\d+-\d*|-\d+)?)*)\z/ =~ value
- raise Net::HTTPHeaderSyntaxError, "invalid syntax for byte-ranges-specifier: '#{value}'"
- end
-
- byte_range_set = $1
- result = byte_range_set.split(/,/).map {|spec|
- m = /(\d+)?\s*-\s*(\d+)?/i.match(spec) or
- raise Net::HTTPHeaderSyntaxError, "invalid byte-range-spec: '#{spec}'"
- d1 = m[1].to_i
- d2 = m[2].to_i
- if m[1] and m[2]
- if d1 > d2
- raise Net::HTTPHeaderSyntaxError, "last-byte-pos MUST greater than or equal to first-byte-pos but '#{spec}'"
- end
- d1..d2
- elsif m[1]
- d1..-1
- elsif m[2]
- -d2..-1
- else
- raise Net::HTTPHeaderSyntaxError, 'range is not specified'
- end
- }
- # if result.empty?
- # byte-range-set must include at least one byte-range-spec or suffix-byte-range-spec
- # but above regexp already denies it.
- if result.size == 1 && result[0].begin == 0 && result[0].end == -1
- raise Net::HTTPHeaderSyntaxError, 'only one suffix-byte-range-spec with zero suffix-length'
- end
- result
- end
-
- # Sets the HTTP Range: header.
- # Accepts either a Range object as a single argument,
- # or a beginning index and a length from that index.
- # Example:
- #
- # req.range = (0..1023)
- # req.set_range 0, 1023
- #
- def set_range(r, e = nil)
- unless r
- @header.delete 'range'
- return r
- end
- r = (r...r+e) if e
- case r
- when Numeric
- n = r.to_i
- rangestr = (n > 0 ? "0-#{n-1}" : "-#{-n}")
- when Range
- first = r.first
- last = r.end
- last -= 1 if r.exclude_end?
- if last == -1
- rangestr = (first > 0 ? "#{first}-" : "-#{-first}")
- else
- raise Net::HTTPHeaderSyntaxError, 'range.first is negative' if first < 0
- raise Net::HTTPHeaderSyntaxError, 'range.last is negative' if last < 0
- raise Net::HTTPHeaderSyntaxError, 'must be .first < .last' if first > last
- rangestr = "#{first}-#{last}"
- end
- else
- raise TypeError, 'Range/Integer is required'
- end
- @header['range'] = ["bytes=#{rangestr}"]
- r
- end
-
- alias range= set_range
-
- # Returns an Integer object which represents the HTTP Content-Length:
- # header field, or +nil+ if that field was not provided.
- def content_length
- return nil unless key?('Content-Length')
- len = self['Content-Length'].slice(/\d+/) or
- raise Net::HTTPHeaderSyntaxError, 'wrong Content-Length format'
- len.to_i
- end
-
- def content_length=(len)
- unless len
- @header.delete 'content-length'
- return nil
- end
- @header['content-length'] = [len.to_i.to_s]
- end
-
- # Returns "true" if the "transfer-encoding" header is present and
- # set to "chunked". This is an HTTP/1.1 feature, allowing the
- # the content to be sent in "chunks" without at the outset
- # stating the entire content length.
- def chunked?
- return false unless @header['transfer-encoding']
- field = self['Transfer-Encoding']
- (/(?:\A|[^\-\w])chunked(?![\-\w])/i =~ field) ? true : false
- end
-
- # Returns a Range object which represents the value of the Content-Range:
- # header field.
- # For a partial entity body, this indicates where this fragment
- # fits inside the full entity body, as range of byte offsets.
- def content_range
- return nil unless @header['content-range']
- m = %ri.match(self['Content-Range']) or
- raise Net::HTTPHeaderSyntaxError, 'wrong Content-Range format'
- m[1].to_i .. m[2].to_i
- end
-
- # The length of the range represented in Content-Range: header.
- def range_length
- r = content_range() or return nil
- r.end - r.begin + 1
- end
-
- # Returns a content type string such as "text/html".
- # This method returns nil if Content-Type: header field does not exist.
- def content_type
- return nil unless main_type()
- if sub_type()
- then "#{main_type()}/#{sub_type()}"
- else main_type()
- end
- end
-
- # Returns a content type string such as "text".
- # This method returns nil if Content-Type: header field does not exist.
- def main_type
- return nil unless @header['content-type']
- self['Content-Type'].split(';').first.to_s.split('/')[0].to_s.strip
- end
-
- # Returns a content type string such as "html".
- # This method returns nil if Content-Type: header field does not exist
- # or sub-type is not given (e.g. "Content-Type: text").
- def sub_type
- return nil unless @header['content-type']
- _, sub = *self['Content-Type'].split(';').first.to_s.split('/')
- return nil unless sub
- sub.strip
- end
-
- # Any parameters specified for the content type, returned as a Hash.
- # For example, a header of Content-Type: text/html; charset=EUC-JP
- # would result in type_params returning {'charset' => 'EUC-JP'}
- def type_params
- result = {}
- list = self['Content-Type'].to_s.split(';')
- list.shift
- list.each do |param|
- k, v = *param.split('=', 2)
- result[k.strip] = v.strip
- end
- result
- end
-
- # Sets the content type in an HTTP header.
- # The +type+ should be a full HTTP content type, e.g. "text/html".
- # The +params+ are an optional Hash of parameters to add after the
- # content type, e.g. {'charset' => 'iso-8859-1'}
- def set_content_type(type, params = {})
- @header['content-type'] = [type + params.map{|k,v|"; #{k}=#{v}"}.join('')]
- end
-
- alias content_type= set_content_type
-
- # Set header fields and a body from HTML form data.
- # +params+ should be an Array of Arrays or
- # a Hash containing HTML form data.
- # Optional argument +sep+ means data record separator.
- #
- # Values are URL encoded as necessary and the content-type is set to
- # application/x-www-form-urlencoded
- #
- # Example:
- # http.form_data = {"q" => "ruby", "lang" => "en"}
- # http.form_data = {"q" => ["ruby", "perl"], "lang" => "en"}
- # http.set_form_data({"q" => "ruby", "lang" => "en"}, ';')
- #
- def set_form_data(params, sep = '&')
- query = URI.encode_www_form(params)
- query.gsub!(/&/, sep) if sep != '&'
- self.body = query
- self.content_type = 'application/x-www-form-urlencoded'
- end
-
- alias form_data= set_form_data
-
- # Set a HTML form data set.
- # +params+ is the form data set; it is an Array of Arrays or a Hash
- # +enctype is the type to encode the form data set.
- # It is application/x-www-form-urlencoded or multipart/form-data.
- # +formpot+ is an optional hash to specify the detail.
- #
- # boundary:: the boundary of the multipart message
- # charset:: the charset of the message. All names and the values of
- # non-file fields are encoded as the charset.
- #
- # Each item of params is an array and contains following items:
- # +name+:: the name of the field
- # +value+:: the value of the field, it should be a String or a File
- # +opt+:: an optional hash to specify additional information
- #
- # Each item is a file field or a normal field.
- # If +value+ is a File object or the +opt+ have a filename key,
- # the item is treated as a file field.
- #
- # If Transfer-Encoding is set as chunked, this send the request in
- # chunked encoding. Because chunked encoding is HTTP/1.1 feature,
- # you must confirm the server to support HTTP/1.1 before sending it.
- #
- # Example:
- # http.set_form([["q", "ruby"], ["lang", "en"]])
- #
- # See also RFC 2388, RFC 2616, HTML 4.01, and HTML5
- #
- def set_form(params, enctype='application/x-www-form-urlencoded', formopt={})
- @body_data = params
- @body = nil
- @body_stream = nil
- @form_option = formopt
- case enctype
- when /\Aapplication\/x-www-form-urlencoded\z/i,
- /\Amultipart\/form-data\z/i
- self.content_type = enctype
- else
- raise ArgumentError, "invalid enctype: #{enctype}"
- end
- end
-
- # Set the Authorization: header for "Basic" authorization.
- def basic_auth(account, password)
- @header['authorization'] = [basic_encode(account, password)]
- end
-
- # Set Proxy-Authorization: header for "Basic" authorization.
- def proxy_basic_auth(account, password)
- @header['proxy-authorization'] = [basic_encode(account, password)]
- end
-
- def basic_encode(account, password)
- 'Basic ' + ["#{account}:#{password}"].pack('m').delete("\r\n")
- end
- private :basic_encode
-
- def connection_close?
- tokens(@header['connection']).include?('close') or
- tokens(@header['proxy-connection']).include?('close')
- end
-
- def connection_keep_alive?
- tokens(@header['connection']).include?('keep-alive') or
- tokens(@header['proxy-connection']).include?('keep-alive')
- end
-
- def tokens(vals)
- return [] unless vals
- vals.map {|v| v.split(',') }.flatten\
- .reject {|str| str.strip.empty? }\
- .map {|tok| tok.strip.downcase }
- end
- private :tokens
-
-end
-
diff --git a/src/main/resources/stdlib/net/http/proxy_delta.rb b/src/main/resources/stdlib/net/http/proxy_delta.rb
deleted file mode 100644
index b16c9f1..0000000
--- a/src/main/resources/stdlib/net/http/proxy_delta.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-module Net::HTTP::ProxyDelta #:nodoc: internal use only
- private
-
- def conn_address
- proxy_address()
- end
-
- def conn_port
- proxy_port()
- end
-
- def edit_path(path)
- use_ssl? ? path : "http://#{addr_port()}#{path}"
- end
-end
-
diff --git a/src/main/resources/stdlib/net/http/request.rb b/src/main/resources/stdlib/net/http/request.rb
deleted file mode 100644
index e8b0f48..0000000
--- a/src/main/resources/stdlib/net/http/request.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# HTTP request class.
-# This class wraps together the request header and the request path.
-# You cannot use this class directly. Instead, you should use one of its
-# subclasses: Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Head.
-#
-class Net::HTTPRequest < Net::HTTPGenericRequest
- # Creates an HTTP request object for +path+.
- #
- # +initheader+ are the default headers to use. Net::HTTP adds
- # Accept-Encoding to enable compression of the response body unless
- # Accept-Encoding or Range are supplied in +initheader+.
-
- def initialize(path, initheader = nil)
- super self.class::METHOD,
- self.class::REQUEST_HAS_BODY,
- self.class::RESPONSE_HAS_BODY,
- path, initheader
- end
-end
-
diff --git a/src/main/resources/stdlib/net/http/requests.rb b/src/main/resources/stdlib/net/http/requests.rb
deleted file mode 100644
index c1f8360..0000000
--- a/src/main/resources/stdlib/net/http/requests.rb
+++ /dev/null
@@ -1,122 +0,0 @@
-#
-# HTTP/1.1 methods --- RFC2616
-#
-
-# See Net::HTTPGenericRequest for attributes and methods.
-# See Net::HTTP for usage examples.
-class Net::HTTP::Get < Net::HTTPRequest
- METHOD = 'GET'
- REQUEST_HAS_BODY = false
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-# See Net::HTTP for usage examples.
-class Net::HTTP::Head < Net::HTTPRequest
- METHOD = 'HEAD'
- REQUEST_HAS_BODY = false
- RESPONSE_HAS_BODY = false
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-# See Net::HTTP for usage examples.
-class Net::HTTP::Post < Net::HTTPRequest
- METHOD = 'POST'
- REQUEST_HAS_BODY = true
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-# See Net::HTTP for usage examples.
-class Net::HTTP::Put < Net::HTTPRequest
- METHOD = 'PUT'
- REQUEST_HAS_BODY = true
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-# See Net::HTTP for usage examples.
-class Net::HTTP::Delete < Net::HTTPRequest
- METHOD = 'DELETE'
- REQUEST_HAS_BODY = false
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Options < Net::HTTPRequest
- METHOD = 'OPTIONS'
- REQUEST_HAS_BODY = false
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Trace < Net::HTTPRequest
- METHOD = 'TRACE'
- REQUEST_HAS_BODY = false
- RESPONSE_HAS_BODY = true
-end
-
-#
-# PATCH method --- RFC5789
-#
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Patch < Net::HTTPRequest
- METHOD = 'PATCH'
- REQUEST_HAS_BODY = true
- RESPONSE_HAS_BODY = true
-end
-
-#
-# WebDAV methods --- RFC2518
-#
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Propfind < Net::HTTPRequest
- METHOD = 'PROPFIND'
- REQUEST_HAS_BODY = true
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Proppatch < Net::HTTPRequest
- METHOD = 'PROPPATCH'
- REQUEST_HAS_BODY = true
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Mkcol < Net::HTTPRequest
- METHOD = 'MKCOL'
- REQUEST_HAS_BODY = true
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Copy < Net::HTTPRequest
- METHOD = 'COPY'
- REQUEST_HAS_BODY = false
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Move < Net::HTTPRequest
- METHOD = 'MOVE'
- REQUEST_HAS_BODY = false
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Lock < Net::HTTPRequest
- METHOD = 'LOCK'
- REQUEST_HAS_BODY = true
- RESPONSE_HAS_BODY = true
-end
-
-# See Net::HTTPGenericRequest for attributes and methods.
-class Net::HTTP::Unlock < Net::HTTPRequest
- METHOD = 'UNLOCK'
- REQUEST_HAS_BODY = true
- RESPONSE_HAS_BODY = true
-end
-
diff --git a/src/main/resources/stdlib/net/http/response.rb b/src/main/resources/stdlib/net/http/response.rb
deleted file mode 100644
index b073169..0000000
--- a/src/main/resources/stdlib/net/http/response.rb
+++ /dev/null
@@ -1,414 +0,0 @@
-# HTTP response class.
-#
-# This class wraps together the response header and the response body (the
-# entity requested).
-#
-# It mixes in the HTTPHeader module, which provides access to response
-# header values both via hash-like methods and via individual readers.
-#
-# Note that each possible HTTP response code defines its own
-# HTTPResponse subclass. These are listed below.
-#
-# All classes are defined under the Net module. Indentation indicates
-# inheritance. For a list of the classes see Net::HTTP.
-#
-#
-class Net::HTTPResponse
- class << self
- # true if the response has a body.
- def body_permitted?
- self::HAS_BODY
- end
-
- def exception_type # :nodoc: internal use only
- self::EXCEPTION_TYPE
- end
-
- def read_new(sock) #:nodoc: internal use only
- httpv, code, msg = read_status_line(sock)
- res = response_class(code).new(httpv, code, msg)
- each_response_header(sock) do |k,v|
- res.add_field k, v
- end
- res
- end
-
- private
-
- def read_status_line(sock)
- str = sock.readline
- m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\z/in.match(str) or
- raise Net::HTTPBadResponse, "wrong status line: #{str.dump}"
- m.captures
- end
-
- def response_class(code)
- CODE_TO_OBJ[code] or
- CODE_CLASS_TO_OBJ[code[0,1]] or
- Net::HTTPUnknownResponse
- end
-
- def each_response_header(sock)
- key = value = nil
- while true
- line = sock.readuntil("\n", true).sub(/\s+\z/, '')
- break if line.empty?
- if line[0] == ?\s or line[0] == ?\t and value
- value << ' ' unless value.empty?
- value << line.strip
- else
- yield key, value if key
- key, value = line.strip.split(/\s*:\s*/, 2)
- raise Net::HTTPBadResponse, 'wrong header line format' if value.nil?
- end
- end
- yield key, value if key
- end
- end
-
- # next is to fix bug in RDoc, where the private inside class << self
- # spills out.
- public
-
- include Net::HTTPHeader
-
- def initialize(httpv, code, msg) #:nodoc: internal use only
- @http_version = httpv
- @code = code
- @message = msg
- initialize_http_header nil
- @body = nil
- @read = false
- @uri = nil
- @decode_content = false
- end
-
- # The HTTP version supported by the server.
- attr_reader :http_version
-
- # The HTTP result code string. For example, '302'. You can also
- # determine the response type by examining which response subclass
- # the response object is an instance of.
- attr_reader :code
-
- # The HTTP result message sent by the server. For example, 'Not Found'.
- attr_reader :message
- alias msg message # :nodoc: obsolete
-
- # The URI used to fetch this response. The response URI is only available
- # if a URI was used to create the request.
- attr_reader :uri
-
- # Set to true automatically when the request did not contain an
- # Accept-Encoding header from the user.
- attr_accessor :decode_content
-
- def inspect
- "#<#{self.class} #{@code} #{@message} readbody=#{@read}>"
- end
-
- #
- # response <-> exception relationship
- #
-
- def code_type #:nodoc:
- self.class
- end
-
- def error! #:nodoc:
- raise error_type().new(@code + ' ' + @message.dump, self)
- end
-
- def error_type #:nodoc:
- self.class::EXCEPTION_TYPE
- end
-
- # Raises an HTTP error if the response is not 2xx (success).
- def value
- error! unless self.kind_of?(Net::HTTPSuccess)
- end
-
- def uri= uri # :nodoc:
- @uri = uri.dup if uri
- end
-
- #
- # header (for backward compatibility only; DO NOT USE)
- #
-
- def response #:nodoc:
- warn "#{caller(1)[0]}: warning: Net::HTTPResponse#response is obsolete" if $VERBOSE
- self
- end
-
- def header #:nodoc:
- warn "#{caller(1)[0]}: warning: Net::HTTPResponse#header is obsolete" if $VERBOSE
- self
- end
-
- def read_header #:nodoc:
- warn "#{caller(1)[0]}: warning: Net::HTTPResponse#read_header is obsolete" if $VERBOSE
- self
- end
-
- #
- # body
- #
-
- def reading_body(sock, reqmethodallowbody) #:nodoc: internal use only
- @socket = sock
- @body_exist = reqmethodallowbody && self.class.body_permitted?
- begin
- yield
- self.body # ensure to read body
- ensure
- @socket = nil
- end
- end
-
- # Gets the entity body returned by the remote HTTP server.
- #
- # If a block is given, the body is passed to the block, and
- # the body is provided in fragments, as it is read in from the socket.
- #
- # Calling this method a second or subsequent time for the same
- # HTTPResponse object will return the value already read.
- #
- # http.request_get('/index.html') {|res|
- # puts res.read_body
- # }
- #
- # http.request_get('/index.html') {|res|
- # p res.read_body.object_id # 538149362
- # p res.read_body.object_id # 538149362
- # }
- #
- # # using iterator
- # http.request_get('/index.html') {|res|
- # res.read_body do |segment|
- # print segment
- # end
- # }
- #
- def read_body(dest = nil, &block)
- if @read
- raise IOError, "#{self.class}\#read_body called twice" if dest or block
- return @body
- end
- to = procdest(dest, block)
- stream_check
- if @body_exist
- read_body_0 to
- @body = to
- else
- @body = nil
- end
- @read = true
-
- @body
- end
-
- # Returns the full entity body.
- #
- # Calling this method a second or subsequent time will return the
- # string already read.
- #
- # http.request_get('/index.html') {|res|
- # puts res.body
- # }
- #
- # http.request_get('/index.html') {|res|
- # p res.body.object_id # 538149362
- # p res.body.object_id # 538149362
- # }
- #
- def body
- read_body()
- end
-
- # Because it may be necessary to modify the body, Eg, decompression
- # this method facilitates that.
- def body=(value)
- @body = value
- end
-
- alias entity body #:nodoc: obsolete
-
- private
-
- ##
- # Checks for a supported Content-Encoding header and yields an Inflate
- # wrapper for this response's socket when zlib is present. If the
- # Content-Encoding is unsupported or zlib is missing the plain socket is
- # yielded.
- #
- # If a Content-Range header is present a plain socket is yielded as the
- # bytes in the range may not be a complete deflate block.
-
- def inflater # :nodoc:
- return yield @socket unless Net::HTTP::HAVE_ZLIB
- return yield @socket unless @decode_content
- return yield @socket if self['content-range']
-
- case self['content-encoding']
- when 'deflate', 'gzip', 'x-gzip' then
- self.delete 'content-encoding'
-
- inflate_body_io = Inflater.new(@socket)
-
- begin
- yield inflate_body_io
- ensure
- e = $!
- begin
- inflate_body_io.finish
- rescue
- raise e
- end
- end
- when 'none', 'identity' then
- self.delete 'content-encoding'
-
- yield @socket
- else
- yield @socket
- end
- end
-
- def read_body_0(dest)
- inflater do |inflate_body_io|
- if chunked?
- read_chunked dest, inflate_body_io
- return
- end
-
- @socket = inflate_body_io
-
- clen = content_length()
- if clen
- @socket.read clen, dest, true # ignore EOF
- return
- end
- clen = range_length()
- if clen
- @socket.read clen, dest
- return
- end
- @socket.read_all dest
- end
- end
-
- ##
- # read_chunked reads from +@socket+ for chunk-size, chunk-extension, CRLF,
- # etc. and +chunk_data_io+ for chunk-data which may be deflate or gzip
- # encoded.
- #
- # See RFC 2616 section 3.6.1 for definitions
-
- def read_chunked(dest, chunk_data_io) # :nodoc:
- total = 0
- while true
- line = @socket.readline
- hexlen = line.slice(/[0-9a-fA-F]+/) or
- raise Net::HTTPBadResponse, "wrong chunk size line: #{line}"
- len = hexlen.hex
- break if len == 0
- begin
- chunk_data_io.read len, dest
- ensure
- total += len
- @socket.read 2 # \r\n
- end
- end
- until @socket.readline.empty?
- # none
- end
- end
-
- def stream_check
- raise IOError, 'attempt to read body out of block' if @socket.closed?
- end
-
- def procdest(dest, block)
- raise ArgumentError, 'both arg and block given for HTTP method' if
- dest and block
- if block
- Net::ReadAdapter.new(block)
- else
- dest || ''
- end
- end
-
- ##
- # Inflater is a wrapper around Net::BufferedIO that transparently inflates
- # zlib and gzip streams.
-
- class Inflater # :nodoc:
-
- ##
- # Creates a new Inflater wrapping +socket+
-
- def initialize socket
- @socket = socket
- # zlib with automatic gzip detection
- @inflate = Zlib::Inflate.new(32 + Zlib::MAX_WBITS)
- end
-
- ##
- # Finishes the inflate stream.
-
- def finish
- @inflate.finish
- end
-
- ##
- # Returns a Net::ReadAdapter that inflates each read chunk into +dest+.
- #
- # This allows a large response body to be inflated without storing the
- # entire body in memory.
-
- def inflate_adapter(dest)
- if dest.respond_to?(:set_encoding)
- dest.set_encoding(Encoding::ASCII_8BIT)
- elsif dest.respond_to?(:force_encoding)
- dest.force_encoding(Encoding::ASCII_8BIT)
- end
- block = proc do |compressed_chunk|
- @inflate.inflate(compressed_chunk) do |chunk|
- dest << chunk
- end
- end
-
- Net::ReadAdapter.new(block)
- end
-
- ##
- # Reads +clen+ bytes from the socket, inflates them, then writes them to
- # +dest+. +ignore_eof+ is passed down to Net::BufferedIO#read
- #
- # Unlike Net::BufferedIO#read, this method returns more than +clen+ bytes.
- # At this time there is no way for a user of Net::HTTPResponse to read a
- # specific number of bytes from the HTTP response body, so this internal
- # API does not return the same number of bytes as were requested.
- #
- # See https://bugs.ruby-lang.org/issues/6492 for further discussion.
-
- def read clen, dest, ignore_eof = false
- temp_dest = inflate_adapter(dest)
-
- @socket.read clen, temp_dest, ignore_eof
- end
-
- ##
- # Reads the rest of the socket, inflates it, then writes it to +dest+.
-
- def read_all dest
- temp_dest = inflate_adapter(dest)
-
- @socket.read_all temp_dest
- end
-
- end
-
-end
-
diff --git a/src/main/resources/stdlib/net/http/responses.rb b/src/main/resources/stdlib/net/http/responses.rb
deleted file mode 100644
index 1454a27..0000000
--- a/src/main/resources/stdlib/net/http/responses.rb
+++ /dev/null
@@ -1,273 +0,0 @@
-# :stopdoc:
-class Net::HTTPUnknownResponse < Net::HTTPResponse
- HAS_BODY = true
- EXCEPTION_TYPE = Net::HTTPError
-end
-class Net::HTTPInformation < Net::HTTPResponse # 1xx
- HAS_BODY = false
- EXCEPTION_TYPE = Net::HTTPError
-end
-class Net::HTTPSuccess < Net::HTTPResponse # 2xx
- HAS_BODY = true
- EXCEPTION_TYPE = Net::HTTPError
-end
-class Net::HTTPRedirection < Net::HTTPResponse # 3xx
- HAS_BODY = true
- EXCEPTION_TYPE = Net::HTTPRetriableError
-end
-class Net::HTTPClientError < Net::HTTPResponse # 4xx
- HAS_BODY = true
- EXCEPTION_TYPE = Net::HTTPServerException # for backward compatibility
-end
-class Net::HTTPServerError < Net::HTTPResponse # 5xx
- HAS_BODY = true
- EXCEPTION_TYPE = Net::HTTPFatalError # for backward compatibility
-end
-
-class Net::HTTPContinue < Net::HTTPInformation # 100
- HAS_BODY = false
-end
-class Net::HTTPSwitchProtocol < Net::HTTPInformation # 101
- HAS_BODY = false
-end
-# 102 - RFC 2518; removed in RFC 4918
-
-class Net::HTTPOK < Net::HTTPSuccess # 200
- HAS_BODY = true
-end
-class Net::HTTPCreated < Net::HTTPSuccess # 201
- HAS_BODY = true
-end
-class Net::HTTPAccepted < Net::HTTPSuccess # 202
- HAS_BODY = true
-end
-class Net::HTTPNonAuthoritativeInformation < Net::HTTPSuccess # 203
- HAS_BODY = true
-end
-class Net::HTTPNoContent < Net::HTTPSuccess # 204
- HAS_BODY = false
-end
-class Net::HTTPResetContent < Net::HTTPSuccess # 205
- HAS_BODY = false
-end
-class Net::HTTPPartialContent < Net::HTTPSuccess # 206
- HAS_BODY = true
-end
-class Net::HTTPMultiStatus < Net::HTTPSuccess # 207 - RFC 4918
- HAS_BODY = true
-end
-# 208 Already Reported - RFC 5842; experimental
-class Net::HTTPIMUsed < Net::HTTPSuccess # 226 - RFC 3229
- HAS_BODY = true
-end
-
-class Net::HTTPMultipleChoices < Net::HTTPRedirection # 300
- HAS_BODY = true
-end
-Net::HTTPMultipleChoice = Net::HTTPMultipleChoices
-class Net::HTTPMovedPermanently < Net::HTTPRedirection # 301
- HAS_BODY = true
-end
-class Net::HTTPFound < Net::HTTPRedirection # 302
- HAS_BODY = true
-end
-Net::HTTPMovedTemporarily = Net::HTTPFound
-class Net::HTTPSeeOther < Net::HTTPRedirection # 303
- HAS_BODY = true
-end
-class Net::HTTPNotModified < Net::HTTPRedirection # 304
- HAS_BODY = false
-end
-class Net::HTTPUseProxy < Net::HTTPRedirection # 305
- HAS_BODY = false
-end
-# 306 Switch Proxy - no longer unused
-class Net::HTTPTemporaryRedirect < Net::HTTPRedirection # 307
- HAS_BODY = true
-end
-class Net::HTTPPermanentRedirect < Net::HTTPRedirection # 308
- HAS_BODY = true
-end
-
-class Net::HTTPBadRequest < Net::HTTPClientError # 400
- HAS_BODY = true
-end
-class Net::HTTPUnauthorized < Net::HTTPClientError # 401
- HAS_BODY = true
-end
-class Net::HTTPPaymentRequired < Net::HTTPClientError # 402
- HAS_BODY = true
-end
-class Net::HTTPForbidden < Net::HTTPClientError # 403
- HAS_BODY = true
-end
-class Net::HTTPNotFound < Net::HTTPClientError # 404
- HAS_BODY = true
-end
-class Net::HTTPMethodNotAllowed < Net::HTTPClientError # 405
- HAS_BODY = true
-end
-class Net::HTTPNotAcceptable < Net::HTTPClientError # 406
- HAS_BODY = true
-end
-class Net::HTTPProxyAuthenticationRequired < Net::HTTPClientError # 407
- HAS_BODY = true
-end
-class Net::HTTPRequestTimeOut < Net::HTTPClientError # 408
- HAS_BODY = true
-end
-class Net::HTTPConflict < Net::HTTPClientError # 409
- HAS_BODY = true
-end
-class Net::HTTPGone < Net::HTTPClientError # 410
- HAS_BODY = true
-end
-class Net::HTTPLengthRequired < Net::HTTPClientError # 411
- HAS_BODY = true
-end
-class Net::HTTPPreconditionFailed < Net::HTTPClientError # 412
- HAS_BODY = true
-end
-class Net::HTTPRequestEntityTooLarge < Net::HTTPClientError # 413
- HAS_BODY = true
-end
-class Net::HTTPRequestURITooLong < Net::HTTPClientError # 414
- HAS_BODY = true
-end
-Net::HTTPRequestURITooLarge = Net::HTTPRequestURITooLong
-class Net::HTTPUnsupportedMediaType < Net::HTTPClientError # 415
- HAS_BODY = true
-end
-class Net::HTTPRequestedRangeNotSatisfiable < Net::HTTPClientError # 416
- HAS_BODY = true
-end
-class Net::HTTPExpectationFailed < Net::HTTPClientError # 417
- HAS_BODY = true
-end
-# 418 I'm a teapot - RFC 2324; a joke RFC
-# 420 Enhance Your Calm - Twitter
-class Net::HTTPUnprocessableEntity < Net::HTTPClientError # 422 - RFC 4918
- HAS_BODY = true
-end
-class Net::HTTPLocked < Net::HTTPClientError # 423 - RFC 4918
- HAS_BODY = true
-end
-class Net::HTTPFailedDependency < Net::HTTPClientError # 424 - RFC 4918
- HAS_BODY = true
-end
-# 425 Unordered Collection - existed only in draft
-class Net::HTTPUpgradeRequired < Net::HTTPClientError # 426 - RFC 2817
- HAS_BODY = true
-end
-class Net::HTTPPreconditionRequired < Net::HTTPClientError # 428 - RFC 6585
- HAS_BODY = true
-end
-class Net::HTTPTooManyRequests < Net::HTTPClientError # 429 - RFC 6585
- HAS_BODY = true
-end
-class Net::HTTPRequestHeaderFieldsTooLarge < Net::HTTPClientError # 431 - RFC 6585
- HAS_BODY = true
-end
-# 444 No Response - Nginx
-# 449 Retry With - Microsoft
-# 450 Blocked by Windows Parental Controls - Microsoft
-# 499 Client Closed Request - Nginx
-
-class Net::HTTPInternalServerError < Net::HTTPServerError # 500
- HAS_BODY = true
-end
-class Net::HTTPNotImplemented < Net::HTTPServerError # 501
- HAS_BODY = true
-end
-class Net::HTTPBadGateway < Net::HTTPServerError # 502
- HAS_BODY = true
-end
-class Net::HTTPServiceUnavailable < Net::HTTPServerError # 503
- HAS_BODY = true
-end
-class Net::HTTPGatewayTimeOut < Net::HTTPServerError # 504
- HAS_BODY = true
-end
-class Net::HTTPVersionNotSupported < Net::HTTPServerError # 505
- HAS_BODY = true
-end
-# 506 Variant Also Negotiates - RFC 2295; experimental
-class Net::HTTPInsufficientStorage < Net::HTTPServerError # 507 - RFC 4918
- HAS_BODY = true
-end
-# 508 Loop Detected - RFC 5842; experimental
-# 509 Bandwidth Limit Exceeded - Apache bw/limited extension
-# 510 Not Extended - RFC 2774; experimental
-class Net::HTTPNetworkAuthenticationRequired < Net::HTTPServerError # 511 - RFC 6585
- HAS_BODY = true
-end
-
-class Net::HTTPResponse
- CODE_CLASS_TO_OBJ = {
- '1' => Net::HTTPInformation,
- '2' => Net::HTTPSuccess,
- '3' => Net::HTTPRedirection,
- '4' => Net::HTTPClientError,
- '5' => Net::HTTPServerError
- }
- CODE_TO_OBJ = {
- '100' => Net::HTTPContinue,
- '101' => Net::HTTPSwitchProtocol,
-
- '200' => Net::HTTPOK,
- '201' => Net::HTTPCreated,
- '202' => Net::HTTPAccepted,
- '203' => Net::HTTPNonAuthoritativeInformation,
- '204' => Net::HTTPNoContent,
- '205' => Net::HTTPResetContent,
- '206' => Net::HTTPPartialContent,
- '207' => Net::HTTPMultiStatus,
- '226' => Net::HTTPIMUsed,
-
- '300' => Net::HTTPMultipleChoices,
- '301' => Net::HTTPMovedPermanently,
- '302' => Net::HTTPFound,
- '303' => Net::HTTPSeeOther,
- '304' => Net::HTTPNotModified,
- '305' => Net::HTTPUseProxy,
- '307' => Net::HTTPTemporaryRedirect,
-
- '400' => Net::HTTPBadRequest,
- '401' => Net::HTTPUnauthorized,
- '402' => Net::HTTPPaymentRequired,
- '403' => Net::HTTPForbidden,
- '404' => Net::HTTPNotFound,
- '405' => Net::HTTPMethodNotAllowed,
- '406' => Net::HTTPNotAcceptable,
- '407' => Net::HTTPProxyAuthenticationRequired,
- '408' => Net::HTTPRequestTimeOut,
- '409' => Net::HTTPConflict,
- '410' => Net::HTTPGone,
- '411' => Net::HTTPLengthRequired,
- '412' => Net::HTTPPreconditionFailed,
- '413' => Net::HTTPRequestEntityTooLarge,
- '414' => Net::HTTPRequestURITooLong,
- '415' => Net::HTTPUnsupportedMediaType,
- '416' => Net::HTTPRequestedRangeNotSatisfiable,
- '417' => Net::HTTPExpectationFailed,
- '422' => Net::HTTPUnprocessableEntity,
- '423' => Net::HTTPLocked,
- '424' => Net::HTTPFailedDependency,
- '426' => Net::HTTPUpgradeRequired,
- '428' => Net::HTTPPreconditionRequired,
- '429' => Net::HTTPTooManyRequests,
- '431' => Net::HTTPRequestHeaderFieldsTooLarge,
-
- '500' => Net::HTTPInternalServerError,
- '501' => Net::HTTPNotImplemented,
- '502' => Net::HTTPBadGateway,
- '503' => Net::HTTPServiceUnavailable,
- '504' => Net::HTTPGatewayTimeOut,
- '505' => Net::HTTPVersionNotSupported,
- '507' => Net::HTTPInsufficientStorage,
- '511' => Net::HTTPNetworkAuthenticationRequired,
- }
-end
-
-# :startdoc:
-
diff --git a/src/main/resources/stdlib/net/https.rb b/src/main/resources/stdlib/net/https.rb
deleted file mode 100644
index d36f820..0000000
--- a/src/main/resources/stdlib/net/https.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-=begin
-
-= net/https -- SSL/TLS enhancement for Net::HTTP.
-
- This file has been merged with net/http. There is no longer any need to
- require 'net/https' to use HTTPS.
-
- See Net::HTTP for details on how to make HTTPS connections.
-
-== Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2001 GOTOU Yuuzou
- All rights reserved.
-
-== Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-=end
-
-require 'net/http'
-require 'openssl'
diff --git a/src/main/resources/stdlib/net/imap.rb b/src/main/resources/stdlib/net/imap.rb
deleted file mode 100644
index a772c46..0000000
--- a/src/main/resources/stdlib/net/imap.rb
+++ /dev/null
@@ -1,3616 +0,0 @@
-#
-# = net/imap.rb
-#
-# Copyright (C) 2000 Shugo Maeda
-#
-# This library is distributed under the terms of the Ruby license.
-# You can freely distribute/modify this library.
-#
-# Documentation: Shugo Maeda, with RDoc conversion and overview by William
-# Webber.
-#
-# See Net::IMAP for documentation.
-#
-
-
-require "socket"
-require "monitor"
-require "digest/md5"
-require "strscan"
-begin
- require "openssl"
-rescue LoadError
-end
-
-module Net
-
- #
- # Net::IMAP implements Internet Message Access Protocol (IMAP) client
- # functionality. The protocol is described in [IMAP].
- #
- # == IMAP Overview
- #
- # An IMAP client connects to a server, and then authenticates
- # itself using either #authenticate() or #login(). Having
- # authenticated itself, there is a range of commands
- # available to it. Most work with mailboxes, which may be
- # arranged in an hierarchical namespace, and each of which
- # contains zero or more messages. How this is implemented on
- # the server is implementation-dependent; on a UNIX server, it
- # will frequently be implemented as files in mailbox format
- # within a hierarchy of directories.
- #
- # To work on the messages within a mailbox, the client must
- # first select that mailbox, using either #select() or (for
- # read-only access) #examine(). Once the client has successfully
- # selected a mailbox, they enter _selected_ state, and that
- # mailbox becomes the _current_ mailbox, on which mail-item
- # related commands implicitly operate.
- #
- # Messages have two sorts of identifiers: message sequence
- # numbers and UIDs.
- #
- # Message sequence numbers number messages within a mailbox
- # from 1 up to the number of items in the mailbox. If a new
- # message arrives during a session, it receives a sequence
- # number equal to the new size of the mailbox. If messages
- # are expunged from the mailbox, remaining messages have their
- # sequence numbers "shuffled down" to fill the gaps.
- #
- # UIDs, on the other hand, are permanently guaranteed not to
- # identify another message within the same mailbox, even if
- # the existing message is deleted. UIDs are required to
- # be assigned in ascending (but not necessarily sequential)
- # order within a mailbox; this means that if a non-IMAP client
- # rearranges the order of mailitems within a mailbox, the
- # UIDs have to be reassigned. An IMAP client thus cannot
- # rearrange message orders.
- #
- # == Examples of Usage
- #
- # === List sender and subject of all recent messages in the default mailbox
- #
- # imap = Net::IMAP.new('mail.example.com')
- # imap.authenticate('LOGIN', 'joe_user', 'joes_password')
- # imap.examine('INBOX')
- # imap.search(["RECENT"]).each do |message_id|
- # envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
- # puts "#{envelope.from[0].name}: \t#{envelope.subject}"
- # end
- #
- # === Move all messages from April 2003 from "Mail/sent-mail" to "Mail/sent-apr03"
- #
- # imap = Net::IMAP.new('mail.example.com')
- # imap.authenticate('LOGIN', 'joe_user', 'joes_password')
- # imap.select('Mail/sent-mail')
- # if not imap.list('Mail/', 'sent-apr03')
- # imap.create('Mail/sent-apr03')
- # end
- # imap.search(["BEFORE", "30-Apr-2003", "SINCE", "1-Apr-2003"]).each do |message_id|
- # imap.copy(message_id, "Mail/sent-apr03")
- # imap.store(message_id, "+FLAGS", [:Deleted])
- # end
- # imap.expunge
- #
- # == Thread Safety
- #
- # Net::IMAP supports concurrent threads. For example,
- #
- # imap = Net::IMAP.new("imap.foo.net", "imap2")
- # imap.authenticate("cram-md5", "bar", "password")
- # imap.select("inbox")
- # fetch_thread = Thread.start { imap.fetch(1..-1, "UID") }
- # search_result = imap.search(["BODY", "hello"])
- # fetch_result = fetch_thread.value
- # imap.disconnect
- #
- # This script invokes the FETCH command and the SEARCH command concurrently.
- #
- # == Errors
- #
- # An IMAP server can send three different types of responses to indicate
- # failure:
- #
- # NO:: the attempted command could not be successfully completed. For
- # instance, the username/password used for logging in are incorrect;
- # the selected mailbox does not exist; etc.
- #
- # BAD:: the request from the client does not follow the server's
- # understanding of the IMAP protocol. This includes attempting
- # commands from the wrong client state; for instance, attempting
- # to perform a SEARCH command without having SELECTed a current
- # mailbox. It can also signal an internal server
- # failure (such as a disk crash) has occurred.
- #
- # BYE:: the server is saying goodbye. This can be part of a normal
- # logout sequence, and can be used as part of a login sequence
- # to indicate that the server is (for some reason) unwilling
- # to accept your connection. As a response to any other command,
- # it indicates either that the server is shutting down, or that
- # the server is timing out the client connection due to inactivity.
- #
- # These three error response are represented by the errors
- # Net::IMAP::NoResponseError, Net::IMAP::BadResponseError, and
- # Net::IMAP::ByeResponseError, all of which are subclasses of
- # Net::IMAP::ResponseError. Essentially, all methods that involve
- # sending a request to the server can generate one of these errors.
- # Only the most pertinent instances have been documented below.
- #
- # Because the IMAP class uses Sockets for communication, its methods
- # are also susceptible to the various errors that can occur when
- # working with sockets. These are generally represented as
- # Errno errors. For instance, any method that involves sending a
- # request to the server and/or receiving a response from it could
- # raise an Errno::EPIPE error if the network connection unexpectedly
- # goes down. See the socket(7), ip(7), tcp(7), socket(2), connect(2),
- # and associated man pages.
- #
- # Finally, a Net::IMAP::DataFormatError is thrown if low-level data
- # is found to be in an incorrect format (for instance, when converting
- # between UTF-8 and UTF-16), and Net::IMAP::ResponseParseError is
- # thrown if a server response is non-parseable.
- #
- #
- # == References
- #
- # [[IMAP]]
- # M. Crispin, "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1",
- # RFC 2060, December 1996. (Note: since obsoleted by RFC 3501)
- #
- # [[LANGUAGE-TAGS]]
- # Alvestrand, H., "Tags for the Identification of
- # Languages", RFC 1766, March 1995.
- #
- # [[MD5]]
- # Myers, J., and M. Rose, "The Content-MD5 Header Field", RFC
- # 1864, October 1995.
- #
- # [[MIME-IMB]]
- # Freed, N., and N. Borenstein, "MIME (Multipurpose Internet
- # Mail Extensions) Part One: Format of Internet Message Bodies", RFC
- # 2045, November 1996.
- #
- # [[RFC-822]]
- # Crocker, D., "Standard for the Format of ARPA Internet Text
- # Messages", STD 11, RFC 822, University of Delaware, August 1982.
- #
- # [[RFC-2087]]
- # Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 1997.
- #
- # [[RFC-2086]]
- # Myers, J., "IMAP4 ACL extension", RFC 2086, January 1997.
- #
- # [[RFC-2195]]
- # Klensin, J., Catoe, R., and Krumviede, P., "IMAP/POP AUTHorize Extension
- # for Simple Challenge/Response", RFC 2195, September 1997.
- #
- # [[SORT-THREAD-EXT]]
- # Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - SORT and THREAD
- # Extensions", draft-ietf-imapext-sort, May 2003.
- #
- # [[OSSL]]
- # http://www.openssl.org
- #
- # [[RSSL]]
- # http://savannah.gnu.org/projects/rubypki
- #
- # [[UTF7]]
- # Goldsmith, D. and Davis, M., "UTF-7: A Mail-Safe Transformation Format of
- # Unicode", RFC 2152, May 1997.
- #
- class IMAP
- include MonitorMixin
- if defined?(OpenSSL::SSL)
- include OpenSSL
- include SSL
- end
-
- # Returns an initial greeting response from the server.
- attr_reader :greeting
-
- # Returns recorded untagged responses. For example:
- #
- # imap.select("inbox")
- # p imap.responses["EXISTS"][-1]
- # #=> 2
- # p imap.responses["UIDVALIDITY"][-1]
- # #=> 968263756
- attr_reader :responses
-
- # Returns all response handlers.
- attr_reader :response_handlers
-
- # The thread to receive exceptions.
- attr_accessor :client_thread
-
- # Flag indicating a message has been seen.
- SEEN = :Seen
-
- # Flag indicating a message has been answered.
- ANSWERED = :Answered
-
- # Flag indicating a message has been flagged for special or urgent
- # attention.
- FLAGGED = :Flagged
-
- # Flag indicating a message has been marked for deletion. This
- # will occur when the mailbox is closed or expunged.
- DELETED = :Deleted
-
- # Flag indicating a message is only a draft or work-in-progress version.
- DRAFT = :Draft
-
- # Flag indicating that the message is "recent," meaning that this
- # session is the first session in which the client has been notified
- # of this message.
- RECENT = :Recent
-
- # Flag indicating that a mailbox context name cannot contain
- # children.
- NOINFERIORS = :Noinferiors
-
- # Flag indicating that a mailbox is not selected.
- NOSELECT = :Noselect
-
- # Flag indicating that a mailbox has been marked "interesting" by
- # the server; this commonly indicates that the mailbox contains
- # new messages.
- MARKED = :Marked
-
- # Flag indicating that the mailbox does not contains new messages.
- UNMARKED = :Unmarked
-
- # Returns the debug mode.
- def self.debug
- return @@debug
- end
-
- # Sets the debug mode.
- def self.debug=(val)
- return @@debug = val
- end
-
- # Returns the max number of flags interned to symbols.
- def self.max_flag_count
- return @@max_flag_count
- end
-
- # Sets the max number of flags interned to symbols.
- def self.max_flag_count=(count)
- @@max_flag_count = count
- end
-
- # Adds an authenticator for Net::IMAP#authenticate. +auth_type+
- # is the type of authentication this authenticator supports
- # (for instance, "LOGIN"). The +authenticator+ is an object
- # which defines a process() method to handle authentication with
- # the server. See Net::IMAP::LoginAuthenticator,
- # Net::IMAP::CramMD5Authenticator, and Net::IMAP::DigestMD5Authenticator
- # for examples.
- #
- #
- # If +auth_type+ refers to an existing authenticator, it will be
- # replaced by the new one.
- def self.add_authenticator(auth_type, authenticator)
- @@authenticators[auth_type] = authenticator
- end
-
- # The default port for IMAP connections, port 143
- def self.default_port
- return PORT
- end
-
- # The default port for IMAPS connections, port 993
- def self.default_tls_port
- return SSL_PORT
- end
-
- class << self
- alias default_imap_port default_port
- alias default_imaps_port default_tls_port
- alias default_ssl_port default_tls_port
- end
-
- # Disconnects from the server.
- def disconnect
- begin
- begin
- # try to call SSL::SSLSocket#io.
- @sock.io.shutdown
- rescue NoMethodError
- # @sock is not an SSL::SSLSocket.
- @sock.shutdown
- end
- rescue Errno::ENOTCONN
- # ignore `Errno::ENOTCONN: Socket is not connected' on some platforms.
- rescue Exception => e
- @receiver_thread.raise(e)
- end
- @receiver_thread.join
- synchronize do
- unless @sock.closed?
- @sock.close
- end
- end
- raise e if e
- end
-
- # Returns true if disconnected from the server.
- def disconnected?
- return @sock.closed?
- end
-
- # Sends a CAPABILITY command, and returns an array of
- # capabilities that the server supports. Each capability
- # is a string. See [IMAP] for a list of possible
- # capabilities.
- #
- # Note that the Net::IMAP class does not modify its
- # behaviour according to the capabilities of the server;
- # it is up to the user of the class to ensure that
- # a certain capability is supported by a server before
- # using it.
- def capability
- synchronize do
- send_command("CAPABILITY")
- return @responses.delete("CAPABILITY")[-1]
- end
- end
-
- # Sends a NOOP command to the server. It does nothing.
- def noop
- send_command("NOOP")
- end
-
- # Sends a LOGOUT command to inform the server that the client is
- # done with the connection.
- def logout
- send_command("LOGOUT")
- end
-
- # Sends a STARTTLS command to start TLS session.
- def starttls(options = {}, verify = true)
- send_command("STARTTLS") do |resp|
- if resp.kind_of?(TaggedResponse) && resp.name == "OK"
- begin
- # for backward compatibility
- certs = options.to_str
- options = create_ssl_params(certs, verify)
- rescue NoMethodError
- end
- start_tls_session(options)
- end
- end
- end
-
- # Sends an AUTHENTICATE command to authenticate the client.
- # The +auth_type+ parameter is a string that represents
- # the authentication mechanism to be used. Currently Net::IMAP
- # supports the authentication mechanisms:
- #
- # LOGIN:: login using cleartext user and password.
- # CRAM-MD5:: login with cleartext user and encrypted password
- # (see [RFC-2195] for a full description). This
- # mechanism requires that the server have the user's
- # password stored in clear-text password.
- #
- # For both of these mechanisms, there should be two +args+: username
- # and (cleartext) password. A server may not support one or the other
- # of these mechanisms; check #capability() for a capability of
- # the form "AUTH=LOGIN" or "AUTH=CRAM-MD5".
- #
- # Authentication is done using the appropriate authenticator object:
- # see @@authenticators for more information on plugging in your own
- # authenticator.
- #
- # For example:
- #
- # imap.authenticate('LOGIN', user, password)
- #
- # A Net::IMAP::NoResponseError is raised if authentication fails.
- def authenticate(auth_type, *args)
- auth_type = auth_type.upcase
- unless @@authenticators.has_key?(auth_type)
- raise ArgumentError,
- format('unknown auth type - "%s"', auth_type)
- end
- authenticator = @@authenticators[auth_type].new(*args)
- send_command("AUTHENTICATE", auth_type) do |resp|
- if resp.instance_of?(ContinuationRequest)
- data = authenticator.process(resp.data.text.unpack("m")[0])
- s = [data].pack("m").gsub(/\n/, "")
- send_string_data(s)
- put_string(CRLF)
- end
- end
- end
-
- # Sends a LOGIN command to identify the client and carries
- # the plaintext +password+ authenticating this +user+. Note
- # that, unlike calling #authenticate() with an +auth_type+
- # of "LOGIN", #login() does *not* use the login authenticator.
- #
- # A Net::IMAP::NoResponseError is raised if authentication fails.
- def login(user, password)
- send_command("LOGIN", user, password)
- end
-
- # Sends a SELECT command to select a +mailbox+ so that messages
- # in the +mailbox+ can be accessed.
- #
- # After you have selected a mailbox, you may retrieve the
- # number of items in that mailbox from @responses["EXISTS"][-1],
- # and the number of recent messages from @responses["RECENT"][-1].
- # Note that these values can change if new messages arrive
- # during a session; see #add_response_handler() for a way of
- # detecting this event.
- #
- # A Net::IMAP::NoResponseError is raised if the mailbox does not
- # exist or is for some reason non-selectable.
- def select(mailbox)
- synchronize do
- @responses.clear
- send_command("SELECT", mailbox)
- end
- end
-
- # Sends a EXAMINE command to select a +mailbox+ so that messages
- # in the +mailbox+ can be accessed. Behaves the same as #select(),
- # except that the selected +mailbox+ is identified as read-only.
- #
- # A Net::IMAP::NoResponseError is raised if the mailbox does not
- # exist or is for some reason non-examinable.
- def examine(mailbox)
- synchronize do
- @responses.clear
- send_command("EXAMINE", mailbox)
- end
- end
-
- # Sends a CREATE command to create a new +mailbox+.
- #
- # A Net::IMAP::NoResponseError is raised if a mailbox with that name
- # cannot be created.
- def create(mailbox)
- send_command("CREATE", mailbox)
- end
-
- # Sends a DELETE command to remove the +mailbox+.
- #
- # A Net::IMAP::NoResponseError is raised if a mailbox with that name
- # cannot be deleted, either because it does not exist or because the
- # client does not have permission to delete it.
- def delete(mailbox)
- send_command("DELETE", mailbox)
- end
-
- # Sends a RENAME command to change the name of the +mailbox+ to
- # +newname+.
- #
- # A Net::IMAP::NoResponseError is raised if a mailbox with the
- # name +mailbox+ cannot be renamed to +newname+ for whatever
- # reason; for instance, because +mailbox+ does not exist, or
- # because there is already a mailbox with the name +newname+.
- def rename(mailbox, newname)
- send_command("RENAME", mailbox, newname)
- end
-
- # Sends a SUBSCRIBE command to add the specified +mailbox+ name to
- # the server's set of "active" or "subscribed" mailboxes as returned
- # by #lsub().
- #
- # A Net::IMAP::NoResponseError is raised if +mailbox+ cannot be
- # subscribed to; for instance, because it does not exist.
- def subscribe(mailbox)
- send_command("SUBSCRIBE", mailbox)
- end
-
- # Sends a UNSUBSCRIBE command to remove the specified +mailbox+ name
- # from the server's set of "active" or "subscribed" mailboxes.
- #
- # A Net::IMAP::NoResponseError is raised if +mailbox+ cannot be
- # unsubscribed from; for instance, because the client is not currently
- # subscribed to it.
- def unsubscribe(mailbox)
- send_command("UNSUBSCRIBE", mailbox)
- end
-
- # Sends a LIST command, and returns a subset of names from
- # the complete set of all names available to the client.
- # +refname+ provides a context (for instance, a base directory
- # in a directory-based mailbox hierarchy). +mailbox+ specifies
- # a mailbox or (via wildcards) mailboxes under that context.
- # Two wildcards may be used in +mailbox+: '*', which matches
- # all characters *including* the hierarchy delimiter (for instance,
- # '/' on a UNIX-hosted directory-based mailbox hierarchy); and '%',
- # which matches all characters *except* the hierarchy delimiter.
- #
- # If +refname+ is empty, +mailbox+ is used directly to determine
- # which mailboxes to match. If +mailbox+ is empty, the root
- # name of +refname+ and the hierarchy delimiter are returned.
- #
- # The return value is an array of +Net::IMAP::MailboxList+. For example:
- #
- # imap.create("foo/bar")
- # imap.create("foo/baz")
- # p imap.list("", "foo/%")
- # #=> [#, \\
- # #, \\
- # #]
- def list(refname, mailbox)
- synchronize do
- send_command("LIST", refname, mailbox)
- return @responses.delete("LIST")
- end
- end
-
- # Sends a XLIST command, and returns a subset of names from
- # the complete set of all names available to the client.
- # +refname+ provides a context (for instance, a base directory
- # in a directory-based mailbox hierarchy). +mailbox+ specifies
- # a mailbox or (via wildcards) mailboxes under that context.
- # Two wildcards may be used in +mailbox+: '*', which matches
- # all characters *including* the hierarchy delimiter (for instance,
- # '/' on a UNIX-hosted directory-based mailbox hierarchy); and '%',
- # which matches all characters *except* the hierarchy delimiter.
- #
- # If +refname+ is empty, +mailbox+ is used directly to determine
- # which mailboxes to match. If +mailbox+ is empty, the root
- # name of +refname+ and the hierarchy delimiter are returned.
- #
- # The XLIST command is like the LIST command except that the flags
- # returned refer to the function of the folder/mailbox, e.g. :Sent
- #
- # The return value is an array of +Net::IMAP::MailboxList+. For example:
- #
- # imap.create("foo/bar")
- # imap.create("foo/baz")
- # p imap.xlist("", "foo/%")
- # #=> [#, \\
- # #, \\
- # #]
- def xlist(refname, mailbox)
- synchronize do
- send_command("XLIST", refname, mailbox)
- return @responses.delete("XLIST")
- end
- end
-
- # Sends the GETQUOTAROOT command along with the specified +mailbox+.
- # This command is generally available to both admin and user.
- # If this mailbox exists, it returns an array containing objects of type
- # Net::IMAP::MailboxQuotaRoot and Net::IMAP::MailboxQuota.
- def getquotaroot(mailbox)
- synchronize do
- send_command("GETQUOTAROOT", mailbox)
- result = []
- result.concat(@responses.delete("QUOTAROOT"))
- result.concat(@responses.delete("QUOTA"))
- return result
- end
- end
-
- # Sends the GETQUOTA command along with specified +mailbox+.
- # If this mailbox exists, then an array containing a
- # Net::IMAP::MailboxQuota object is returned. This
- # command is generally only available to server admin.
- def getquota(mailbox)
- synchronize do
- send_command("GETQUOTA", mailbox)
- return @responses.delete("QUOTA")
- end
- end
-
- # Sends a SETQUOTA command along with the specified +mailbox+ and
- # +quota+. If +quota+ is nil, then +quota+ will be unset for that
- # mailbox. Typically one needs to be logged in as a server admin
- # for this to work. The IMAP quota commands are described in
- # [RFC-2087].
- def setquota(mailbox, quota)
- if quota.nil?
- data = '()'
- else
- data = '(STORAGE ' + quota.to_s + ')'
- end
- send_command("SETQUOTA", mailbox, RawData.new(data))
- end
-
- # Sends the SETACL command along with +mailbox+, +user+ and the
- # +rights+ that user is to have on that mailbox. If +rights+ is nil,
- # then that user will be stripped of any rights to that mailbox.
- # The IMAP ACL commands are described in [RFC-2086].
- def setacl(mailbox, user, rights)
- if rights.nil?
- send_command("SETACL", mailbox, user, "")
- else
- send_command("SETACL", mailbox, user, rights)
- end
- end
-
- # Send the GETACL command along with a specified +mailbox+.
- # If this mailbox exists, an array containing objects of
- # Net::IMAP::MailboxACLItem will be returned.
- def getacl(mailbox)
- synchronize do
- send_command("GETACL", mailbox)
- return @responses.delete("ACL")[-1]
- end
- end
-
- # Sends a LSUB command, and returns a subset of names from the set
- # of names that the user has declared as being "active" or
- # "subscribed." +refname+ and +mailbox+ are interpreted as
- # for #list().
- # The return value is an array of +Net::IMAP::MailboxList+.
- def lsub(refname, mailbox)
- synchronize do
- send_command("LSUB", refname, mailbox)
- return @responses.delete("LSUB")
- end
- end
-
- # Sends a STATUS command, and returns the status of the indicated
- # +mailbox+. +attr+ is a list of one or more attributes whose
- # statuses are to be requested. Supported attributes include:
- #
- # MESSAGES:: the number of messages in the mailbox.
- # RECENT:: the number of recent messages in the mailbox.
- # UNSEEN:: the number of unseen messages in the mailbox.
- #
- # The return value is a hash of attributes. For example:
- #
- # p imap.status("inbox", ["MESSAGES", "RECENT"])
- # #=> {"RECENT"=>0, "MESSAGES"=>44}
- #
- # A Net::IMAP::NoResponseError is raised if status values
- # for +mailbox+ cannot be returned; for instance, because it
- # does not exist.
- def status(mailbox, attr)
- synchronize do
- send_command("STATUS", mailbox, attr)
- return @responses.delete("STATUS")[-1].attr
- end
- end
-
- # Sends a APPEND command to append the +message+ to the end of
- # the +mailbox+. The optional +flags+ argument is an array of
- # flags initially passed to the new message. The optional
- # +date_time+ argument specifies the creation time to assign to the
- # new message; it defaults to the current time.
- # For example:
- #
- # imap.append("inbox", <:: a set of message sequence numbers. ',' indicates
- # an interval, ':' indicates a range. For instance,
- # '2,10:12,15' means "2,10,11,12,15".
- #
- # BEFORE :: messages with an internal date strictly before
- # . The date argument has a format similar
- # to 8-Aug-2002.
- #
- # BODY :: messages that contain within their body.
- #
- # CC :: messages containing in their CC field.
- #
- # FROM :: messages that contain in their FROM field.
- #
- # NEW:: messages with the \Recent, but not the \Seen, flag set.
- #
- # NOT :: negate the following search key.
- #
- # OR :: "or" two search keys together.
- #
- # ON :: messages with an internal date exactly equal to ,
- # which has a format similar to 8-Aug-2002.
- #
- # SINCE :: messages with an internal date on or after .
- #
- # SUBJECT :: messages with in their subject.
- #
- # TO :: messages with in their TO field.
- #
- # For example:
- #
- # p imap.search(["SUBJECT", "hello", "NOT", "NEW"])
- # #=> [1, 6, 7, 8]
- def search(keys, charset = nil)
- return search_internal("SEARCH", keys, charset)
- end
-
- # Similar to #search(), but returns unique identifiers.
- def uid_search(keys, charset = nil)
- return search_internal("UID SEARCH", keys, charset)
- end
-
- # Sends a FETCH command to retrieve data associated with a message
- # in the mailbox.
- #
- # The +set+ parameter is a number or a range between two numbers,
- # or an array of those. The number is a message sequence number,
- # where -1 repesents a '*' for use in range notation like 100..-1
- # being interpreted as '100:*'. Beware that the +exclude_end?+
- # property of a Range object is ignored, and the contents of a
- # range are independent of the order of the range endpoints as per
- # the protocol specification, so 1...5, 5..1 and 5...1 are all
- # equivalent to 1..5.
- #
- # +attr+ is a list of attributes to fetch; see the documentation
- # for Net::IMAP::FetchData for a list of valid attributes.
- #
- # The return value is an array of Net::IMAP::FetchData or nil
- # (instead of an empty array) if there is no matching message.
- #
- # For example:
- #
- # p imap.fetch(6..8, "UID")
- # #=> [#98}>, \\
- # #99}>, \\
- # #100}>]
- # p imap.fetch(6, "BODY[HEADER.FIELDS (SUBJECT)]")
- # #=> [#"Subject: test\r\n\r\n"}>]
- # data = imap.uid_fetch(98, ["RFC822.SIZE", "INTERNALDATE"])[0]
- # p data.seqno
- # #=> 6
- # p data.attr["RFC822.SIZE"]
- # #=> 611
- # p data.attr["INTERNALDATE"]
- # #=> "12-Oct-2000 22:40:59 +0900"
- # p data.attr["UID"]
- # #=> 98
- def fetch(set, attr)
- return fetch_internal("FETCH", set, attr)
- end
-
- # Similar to #fetch(), but +set+ contains unique identifiers.
- def uid_fetch(set, attr)
- return fetch_internal("UID FETCH", set, attr)
- end
-
- # Sends a STORE command to alter data associated with messages
- # in the mailbox, in particular their flags. The +set+ parameter
- # is a number, an array of numbers, or a Range object. Each number
- # is a message sequence number. +attr+ is the name of a data item
- # to store: 'FLAGS' will replace the message's flag list
- # with the provided one, '+FLAGS' will add the provided flags,
- # and '-FLAGS' will remove them. +flags+ is a list of flags.
- #
- # The return value is an array of Net::IMAP::FetchData. For example:
- #
- # p imap.store(6..8, "+FLAGS", [:Deleted])
- # #=> [#[:Seen, :Deleted]}>, \\
- # #[:Seen, :Deleted]}>, \\
- # #[:Seen, :Deleted]}>]
- def store(set, attr, flags)
- return store_internal("STORE", set, attr, flags)
- end
-
- # Similar to #store(), but +set+ contains unique identifiers.
- def uid_store(set, attr, flags)
- return store_internal("UID STORE", set, attr, flags)
- end
-
- # Sends a COPY command to copy the specified message(s) to the end
- # of the specified destination +mailbox+. The +set+ parameter is
- # a number, an array of numbers, or a Range object. The number is
- # a message sequence number.
- def copy(set, mailbox)
- copy_internal("COPY", set, mailbox)
- end
-
- # Similar to #copy(), but +set+ contains unique identifiers.
- def uid_copy(set, mailbox)
- copy_internal("UID COPY", set, mailbox)
- end
-
- # Sends a SORT command to sort messages in the mailbox.
- # Returns an array of message sequence numbers. For example:
- #
- # p imap.sort(["FROM"], ["ALL"], "US-ASCII")
- # #=> [1, 2, 3, 5, 6, 7, 8, 4, 9]
- # p imap.sort(["DATE"], ["SUBJECT", "hello"], "US-ASCII")
- # #=> [6, 7, 8, 1]
- #
- # See [SORT-THREAD-EXT] for more details.
- def sort(sort_keys, search_keys, charset)
- return sort_internal("SORT", sort_keys, search_keys, charset)
- end
-
- # Similar to #sort(), but returns an array of unique identifiers.
- def uid_sort(sort_keys, search_keys, charset)
- return sort_internal("UID SORT", sort_keys, search_keys, charset)
- end
-
- # Adds a response handler. For example, to detect when
- # the server sends a new EXISTS response (which normally
- # indicates new messages being added to the mailbox),
- # add the following handler after selecting the
- # mailbox:
- #
- # imap.add_response_handler { |resp|
- # if resp.kind_of?(Net::IMAP::UntaggedResponse) and resp.name == "EXISTS"
- # puts "Mailbox now has #{resp.data} messages"
- # end
- # }
- #
- def add_response_handler(handler = Proc.new)
- @response_handlers.push(handler)
- end
-
- # Removes the response handler.
- def remove_response_handler(handler)
- @response_handlers.delete(handler)
- end
-
- # Similar to #search(), but returns message sequence numbers in threaded
- # format, as a Net::IMAP::ThreadMember tree. The supported algorithms
- # are:
- #
- # ORDEREDSUBJECT:: split into single-level threads according to subject,
- # ordered by date.
- # REFERENCES:: split into threads by parent/child relationships determined
- # by which message is a reply to which.
- #
- # Unlike #search(), +charset+ is a required argument. US-ASCII
- # and UTF-8 are sample values.
- #
- # See [SORT-THREAD-EXT] for more details.
- def thread(algorithm, search_keys, charset)
- return thread_internal("THREAD", algorithm, search_keys, charset)
- end
-
- # Similar to #thread(), but returns unique identifiers instead of
- # message sequence numbers.
- def uid_thread(algorithm, search_keys, charset)
- return thread_internal("UID THREAD", algorithm, search_keys, charset)
- end
-
- # Sends an IDLE command that waits for notifications of new or expunged
- # messages. Yields responses from the server during the IDLE.
- #
- # Use #idle_done() to leave IDLE.
- def idle(&response_handler)
- raise LocalJumpError, "no block given" unless response_handler
-
- response = nil
-
- synchronize do
- tag = Thread.current[:net_imap_tag] = generate_tag
- put_string("#{tag} IDLE#{CRLF}")
-
- begin
- add_response_handler(response_handler)
- @idle_done_cond = new_cond
- @idle_done_cond.wait
- @idle_done_cond = nil
- if @receiver_thread_terminating
- raise Net::IMAP::Error, "connection closed"
- end
- ensure
- unless @receiver_thread_terminating
- remove_response_handler(response_handler)
- put_string("DONE#{CRLF}")
- response = get_tagged_response(tag, "IDLE")
- end
- end
- end
-
- return response
- end
-
- # Leaves IDLE.
- def idle_done
- synchronize do
- if @idle_done_cond.nil?
- raise Net::IMAP::Error, "not during IDLE"
- end
- @idle_done_cond.signal
- end
- end
-
- # Decode a string from modified UTF-7 format to UTF-8.
- #
- # UTF-7 is a 7-bit encoding of Unicode [UTF7]. IMAP uses a
- # slightly modified version of this to encode mailbox names
- # containing non-ASCII characters; see [IMAP] section 5.1.3.
- #
- # Net::IMAP does _not_ automatically encode and decode
- # mailbox names to and from UTF-7.
- def self.decode_utf7(s)
- return s.gsub(/&([^-]+)?-/n) {
- if $1
- ($1.tr(",", "/") + "===").unpack("m")[0].encode(Encoding::UTF_8, Encoding::UTF_16BE)
- else
- "&"
- end
- }
- end
-
- # Encode a string from UTF-8 format to modified UTF-7.
- def self.encode_utf7(s)
- return s.gsub(/(&)|[^\x20-\x7e]+/) {
- if $1
- "&-"
- else
- base64 = [$&.encode(Encoding::UTF_16BE)].pack("m")
- "&" + base64.delete("=\n").tr("/", ",") + "-"
- end
- }.force_encoding("ASCII-8BIT")
- end
-
- # Formats +time+ as an IMAP-style date.
- def self.format_date(time)
- return time.strftime('%d-%b-%Y')
- end
-
- # Formats +time+ as an IMAP-style date-time.
- def self.format_datetime(time)
- return time.strftime('%d-%b-%Y %H:%M %z')
- end
-
- private
-
- CRLF = "\r\n" # :nodoc:
- PORT = 143 # :nodoc:
- SSL_PORT = 993 # :nodoc:
-
- @@debug = false
- @@authenticators = {}
- @@max_flag_count = 10000
-
- # :call-seq:
- # Net::IMAP.new(host, options = {})
- #
- # Creates a new Net::IMAP object and connects it to the specified
- # +host+.
- #
- # +options+ is an option hash, each key of which is a symbol.
- #
- # The available options are:
- #
- # port:: Port number (default value is 143 for imap, or 993 for imaps)
- # ssl:: If options[:ssl] is true, then an attempt will be made
- # to use SSL (now TLS) to connect to the server. For this to work
- # OpenSSL [OSSL] and the Ruby OpenSSL [RSSL] extensions need to
- # be installed.
- # If options[:ssl] is a hash, it's passed to
- # OpenSSL::SSL::SSLContext#set_params as parameters.
- #
- # The most common errors are:
- #
- # Errno::ECONNREFUSED:: Connection refused by +host+ or an intervening
- # firewall.
- # Errno::ETIMEDOUT:: Connection timed out (possibly due to packets
- # being dropped by an intervening firewall).
- # Errno::ENETUNREACH:: There is no route to that network.
- # SocketError:: Hostname not known or other socket error.
- # Net::IMAP::ByeResponseError:: The connected to the host was successful, but
- # it immediately said goodbye.
- def initialize(host, port_or_options = {},
- usessl = false, certs = nil, verify = true)
- super()
- @host = host
- begin
- options = port_or_options.to_hash
- rescue NoMethodError
- # for backward compatibility
- options = {}
- options[:port] = port_or_options
- if usessl
- options[:ssl] = create_ssl_params(certs, verify)
- end
- end
- @port = options[:port] || (options[:ssl] ? SSL_PORT : PORT)
- @tag_prefix = "RUBY"
- @tagno = 0
- @parser = ResponseParser.new
- @sock = TCPSocket.open(@host, @port)
- begin
- if options[:ssl]
- start_tls_session(options[:ssl])
- @usessl = true
- else
- @usessl = false
- end
- @responses = Hash.new([].freeze)
- @tagged_responses = {}
- @response_handlers = []
- @tagged_response_arrival = new_cond
- @continuation_request_arrival = new_cond
- @idle_done_cond = nil
- @logout_command_tag = nil
- @debug_output_bol = true
- @exception = nil
-
- @greeting = get_response
- if @greeting.nil?
- raise Error, "connection closed"
- end
- if @greeting.name == "BYE"
- raise ByeResponseError, @greeting
- end
-
- @client_thread = Thread.current
- @receiver_thread = Thread.start {
- begin
- receive_responses
- rescue Exception
- end
- }
- @receiver_thread_terminating = false
- rescue Exception
- @sock.close
- raise
- end
- end
-
- def receive_responses
- connection_closed = false
- until connection_closed
- synchronize do
- @exception = nil
- end
- begin
- resp = get_response
- rescue Exception => e
- synchronize do
- @sock.close
- @exception = e
- end
- break
- end
- unless resp
- synchronize do
- @exception = EOFError.new("end of file reached")
- end
- break
- end
- begin
- synchronize do
- case resp
- when TaggedResponse
- @tagged_responses[resp.tag] = resp
- @tagged_response_arrival.broadcast
- if resp.tag == @logout_command_tag
- return
- end
- when UntaggedResponse
- record_response(resp.name, resp.data)
- if resp.data.instance_of?(ResponseText) &&
- (code = resp.data.code)
- record_response(code.name, code.data)
- end
- if resp.name == "BYE" && @logout_command_tag.nil?
- @sock.close
- @exception = ByeResponseError.new(resp)
- connection_closed = true
- end
- when ContinuationRequest
- @continuation_request_arrival.signal
- end
- @response_handlers.each do |handler|
- handler.call(resp)
- end
- end
- rescue Exception => e
- @exception = e
- synchronize do
- @tagged_response_arrival.broadcast
- @continuation_request_arrival.broadcast
- end
- end
- end
- synchronize do
- @receiver_thread_terminating = true
- @tagged_response_arrival.broadcast
- @continuation_request_arrival.broadcast
- if @idle_done_cond
- @idle_done_cond.signal
- end
- end
- end
-
- def get_tagged_response(tag, cmd)
- until @tagged_responses.key?(tag)
- raise @exception if @exception
- @tagged_response_arrival.wait
- end
- resp = @tagged_responses.delete(tag)
- case resp.name
- when /\A(?:NO)\z/ni
- raise NoResponseError, resp
- when /\A(?:BAD)\z/ni
- raise BadResponseError, resp
- else
- return resp
- end
- end
-
- def get_response
- buff = ""
- while true
- s = @sock.gets(CRLF)
- break unless s
- buff.concat(s)
- if /\{(\d+)\}\r\n/n =~ s
- s = @sock.read($1.to_i)
- buff.concat(s)
- else
- break
- end
- end
- return nil if buff.length == 0
- if @@debug
- $stderr.print(buff.gsub(/^/n, "S: "))
- end
- return @parser.parse(buff)
- end
-
- def record_response(name, data)
- unless @responses.has_key?(name)
- @responses[name] = []
- end
- @responses[name].push(data)
- end
-
- def send_command(cmd, *args, &block)
- synchronize do
- args.each do |i|
- validate_data(i)
- end
- tag = generate_tag
- put_string(tag + " " + cmd)
- args.each do |i|
- put_string(" ")
- send_data(i)
- end
- put_string(CRLF)
- if cmd == "LOGOUT"
- @logout_command_tag = tag
- end
- if block
- add_response_handler(block)
- end
- begin
- return get_tagged_response(tag, cmd)
- ensure
- if block
- remove_response_handler(block)
- end
- end
- end
- end
-
- def generate_tag
- @tagno += 1
- return format("%s%04d", @tag_prefix, @tagno)
- end
-
- def put_string(str)
- @sock.print(str)
- if @@debug
- if @debug_output_bol
- $stderr.print("C: ")
- end
- $stderr.print(str.gsub(/\n(?!\z)/n, "\nC: "))
- if /\r\n\z/n.match(str)
- @debug_output_bol = true
- else
- @debug_output_bol = false
- end
- end
- end
-
- def validate_data(data)
- case data
- when nil
- when String
- when Integer
- NumValidator.ensure_number(data)
- when Array
- data.each do |i|
- validate_data(i)
- end
- when Time
- when Symbol
- else
- data.validate
- end
- end
-
- def send_data(data)
- case data
- when nil
- put_string("NIL")
- when String
- send_string_data(data)
- when Integer
- send_number_data(data)
- when Array
- send_list_data(data)
- when Time
- send_time_data(data)
- when Symbol
- send_symbol_data(data)
- else
- data.send_data(self)
- end
- end
-
- def send_string_data(str)
- case str
- when ""
- put_string('""')
- when /[\x80-\xff\r\n]/n
- # literal
- send_literal(str)
- when /[(){ \x00-\x1f\x7f%*"\\]/n
- # quoted string
- send_quoted_string(str)
- else
- put_string(str)
- end
- end
-
- def send_quoted_string(str)
- put_string('"' + str.gsub(/["\\]/n, "\\\\\\&") + '"')
- end
-
- def send_literal(str)
- put_string("{" + str.bytesize.to_s + "}" + CRLF)
- @continuation_request_arrival.wait
- raise @exception if @exception
- put_string(str)
- end
-
- def send_number_data(num)
- put_string(num.to_s)
- end
-
- def send_list_data(list)
- put_string("(")
- first = true
- list.each do |i|
- if first
- first = false
- else
- put_string(" ")
- end
- send_data(i)
- end
- put_string(")")
- end
-
- DATE_MONTH = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
-
- def send_time_data(time)
- t = time.dup.gmtime
- s = format('"%2d-%3s-%4d %02d:%02d:%02d +0000"',
- t.day, DATE_MONTH[t.month - 1], t.year,
- t.hour, t.min, t.sec)
- put_string(s)
- end
-
- def send_symbol_data(symbol)
- put_string("\\" + symbol.to_s)
- end
-
- def search_internal(cmd, keys, charset)
- if keys.instance_of?(String)
- keys = [RawData.new(keys)]
- else
- normalize_searching_criteria(keys)
- end
- synchronize do
- if charset
- send_command(cmd, "CHARSET", charset, *keys)
- else
- send_command(cmd, *keys)
- end
- return @responses.delete("SEARCH")[-1]
- end
- end
-
- def fetch_internal(cmd, set, attr)
- case attr
- when String then
- attr = RawData.new(attr)
- when Array then
- attr = attr.map { |arg|
- arg.is_a?(String) ? RawData.new(arg) : arg
- }
- end
-
- synchronize do
- @responses.delete("FETCH")
- send_command(cmd, MessageSet.new(set), attr)
- return @responses.delete("FETCH")
- end
- end
-
- def store_internal(cmd, set, attr, flags)
- if attr.instance_of?(String)
- attr = RawData.new(attr)
- end
- synchronize do
- @responses.delete("FETCH")
- send_command(cmd, MessageSet.new(set), attr, flags)
- return @responses.delete("FETCH")
- end
- end
-
- def copy_internal(cmd, set, mailbox)
- send_command(cmd, MessageSet.new(set), mailbox)
- end
-
- def sort_internal(cmd, sort_keys, search_keys, charset)
- if search_keys.instance_of?(String)
- search_keys = [RawData.new(search_keys)]
- else
- normalize_searching_criteria(search_keys)
- end
- normalize_searching_criteria(search_keys)
- synchronize do
- send_command(cmd, sort_keys, charset, *search_keys)
- return @responses.delete("SORT")[-1]
- end
- end
-
- def thread_internal(cmd, algorithm, search_keys, charset)
- if search_keys.instance_of?(String)
- search_keys = [RawData.new(search_keys)]
- else
- normalize_searching_criteria(search_keys)
- end
- normalize_searching_criteria(search_keys)
- send_command(cmd, algorithm, charset, *search_keys)
- return @responses.delete("THREAD")[-1]
- end
-
- def normalize_searching_criteria(keys)
- keys.collect! do |i|
- case i
- when -1, Range, Array
- MessageSet.new(i)
- else
- i
- end
- end
- end
-
- def create_ssl_params(certs = nil, verify = true)
- params = {}
- if certs
- if File.file?(certs)
- params[:ca_file] = certs
- elsif File.directory?(certs)
- params[:ca_path] = certs
- end
- end
- if verify
- params[:verify_mode] = VERIFY_PEER
- else
- params[:verify_mode] = VERIFY_NONE
- end
- return params
- end
-
- def start_tls_session(params = {})
- unless defined?(OpenSSL::SSL)
- raise "SSL extension not installed"
- end
- if @sock.kind_of?(OpenSSL::SSL::SSLSocket)
- raise RuntimeError, "already using SSL"
- end
- begin
- params = params.to_hash
- rescue NoMethodError
- params = {}
- end
- context = SSLContext.new
- context.set_params(params)
- if defined?(VerifyCallbackProc)
- context.verify_callback = VerifyCallbackProc
- end
- @sock = SSLSocket.new(@sock, context)
- @sock.sync_close = true
- @sock.connect
- if context.verify_mode != VERIFY_NONE
- @sock.post_connection_check(@host)
- end
- end
-
- class RawData # :nodoc:
- def send_data(imap)
- imap.send(:put_string, @data)
- end
-
- def validate
- end
-
- private
-
- def initialize(data)
- @data = data
- end
- end
-
- class Atom # :nodoc:
- def send_data(imap)
- imap.send(:put_string, @data)
- end
-
- def validate
- end
-
- private
-
- def initialize(data)
- @data = data
- end
- end
-
- class QuotedString # :nodoc:
- def send_data(imap)
- imap.send(:send_quoted_string, @data)
- end
-
- def validate
- end
-
- private
-
- def initialize(data)
- @data = data
- end
- end
-
- class Literal # :nodoc:
- def send_data(imap)
- imap.send(:send_literal, @data)
- end
-
- def validate
- end
-
- private
-
- def initialize(data)
- @data = data
- end
- end
-
- class MessageSet # :nodoc:
- def send_data(imap)
- imap.send(:put_string, format_internal(@data))
- end
-
- def validate
- validate_internal(@data)
- end
-
- private
-
- def initialize(data)
- @data = data
- end
-
- def format_internal(data)
- case data
- when "*"
- return data
- when Integer
- if data == -1
- return "*"
- else
- return data.to_s
- end
- when Range
- return format_internal(data.first) +
- ":" + format_internal(data.last)
- when Array
- return data.collect {|i| format_internal(i)}.join(",")
- when ThreadMember
- return data.seqno.to_s +
- ":" + data.children.collect {|i| format_internal(i).join(",")}
- end
- end
-
- def validate_internal(data)
- case data
- when "*"
- when Integer
- NumValidator.ensure_nz_number(data)
- when Range
- when Array
- data.each do |i|
- validate_internal(i)
- end
- when ThreadMember
- data.children.each do |i|
- validate_internal(i)
- end
- else
- raise DataFormatError, data.inspect
- end
- end
- end
-
- # Common validators of number and nz_number types
- module NumValidator # :nodoc
- class << self
- # Check is passed argument valid 'number' in RFC 3501 terminology
- def valid_number?(num)
- # [RFC 3501]
- # number = 1*DIGIT
- # ; Unsigned 32-bit integer
- # ; (0 <= n < 4,294,967,296)
- num >= 0 && num < 4294967296
- end
-
- # Check is passed argument valid 'nz_number' in RFC 3501 terminology
- def valid_nz_number?(num)
- # [RFC 3501]
- # nz-number = digit-nz *DIGIT
- # ; Non-zero unsigned 32-bit integer
- # ; (0 < n < 4,294,967,296)
- num != 0 && valid_number?(num)
- end
-
- # Ensure argument is 'number' or raise DataFormatError
- def ensure_number(num)
- return if valid_number?(num)
-
- msg = "number must be unsigned 32-bit integer: #{num}"
- raise DataFormatError, msg
- end
-
- # Ensure argument is 'nz_number' or raise DataFormatError
- def ensure_nz_number(num)
- return if valid_nz_number?(num)
-
- msg = "nz_number must be non-zero unsigned 32-bit integer: #{num}"
- raise DataFormatError, msg
- end
- end
- end
-
- # Net::IMAP::ContinuationRequest represents command continuation requests.
- #
- # The command continuation request response is indicated by a "+" token
- # instead of a tag. This form of response indicates that the server is
- # ready to accept the continuation of a command from the client. The
- # remainder of this response is a line of text.
- #
- # continue_req ::= "+" SPACE (resp_text / base64)
- #
- # ==== Fields:
- #
- # data:: Returns the data (Net::IMAP::ResponseText).
- #
- # raw_data:: Returns the raw data string.
- ContinuationRequest = Struct.new(:data, :raw_data)
-
- # Net::IMAP::UntaggedResponse represents untagged responses.
- #
- # Data transmitted by the server to the client and status responses
- # that do not indicate command completion are prefixed with the token
- # "*", and are called untagged responses.
- #
- # response_data ::= "*" SPACE (resp_cond_state / resp_cond_bye /
- # mailbox_data / message_data / capability_data)
- #
- # ==== Fields:
- #
- # name:: Returns the name, such as "FLAGS", "LIST", or "FETCH".
- #
- # data:: Returns the data such as an array of flag symbols,
- # a (()) object.
- #
- # raw_data:: Returns the raw data string.
- UntaggedResponse = Struct.new(:name, :data, :raw_data)
-
- # Net::IMAP::TaggedResponse represents tagged responses.
- #
- # The server completion result response indicates the success or
- # failure of the operation. It is tagged with the same tag as the
- # client command which began the operation.
- #
- # response_tagged ::= tag SPACE resp_cond_state CRLF
- #
- # tag ::= 1*
- #
- # resp_cond_state ::= ("OK" / "NO" / "BAD") SPACE resp_text
- #
- # ==== Fields:
- #
- # tag:: Returns the tag.
- #
- # name:: Returns the name, one of "OK", "NO", or "BAD".
- #
- # data:: Returns the data. See (()).
- #
- # raw_data:: Returns the raw data string.
- #
- TaggedResponse = Struct.new(:tag, :name, :data, :raw_data)
-
- # Net::IMAP::ResponseText represents texts of responses.
- # The text may be prefixed by the response code.
- #
- # resp_text ::= ["[" resp_text_code "]" SPACE] (text_mime2 / text)
- # ;; text SHOULD NOT begin with "[" or "="
- #
- # ==== Fields:
- #
- # code:: Returns the response code. See ((