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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0214c682062d1e669d2ec2df579d91466b2d0330205231d00734e3d9b21fc57
4
- data.tar.gz: 2bce2e4f6edf26bd2442e7205ef10ad59529f1e16f2a88aa0a282cb61d623ced
3
+ metadata.gz: a70af9cdc5c6bdd0ff971474bfc3e7c7facaf9e3cd04af4375d40953e3827b7d
4
+ data.tar.gz: 19b9c62a9003a5a097ff1643a783fa3a9bb72d36c06e1eb65f361d7679f51398
5
5
  SHA512:
6
- metadata.gz: f700b08bb46f282b7298f7530bbbade2a59fcde144e54af97bb01a1766a98b3a133b10e064cd62a69621e2d61ff9d587bff17d850f96bb23b4e5c2ee101f97a7
7
- data.tar.gz: 8571472b2ceb6fa2cd5d6627fce64c896e2ae651012fd8d949f9a94a6cf70dc48df6af7f379652c956b3b1e5e6725fb14465d616abdae776e9ec635c0c4150f9
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 libui gem uses the standard Ruby library [Fiddle](https://github.com/ruby/fiddle) to call C functions. And this gem contains the official release of the libui shared library version 4.1 for Windows, Mac, and Linux. That means there is no need to install anything other than this gem.
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.
@@ -12,9 +12,15 @@ module Fiddle
12
12
  module Importer
13
13
  def parse_signature(signature, tymap = nil)
14
14
  tymap ||= {}
15
- ret, func, args = split_signature(signature)
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 # Fixme: struct tm
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)'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LibUI
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.7'
5
5
  end
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.6
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-22 00:00:00.000000000 Z
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.1.4
120
+ rubygems_version: 3.2.3
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Ruby bindings to libui