libui 0.0.7 → 0.0.8
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/libui.rb +11 -2
- data/lib/libui/ffi.rb +20 -16
- data/lib/libui/version.rb +1 -1
- data/vendor/libui.so +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02ee9e67a91414cbea40a50448a58bbb320f8962f34a35fa9c26d7ed0019878d
|
|
4
|
+
data.tar.gz: cfde88b2432abbf23f9dd0d195db0258c143bfd1ff339f51b3112ccaf4742af2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb131ab13e11e6573058c0ec611c7467557756904b49d4121541f4075518958d3fdf2adc74e21d52f0f433c537faeffd6a77ab4162f7d42321fdec75437d1be0
|
|
7
|
+
data.tar.gz: 0dc6139433b79bec3e0a096f376db6af7eedc6b989ccab25bf4d3a1123afc75d053d43625d5302122952b2a527a8a17665ec9bc1472c1574f5ae4262bef80197
|
data/README.md
CHANGED
data/lib/libui.rb
CHANGED
|
@@ -41,14 +41,23 @@ module LibUI
|
|
|
41
41
|
if arg.is_a?(Proc)
|
|
42
42
|
# The types of the function arguments are recorded beforehand.
|
|
43
43
|
# See the monkey patch in ffi.rb.
|
|
44
|
-
Fiddle::Closure::BlockCaller.new(
|
|
44
|
+
callback = Fiddle::Closure::BlockCaller.new(
|
|
45
|
+
*func.callback_argument_types[idx][1..2], &arg
|
|
46
|
+
)
|
|
47
|
+
# Protect from GC
|
|
48
|
+
# See https://github.com/kojix2/LibUI/issues/8
|
|
49
|
+
receiver = args[0]
|
|
50
|
+
callbacks = receiver.instance_variable_get(:@callbacks) || []
|
|
51
|
+
callbacks << callback
|
|
52
|
+
receiver.instance_variable_set(:@callbacks, callback)
|
|
53
|
+
callback
|
|
45
54
|
else
|
|
46
55
|
arg
|
|
47
56
|
end
|
|
48
57
|
end
|
|
49
58
|
|
|
50
59
|
# Make it possible to omit the last nil. This may be an over-optimization.
|
|
51
|
-
siz = func.
|
|
60
|
+
siz = func.argument_types.size - 1
|
|
52
61
|
args[siz] = nil if args.size == siz
|
|
53
62
|
|
|
54
63
|
FFI.public_send(original_method_name, *args)
|
data/lib/libui/ffi.rb
CHANGED
|
@@ -4,9 +4,11 @@ require 'fiddle/import'
|
|
|
4
4
|
|
|
5
5
|
module Fiddle
|
|
6
6
|
# Change the Function to hold a little more information.
|
|
7
|
-
# FIXME: Give inner_function a better name.
|
|
8
7
|
class Function
|
|
9
|
-
|
|
8
|
+
# Note:
|
|
9
|
+
# Ruby 2.7 Fiddle::Function dose not have @argument_types
|
|
10
|
+
# Ruby 3.0 Fiddle::Function has @argument_types
|
|
11
|
+
attr_accessor :callback_argument_types, :argument_types
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
module Importer
|
|
@@ -21,32 +23,34 @@ module Fiddle
|
|
|
21
23
|
raise("can't parserake the function prototype: #{signature}")
|
|
22
24
|
end
|
|
23
25
|
symname = func
|
|
24
|
-
|
|
25
|
-
argtype = split_arguments(args).collect.with_index do |arg, idx|
|
|
26
|
+
callback_argument_types = {} # Added
|
|
27
|
+
argtype = split_arguments(args).collect.with_index do |arg, idx| # Added with_index
|
|
26
28
|
# Check if it is a function pointer or not
|
|
27
|
-
if arg =~ /\(\*.*\)\(.*\)/
|
|
29
|
+
if arg =~ /\(\*.*\)\(.*\)/ # Added
|
|
28
30
|
# From the arguments, create a notation that looks like a function declaration
|
|
29
31
|
# int(*f)(int *, void *) -> int f(int *, void *)
|
|
30
|
-
func_arg = arg.sub('(*', ' ').sub(')', '')
|
|
32
|
+
func_arg = arg.sub('(*', ' ').sub(')', '') # Added
|
|
31
33
|
# Use Fiddle's parse_signature method again.
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
+
callback_argument_types[idx] = parse_signature(func_arg) # Added
|
|
35
|
+
end
|
|
34
36
|
parse_ctype(arg, tymap)
|
|
35
37
|
end
|
|
36
|
-
# Added
|
|
37
|
-
[symname, ctype, argtype,
|
|
38
|
+
# Added callback_argument_types. Original method return only 3 values.
|
|
39
|
+
[symname, ctype, argtype, callback_argument_types]
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
def extern(signature, *opts)
|
|
41
|
-
symname, ctype, argtype,
|
|
43
|
+
symname, ctype, argtype, callback_argument_types = parse_signature(signature, type_alias)
|
|
42
44
|
opt = parse_bind_options(opts)
|
|
43
|
-
|
|
45
|
+
func = import_function(symname, ctype, argtype, opt[:call_type])
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
func.callback_argument_types = callback_argument_types # Added
|
|
48
|
+
# Ruby 2.7 Fiddle::Function dose not have @argument_types
|
|
49
|
+
# Ruby 3.0 Fiddle::Function has @argument_types
|
|
50
|
+
func.argument_types = argtype
|
|
47
51
|
|
|
48
52
|
name = symname.gsub(/@.+/, '')
|
|
49
|
-
@func_map[name] =
|
|
53
|
+
@func_map[name] = func
|
|
50
54
|
# define_method(name){|*args,&block| f.call(*args,&block)}
|
|
51
55
|
begin
|
|
52
56
|
/^(.+?):(\d+)/ =~ caller.first
|
|
@@ -61,7 +65,7 @@ module Fiddle
|
|
|
61
65
|
end
|
|
62
66
|
EOS
|
|
63
67
|
module_function(name)
|
|
64
|
-
|
|
68
|
+
func
|
|
65
69
|
end
|
|
66
70
|
end
|
|
67
71
|
end
|
data/lib/libui/version.rb
CHANGED
data/vendor/libui.so
CHANGED
|
File without changes
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: libui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kojix2
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-01-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
117
117
|
- !ruby/object:Gem::Version
|
|
118
118
|
version: '0'
|
|
119
119
|
requirements: []
|
|
120
|
-
rubygems_version: 3.
|
|
120
|
+
rubygems_version: 3.1.4
|
|
121
121
|
signing_key:
|
|
122
122
|
specification_version: 4
|
|
123
123
|
summary: Ruby bindings to libui
|