libui 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/libui/ffi.rb +22 -20
- data/lib/libui/version.rb +1 -1
- 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: a70af9cdc5c6bdd0ff971474bfc3e7c7facaf9e3cd04af4375d40953e3827b7d
|
4
|
+
data.tar.gz: 19b9c62a9003a5a097ff1643a783fa3a9bb72d36c06e1eb65f361d7679f51398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9df4e5b0fb7a71c02b9b8715ebecf02cf0367829448d959ed1bd89fca65fd40fa51db37ee38b58546d60edb33c03719a183116f64fd95149081de711d095b9cb
|
7
|
+
data.tar.gz: 27daac95b0cc02f44ca94b9ea11e3f91ef983806a1bef3319689d4dc60596f600d0673369fe165fe6e01470dae61dcf4ba6f6c80fd0cc5df5cf26c291a547466
|
data/README.md
CHANGED
@@ -11,7 +11,14 @@
|
|
11
11
|
gem install libui
|
12
12
|
```
|
13
13
|
|
14
|
-
The
|
14
|
+
* The gem package contains the [official release](https://github.com/andlabs/libui/releases/tag/alpha4.1) of the libui shared library versions 4.1 for Windows, Mac, and Linux.
|
15
|
+
* Namely `libui.dll`, `libui.dylib`, and `libui.so` (only 1.4MB in total).
|
16
|
+
* No dependency
|
17
|
+
* The libui gem uses the standard Ruby library [Fiddle](https://github.com/ruby/fiddle) to call C functions.
|
18
|
+
|
19
|
+
| Windows | Mac | Linux |
|
20
|
+
|---------|-----|-------|
|
21
|
+
|<img src="https://user-images.githubusercontent.com/5798442/103118046-900ea780-46b0-11eb-81fc-32626762e4df.png">|<img src="https://user-images.githubusercontent.com/5798442/103118059-99980f80-46b0-11eb-9d12-324ec4d297c9.png">|<img src="https://user-images.githubusercontent.com/5798442/103118068-a0bf1d80-46b0-11eb-8c5c-3bdcc3dcfb26.png">|
|
15
22
|
|
16
23
|
## Usage
|
17
24
|
|
@@ -46,6 +53,8 @@ See [examples](https://github.com/kojix2/libui/tree/main/examples) directory.
|
|
46
53
|
|
47
54
|
### General Rules
|
48
55
|
|
56
|
+
Compared to original libui written in C,
|
57
|
+
|
49
58
|
* The method names are snake_case.
|
50
59
|
* If the last argument is nil, it can be omitted.
|
51
60
|
* You can pass a block as a callback.
|
data/lib/libui/ffi.rb
CHANGED
@@ -12,9 +12,15 @@ module Fiddle
|
|
12
12
|
module Importer
|
13
13
|
def parse_signature(signature, tymap = nil)
|
14
14
|
tymap ||= {}
|
15
|
-
|
15
|
+
ctype, func, args = case compact(signature)
|
16
|
+
when /^(?:[\w\*\s]+)\(\*(\w+)\((.*?)\)\)(?:\[\w*\]|\(.*?\));?$/
|
17
|
+
[TYPE_VOIDP, Regexp.last_match(1), Regexp.last_match(2)]
|
18
|
+
when /^([\w\*\s]+[*\s])(\w+)\((.*?)\);?$/
|
19
|
+
[parse_ctype(Regexp.last_match(1).strip, tymap), Regexp.last_match(2), Regexp.last_match(3)]
|
20
|
+
else
|
21
|
+
raise("can't parserake the function prototype: #{signature}")
|
22
|
+
end
|
16
23
|
symname = func
|
17
|
-
ctype = parse_ctype(ret, tymap)
|
18
24
|
inner_funcs = [] # Added
|
19
25
|
argtype = split_arguments(args).collect.with_index do |arg, idx| # Added with_index
|
20
26
|
# Check if it is a function pointer or not
|
@@ -31,23 +37,6 @@ module Fiddle
|
|
31
37
|
[symname, ctype, argtype, inner_funcs]
|
32
38
|
end
|
33
39
|
|
34
|
-
# refactored
|
35
|
-
def split_signature(signature)
|
36
|
-
case compact(signature)
|
37
|
-
when /^(?:[\w*\s]+)\(\*(\w+)\((.*?)\)\)(?:\[\w*\]|\(.*?\));?$/
|
38
|
-
ret = TYPE_VOIDP
|
39
|
-
func = Regexp.last_match(1)
|
40
|
-
args = Regexp.last_match(2)
|
41
|
-
when /^([\w*\s]+[*\s])(\w+)\((.*?)\);?$/
|
42
|
-
ret = Regexp.last_match(1).strip
|
43
|
-
func = Regexp.last_match(2)
|
44
|
-
args = Regexp.last_match(3)
|
45
|
-
else
|
46
|
-
raise("can't parse the function prototype: #{signature}")
|
47
|
-
end
|
48
|
-
[ret, func, args]
|
49
|
-
end
|
50
|
-
|
51
40
|
def extern(signature, *opts)
|
52
41
|
symname, ctype, argtype, inner_funcs = parse_signature(signature, type_alias)
|
53
42
|
opt = parse_bind_options(opts)
|
@@ -284,7 +273,20 @@ module LibUI
|
|
284
273
|
try_extern 'void uiRadioButtonsOnSelected(uiRadioButtons *r, void (*f)(uiRadioButtons *, void *), void *data)'
|
285
274
|
try_extern 'uiRadioButtons *uiNewRadioButtons(void)'
|
286
275
|
|
287
|
-
# uiDateTimePicker
|
276
|
+
# uiDateTimePicker
|
277
|
+
|
278
|
+
# time.h
|
279
|
+
TM = struct [
|
280
|
+
'int tm_sec',
|
281
|
+
'int tm_min',
|
282
|
+
'int tm_hour',
|
283
|
+
'int tm_mday',
|
284
|
+
'int tm_mon',
|
285
|
+
'int tm_year',
|
286
|
+
'int tm_wday',
|
287
|
+
'int tm_yday',
|
288
|
+
'int tm_isdst'
|
289
|
+
]
|
288
290
|
|
289
291
|
try_extern 'void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)'
|
290
292
|
try_extern 'void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)'
|
data/lib/libui/version.rb
CHANGED
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-26 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.2.3
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Ruby bindings to libui
|