win32-nio 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +3 -0
- data/MANIFEST +2 -5
- data/README +2 -1
- data/Rakefile +1 -0
- data/ext/win32/nio.c +19 -11
- data/test/test_win32_nio_read.rb +1 -3
- data/win32-nio.gemspec +2 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d829b0d7823000b4e8c3ce911a129328e0d72db8
|
4
|
+
data.tar.gz: 3a23c84c020ac5a28f76623a4768c4882723ce7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 564ff3198da3309c3ed9a6d2ec2136a499e093f71728643b2f397f8805abeb18ddbe60ea6e4a51f1dbc5600d82310a4b8606b3a52cd29c1e6d644817df82203d
|
7
|
+
data.tar.gz: 9c4dedc035094a63824032d57675d90fea431bdb740fccaa7297e3bbb9a08105efdeab023ca91513c319b95bccf636f665d480578dfa20489a2cc6dfd5e0df6a
|
data/CHANGES
CHANGED
data/MANIFEST
CHANGED
@@ -4,10 +4,7 @@
|
|
4
4
|
* README
|
5
5
|
* win32-nio.gemspec
|
6
6
|
* benchmarks/win32_nio_benchmarks.rb
|
7
|
-
*
|
8
|
-
*
|
9
|
-
* lib/windows/functions.rb
|
10
|
-
* lib/windows/macros.rb
|
11
|
-
* lib/windows/structs.rb
|
7
|
+
* ext/extconf.rb
|
8
|
+
* ext/win32/nio.c
|
12
9
|
* test/test_win32_nio_read.rb
|
13
10
|
* test/test_win32_nio_readlines.rb
|
data/README
CHANGED
@@ -31,7 +31,7 @@
|
|
31
31
|
to implement MRI methods would offer any practical advantage. The answer
|
32
32
|
is a definite maybe.
|
33
33
|
|
34
|
-
Functionally,
|
34
|
+
Functionally, this library does offer something the MRI methods do not,
|
35
35
|
which is the ability to provide a block or event object that is called
|
36
36
|
when a read is finished.
|
37
37
|
|
@@ -51,6 +51,7 @@
|
|
51
51
|
NIO.read(medium) 0.015000 0.093000 0.108000 ( 0.122542)
|
52
52
|
IO.read(large) 1.654000 0.593000 2.247000 ( 2.355478)
|
53
53
|
NIO.read(large) 0.343000 0.765000 1.108000 ( 1.222567)
|
54
|
+
|
54
55
|
IO.readlines(small) 0.125000 0.000000 0.125000 ( 0.119982)
|
55
56
|
NIO.readlines(small) 0.094000 0.015000 0.109000 ( 0.132461)
|
56
57
|
IO.readlines(medium) 1.419000 0.234000 1.653000 ( 1.764216)
|
data/Rakefile
CHANGED
data/ext/win32/nio.c
CHANGED
@@ -16,8 +16,12 @@ void rb_raise_syserr(const char* msg, int errnum){
|
|
16
16
|
}
|
17
17
|
|
18
18
|
/*
|
19
|
+
* NIO.read(file, length=nil, offset=0, options=nil){ # optional block }
|
20
|
+
*
|
19
21
|
* This method is similar to Ruby's IO.read method except that it uses
|
20
|
-
* native function calls.
|
22
|
+
* native function calls. It also optionally accepts a Win32::Event object,
|
23
|
+
* signalling it upon completion. If provided it calls a block upon completion
|
24
|
+
* of the read.
|
21
25
|
*
|
22
26
|
* Examples:
|
23
27
|
*
|
@@ -30,10 +34,10 @@ void rb_raise_syserr(const char* msg, int errnum){
|
|
30
34
|
* # Read 50 bytes starting at offset 10
|
31
35
|
* Win32::NIO.read(file, 50, 10)
|
32
36
|
*
|
33
|
-
* Note that the +
|
34
|
-
* to :encoding, :
|
35
|
-
* function internally.In the case of:mode the only thing that is checked
|
36
|
-
* for is the presence of the 'b' (binary)mode.
|
37
|
+
* Note that the +options+ that may be passed to this method are limited
|
38
|
+
* to :encoding, :mode and :event because we're no longer using the open
|
39
|
+
* function internally. In the case of :mode the only thing that is checked
|
40
|
+
* for is the presence of the 'b' (binary) mode.
|
37
41
|
*
|
38
42
|
* The :event option, if present, must be a Win32::Event object.
|
39
43
|
*/
|
@@ -103,7 +107,7 @@ static VALUE rb_nio_read(int argc, VALUE* argv, VALUE self){
|
|
103
107
|
|
104
108
|
if (!NIL_P(v_event)){
|
105
109
|
flags |= FILE_FLAG_OVERLAPPED;
|
106
|
-
olap.hEvent = (HANDLE)NUM2OFFT(rb_funcall(v_event, rb_intern("handle"), 0, 0));
|
110
|
+
olap.hEvent = (HANDLE)(uintptr_t)NUM2OFFT(rb_funcall(v_event, rb_intern("handle"), 0, 0));
|
107
111
|
}
|
108
112
|
}
|
109
113
|
else{
|
@@ -189,8 +193,12 @@ static VALUE rb_nio_read(int argc, VALUE* argv, VALUE self){
|
|
189
193
|
}
|
190
194
|
|
191
195
|
/*
|
196
|
+
* NIO.readlines(file, sep="\r\n", event=nil)
|
197
|
+
*
|
192
198
|
* Reads the entire file specified by portname as individual lines, and
|
193
|
-
* returns those lines in an array. Lines are separated by +sep+.
|
199
|
+
* returns those lines in an array. Lines are separated by +sep+. The +event+
|
200
|
+
* argument must be a Win32::Event if present, and it is signalled upon
|
201
|
+
* completion.
|
194
202
|
*
|
195
203
|
* Examples:
|
196
204
|
*
|
@@ -290,14 +298,14 @@ static VALUE rb_nio_readlines(int argc, VALUE* argv, VALUE self){
|
|
290
298
|
if (NIL_P(v_event))
|
291
299
|
olap.hEvent = NULL;
|
292
300
|
else
|
293
|
-
olap.hEvent = (HANDLE)NUM2OFFT(rb_funcall(v_event, rb_intern("handle"), 0, 0));
|
301
|
+
olap.hEvent = (HANDLE)(uintptr_t)NUM2OFFT(rb_funcall(v_event, rb_intern("handle"), 0, 0));
|
294
302
|
|
295
303
|
fse = (FILE_SEGMENT_ELEMENT*)malloc(sizeof(FILE_SEGMENT_ELEMENT) * (page_num + 1));
|
296
304
|
memset(fse, 0, sizeof(FILE_SEGMENT_ELEMENT) * (page_num + 1));
|
297
305
|
v_result = Qnil;
|
298
306
|
|
299
307
|
for (i = 0; i < page_num; i++)
|
300
|
-
fse[i].Alignment = (ULONGLONG)base_address + (page_size * i);
|
308
|
+
fse[i].Alignment = (ULONGLONG)(uintptr_t)base_address + (page_size * i);
|
301
309
|
|
302
310
|
rv = ReadFileScatter(h, fse, (DWORD)size, NULL, &olap);
|
303
311
|
|
@@ -342,6 +350,6 @@ void Init_nio(){
|
|
342
350
|
rb_define_singleton_method(cNio, "read", rb_nio_read, -1);
|
343
351
|
rb_define_singleton_method(cNio, "readlines", rb_nio_readlines, -1);
|
344
352
|
|
345
|
-
/* 0.2.
|
346
|
-
rb_define_const(cNio, "VERSION", rb_str_new2("0.2.
|
353
|
+
/* 0.2.1: The version of the win32-nio library */
|
354
|
+
rb_define_const(cNio, "VERSION", rb_str_new2("0.2.1"));
|
347
355
|
}
|
data/test/test_win32_nio_read.rb
CHANGED
@@ -24,7 +24,7 @@ class TC_Win32_NIO_Read < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
test "version number is set to expected value" do
|
27
|
-
assert_equal('0.2.
|
27
|
+
assert_equal('0.2.1', Win32::NIO::VERSION)
|
28
28
|
end
|
29
29
|
|
30
30
|
test "read method basic functionality" do
|
@@ -34,8 +34,6 @@ class TC_Win32_NIO_Read < Test::Unit::TestCase
|
|
34
34
|
|
35
35
|
test "read method accepts a file name and returns a string of the expected size" do
|
36
36
|
assert_kind_of(String, NIO.read(@@file))
|
37
|
-
p @size
|
38
|
-
p NIO.read(@@file).size
|
39
37
|
assert_true(NIO.read(@@file).size == @size)
|
40
38
|
end
|
41
39
|
|
data/win32-nio.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'win32-nio'
|
5
|
-
spec.version = '0.2.
|
5
|
+
spec.version = '0.2.1'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.license = 'Artistic 2.0'
|
8
8
|
spec.email = 'djberg96@gmail.com'
|
@@ -11,9 +11,8 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
12
12
|
spec.extensions = ['ext/extconf.rb']
|
13
13
|
|
14
|
-
spec.rubyforge_project = 'Win32Utils'
|
15
14
|
spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
|
16
|
-
spec.required_ruby_version = '
|
15
|
+
spec.required_ruby_version = '>= 1.9.3'
|
17
16
|
|
18
17
|
spec.add_dependency('win32-event', '>= 0.6.0')
|
19
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32-nio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: win32-event
|
@@ -86,16 +86,16 @@ require_paths:
|
|
86
86
|
- lib
|
87
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - "
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 1.9.
|
91
|
+
version: 1.9.3
|
92
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
rubyforge_project:
|
98
|
+
rubyforge_project:
|
99
99
|
rubygems_version: 2.4.5
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|