ffi-win32-extensions 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES +4 -0
- data/README +3 -2
- data/ffi-win32-extensions.gemspec +1 -1
- data/lib/ffi/win32/extensions.rb +18 -4
- data/test/test_ffi_extensions.rb +7 -1
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 222fca76d4a26f80510379101b6cdcbb35983631
|
4
|
+
data.tar.gz: c552a2d5f78aafd64c993fed870819d3f983b4b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed1b217b84bf3bc93e382766f156aa8bfc88726a8cf20a51527d1f88bcff208b2e6bf729b70c61d06c5196219e82470b7a7c24d199efc6bdb79b2fb1648defa3
|
7
|
+
data.tar.gz: dd629833b40839498f2a49688a4cbe12bb8dfb6d78f81acc6a4dbb631a1710b4fa3e79d152a584a6a7df76391abcfe66b7d89beab212d878f53190d5c1da0a7f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES
CHANGED
data/README
CHANGED
@@ -18,8 +18,9 @@
|
|
18
18
|
|
19
19
|
The following String instance methods have been added:
|
20
20
|
|
21
|
-
* wincode
|
22
|
-
* wstrip
|
21
|
+
* wincode - Converts a string to UTF-16LE for use in wide char functions.
|
22
|
+
* wstrip - Like String#strip, but for wide strings.
|
23
|
+
* read_wide_string - Reads a Ruby string up to the first double null.
|
23
24
|
|
24
25
|
Example:
|
25
26
|
|
data/lib/ffi/win32/extensions.rb
CHANGED
@@ -41,13 +41,20 @@ module FFI
|
|
41
41
|
# The message will always be English regardless of your locale.
|
42
42
|
#
|
43
43
|
def windows_error_message(function, err=FFI.errno)
|
44
|
-
|
45
|
-
|
44
|
+
error_message = ''
|
45
|
+
|
46
|
+
# ARGUMENT_ARRAY + SYSTEM + MAX_WIDTH_MASK
|
47
|
+
flags = 0x00001000 | 0x00000200 | 0x000000FF
|
46
48
|
|
47
49
|
# 0x0409 = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)
|
48
|
-
|
50
|
+
# We use English for errors because Ruby uses English for errors.
|
51
|
+
|
52
|
+
FFI::MemoryPointer.new(:char, 1024) do |buf|
|
53
|
+
length = FormatMessage(flags, nil, err , 0x0409, buf, buf.size, nil)
|
54
|
+
error_message = function + ': ' + buf.read_string(length).strip
|
55
|
+
end
|
49
56
|
|
50
|
-
|
57
|
+
error_message
|
51
58
|
end
|
52
59
|
|
53
60
|
# Raises a Windows specific error using SystemCallError that is based on
|
@@ -79,4 +86,11 @@ class String
|
|
79
86
|
rescue
|
80
87
|
nil
|
81
88
|
end
|
89
|
+
|
90
|
+
# Read a wide character string up until the first double null, and delete
|
91
|
+
# any remaining null characters.
|
92
|
+
#
|
93
|
+
def read_wide_string
|
94
|
+
self[/^.*?(?=\x00{2})/].delete(0.chr)
|
95
|
+
end
|
82
96
|
end
|
data/test/test_ffi_extensions.rb
CHANGED
@@ -10,8 +10,14 @@ class TC_FFI_Win32_Extensions < Test::Unit::TestCase
|
|
10
10
|
assert_respond_to(@ptr, :read_array_of_string)
|
11
11
|
end
|
12
12
|
|
13
|
-
test 'windows_error_message' do
|
13
|
+
test 'windows_error_message basic functionality' do
|
14
14
|
assert_respond_to(FFI, :windows_error_message)
|
15
|
+
assert_kind_of(String, FFI.windows_error_message('foo'))
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'windows_error_message returns the expected value' do
|
19
|
+
expected = 'foo: The operation completed successfully.'
|
20
|
+
assert_equal(expected, FFI.windows_error_message('foo', 0))
|
15
21
|
end
|
16
22
|
|
17
23
|
test 'raise_windows_error' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-win32-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
|
31
31
|
tGSHgAmcLlkdGgan182qsE/4kKM=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2016-
|
33
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: ffi
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.4
|
111
|
+
rubygems_version: 2.6.4
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Extends the FFI and String classes on MS Windows
|
metadata.gz.sig
CHANGED
Binary file
|