noderb 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/ext/noderb_extension/extconf.rb +15 -11
  2. data/ext/noderb_extension/libuv/AUTHORS +3 -0
  3. data/ext/noderb_extension/libuv/{README → README.md} +48 -6
  4. data/ext/noderb_extension/libuv/common.gypi +6 -1
  5. data/ext/noderb_extension/libuv/config-unix.mk +1 -1
  6. data/ext/noderb_extension/libuv/include/uv-private/uv-linux.h +29 -0
  7. data/ext/noderb_extension/libuv/include/uv-private/uv-unix.h +9 -0
  8. data/ext/noderb_extension/libuv/include/uv-private/uv-win.h +38 -3
  9. data/ext/noderb_extension/libuv/include/uv.h +55 -3
  10. data/ext/noderb_extension/libuv/src/unix/cares.c +1 -0
  11. data/ext/noderb_extension/libuv/src/unix/core.c +20 -4
  12. data/ext/noderb_extension/libuv/src/unix/cygwin.c +16 -0
  13. data/ext/noderb_extension/libuv/src/unix/darwin.c +18 -0
  14. data/ext/noderb_extension/libuv/src/unix/freebsd.c +18 -1
  15. data/ext/noderb_extension/libuv/src/unix/fs.c +18 -9
  16. data/ext/noderb_extension/libuv/src/unix/internal.h +24 -0
  17. data/ext/noderb_extension/libuv/src/unix/linux.c +133 -1
  18. data/ext/noderb_extension/libuv/src/unix/netbsd.c +18 -1
  19. data/ext/noderb_extension/libuv/src/unix/stream.c +21 -7
  20. data/ext/noderb_extension/libuv/src/unix/sunos.c +18 -1
  21. data/ext/noderb_extension/libuv/src/unix/tty.c +41 -0
  22. data/ext/noderb_extension/libuv/src/unix/udp.c +1 -0
  23. data/ext/noderb_extension/libuv/src/win/core.c +3 -0
  24. data/ext/noderb_extension/libuv/src/win/fs-event.c +384 -0
  25. data/ext/noderb_extension/libuv/src/win/getaddrinfo.c +7 -2
  26. data/ext/noderb_extension/libuv/src/win/handle.c +41 -0
  27. data/ext/noderb_extension/libuv/src/win/internal.h +36 -0
  28. data/ext/noderb_extension/libuv/src/win/pipe.c +3 -0
  29. data/ext/noderb_extension/libuv/src/win/process.c +7 -2
  30. data/ext/noderb_extension/libuv/src/win/req.c +10 -0
  31. data/ext/noderb_extension/libuv/src/win/stream.c +10 -3
  32. data/ext/noderb_extension/libuv/src/win/tcp.c +3 -1
  33. data/ext/noderb_extension/libuv/src/win/tty.c +1559 -5
  34. data/ext/noderb_extension/libuv/test/benchmark-getaddrinfo.c +2 -0
  35. data/ext/noderb_extension/libuv/test/runner-unix.c +2 -0
  36. data/ext/noderb_extension/libuv/test/test-fs-event.c +217 -0
  37. data/ext/noderb_extension/libuv/test/test-fs.c +0 -4
  38. data/ext/noderb_extension/libuv/test/test-getaddrinfo.c +7 -3
  39. data/ext/noderb_extension/libuv/test/test-list.h +23 -0
  40. data/ext/noderb_extension/libuv/test/test-tcp-close.c +47 -0
  41. data/ext/noderb_extension/libuv/test/test-tcp-write-error.c +168 -0
  42. data/ext/noderb_extension/libuv/test/test-timer.c +40 -0
  43. data/ext/noderb_extension/libuv/test/test-tty.c +56 -0
  44. data/ext/noderb_extension/libuv/uv.gyp +17 -18
  45. data/ext/noderb_extension/noderb.c +0 -2
  46. data/ext/noderb_extension/noderb_dns.c +6 -7
  47. data/ext/noderb_extension/noderb_fs.c +11 -10
  48. data/ext/noderb_extension/noderb_timers.c +5 -5
  49. data/lib/noderb/version.rb +1 -1
  50. metadata +8 -3
@@ -103,6 +103,7 @@
103
103
  'src/win/core.c',
104
104
  'src/win/error.c',
105
105
  'src/win/fs.c',
106
+ 'src/win/fs-event.c',
106
107
  'src/win/getaddrinfo.c',
107
108
  'src/win/handle.c',
108
109
  'src/win/internal.h',
@@ -163,23 +164,6 @@
163
164
  'src/unix/ev/ev_vars.h',
164
165
  'src/unix/ev/ev_wrap.h',
165
166
  'src/unix/ev/event.h',
166
- # TODO: conditionally include the following based on OS?
167
- 'src/ares/config_cygwin/ares_config.h',
168
- 'src/ares/config_darwin/ares_config.h',
169
- 'src/ares/config_freebsd/ares_config.h',
170
- 'src/ares/config_linux/ares_config.h',
171
- 'src/ares/config_openbsd/ares_config.h',
172
- 'src/ares/config_sunos/ares_config.h',
173
- 'src/unix/eio/config_cygwin.h',
174
- 'src/unix/eio/config_darwin.h',
175
- 'src/unix/eio/config_freebsd.h',
176
- 'src/unix/eio/config_linux.h',
177
- 'src/unix/eio/config_sunos.h',
178
- 'src/unix/ev/config_cygwin.h',
179
- 'src/unix/ev/config_darwin.h',
180
- 'src/unix/ev/config_freebsd.h',
181
- 'src/unix/ev/config_linux.h',
182
- 'src/unix/ev/config_sunos.h',
183
167
  ],
184
168
  'include_dirs': [ 'src/unix/ev', ],
185
169
  'defines': [
@@ -194,7 +178,10 @@
194
178
  'include_dirs': [ 'src/ares/config_darwin' ],
195
179
  'sources': [ 'src/unix/darwin.c' ],
196
180
  'direct_dependent_settings': {
197
- 'libraries': [ '-framework CoreServices' ],
181
+ 'libraries': [
182
+ '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
183
+ '$(SDKROOT)/System/Library/Frameworks/CoreServices.framework',
184
+ ],
198
185
  },
199
186
  'defines': [
200
187
  'EV_CONFIG_H="config_darwin.h"',
@@ -225,6 +212,14 @@
225
212
  'libraries': [ '-lrt' ],
226
213
  },
227
214
  }],
215
+ [ 'OS=="freebsd"', {
216
+ 'include_dirs': [ 'src/ares/config_freebsd' ],
217
+ 'sources': [ 'src/unix/freebsd.c' ],
218
+ 'defines': [
219
+ 'EV_CONFIG_H="config_freebsd.h"',
220
+ 'EIO_CONFIG_H="config_freebsd.h"',
221
+ ],
222
+ }],
228
223
  ]
229
224
  },
230
225
 
@@ -244,6 +239,7 @@
244
239
  'test/test-delayed-accept.c',
245
240
  'test/test-fail-always.c',
246
241
  'test/test-fs.c',
242
+ 'test/test-fs-event.c',
247
243
  'test/test-get-currentexe.c',
248
244
  'test/test-getaddrinfo.c',
249
245
  'test/test-gethostbyname.c',
@@ -261,10 +257,12 @@
261
257
  'test/test-tcp-bind-error.c',
262
258
  'test/test-tcp-bind6-error.c',
263
259
  'test/test-tcp-close.c',
260
+ 'test/test-tcp-write-error.c',
264
261
  'test/test-tcp-writealot.c',
265
262
  'test/test-threadpool.c',
266
263
  'test/test-timer-again.c',
267
264
  'test/test-timer.c',
265
+ 'test/test-tty.c',
268
266
  'test/test-udp-dgram-too-big.c',
269
267
  'test/test-udp-ipv6.c',
270
268
  'test/test-udp-send-and-recv.c',
@@ -338,3 +336,4 @@
338
336
  ]
339
337
  }
340
338
 
339
+
@@ -25,8 +25,6 @@ VALUE nodeRb_get_nodeRb_pointer(){
25
25
  }
26
26
 
27
27
  void Init_noderb_extension() {
28
- // Initialize event loop, but not start it
29
- uv_init();
30
28
  // Define module
31
29
  nodeRb = rb_define_module("NodeRb");
32
30
  // Define native pointer
@@ -4,7 +4,7 @@
4
4
  #include <noderb_tools.h>
5
5
 
6
6
  typedef struct {
7
- long target;
7
+ VALUE target;
8
8
  } nodeRb_dns_handle;
9
9
 
10
10
  void nodeRb_dns_resolved(uv_getaddrinfo_t* handle, int status, struct addrinfo* res){
@@ -14,10 +14,9 @@ void nodeRb_dns_resolved(uv_getaddrinfo_t* handle, int status, struct addrinfo*
14
14
  char address[INET_ADDRSTRLEN];
15
15
  inet_ntop(AF_INET, &(((struct sockaddr_in*) res->ai_addr)->sin_addr), address, INET_ADDRSTRLEN);
16
16
  // Call back
17
- VALUE callback = nodeRb_get_class_from_id(data->target);
18
- rb_funcall(callback, rb_intern("call"), 1, rb_str_new2(address));
17
+ rb_funcall(data->target, rb_intern("call"), 1, rb_str_new2(address));
19
18
  // Let callback GC
20
- nodeRb_unregister_instance(callback);
19
+ nodeRb_unregister_instance(data->target);
21
20
  free(handle);
22
21
  free(data);
23
22
  };
@@ -29,9 +28,9 @@ VALUE nodeRb_dns_resolve(VALUE self, VALUE host, VALUE callback){
29
28
  // Save from GC
30
29
  nodeRb_register_instance(callback);
31
30
  // Save data
32
- data->target = rb_num2long(rb_obj_id(callback));
33
- // Resolve
34
- uv_getaddrinfo(uv_default_loop(), handle, nodeRb_dns_resolved, rb_string_value_cstr(&host), NULL, NULL);
31
+ data->target = callback;
35
32
  // Save callback
36
33
  handle->data = data;
34
+ // Resolve
35
+ uv_getaddrinfo(uv_default_loop(), handle, nodeRb_dns_resolved, rb_string_value_cstr(&host), NULL, NULL);
37
36
  }
@@ -7,13 +7,13 @@
7
7
  #include <sys/stat.h>
8
8
 
9
9
  typedef struct {
10
- long target;
10
+ VALUE target;
11
11
  char* buffer;
12
12
  } nodeRb_file_handle;
13
13
 
14
14
  void nodeRb_fs_operation_callback(uv_fs_t* handle){
15
15
  nodeRb_file_handle* data = (nodeRb_file_handle*) handle->data;
16
- VALUE target = nodeRb_get_class_from_id(data->target);
16
+ VALUE target = data->target;
17
17
  if(handle->result == -1){
18
18
  rb_funcall(target, rb_intern("call"), 1, Qnil);
19
19
  }else{
@@ -63,7 +63,7 @@ void nodeRb_fs_operation_callback(uv_fs_t* handle){
63
63
  }
64
64
  }
65
65
  nodeRb_unregister_instance(target);
66
- free(handle->data);
66
+ free(data);
67
67
  uv_fs_req_cleanup(handle);
68
68
  }
69
69
 
@@ -71,7 +71,8 @@ VALUE nodeRb_fs_operation(VALUE self, VALUE roperation, VALUE path, VALUE params
71
71
  uv_fs_t* handle = malloc(sizeof(uv_fs_t));
72
72
  nodeRb_file_handle* data = malloc(sizeof(nodeRb_file_handle));
73
73
  nodeRb_register_instance(callback);
74
- data->target = rb_num2long(rb_obj_id(callback));
74
+ data->target = callback;
75
+ handle->data = data;
75
76
  long operation = rb_num2long(roperation);
76
77
  switch(operation){
77
78
  case 0:
@@ -117,12 +118,12 @@ VALUE nodeRb_fs_operation(VALUE self, VALUE roperation, VALUE path, VALUE params
117
118
  uv_fs_chown(uv_default_loop(), handle, rb_string_value_cstr(&path), (int) rb_num2long(rb_ary_entry(params, 0)), (int) rb_num2long(rb_ary_entry(params, 1)), nodeRb_fs_operation_callback);
118
119
  break;
119
120
  }
120
- handle->data = data;
121
121
  }
122
122
 
123
123
  void nodeRb_fs_file_operation_callback(uv_fs_t* handle){
124
+ printf("Test\n");
124
125
  nodeRb_file_handle* data = (nodeRb_file_handle*) handle->data;
125
- VALUE target = nodeRb_get_class_from_id(data->target);
126
+ VALUE target = data->target;
126
127
  if(handle->result == -1){
127
128
  rb_funcall(target, rb_intern("on_error"), 0, 0);
128
129
  }else{
@@ -178,7 +179,7 @@ void nodeRb_fs_file_operation_callback(uv_fs_t* handle){
178
179
  case UV_FS_OPEN:
179
180
  {
180
181
  uv_file fd = (uv_file) handle->result;
181
- rb_iv_set(target, "@_handle", INT2NUM(fd));
182
+ rb_iv_set(target, "@_handle", INT2NUM(fd)); //INT2NUM(fd)
182
183
  rb_funcall(target, rb_intern("on_open"), 0, 0);
183
184
  }
184
185
  break;
@@ -197,7 +198,7 @@ void nodeRb_fs_file_operation_callback(uv_fs_t* handle){
197
198
  break;
198
199
  }
199
200
  }
200
- free(handle->data);
201
+ free(data);
201
202
  uv_fs_req_cleanup(handle);
202
203
  }
203
204
 
@@ -211,7 +212,8 @@ VALUE nodeRb_fs_file_operation(VALUE self, VALUE roperation, VALUE params){
211
212
  uv_fs_t* handle = malloc(sizeof(uv_fs_t));
212
213
  nodeRb_file_handle* data = malloc(sizeof(nodeRb_file_handle));
213
214
  // Save Ruby data
214
- data->target = rb_num2long(rb_obj_id(self));
215
+ data->target = self;
216
+ handle->data = data;
215
217
  // Open file
216
218
  switch(operation){
217
219
  case 0:
@@ -272,5 +274,4 @@ VALUE nodeRb_fs_file_operation(VALUE self, VALUE roperation, VALUE params){
272
274
  uv_fs_close(uv_default_loop(), handle, fd, nodeRb_fs_file_operation_callback);
273
275
  break;
274
276
  }
275
- handle->data = data;
276
277
  }
@@ -14,7 +14,7 @@ void nodeRb_timers_callback(uv_timer_t* handle, int status){
14
14
  nodeRb_timers_handle* data = (nodeRb_timers_handle*) handle->data;
15
15
  VALUE handler = nodeRb_get_class_from_id(data->target);
16
16
  // Run callback
17
- rb_funcall(handler, rb_intern("call"), 1, handler);
17
+ rb_funcall(nodeRb_get_nodeRb_module(), rb_intern("next_tick_schedule"), 2, handler, handler);
18
18
  if(data->repeat == 0){
19
19
  // Let the GC work
20
20
  nodeRb_unregister_instance(handler);
@@ -28,13 +28,13 @@ VALUE nodeRb_timers_stop(VALUE self){
28
28
  // Load data
29
29
  uv_timer_t *handle;
30
30
  Data_Get_Struct(rb_iv_get(self, "@_handle"), uv_timer_t, handle);
31
+ // Free memory
32
+ nodeRb_timers_handle* data = (nodeRb_timers_handle*) handle->data;
33
+ free(data);
31
34
  // Stop timer
32
35
  uv_timer_stop(handle);
33
36
  // Let the GC work
34
37
  nodeRb_unregister_instance(self);
35
- // Free memory
36
- free((nodeRb_timers_handle*) handle->data);
37
- free(handle);
38
38
  }
39
39
 
40
40
  VALUE nodeRb_timers_once(VALUE self, VALUE timeout, VALUE repeat, VALUE handler){
@@ -49,7 +49,7 @@ VALUE nodeRb_timers_once(VALUE self, VALUE timeout, VALUE repeat, VALUE handler)
49
49
  }
50
50
  data->target = rb_num2long(rb_obj_id(handler));
51
51
  // Initialize
52
- uv_timer_init1(uv_default_loop(), handle);
52
+ uv_timer_init(uv_default_loop(), handle);
53
53
  handle->data = data;
54
54
  // Save handle
55
55
  rb_iv_set(handler, "@_handle", Data_Wrap_Struct(nodeRb_get_nodeRb_pointer(), 0, NULL, handle));
@@ -1,3 +1,3 @@
1
1
  module NodeRb
2
- VERSION = "0.0.10" unless const_defined?(:VERSION)
2
+ VERSION = "0.0.11" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noderb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-22 00:00:00.000000000Z
12
+ date: 2011-09-30 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Port of the NodeJs library to Ruby, featuring asynchronous IO operations
15
15
  of all kinds.
@@ -43,12 +43,13 @@ files:
43
43
  - ext/noderb_extension/libuv/include/uv-private/ev.h
44
44
  - ext/noderb_extension/libuv/include/uv-private/ngx-queue.h
45
45
  - ext/noderb_extension/libuv/include/uv-private/tree.h
46
+ - ext/noderb_extension/libuv/include/uv-private/uv-linux.h
46
47
  - ext/noderb_extension/libuv/include/uv-private/uv-unix.h
47
48
  - ext/noderb_extension/libuv/include/uv-private/uv-win.h
48
49
  - ext/noderb_extension/libuv/include/uv.h
49
50
  - ext/noderb_extension/libuv/LICENSE
50
51
  - ext/noderb_extension/libuv/Makefile
51
- - ext/noderb_extension/libuv/README
52
+ - ext/noderb_extension/libuv/README.md
52
53
  - ext/noderb_extension/libuv/src/ares/ares__close_sockets.c
53
54
  - ext/noderb_extension/libuv/src/ares/ares__get_hostent.c
54
55
  - ext/noderb_extension/libuv/src/ares/ares__read_line.c
@@ -213,6 +214,7 @@ files:
213
214
  - ext/noderb_extension/libuv/src/win/cares.c
214
215
  - ext/noderb_extension/libuv/src/win/core.c
215
216
  - ext/noderb_extension/libuv/src/win/error.c
217
+ - ext/noderb_extension/libuv/src/win/fs-event.c
216
218
  - ext/noderb_extension/libuv/src/win/fs.c
217
219
  - ext/noderb_extension/libuv/src/win/getaddrinfo.c
218
220
  - ext/noderb_extension/libuv/src/win/handle.c
@@ -259,6 +261,7 @@ files:
259
261
  - ext/noderb_extension/libuv/test/test-connection-fail.c
260
262
  - ext/noderb_extension/libuv/test/test-delayed-accept.c
261
263
  - ext/noderb_extension/libuv/test/test-fail-always.c
264
+ - ext/noderb_extension/libuv/test/test-fs-event.c
262
265
  - ext/noderb_extension/libuv/test/test-fs.c
263
266
  - ext/noderb_extension/libuv/test/test-get-currentexe.c
264
267
  - ext/noderb_extension/libuv/test/test-getaddrinfo.c
@@ -277,10 +280,12 @@ files:
277
280
  - ext/noderb_extension/libuv/test/test-tcp-bind-error.c
278
281
  - ext/noderb_extension/libuv/test/test-tcp-bind6-error.c
279
282
  - ext/noderb_extension/libuv/test/test-tcp-close.c
283
+ - ext/noderb_extension/libuv/test/test-tcp-write-error.c
280
284
  - ext/noderb_extension/libuv/test/test-tcp-writealot.c
281
285
  - ext/noderb_extension/libuv/test/test-threadpool.c
282
286
  - ext/noderb_extension/libuv/test/test-timer-again.c
283
287
  - ext/noderb_extension/libuv/test/test-timer.c
288
+ - ext/noderb_extension/libuv/test/test-tty.c
284
289
  - ext/noderb_extension/libuv/test/test-udp-dgram-too-big.c
285
290
  - ext/noderb_extension/libuv/test/test-udp-ipv6.c
286
291
  - ext/noderb_extension/libuv/test/test-udp-send-and-recv.c