mini_readline 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/mini_readline/raw_term/windows/win_32_api.rb +11 -21
- data/lib/mini_readline/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4f4d133f9c4b1b125c72e46f6fc975765bdfc84
|
4
|
+
data.tar.gz: 7d4998a8f1e72d332dabf336d3c18d5dc3fc046a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 804e9995ed300252cd50c0afdbd102d92c32b50e72a1264d264e7beeaba04acd76425d2e219411402ae558fcc529f43162f83100d6d2f5628027efdc6160db50
|
7
|
+
data.tar.gz: 923e4575825fac2d9862daf90742100e0cafe14519142424ef6408806f7a5c069a691a2d26ee183b4a521d6279f393e9b8ebdab9086ccf64db0d825e3b94cbfe
|
data/README.md
CHANGED
@@ -9,6 +9,12 @@ of Ruby programs. It will also try to correct a number of irritating issues
|
|
9
9
|
encountered when running cross platform environments. See Cross Platform
|
10
10
|
Portability Progress below for more details.
|
11
11
|
|
12
|
+
Finally, I know this code must seem to give off a sort of angry birds vibe
|
13
|
+
against the original rb-readline gem. This sort of thing is not good. I owe
|
14
|
+
a great debt of gratitude to the authors and maintainers of that vital code.
|
15
|
+
Their getting around the whole Win32API, dl obsolescence debacle saved me so
|
16
|
+
much time and frustration that words do not suffice. Thanks!
|
17
|
+
|
12
18
|
## Installation
|
13
19
|
|
14
20
|
Add this line to your application's Gemfile:
|
@@ -3,38 +3,28 @@
|
|
3
3
|
#* windows/win_32_api.rb - Support for selected low level Win32 API entry points.
|
4
4
|
module MiniReadline
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'fiddle'
|
7
7
|
|
8
|
-
#The classic \Win32API gem is deprecated, so we emulate it with
|
8
|
+
#The classic \Win32API gem is deprecated, so we emulate it with fiddle.
|
9
9
|
class Win32API
|
10
10
|
|
11
|
-
#A hash of DLL files used for one or more API entry points.
|
12
11
|
DLL = {}
|
12
|
+
TYPEMAP = {"0" => Fiddle::TYPE_VOID, "S" => Fiddle::TYPE_VOIDP, "I" => Fiddle::TYPE_LONG}
|
13
|
+
CALL_TYPE_TO_ABI = {:stdcall => 1, :cdecl => 1, nil => 1} #Taken from Fiddle::Importer
|
13
14
|
|
14
|
-
#Type mappings
|
15
|
-
TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
|
16
|
-
|
17
|
-
#Set up an API entry point.
|
18
15
|
def initialize(dllname, func, import, export = "0", calltype = :stdcall)
|
19
|
-
@proto =
|
20
|
-
handle = DLL[dllname] ||=
|
21
|
-
@func
|
16
|
+
@proto = import.join.tr("VPpNnLlIi", "0SSI").chomp('0').split('')
|
17
|
+
handle = DLL[dllname] ||= Fiddle.dlopen(dllname)
|
18
|
+
@func = Fiddle::Function.new(handle[func], TYPEMAP.values_at(*@proto), CALL_TYPE_TO_ABI[calltype])
|
22
19
|
end
|
23
20
|
|
24
|
-
#Call the Win 32 API entry point with appropriate arguments.
|
25
|
-
#<br>Endemic Code Smells
|
26
|
-
#* :reek:FeatureEnvy
|
27
21
|
def call(*args)
|
28
|
-
args.each_with_index do |
|
29
|
-
|
30
|
-
|
31
|
-
args[index], = [arg == 0 ? nil : arg].pack("p").unpack("l!*")
|
32
|
-
when "I"
|
33
|
-
args[index], = [arg].pack("I").unpack("i")
|
34
|
-
end
|
22
|
+
args.each_with_index do |x, i|
|
23
|
+
args[i], = [x == 0 ? nil : x].pack("p").unpack("l!*") if @proto[i] == "S" && !x.is_a?(Fiddle::Pointer)
|
24
|
+
args[i], = [x].pack("I").unpack("i") if @proto[i] == "I"
|
35
25
|
end
|
36
26
|
|
37
|
-
@func.call(args).to_i || 0
|
27
|
+
@func.call(*args).to_i || 0
|
38
28
|
end
|
39
29
|
|
40
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_readline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -185,9 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.2
|
188
|
+
rubygems_version: 2.5.2
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: A simplified replacement for readline.
|
192
192
|
test_files: []
|
193
|
-
has_rdoc:
|