gir_ffi 0.14.0 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/lib/gir_ffi/builders/enum_builder.rb +9 -0
- data/lib/gir_ffi/info_ext.rb +1 -0
- data/lib/gir_ffi/info_ext/i_value_info.rb +25 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/test/gir_ffi/builders/enum_builder_test.rb +9 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c32084045b640a22901bdd0d256ce8b8df1ace345930d3e4fccfd0e598b82b19
|
4
|
+
data.tar.gz: 5ac1e06a4dd28b4589ca93e30c48218a4cffb40f18d9f8c87859fdd76460fc8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f70592c52c01f747ca9370007783231007ef535a0039337aaf42e46a17acbf2a54178b33c591ca8658e040496bb66a34ffd1f8126b2b323470783b97418418ae
|
7
|
+
data.tar.gz: fd92518d3541a1c46ebfe4758af76e8f746cf7ae355797a7f5736cdb4bc4b8444f6e9b4be7bf08712155759b11e5d697c2bdb522f3a4241337446204e5fb13c3
|
data/Changelog.md
CHANGED
@@ -26,6 +26,7 @@ module GirFFI
|
|
26
26
|
setup_ffi_type
|
27
27
|
klass.extend superclass
|
28
28
|
setup_constants
|
29
|
+
setup_value_constants
|
29
30
|
stub_methods
|
30
31
|
setup_inspect
|
31
32
|
end
|
@@ -40,6 +41,14 @@ module GirFFI
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
44
|
+
def setup_value_constants
|
45
|
+
info.values.each do |vinfo|
|
46
|
+
optionally_define_constant klass, vinfo.constant_name do
|
47
|
+
vinfo.value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
43
52
|
def setup_inspect
|
44
53
|
klass.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
|
45
54
|
def self.inspect
|
data/lib/gir_ffi/info_ext.rb
CHANGED
@@ -11,6 +11,7 @@ require 'gir_ffi/info_ext/i_registered_type_info'
|
|
11
11
|
require 'gir_ffi/info_ext/i_signal_info'
|
12
12
|
require 'gir_ffi/info_ext/i_type_info'
|
13
13
|
require 'gir_ffi/info_ext/i_unresolved_info'
|
14
|
+
require 'gir_ffi/info_ext/i_value_info'
|
14
15
|
require 'gir_ffi/info_ext/i_vfunc_info'
|
15
16
|
require 'gir_ffi/info_ext/safe_constant_name'
|
16
17
|
require 'gir_ffi/info_ext/safe_function_name'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GirFFI
|
4
|
+
module InfoExt
|
5
|
+
# Extensions for GObjectIntrospection::IValueInfo needed by GirFFI
|
6
|
+
module IValueInfo
|
7
|
+
def constant_name
|
8
|
+
upcased_name = name.upcase
|
9
|
+
if upcased_name =~ /^[0-9]/
|
10
|
+
"VALUE_#{upcased_name}"
|
11
|
+
else
|
12
|
+
upcased_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_callback_ffi_type
|
17
|
+
return :pointer if direction != :in
|
18
|
+
|
19
|
+
argument_type.to_callback_ffi_type
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
GObjectIntrospection::IValueInfo.send :include, GirFFI::InfoExt::IValueInfo
|
data/lib/gir_ffi/version.rb
CHANGED
@@ -3,20 +3,21 @@
|
|
3
3
|
require 'gir_ffi_test_helper'
|
4
4
|
|
5
5
|
describe GirFFI::Builders::EnumBuilder do
|
6
|
-
describe '
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
describe '#build_class' do
|
7
|
+
let(:info) { get_introspection_data 'Regress', 'TestEnum' }
|
8
|
+
let(:builder) { GirFFI::Builders::EnumBuilder.new info }
|
10
9
|
|
11
10
|
it 'makes the created type know its proper name' do
|
12
|
-
info = get_introspection_data 'Regress', 'TestEnum'
|
13
|
-
builder = GirFFI::Builders::EnumBuilder.new info
|
14
11
|
enum = builder.build_class
|
15
12
|
enum.inspect.must_equal 'Regress::TestEnum'
|
16
13
|
end
|
17
14
|
|
18
|
-
|
19
|
-
|
15
|
+
it 'adds constants for the values' do
|
16
|
+
enum = builder.build_class
|
17
|
+
enum::VALUE1.must_equal enum[:value1]
|
18
|
+
enum::VALUE2.must_equal enum[:value2]
|
19
|
+
enum::VALUE3.must_equal enum[:value3]
|
20
|
+
enum::VALUE4.must_equal enum[:value4]
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gir_ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matijs van Zuijlen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -284,6 +284,7 @@ files:
|
|
284
284
|
- lib/gir_ffi/info_ext/i_signal_info.rb
|
285
285
|
- lib/gir_ffi/info_ext/i_type_info.rb
|
286
286
|
- lib/gir_ffi/info_ext/i_unresolved_info.rb
|
287
|
+
- lib/gir_ffi/info_ext/i_value_info.rb
|
287
288
|
- lib/gir_ffi/info_ext/i_vfunc_info.rb
|
288
289
|
- lib/gir_ffi/info_ext/safe_constant_name.rb
|
289
290
|
- lib/gir_ffi/info_ext/safe_function_name.rb
|