win32-mmap 0.2.0 → 0.2.2
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.
- data/CHANGES +16 -1
- data/MANIFEST +11 -15
- data/README +4 -3
- data/Rakefile +21 -0
- data/lib/win32/mmap.rb +14 -15
- data/test/tc_mmap.rb +30 -11
- data/win32-mmap.gemspec +3 -3
- metadata +8 -5
- data/install.rb +0 -11
data/CHANGES
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
== 0.2.2 - 16-May-2007
|
2
|
+
* Fixed a bug where marshalled data that happened to end with a "\0" would
|
3
|
+
cause the getter to fail.
|
4
|
+
* Now runs -w clean.
|
5
|
+
* Added more tests.
|
6
|
+
* Removed the install.rb file. Installation is now handled via the 'rake
|
7
|
+
install' task.
|
8
|
+
* Updated the MANIFEST file and made it rdoc friendly.
|
9
|
+
|
10
|
+
== 0.2.1 - 22-Oct-2006
|
11
|
+
* Removed the custom memcpy function since that function now does the right
|
12
|
+
thing regardless of argument type.
|
13
|
+
* Now requires windows-pr 0.5.6 or later (to take advantage of the improved
|
14
|
+
memcpy).
|
15
|
+
|
1
16
|
== 0.2.0 - 13-Oct-2006
|
2
17
|
* Completely scrapped the old interface and code. It is now pure Ruby and
|
3
18
|
has a much different API, and some internal changes.
|
@@ -20,4 +35,4 @@
|
|
20
35
|
* Fixed sprintf() bug in new().
|
21
36
|
|
22
37
|
== 0.0.1 - 13-Mar-2004
|
23
|
-
* Initial (Beta) release
|
38
|
+
* Initial (Beta) release
|
data/MANIFEST
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
CHANGES
|
2
|
-
MANIFEST
|
3
|
-
README
|
4
|
-
|
5
|
-
win32-mmap.gemspec
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
examples/
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
lib/win32/mmap.rb
|
14
|
-
|
15
|
-
test/tc_mmap.rb
|
1
|
+
* CHANGES
|
2
|
+
* MANIFEST
|
3
|
+
* README
|
4
|
+
* Rakefile
|
5
|
+
* win32-mmap.gemspec
|
6
|
+
* doc/mmap.rdoc
|
7
|
+
* examples/mmap_test.rb
|
8
|
+
* examples/test_client.rb
|
9
|
+
* examples/test_server.rb
|
10
|
+
* lib/win32/mmap.rb
|
11
|
+
* test/tc_mmap.rb
|
data/README
CHANGED
@@ -7,7 +7,8 @@
|
|
7
7
|
|
8
8
|
= Installation
|
9
9
|
== Standard Installation
|
10
|
-
|
10
|
+
rake test (optional)
|
11
|
+
rake install
|
11
12
|
|
12
13
|
== Gem Installation
|
13
14
|
ruby win32-mmap.gemspec
|
@@ -58,7 +59,7 @@
|
|
58
59
|
Ruby's
|
59
60
|
|
60
61
|
= Copyright
|
61
|
-
(C) 2003-
|
62
|
+
(C) 2003-2007 Daniel J. Berger, All Rights Reserved
|
62
63
|
|
63
64
|
= Warranty
|
64
65
|
This package is provided "as is" and without any express or
|
@@ -67,4 +68,4 @@
|
|
67
68
|
|
68
69
|
= Authors
|
69
70
|
Daniel J. Berger
|
70
|
-
Park Heesob
|
71
|
+
Park Heesob
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rbconfig'
|
4
|
+
include Config
|
5
|
+
|
6
|
+
desc 'Install the win32-mmap package (non-gem)'
|
7
|
+
task :install do
|
8
|
+
sitelibdir = CONFIG['sitelibdir']
|
9
|
+
installdir = File.join(sitelibdir, 'win32')
|
10
|
+
file = 'lib\win32\mmap.rb'
|
11
|
+
|
12
|
+
Dir.mkdir(installdir) unless File.exists?(installdir)
|
13
|
+
FileUtils.cp(file, installdir, :verbose => true)
|
14
|
+
end
|
15
|
+
|
16
|
+
Rake::TestTask.new do |t|
|
17
|
+
t.libs << 'test'
|
18
|
+
t.verbose = true
|
19
|
+
t.warning = true
|
20
|
+
t.test_files = FileList['test/tc_mmap.rb']
|
21
|
+
end
|
data/lib/win32/mmap.rb
CHANGED
@@ -11,12 +11,7 @@ module Win32
|
|
11
11
|
# Memory mapped files for MS Windows.
|
12
12
|
#
|
13
13
|
class MMap
|
14
|
-
VERSION = '0.2.
|
15
|
-
|
16
|
-
# This is a slightly different version of memcpy than what's provided
|
17
|
-
# in the Windows::MSVCRT::Buffer module. The difference is that the
|
18
|
-
# first argument is an address, not a char buffer.
|
19
|
-
MEMCPY = Win32API.new('msvcrt', 'memcpy', 'LPL', 'P')
|
14
|
+
VERSION = '0.2.2'
|
20
15
|
|
21
16
|
# All errors generated by Win32::MMap are of type MMap::Error.
|
22
17
|
#
|
@@ -129,7 +124,7 @@ module Win32
|
|
129
124
|
# * timeout
|
130
125
|
# * file
|
131
126
|
#
|
132
|
-
# Please see the documentation
|
127
|
+
# Please see the documentation on the individual attributes for
|
133
128
|
# further details. Note that, although these are accessors, they
|
134
129
|
# *must* be set in the constructor (if set at all). Setting them
|
135
130
|
# after the call to MMap.new will not have any effect.
|
@@ -151,6 +146,10 @@ module Win32
|
|
151
146
|
base_address open autolock timeout
|
152
147
|
/
|
153
148
|
|
149
|
+
@open = nil
|
150
|
+
@file = nil
|
151
|
+
@autolock = nil
|
152
|
+
|
154
153
|
opts.each{ |key, value|
|
155
154
|
key = key.to_s.downcase
|
156
155
|
unless valid.include?(key)
|
@@ -196,7 +195,7 @@ module Win32
|
|
196
195
|
end
|
197
196
|
|
198
197
|
if @open
|
199
|
-
@mh = OpenFileMapping
|
198
|
+
@mh = OpenFileMapping(@access, @inherit, @name)
|
200
199
|
else
|
201
200
|
@mh = CreateFileMapping(@fh, @inherit, @protection, 0, @size, @name)
|
202
201
|
end
|
@@ -307,7 +306,7 @@ module Win32
|
|
307
306
|
#--
|
308
307
|
# This replaces the getvar/setvar API from 0.1.0.
|
309
308
|
#
|
310
|
-
def method_missing(method_id, *args)
|
309
|
+
def method_missing(method_id, *args)
|
311
310
|
method = method_id.id2name
|
312
311
|
args = args.first if args.length == 1
|
313
312
|
|
@@ -319,27 +318,27 @@ module Win32
|
|
319
318
|
if mmap_lock
|
320
319
|
instance_variable_set("@#{method}", args)
|
321
320
|
marshal = Marshal.dump(@hash)
|
322
|
-
|
321
|
+
memcpy(@address, marshal)
|
323
322
|
mmap_unlock
|
324
323
|
end
|
325
324
|
else
|
326
325
|
instance_variable_set("@#{method}", args)
|
327
326
|
marshal = Marshal.dump(@hash)
|
328
|
-
|
327
|
+
memcpy(@address, marshal)
|
329
328
|
end
|
330
329
|
else # Getter
|
331
330
|
buf = 0.chr * @size
|
332
331
|
if @autolock
|
333
332
|
if mmap_lock
|
334
|
-
|
335
|
-
hash = Marshal.load(
|
333
|
+
memcpy(buf, @address, @size)
|
334
|
+
hash = Marshal.load(buf)
|
336
335
|
val = hash["#{method}"]
|
337
336
|
instance_variable_set("@#{method}", val)
|
338
337
|
mmap_unlock
|
339
338
|
end
|
340
339
|
else
|
341
|
-
|
342
|
-
hash = Marshal.load(
|
340
|
+
memcpy(buf, @address, @size)
|
341
|
+
hash = Marshal.load(buf)
|
343
342
|
val = hash["#{method}"]
|
344
343
|
instance_variable_set("@#{method}", val)
|
345
344
|
end
|
data/test/tc_mmap.rb
CHANGED
@@ -1,29 +1,48 @@
|
|
1
|
-
|
1
|
+
#####################################################################
|
2
2
|
# tc_mmap.rb
|
3
3
|
#
|
4
|
-
# Test suite for the win32-mmap package.
|
5
|
-
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift Dir.pwd
|
8
|
-
$LOAD_PATH.unshift Dir.pwd + '/lib'
|
9
|
-
|
4
|
+
# Test suite for the win32-mmap package. This should be run via the
|
5
|
+
# 'rake test' task.
|
6
|
+
#####################################################################
|
10
7
|
require 'test/unit'
|
11
8
|
require 'win32/mmap'
|
12
9
|
include Win32
|
13
10
|
|
14
|
-
# The order of the tests matters (for now)
|
15
11
|
class TC_Mmap < Test::Unit::TestCase
|
16
12
|
def setup
|
17
13
|
@mmap = MMap.new(:name => 'test', :size => 100)
|
18
14
|
end
|
19
15
|
|
20
16
|
def test_version
|
21
|
-
assert_equal('0.2.
|
17
|
+
assert_equal('0.2.2', MMap::VERSION)
|
22
18
|
end
|
23
19
|
|
24
|
-
def
|
20
|
+
def test_dynamic_string_value
|
25
21
|
assert_nothing_raised{ @mmap.foo = 'test' }
|
22
|
+
assert_nothing_raised{ @mmap.bar = 'alpha123' }
|
26
23
|
assert_equal('test', @mmap.foo)
|
24
|
+
assert_equal('alpha123', @mmap.bar)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_dynamic_integer_value
|
28
|
+
assert_nothing_raised{ @mmap.bar = 7 }
|
29
|
+
assert_nothing_raised{ @mmap.zero = 0 }
|
30
|
+
assert_equal(7, @mmap.bar)
|
31
|
+
assert_equal(0, @mmap.zero)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_dynamic_hash_value
|
35
|
+
assert_nothing_raised{ @mmap.ahash = {'foo' => 0} }
|
36
|
+
assert_nothing_raised{ @mmap.bhash = {'foo' => 0, 'bar' => 'hello'} }
|
37
|
+
assert_equal({'foo' => 0}, @mmap.ahash)
|
38
|
+
assert_equal({'foo' => 0, 'bar' => 'hello'}, @mmap.bhash)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_dynamic_array_value
|
42
|
+
assert_nothing_raised{ @mmap.aarray = [1, 'x', 3] }
|
43
|
+
assert_nothing_raised{ @mmap.barray = [{1 => 2}, [1,2,3], 'foo'] }
|
44
|
+
assert_equal([1, 'x', 3], @mmap.aarray)
|
45
|
+
assert_equal([{1=>2}, [1,2,3], 'foo'], @mmap.barray)
|
27
46
|
end
|
28
47
|
|
29
48
|
def test_valid_options
|
@@ -85,4 +104,4 @@ class TC_Mmap < Test::Unit::TestCase
|
|
85
104
|
def teardown
|
86
105
|
@mmap.close
|
87
106
|
end
|
88
|
-
end
|
107
|
+
end
|
data/win32-mmap.gemspec
CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |gem|
|
4
4
|
gem.name = "win32-mmap"
|
5
|
-
gem.version = "0.2.
|
5
|
+
gem.version = "0.2.2"
|
6
6
|
gem.author = "Daniel J. Berger"
|
7
7
|
gem.email = "djberg96@gmail.com"
|
8
8
|
gem.homepage = "http://www.rubyforge.org/projects/win32utils"
|
@@ -14,8 +14,8 @@ spec = Gem::Specification.new do |gem|
|
|
14
14
|
gem.files = Dir["lib/win32/*.rb"] + Dir["test/*"] + Dir["[A-Z]*"]
|
15
15
|
gem.files.reject! { |fn| fn.include? "CVS" }
|
16
16
|
gem.require_path = "lib"
|
17
|
-
gem.extra_rdoc_files = ["README", "CHANGES"]
|
18
|
-
gem.add_dependency("windows-pr", ">= 0.5.
|
17
|
+
gem.extra_rdoc_files = ["MANIFEST", "README", "CHANGES"]
|
18
|
+
gem.add_dependency("windows-pr", ">= 0.5.6")
|
19
19
|
end
|
20
20
|
|
21
21
|
if $0 == __FILE__
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.3
|
3
3
|
specification_version: 1
|
4
4
|
name: win32-mmap
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date:
|
6
|
+
version: 0.2.2
|
7
|
+
date: 2007-05-16 00:00:00 -06:00
|
8
8
|
summary: Memory mapped IO for Windows.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -30,13 +30,15 @@ authors:
|
|
30
30
|
- Daniel J. Berger
|
31
31
|
files:
|
32
32
|
- lib/win32/mmap.rb
|
33
|
+
- test/CVS
|
33
34
|
- test/tc_mmap.rb
|
34
35
|
- CHANGES
|
36
|
+
- CVS
|
35
37
|
- doc
|
36
38
|
- examples
|
37
|
-
- install.rb
|
38
39
|
- lib
|
39
40
|
- MANIFEST
|
41
|
+
- Rakefile
|
40
42
|
- README
|
41
43
|
- test
|
42
44
|
- win32-mmap.gemspec
|
@@ -45,6 +47,7 @@ test_files:
|
|
45
47
|
rdoc_options: []
|
46
48
|
|
47
49
|
extra_rdoc_files:
|
50
|
+
- MANIFEST
|
48
51
|
- README
|
49
52
|
- CHANGES
|
50
53
|
executables: []
|
@@ -61,5 +64,5 @@ dependencies:
|
|
61
64
|
requirements:
|
62
65
|
- - ">="
|
63
66
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.5.
|
67
|
+
version: 0.5.6
|
65
68
|
version:
|
data/install.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# For those who don't like gems...
|
2
|
-
require 'rbconfig'
|
3
|
-
require 'ftools'
|
4
|
-
include Config
|
5
|
-
|
6
|
-
sitelibdir = CONFIG['sitelibdir']
|
7
|
-
installdir = sitelibdir + '/win32'
|
8
|
-
file = 'lib\win32\mmap.rb'
|
9
|
-
|
10
|
-
Dir.mkdir(installdir) unless File.exists?(installdir)
|
11
|
-
File.copy(file, installdir, true)
|