repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/commands/cert_command.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/commands/cert_command.rb
require 'rubygems/command' require 'rubygems/security' class Gem::Commands::CertCommand < Gem::Command def initialize super 'cert', 'Manage RubyGems certificates and signing settings' add_option('-a', '--add CERT', 'Add a trusted certificate.') do |value, options| cert = OpenSSL::X509::Certificate.new(File.read(value)) Gem::Security.add_trusted_cert(cert) say "Added '#{cert.subject.to_s}'" end add_option('-l', '--list', 'List trusted certificates.') do |value, options| glob_str = File::join(Gem::Security::OPT[:trust_dir], '*.pem') Dir::glob(glob_str) do |path| begin cert = OpenSSL::X509::Certificate.new(File.read(path)) # this could probably be formatted more gracefully say cert.subject.to_s rescue OpenSSL::X509::CertificateError next end end end add_option('-r', '--remove STRING', 'Remove trusted certificates containing', 'STRING.') do |value, options| trust_dir = Gem::Security::OPT[:trust_dir] glob_str = File::join(trust_dir, '*.pem') Dir::glob(glob_str) do |path| begin cert = OpenSSL::X509::Certificate.new(File.read(path)) if cert.subject.to_s.downcase.index(value) say "Removed '#{cert.subject.to_s}'" File.unlink(path) end rescue OpenSSL::X509::CertificateError next end end end add_option('-b', '--build EMAIL_ADDR', 'Build private key and self-signed', 'certificate for EMAIL_ADDR.') do |value, options| vals = Gem::Security.build_self_signed_cert(value) File.chmod 0600, vals[:key_path] say "Public Cert: #{vals[:cert_path]}" say "Private Key: #{vals[:key_path]}" say "Don't forget to move the key file to somewhere private..." end add_option('-C', '--certificate CERT', 'Certificate for --sign command.') do |value, options| cert = OpenSSL::X509::Certificate.new(File.read(value)) Gem::Security::OPT[:issuer_cert] = cert end add_option('-K', '--private-key KEY', 'Private key for --sign command.') do |value, options| key = OpenSSL::PKey::RSA.new(File.read(value)) Gem::Security::OPT[:issuer_key] = key end add_option('-s', '--sign NEWCERT', 'Sign a certificate with my key and', 'certificate.') do |value, options| cert = OpenSSL::X509::Certificate.new(File.read(value)) my_cert = Gem::Security::OPT[:issuer_cert] my_key = Gem::Security::OPT[:issuer_key] cert = Gem::Security.sign_cert(cert, my_key, my_cert) File.open(value, 'wb') { |file| file.write(cert.to_pem) } end end def execute end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/ext/ext_conf_builder.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/ext/ext_conf_builder.rb
#-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. # See LICENSE.txt for permissions. #++ require 'rubygems/ext/builder' require 'rubygems/command' class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder def self.build(extension, directory, dest_path, results) cmd = "#{Gem.ruby} #{File.basename extension}" cmd << " #{Gem::Command.build_args.join ' '}" unless Gem::Command.build_args.empty? run cmd, results make dest_path, results results end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/ext/configure_builder.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/ext/configure_builder.rb
#-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. # See LICENSE.txt for permissions. #++ require 'rubygems/ext/builder' class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder def self.build(extension, directory, dest_path, results) unless File.exist?('Makefile') then cmd = "sh ./configure --prefix=#{dest_path}" cmd << " #{Gem::Command.build_args.join ' '}" unless Gem::Command.build_args.empty? run cmd, results end make dest_path, results results end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/ext/builder.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/ext/builder.rb
#-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. # See LICENSE.txt for permissions. #++ class Gem::Ext::Builder def self.class_name name =~ /Ext::(.*)Builder/ $1.downcase end def self.make(dest_path, results) unless File.exist? 'Makefile' then raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}" end mf = File.read('Makefile') mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}") mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}") File.open('Makefile', 'wb') {|f| f.print mf} make_program = ENV['make'] unless make_program then make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make' end ['', ' install'].each do |target| cmd = "#{make_program}#{target}" results << cmd results << `#{cmd} #{redirector}` raise Gem::InstallError, "make#{target} failed:\n\n#{results}" unless $?.success? end end def self.redirector '2>&1' end def self.run(command, results) results << command results << `#{command} #{redirector}` unless $?.success? then raise Gem::InstallError, "#{class_name} failed:\n\n#{results.join "\n"}" end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/ext/rake_builder.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/ext/rake_builder.rb
#-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. # See LICENSE.txt for permissions. #++ require 'rubygems/ext/builder' require 'rubygems/command' class Gem::Ext::RakeBuilder < Gem::Ext::Builder def self.build(extension, directory, dest_path, results) if File.basename(extension) =~ /mkrf_conf/i then cmd = "#{Gem.ruby} #{File.basename extension}" cmd << " #{Gem::Command.build_args.join " "}" unless Gem::Command.build_args.empty? run cmd, results end # Deal with possible spaces in the path, e.g. C:/Program Files dest_path = '"' + dest_path + '"' if dest_path.include?(' ') cmd = ENV['rake'] || "#{Gem.ruby} -rubygems #{Gem.bin_path('rake')}" rescue Gem.default_exec_format % 'rake' cmd += " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen run cmd, results results end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/digest/sha2.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/digest/sha2.rb
#!/usr/bin/env ruby #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. # See LICENSE.txt for permissions. #++ require 'digest/sha2' # :stopdoc: module Gem if RUBY_VERSION >= '1.8.6' SHA256 = Digest::SHA256 else require 'rubygems/digest/digest_adapter' SHA256 = DigestAdapter.new(Digest::SHA256) end end # :startdoc:
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/digest/md5.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/digest/md5.rb
#!/usr/bin/env ruby #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. # See LICENSE.txt for permissions. #++ require 'digest/md5' # :stopdoc: module Gem if RUBY_VERSION >= '1.8.6' MD5 = Digest::MD5 else require 'rubygems/digest/digest_adapter' MD5 = DigestAdapter.new(Digest::MD5) def MD5.md5(string) self.hexdigest(string) end end end # :startdoc:
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/digest/sha1.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/digest/sha1.rb
#!/usr/bin/env ruby #-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. # See LICENSE.txt for permissions. #++ require 'digest/sha1' # :stopdoc: module Gem if RUBY_VERSION >= '1.8.6' SHA1 = Digest::SHA1 else require 'rubygems/digest/digest_adapter' SHA1 = DigestAdapter.new(Digest::SHA1) end end # :startdoc:
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/digest/digest_adapter.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/digest/digest_adapter.rb
#-- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # All rights reserved. # See LICENSE.txt for permissions. #++ require 'rubygems' ## # There is an incompatibility between the way Ruby 1.8.5 and 1.8.6 handles # digests. This DigestAdapter will take a pre-1.8.6 digest and adapt it to # the 1.8.6 API. # # Note that only the digest and hexdigest methods are adapted, since these # are the only functions used by RubyGems. class Gem::DigestAdapter ## # Initialize a digest adapter. def initialize(digest_class) @digest_class = digest_class end ## # Return a new digester. Since we are only implementing the stateless # methods, we will return ourself as the instance. def new self end ## # Return the digest of +string+ as a hex string. def hexdigest(string) @digest_class.new(string).hexdigest end ## # Return the digest of +string+ as a binary string. def digest(string) @digest_class.new(string).digest end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/securerandom.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/securerandom.rb
# = Secure random number generator interface. # # This library is an interface for secure random number generator which is # suitable for generating session key in HTTP cookies, etc. # # It supports following secure random number generators. # # * Java's java.security.SecureRandom. # # == Example # # # random hexadecimal string. # p SecureRandom.hex(10) #=> "52750b30ffbc7de3b362" # p SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559" # p SecureRandom.hex(11) #=> "6aca1b5c58e4863e6b81b8" # p SecureRandom.hex(12) #=> "94b2fff3e7fd9b9c391a2306" # p SecureRandom.hex(13) #=> "39b290146bea6ce975c37cfc23" # ... # # # random base64 string. # p SecureRandom.base64(10) #=> "EcmTPZwWRAozdA==" # p SecureRandom.base64(10) #=> "9b0nsevdwNuM/w==" # p SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg==" # p SecureRandom.base64(11) #=> "l7XEiFja+8EKEtY=" # p SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8" # p SecureRandom.base64(13) #=> "vKLJ0tXBHqQOuIcSIg==" # ... # # # random binary string. # p SecureRandom.random_bytes(10) #=> "\016\t{\370g\310pbr\301" # p SecureRandom.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337" # ... require 'java' # Implements 1.8.7/1.9's SecureRandom class with java.security.SecureRandom. class SecureRandom # SecureRandom.random_bytes generates a random binary string. # # The argument n specifies the length of the result string. # # If n is not specified, 16 is assumed. # It may be larger in future. # # If secure random number generator is not available, # NotImplementedError is raised. def self.random_bytes(n=nil) n = (n.nil?) ? 16 : n.to_int raise ArgumentError, "non-integer argument: #{n}" unless n.is_a?(Fixnum) raise ArgumentError, "negative argument: #{n}" if n < 0 bytes = Java::byte[n].new java.security.SecureRandom.new.nextBytes(bytes) String.from_java_bytes bytes end # SecureRandom.hex generates a random hex string. # # The argument n specifies the length of the random length. # The length of the result string is twice of n. # # If n is not specified, 16 is assumed. # It may be larger in future. # # If secure random number generator is not available, # NotImplementedError is raised. def self.hex(n=nil) random_bytes(n).unpack("H*")[0] end # SecureRandom.base64 generates a random base64 string. # # The argument n specifies the length of the random length. # The length of the result string is about 4/3 of n. # # If n is not specified, 16 is assumed. # It may be larger in future. # # If secure random number generator is not available, # NotImplementedError is raised. def self.base64(n=nil) [random_bytes(n)].pack("m*").delete("\n") end # SecureRandom.random_number generates a random number. # # If an positive integer is given as n, # SecureRandom.random_number returns an integer: # 0 <= SecureRandom.random_number(n) < n. # # If 0 is given or an argument is not given, # SecureRandom.random_number returns an float: # 0.0 <= SecureRandom.random_number() < 1.0. def self.random_number(n=0) if 0 < n java.security.SecureRandom.new.nextInt(n) else java.security.SecureRandom.new.nextDouble end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant.rb
require 'java' class Ant def self.load_from_ant IO.popen("ant -diagnostics") do |diag| classpath_jars = [] listing_path = nil jar_path = nil diag.readlines.each do |line| if line =~ /^ant\.home: (.*)$/ && !defined?(ANT_HOME) const_set(:ANT_HOME, $1) elsif line =~ /Tasks availability/ break elsif line =~ /^ (.*) jar listing$/ listing_path = $1 elsif line =~ /^(.*\.home): (.*)$/ home_var, path = $1, $2 jar_path = listing_path.sub(home_var.upcase.sub('.','_'), path) elsif line =~ /^ant\.core\.lib: (.*)$/ classpath_jars << $1 elsif line =~ /^(.*\.jar) \(\d+ bytes\)/ classpath_jars << File.join(jar_path, $1) end end classpath_jars.uniq.each {|j| $CLASSPATH << j } end end def self.load if ENV['ANT_HOME'] && File.exist?(ENV['ANT_HOME']) const_set(:ANT_HOME, ENV['ANT_HOME']) Dir["#{ANT_HOME}/lib/*.jar"].each {|j| $CLASSPATH << j } else load_from_ant end end load end require 'ant/ant' require 'ant/rake' if defined?(::Rake)
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi.rb
require 'ffi/ffi'
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/pty.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/pty.rb
require 'ffi' module PTY private module LibUtil extend FFI::Library # forkpty(3) is in libutil on linux, libc on MacOS/BSD if FFI::Platform.linux? ffi_lib 'libutil' end attach_function :forkpty, [ :buffer_out, :buffer_out, :buffer_in, :buffer_in ], :pid_t end module LibC extend FFI::Library attach_function :close, [ :int ], :int attach_function :strerror, [ :int ], :string attach_function :execv, [ :string, :buffer_in ], :int attach_function :execvp, [ :string, :buffer_in ], :int attach_function :dup2, [ :int, :int ], :int attach_function :dup, [ :int ], :int attach_function :_exit, [ :int ], :void end Buffer = FFI::Buffer def self.build_args(args) cmd = args.shift cmd_args = args.map do |arg| MemoryPointer.from_string(arg) end exec_args = MemoryPointer.new(:pointer, 1 + cmd_args.length + 1) exec_cmd = MemoryPointer.from_string(cmd) exec_args[0].put_pointer(0, exec_cmd) cmd_args.each_with_index do |arg, i| exec_args[i + 1].put_pointer(0, arg) end [ cmd, exec_args ] end public def self.getpty(*args) mfdp = Buffer.alloc_out :int name = Buffer.alloc_out 1024 exec_cmd, exec_args = build_args(args) pid = LibUtil.forkpty(mfdp, name, nil, nil) # # We want to do as little as possible in the child process, since we're running # without any GC thread now, so test for the child case first # if pid == 0 LibC.execvp(exec_cmd, exec_args) LibC._exit(1) end raise "forkpty failed: #{LibC.strerror(FFI.errno)}" if pid < 0 masterfd = mfdp.get_int(0) rfp = FFI::IO.for_fd(masterfd, "r") wfp = FFI::IO.for_fd(LibC.dup(masterfd), "w") if block_given? retval = yield rfp, wfp, pid begin; rfp.close; rescue Exception; end begin; wfp.close; rescue Exception; end retval else [ rfp, wfp, pid ] end end def self.spawn(*args, &block) self.getpty("/bin/sh", "-c", args[0], &block) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/syslog.rb
# Created by Ari Brown on 2008-02-23. # For rubinius. All pwnage reserved. # # Used in pwning teh nubs with FFI instead of C # ** Syslog(Module) # Included Modules: Syslog::Constants # require 'syslog' # A Simple wrapper for the UNIX syslog system calls that might be handy # if you're writing a server in Ruby. For the details of the syslog(8) # architecture and constants, see the syslog(3) manual page of your # platform. begin require 'ffi' require "#{File.join(FFI::Platform::CONF_DIR, 'syslog.rb')}" rescue LoadError => ex raise LoadError, "Syslog not supported on this platform" end module Syslog include Constants module Foreign extend FFI::Library ffi_lib FFI::Platform::LIBC # methods attach_function :open, "openlog", [:pointer, :int, :int], :void attach_function :close, "closelog", [], :void attach_function :write, "syslog", [:int, :string, :string], :void attach_function :set_mask, "setlogmask", [:int], :int end class << self ## # returns the ident of the last open call attr_reader :ident ## # returns the options of the last open call attr_reader :options ## # returns the facility of the last open call attr_reader :facility ## # mask # mask=(mask) # # Returns or sets the log priority mask. The value of the mask # is persistent and will not be reset by Syslog::open or # Syslog::close. # # Example: # Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR) def mask; @mask ||= -1; end attr_writer :mask ## # open(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS, facility = Syslog::LOG_USER) [{ |syslog| ... }] # # Opens syslog with the given options and returns the module # itself. If a block is given, calls it with an argument of # itself. If syslog is already opened, raises RuntimeError. # # Examples: # Syslog.open('ftpd', Syslog::LOG_PID | Syslog::LOG_NDELAY, Syslog::LOG_FTP) # open!(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS, facility = Syslog::LOG_USER) # reopen(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS, facility = Syslog::LOG_USER) def open(ident=nil, opt=nil, fac=nil) raise "Syslog already open" unless not @opened ident ||= $0 opt ||= Constants::LOG_PID | Constants::LOG_CONS fac ||= Constants::LOG_USER @ident = ident @options = opt @facility = fac @ident_memory = if ident ptr = FFI::MemoryPointer.new ident.length + 1 ptr.write_string(ident + "\0") ptr else nil end Foreign.open(@ident_memory, opt, fac) @opened = true # Calling set_mask twice is the standard way to set the 'default' mask @mask = Foreign.set_mask(0) Foreign.set_mask(@mask) if block_given? begin yield self ensure close end end self end alias_method :open!, :open ## # like open, but closes it first def reopen(*args) close open(*args) end ## # Is it open? def opened? @opened || false end ## # Close the log # close will raise an error if it is already closed def close raise "Syslog not opened" unless @opened Foreign.close @ident = nil @options = @facility = @mask = -1; @opened = false end ## # log(Syslog::LOG_CRIT, "The %s is falling!", "sky") # # Doesn't take any platform specific printf statements # logs things to $stderr # log(Syslog::LOG_CRIT, "Welcome, %s, to my %s!", "leethaxxor", "lavratory") def log(pri, *args) write(pri, *args) end ## # handy little shortcut for LOG_EMERG as the priority def emerg(*args); write(Syslog::LOG_EMERG, *args); end ## # handy little shortcut for LOG_ALERT as the priority def alert(*args); write(Syslog::LOG_ALERT, *args); end ## # handy little shortcut for LOG_ERR as the priority def err(*args); write(Syslog::LOG_ERR, *args); end ## # handy little shortcut for LOG_CRIT as the priority def crit(*args); write(Syslog::LOG_CRIT, *args); end ## # handy little shortcut for LOG_WARNING as the priority def warning(*args);write(Syslog::LOG_WARNING, *args); end ## # handy little shortcut for LOG_NOTICE as the priority def notice(*args); write(Syslog::LOG_NOTICE, *args); end ## # handy little shortcut for LOG_INFO as the priority def info(*args); write(Syslog::LOG_INFO, *args); end ## # handy little shortcut for LOG_DEBUG as the priority def debug(*args); write(Syslog::LOG_DEBUG, *args); end ## # LOG_MASK(pri) # # HACK copied from macro # Creates a mask for one priority. def LOG_MASK(pri) 1 << pri end ## # LOG_UPTO(pri) # HACK copied from macro # Creates a mask for all priorities up to pri. def LOG_UPTO(pri) (1 << ((pri)+1)) - 1 end def inspect if @opened "#<%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>" % [self.name, @ident, @options, @facility, @mask] else "#<#{self.name}: opened=false>" end end ## # Syslog.instance # => Syslog # Returns the Syslog module def instance self end def write(pri, format, *args) raise "Syslog must be opened before write" unless @opened message = format % args Foreign.write(pri, "%s", message) end private :write end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/target.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/target.rb
require 'java' require 'ant/ant' class Ant java_import org.apache.tools.ant.Target class RakeTarget < Target ALREADY_DEFINED_PREFIX = "rake_" def initialize(ant, rake_task) super() set_project ant.project set_name generate_unique_target_name rake_task.name rake_task.prerequisites.each { |prereq| add_dependency prereq } @rake_task = rake_task end def execute @rake_task.execute end private def generate_unique_target_name(name) # FIXME: This is not guaranteed to be unique and may be a wonky naming convention? if project.targets.get(name) project.log "ant already defines #{name}. Redefining as #{ALREADY_DEFINED_PREFIX}#{name}" name = ALREADY_DEFINED_PREFIX + name end name end end class BlockTarget < Target def initialize(ant, *options, &block) super() set_project ant.project hash = extract_options(options) hash.each_pair {|k,v| send("set_#{k}", v) } @ant, @block = ant, block end def execute # Have to dupe this logic b/c Ant doesn't provide a way to # override inner part of execute if_cond, unless_cond = if_condition, unless_condition if if_cond && unless_cond execute_target elsif !if_cond project.log(self, "Skipped because property '#{if_cond}' not set.", Project::MSG_VERBOSE) else project.log(self, "Skipped because property '#{unless_cond}' set.", Project::MSG_VERBOSE) end end def defined_tasks define_target.tasks end private def extract_options(options) hash = Hash === options.last ? options.pop : {} hash[:name] = options[0].to_s if options[0] hash[:description] = options[1].to_s if options[1] hash end def if_condition cond = get_if return true unless cond val = project.replace_properties(cond) project.get_property(val) && val end def unless_condition cond = get_unless return true unless cond val = project.replace_properties(cond) project.get_property(val).nil? && val end def execute_target @ant.instance_eval(&@block) if @block end def define_target Target.new.tap do |t| t.name = "" begin @ant.current_target = t execute_target ensure @ant.current_target = nil end end end end class TargetWrapper def initialize(project, name) @project, @name = project, name end def execute @project.execute_target(@name) end end class MissingWrapper def initialize(project, name) @project_name = project.name || "<anonymous>" @name = name end def execute raise "Target `#{@name}' does not exist in project `#{@project_name}'" end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/element.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/element.rb
require 'java' class Ant java_import org.apache.tools.ant.IntrospectionHelper java_import org.apache.tools.ant.RuntimeConfigurable java_import org.apache.tools.ant.UnknownElement class UnknownElement attr_accessor :ant, :nesting # undef some method names that might collide with ant task/type names %w(test fail abort raise exec trap).each {|m| undef_method(m)} Object.instance_methods.grep(/java/).each {|m| undef_method(m)} def _element(name, args = {}, &block) Element.new(ant, name).call(self, args, &block) end def method_missing(name, *args, &block) ant.project.log "#{location.to_s}: #{' ' * nesting}#{task_name} -> #{name}", 5 _element(name, *args, &block) end end # This is really the metadata of the element coupled with the logic for # instantiating an instance of an element and evaluating it. My intention # is to decouple these two pieces. This has extra value since we can then # also make two types of instances for both top-level tasks and for targets # since we have some conditionals which would then be eliminated class Element attr_reader :name def initialize(ant, name, clazz = nil) @ant, @name, @clazz = ant, name, clazz end def call(parent, args={}, &code) element = create_element(parent) assign_attributes element, args define_nested_elements element if @clazz code.arity==1 ? code[element] : element.instance_eval(&code) if block_given? if parent.respond_to? :add_child # Task parent.add_child element parent.runtime_configurable_wrapper.add_child element.runtime_configurable_wrapper elsif parent.respond_to? :add_task # Target parent.add_task element else # Just run it now @ant.project.log "#{element.location.to_s}: Executing #{name}", 5 element.owning_target = Target.new.tap {|t| t.name = ""} element.maybe_configure element.execute end end private def create_element(parent) # See ProjectHelper2.ElementHandler UnknownElement.new(@name).tap do |e| if parent.respond_to?(:nesting) e.nesting = parent.nesting + 1 else e.nesting = 1 end e.ant = @ant e.project = @ant.project e.task_name = @name e.location = Ant.location_from_caller e.owning_target = @ant.current_target end end # This also subsumes configureId to only have to traverse args once def assign_attributes(instance, args) wrapper = RuntimeConfigurable.new instance, instance.task_name args.each do |key, value| wrapper.set_attribute key, @ant.project.replace_properties(to_string(value)) end end def define_nested_elements(instance) meta_class = class << instance; self; end @helper = IntrospectionHelper.get_helper(@ant.project, @clazz) @helper.get_nested_element_map.each do |element_name, clazz| element = Element.new(@ant, element_name, clazz) meta_class.send(:define_method, Ant.safe_method_name(element_name)) do |*args, &block| instance.ant.project.log "#{instance.location.to_s}: #{' ' * instance.nesting}#{instance.task_name} . #{element_name}", 5 element.call(instance, *args, &block) end end end def to_string(value) if String === value value elsif value.respond_to?(:to_str) value.to_str else value.to_s end end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/ant.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/ant.rb
require 'java' require 'ant/element' require 'ant/target' class Ant java_import org.apache.tools.ant.DefaultLogger java_import org.apache.tools.ant.Location java_import org.apache.tools.ant.Project java_import org.apache.tools.ant.ProjectHelper attr_reader :project, :log, :location attr_accessor :current_target def initialize(options={}, &block) @options = options @location = Ant.location_from_caller @project = create_project options @current_target = nil generate_methods @project.data_type_definitions generate_methods @project.task_definitions process_arguments unless options[:run] == false || Ant.run || @location.file_name != $0 define_tasks(&block) end def properties @project.properties end def define_tasks(&code) code.arity == 1 ? code[self] : instance_eval(&code) if code end # Add a target (two forms) # 1. Execute a block as a target: add_target "foo-target" { echo :message => "I am cool" } # 2. Execute a rake task as a target: add_target Rake.application["default"] def add_target(*options, &block) target = options.first.respond_to?(:name) ? RakeTarget.new(self, options.first) : BlockTarget.new(self, *options, &block) @project.add_target target end alias target add_target def [](name) if @project.targets.containsKey(name.to_s) TargetWrapper.new(@project, name) else MissingWrapper.new(@project, name) end end def execute_target(name) self[name].execute end def execute_default @project.execute_target(@project.default_target) end def project_help max_width = @project.targets.keys.max {|a,b| a.length <=> b.length}.length @project.targets.values.select {|t| t.description }.sort{|a,b| a.name <=> b.name }.map {|t| "%-#{max_width}s - %s" % [t.name, t.description] }.join("\n") end def ant(*args) raise "ant is known to be broken and is unsupported in the ant library" end def antcall(*args) raise "antcall is known to be broken and is unsupported in the ant library" end def _element(name, args = {}, &block) Element.new(self, name).call(@current_target, args, &block) end def method_missing(name, *args, &block) project.log "invoking method_missing: #{name} on Ant instance", 5 _element(name, *args, &block) end def run(*targets) if targets.length > 0 targets.each {|t| execute_target(t) } else execute_default end end def process_arguments(argv = ARGV, run_at_exit = true) properties = [] targets = [] argv.each {|a| a =~ /^-D/ ? properties << a[2..-1] : targets << a } properties.each do |p| key, value = p.split('=', 2) value ||= "true" @project.set_user_property(key, value) end at_exit do begin run(*targets) if (!targets.empty? || @project.default_target) && !Ant.run rescue => e warn e.message puts e.backtrace.join("\n") if $DEBUG exit 1 end end if run_at_exit end private def create_project(options) # If we are calling into a rakefile from ant then we already have a project to use return $project if defined?($project) && $project options[:basedir] ||= '.' output_level = options.delete(:output_level) || 2 Project.new.tap do |p| p.init p.add_build_listener(DefaultLogger.new.tap do |log| log.output_print_stream = Java::java.lang.System.out log.error_print_stream = Java::java.lang.System.err log.emacs_mode = true log.message_output_level = output_level @log = log end) helper = ProjectHelper.getProjectHelper helper.import_stack.add(Java::java.io.File.new(@location.file_name)) p.addReference(ProjectHelper::PROJECTHELPER_REFERENCE, helper) options.each_pair {|k,v| p.send("set_#{k}", v) if p.respond_to?("set_#{k}") } end end def generate_methods(collection) existing_methods = Ant.instance_methods(false) collection.each do |name, clazz| element = Element.new(self, name, clazz) method_name = Ant.safe_method_name(name) (class << self; self; end).send(:define_method, method_name) do |*a, &b| element.call(@current_target, *a, &b) end unless existing_methods.include?(method_name) end end class << self attr_accessor :run def safe_method_name(element_name) if element_name =~ /\A(and|or|not|do|end|if|else)\z/m "_#{element_name}" else element_name end end def location_from_caller file, line = caller.detect{|el| el !~ /^#{File.dirname(__FILE__)}/}.split(/:(\d+):?/) Location.new(file, line.to_i, 1) end def ant(options={}, &code) if options.respond_to? :to_hash @ant ||= Ant.new options.to_hash @ant.define_tasks(&code) @ant else options = options.join(" ") if options.respond_to? :to_ary sh "ant #{options.to_s}" # FIXME: Make this more secure if using array form end rescue => e warn e.message warn e.backtrace.join("\n") end end end # This method has three different uses: # # 1. Call an ant task or type directly: # task :compile do # Rake task # ant.javac { } # Look I am calling an ant task # end # 2. Provide a block to provide an impromptu ant session # ant do # javac {} # Everything executes as if in an executing ant target # end # 3. Provide arguments to execute ant as it's own build # ant '-f my_build.xml my_target1' # # Additionally this may be passed in array format if you are worried about injection: # # args = ['-f', 'my_build.xml', 'my_target1'] # ant args # def ant(*args, &block) Ant.ant(*args, &block) end def ant_import(filename = 'build.xml') ant = Ant.ant abs_name = File.expand_path(filename) Ant::ProjectHelper.configure_project ant.project, java.io.File.new(abs_name) ant.project.targets.each do |target_name, target| name = Rake.application.lookup(target_name) ? "ant_" + target_name : target_name task(name) { target.project.execute_target(target_name) } end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/project_converter.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/project_converter.rb
require 'rexml/parsers/sax2parser' require 'rexml/sax2listener' require 'ant' class Ant class ProjectConverter include REXML::SAX2Listener def initialize @output = $stdout @depth = 0 @seen = ['<DOC>', 0] end def start_element(uri, localname, qname, attributes) emit_do(localname) case localname when "project" @output.puts "require 'ant'" emit "ant", attributes when "description" print_with_indent "project.description = " else emit localname, attributes end @depth += 1 end def end_element(uri, localname, qname) @depth -= 1 emit_end(localname) end def characters(text) @output.print value_inspect(text.strip) if text.strip.length > 0 end def emit_do(tag) @output.puts " do" if @seen.last[1] != @depth @seen << [tag, @depth] end def emit_end(tag) level = @seen.last if level[0] == tag && level[1] == @depth @output.puts else print_with_indent "end\n" @seen << ["/#{tag}", @depth] end end def emit(code, attributes = nil) print_with_indent safe_method_name(code, attributes) if attributes first = true attributes.each do |k,v| @output.print "," unless first @output.print " #{symbol_or_string(k)} => #{value_inspect(v)}" first = false end end end def print_with_indent(str) @output.print " " * @depth @output.print str end ID = /\A[a-zA-Z_][a-zA-Z0-9_]*\z/ def symbol_or_string(s) if s =~ ID ":#{s}" else s.inspect end end def value_inspect(s) s.inspect.gsub("\\n", "\n") end def safe_method_name(s, attributes) s = Ant.safe_method_name(s) if s =~ ID s else "_element #{s.inspect}#{attributes.nil? || attributes.empty? ? '' : ','}" end end def self.convert(file = "build.xml") source = File.exists?(file) ? File.new(file) : $stdin parser = REXML::Parsers::SAX2Parser.new source parser.listen self.new parser.parse end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/rake.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/rake.rb
def ant_task(*args, &block) task(*args) do |t| ant.define_tasks(&block) end end class FileList def to_str join(',') end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/tasks/raketasks.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ant/tasks/raketasks.rb
require 'rubygems' require 'rake' require 'ant' class RakeWrapper def load_tasks(*args) # FIXME: Use our arguments (this sucks...let's submit a patch for Rake ARGV.clear ARGV.concat args Rake.application.tap do |application| application.init application.load_rakefile end end def execute(*args) load_tasks(*args).top_level end def invoke_task(task) Rake.application[task].invoke end def import(*args) ant = Ant.new load_tasks(*args).tasks.each { |rake_task| ant.add_target rake_task } end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport.rb
###### BEGIN LICENSE BLOCK ###### # Version: CPL 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) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se> # Copyright (C) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de> # Copyright (C) 2004-2006 Thomas E Enebo <enebo@acm.org> # Copyright (C) 2004 David Corbin <dcorbin@users.sourceforge.net> # Copyright (C) 2006 Michael Studman <me@michaelstudman.com> # Copyright (C) 2006 Kresten Krab Thorup <krab@gnu.org> # Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com> # Copyright (C) 2007 Miguel Covarrubias <mlcovarrubias@gmail.com> # # 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 CPL, 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 CPL, the GPL or the LGPL. ###### END LICENSE BLOCK ###### require 'builtin/javasupport/java' require 'builtin/javasupport/proxy/array' require 'builtin/javasupport/utilities/base' require 'builtin/javasupport/utilities/array' require 'builtin/javasupport/core_ext' require 'builtin/java/java.lang' require 'builtin/java/java.util' require 'builtin/java/java.util.regex' require 'builtin/java/java.io' require 'builtin/java/org.jruby.ast'
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/rdoc_jruby.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/rdoc_jruby.rb
require 'java' require 'rdoc/rdoc' module JRuby class RDoc class AnnotationParser attr_accessor :progress # prepare to parse a Java class with annotations def initialize(top_level, clazz, options, stats) @options = options @top_level = top_level @classes = Hash.new @progress = $stderr unless options.quiet @clazz = clazz @stats = stats end def scan extract_class_information(@clazz) @top_level end ####### private ####### def progress(char) unless @options.quiet @progress.print(char) @progress.flush end end def warn(msg) $stderr.puts $stderr.puts msg $stderr.flush end JRubyMethodAnnotation = org.jruby.anno.JRubyMethod.java_class JRubyClassAnnotation = org.jruby.anno.JRubyClass.java_class JRubyModuleAnnotation = org.jruby.anno.JRubyModule.java_class def handle_class_module(clazz, class_mod, annotation, type_annotation, enclosure) type_annotation.name.to_a.each do |name| progress(class_mod[0, 1]) parent = class_mod == 'class' ? type_annotation.parent : nil if class_mod == "class" cm = enclosure.add_class(::RDoc::NormalClass, name, parent) @stats.num_classes += 1 else cm = enclosure.add_module(::RDoc::NormalModule, name) @stats.num_modules += 1 end cm.record_location(enclosure.toplevel) type_annotation.include.to_a.each do |inc| cm.add_include(::RDoc::Include.new(inc, "")) end find_class_comment(clazz, annotation, cm) handle_methods(clazz, cm) end end def handle_methods(clazz, enclosure) clazz.java_class.declared_class_methods.each do |method| if method.annotation_present?(JRubyMethodAnnotation) handle_method(clazz, method, enclosure) end end clazz.java_class.declared_instance_methods.each do |method| if method.annotation_present?(JRubyMethodAnnotation) handle_method(clazz, method, enclosure) end end end def handle_method(clazz, method, enclosure) progress(".") @stats.num_methods += 1 anno = method.annotation(JRubyMethodAnnotation) meth_name = anno.name.to_a.first || method.name type = anno.meta ? "singleton_method" : "instance_method" if meth_name == "initialize" meth_name = "new" type = "singleton_method" end meth_obj = ::RDoc::AnyMethod.new("", meth_name) meth_obj.singleton = type == "singleton_method" p_count = (anno.optional == 0 && !anno.rest) ? anno.required : -1 if p_count < 0 meth_obj.params = "(...)" elsif p_count == 0 meth_obj.params = "()" else meth_obj.params = "(" + (1..p_count).map{|i| "p#{i}"}.join(", ") + ")" end find_method_comment(nil, #method.annotation(RDocAnnotation), meth_obj) enclosure.add_method(meth_obj) meth_obj.visibility = case anno.visibility when org.jruby.runtime.Visibility::PUBLIC: :public when org.jruby.runtime.Visibility::PROTECTED: :protected when org.jruby.runtime.Visibility::PRIVATE: :private when org.jruby.runtime.Visibility::MODULE_FUNCTION: :public end if anno.name.to_a.length > 1 anno.name.to_a[1..-1].each do |al| new_meth = ::RDoc::AnyMethod.new("", al) new_meth.is_alias_for = meth_obj new_meth.singleton = meth_obj.singleton new_meth.params = meth_obj.params new_meth.comment = "Alias for \##{meth_obj.name}" meth_obj.add_alias(new_meth) enclosure.add_method(new_meth) new_meth.visibility = meth_obj.visibility end end end def find_class_comment(clazz, doc_annotation, class_meth) if doc_annotation class_meth.comment = doc_annotation.doc end end def find_method_comment(doc_annotation, meth) if doc_annotation call_seq = (doc_annotation.call_seq || []).to_a.join("\n") if call_seq != "" call_seq << "\n\n" end meth.comment = call_seq + doc_annotation.doc end end def extract_class_information(clazz) class_anno = clazz.java_class.annotation(JRubyClassAnnotation) module_anno = clazz.java_class.annotation(JRubyModuleAnnotation) # doc_anno = clazz.java_class.annotation(RDocAnnotation) doc_anno = nil if (class_anno || module_anno) $stderr.printf("%70s: ", clazz.java_class.to_s) unless @options.quiet class_mod = if class_anno "class" else "module" end handle_class_module(clazz, class_mod, doc_anno, class_anno || module_anno, @top_level) if class_anno && module_anno handle_class_module(clazz, "module", doc_anno, module_anno, @top_level) end $stderr.puts unless @options.quiet end end end INTERNAL_PACKAGES = %w(org.jruby.yaml org.jruby.util org.jruby.runtime org.jruby.ast org.jruby.internal org.jruby.lexer org.jruby.evaluator org.jruby.compiler org.jruby.parser org.jruby.exceptions org.jruby.demo org.jruby.environment org.jruby.JRubyApplet) INTERNAL_PACKAGES_RE = INTERNAL_PACKAGES.map{ |ip| /^#{ip}/ } INTERNAL_PACKAGE_RE = Regexp::union(*INTERNAL_PACKAGES_RE) class << self def find_classes_from_jar(jar, package) file = java.util.jar.JarFile.new(jar.toString[5..-1], false) beginning = %r[^(#{package.empty? ? '' : (package.join("/") + "/")}.*)\.class$] result = [] file.entries.each do |e| if /Invoker\$/ !~ e.to_s && beginning =~ e.to_s class_name = $1.gsub('/', '.') if INTERNAL_PACKAGE_RE !~ class_name result << class_name end end end result end def find_classes_from_directory(dir, package) raise "not implemented yet" end def find_classes_from_location(location, package) if /\.jar$/ =~ location.to_s find_classes_from_jar(location, package) else find_classes_from_directory(location, package) end end # Executes a block inside of a context where the named method on the object in question will just return nil # without actually doing anything. Useful to stub out things temporarily def returning_nil(object, method_name) singleton_object = (class << object; self; end) singleton_object.send :alias_method, :"#{method_name}_with_real_functionality", method_name singleton_object.send :define_method, method_name do |*args| nil end begin result = yield ensure singleton_object.send(:alias_method, method_name, :"#{method_name}_with_real_functionality") end result end # Returns an array of TopLevel def extract_rdoc_information_from_classes(classes, options, stats) result = [] classes.each do |clzz| tp = returning_nil(File, :stat) { ::RDoc::TopLevel.new(clzz.java_class.to_s) } result << AnnotationParser.new(tp, clzz, options, stats).scan stats.num_files += 1 end result end def install_doc(package = []) r = ::RDoc::RDoc.new # So parse_files should actually return an array of TopLevel objects (class << r; self; end).send(:define_method, :parse_files) do |options| location = org.jruby.Ruby.java_class.protection_domain.code_source.location class_names = JRuby::RDoc::find_classes_from_location(location, package) classes = class_names.map {|c| JavaUtilities.get_proxy_class(c) } JRuby::RDoc::extract_rdoc_information_from_classes(classes, options, @stats) end r.document(%w(--all --ri-system)) end end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/core_ext/symbol.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/core_ext/symbol.rb
class Symbol def to_proc proc { |*args| args.shift.__send__(self, *args) } end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext.rb
require 'builtin/javasupport/core_ext/module' require 'builtin/javasupport/core_ext/object' require 'builtin/javasupport/core_ext/kernel'
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/java.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/java.rb
module Java class << self def const_missing(sym) result = JavaUtilities.get_top_level_proxy_or_package(sym) if const_defined? sym result else const_set(sym, result) end end def method_missing(sym, *args) raise ArgumentError, "Java package `java' does not have a method `#{sym}'" unless args.empty? JavaUtilities.get_top_level_proxy_or_package sym end end end module JavaPackageModuleTemplate # don't undefine important methods @@keep = /^(__|<|>|=)|^(class|const_missing|inspect|method_missing|to_s)$|(\?|!|=)$/ # don't alias "special" methods @@no_alias = /^(eval|module_eval|class_eval|instance_eval|instance_exec|binding|local_variables)$/ class << self # blank-slate logic relocated from org.jruby.javasupport.Java instance_methods.each do |meth| unless meth.to_s =~ @@keep # keep aliased methods for those we'll undef, for use by IRB and other utilities unless meth.to_s =~ @@no_alias || method_defined?(method_alias = :"__#{meth}__") alias_method method_alias, meth end undef_method meth end end def __block__(name) if (name_str = name.to_s) !~ @@keep (class<<self;self;end).__send__(:undef_method, name) rescue nil end end def const_missing(const) JavaUtilities.get_proxy_class(@package_name + const.to_s) end private :const_missing def method_missing(sym, *args) raise ArgumentError, "Java package `#{package_name}' does not have a method `#{sym}'" unless args.empty? JavaUtilities.get_proxy_or_package_under_package self, sym end private :method_missing def package_name # strip off trailing . @package_name[0..-2] end end end # pull in the default package JavaUtilities.get_package_module("Default")
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/proxy/array.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/proxy/array.rb
# This class enables the syntax arr = MyClass[n][n]...[n].new class ArrayJavaProxyCreator def initialize(java_class,*args) @java_class = java_class @dimensions = [] extract_dimensions(args) end def [](*args) extract_dimensions(args) self end private def extract_dimensions(args) unless args.length > 0 raise ArgumentError,"empty array dimensions specified" end args.each do |arg| unless arg.kind_of?(Fixnum) raise ArgumentError,"array dimension length must be Fixnum" end @dimensions << arg end end public def new() array = @java_class.new_array(@dimensions) array_class = @java_class.array_class (@dimensions.length-1).times do array_class = array_class.array_class end proxy_class = JavaUtilities.get_proxy_class(array_class) proxy_class.new(array) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/kernel.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/kernel.rb
# Prevent methods added to Kernel from being added to the # blank-slate JavaPackageModuleTemplate module Kernel class << self alias_method :java_package_method_added, :method_added def method_added(name) result = java_package_method_added(name) JavaPackageModuleTemplate.__block__(name) if self == Kernel result end private :method_added end end # Create convenience methods for top-level java packages so we do not need to prefix # with 'Java::'. We undef these methods within Package in case we run into 'com.foo.com'. [:java, :javax, :com, :org].each do |meth| Kernel.module_eval <<-EOM def #{meth} JavaUtilities.get_package_module_dot_format('#{meth}') end EOM end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/object.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/object.rb
class Object # Prevent methods added to Object from being added to the # blank-slate JavaPackageModuleTemplate class << self alias_method :java_package_method_added, :method_added def method_added(name) # If someone added a new method_added since we aliased original, then # lets defer to that. Otherwise run one we aliased. if self.class.superclass.instance_method(:method_added) != method(:java_package_method_added) result = super else result = java_package_method_added(name) end JavaPackageModuleTemplate.__block__(name) if self == Object result end private :method_added end # include the class specified by +include_class+ into the current namespace, # using either its base name or by using a name returned from an optional block, # passing all specified classes in turn and providing the block package name # and base class name. def include_class(include_class, &block) java_import(include_class, &block) end # TODO: this can go away now, but people may be using it def java_kind_of?(other) return true if self.kind_of?(other) return false unless self.respond_to?(:java_class) && other.respond_to?(:java_class) && other.kind_of?(Module) && !self.kind_of?(Module) return other.java_class.assignable_from?(self.java_class) end def java_import(import_class) case import_class when Array import_class.each do |arg| java_import(arg) end return when String # pull in the class import_class = JavaUtilities.get_proxy_class(import_class); when Module if import_class.respond_to? "java_class" # ok, it's a proxy else raise ArgumentError.new "Not a Java class or interface: #{import_class}" end else raise ArgumentError.new "Invalid java class/interface: #{import_class}" end full_name = import_class.java_class.name package = import_class.java_class.package # package can be nil if it's default or no package was defined by the classloader if package package_name = package.name else dot_index = full_name.rindex('.') if dot_index package_name = full_name[0...full_name.rindex('.')] else # class in default package package_name = "" end end if package_name.length > 0 class_name = full_name[(package_name.length + 1)..-1] else class_name = full_name end if block_given? constant = yield(package_name, class_name) else constant = class_name # Inner classes are separated with $ if constant =~ /\$/ constant = constant.split(/\$/).last end if constant[0,1].upcase != constant[0,1] raise ArgumentError.new "cannot import class `" + class_name + "' as `" + constant + "'" end end # JRUBY-3453: Make import not complain if Java already has already imported the specific Java class # If no constant is defined, or the constant is not already set to the include_class, assign it eval_str = "if !defined?(#{constant}) || #{constant} != import_class; #{constant} = import_class; end" if (Module === self) return class_eval(eval_str, __FILE__, __LINE__) else return eval(eval_str, binding, __FILE__, __LINE__) end end private :java_import def handle_different_imports(*args, &block) if args.first.respond_to?(:java_class) java_import(*args, &block) else other_import(*args, &block) end end if respond_to?(:import) alias :other_import :import alias :import :handle_different_imports else alias :import :java_import class << self alias_method :method_added_without_import_checking, :method_added def method_added(name) if name.to_sym == :import && defined?(@adding) && !@adding @adding = true alias_method :other_import, :import alias_method :import, :handle_different_imports @adding = false end method_added_without_import_checking(name) end end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/module.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/module.rb
# Extensions to the standard Module package. class Module private ## # Includes a Java package into this class/module. The Java classes in the # package will become available in this class/module, unless a constant # with the same name as a Java class is already defined. # def include_package(package_name) if defined? @included_packages @included_packages << package_name return end @included_packages = [package_name] @java_aliases ||= {} def self.const_missing(constant) real_name = @java_aliases[constant] || constant java_class = nil last_error = nil @included_packages.each do |package| begin java_class = JavaUtilities.get_java_class(package + '.' + real_name.to_s) rescue NameError # we only rescue NameError, since other errors should bubble out last_error = $! end break if java_class end if java_class return JavaUtilities.create_proxy_class(constant, java_class, self) else # try to chain to super's const_missing begin return super rescue NameError # super didn't find anything either, raise our Java error raise NameError.new("#{constant} not found in packages #{@included_packages.join(', ')}; last error: #{last_error.message}") end end end end # Imports the package specified by +package_name+, first by trying to scan JAR resources # for the file in question, and failing that by adding a const_missing hook # to try that package when constants are missing. def import(package_name, &b) if package_name.respond_to?(:java_class) || (String === package_name && package_name.split(/\./).last =~ /^[A-Z]/) return super(package_name, &b) end package_name = package_name.package_name if package_name.respond_to?(:package_name) return include_package(package_name, &b) end def java_alias(new_id, old_id) @java_aliases[new_id] = old_id end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/utilities/array.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/utilities/array.rb
module JavaArrayUtilities class << self def java_to_ruby(java_array) unless java_array.kind_of?(ArrayJavaProxy) raise ArgumentError,"not a Java array: #{java_array}" end length = java_array.length ruby_array = Array.new(length) if length > 0 if java_array[0].kind_of?ArrayJavaProxy length.times do |i| ruby_array[i] = java_to_ruby(java_array[i]) end else length.times do |i| ruby_array[i] = java_array[i] end end end ruby_array end end #self end #JavaArrayUtilities
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/utilities/base.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/utilities/base.rb
module JavaUtilities def JavaUtilities.extend_proxy(java_class_name, &block) java_class = Java::JavaClass.for_name(java_class_name) java_class.extend_proxy JavaInterfaceExtender.new(java_class_name, &block) end def JavaUtilities.print_class(java_type, indent="") while (!java_type.nil? && java_type.name != "java.lang.Class") puts "#{indent}Name: #{java_type.name}, access: #{ JavaUtilities.access(java_type) } Interfaces: " java_type.interfaces.each { |i| print_class(i, " #{indent}") } puts "#{indent}SuperClass: " print_class(java_type.superclass, " #{indent}") java_type = java_type.superclass end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/org.jruby.ast.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/org.jruby.ast.rb
class org::jruby::ast::Node POS = org.jruby.lexer.yacc.SimpleSourcePosition.new("-",-1) def [](ix) self.child_nodes[ix] end def first self.child_nodes[0] if self.child_nodes.size > 0 end def last self.child_nodes[self.child_nodes.size-1] if self.child_nodes.size > 0 end def +(other) blk = org.jruby.ast.BlockNode.new POS blk.add self blk.add other blk end attr_accessor :locals def run unless defined?(JRuby) require 'jruby' end root = self unless org.jruby.ast.RootNode === root pos = POS scope1 = org.jruby.parser.LocalStaticScope.new(nil) scope1.setVariables(java.lang.String[self.locals || 40].new) scope = org.jruby.runtime.DynamicScope.newDynamicScope(scope1, nil) root = org.jruby.ast.RootNode.new(pos, scope, self) end JRuby::runtime.runInterpreter root end def inspect(indent = 0) s = ' '*indent + self.class.name.split('::').last if self.respond_to?(:name) s << " |#{self.name}|" end if self.respond_to?(:value) s << " ==#{self.value.inspect}" end if self.respond_to?(:index) s << " &#{self.index.inspect}" end if self.respond_to?(:depth) s << " >#{self.depth.inspect}" end [:receiver_node, :args_node, :var_node, :head_node, :value_node, :iter_node, :body_node, :next_node, :condition, :then_body, :else_body].each do |mm| if self.respond_to?(mm) begin s << "\n#{self.send(mm).inspect(indent+2)}" if self.send(mm) rescue s << "\n#{' '*(indent+2)}#{self.send(mm).inspect}" if self.send(mm) end end end if org::jruby::ast::ListNode === self (0...self.size).each do |n| begin s << "\n#{self.get(n).inspect(indent+2)}" if self.get(n) rescue s << "\n#{' '*(indent+2)}#{self.get(n).inspect}" if self.get(n) end end end s end def to_yaml_node(out) content = [] content << {'name' => self.name} if self.respond_to?(:name) content << {'value' => self.value} if self.respond_to?(:value) [:receiver_node, :args_node, :value_node, :iter_node, :body_node, :next_node].each do |mm| if self.respond_to?(mm) content << self.send(mm) if self.send(mm) end end if org::jruby::ast::ListNode === self (0...self.size).each do |n| content << self.get(n) if self.get(n) end end out.map({ }.taguri, { self.class.name.split('::').last => content }, nil) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/java.util.regex.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/java.util.regex.rb
class java::util::regex::Pattern def =~(str) m = self.matcher(str) m.find ? m.start : nil end def ===(str) self.matcher(str).find end def match(str) m = self.matcher(str) m.str = str m.find ? m : nil end end class java::util::regex::Matcher attr_accessor :str def captures g = self.group_count capt = [] count.times do |i| capt << self.group(i+1) end capt end def [](*args) self.to_a[*args] end def begin(ix) self.start(ix) end def end(ix) self.end(ix) end def to_a arr = [] self.group_count.times do |gg| if self.start(gg) == -1 arr << nil else arr << self.group(gg) end end arr end def size self.group_count end alias length size def values_at(*args) self.to_a.values_at(*args) end def select yield self.to_a end def offset(ix) [self.start(ix), self.end(ix)] end def pre_match self.str[0..(self.start(0))] end def post_match self.str[(self.end(0))..-1] end def string self.group(0) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/java.io.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/java.io.rb
require 'jruby' class java::io::InputStream def to_io JRuby.dereference(org.jruby.RubyIO.new(JRuby.runtime, self)) end end class java::io::OutputStream def to_io JRuby.dereference(org.jruby.RubyIO.new(JRuby.runtime, self)) end end module java::nio::channels::Channel def to_io JRuby.dereference(org.jruby.RubyIO.new(JRuby.runtime, self)) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/java.util.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/java.util.rb
# TODO java.util.Comparator support? module java::util::Map include Enumerable def each(&block) entrySet.each { |pair| block.call([pair.key, pair.value]) } end def [](key) get(key) end def []=(key,val) put(key,val) val end end module java::util::Collection include Enumerable def each(&block) iter = iterator while iter.hasNext block.call(iter.next) end end def <<(a); add(a); self; end def +(oth) nw = self.dup nw.addAll(oth) nw end def -(oth) nw = self.dup nw.removeAll(oth) nw end def length self.size end def join(*args) self.to_a.join(*args) end def to_a # JRUBY-3910: conversion is faster by going directly to java array # first toArray.to_a end end module java::util::Enumeration include Enumerable def each while (has_more_elements) yield next_element end end end module java::util::Iterator include Enumerable def each while (has_next) yield self.next end end end module java::util::List def [](ix1, ix2 = nil) if (ix2) sub_list(ix1, ix1 + ix2) elsif (ix1.is_a?(Range)) sub_list(ix1.first, ix1.exclude_end? ? ix1.last : ix1.last + 1) elsif ix1 < size get(ix1) else nil end end def []=(ix,val) if (ix.is_a?(Range)) ix.each { |i| remove(i) } add_all(ix.first, val) elsif size < ix ((ix-size)+1).times { self << nil } end set(ix,val) val end def sort() comparator = Class.new do include java::util::Comparator if block_given? define_method :compare do |o1, o2| yield o1, o2 end else def compare(o1, o2) o1 <=> o2 end end end.new list = java::util::ArrayList.new list.addAll(self) java::util::Collections.sort(list, comparator) list end def sort!(&block) comparator = java::util::Comparator.impl do |name, o1, o2| if block block.call(o1, o2) else o1 <=> o2 end end java::util::Collections.sort(self, comparator) self end def _wrap_yield(*args) p = yield(*args) p p end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/java.lang.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/java/java.lang.rb
module java::lang::Runnable def to_proc proc { self.run } end end module java::lang::Iterable include Enumerable def each iter = iterator yield(iter.next) while iter.hasNext end def each_with_index index = 0 iter = iterator while iter.hasNext yield(iter.next, index) index += 1 end end end module java::lang::Comparable include Comparable def <=>(a) return nil if a.nil? compareTo(a) end end class java::lang::Throwable def backtrace @backtrace ||= stack_trace.map(&:to_s) end def set_backtrace(trace) unless trace.kind_of?(Array) && trace.all? {|x| x.kind_of?(String)} raise TypeError.new("backtrace must be an Array of String") end @backtrace = trace end def to_s message end def to_str to_s end def inspect to_string end class << self alias :old_eqq :=== def ===(rhs) if (NativeException == rhs.class) && (java_class.assignable_from?(rhs.cause.java_class)) true else old_eqq(rhs) end end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/compiler.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/compiler.rb
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 BytecodeCompiler = org.jruby.compiler.impl.StandardASMCompiler ASTCompiler = org.jruby.compiler.ASTCompiler 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 } 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 root of the compiled package and filename") 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("--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.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 ) 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]) end inspector = org.jruby.compiler.ASTInspector.new source = file.read node = runtime.parse_file(BAIS.new(source.to_java_bytes), filename, nil) if options[:java] || options[:javac] 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}" files << java_src File.open(java_src, 'w') do |f| f.write(cls.to_s) end end else puts "Compiling #{filename} to class #{pathname}" inspector.inspect(node) asmCompiler = BytecodeCompiler.new(pathname.gsub(".", "/"), filename) compiler = ASTCompiler.new compiler.compile_root(node, asmCompiler, inspector) target_file = JavaFile.new(options[:target]) asmCompiler.write_class(target_file) if options[:handles] puts "Generating direct handles for #{filename}" asmCompiler.write_invokers(target_file) 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)}'..." Dir.glob(filename + "/**/*.rb").each { |filename| errors += compile_proc[filename] } else errors += compile_proc[filename] end end if options[:javac] javac_string = JavaGenerator.generate_javac(files, options) puts javac_string system javac_string end errors end module_function :compile_files_with_options end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/jrubyc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/jrubyc.rb
require 'jruby/compiler' # For compatibility with libraries that used it directly in 1.4- JRubyCompiler = JRuby::Compiler
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/vm.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/vm.rb
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 import java.util.concurrent.LinkedBlockingQueue import java.util.HashMap class ChildVM < VM JThread = java.lang.Thread Runnable = java.lang.Runnable import org.jruby.RubyInstanceConfig import org.jruby.Ruby import org.jruby.RubyIO import java.nio.channels.Pipe import java.nio.channels.Channels 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 # Create the main thread for the child VM @main = JThread.new Runnable.impl { @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 } @main.start 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/gem_only.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/gem_only.rb
module JRuby module OpenSSL GEM_ONLY = true end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/stub.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/stub.rb
module JRuby module OpenSSL GEM_ONLY = false unless defined?(GEM_ONLY) end end if JRuby::OpenSSL::GEM_ONLY require 'jruby/openssl/gem' else require "jruby/openssl/builtin" end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/builtin.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/builtin.rb
# this will load the gem and library only if it's available require 'jruby/openssl/gem' unless defined?(OpenSSL) module OpenSSL VERSION = "1.0.0" OPENSSL_VERSION = "OpenSSL 0.9.8b 04 May 2006 (JRuby fake)" OPENSSL_DUMMY = true class OpenSSLError < StandardError; end # These require the gem, so we present an error if they're accessed %w[ ASN1 BN Cipher Config Netscape PKCS7 PKey Random SSL X509 ].each {|c| autoload c, "jruby/openssl/autoloads/#{c.downcase}"} def self.determine_version require 'java' java.security.MessageDigest.getInstance("SHA224", PROVIDER); 9469999 rescue Exception 9469952 end OPENSSL_VERSION_NUMBER = determine_version require 'java' class HMACError < OpenSSLError; end class DigestError < OpenSSLError; end class Digest class << self def digest(name, data) self.new(name, data).digest end def hexdigest(name, data) self.new(name, data).hexdigest end end attr_reader :algorithm, :name, :data def initialize(name, data = nil) @name = name @data = "" create_digest update(data) if data end def initialize_copy(dig) initialize(dig.name, dig.data) end def update(d) @data << d @md.update(d.to_java_bytes) self end alias_method :<<, :update def digest @md.reset String.from_java_bytes @md.digest(@data.to_java_bytes) end def hexdigest digest.unpack("H*")[0] end alias_method :to_s, :hexdigest alias_method :inspect, :hexdigest def ==(oth) return false unless oth.kind_of? OpenSSL::Digest self.algorithm == oth.algorithm && self.digest == oth.digest end def reset @md.reset @data = "" end def size @md.getDigestLength end private def create_digest @algorithm = case @name when "DSS" "SHA" when "DSS1" "SHA1" else @name end @md = java.security.MessageDigest.getInstance(@algorithm) end begin old_verbose, $VERBOSE = $VERBOSE, nil # silence warnings # from openssl/digest.rb -- define the concrete digest classes alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1) if ::OpenSSL::OPENSSL_VERSION_NUMBER > 0x00908000 alg += %w(SHA224 SHA256 SHA384 SHA512) end alg.each{|name| klass = Class.new(Digest){ define_method(:initialize){|*data| if data.length > 1 raise ArgumentError, "wrong number of arguments (#{data.length} for 1)" end super(name, data.first) } } singleton = (class << klass; self; end) singleton.class_eval{ define_method(:digest){|data| Digest.digest(name, data) } define_method(:hexdigest){|data| Digest.hexdigest(name, data) } } const_set(name, klass) } ensure $VERBOSE = old_verbose end class Digest < Digest def initialize(*args) # add warning super(*args) end end end class HMAC class << self def digest(dig, key, data) self.new(key, dig).update(data).digest end def hexdigest(dig, key, data) self.new(key, dig).update(data).hexdigest end end attr_reader :name, :key, :data def initialize(key, dig) @name = "HMAC" + dig.algorithm @key = key @data = "" create_mac end def initialize_copy(hmac) @name = hmac.name @key = hmac.key @data = hmac.data create_mac end def update(d) @data << d self end alias_method :<<, :update def digest @mac.reset String.from_java_bytes @mac.doFinal(@data.to_java_bytes) end def hexdigest digest.unpack("H*")[0] end alias_method :inspect, :hexdigest alias_method :to_s, :hexdigest private def create_mac @mac = javax.crypto.Mac.getInstance(@name) @mac.init(javax.crypto.spec.SecretKeySpec.new(@key.to_java_bytes, @name)) end end warn %{JRuby limited openssl loaded. http://jruby.org/openssl gem install jruby-openssl for full support.} end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/gem.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/gem.rb
require 'rubygems' # try to activate jruby-openssl gem, and only require from the gem if it's there begin gem 'jruby-openssl' require 'openssl.rb' rescue LoadError end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/ssl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/ssl.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::SSL requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/x509.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/x509.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::X509 requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/netscape.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/netscape.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::Netscape requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/random.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/random.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::Random requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/pkey.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/pkey.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::PKey requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/config.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/config.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::Config requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/pkcs7.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/pkcs7.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::PKCS7 requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/asn1.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/asn1.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::ASN1 requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/bn.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/bn.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::BN requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/cipher.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/cipher.rb
require 'rubygems' # try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present begin gem 'jruby-openssl' require 'openssl.rb' rescue Gem::LoadError => e raise LoadError.new("OpenSSL::Cipher requires the jruby-openssl gem") end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/compiler/extending.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/compiler/extending.rb
module JRuby::Compiler EXTENSION_STRING = <<JAVA public IRubyObject callSuper(ThreadContext context, IRubyObject[] args, Block block) { return org.jruby.BasicObjectStub.callSuper(this, context, args, block); } public IRubyObject callMethod(ThreadContext context, String name) { return org.jruby.BasicObjectStub..callMethod(this, context, name); } public IRubyObject callMethod(ThreadContext context, String name, IRubyObject arg) { return org.jruby.BasicObjectStub.callMethod(this, context, name, arg); } public IRubyObject callMethod(ThreadContext context, String name, IRubyObject[] args) { return org.jruby.BasicObjectStub.callMethod(this, context, name, args); } public IRubyObject callMethod(ThreadContext context, String name, IRubyObject[] args, Block block) { return org.jruby.BasicObjectStub.callMethod(this, context, name, args, block); } public IRubyObject callMethod(ThreadContext context, int methodIndex, String name) { return org.jruby.BasicObjectStub.callMethod(this, context, methodIndex, name); } public IRubyObject callMethod(ThreadContext context, int methodIndex, String name, IRubyObject arg) { return org.jruby.BasicObjectStub.callMethod(this, context, methodIndex, name, arg); } public boolean isNil() { return org.jruby.BasicObjectStub.isNil(this); } public boolean isTrue() { return org.jruby.BasicObjectStub.isTrue(this); } public boolean isTaint() { return org.jruby.BasicObjectStub.isTaint(this); } public void setTaint(boolean b) { return org.jruby.BasicObjectStub.setTaint(this, b); } public IRubyObject infectBy(IRubyObject obj) { return org.jruby.BasicObjectStub.infectBy(this, obj); } public boolean isFrozen() { return org.jruby.BasicObjectStub.isFrozen(this); } public void setFrozen(boolean b) { return org.jruby.BasicObjectStub.setFrozen(this); } public boolean isUntrusted() { return org.jruby.BasicObjectStub.isUntrusted(this); } public void setUntrusted(boolean b) { return org.jruby.BasicObjectStub.setUntrusted(this); } public boolean isImmediate() { return org.jruby.BasicObjectStub.isImmediate(this); } public RubyClass getMetaClass() { return __metaclass__; } public RubyClass getSingletonClass() { return org.jruby.BasicObjectStub.getSingletonClass(this); } public RubyClass getType() { return org.jruby.BasicObjectStub.getType(this); } public boolean respondsTo(String name) { return org.jruby.BasicObjectStub.resondsTo(this, name); } public Ruby getRuntime() { return __ruby__; } public Class getJavaClass() { return getClass(); } public String asJavaString() { return org.jruby.BasicObjectStub.asJavaString(this); } public RubyString asString() { return org.jruby.BasicObjectStub.asString(this); } public RubyArray convertToArray() { return org.jruby.BasicObjectStub.convertToArray(this); } public RubyHash convertToHash() { return org.jruby.BasicObjectStub.convertToHash(this); } public RubyFloat convertToFloat() { return org.jruby.BasicObjectStub.convertToFloat(this); } public RubyInteger convertToInteger() { return org.jruby.BasicObjectStub.convertToInteger(this); } public RubyInteger convertToInteger(int convertMethodIndex, String convertMethod) { return org.jruby.BasicObjectStub.convertToInteger(this, convertMethodIndex, convertMethod); } public RubyInteger convertToInteger(String convertMethod) { return org.jruby.BasicObjectStub.convertToInteger(this, convertMethod); } public RubyString convertToString() { return org.jruby.BasicObjectStub.convertToString(this); } public IRubyObject anyToString() { return org.jruby.BasicObjectStub.anyToString(this); } public IRubyObject checkStringType() { return org.jruby.BasicObjectStub.checkStringType(this); } public IRubyObject checkArrayType() { return org.jruby.BasicObjectStub.checkArrayType(this); } public Object toJava(Class cls) { return org.jruby.BasicObjectStub.toJava(cls); } public IRubyObject dup() { return org.jruby.BasicObjectStub.dup(this); } public IRubyObject inspect() { return org.jruby.BasicObjectStub.inspect(this); } public IRubyObject rbClone() { return org.jruby.BasicObjectStub.rbClone(this); } public boolean isModule() { return org.jruby.BasicObjectStub.isModule(this); } public boolean isClass() { return org.jruby.BasicObjectStub.isClass(this); } public void dataWrapStruct(Object obj) { return org.jruby.BasicObjectStub.dataWrapStruct(this, obj); } public Object dataGetStruct() { return org.jruby.BasicObjectStub.dataGetStruct(this); } public Object dataGetStructChecked() { return org.jruby.BasicObjectStub.dataGetStructChecked(this); } public IRubyObject id() { return org.jruby.BasicObjectStub.id(this); } public IRubyObject op_equal(ThreadContext context, IRubyObject other) { return org.jruby.BasicObjectStub.op_equal(this, context, other); } public IRubyObject op_eqq(ThreadContext context, IRubyObject other) { return org.jruby.BasicObjectStub.op_eqq(this, context, other); } public boolean eql(IRubyObject other) { return self == other; } public void addFinalizer(IRubyObject finalizer) { return org.jruby.BasicObjectStub.addFinalizer(this, finalizer); } public void removeFinalizers() { return org.jruby.BasicObjectStub.removeFinalizers(this); } public boolean hasVariables() { return org.jruby.BasicObjectStub.hasVariables(this); } public int getVariableCount() { return org.jruby.BasicObjectStub.getVariableCount(this); } public void syncVariables(List<Variable<Object>> variables) { return org.jruby.BasicObjectStub.syncVariables(this, variables); } public List<Variable<Object>> 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<String> 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb
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 classpath_string = options[:classpath].size > 0 ? options[:classpath].join(":") : "." compile_string = "javac #{options[:javac_options].join(' ')} -d #{options[:target]} -cp #{ENV_JAVA['jruby.home']}/lib/#{jruby_jar}:#{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 import AST::NodeType import org.jruby.parser.JavaSignatureParser 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 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.rest_arg >= 0 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) 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.javasupport.util.RuntimeHelpers", "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 @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 @methods = [] @annotations = annotations @interfaces = [] @requires = requires @package = package @has_constructor = false; end attr_accessor :methods, :name, :script_name, :annotations, :interfaces, :requires, :package, :sourcefile def constructor? @has_constructor end def new_method(name, java_signature = nil, annotations = []) is_constructor = name == "initialize" @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 <<JAVA static { #{requires_string} RubyClass metaclass = __ruby__.getClass(\"#{name}\"); metaclass.setRubyStaticAllocator(#{name}.class); if (metaclass == null) throw new NoClassDefFoundError(\"Could not load Ruby class: #{name}\"); __metaclass__ = metaclass; } JAVA end def annotations_string annotations.map do |a| "@" + a end.join("\n") end def methods_string methods.map(&:to_s).join("\n") end def requires_string if requires.size == 0 source = File.read script_name source_chunks = source.unpack("a32000" * (source.size / 32000 + 1)) source_chunks.each do |chunk| chunk.gsub!(/([\\"])/, '\\\\\1') chunk.gsub!("\n", "\\n\" +\n \"") end source_line = source_chunks.join("\")\n .append(\""); " String source = new StringBuilder(\"#{source_line}\").toString();\n __ruby__.executeScript(source, \"#{script_name}\");" else requires.map do |r| " __ruby__.getLoadService().lockAndRequire(\"#{r}\");" end.join("\n") end end def package_string if package.empty? "" else "package #{package};" end end def constructor_string str = <<JAVA /** * Standard Ruby object constructor, for construction-from-Ruby purposes. * Generally not for user consumption. * * @param ruby The JRuby instance this object will belong to * @param metaclass The RubyClass representing the Ruby class of this object */ private #{name}(Ruby ruby, RubyClass metaclass) { super(ruby, metaclass); } /** * A static method used by JRuby for allocating instances of this object * from Ruby. Generally not for user comsumption. * * @param ruby The JRuby instance this object will belong to * @param metaclass The RubyClass representing the Ruby class of this object */ public static IRubyObject __allocate__(Ruby ruby, RubyClass metaClass) { return new #{name}(ruby, metaClass); } JAVA unless @has_constructor str << <<JAVA /** * Default constructor. Invokes this(Ruby, RubyClass) with the classloader-static * Ruby and RubyClass instances assocated with this class, and then invokes the * no-argument 'initialize' method in Ruby. * * @param ruby The JRuby instance this object will belong to * @param metaclass The RubyClass representing the Ruby class of this object */ public #{name}() { this(__ruby__, __metaclass__); RuntimeHelpers.invoke(__ruby__.getCurrentContext(), this, "initialize"); } JAVA end str end def to_s class_string = <<JAVA #{package_string} #{imports_string} #{annotations_string} public class #{name} extends RubyObject #{interface_string} { private static final Ruby __ruby__ = Ruby.getGlobalRuntime(); private static final RubyClass __metaclass__; #{static_init} #{constructor_string} #{methods_string} } JAVA class_string end def imports_string @imports.map do |import| "import #{import};" end.join("\n") end end class RubyMethod def initialize(ruby_class, name, java_signature = nil, annotations = []) @ruby_class = ruby_class @name = name @java_signature = java_signature @static = false @args = [] @annotations = annotations end attr_accessor :args, :name, :java_signature, :static, :annotations def constructor? false end def to_s declarator_string do <<-JAVA #{conversion_string(var_names)} IRubyObject ruby_result = RuntimeHelpers.invoke(__ruby__.getCurrentContext(), #{static ? '__metaclass__' : 'this'}, \"#{name}\"#{passed_args}); #{return_string} JAVA end end def declarator_string(&body) <<JAVA #{annotations_string} #{modifier_string} #{return_type} #{java_name}(#{declared_args}) { #{body.call} } JAVA end def annotations_string annotations.map { |a| "@" + a }.join("\n") end def conversion_string(var_names) var_names.map { |a| " IRubyObject ruby_#{a} = JavaUtil.convertJavaToRuby(__ruby__, #{a});"}.join("\n") end # FIXME: We should allow all valid modifiers def modifier_string modifiers = {} java_signature.modifiers.each {|m| modifiers[m.to_s] = m.to_s} is_static = static || modifiers["static"] static_str = is_static ? ' static' : '' abstract_str = modifiers["abstract"] ? ' abstract' : '' final_str = modifiers["final"] ? ' final' : '' native_str = modifiers["native"] ? ' native' : '' synchronized_str = modifiers["synchronized"] ? ' synchronized' : '' # only make sense for fields #is_transient = modifiers["transient"] #is_volatile = modifiers["volatile"] strictfp_str = modifiers["strictfp"] ? ' strictfp' : '' visibilities = modifiers.keys.to_a.grep(/public|private|protected/) if visibilities.size > 0 visibility_str = "#{visibilities[0]}" else visibility_str = 'public' end "#{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 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 @passed_args = var_names.map {|a| "ruby_#{a}"}.join(', ') @passed_args = ', ' + @passed_args if args.size > 0 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 "return (#{return_type.wrapper_name})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)} RuntimeHelpers.invoke(__ruby__.getCurrentContext(), this, \"initialize\"#{passed_args}); JAVA end end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform.rb
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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/io.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/io.rb
module FFI module IO def self.for_fd(fd, mode) 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/errno.rb
module FFI def self.errno FFI::LastError.error end def self.errno=(error) FFI::LastError.error = error end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb
module FFI CURRENT_PROCESS = USE_THIS_PROCESS_AS_LIBRARY = Object.new module Library CURRENT_PROCESS = FFI::CURRENT_PROCESS LIBC = FFI::Platform::LIBC def ffi_lib(*names) 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 errors[libname] = ex end end if lib.nil? raise LoadError.new(errors.values.join('. ')) end # return the found lib lib end end @ffi_libs = ffi_libs end def ffi_convention(convention) @ffi_convention = convention end def ffi_libraries raise LoadError.new("no library specified") if !defined?(@ffi_libs) || @ffi_libs.empty? @ffi_libs end FlagsMap = { :global => DynamicLibrary::RTLD_GLOBAL, :local => DynamicLibrary::RTLD_LOCAL, :lazy => DynamicLibrary::RTLD_LAZY, :now => DynamicLibrary::RTLD_NOW } def ffi_lib_flags(*flags) lib_flags = flags.inject(0) { |result, f| result | FlagsMap[f] } if (lib_flags & (DynamicLibrary::RTLD_LAZY | DynamicLibrary::RTLD_NOW)) == 0 lib_flags |= DynamicLibrary::RTLD_LAZY end if (lib_flags & (DynamicLibrary::RTLD_GLOBAL | DynamicLibrary::RTLD_LOCAL) == 0) lib_flags |= DynamicLibrary::RTLD_LOCAL end @ffi_lib_flags = lib_flags end ## # Attach C function +name+ to this module. # # If you want to provide an alternate name for the module function, supply # it after the +name+, otherwise the C function name will be used.# # # After the +name+, the C function argument types are provided as an Array. # # The C function return type is provided last. def attach_function(mname, a2, a3, a4=nil, a5 = nil) 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.map! { |e| find_type(e) } options = Hash.new options[:convention] = defined?(@ffi_convention) ? @ffi_convention : :default options[:type_map] = defined?(@ffi_typedefs) ? @ffi_typedefs : nil options[:enums] = defined?(@ffi_enum_map) ? @ffi_enum_map : nil options.merge!(opts) if opts.is_a?(Hash) # Try to locate the function in any of the libraries invokers = [] load_error = nil ffi_libraries.each do |lib| begin invokers << FFI.create_invoker(lib, cname.to_s, arg_types, find_type(ret_type), options) rescue LoadError => ex load_error = ex end if invokers.empty? end invoker = invokers.compact.shift raise load_error if load_error && invoker.nil? #raise FFI::NotFoundError.new(cname.to_s, *libraries) unless invoker invoker.attach(self, mname.to_s) invoker # Return a version that can be called via #call end 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 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 options = Hash.new options[:convention] = defined?(@ffi_convention) ? @ffi_convention : :default options[:enums] = @ffi_enums if defined?(@ffi_enums) cb = FFI::CallbackInfo.new(find_type(ret), params.map { |e| find_type(e) }, options) # Add to the symbol -> type map (unless there was no name) unless name.nil? __cb_map[name] = cb # Also put in the type map, so it can be used for typedefs __type_map[name] = cb end cb end def __type_map defined?(@ffi_typedefs) ? @ffi_typedefs : (@ffi_typedefs = Hash.new) end def __cb_map defined?(@ffi_callbacks) ? @ffi_callbacks: (@ffi_callbacks = Hash.new) end def typedef(current, add, info=nil) __type_map[add] = if current.kind_of?(FFI::Type) current else __type_map[current] || FFI.find_type(current) end end def enum(*args) # # enum can be called as: # enum :zero, :one, :two # unnamed enum # enum [ :zero, :one, :two ] # equivalent to above # enum :foo, [ :zero, :one, :two ] create an enum named :foo # 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 = FFI::Enum.new(values, name)) @ffi_enum_map = Hash.new unless defined?(@ffi_enum_map) # append all the enum values to a global :name => value map @ffi_enum_map.merge!(e.symbol_map) # If called as enum :foo, [ :zero, :one, :two ], add a typedef alias typedef(e, name) if name e end def enum_type(name) @ffi_enums.find(name) if defined?(@ffi_enums) end def enum_value(symbol) @ffi_enums.__map_symbol(symbol) end def find_type(name) if name.kind_of?(FFI::Type) name elsif name.is_a?(Class) && name < FFI::Struct FFI::NativeType::POINTER elsif defined?(@ffi_typedefs) && @ffi_typedefs.has_key?(name) @ffi_typedefs[name] elsif defined?(@ffi_callbacks) && @ffi_callbacks.has_key?(name) @ffi_callbacks[name] end || FFI.find_type(name) end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/autopointer.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/autopointer.rb
module FFI class AutoPointer # call-seq: # AutoPointer.new(pointer, method) => the passed Method will be invoked at GC time # AutoPointer.new(pointer, proc) => the passed Proc will be invoked at GC time (SEE WARNING BELOW!) # AutoPointer.new(pointer) { |p| ... } => the passed block will be invoked at GC time (SEE WARNING BELOW!) # AutoPointer.new(pointer) => the pointer's release() class method will be invoked at GC time # # WARNING: passing a proc _may_ cause your pointer to never be GC'd, unless you're careful to avoid trapping a reference to the pointer in the proc. See the test specs for examples. # WARNING: passing a block will cause your pointer to never be GC'd. This is bad. # # Please note that the safest, and therefore preferred, calling # idiom is to pass a Method as the second parameter. Example usage: # # class PointerHelper # def self.release(pointer) # ... # end # end # # p = AutoPointer.new(other_pointer, PointerHelper.method(:release)) # # The above code will cause PointerHelper#release to be invoked at GC time. # # The last calling idiom (only one parameter) is generally only # going to be useful if you subclass AutoPointer, and override # release(), which by default does nothing. # end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/struct.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/struct.rb
module FFI class Struct def size self.class.size end def alignment self.class.alignment end alias_method :align, :alignment def offset_of(name) self.class.offset_of(name) end def members self.class.members end def values members.map { |m| self[m] } end def offsets self.class.offsets end def clear pointer.clear self end def to_ptr pointer end def self.size defined?(@layout) ? @layout.size : defined?(@size) ? @size : 0 end def self.size=(size) raise ArgumentError, "Size already set" if defined?(@size) || defined?(@layout) @size = size end def self.alignment @layout.alignment end def self.align @layout.alignment end def self.members @layout.members end def self.offsets @layout.offsets end def self.offset_of(name) @layout.offset_of(name) end def self.in :buffer_in end def self.out :buffer_out end def self.by_value ::FFI::StructByValue.new(self) end class << self public def layout(*spec) return @layout if spec.size == 0 builder = FFI::StructLayoutBuilder.new builder.union = self < Union 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 cspec = builder.build @layout = cspec unless self == FFI::Struct @size = cspec.size return cspec 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 enclosing_module begin mod = self.name.split("::")[0..-2].inject(Object) { |obj, c| obj.const_get(c) } mod.respond_to?(:find_type) ? mod : nil rescue Exception => ex nil end end def find_type(type, mod = nil) if type.kind_of?(Class) && type < FFI::Struct FFI::Type::Struct.new(type) elsif type.is_a?(::Array) type elsif 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/) mod = enclosing_module spec[0].each do |name,type| if type.kind_of?(Class) && type < Struct builder.add_struct(name, type) elsif type.kind_of?(::Array) builder.add_array(name, find_type(type[0], mod), type[1]) else builder.add_field(name, find_type(type, mod)) end end end def array_layout(builder, spec) mod = enclosing_module 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 if type.kind_of?(Class) && type < Struct builder.add_struct(name, type, offset) elsif type.kind_of?(::Array) builder.add_array(name, find_type(type[0], mod), type[1], offset) else builder.add_field(name, find_type(type, mod), offset) end end end # # FIXME This is here for backwards compat with rbx. No idea if it # even works anymore, but left here for now. # protected def config(base, *fields) config = FFI::Config::CONFIG builder = FFI::StructLayoutBuilder.new fields.each do |field| offset = config["#{base}.#{field}.offset"] size = config["#{base}.#{field}.size"] type = config["#{base}.#{field}.type"] type = type ? type.to_sym : FFI.size_to_type(size) code = FFI.find_type type if (code == NativeType::CHAR_ARRAY) builder.add_char_array(field.to_s, size, offset) else builder.add_field(field.to_s, code, offset) end end size = config["#{base}.sizeof"] builder.size = size if size > builder.size cspec = builder.build @layout = cspec @size = cspec.size return cspec end end end class Union < Struct # Nothing to do here end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/pointer.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/pointer.rb
module FFI class Pointer def write_string(str, len=nil) len = str.size unless len # Write the string data without NUL termination put_bytes(0, str) end def read_array_of_type(type, reader, length) ary = [] size = FFI.type_size(type) tmp = self (length - 1).times { ary << tmp.send(reader) tmp += size } ary << tmp.send(reader) ary end def write_array_of_type(type, writer, ary) size = FFI.type_size(type) tmp = self (ary.length - 1).times do |i| tmp.send(writer, ary[i]) tmp += size end tmp.send(writer, ary.last) self end def read_array_of_int(length) get_array_of_int32(0, length) end def write_array_of_int(ary) put_array_of_int32(0, ary) end def read_array_of_long(length) get_array_of_long(0, length) end def write_array_of_long(ary) put_array_of_long(0, ary) end def read_array_of_pointer(length) get_array_of_pointer(0, length) end def write_array_of_pointer(ary) put_array_of_pointer(0, ary) end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/rbx.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/rbx.rb
# This file intentionally left blank
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/ffi.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/ffi.rb
# # Version: CPL 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 CPL, 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 CPL, 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/memorypointer' require 'ffi/autopointer' require 'ffi/struct' require 'ffi/io' require 'ffi/variadic' require 'ffi/errno' require 'ffi/managedstruct' require 'ffi/enum' 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 ext = ".#{Platform::LIBSUFFIX}" lib = Platform::LIBPREFIX + lib unless lib =~ /^#{Platform::LIBPREFIX}/ lib += ext unless lib =~ /#{ext}/ 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/types.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/types.rb
module FFI TypeDefs = Hash.new def self.add_typedef(current, add) TypeDefs[add] = self.find_type(current) end def self.find_type(name, type_map = nil) type = if name.is_a?(FFI::Type) name elsif type_map type_map[name] end || TypeDefs[name] raise TypeError, "Unable to resolve type '#{name}'" unless type return type end # Converts a char add_typedef(Type::CHAR, :char) # Converts an unsigned char add_typedef(Type::UCHAR, :uchar) # Converts an 8 bit int add_typedef(Type::INT8, :int8) # Converts an unsigned char add_typedef(Type::UINT8, :uint8) # Converts a short add_typedef(Type::SHORT, :short) # Converts an unsigned short add_typedef(Type::USHORT, :ushort) # Converts a 16bit int add_typedef(Type::INT16, :int16) # Converts an unsigned 16 bit int add_typedef(Type::UINT16, :uint16) # Converts an int add_typedef(Type::INT, :int) # Converts an unsigned int add_typedef(Type::UINT, :uint) # Converts a 32 bit int add_typedef(Type::INT32, :int32) # Converts an unsigned 16 bit int add_typedef(Type::UINT32, :uint32) # Converts a long add_typedef(Type::LONG, :long) # Converts an unsigned long add_typedef(Type::ULONG, :ulong) # Converts a 64 bit int add_typedef(Type::INT64, :int64) # Converts an unsigned 64 bit int add_typedef(Type::UINT64, :uint64) # Converts a long long add_typedef(Type::LONG_LONG, :long_long) # Converts an unsigned long long add_typedef(Type::ULONG_LONG, :ulong_long) # Converts a float add_typedef(Type::FLOAT, :float) # Converts a double add_typedef(Type::DOUBLE, :double) # Converts a pointer to opaque data add_typedef(Type::POINTER, :pointer) # For when a function has no return value add_typedef(Type::VOID, :void) # Native boolean type add_typedef(Type::BOOL, :bool) # Converts NUL-terminated C strings add_typedef(Type::STRING, :string) # Returns a [ String, Pointer ] tuple so the C memory for the string can be freed add_typedef(Type::STRPTR, :strptr) # Converts FFI::Buffer objects add_typedef(Type::BUFFER_IN, :buffer_in) add_typedef(Type::BUFFER_OUT, :buffer_out) add_typedef(Type::BUFFER_INOUT, :buffer_inout) add_typedef(Type::VARARGS, :varargs) # Use for a C struct with a char [] embedded inside. add_typedef(NativeType::CHAR_ARRAY, :char_array) TypeSizes = { 1 => :char, 2 => :short, 4 => :int, 8 => :long_long, } def self.size_to_type(size) if sz = TypeSizes[size] return sz end # Be like C, use int as the default type size. return :int end def self.type_size(type) if type.kind_of?(Type) || (type = find_type(type)) return type.size end raise ArgumentError, "Unknown native type" end # Load all the platform dependent types begin File.open(File.join(FFI::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*/) add_typedef(orig_type.to_sym, new_type.to_sym) end } end rescue Errno::ENOENT end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/enum.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/enum.rb
module FFI class Enums def initialize @all_enums = Array.new @tagged_enums = Hash.new @symbol_map = Hash.new end def <<(enum) @all_enums << enum @tagged_enums[enum.tag] = enum unless enum.tag.nil? @symbol_map.merge!(enum.symbol_map) end def find(query) if @tagged_enums.has_key?(query) @tagged_enums[query] else @all_enums.detect { |enum| enum.symbols.include?(query) } end end def __map_symbol(symbol) @symbol_map[symbol] end def to_hash @symbol_map end end class Enum attr_reader :tag def initialize(info, tag=nil) @tag = tag @kv_map = Hash.new @vk_map = Hash.new unless info.nil? last_cst = nil value = 0 info.each do |i| case i when Symbol @kv_map[i] = value @vk_map[value] = i last_cst = i value += 1 when Integer @kv_map[last_cst] = i @vk_map[i] = last_cst value = i+1 end end end end def symbols @kv_map.keys end def [](query) case query when Symbol @kv_map[query] when Integer @vk_map[query] end end alias find [] def symbol_map @kv_map end alias to_h symbol_map alias to_hash symbol_map end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/memorypointer.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/memorypointer.rb
require 'ffi/pointer' require 'ffi/types' module FFI class MemoryPointer def self.from_string(s) ptr = self.new(s.length + 1, 1, false) ptr.put_string(0, s) ptr end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/variadic.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/variadic.rb
module FFI class VariadicInvoker def VariadicInvoker.new(library, function, arg_types, ret_type, options) invoker = self.__new(library, function, ret_type, options[:convention].to_s) invoker.init(arg_types, options[:type_map]) invoker end def init(arg_types, type_map) @fixed = Array.new @type_map = type_map arg_types.each_with_index do |type, i| @fixed << FFI.find_type(type, @type_map) 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 def attach(mod, mname) # # Attach the invoker to this module as '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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/times.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/times.rb
require 'ffi' require 'java' module Process class Foreign SC_CLK_TCK = com.kenai.constantine.platform.Sysconf::_SC_CLK_TCK.value extend FFI::Library ffi_lib FFI::Library::LIBC class Times < FFI::Struct layout \ :utime => :long, :stime => :long, :cutime => :long, :cstime => :long end attach_function :times, [ :buffer_out ], :long attach_function :sysconf, [ :int ], :long Tms = Struct.new("Foreign::Tms", :utime, :stime, :cutime, :cstime) end def self.times hz = Foreign.sysconf(Foreign::SC_CLK_TCK).to_f t = Foreign::Times.alloc_out(false) Foreign.times(t.pointer) Foreign::Tms.new(t[:utime] / hz, t[:stime] / hz, t[:cutime] / hz, t[:cstime] / hz) end end if $0 == __FILE__ while true 10.times { system("ls -l / > /dev/null") } t = Process.times puts "utime=#{t.utime} stime=#{t.stime} cutime=#{t.cutime} cstime=#{t.cstime}" sleep 1 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/buffer.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/buffer.rb
# This file intentionally left blank
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/managedstruct.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/managedstruct.rb
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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/struct_generator.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/struct_generator.rb
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 <stdio.h>" @includes.each do |inc| f.puts "#include <#{inc}>" end f.puts "#include <stddef.h>\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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/types_generator.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/types_generator.rb
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 <sys/types.h> #include <sys/socket.h> #include <sys/resource.h> 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/const_generator.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/const_generator.rb
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 <stdio.h>" @includes.each do |inc| f.puts "#include <#{inc}>" end f.puts "#include <stddef.h>\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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/generator.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/generator.rb
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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/generator_task.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/generator_task.rb
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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-openbsd/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-openbsd/etc.rb
# This file is generated by rake. Do not edit. module 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, 28, :pw_shell, :string, 32 end class Group < FFI::Struct layout :gr_name, :string, 0, :gr_gid, :uint, 8 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-openbsd/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-openbsd/syslog.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-openbsd/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-openbsd/fcntl.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-openbsd/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-openbsd/zlib.rb
# 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, 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_', :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 # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, 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 <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. 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 <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> 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 # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> 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. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. 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 ##
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/errno.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/socket.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/stat.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/etc.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/syslog.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/fcntl.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb
# 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 # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, 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 <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. 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 <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> 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 # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> 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. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/sysconf.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/errno.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/socket.rb
# 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 = 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 = 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/stat.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/etc.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/syslog.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/fcntl.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/zlib.rb
# 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 # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, 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 <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. 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 <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> 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 # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> 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. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-darwin/sysconf.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/errno.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/socket.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/stat.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/etc.rb
# 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
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false