gir_ffi 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +9 -1
  3. data/Gemfile +1 -1
  4. data/README.md +3 -2
  5. data/lib/ffi-glib/bytes.rb +0 -14
  6. data/lib/ffi-glib/hash_table.rb +0 -1
  7. data/lib/ffi-gobject/object.rb +7 -0
  8. data/lib/ffi-gobject_introspection/i_base_info.rb +4 -0
  9. data/lib/ffi-gobject_introspection/lib.rb +1 -0
  10. data/lib/gir_ffi/boxed_base.rb +2 -2
  11. data/lib/gir_ffi/builders/callback_argument_builder.rb +3 -1
  12. data/lib/gir_ffi/builders/closure_return_value_builder.rb +0 -1
  13. data/lib/gir_ffi/builders/module_builder.rb +9 -2
  14. data/lib/gir_ffi/builders/null_class_builder.rb +1 -0
  15. data/lib/gir_ffi/builders/registered_type_builder.rb +5 -1
  16. data/lib/gir_ffi/callback_base.rb +2 -2
  17. data/lib/gir_ffi/enum_base.rb +2 -2
  18. data/lib/gir_ffi/in_out_pointer.rb +1 -1
  19. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +1 -1
  20. data/lib/gir_ffi/object_base.rb +24 -8
  21. data/lib/gir_ffi/sized_array.rb +2 -2
  22. data/lib/gir_ffi/version.rb +1 -1
  23. data/lib/gir_ffi/zero_terminated.rb +12 -1
  24. data/lib/gir_ffi-base/glib/boolean.rb +2 -2
  25. data/tasks/test.rake +25 -23
  26. data/test/base_test_helper.rb +3 -4
  27. data/test/ffi-gobject/object_test.rb +10 -4
  28. data/test/ffi-gobject_introspection/i_property_info_test.rb +3 -2
  29. data/test/gir_ffi/builders/module_builder_test.rb +26 -3
  30. data/test/gir_ffi/object_base_test.rb +2 -2
  31. data/test/integration/generated_everything_test.rb +428 -0
  32. data/test/integration/generated_gimarshallingtests_test.rb +17 -0
  33. data/test/integration/generated_gtop_test.rb +21 -0
  34. data/test/integration/generated_regress_test.rb +734 -0
  35. data/test/integration/generated_warnlib_test.rb +47 -0
  36. data/test/introspection_test_helper.rb +2 -0
  37. data/test/lib/Makefile.am +82 -16
  38. data/test/lib/configure.ac +3 -0
  39. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be09f0c7b882ddc0bb3dfdc7d0c78a799f364523
4
- data.tar.gz: 0a5cff8324417259a1092c686e9d3ffc492efebf
3
+ metadata.gz: a1ad50242508ce93d6d0b6751cd18b550f3f8137
4
+ data.tar.gz: b4ea1af0594d95c7293edabbf4f108506b2d46c4
5
5
  SHA512:
6
- metadata.gz: 26639dd911992a83273376f6421f9eee8f802386d3b345a62feacd4b6a7d5fac9f7cc55cba160428ceb59c7e4740404b990761892fddef705bb4dd94bcf1fa21
7
- data.tar.gz: 63a71dd6cf133b0e7f0dcaf335961297b968e3cc3293170e9f5b9daf9709ad6562cc1df92e8c4b4749af61b9966a8540153a316002ef2b0b8bf817dd02199837
6
+ metadata.gz: 71bc54a2a76ddaa7a8d3633c02ce1ccc123ca036031e7c207fb6808aa81c995e30bf2eb4ffa7bc78321401f09887d1118862e7178534d12bc962c32099889355
7
+ data.tar.gz: 099c5f239a3f1d7222871f1ad3f78730e733dbbc6c8f7fe278740b261390271f7aa072174ccf3a92b3246ead586d52bd29c09c22596474ede0282ef612c86ea7
data/Changelog.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.4 / 2015-12-03
4
+
5
+ * Handle classes with lower-case names
6
+ * Make ObjectBase a DataConverter so FFI handles it natively
7
+ * Use more of gobject-introspection's test libraries for testing
8
+ * Simplify constructor overrides: Custom initializers will no longer be
9
+ overwritten when setting up the corresponding constructor.
10
+ * Override GObject::Object.new to not require a GType argument
11
+
3
12
  ## 0.8.3 / 2015-11-13
4
13
 
5
14
  * Fix handling of signal handler return values
@@ -50,7 +59,6 @@
50
59
  * Increase refcount for :object return values of vfuncs with full transfer
51
60
  * Increase refcount for outgoing :object arguments of vfuncs with full ownership
52
61
  transfer
53
- * Apply more RuboCop rules
54
62
  * Support Ruby 2.2
55
63
  * Rename several methods. The old names are deprecated and will be removed in 0.8.0.
56
64
 
data/Gemfile CHANGED
@@ -8,6 +8,6 @@ if ENV['CI']
8
8
  gem 'coveralls', type: :development
9
9
  end
10
10
  else
11
- gem 'simplecov', '~> 0.10.0', type: :development, platform: :mri
11
+ gem 'simplecov', '~> 0.11.0', type: :development, platform: :mri
12
12
  gem 'pry', '~> 0.10.0', type: :development
13
13
  end
data/README.md CHANGED
@@ -64,8 +64,9 @@ GirFFI is developed on Debian sid, and tested through Travis CI on Ubuntu
64
64
  12.04. Older versions of gobject-introspection than the ones used there
65
65
  are therefore not officially supported (although they may work).
66
66
 
67
- On Debian and Ubuntu, installing `libgirepository1.0-dev` and
68
- `gobject-introspection` should be enough to get `rake test` working.
67
+ On Debian and Ubuntu, installing `libgirepository1.0-dev`,
68
+ `gobject-introspection` and `gir1.2-gtop-2.0` should be enough to get
69
+ `rake test` working.
69
70
 
70
71
  GirFFI has not been tested on Mac OS X or Microsoft Windows. YMMV.
71
72
 
@@ -32,20 +32,6 @@ module GLib
32
32
  end
33
33
  end
34
34
 
35
- # Why redefine new here? The class builder will only define the full
36
- # version of 'new' on first call, causing both new and initialize to be
37
- # defined. This overwrites the custom version of initialize below.
38
- # TODO: Improve class builder so this trick is not needed.
39
- class << self
40
- undef new
41
- end
42
-
43
- def self.new(*args)
44
- obj = allocate
45
- obj.__send__ :initialize, *args
46
- obj
47
- end
48
-
49
35
  def initialize(arr)
50
36
  data = GirFFI::SizedArray.from :guint8, arr.size, arr
51
37
  store_pointer Lib.g_bytes_new data.to_ptr, data.size
@@ -78,6 +78,5 @@ module GLib
78
78
  lib = ::GLib::Lib.ffi_libraries.first
79
79
  lib.find_function(name)
80
80
  end
81
-
82
81
  end
83
82
  end
@@ -5,6 +5,13 @@ module GObject
5
5
  class Object
6
6
  setup_method 'new'
7
7
 
8
+ def initialize_with_automatic_gtype(properties)
9
+ initialize_without_automatic_gtype(self.class.gtype, properties)
10
+ end
11
+
12
+ alias_method :initialize_without_automatic_gtype, :initialize
13
+ alias_method :initialize, :initialize_with_automatic_gtype
14
+
8
15
  def store_pointer(ptr)
9
16
  super
10
17
  klass = self.class
@@ -106,6 +106,10 @@ module GObjectIntrospection
106
106
  Lib.g_base_info_is_deprecated @gobj
107
107
  end
108
108
 
109
+ def attribute(name)
110
+ Lib.g_base_info_get_attribute @gobj, name
111
+ end
112
+
109
113
  def self.wrap(ptr)
110
114
  new ptr unless ptr.null?
111
115
  end
@@ -68,6 +68,7 @@ module GObjectIntrospection
68
68
 
69
69
  attach_function :g_base_info_ref, [:pointer], :void
70
70
  attach_function :g_base_info_unref, [:pointer], :void
71
+ attach_function :g_base_info_get_attribute, [:pointer, :string], :string
71
72
  attach_function :g_base_info_get_type, [:pointer], :IInfoType
72
73
  attach_function :g_base_info_get_name, [:pointer], :string
73
74
  attach_function :g_base_info_get_namespace, [:pointer], :string
@@ -17,8 +17,8 @@ module GirFFI
17
17
  value.struct
18
18
  end
19
19
 
20
- def self.get_value_from_pointer(pointer)
21
- pointer.to_ptr
20
+ def self.get_value_from_pointer(pointer, offset)
21
+ pointer + offset
22
22
  end
23
23
 
24
24
  def self.copy_value_to_pointer(value, pointer, offset = 0)
@@ -32,7 +32,9 @@ module GirFFI
32
32
  end
33
33
 
34
34
  def capture_variable_name
35
- result_name if [:out, :inout].include? direction unless array_arg
35
+ unless array_arg
36
+ result_name if [:out, :inout].include? direction
37
+ end
36
38
  end
37
39
 
38
40
  def pre_conversion
@@ -11,4 +11,3 @@ module GirFFI
11
11
  end
12
12
  end
13
13
  end
14
-
@@ -33,12 +33,19 @@ module GirFFI
33
33
  end
34
34
 
35
35
  def build_namespaced_class(classname)
36
- info = gir.find_by_name @namespace, classname.to_s
36
+ info = find_namespaced_class_info(classname)
37
+ Builder.build_class info
38
+ end
39
+
40
+ def find_namespaced_class_info(classname)
41
+ name = classname.to_s
42
+ info = gir.find_by_name(@namespace, name) ||
43
+ gir.find_by_name(@namespace, name.sub(/^./, &:downcase))
37
44
  unless info
38
45
  raise NameError,
39
46
  "Class #{classname} not found in namespace #{@namespace}"
40
47
  end
41
- Builder.build_class info
48
+ info
42
49
  end
43
50
 
44
51
  private
@@ -1,5 +1,6 @@
1
1
  module GirFFI
2
2
  module Builders
3
+ # Class builder that does nothing
3
4
  class NullClassBuilder
4
5
  def setup_method(_)
5
6
  nil
@@ -42,7 +42,11 @@ module GirFFI
42
42
 
43
43
  def define_method(method_info)
44
44
  if method_info.constructor?
45
- build_class.class_eval InitializerBuilder.new(method_info).method_definition
45
+ initializer_builder = InitializerBuilder.new(method_info)
46
+ initializer_name = initializer_builder.method_name.to_sym
47
+ unless build_class.private_instance_methods(false).include? initializer_name
48
+ build_class.class_eval initializer_builder.method_definition
49
+ end
46
50
  build_class.class_eval ConstructorBuilder.new(method_info).method_definition
47
51
  else
48
52
  build_class.class_eval FunctionBuilder.new(method_info).method_definition
@@ -69,8 +69,8 @@ module GirFFI
69
69
  pointer.put_pointer 0, to_native(value, nil)
70
70
  end
71
71
 
72
- def self.get_value_from_pointer(pointer)
73
- from_native pointer.get_pointer(0), nil
72
+ def self.get_value_from_pointer(pointer, offset)
73
+ from_native pointer.get_pointer(offset), nil
74
74
  end
75
75
  end
76
76
  end
@@ -34,8 +34,8 @@ module GirFFI
34
34
  pointer.put_int32 0, to_native(value, nil)
35
35
  end
36
36
 
37
- def get_value_from_pointer(pointer)
38
- from_native pointer.get_int32(0), nil
37
+ def get_value_from_pointer(pointer, offset)
38
+ from_native pointer.get_int32(offset), nil
39
39
  end
40
40
 
41
41
  def setup_and_call(method, arguments, &block)
@@ -17,7 +17,7 @@ module GirFFI
17
17
  def to_value
18
18
  case value_ffi_type
19
19
  when Module
20
- value_ffi_type.get_value_from_pointer(self)
20
+ value_ffi_type.get_value_from_pointer(self, 0)
21
21
  when Symbol
22
22
  send("get_#{value_ffi_type}", 0)
23
23
  else
@@ -17,7 +17,7 @@ module GirFFI
17
17
  return info if info && info.method?
18
18
  end
19
19
 
20
- def find_method(method)
20
+ def find_method(_method)
21
21
  raise 'Must be overridden in subclass'
22
22
  end
23
23
  end
@@ -1,6 +1,30 @@
1
+ require 'gir_ffi/class_base'
2
+
1
3
  module GirFFI
2
4
  # Base class for all generated classes of type :object.
3
5
  class ObjectBase < ClassBase
6
+ extend FFI::DataConverter
7
+
8
+ def self.native_type
9
+ FFI::Type::POINTER
10
+ end
11
+
12
+ def self.to_ffi_type
13
+ self
14
+ end
15
+
16
+ def self.to_native(it, _)
17
+ it.to_ptr
18
+ end
19
+
20
+ def self.get_value_from_pointer(pointer, offset = 0)
21
+ pointer.get_pointer offset
22
+ end
23
+
24
+ def self.copy_value_to_pointer(value, pointer, offset = 0)
25
+ pointer.put_pointer offset, value.to_ptr
26
+ end
27
+
4
28
  # Wrap the passed pointer in an instance of its type's corresponding class,
5
29
  # generally assumed to be a descendant of the current type.
6
30
  def self.wrap(ptr)
@@ -29,14 +53,6 @@ module GirFFI
29
53
  gir_ffi_builder.find_signal name
30
54
  end
31
55
 
32
- def self.to_ffi_type
33
- :pointer
34
- end
35
-
36
- def self.copy_value_to_pointer(value, pointer, offset = 0)
37
- pointer.put_pointer offset, value.to_ptr
38
- end
39
-
40
56
  def self.object_class
41
57
  gir_ffi_builder.object_class
42
58
  end
@@ -33,8 +33,8 @@ module GirFFI
33
33
  size * element_size
34
34
  end
35
35
 
36
- def self.get_value_from_pointer(pointer)
37
- pointer
36
+ def self.get_value_from_pointer(pointer, offset)
37
+ pointer + offset
38
38
  end
39
39
 
40
40
  def self.copy_value_to_pointer(value, pointer)
@@ -1,4 +1,4 @@
1
1
  # Current GirFFI version
2
2
  module GirFFI
3
- VERSION = '0.8.3'
3
+ VERSION = '0.8.4'
4
4
  end
@@ -38,7 +38,7 @@ module GirFFI
38
38
  private
39
39
 
40
40
  def read_value(offset)
41
- val = @ptr.send(getter_method, offset)
41
+ val = fetch_value(offset)
42
42
  val unless val.zero?
43
43
  end
44
44
 
@@ -46,6 +46,17 @@ module GirFFI
46
46
  @getter_method ||= "get_#{ffi_type}"
47
47
  end
48
48
 
49
+ def fetch_value(offset)
50
+ case ffi_type
51
+ when Module
52
+ ffi_type.get_value_from_pointer(@ptr, offset)
53
+ when Symbol
54
+ @ptr.send(getter_method, offset)
55
+ else
56
+ raise NotImplementedError
57
+ end
58
+ end
59
+
49
60
  def wrap_value(val)
50
61
  case element_type
51
62
  when Array
@@ -22,8 +22,8 @@ module GLib
22
22
  pointer.put_int 0, to_native(value, nil)
23
23
  end
24
24
 
25
- def self.get_value_from_pointer(pointer)
26
- from_native pointer.get_int(0), nil
25
+ def self.get_value_from_pointer(pointer, offset)
26
+ from_native pointer.get_int(offset), nil
27
27
  end
28
28
  end
29
29
  end
data/tasks/test.rake CHANGED
@@ -28,40 +28,40 @@ class Listener
28
28
  obj_name = attrs['name']
29
29
  case name
30
30
  when "constant"
31
- result.puts " it \"has the constant #{obj_name}\" do"
31
+ result.puts " it 'has the constant #{obj_name}' do"
32
32
  when "record", "class", "enumeration", "bitfield", "interface", "union"
33
- result.puts " describe \"#{namespace}::#{obj_name}\" do"
33
+ result.puts " describe '#{namespace}::#{obj_name}' do"
34
34
  @inside_class = name
35
35
  when "constructor"
36
- result.puts " it \"creates an instance using ##{obj_name}\" do"
36
+ result.puts " it 'creates an instance using ##{obj_name}' do"
37
37
  when "field"
38
38
  if @inside_class != 'class'
39
39
  if attrs['private'] == "1"
40
- result.puts " it \"has a private field #{obj_name}\" do"
40
+ result.puts " it 'has a private field #{obj_name}' do"
41
41
  elsif attrs['writable'] == "1"
42
- result.puts " it \"has a writable field #{obj_name}\" do"
42
+ result.puts " it 'has a writable field #{obj_name}' do"
43
43
  else
44
- result.puts " it \"has a read-only field #{obj_name}\" do"
44
+ result.puts " it 'has a read-only field #{obj_name}' do"
45
45
  end
46
46
  end
47
47
  when "function", "method"
48
48
  spaces = @inside_class ? " " : ""
49
- result.puts " #{spaces}it \"has a working #{name} ##{obj_name}\" do"
49
+ result.puts " #{spaces}it 'has a working #{name} ##{obj_name}' do"
50
50
  when "member"
51
- result.puts " it \"has the member :#{obj_name}\" do"
51
+ result.puts " it 'has the member :#{obj_name}' do"
52
52
  when "namespace"
53
53
  result.puts "describe #{obj_name} do"
54
54
  when "property"
55
55
  accessor_name = obj_name.gsub(/-/, '_')
56
56
  result.puts " describe \"its '#{obj_name}' property\" do"
57
- result.puts " it \"can be retrieved with #get_property\" do"
57
+ result.puts " it 'can be retrieved with #get_property' do"
58
58
  result.puts " end"
59
- result.puts " it \"can be retrieved with ##{accessor_name}\" do"
59
+ result.puts " it 'can be retrieved with ##{accessor_name}' do"
60
60
  result.puts " end"
61
61
  if attrs['writable'] == '1'
62
- result.puts " it \"can be set with #set_property\" do"
62
+ result.puts " it 'can be set with #set_property' do"
63
63
  result.puts " end"
64
- result.puts " it \"can be set with ##{accessor_name}=\" do"
64
+ result.puts " it 'can be set with ##{accessor_name}=' do"
65
65
  result.puts " end"
66
66
  end
67
67
  when "glib:signal"
@@ -145,7 +145,7 @@ namespace :test do
145
145
  t.test_files = FileList['test/integration/**/*_test.rb']
146
146
  end
147
147
 
148
- desc 'Build Regress test library and typelib'
148
+ desc 'Build test libraries and typelibs'
149
149
  task :lib => "test/lib/Makefile" do
150
150
  sh %{cd test/lib && make}
151
151
  end
@@ -169,19 +169,21 @@ namespace :test do
169
169
  :overrides,
170
170
  :integration]
171
171
 
172
- desc "Create stubs for Regress and GIMarshallingTests tests"
173
- task :stub => :lib do
174
- file = File.new 'test/lib/Regress-1.0.gir'
172
+ def make_stub_file(libname)
173
+ file = File.new "test/lib/#{libname}-1.0.gir"
175
174
  listener = Listener.new
176
- listener.result = File.open('tmp/regress_lines.rb', 'w')
177
- listener.namespace = "Regress"
175
+ listener.result = File.open("tmp/#{libname.downcase}_lines.rb", 'w')
176
+ listener.namespace = libname
178
177
  REXML::Document.parse_stream file, listener
178
+ end
179
179
 
180
- file = File.new 'test/lib/GIMarshallingTests-1.0.gir'
181
- listener = Listener.new
182
- listener.result = File.open('tmp/gimarshallingtests_lines.rb', 'w')
183
- listener.namespace = "GIMarshallingTests"
184
- REXML::Document.parse_stream file, listener
180
+ desc "Create stubs for integration tests"
181
+ task :stub => :lib do
182
+ make_stub_file 'Everything'
183
+ make_stub_file 'GIMarshallingTests'
184
+ make_stub_file 'Regress'
185
+ make_stub_file 'Utility'
186
+ make_stub_file 'WarnLib'
185
187
  end
186
188
  end
187
189
 
@@ -3,6 +3,7 @@ require 'rubygems' if RUBY_PLATFORM == 'java'
3
3
  begin
4
4
  require 'simplecov'
5
5
  SimpleCov.start do
6
+ track_files 'lib/**/*.rb'
6
7
  add_filter '/test/'
7
8
  end
8
9
 
@@ -25,10 +26,8 @@ module GObjectIntrospection
25
26
  class IRepository
26
27
  def shared_library_with_regress(namespace)
27
28
  case namespace
28
- when 'Regress'
29
- return File.join(File.dirname(__FILE__), 'lib', 'libregress.so')
30
- when 'GIMarshallingTests'
31
- return File.join(File.dirname(__FILE__), 'lib', 'libgimarshallingtests.so')
29
+ when 'Everything', 'GIMarshallingTests', 'Regress', 'Utility', 'WarnLib'
30
+ return File.join(File.dirname(__FILE__), 'lib', "lib#{namespace.downcase}.so")
32
31
  else
33
32
  return shared_library_without_regress namespace
34
33
  end
@@ -3,6 +3,12 @@ require 'gir_ffi_test_helper'
3
3
  require 'ffi-gobject'
4
4
 
5
5
  describe GObject::Object do
6
+ describe '.new' do
7
+ it 'is overridden to take only one argument' do
8
+ GObject::Object.new(nil).must_be_instance_of GObject::Object
9
+ end
10
+ end
11
+
6
12
  describe '#get_property' do
7
13
  it 'is overridden to have arity 1' do
8
14
  GObject::Object.instance_method('get_property').arity.must_equal 1
@@ -20,7 +26,7 @@ describe GObject::Object do
20
26
  end
21
27
  end
22
28
 
23
- subject { AccessorTest.new GObject::TYPE_OBJECT, nil }
29
+ subject { AccessorTest.new nil }
24
30
 
25
31
  it 'reads x by calling get_x' do
26
32
  subject.set_x(1)
@@ -34,7 +40,7 @@ describe GObject::Object do
34
40
  end
35
41
 
36
42
  describe '#signal_connect' do
37
- subject { GObject::Object.new GObject::TYPE_OBJECT, nil }
43
+ subject { GObject::Object.new nil }
38
44
 
39
45
  it 'delegates to GObject' do
40
46
  expect(GObject).to receive(:signal_connect).with(subject, 'some-event', nil)
@@ -52,7 +58,7 @@ describe GObject::Object do
52
58
  end
53
59
 
54
60
  describe '#signal_connect_after' do
55
- subject { GObject::Object.new GObject::TYPE_OBJECT, nil }
61
+ subject { GObject::Object.new nil }
56
62
 
57
63
  it 'delegates to GObject' do
58
64
  expect(GObject).to receive(:signal_connect_after).with(subject, 'some-event', nil)
@@ -75,7 +81,7 @@ describe GObject::Object do
75
81
  skip 'cannot be reliably tested on JRuby and Rubinius'
76
82
  end
77
83
 
78
- object = GObject::Object.new GObject::TYPE_OBJECT, nil
84
+ object = GObject::Object.new nil
79
85
  ptr = object.to_ptr
80
86
  ref_count(ptr).must_equal 1
81
87
 
@@ -22,8 +22,9 @@ describe GObjectIntrospection::IPropertyInfo do
22
22
  end
23
23
 
24
24
  describe "for GObject::Binding's 'target-property' property" do
25
- let(:property_info) {
26
- get_property_introspection_data 'GObject', 'Binding', 'target-property' }
25
+ let(:property_info) do
26
+ get_property_introspection_data 'GObject', 'Binding', 'target-property'
27
+ end
27
28
 
28
29
  it 'returns :utf8 as its type' do
29
30
  property_info.property_type.tag.must_equal :utf8
@@ -1,17 +1,40 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::Builders::ModuleBuilder do
4
- describe '#build_namespaced_class' do
4
+ let(:gir) { GObjectIntrospection::IRepository.default }
5
+
6
+ describe '#find_namespaced_class_info' do
7
+ it 'finds the info in the GIR' do
8
+ allow(gir).to receive(:require).with('Foo', nil)
9
+
10
+ builder = GirFFI::Builders::ModuleBuilder.new 'Foo'
11
+
12
+ expect(gir).to receive(:find_by_name).with('Foo', 'Bar').and_return 'gir info'
13
+
14
+ builder.find_namespaced_class_info(:Bar).must_equal 'gir info'
15
+ end
16
+
17
+ it 'checks downcased class name as an alternative' do
18
+ allow(gir).to receive(:require).with('Foo', nil)
19
+
20
+ builder = GirFFI::Builders::ModuleBuilder.new 'Foo'
21
+
22
+ expect(gir).to receive(:find_by_name).with('Foo', 'Bar').and_return nil
23
+ expect(gir).to receive(:find_by_name).with('Foo', 'bar').and_return 'gir info'
24
+
25
+ builder.find_namespaced_class_info(:Bar).must_equal 'gir info'
26
+ end
27
+
5
28
  it 'raises a clear error if the named class does not exist' do
6
- gir = GObjectIntrospection::IRepository.default
7
29
  allow(gir).to receive(:require).with('Foo', nil)
8
30
 
9
31
  builder = GirFFI::Builders::ModuleBuilder.new 'Foo'
10
32
 
11
33
  expect(gir).to receive(:find_by_name).with('Foo', 'Bar').and_return nil
34
+ expect(gir).to receive(:find_by_name).with('Foo', 'bar').and_return nil
12
35
 
13
36
  assert_raises NameError do
14
- builder.build_namespaced_class :Bar
37
+ builder.find_namespaced_class_info :Bar
15
38
  end
16
39
  end
17
40
  end
@@ -11,8 +11,8 @@ describe GirFFI::ObjectBase do
11
11
  end
12
12
 
13
13
  describe '.to_ffi_type' do
14
- it 'returns :pointer' do
15
- derived_class.to_ffi_type.must_equal :pointer
14
+ it 'returns itself' do
15
+ derived_class.to_ffi_type.must_equal derived_class
16
16
  end
17
17
  end
18
18
  end