gir_ffi 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/gir_ffi/arg_helper.rb +10 -3
- data/lib/gir_ffi/version.rb +1 -1
- data/test/base_test_helper.rb +2 -3
- data/test/ffi-gobject_introspection/i_object_info_test.rb +9 -14
- data/test/gir_ffi/arg_helper_test.rb +21 -0
- data/test/gir_ffi_test_helper.rb +1 -1
- data/test/integration/generated_pango_test.rb +25 -0
- data/test/introspection_test_helper.rb +1 -1
- metadata +6 -4
data/History.txt
CHANGED
data/lib/gir_ffi/arg_helper.rb
CHANGED
@@ -26,11 +26,14 @@ module GirFFI
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.ptr_to_typed_array type, ptr, size
|
29
|
-
|
29
|
+
case type
|
30
|
+
when Class
|
30
31
|
ptr_to_interface_array type, ptr, size
|
31
|
-
|
32
|
+
when Array
|
32
33
|
ptr_to_interface_pointer_array type[1], ptr, size
|
33
|
-
|
34
|
+
when FFI::Enum
|
35
|
+
ptr_to_enum_array type, ptr, size
|
36
|
+
when :utf8
|
34
37
|
ptr_to_utf8_array ptr, size
|
35
38
|
else
|
36
39
|
self.send "ptr_to_#{type}_array", ptr, size
|
@@ -73,6 +76,10 @@ module GirFFI
|
|
73
76
|
end
|
74
77
|
end
|
75
78
|
|
79
|
+
def self.ptr_to_enum_array enum, ptr, size
|
80
|
+
ptr_to_gint32_array(ptr, size).map {|val| enum[val] }
|
81
|
+
end
|
82
|
+
|
76
83
|
if RUBY_VERSION < "1.9"
|
77
84
|
def self.ptr_to_utf8 ptr
|
78
85
|
ptr.null? ? nil : ptr.read_string
|
data/lib/gir_ffi/version.rb
CHANGED
data/test/base_test_helper.rb
CHANGED
@@ -7,13 +7,12 @@ if RUBY_VERSION >= "1.9"
|
|
7
7
|
SimpleCov.start
|
8
8
|
end
|
9
9
|
|
10
|
-
require 'minitest/spec'
|
11
10
|
require 'minitest/autorun'
|
12
11
|
require 'rr'
|
13
12
|
|
14
13
|
Thread.abort_on_exception = true
|
15
14
|
|
16
|
-
class
|
15
|
+
class Minitest::Test
|
17
16
|
include RR::Adapters::TestUnit
|
18
17
|
|
19
18
|
def assert_nothing_raised
|
@@ -64,7 +63,7 @@ class MiniTest::Unit::TestCase
|
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
67
|
-
class
|
66
|
+
class Minitest::Spec
|
68
67
|
class << self
|
69
68
|
alias :setup :before
|
70
69
|
alias :teardown :after
|
@@ -1,20 +1,15 @@
|
|
1
1
|
require 'introspection_test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gir.require 'GObject', nil
|
10
|
-
@info = gir.find_by_name 'GObject', 'Object'
|
11
|
-
end
|
12
|
-
|
13
|
-
should "find a vfunc by name" do
|
14
|
-
assert_not_nil @info.find_vfunc("finalize")
|
15
|
-
end
|
3
|
+
describe GObjectIntrospection::IObjectInfo do
|
4
|
+
describe "#find_vfunc" do
|
5
|
+
setup do
|
6
|
+
gir = GObjectIntrospection::IRepository.default
|
7
|
+
gir.require 'GObject', nil
|
8
|
+
@info = gir.find_by_name 'GObject', 'Object'
|
16
9
|
end
|
17
10
|
|
11
|
+
should "find a vfunc by name" do
|
12
|
+
assert_not_nil @info.find_vfunc("finalize")
|
13
|
+
end
|
18
14
|
end
|
19
15
|
end
|
20
|
-
|
@@ -51,6 +51,27 @@ describe GirFFI::ArgHelper do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
describe "for pointers to arrays of enums" do
|
55
|
+
let(:enum) { FFI::Enum.new([:foo, 1, :bar, 2]) }
|
56
|
+
it "returns an empty array when passed a null pointer" do
|
57
|
+
result = GirFFI::ArgHelper.ptr_to_typed_array enum, FFI::Pointer.new(0), 0
|
58
|
+
result.must_equal []
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns an empty array when passed nil" do
|
62
|
+
result = GirFFI::ArgHelper.ptr_to_typed_array enum, nil, 0
|
63
|
+
result.must_equal []
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns an array of symbols when passed a pointer to ints" do
|
67
|
+
block = FFI::MemoryPointer.new(:int32, 2)
|
68
|
+
block.write_array_of_int32 [1, 2]
|
69
|
+
result = GirFFI::ArgHelper.ptr_to_typed_array enum, block, 2
|
70
|
+
result.must_equal [:foo, :bar]
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
54
75
|
describe "for pointers to arrays of base types" do
|
55
76
|
it "returns an empty array when passed a null pointer" do
|
56
77
|
result = GirFFI::ArgHelper.ptr_to_typed_array :gint32, FFI::Pointer.new(0), 0
|
data/test/gir_ffi_test_helper.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'gir_ffi_test_helper'
|
3
|
+
|
4
|
+
require 'gir_ffi'
|
5
|
+
|
6
|
+
GirFFI.setup :Pango
|
7
|
+
|
8
|
+
# Tests generated methods and functions in the Pango namespace.
|
9
|
+
describe Pango do
|
10
|
+
describe Pango::Language do
|
11
|
+
it "has a working method get_scripts" do
|
12
|
+
lang = Pango::Language.from_string 'ja'
|
13
|
+
result = lang.get_scripts
|
14
|
+
|
15
|
+
if GLib::SizedArray === result
|
16
|
+
scripts = result
|
17
|
+
else
|
18
|
+
ptr, size = *result
|
19
|
+
scripts = GLib::SizedArray.new Pango::Script, size, ptr
|
20
|
+
end
|
21
|
+
|
22
|
+
scripts.to_a.must_equal [:han, :katakana, :hiragana]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gir_ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '5.0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '5.0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rr
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- test/integration/method_lookup_test.rb
|
217
217
|
- test/integration/generated_gimarshallingtests_test.rb
|
218
218
|
- test/integration/generated_gio_test.rb
|
219
|
+
- test/integration/generated_pango_test.rb
|
219
220
|
- test/integration/generated_gobject_test.rb
|
220
221
|
- test/gir_ffi/builder/type/user_defined_test.rb
|
221
222
|
- test/gir_ffi/builder/type/enum_test.rb
|
@@ -382,6 +383,7 @@ test_files:
|
|
382
383
|
- test/integration/generated_gimarshallingtests_test.rb
|
383
384
|
- test/integration/generated_gio_test.rb
|
384
385
|
- test/integration/generated_gobject_test.rb
|
386
|
+
- test/integration/generated_pango_test.rb
|
385
387
|
- test/integration/generated_regress_test.rb
|
386
388
|
- test/integration/method_lookup_test.rb
|
387
389
|
- test/introspection_test_helper.rb
|