Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved FFI under Rubinius.

  • Loading branch information...
commit 53a0a092b8676e0748343eb8b5fa861e3fc10a89 1 parent e850ba2
@brixen brixen authored
Showing with 90 additions and 30 deletions.
  1. +2 −0  kernel/common/complex.rb
  2. +2 −0  kernel/common/dir.rb
  3. +1 −0  kernel/common/errno.rb
  4. +6 −0 kernel/common/file.rb
  5. +2 −0  kernel/common/float.rb
  6. +1 −0  kernel/common/io.rb
  7. +2 −0  kernel/common/math.rb
  8. +2 −0  kernel/common/process.rb
  9. +2 −0  kernel/delta/ffi.rb
  10. +2 −0  kernel/platform/enum.rb
  11. +2 −0  kernel/platform/ffi.rb
  12. +2 −1  kernel/platform/file.rb
  13. +2 −1  kernel/platform/library.rb
  14. +2 −1  kernel/platform/math.rb
  15. +2 −0  kernel/platform/math19.rb
  16. +2 −1  kernel/platform/pointer.rb
  17. +2 −0  kernel/platform/pointer_accessors.rb
  18. +2 −1  kernel/platform/posix.rb
  19. +2 −1  kernel/platform/struct.rb
  20. +2 −1  kernel/platform/union.rb
  21. +4 −0 lib/19/socket.rb
  22. +4 −0 lib/20/socket.rb
  23. +5 −2 lib/etc.rb.ffi
  24. +1 −0  lib/ffi.rb
  25. +2 −0  lib/ffi/file_processor.rb
  26. +2 −0  lib/ffi/generator.rb
  27. +2 −0  lib/ffi/generators.rb
  28. +2 −0  lib/ffi/generators/constants.rb
  29. +2 −0  lib/ffi/generators/structures.rb
  30. +2 −0  lib/ffi/generators/types.rb
  31. +1 −0  lib/syslog.rb.ffi
  32. +2 −2 rakelib/generator_task.rb
  33. +17 −17 rakelib/platform.rake
  34. +1 −1  rakelib/vm.rake
  35. +1 −1  vm/ffi.cpp
View
2  kernel/common/complex.rb
@@ -9,6 +9,8 @@
#
class Complex < Numeric
+ FFI = Rubinius::FFI
+
undef_method :%
undef_method :<
undef_method :<=
View
2  kernel/common/dir.rb
@@ -3,6 +3,8 @@
class Dir
include Enumerable
+ FFI = Rubinius::FFI
+
def self.[](*patterns)
if patterns.size == 1
patterns = Rubinius::Type.coerce_to_path(patterns[0]).split("\0")
View
1  kernel/common/errno.rb
@@ -4,6 +4,7 @@
# Interface to the C errno integer.
module Errno
+ FFI = Rubinius::FFI
##
# Raises the appropriate SystemCallError exception with +additional+ as the
View
6 kernel/common/file.rb
@@ -1,5 +1,6 @@
# -*- encoding: us-ascii -*-
+module Rubinius
module FFI::Platform::POSIX
#--
# Internal class for accessing timevals
@@ -8,6 +9,7 @@ class TimeVal < FFI::Struct
config 'rbx.platform.timeval', :tv_sec, :tv_usec
end
end
+end
class File < IO
include Enumerable
@@ -59,6 +61,8 @@ module Constants
FNM_CASEFOLD = 0x08
end
+ FFI = Rubinius::FFI
+
SEPARATOR = FFI::Platform::File::SEPARATOR
Separator = FFI::Platform::File::SEPARATOR
ALT_SEPARATOR = FFI::Platform::File::ALT_SEPARATOR
@@ -1065,6 +1069,8 @@ class IO
end
class File::Stat
+ FFI = Rubinius::FFI
+
class Struct < FFI::Struct
config "rbx.platform.stat", :st_dev, :st_ino, :st_mode, :st_nlink,
:st_uid, :st_gid, :st_rdev, :st_size, :st_blksize, :st_blocks,
View
2  kernel/common/float.rb
@@ -4,6 +4,8 @@ class Float < Numeric
include Precision
+ FFI = Rubinius::FFI
+
def self.induced_from(obj)
case obj
when Float, Bignum, Fixnum
View
1  kernel/common/io.rb
@@ -1,6 +1,7 @@
# -*- encoding: us-ascii -*-
class IO
+ FFI = Rubinius::FFI
include Enumerable
View
2  kernel/common/math.rb
@@ -1,6 +1,8 @@
# -*- encoding: us-ascii -*-
module Math
+ FFI = Rubinius::FFI
+
# Constants
PI = 3.14159_26535_89793_23846
E = 2.71828_18284_59045_23536
View
2  kernel/common/process.rb
@@ -30,6 +30,8 @@ module Constants
end
include Constants
+ FFI = Rubinius::FFI
+
class Rlimit < FFI::Struct
config "rbx.platform.rlimit", :rlim_cur, :rlim_max
end
View
2  kernel/delta/ffi.rb
@@ -1,5 +1,6 @@
# -*- encoding: us-ascii -*-
+module Rubinius
module FFI
module Library
@@ -18,3 +19,4 @@ class InlineArray
end
end
+end
View
2  kernel/platform/enum.rb
@@ -1,5 +1,6 @@
# -*- encoding: us-ascii -*-
+module Rubinius
module FFI
# Represents a C enum.
@@ -59,3 +60,4 @@ def symbol(value)
end
end
+end
View
2  kernel/platform/ffi.rb
@@ -3,6 +3,7 @@
##
# A Foreign Function Interface used to bind C libraries to ruby.
+module Rubinius
module FFI
# Specialised error classes
@@ -258,3 +259,4 @@ def self.unix?
! windows?
end
end
+end
View
3  kernel/platform/file.rb
@@ -3,9 +3,10 @@
##
# Platform specific behavior for the File class.
+module Rubinius
module FFI::Platform::File
SEPARATOR = '/'
ALT_SEPARATOR = nil
PATH_SEPARATOR = ':'
end
-
+end
View
3  kernel/platform/library.rb
@@ -5,6 +5,7 @@ class Rubinius::NativeFunction
attr_accessor :argument_types
end
+module Rubinius
module FFI
def self.generate_function(ptr, name, args, ret)
Rubinius.primitive :nativefunction_generate
@@ -405,4 +406,4 @@ def last_error
CURRENT_PROCESS = DynamicLibrary.new(nil)
end
end
-
+end
View
3  kernel/platform/math.rb
@@ -3,6 +3,7 @@
##
# Platform specific behavior for Math.
+module Rubinius
module FFI::Platform::Math
extend FFI::Library
@@ -42,4 +43,4 @@ def self.log2(x)
log10(x) / log10(2.0)
end
end
-
+end
View
2  kernel/platform/math19.rb
@@ -3,8 +3,10 @@
##
# Platform specific behavior for Math in 1.9.
+module Rubinius
module FFI::Platform::Math
attach_function :cbrt, [:double], :double
attach_function :tgamma, [:double], :double
attach_function :lgamma_r, [:double, :pointer], :double
end
+end
View
3  kernel/platform/pointer.rb
@@ -1,5 +1,6 @@
# -*- encoding: us-ascii -*-
+module Rubinius
module FFI
##
@@ -443,4 +444,4 @@ def attach(mod, name)
end
end
end
-
+end
View
2  kernel/platform/pointer_accessors.rb
@@ -4,6 +4,7 @@
# modified manually. Due to the vast amount of very similar
# methods in this module, it is automatically generated.
+module Rubinius
module FFI
##
# This module provides accessors for various different types. It
@@ -836,3 +837,4 @@ def put_array_of_pointer(offset, ary)
end
end
+end
View
3  kernel/platform/posix.rb
@@ -3,6 +3,7 @@
##
# Namespace for various POSIX functions.
+module Rubinius
module FFI::Platform::POSIX
extend FFI::Library
@@ -116,4 +117,4 @@ module FFI::Platform::POSIX
attach_function :fstat, 'ffi_fstat', [:int, :pointer], :int
attach_function :lstat, 'ffi_lstat', [:string, :pointer], :int
end
-
+end
View
3  kernel/platform/struct.rb
@@ -1,5 +1,6 @@
# -*- encoding: us-ascii -*-
+module Rubinius
module FFI
##
# Represents a C struct as ruby class.
@@ -305,4 +306,4 @@ def null?
end
end
-
+end
View
3  kernel/platform/union.rb
@@ -1,5 +1,6 @@
# -*- encoding: us-ascii -*-
+module Rubinius
module FFI
##
# Represents a C union as ruby class.
@@ -7,4 +8,4 @@ module FFI
class Union < Struct
end
end
-
+end
View
4 lib/19/socket.rb
@@ -8,6 +8,7 @@ class SocketError < StandardError
# @todo UDPSocket#recvfrom
class BasicSocket < IO
+ FFI = Rubinius::FFI
class << self
def from_descriptor(fixnum)
@@ -245,6 +246,7 @@ def constant(prefix, suffix)
end
class Socket < BasicSocket
+ FFI = Rubinius::FFI
# @todo Is omitting empty-value constants reasonable? --rue
module Constants
@@ -1017,6 +1019,7 @@ def recvfrom_nonblock(maxlen, flags = 0)
end
class UDPSocket < IPSocket
+ FFI = Rubinius::FFI
def initialize(socktype = Socket::AF_INET)
@no_reverse_lookup = self.class.do_not_reverse_lookup
@@ -1091,6 +1094,7 @@ def inspect
end
class TCPSocket < IPSocket
+ FFI = Rubinius::FFI
def self.gethostbyname(hostname)
addrinfos = Socket.getaddrinfo(hostname, nil)
View
4 lib/20/socket.rb
@@ -8,6 +8,7 @@ class SocketError < StandardError
# @todo UDPSocket#recvfrom
class BasicSocket < IO
+ FFI = Rubinius::FFI
class << self
def from_descriptor(fixnum)
@@ -245,6 +246,7 @@ def constant(prefix, suffix)
end
class Socket < BasicSocket
+ FFI = Rubinius::FFI
# @todo Is omitting empty-value constants reasonable? --rue
module Constants
@@ -1017,6 +1019,7 @@ def recvfrom_nonblock(maxlen, flags = 0)
end
class UDPSocket < IPSocket
+ FFI = Rubinius::FFI
def initialize(socktype = Socket::AF_INET)
@no_reverse_lookup = self.class.do_not_reverse_lookup
@@ -1091,6 +1094,7 @@ def inspect
end
class TCPSocket < IPSocket
+ FFI = Rubinius::FFI
def self.gethostbyname(hostname)
addrinfos = Socket.getaddrinfo(hostname, nil)
View
7 lib/etc.rb.ffi
@@ -1,4 +1,4 @@
-class Struct::Passwd < FFI::Struct
+class Struct::Passwd < Rubinius::FFI::Struct
@@@
struct do |s|
s.include "sys/types.h"
@@ -24,7 +24,7 @@ class Struct::Passwd < FFI::Struct
def shell; self[:pw_shell]; end
end
-class Struct::Group < FFI::Struct
+class Struct::Group < Rubinius::FFI::Struct
@@@
struct do |s|
s.include "sys/types.h"
@@ -38,6 +38,8 @@ class Struct::Group < FFI::Struct
end
@@@
+ FFI = Rubinius::FFI
+
def name; self[:gr_name]; end
def gid; self[:gr_gid]; end
def passwd; self[:gr_passwd]; end
@@ -58,6 +60,7 @@ class Struct::Group < FFI::Struct
end
module Etc
+ FFI = Rubinius::FFI
const_set(:Passwd, Struct::Passwd)
const_set(:Group, Struct::Group)
View
1  lib/ffi.rb
@@ -3,3 +3,4 @@
# Rubinius, FFI is a part of the kernel code and thus
# already loaded.
+FFI = Rubinius::FFI
View
2  lib/ffi/file_processor.rb
@@ -1,5 +1,6 @@
require File.expand_path('../generators', __FILE__)
+module Rubinius
module FFI
# Processes a file containing Ruby code with blocks of FFI definitions
@@ -85,3 +86,4 @@ def to_s
end
end
end
+end
View
2  lib/ffi/generator.rb
@@ -1,5 +1,6 @@
require File.expand_path('../file_processor', __FILE__)
+module Rubinius
module FFI
class Generator
def initialize(ffi_name, rb_name)
@@ -10,3 +11,4 @@ def initialize(ffi_name, rb_name)
end
end
end
+end
View
2  lib/ffi/generators.rb
@@ -6,6 +6,7 @@
require base + '/generators/constants'
require base + '/generators/types'
+module Rubinius
module FFI
module Generators
@@ -126,3 +127,4 @@ def windows?
end
end
end
+end
View
2  lib/ffi/generators/constants.rb
@@ -1,3 +1,4 @@
+module Rubinius
module FFI
module Generators
##
@@ -177,3 +178,4 @@ def include_dir(i)
ConstGenerator = Generators::Constants
end
+end
View
2  lib/ffi/generators/structures.rb
@@ -1,3 +1,4 @@
+module Rubinius
module FFI
module Generators
##
@@ -197,3 +198,4 @@ def name(n)
StructGenerator = Generators::Structures
end
+end
View
2  lib/ffi/generators/types.rb
@@ -1,3 +1,4 @@
+module Rubinius
module FFI
module Generators
class Types
@@ -140,3 +141,4 @@ def generate
TypesGenerator = Generators::Types
end
+end
View
1  lib/syslog.rb.ffi
@@ -14,6 +14,7 @@
# platform.
module Syslog
+ FFI = Rubinius::FFI
module Constants
@@@
View
4 rakelib/generator_task.rb
@@ -7,7 +7,7 @@
##
# Rake task that calculates C structs for FFI::Struct.
-class FFI::FileProcessor::Task < Rake::TaskLib
+class Rubinius::FFI::FileProcessor::Task < Rake::TaskLib
def initialize(rb_names)
task :clean do rm_f rb_names end
@@ -18,7 +18,7 @@ def initialize(rb_names)
file rb_name => ffi_name do |t|
puts "Generating #{rb_name}..." if Rake.application.options.trace
- FFI::FileProcessor.new ffi_name, rb_name
+ Rubinius::FFI::FileProcessor.new ffi_name, rb_name
end
end
end
View
34 rakelib/platform.rake
@@ -8,7 +8,7 @@ file 'runtime/platform.conf' => deps do |task|
puts "GEN runtime/platform.conf"
File.open task.name, "wb" do |f|
- FFI::Generators::Structures.new 'addrinfo' do |s|
+ Rubinius::FFI::Generators::Structures.new 'addrinfo' do |s|
if BUILD_CONFIG[:windows]
s.include "ws2tcpip.h"
else
@@ -26,7 +26,7 @@ file 'runtime/platform.conf' => deps do |task|
s.field :ai_next, :pointer
end.write_config(f)
- FFI::Generators::Structures.new 'dirent' do |s|
+ Rubinius::FFI::Generators::Structures.new 'dirent' do |s|
s.include "sys/types.h"
s.include "dirent.h"
s.name 'struct dirent'
@@ -35,14 +35,14 @@ file 'runtime/platform.conf' => deps do |task|
s.field :d_name, :char_array
end.write_config(f)
- FFI::Generators::Structures.new 'timeval' do |s|
+ Rubinius::FFI::Generators::Structures.new 'timeval' do |s|
s.include "sys/time.h"
s.name 'struct timeval'
s.field :tv_sec, :time_t
s.field :tv_usec, :suseconds_t
end.write_config(f)
- FFI::Generators::Structures.new 'sockaddr_in' do |s|
+ Rubinius::FFI::Generators::Structures.new 'sockaddr_in' do |s|
if BUILD_CONFIG[:windows]
s.include "ws2tcpip.h"
else
@@ -59,7 +59,7 @@ file 'runtime/platform.conf' => deps do |task|
end.write_config(f)
unless BUILD_CONFIG[:windows]
- sockaddr_un = FFI::Generators::Structures.new 'sockaddr_un' do |s|
+ sockaddr_un = Rubinius::FFI::Generators::Structures.new 'sockaddr_un' do |s|
s.include "sys/un.h"
s.name 'struct sockaddr_un'
s.field :sun_family, :sa_family_t
@@ -69,7 +69,7 @@ file 'runtime/platform.conf' => deps do |task|
sockaddr_un.write_config f if sockaddr_un.found?
end
- FFI::Generators::Structures.new 'servent' do |s|
+ Rubinius::FFI::Generators::Structures.new 'servent' do |s|
if BUILD_CONFIG[:windows]
s.include "winsock2.h"
else
@@ -82,7 +82,7 @@ file 'runtime/platform.conf' => deps do |task|
s.field :s_proto, :pointer
end.write_config(f)
- FFI::Generators::Structures.new 'stat' do |s|
+ Rubinius::FFI::Generators::Structures.new 'stat' do |s|
unless BUILD_CONFIG[:windows]
s.include "sys/types.h"
s.include "unistd.h"
@@ -114,7 +114,7 @@ file 'runtime/platform.conf' => deps do |task|
end.write_config(f)
unless BUILD_CONFIG[:windows]
- FFI::Generators::Structures.new 'rlimit' do |s|
+ Rubinius::FFI::Generators::Structures.new 'rlimit' do |s|
s.include "sys/types.h"
s.include "sys/time.h"
s.include "sys/resource.h"
@@ -136,7 +136,7 @@ file 'runtime/platform.conf' => deps do |task|
# BINARY
# }
- FFI::Generators::Constants.new 'rbx.platform.file' do |cg|
+ Rubinius::FFI::Generators::Constants.new 'rbx.platform.file' do |cg|
cg.include 'stdio.h'
cg.include 'fcntl.h'
cg.include 'sys/stat.h'
@@ -178,7 +178,7 @@ file 'runtime/platform.conf' => deps do |task|
file_constants.each { |c| cg.const c }
end.write_constants(f)
- FFI::Generators::Constants.new 'rbx.platform.io' do |cg|
+ Rubinius::FFI::Generators::Constants.new 'rbx.platform.io' do |cg|
cg.include 'stdio.h'
io_constants = %w[
@@ -191,7 +191,7 @@ file 'runtime/platform.conf' => deps do |task|
end.write_constants(f)
# Only constants needed by core are added here
- FFI::Generators::Constants.new 'rbx.platform.fcntl' do |cg|
+ Rubinius::FFI::Generators::Constants.new 'rbx.platform.fcntl' do |cg|
cg.include 'fcntl.h'
fcntl_constants = %w[
@@ -206,7 +206,7 @@ file 'runtime/platform.conf' => deps do |task|
fcntl_constants.each { |c| cg.const c }
end.write_constants(f)
- FFI::Generators::Constants.new 'rbx.platform.socket' do |cg|
+ Rubinius::FFI::Generators::Constants.new 'rbx.platform.socket' do |cg|
cg.include 'sys/types.h'
if BUILD_CONFIG[:windows]
cg.include "winsock2.h"
@@ -461,7 +461,7 @@ file 'runtime/platform.conf' => deps do |task|
end.write_constants(f)
unless BUILD_CONFIG[:windows]
- FFI::Generators::Constants.new 'rbx.platform.process' do |cg|
+ Rubinius::FFI::Generators::Constants.new 'rbx.platform.process' do |cg|
cg.include 'sys/wait.h'
cg.include 'sys/resource.h'
cg.include 'stdlib.h'
@@ -505,7 +505,7 @@ file 'runtime/platform.conf' => deps do |task|
# The constants come from MRI's signal.c. This means that some of them might
# be missing.
- FFI::Generators::Constants.new 'rbx.platform.signal' do |cg|
+ Rubinius::FFI::Generators::Constants.new 'rbx.platform.signal' do |cg|
cg.include 'signal.h'
unless BUILD_CONFIG[:windows]
cg.include 'sys/signal.h'
@@ -561,7 +561,7 @@ file 'runtime/platform.conf' => deps do |task|
signal_constants.each { |c| cg.const c }
end.write_constants(f)
- FFI::Generators::Constants.new 'rbx.platform.zlib' do |cg|
+ Rubinius::FFI::Generators::Constants.new 'rbx.platform.zlib' do |cg|
cg.include_dir 'vendor/zlib' if BUILD_CONFIG[:vendor_zlib]
cg.include 'zlib.h'
@@ -571,7 +571,7 @@ file 'runtime/platform.conf' => deps do |task|
end.write_constants(f)
unless BUILD_CONFIG[:windows]
- FFI::Generators::Constants.new 'rbx.platform.dlopen' do |cg|
+ Rubinius::FFI::Generators::Constants.new 'rbx.platform.dlopen' do |cg|
cg.include 'dlfcn.h'
dlopen_constants = %w[
@@ -585,6 +585,6 @@ file 'runtime/platform.conf' => deps do |task|
end.write_constants(f)
end
- f.puts FFI::Generators::Types.new.generate
+ f.puts Rubinius::FFI::Generators::Types.new.generate
end
end
View
2  rakelib/vm.rake
@@ -189,7 +189,7 @@ namespace :build do
# Generate the .rb files from lib/*.rb.ffi
task :preprocessor => FFI_PREPROCESSABLES
- FFI::FileProcessor::Task.new FFI_PREPROCESSABLES
+ Rubinius::FFI::FileProcessor::Task.new FFI_PREPROCESSABLES
end
end
View
2  vm/ffi.cpp
@@ -32,7 +32,7 @@
namespace rubinius {
void VM::init_ffi(STATE) {
- GO(ffi).set(ontology::new_module(state, "FFI"));
+ GO(ffi).set(ontology::new_module(state, "FFI", G(rubinius)));
Module* mod = G(ffi);
mod->set_const(state, "TYPE_CHAR", Fixnum::from(RBX_FFI_TYPE_CHAR));
mod->set_const(state, "TYPE_UCHAR", Fixnum::from(RBX_FFI_TYPE_UCHAR));
Please sign in to comment.
Something went wrong with that request. Please try again.