libuv 0.10.0 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.gitignore +17 -17
  2. data/.gitmodules +3 -3
  3. data/.rspec +1 -1
  4. data/.travis.yml +16 -16
  5. data/Gemfile +2 -2
  6. data/LICENSE +23 -23
  7. data/README.md +82 -73
  8. data/Rakefile +31 -31
  9. data/lib/libuv.rb +53 -34
  10. data/lib/libuv/async.rb +47 -33
  11. data/lib/libuv/check.rb +55 -48
  12. data/lib/libuv/error.rb +70 -70
  13. data/lib/libuv/ext/ext.rb +264 -256
  14. data/lib/libuv/ext/platform/darwin_x64.rb +12 -12
  15. data/lib/libuv/ext/platform/linux.rb +7 -7
  16. data/lib/libuv/ext/platform/unix.rb +13 -13
  17. data/lib/libuv/ext/platform/windows.rb +26 -26
  18. data/lib/libuv/ext/tasks.rb +27 -27
  19. data/lib/libuv/ext/tasks/mac.rb +23 -23
  20. data/lib/libuv/ext/tasks/unix.rb +23 -23
  21. data/lib/libuv/ext/tasks/win.rb +11 -11
  22. data/lib/libuv/ext/types.rb +234 -229
  23. data/lib/libuv/file.rb +192 -0
  24. data/lib/libuv/filesystem.rb +233 -0
  25. data/lib/libuv/fs_event.rb +31 -31
  26. data/lib/libuv/handle.rb +85 -81
  27. data/lib/libuv/idle.rb +56 -49
  28. data/lib/libuv/loop.rb +338 -310
  29. data/lib/libuv/{assertions.rb → mixins/assertions.rb} +23 -23
  30. data/lib/libuv/mixins/fs_checks.rb +55 -0
  31. data/lib/libuv/{listener.rb → mixins/listener.rb} +34 -34
  32. data/lib/libuv/{net.rb → mixins/net.rb} +37 -37
  33. data/lib/libuv/{resource.rb → mixins/resource.rb} +27 -27
  34. data/lib/libuv/{stream.rb → mixins/stream.rb} +143 -123
  35. data/lib/libuv/pipe.rb +197 -97
  36. data/lib/libuv/prepare.rb +56 -49
  37. data/lib/libuv/q.rb +1 -1
  38. data/lib/libuv/signal.rb +51 -0
  39. data/lib/libuv/tcp.rb +204 -193
  40. data/lib/libuv/timer.rb +88 -75
  41. data/lib/libuv/tty.rb +37 -34
  42. data/lib/libuv/udp.rb +273 -255
  43. data/lib/libuv/version.rb +3 -3
  44. data/lib/libuv/work.rb +63 -61
  45. data/libuv.gemspec +54 -54
  46. data/spec/async_spec.rb +60 -60
  47. data/spec/cpu_spec.rb +10 -0
  48. data/spec/defer_spec.rb +980 -980
  49. data/spec/filesystem_spec.rb +119 -0
  50. data/spec/idle_spec.rb +56 -56
  51. data/spec/pipe_spec.rb +153 -148
  52. data/spec/tcp_spec.rb +203 -188
  53. metadata +73 -49
  54. checksums.yaml +0 -15
  55. 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
@@ -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
@@ -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}")
@@ -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}")
@@ -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}")
@@ -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
- require 'libuv/ext/platform/windows.rb' if FFI::Platform.windows?
13
-
14
- enum :uv_handle_type, [
15
- :uv_unknown_handle, 0,
16
- :uv_async, # start UV_HANDLE_TYPE_MAP
17
- :uv_check,
18
- :uv_fs_event,
19
- :uv_fs_poll,
20
- :uv_handle,
21
- :uv_idle,
22
- :uv_pipe,
23
- :uv_poll,
24
- :uv_prepare,
25
- :uv_process,
26
- :uv_stream,
27
- :uv_tcp,
28
- :uv_timer,
29
- :uv_tty,
30
- :uv_udp,
31
- :uv_signal, # end UV_HANDLE_TYPE_MAP
32
- :uv_file,
33
- :uv_handle_type_max
34
- ]
35
- enum :uv_req_type, [
36
- :uv_unknown_req, 0,
37
- :uv_req, # start UV_REQ_TYPE_MAP
38
- :uv_connect,
39
- :uv_write,
40
- :uv_shutdown,
41
- :uv_udp_send,
42
- :uv_fs,
43
- :uv_work,
44
- :uv_getaddrinfo, # end UV_REQ_TYPE_MAP
45
- :uv_req_type_private,
46
- :uv_req_type_max
47
- ]
48
- enum :uv_membership, [
49
- :uv_leave_group, 0,
50
- :uv_join_group
51
- ]
52
- enum :uv_fs_type, [
53
- :UV_FS_UNKNOWN, -1,
54
- :UV_FS_CUSTOM,
55
- :UV_FS_OPEN,
56
- :UV_FS_CLOSE,
57
- :UV_FS_READ,
58
- :UV_FS_WRITE,
59
- :UV_FS_SENDFILE,
60
- :UV_FS_STAT,
61
- :UV_FS_LSTAT,
62
- :UV_FS_FSTAT,
63
- :UV_FS_FTRUNCATE,
64
- :UV_FS_UTIME,
65
- :UV_FS_FUTIME,
66
- :UV_FS_CHMOD,
67
- :UV_FS_FCHMOD,
68
- :UV_FS_FSYNC,
69
- :UV_FS_FDATASYNC,
70
- :UV_FS_UNLINK,
71
- :UV_FS_RMDIR,
72
- :UV_FS_MKDIR,
73
- :UV_FS_RENAME,
74
- :UV_FS_READDIR,
75
- :UV_FS_LINK,
76
- :UV_FS_SYMLINK,
77
- :UV_FS_READLINK,
78
- :UV_FS_CHOWN,
79
- :UV_FS_FCHOWN
80
- ]
81
- enum :uv_fs_event, [
82
- :UV_RENAME, 1,
83
- :UV_CHANGE, 2
84
- ]
85
- enum :uv_run_mode, [
86
- :UV_RUN_DEFAULT, 0,
87
- :UV_RUN_ONCE,
88
- :UV_RUN_NOWAIT
89
- ]
90
-
91
- typedef UvBuf.by_value, :uv_buf_t
92
- typedef UvFSStat.by_value, :uv_fs_stat_t
93
-
94
-
95
- class Sockaddr < FFI::Struct
96
- layout :sa_len, :uint8,
97
- :sa_family, :sa_family_t,
98
- :sa_data, [:char, 14]
99
- end
100
-
101
- class InAddr < FFI::Struct
102
- layout :s_addr, :in_addr_t
103
- end
104
-
105
- class SockaddrIn < FFI::Struct
106
- layout :sin_len, :uint8,
107
- :sin_family, :sa_family_t,
108
- :sin_port, :in_port_t,
109
- :sin_addr, InAddr,
110
- :sin_zero, [:char, 8]
111
- end
112
-
113
- typedef SockaddrIn.by_value, :sockaddr_in
114
-
115
- class U6Addr < FFI::Union
116
- layout :__u6_addr8, [:uint8, 16],
117
- :__u6_addr16, [:uint16, 8]
118
- end
119
-
120
- class In6Addr < FFI::Struct
121
- layout :__u6_addr, U6Addr
122
- end
123
-
124
- class SockaddrIn6 < FFI::Struct
125
- layout :sin6_len, :uint8,
126
- :sin6_family, :sa_family_t,
127
- :sin6_port, :in_port_t,
128
- :sin6_flowinfo, :uint32,
129
- :sin6_addr, In6Addr,
130
- :sin6_scope_id, :uint32
131
- end
132
-
133
- typedef SockaddrIn6.by_value, :sockaddr_in6
134
-
135
-
136
- class UvTimespec < FFI::Struct
137
- layout :tv_sec, :long,
138
- :tv_nsec, :long
139
- end
140
-
141
- class UvStat < FFI::Struct
142
- layout :st_dev, :uint64,
143
- :st_mode, :uint64,
144
- :st_nlink, :uint64,
145
- :st_uid, :uint64,
146
- :st_gid, :uint64,
147
- :st_rdev, :uint64,
148
- :st_ino, :uint64,
149
- :st_size, :uint64,
150
- :st_blksize, :uint64,
151
- :st_blocks, :uint64,
152
- :st_flags, :uint64,
153
- :st_gen, :uint64,
154
- :st_atim, UvTimespec,
155
- :st_mtim, UvTimespec,
156
- :st_ctim, UvTimespec,
157
- :st_birthtim, UvTimespec
158
- end
159
-
160
- typedef UvStat.by_value, :uv_stat_t
161
-
162
- typedef :pointer, :uv_handle_t
163
- typedef :pointer, :uv_fs_event_t
164
- typedef :pointer, :uv_fs_poll_t
165
- typedef :pointer, :uv_stream_t
166
- typedef :pointer, :uv_tcp_t
167
- typedef :pointer, :uv_udp_t
168
- typedef :pointer, :uv_tty_t
169
- typedef :pointer, :uv_pipe_t
170
- typedef :pointer, :uv_prepare_t
171
- typedef :pointer, :uv_check_t
172
- typedef :pointer, :uv_idle_t
173
- typedef :pointer, :uv_async_t
174
- typedef :pointer, :uv_timer_t
175
- typedef :pointer, :uv_process_t
176
- typedef :pointer, :uv_getaddrinfo_cb
177
- typedef :pointer, :addrinfo
178
- typedef :pointer, :uv_fs_t
179
- typedef :pointer, :uv_work_t
180
- typedef :pointer, :uv_loop_t
181
- typedef :pointer, :uv_shutdown_t
182
- typedef :pointer, :uv_write_t
183
- typedef :pointer, :uv_connect_t
184
- typedef :pointer, :uv_udp_send_t
185
- typedef :int, :uv_file
186
- typedef :pointer, :ares_channel
187
- typedef :pointer, :ares_options
188
- typedef :pointer, :uv_getaddrinfo_t
189
- typedef :pointer, :uv_options_t
190
- typedef :pointer, :uv_cpu_info_t
191
- typedef :pointer, :uv_interface_address_t
192
- typedef :pointer, :uv_fs_t
193
- typedef :pointer, :uv_lib_t
194
- typedef :pointer, :uv_mutex_t
195
- typedef :pointer, :uv_rwlock_t
196
- typedef :pointer, :uv_once_t
197
- typedef :pointer, :uv_thread_t
198
- typedef :pointer, :uv_poll_t
199
- typedef :pointer, :uv_stat_t
200
- typedef :int, :status
201
- typedef :int, :events
202
-
203
- callback :uv_alloc_cb, [:uv_handle_t, :size_t], :uv_buf_t
204
- callback :uv_read_cb, [:uv_stream_t, :ssize_t, :uv_buf_t], :void
205
- callback :uv_read2_cb, [:uv_pipe_t, :ssize_t, :uv_buf_t, :uv_handle_type], :void
206
- callback :uv_write_cb, [:uv_write_t, :status], :void
207
- callback :uv_connect_cb, [:uv_connect_t, :status], :void
208
- callback :uv_shutdown_cb, [:uv_shutdown_t, :status], :void
209
- callback :uv_connection_cb, [:uv_stream_t, :status], :void
210
- callback :uv_close_cb, [:uv_handle_t], :void
211
- callback :uv_poll_cb, [:uv_poll_t, :status, :events], :void
212
- callback :uv_timer_cb, [:uv_timer_t, :status], :void
213
- callback :uv_async_cb, [:uv_async_t, :status], :void
214
- callback :uv_prepare_cb, [:uv_prepare_t, :status], :void
215
- callback :uv_check_cb, [:uv_check_t, :status], :void
216
- callback :uv_idle_cb, [:uv_idle_t, :status], :void
217
- callback :uv_getaddrinfo_cb, [:uv_getaddrinfo_t, :status, :addrinfo], :void
218
- callback :uv_exit_cb, [:uv_process_t, :int, :int], :void
219
- callback :uv_walk_cb, [:uv_handle_t, :pointer], :void
220
- callback :uv_fs_cb, [:uv_fs_t], :void
221
- callback :uv_work_cb, [:uv_work_t], :void
222
- callback :uv_after_work_cb, [:uv_work_t, :int], :void
223
- callback :uv_fs_event_cb, [:uv_fs_event_t, :string, :int, :int], :void
224
- callback :uv_fs_poll_cb, [:uv_fs_poll_t, :status, :uv_stat_t, :uv_stat_t], :void
225
- #callback :uv_signal_cb, []
226
- callback :uv_udp_send_cb, [:uv_udp_send_t, :int], :void
227
- callback :uv_udp_recv_cb, [:uv_udp_t, :ssize_t, :uv_buf_t, Sockaddr, :uint], :void
228
- callback :uv_cb, [], :void
229
- end
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