libuv 0.11.21 → 0.11.22

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