libuv 0.10.0 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -17
- data/.gitmodules +3 -3
- data/.rspec +1 -1
- data/.travis.yml +16 -16
- data/Gemfile +2 -2
- data/LICENSE +23 -23
- data/README.md +82 -73
- data/Rakefile +31 -31
- data/lib/libuv.rb +53 -34
- data/lib/libuv/async.rb +47 -33
- data/lib/libuv/check.rb +55 -48
- data/lib/libuv/error.rb +70 -70
- data/lib/libuv/ext/ext.rb +264 -256
- data/lib/libuv/ext/platform/darwin_x64.rb +12 -12
- data/lib/libuv/ext/platform/linux.rb +7 -7
- data/lib/libuv/ext/platform/unix.rb +13 -13
- data/lib/libuv/ext/platform/windows.rb +26 -26
- data/lib/libuv/ext/tasks.rb +27 -27
- data/lib/libuv/ext/tasks/mac.rb +23 -23
- data/lib/libuv/ext/tasks/unix.rb +23 -23
- data/lib/libuv/ext/tasks/win.rb +11 -11
- data/lib/libuv/ext/types.rb +234 -229
- data/lib/libuv/file.rb +192 -0
- data/lib/libuv/filesystem.rb +233 -0
- data/lib/libuv/fs_event.rb +31 -31
- data/lib/libuv/handle.rb +85 -81
- data/lib/libuv/idle.rb +56 -49
- data/lib/libuv/loop.rb +338 -310
- data/lib/libuv/{assertions.rb → mixins/assertions.rb} +23 -23
- data/lib/libuv/mixins/fs_checks.rb +55 -0
- data/lib/libuv/{listener.rb → mixins/listener.rb} +34 -34
- data/lib/libuv/{net.rb → mixins/net.rb} +37 -37
- data/lib/libuv/{resource.rb → mixins/resource.rb} +27 -27
- data/lib/libuv/{stream.rb → mixins/stream.rb} +143 -123
- data/lib/libuv/pipe.rb +197 -97
- data/lib/libuv/prepare.rb +56 -49
- data/lib/libuv/q.rb +1 -1
- data/lib/libuv/signal.rb +51 -0
- data/lib/libuv/tcp.rb +204 -193
- data/lib/libuv/timer.rb +88 -75
- data/lib/libuv/tty.rb +37 -34
- data/lib/libuv/udp.rb +273 -255
- data/lib/libuv/version.rb +3 -3
- data/lib/libuv/work.rb +63 -61
- data/libuv.gemspec +54 -54
- data/spec/async_spec.rb +60 -60
- data/spec/cpu_spec.rb +10 -0
- data/spec/defer_spec.rb +980 -980
- data/spec/filesystem_spec.rb +119 -0
- data/spec/idle_spec.rb +56 -56
- data/spec/pipe_spec.rb +153 -148
- data/spec/tcp_spec.rb +203 -188
- metadata +73 -49
- checksums.yaml +0 -15
- data/lib/libuv/simple_async.rb +0 -28
@@ -1,12 +1,12 @@
|
|
1
|
-
module Libuv
|
2
|
-
module Ext
|
3
|
-
class UvFSStat < FFI::Struct
|
4
|
-
layout :st_dev, :dev_t, :st_mode, :mode_t, :st_nlink, :nlink_t,
|
5
|
-
:st_ino, :ino_t, :st_uid, :uid_t, :st_gid, :gid_t, :st_rdev,
|
6
|
-
:dev_t, :st_atime, :time_t, :st_mtime, :time_t, :st_ctime,
|
7
|
-
:time_t, :st_size, :off_t, :st_blocks, :blkcnt_t, :st_blksize,
|
8
|
-
:blksize_t, :st_flags, :uint32, :st_gen, :uint32, :st_lspare,
|
9
|
-
:int32, :st_qspare_0, :int64, :st_qspare_1, :int64
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
1
|
+
module Libuv
|
2
|
+
module Ext
|
3
|
+
class UvFSStat < FFI::Struct
|
4
|
+
layout :st_dev, :dev_t, :st_mode, :mode_t, :st_nlink, :nlink_t,
|
5
|
+
:st_ino, :ino_t, :st_uid, :uid_t, :st_gid, :gid_t, :st_rdev,
|
6
|
+
:dev_t, :st_atime, :time_t, :st_mtime, :time_t, :st_ctime,
|
7
|
+
:time_t, :st_size, :off_t, :st_blocks, :blkcnt_t, :st_blksize,
|
8
|
+
:blksize_t, :st_flags, :uint32, :st_gen, :uint32, :st_lspare,
|
9
|
+
:int32, :st_qspare_0, :int64, :st_qspare_1, :int64
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module Libuv
|
2
|
-
module Ext
|
3
|
-
# blksize_t, in_addr_t is not yet part of types.conf on linux
|
4
|
-
typedef :long, :blksize_t
|
5
|
-
typedef :uint32, :in_addr_t
|
6
|
-
typedef :ushort, :in_port_t
|
7
|
-
end
|
1
|
+
module Libuv
|
2
|
+
module Ext
|
3
|
+
# blksize_t, in_addr_t is not yet part of types.conf on linux
|
4
|
+
typedef :long, :blksize_t
|
5
|
+
typedef :uint32, :in_addr_t
|
6
|
+
typedef :ushort, :in_port_t
|
7
|
+
end
|
8
8
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module Libuv
|
2
|
-
module Ext
|
3
|
-
class UvBuf < FFI::Struct
|
4
|
-
layout :base, :pointer, :len, :size_t
|
5
|
-
end
|
6
|
-
|
7
|
-
class UvFSStat < FFI::Struct
|
8
|
-
layout :st_dev, :dev_t, :st_ino, :ino_t, :st_mode, :mode_t, :st_nlink, :nlink_t,
|
9
|
-
:st_uid, :uid_t, :st_gid, :gid_t, :st_rdev, :dev_t, :st_size, :off_t,
|
10
|
-
:st_blksize, :blksize_t, :st_blocks, :blkcnt_t, :st_atime, :time_t,
|
11
|
-
:st_mtime, :time_t, :st_ctime, :time_t
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module Libuv
|
2
|
+
module Ext
|
3
|
+
class UvBuf < FFI::Struct
|
4
|
+
layout :base, :pointer, :len, :size_t
|
5
|
+
end
|
6
|
+
|
7
|
+
class UvFSStat < FFI::Struct
|
8
|
+
layout :st_dev, :dev_t, :st_ino, :ino_t, :st_mode, :mode_t, :st_nlink, :nlink_t,
|
9
|
+
:st_uid, :uid_t, :st_gid, :gid_t, :st_rdev, :dev_t, :st_size, :off_t,
|
10
|
+
:st_blksize, :blksize_t, :st_blocks, :blkcnt_t, :st_atime, :time_t,
|
11
|
+
:st_mtime, :time_t, :st_ctime, :time_t
|
12
|
+
end
|
13
|
+
end
|
14
14
|
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
module Libuv
|
2
|
-
module Ext
|
3
|
-
typedef :uint32_t, :in_addr_t
|
4
|
-
typedef :uint16, :in_port_t
|
5
|
-
typedef :int, :mode_t
|
6
|
-
|
7
|
-
module WS2
|
8
|
-
extend FFI::Library
|
9
|
-
ffi_lib('Ws2_32.dll').first # this is for ntohs
|
10
|
-
attach_function :ntohs, [:ushort], :ushort, :blocking => true
|
11
|
-
end
|
12
|
-
def_delegators :WS2, :ntohs
|
13
|
-
module_function :ntohs
|
14
|
-
|
15
|
-
# win32 has a different uv_buf_t layout to everything else.
|
16
|
-
class UvBuf < FFI::Struct
|
17
|
-
layout :len, :ulong, :base, :pointer
|
18
|
-
end
|
19
|
-
|
20
|
-
# win32 uses _stati64
|
21
|
-
class UvFSStat < FFI::Struct
|
22
|
-
layout :st_gid, :gid_t, :st_atime, :time_t, :st_ctime, :time_t, :st_dev, :dev_t,
|
23
|
-
:st_ino, :ino_t, :st_mode, :mode_t, :st_mtime, :time_t, :st_nlink, :nlink_t,
|
24
|
-
:st_rdev, :dev_t, :st_size, :off_t, :st_uid, :uid_t
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Libuv
|
2
|
+
module Ext
|
3
|
+
typedef :uint32_t, :in_addr_t
|
4
|
+
typedef :uint16, :in_port_t
|
5
|
+
typedef :int, :mode_t
|
6
|
+
|
7
|
+
module WS2
|
8
|
+
extend FFI::Library
|
9
|
+
ffi_lib('Ws2_32.dll').first # this is for ntohs
|
10
|
+
attach_function :ntohs, [:ushort], :ushort, :blocking => true
|
11
|
+
end
|
12
|
+
def_delegators :WS2, :ntohs
|
13
|
+
module_function :ntohs
|
14
|
+
|
15
|
+
# win32 has a different uv_buf_t layout to everything else.
|
16
|
+
class UvBuf < FFI::Struct
|
17
|
+
layout :len, :ulong, :base, :pointer
|
18
|
+
end
|
19
|
+
|
20
|
+
# win32 uses _stati64
|
21
|
+
class UvFSStat < FFI::Struct
|
22
|
+
layout :st_gid, :gid_t, :st_atime, :time_t, :st_ctime, :time_t, :st_dev, :dev_t,
|
23
|
+
:st_ino, :ino_t, :st_mode, :mode_t, :st_mtime, :time_t, :st_nlink, :nlink_t,
|
24
|
+
:st_rdev, :dev_t, :st_size, :off_t, :st_uid, :uid_t
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|
data/lib/libuv/ext/tasks.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
module FFI::Platform
|
2
|
-
def self.ia32?
|
3
|
-
ARCH == "i386"
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.x64?
|
7
|
-
ARCH == "x86_64"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
file 'ext/libuv/build' do
|
12
|
-
system "git", "submodule", "update", "--init"
|
13
|
-
end
|
14
|
-
|
15
|
-
file 'ext/libuv/build/gyp' => 'ext/libuv/build' do
|
16
|
-
system "svn", "export", "-r1214", "http://gyp.googlecode.com/svn/trunk", "ext/libuv/build/gyp"
|
17
|
-
end
|
18
|
-
|
19
|
-
CLEAN.include('ext/libuv/build/gyp')
|
20
|
-
|
21
|
-
if FFI::Platform.windows?
|
22
|
-
require File.join File.expand_path("../", __FILE__), 'tasks/win'
|
23
|
-
elsif FFI::Platform.mac?
|
24
|
-
require File.join File.expand_path("../", __FILE__), 'tasks/mac'
|
25
|
-
else # UNIX
|
26
|
-
require File.join File.expand_path("../", __FILE__), 'tasks/unix'
|
27
|
-
end
|
1
|
+
module FFI::Platform
|
2
|
+
def self.ia32?
|
3
|
+
ARCH == "i386"
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.x64?
|
7
|
+
ARCH == "x86_64"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
file 'ext/libuv/build' do
|
12
|
+
system "git", "submodule", "update", "--init"
|
13
|
+
end
|
14
|
+
|
15
|
+
file 'ext/libuv/build/gyp' => 'ext/libuv/build' do
|
16
|
+
system "svn", "export", "-r1214", "http://gyp.googlecode.com/svn/trunk", "ext/libuv/build/gyp"
|
17
|
+
end
|
18
|
+
|
19
|
+
CLEAN.include('ext/libuv/build/gyp')
|
20
|
+
|
21
|
+
if FFI::Platform.windows?
|
22
|
+
require File.join File.expand_path("../", __FILE__), 'tasks/win'
|
23
|
+
elsif FFI::Platform.mac?
|
24
|
+
require File.join File.expand_path("../", __FILE__), 'tasks/mac'
|
25
|
+
else # UNIX
|
26
|
+
require File.join File.expand_path("../", __FILE__), 'tasks/unix'
|
27
|
+
end
|
data/lib/libuv/ext/tasks/mac.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
file 'ext/libuv/uv.xcodeproj' => 'ext/libuv/build/gyp' do
|
2
|
-
target_arch = 'ia32'if FFI::Platform.ia32?
|
3
|
-
target_arch = 'x64' if FFI::Platform.x64?
|
4
|
-
|
5
|
-
abort "Don't know how to build on #{FFI::Platform::ARCH} (yet)" unless target_arch
|
6
|
-
|
7
|
-
Dir.chdir("ext/libuv") do |path|
|
8
|
-
system "./gyp_uv -f xcode -Dtarget_arch=#{target_arch} -Dlibrary=shared_library -Dcomponent=shared_library"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
file "ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}" => 'ext/libuv/uv.xcodeproj' do
|
13
|
-
Dir.chdir("ext/libuv") do |path|
|
14
|
-
system 'xcodebuild -project uv.xcodeproj -configuration Release -target libuv'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
file "ext/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
19
|
-
File.symlink("libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv.#{FFI::Platform::LIBSUFFIX}")
|
20
|
-
end
|
21
|
-
|
22
|
-
CLEAN.include('ext/libuv/uv.xcodeproj')
|
23
|
-
CLOBBER.include("ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}")
|
1
|
+
file 'ext/libuv/uv.xcodeproj' => 'ext/libuv/build/gyp' do
|
2
|
+
target_arch = 'ia32'if FFI::Platform.ia32?
|
3
|
+
target_arch = 'x64' if FFI::Platform.x64?
|
4
|
+
|
5
|
+
abort "Don't know how to build on #{FFI::Platform::ARCH} (yet)" unless target_arch
|
6
|
+
|
7
|
+
Dir.chdir("ext/libuv") do |path|
|
8
|
+
system "./gyp_uv -f xcode -Dtarget_arch=#{target_arch} -Dlibrary=shared_library -Dcomponent=shared_library"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
file "ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}" => 'ext/libuv/uv.xcodeproj' do
|
13
|
+
Dir.chdir("ext/libuv") do |path|
|
14
|
+
system 'xcodebuild -project uv.xcodeproj -configuration Release -target libuv'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
file "ext/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
19
|
+
File.symlink("libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv.#{FFI::Platform::LIBSUFFIX}")
|
20
|
+
end
|
21
|
+
|
22
|
+
CLEAN.include('ext/libuv/uv.xcodeproj')
|
23
|
+
CLOBBER.include("ext/libuv/build/Release/libuv.#{FFI::Platform::LIBSUFFIX}")
|
data/lib/libuv/ext/tasks/unix.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
file 'ext/libuv/out' => 'ext/libuv/build/gyp' do
|
2
|
-
target_arch = 'ia32'if FFI::Platform.ia32?
|
3
|
-
target_arch = 'x64' if FFI::Platform.x64?
|
4
|
-
|
5
|
-
abort "Don't know how to build on #{FFI::Platform::ARCH} (yet)" unless target_arch
|
6
|
-
|
7
|
-
Dir.chdir("ext/libuv") do |path|
|
8
|
-
system "./gyp_uv -f make -Dtarget_arch=#{target_arch} -Dlibrary=shared_library -Dcomponent=shared_library"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
file "ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}" => 'ext/libuv/out' do
|
13
|
-
Dir.chdir("ext/libuv") do |path|
|
14
|
-
system 'make -C out BUILDTYPE=Release'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
file "ext/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
19
|
-
File.symlink("libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv.#{FFI::Platform::LIBSUFFIX}")
|
20
|
-
end
|
21
|
-
|
22
|
-
CLEAN.include('ext/libuv/out')
|
23
|
-
CLOBBER.include("ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}")
|
1
|
+
file 'ext/libuv/out' => 'ext/libuv/build/gyp' do
|
2
|
+
target_arch = 'ia32'if FFI::Platform.ia32?
|
3
|
+
target_arch = 'x64' if FFI::Platform.x64?
|
4
|
+
|
5
|
+
abort "Don't know how to build on #{FFI::Platform::ARCH} (yet)" unless target_arch
|
6
|
+
|
7
|
+
Dir.chdir("ext/libuv") do |path|
|
8
|
+
system "./gyp_uv -f make -Dtarget_arch=#{target_arch} -Dlibrary=shared_library -Dcomponent=shared_library"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
file "ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}" => 'ext/libuv/out' do
|
13
|
+
Dir.chdir("ext/libuv") do |path|
|
14
|
+
system 'make -C out BUILDTYPE=Release'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
file "ext/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
19
|
+
File.symlink("libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv.#{FFI::Platform::LIBSUFFIX}")
|
20
|
+
end
|
21
|
+
|
22
|
+
CLEAN.include('ext/libuv/out')
|
23
|
+
CLOBBER.include("ext/libuv/out/Release/lib.target/libuv.#{FFI::Platform::LIBSUFFIX}")
|
data/lib/libuv/ext/tasks/win.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
file "ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
2
|
-
Dir.chdir("ext/libuv") do |path|
|
3
|
-
system 'vcbuild.bat', 'shared', 'release'
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
file "ext/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
8
|
-
FileUtils.mv("ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv.#{FFI::Platform::LIBSUFFIX}")
|
9
|
-
end
|
10
|
-
|
11
|
-
CLOBBER.include("ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}")
|
1
|
+
file "ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
2
|
+
Dir.chdir("ext/libuv") do |path|
|
3
|
+
system 'vcbuild.bat', 'shared', 'release'
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
file "ext/libuv.#{FFI::Platform::LIBSUFFIX}" => "ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}" do
|
8
|
+
FileUtils.mv("ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}", "ext/libuv.#{FFI::Platform::LIBSUFFIX}")
|
9
|
+
end
|
10
|
+
|
11
|
+
CLOBBER.include("ext/libuv/Release/libuv.#{FFI::Platform::LIBSUFFIX}")
|
data/lib/libuv/ext/types.rb
CHANGED
@@ -1,230 +1,235 @@
|
|
1
|
-
module FFI::Platform
|
2
|
-
def self.linux?
|
3
|
-
IS_LINUX
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
module Libuv
|
8
|
-
module Ext
|
9
|
-
require 'libuv/ext/platform/linux.rb' if FFI::Platform.linux?
|
10
|
-
require 'libuv/ext/platform/unix.rb' if FFI::Platform.unix?
|
11
|
-
require 'libuv/ext/platform/darwin_x64.rb' if FFI::Platform.mac? and FFI::Platform::ARCH == 'x86_64'
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
|
35
|
-
|
36
|
-
:
|
37
|
-
:
|
38
|
-
|
39
|
-
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
|
48
|
-
|
49
|
-
:
|
50
|
-
:
|
51
|
-
]
|
52
|
-
enum :
|
53
|
-
:
|
54
|
-
:
|
55
|
-
|
56
|
-
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
78
|
-
:
|
79
|
-
:
|
80
|
-
|
81
|
-
|
82
|
-
:
|
83
|
-
:
|
84
|
-
]
|
85
|
-
enum :
|
86
|
-
:
|
87
|
-
:
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
class
|
106
|
-
layout :
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
class
|
125
|
-
layout :
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
:
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
:
|
148
|
-
:
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
154
|
-
:
|
155
|
-
:
|
156
|
-
:
|
157
|
-
:
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
typedef
|
165
|
-
|
166
|
-
typedef :pointer, :
|
167
|
-
typedef :pointer, :
|
168
|
-
typedef :pointer, :
|
169
|
-
typedef :pointer, :
|
170
|
-
typedef :pointer, :
|
171
|
-
typedef :pointer, :
|
172
|
-
typedef :pointer, :
|
173
|
-
typedef :pointer, :
|
174
|
-
typedef :pointer, :
|
175
|
-
typedef :pointer, :
|
176
|
-
typedef :pointer, :
|
177
|
-
typedef :pointer, :
|
178
|
-
typedef :pointer, :
|
179
|
-
typedef :pointer, :
|
180
|
-
typedef :pointer, :
|
181
|
-
typedef :pointer, :
|
182
|
-
typedef :pointer, :
|
183
|
-
typedef :pointer, :
|
184
|
-
typedef :pointer, :
|
185
|
-
typedef :
|
186
|
-
typedef :pointer, :
|
187
|
-
typedef :pointer, :
|
188
|
-
typedef :pointer, :
|
189
|
-
typedef :
|
190
|
-
typedef :pointer, :
|
191
|
-
typedef :pointer, :
|
192
|
-
typedef :pointer, :
|
193
|
-
typedef :pointer, :
|
194
|
-
typedef :pointer, :
|
195
|
-
typedef :pointer, :
|
196
|
-
typedef :pointer, :
|
197
|
-
typedef :pointer, :
|
198
|
-
typedef :pointer, :
|
199
|
-
typedef :pointer, :
|
200
|
-
typedef :
|
201
|
-
typedef :
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
callback :
|
209
|
-
callback :
|
210
|
-
callback :
|
211
|
-
callback :
|
212
|
-
callback :
|
213
|
-
callback :
|
214
|
-
callback :
|
215
|
-
callback :
|
216
|
-
callback :
|
217
|
-
callback :
|
218
|
-
callback :
|
219
|
-
callback :
|
220
|
-
callback :
|
221
|
-
callback :
|
222
|
-
callback :
|
223
|
-
callback :
|
224
|
-
callback :
|
225
|
-
|
226
|
-
callback :
|
227
|
-
callback :
|
228
|
-
callback :
|
229
|
-
|
1
|
+
module FFI::Platform
|
2
|
+
def self.linux?
|
3
|
+
IS_LINUX
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module Libuv
|
8
|
+
module Ext
|
9
|
+
require 'libuv/ext/platform/linux.rb' if FFI::Platform.linux?
|
10
|
+
require 'libuv/ext/platform/unix.rb' if FFI::Platform.unix?
|
11
|
+
require 'libuv/ext/platform/darwin_x64.rb' if FFI::Platform.mac? and FFI::Platform::ARCH == 'x86_64'
|
12
|
+
if FFI::Platform.windows?
|
13
|
+
require 'libuv/ext/platform/windows.rb'
|
14
|
+
else
|
15
|
+
attach_function :ntohs, [:ushort], :ushort, :blocking => true
|
16
|
+
end
|
17
|
+
|
18
|
+
enum :uv_handle_type, [
|
19
|
+
:uv_unknown_handle, 0,
|
20
|
+
:uv_async, # start UV_HANDLE_TYPE_MAP
|
21
|
+
:uv_check,
|
22
|
+
:uv_fs_event,
|
23
|
+
:uv_fs_poll,
|
24
|
+
:uv_handle,
|
25
|
+
:uv_idle,
|
26
|
+
:uv_pipe,
|
27
|
+
:uv_poll,
|
28
|
+
:uv_prepare,
|
29
|
+
:uv_process,
|
30
|
+
:uv_stream,
|
31
|
+
:uv_tcp,
|
32
|
+
:uv_timer,
|
33
|
+
:uv_tty,
|
34
|
+
:uv_udp,
|
35
|
+
:uv_signal, # end UV_HANDLE_TYPE_MAP
|
36
|
+
:uv_file,
|
37
|
+
:uv_handle_type_max
|
38
|
+
]
|
39
|
+
enum :uv_req_type, [
|
40
|
+
:uv_unknown_req, 0,
|
41
|
+
:uv_req, # start UV_REQ_TYPE_MAP
|
42
|
+
:uv_connect,
|
43
|
+
:uv_write,
|
44
|
+
:uv_shutdown,
|
45
|
+
:uv_udp_send,
|
46
|
+
:uv_fs,
|
47
|
+
:uv_work,
|
48
|
+
:uv_getaddrinfo, # end UV_REQ_TYPE_MAP
|
49
|
+
:uv_req_type_private,
|
50
|
+
:uv_req_type_max
|
51
|
+
]
|
52
|
+
enum :uv_membership, [
|
53
|
+
:uv_leave_group, 0,
|
54
|
+
:uv_join_group
|
55
|
+
]
|
56
|
+
enum :uv_fs_type, [
|
57
|
+
:UV_FS_UNKNOWN, -1,
|
58
|
+
:UV_FS_CUSTOM,
|
59
|
+
:UV_FS_OPEN,
|
60
|
+
:UV_FS_CLOSE,
|
61
|
+
:UV_FS_READ,
|
62
|
+
:UV_FS_WRITE,
|
63
|
+
:UV_FS_SENDFILE,
|
64
|
+
:UV_FS_STAT,
|
65
|
+
:UV_FS_LSTAT,
|
66
|
+
:UV_FS_FSTAT,
|
67
|
+
:UV_FS_FTRUNCATE,
|
68
|
+
:UV_FS_UTIME,
|
69
|
+
:UV_FS_FUTIME,
|
70
|
+
:UV_FS_CHMOD,
|
71
|
+
:UV_FS_FCHMOD,
|
72
|
+
:UV_FS_FSYNC,
|
73
|
+
:UV_FS_FDATASYNC,
|
74
|
+
:UV_FS_UNLINK,
|
75
|
+
:UV_FS_RMDIR,
|
76
|
+
:UV_FS_MKDIR,
|
77
|
+
:UV_FS_RENAME,
|
78
|
+
:UV_FS_READDIR,
|
79
|
+
:UV_FS_LINK,
|
80
|
+
:UV_FS_SYMLINK,
|
81
|
+
:UV_FS_READLINK,
|
82
|
+
:UV_FS_CHOWN,
|
83
|
+
:UV_FS_FCHOWN
|
84
|
+
]
|
85
|
+
enum :uv_fs_event, [
|
86
|
+
:UV_RENAME, 1,
|
87
|
+
:UV_CHANGE, 2
|
88
|
+
]
|
89
|
+
enum :uv_run_mode, [
|
90
|
+
:UV_RUN_DEFAULT, 0,
|
91
|
+
:UV_RUN_ONCE,
|
92
|
+
:UV_RUN_NOWAIT
|
93
|
+
]
|
94
|
+
|
95
|
+
typedef UvBuf.by_value, :uv_buf_t
|
96
|
+
typedef UvFSStat.by_value, :uv_fs_stat_t
|
97
|
+
|
98
|
+
|
99
|
+
class Sockaddr < FFI::Struct
|
100
|
+
layout :sa_len, :uint8,
|
101
|
+
:sa_family, :sa_family_t,
|
102
|
+
:sa_data, [:char, 14]
|
103
|
+
end
|
104
|
+
|
105
|
+
class InAddr < FFI::Struct
|
106
|
+
layout :s_addr, :in_addr_t
|
107
|
+
end
|
108
|
+
|
109
|
+
class SockaddrIn < FFI::Struct
|
110
|
+
layout :sin_len, :uint8,
|
111
|
+
:sin_family, :sa_family_t,
|
112
|
+
:sin_port, :in_port_t,
|
113
|
+
:sin_addr, InAddr,
|
114
|
+
:sin_zero, [:char, 8]
|
115
|
+
end
|
116
|
+
|
117
|
+
typedef SockaddrIn.by_value, :sockaddr_in
|
118
|
+
|
119
|
+
class U6Addr < FFI::Union
|
120
|
+
layout :__u6_addr8, [:uint8, 16],
|
121
|
+
:__u6_addr16, [:uint16, 8]
|
122
|
+
end
|
123
|
+
|
124
|
+
class In6Addr < FFI::Struct
|
125
|
+
layout :__u6_addr, U6Addr
|
126
|
+
end
|
127
|
+
|
128
|
+
class SockaddrIn6 < FFI::Struct
|
129
|
+
layout :sin6_len, :uint8,
|
130
|
+
:sin6_family, :sa_family_t,
|
131
|
+
:sin6_port, :in_port_t,
|
132
|
+
:sin6_flowinfo, :uint32,
|
133
|
+
:sin6_addr, In6Addr,
|
134
|
+
:sin6_scope_id, :uint32
|
135
|
+
end
|
136
|
+
|
137
|
+
typedef SockaddrIn6.by_value, :sockaddr_in6
|
138
|
+
|
139
|
+
|
140
|
+
class UvTimespec < FFI::Struct
|
141
|
+
layout :tv_sec, :long,
|
142
|
+
:tv_nsec, :long
|
143
|
+
end
|
144
|
+
|
145
|
+
class UvStat < FFI::Struct
|
146
|
+
layout :st_dev, :uint64,
|
147
|
+
:st_mode, :uint64,
|
148
|
+
:st_nlink, :uint64,
|
149
|
+
:st_uid, :uint64,
|
150
|
+
:st_gid, :uint64,
|
151
|
+
:st_rdev, :uint64,
|
152
|
+
:st_ino, :uint64,
|
153
|
+
:st_size, :uint64,
|
154
|
+
:st_blksize, :uint64,
|
155
|
+
:st_blocks, :uint64,
|
156
|
+
:st_flags, :uint64,
|
157
|
+
:st_gen, :uint64,
|
158
|
+
:st_atim, UvTimespec,
|
159
|
+
:st_mtim, UvTimespec,
|
160
|
+
:st_ctim, UvTimespec,
|
161
|
+
:st_birthtim, UvTimespec
|
162
|
+
end
|
163
|
+
|
164
|
+
typedef UvStat.by_value, :uv_stat_t
|
165
|
+
|
166
|
+
typedef :pointer, :uv_handle_t
|
167
|
+
typedef :pointer, :uv_fs_event_t
|
168
|
+
typedef :pointer, :uv_fs_poll_t
|
169
|
+
typedef :pointer, :uv_stream_t
|
170
|
+
typedef :pointer, :uv_tcp_t
|
171
|
+
typedef :pointer, :uv_udp_t
|
172
|
+
typedef :pointer, :uv_tty_t
|
173
|
+
typedef :pointer, :uv_pipe_t
|
174
|
+
typedef :pointer, :uv_prepare_t
|
175
|
+
typedef :pointer, :uv_check_t
|
176
|
+
typedef :pointer, :uv_idle_t
|
177
|
+
typedef :pointer, :uv_async_t
|
178
|
+
typedef :pointer, :uv_timer_t
|
179
|
+
typedef :pointer, :uv_signal_t
|
180
|
+
typedef :pointer, :uv_process_t
|
181
|
+
typedef :pointer, :uv_getaddrinfo_cb
|
182
|
+
typedef :pointer, :addrinfo
|
183
|
+
typedef :pointer, :uv_work_t
|
184
|
+
typedef :pointer, :uv_loop_t
|
185
|
+
typedef :pointer, :uv_shutdown_t
|
186
|
+
typedef :pointer, :uv_write_t
|
187
|
+
typedef :pointer, :uv_connect_t
|
188
|
+
typedef :pointer, :uv_udp_send_t
|
189
|
+
typedef :int, :uv_file
|
190
|
+
typedef :pointer, :uv_fs_t
|
191
|
+
typedef :pointer, :ares_channel
|
192
|
+
typedef :pointer, :ares_options
|
193
|
+
typedef :pointer, :uv_getaddrinfo_t
|
194
|
+
typedef :pointer, :uv_options_t
|
195
|
+
typedef :pointer, :uv_cpu_info_t
|
196
|
+
typedef :pointer, :uv_interface_address_t
|
197
|
+
typedef :pointer, :uv_lib_t
|
198
|
+
typedef :pointer, :uv_mutex_t
|
199
|
+
typedef :pointer, :uv_rwlock_t
|
200
|
+
typedef :pointer, :uv_once_t
|
201
|
+
typedef :pointer, :uv_thread_t
|
202
|
+
typedef :pointer, :uv_poll_t
|
203
|
+
typedef :pointer, :uv_stat_t
|
204
|
+
typedef :int, :status
|
205
|
+
typedef :int, :events
|
206
|
+
typedef :int, :signal
|
207
|
+
|
208
|
+
callback :uv_alloc_cb, [:uv_handle_t, :size_t], :uv_buf_t
|
209
|
+
callback :uv_read_cb, [:uv_stream_t, :ssize_t, :uv_buf_t], :void
|
210
|
+
callback :uv_read2_cb, [:uv_pipe_t, :ssize_t, :uv_buf_t, :uv_handle_type], :void
|
211
|
+
callback :uv_write_cb, [:uv_write_t, :status], :void
|
212
|
+
callback :uv_connect_cb, [:uv_connect_t, :status], :void
|
213
|
+
callback :uv_shutdown_cb, [:uv_shutdown_t, :status], :void
|
214
|
+
callback :uv_connection_cb, [:uv_stream_t, :status], :void
|
215
|
+
callback :uv_close_cb, [:uv_handle_t], :void
|
216
|
+
callback :uv_poll_cb, [:uv_poll_t, :status, :events], :void
|
217
|
+
callback :uv_timer_cb, [:uv_timer_t, :status], :void
|
218
|
+
callback :uv_signal_cb, [:uv_signal_t, :signal], :void
|
219
|
+
callback :uv_async_cb, [:uv_async_t, :status], :void
|
220
|
+
callback :uv_prepare_cb, [:uv_prepare_t, :status], :void
|
221
|
+
callback :uv_check_cb, [:uv_check_t, :status], :void
|
222
|
+
callback :uv_idle_cb, [:uv_idle_t, :status], :void
|
223
|
+
callback :uv_getaddrinfo_cb, [:uv_getaddrinfo_t, :status, :addrinfo], :void
|
224
|
+
callback :uv_exit_cb, [:uv_process_t, :int, :int], :void
|
225
|
+
callback :uv_walk_cb, [:uv_handle_t, :pointer], :void
|
226
|
+
callback :uv_work_cb, [:uv_work_t], :void
|
227
|
+
callback :uv_after_work_cb, [:uv_work_t, :int], :void
|
228
|
+
callback :uv_fs_event_cb, [:uv_fs_event_t, :string, :int, :int], :void
|
229
|
+
callback :uv_fs_poll_cb, [:uv_fs_poll_t, :status, :uv_stat_t, :uv_stat_t], :void
|
230
|
+
#callback :uv_signal_cb, []
|
231
|
+
callback :uv_udp_send_cb, [:uv_udp_send_t, :int], :void
|
232
|
+
callback :uv_udp_recv_cb, [:uv_udp_t, :ssize_t, :uv_buf_t, Sockaddr, :uint], :void
|
233
|
+
callback :uv_cb, [], :void
|
234
|
+
end
|
230
235
|
end
|