gir_ffi 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/Rakefile +0 -18
- data/TODO.rdoc +1 -1
- data/lib/gir_ffi/arg_helper.rb +165 -35
- data/lib/gir_ffi/builder.rb +4 -3
- data/lib/gir_ffi/class_base.rb +11 -3
- data/lib/gir_ffi/class_builder.rb +49 -35
- data/lib/gir_ffi/function_definition_builder.rb +194 -64
- data/lib/gir_ffi/i_arg_info.rb +3 -0
- data/lib/gir_ffi/i_callback_info.rb +1 -1
- data/lib/gir_ffi/i_interface_info.rb +67 -2
- data/lib/gir_ffi/i_repository.rb +5 -0
- data/lib/gir_ffi/lib.rb +22 -1
- data/lib/gir_ffi/module_builder.rb +1 -0
- data/lib/gir_ffi/overrides/gobject.rb +16 -13
- data/lib/gir_ffi/overrides/gtk.rb +1 -1
- data/tasks/notes.rake +12 -25
- data/tasks/setup.rb +0 -132
- data/tasks/test.rake +4 -12
- data/test/arg_helper_test.rb +25 -7
- data/test/builder_test.rb +36 -21
- data/test/class_base_test.rb +0 -7
- data/test/class_builder_test.rb +6 -0
- data/test/everything_test.rb +427 -1
- data/test/function_definition_builder_test.rb +69 -12
- data/test/gobject_overrides_test.rb +12 -3
- data/test/test_helper.rb +5 -0
- metadata +8 -10
- data/tasks/bones.rake +0 -87
- data/tasks/post_load.rake +0 -25
data/tasks/notes.rake
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
# The following code is copied straight from Bones 2.5.1
|
2
2
|
#
|
3
3
|
|
4
|
-
begin
|
5
|
-
require 'facets/ansicode'
|
6
|
-
HAVE_COLOR = true
|
7
|
-
rescue LoadError
|
8
|
-
HAVE_COLOR = false
|
9
|
-
end
|
10
|
-
|
11
4
|
module Bones
|
12
5
|
|
13
6
|
# A helper class used to find and display any annotations in a collection of
|
@@ -31,19 +24,18 @@ class AnnotationExtractor
|
|
31
24
|
# will search for all athe annotations and display them on standard
|
32
25
|
# output.
|
33
26
|
#
|
34
|
-
def self.enumerate
|
35
|
-
extractor = new(
|
27
|
+
def self.enumerate tag, id = nil, opts = {}
|
28
|
+
extractor = new(tag, id)
|
36
29
|
extractor.display(extractor.find, opts)
|
37
30
|
end
|
38
31
|
|
39
|
-
attr_reader :tag, :
|
32
|
+
attr_reader :tag, :id
|
40
33
|
|
41
34
|
# Creates a new annotation extractor configured to use the _project_ open
|
42
35
|
# strcut and to search for the given _tag_ (which can be more than one tag
|
43
36
|
# via a regular expression 'or' operation -- i.e. THIS|THAT|OTHER)
|
44
37
|
#
|
45
|
-
def initialize
|
46
|
-
@project = project
|
38
|
+
def initialize tag, id
|
47
39
|
@tag = tag
|
48
40
|
@id = @id_rgxp = nil
|
49
41
|
|
@@ -60,13 +52,9 @@ class AnnotationExtractor
|
|
60
52
|
results = {}
|
61
53
|
rgxp = %r/(#{tag}):?\s*(.*?)(?:\s*(?:-?%>|\*+\/))?$/o
|
62
54
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
manifest.each do |fn|
|
68
|
-
next if exclude && exclude =~ fn
|
69
|
-
next unless extensions.include? File.extname(fn)
|
55
|
+
files = Dir.glob("lib/**/*.rb")
|
56
|
+
files += Dir.glob("test/**/*.rb")
|
57
|
+
files.each do |fn|
|
70
58
|
results.update(extract_annotations_from(fn, rgxp))
|
71
59
|
end
|
72
60
|
|
@@ -85,7 +73,6 @@ class AnnotationExtractor
|
|
85
73
|
|
86
74
|
text = m[2]
|
87
75
|
if text =~ @id_rgxp
|
88
|
-
text.gsub!(@id_rgxp) {|str| ANSICode.green(str)} if HAVE_COLOR
|
89
76
|
list << Annotation.new(lineno, m[1], text)
|
90
77
|
end
|
91
78
|
list
|
@@ -110,25 +97,25 @@ class AnnotationExtractor
|
|
110
97
|
end # class AnnotationExtractor
|
111
98
|
end # module Bones
|
112
99
|
|
100
|
+
note_tags = ["TODO", "FIXME", "OPTIMIZE"]
|
101
|
+
|
113
102
|
desc "Enumerate all annotations"
|
114
103
|
task :notes do |t|
|
115
104
|
id = if t.application.top_level_tasks.length > 1
|
116
105
|
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
117
106
|
end
|
118
107
|
Bones::AnnotationExtractor.enumerate(
|
119
|
-
|
108
|
+
note_tags.join('|'), id, :tag => true)
|
120
109
|
end
|
121
110
|
|
122
111
|
namespace :notes do
|
123
|
-
|
112
|
+
note_tags.each do |tag|
|
124
113
|
desc "Enumerate all #{tag} annotations"
|
125
114
|
task tag.downcase.to_sym do |t|
|
126
115
|
id = if t.application.top_level_tasks.length > 1
|
127
116
|
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
128
117
|
end
|
129
|
-
Bones::AnnotationExtractor.enumerate(
|
118
|
+
Bones::AnnotationExtractor.enumerate(tag, id)
|
130
119
|
end
|
131
120
|
end
|
132
121
|
end
|
133
|
-
|
134
|
-
# EOF
|
data/tasks/setup.rb
CHANGED
@@ -1,138 +1,6 @@
|
|
1
|
-
|
2
|
-
require 'rake'
|
3
1
|
require 'rake/clean'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'ostruct'
|
6
|
-
require 'find'
|
7
|
-
|
8
|
-
# TODO: Clean up bones' task set to remove unwanted parts.
|
9
|
-
|
10
|
-
PROJ = OpenStruct.new(
|
11
|
-
# Project Defaults
|
12
|
-
:name => nil,
|
13
|
-
:summary => nil,
|
14
|
-
:description => nil,
|
15
|
-
:changes => nil,
|
16
|
-
:authors => nil,
|
17
|
-
:email => nil,
|
18
|
-
:url => "\000",
|
19
|
-
:version => ENV['VERSION'] || '0.0.0',
|
20
|
-
:exclude => %w(tmp$ bak$ ~$ CVS \.svn/ \.git/ ^pkg/),
|
21
|
-
:release_name => ENV['RELEASE'],
|
22
|
-
|
23
|
-
# System Defaults
|
24
|
-
:ruby_opts => %w(-w),
|
25
|
-
:libs => [],
|
26
|
-
:history_file => 'History.txt',
|
27
|
-
:readme_file => 'README.txt',
|
28
|
-
:ignore_file => '.bnsignore',
|
29
|
-
|
30
|
-
# File Annotations
|
31
|
-
:notes => OpenStruct.new(
|
32
|
-
:exclude => %w(^tasks/setup\.rb$),
|
33
|
-
:extensions => %w(.txt .rb .erb .rdoc) << '',
|
34
|
-
:tags => %w(FIXME OPTIMIZE TODO)
|
35
|
-
),
|
36
|
-
|
37
|
-
# Test::Unit
|
38
|
-
:test => OpenStruct.new(
|
39
|
-
:files => FileList['test/**/*_test.rb'],
|
40
|
-
:file => 'test/all.rb',
|
41
|
-
:opts => []
|
42
|
-
)
|
43
|
-
)
|
44
2
|
|
45
3
|
# Load the other rake files in the tasks folder
|
46
4
|
tasks_dir = File.expand_path(File.dirname(__FILE__))
|
47
|
-
post_load_fn = File.join(tasks_dir, 'post_load.rake')
|
48
5
|
rakefiles = Dir.glob(File.join(tasks_dir, '*.rake')).sort
|
49
|
-
rakefiles.unshift(rakefiles.delete(post_load_fn)).compact!
|
50
6
|
import(*rakefiles)
|
51
|
-
|
52
|
-
# Setup the project libraries
|
53
|
-
%w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
|
54
|
-
|
55
|
-
%w(facets/ansicode).each do |lib|
|
56
|
-
begin
|
57
|
-
require lib
|
58
|
-
Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
|
59
|
-
rescue LoadError
|
60
|
-
Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# Reads a file at +path+ and spits out an array of the +paragraphs+
|
65
|
-
# specified.
|
66
|
-
#
|
67
|
-
# changes = paragraphs_of('History.txt', 0..1).join("\n\n")
|
68
|
-
# summary, *description = paragraphs_of('README.txt', 3, 3..8)
|
69
|
-
#
|
70
|
-
def paragraphs_of( path, *paragraphs )
|
71
|
-
title = String === paragraphs.first ? paragraphs.shift : nil
|
72
|
-
ary = File.read(path).delete("\r").split(/\n\n+/)
|
73
|
-
|
74
|
-
result = if title
|
75
|
-
tmp, matching = [], false
|
76
|
-
rgxp = %r/^=+\s*#{Regexp.escape(title)}/i
|
77
|
-
paragraphs << (0..-1) if paragraphs.empty?
|
78
|
-
|
79
|
-
ary.each do |val|
|
80
|
-
if val =~ rgxp
|
81
|
-
break if matching
|
82
|
-
matching = true
|
83
|
-
rgxp = %r/^=+/i
|
84
|
-
elsif matching
|
85
|
-
tmp << val
|
86
|
-
end
|
87
|
-
end
|
88
|
-
tmp
|
89
|
-
else ary end
|
90
|
-
|
91
|
-
result.values_at(*paragraphs)
|
92
|
-
end
|
93
|
-
|
94
|
-
# Adds the given arguments to the include path if they are not already there
|
95
|
-
#
|
96
|
-
def ensure_in_path( *args )
|
97
|
-
args.each do |path|
|
98
|
-
path = File.expand_path(path)
|
99
|
-
$:.unshift(path) if test(?d, path) and not $:.include?(path)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# Scans the current working directory and creates a list of files that are
|
104
|
-
# candidates to be in the manifest.
|
105
|
-
#
|
106
|
-
def manifest
|
107
|
-
files = []
|
108
|
-
exclude = PROJ.exclude.dup
|
109
|
-
comment = %r/^\s*#/
|
110
|
-
|
111
|
-
# process the ignore file and add the items there to the exclude list
|
112
|
-
if test(?f, PROJ.ignore_file)
|
113
|
-
ary = []
|
114
|
-
File.readlines(PROJ.ignore_file).each do |line|
|
115
|
-
next if line =~ comment
|
116
|
-
line.chomp!
|
117
|
-
line.strip!
|
118
|
-
next if line.nil? or line.empty?
|
119
|
-
|
120
|
-
glob = line =~ %r/\*\./ ? File.join('**', line) : line
|
121
|
-
Dir.glob(glob).each {|fn| ary << "^#{Regexp.escape(fn)}"}
|
122
|
-
end
|
123
|
-
exclude.concat ary
|
124
|
-
end
|
125
|
-
|
126
|
-
# generate a regular expression from the exclude list
|
127
|
-
exclude = Regexp.new(exclude.join('|'))
|
128
|
-
|
129
|
-
Find.find '.' do |path|
|
130
|
-
path.sub! %r/^(\.\/|\/)/o, ''
|
131
|
-
next unless test ?f, path
|
132
|
-
next if path =~ exclude
|
133
|
-
files << path
|
134
|
-
end
|
135
|
-
files.sort!
|
136
|
-
end
|
137
|
-
|
138
|
-
# EOF
|
data/tasks/test.rake
CHANGED
@@ -1,22 +1,14 @@
|
|
1
|
-
|
2
|
-
if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
|
3
1
|
require 'rake/testtask'
|
4
2
|
|
5
3
|
namespace :test do
|
6
4
|
|
7
5
|
Rake::TestTask.new(:run) do |t|
|
8
|
-
t.libs =
|
9
|
-
t.test_files =
|
10
|
-
|
11
|
-
t.ruby_opts += PROJ.ruby_opts
|
12
|
-
t.ruby_opts += PROJ.test.opts
|
6
|
+
t.libs = ['lib']
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
|
+
t.ruby_opts += ["-w"]
|
13
9
|
end
|
14
10
|
|
15
|
-
end
|
11
|
+
end
|
16
12
|
|
17
13
|
desc 'Alias to test:run'
|
18
14
|
task :test => 'test:run'
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
# EOF
|
data/test/arg_helper_test.rb
CHANGED
@@ -16,10 +16,10 @@ class ArgHelperTest < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
context "The
|
19
|
+
context "The utf8_array_to_inoutptr method" do
|
20
20
|
context "when called with an array of strings" do
|
21
21
|
setup do
|
22
|
-
@result = GirFFI::ArgHelper.
|
22
|
+
@result = GirFFI::ArgHelper.utf8_array_to_inoutptr ["foo", "bar", "baz"]
|
23
23
|
end
|
24
24
|
|
25
25
|
should "return a FFI::Pointer" do
|
@@ -34,7 +34,7 @@ class ArgHelperTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
context "when called with nil" do
|
36
36
|
should "return nil" do
|
37
|
-
assert_nil GirFFI::ArgHelper.
|
37
|
+
assert_nil GirFFI::ArgHelper.utf8_array_to_inoutptr nil
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -50,7 +50,7 @@ class ArgHelperTest < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
context "The
|
53
|
+
context "The outptr_to_utf8_array method" do
|
54
54
|
context "when called with a valid pointer to a string array" do
|
55
55
|
setup do
|
56
56
|
p = GirFFI::AllocationHelper.safe_malloc FFI.type_size(:pointer) * 2
|
@@ -64,7 +64,7 @@ class ArgHelperTest < Test::Unit::TestCase
|
|
64
64
|
|
65
65
|
should "return the string array" do
|
66
66
|
assert_equal ["one", "two"],
|
67
|
-
GirFFI::ArgHelper.
|
67
|
+
GirFFI::ArgHelper.outptr_to_utf8_array(@ptr, 2)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -83,13 +83,13 @@ class ArgHelperTest < Test::Unit::TestCase
|
|
83
83
|
|
84
84
|
should "return render the null pointer as nil" do
|
85
85
|
assert_equal ["one", "two", nil],
|
86
|
-
GirFFI::ArgHelper.
|
86
|
+
GirFFI::ArgHelper.outptr_to_utf8_array(@ptr, 3)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
context "when called with nil" do
|
91
91
|
should "return nil" do
|
92
|
-
assert_nil GirFFI::ArgHelper.
|
92
|
+
assert_nil GirFFI::ArgHelper.outptr_to_utf8_array(nil, 0)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
@@ -109,4 +109,22 @@ class ArgHelperTest < Test::Unit::TestCase
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
112
|
+
|
113
|
+
context "The pointer_outptr method" do
|
114
|
+
should "return a pointer to a null pointer" do
|
115
|
+
ptr = GirFFI::ArgHelper.pointer_outptr
|
116
|
+
pptr = ptr.read_pointer
|
117
|
+
assert pptr.null?
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "The object_pointer_to_object method" do
|
122
|
+
should "return an object of the correct class" do
|
123
|
+
GirFFI.setup :Everything
|
124
|
+
o = Everything::TestSubObj.new
|
125
|
+
o2 = GirFFI::ArgHelper.object_pointer_to_object o.to_ptr
|
126
|
+
assert_instance_of Everything::TestSubObj, o2
|
127
|
+
assert_equal o.to_ptr, o2.to_ptr
|
128
|
+
end
|
129
|
+
end
|
112
130
|
end
|
data/test/builder_test.rb
CHANGED
@@ -3,7 +3,6 @@ require 'gir_ffi'
|
|
3
3
|
|
4
4
|
class BuilderTest < Test::Unit::TestCase
|
5
5
|
context "The GirFFI::Builder module" do
|
6
|
-
# TODO: Use gir's sample Everything library for testing instead.
|
7
6
|
context "building GObject::Object" do
|
8
7
|
setup do
|
9
8
|
cleanup_module :GObject
|
@@ -12,8 +11,8 @@ class BuilderTest < Test::Unit::TestCase
|
|
12
11
|
|
13
12
|
should "create a Lib module in the parent namespace ready to attach functions from gobject-2.0" do
|
14
13
|
gir = GirFFI::IRepository.default
|
15
|
-
expected = gir.shared_library
|
16
|
-
|
14
|
+
expected = gir.shared_library('GObject')
|
15
|
+
assert_equal [expected], GObject::Lib.ffi_libraries.map(&:name)
|
17
16
|
end
|
18
17
|
|
19
18
|
should "create an array CALLBACKS inside the GObject::Lib module" do
|
@@ -60,7 +59,7 @@ class BuilderTest < Test::Unit::TestCase
|
|
60
59
|
end
|
61
60
|
|
62
61
|
should "create a Gtk::Window#to_ptr method" do
|
63
|
-
|
62
|
+
assert Gtk::Window.instance_methods.map(&:to_sym).include? :to_ptr
|
64
63
|
end
|
65
64
|
|
66
65
|
should "result in Gtk::Window.new to succeed" do
|
@@ -78,7 +77,7 @@ class BuilderTest < Test::Unit::TestCase
|
|
78
77
|
# The Gtk module has more than one library on my current machine.
|
79
78
|
gir = GirFFI::IRepository.default
|
80
79
|
expected = (gir.shared_library 'Gtk').split(',')
|
81
|
-
|
80
|
+
assert_equal expected.sort, Gtk::Lib.ffi_libraries.map(&:name).sort
|
82
81
|
end
|
83
82
|
|
84
83
|
should "create an array CALLBACKS inside the Gtk::Lib module" do
|
@@ -102,7 +101,7 @@ class BuilderTest < Test::Unit::TestCase
|
|
102
101
|
setup do
|
103
102
|
@go = get_function_introspection_data 'Gtk', 'main'
|
104
103
|
end
|
105
|
-
|
104
|
+
|
106
105
|
should "have correct introspection data" do
|
107
106
|
gir = GirFFI::IRepository.default
|
108
107
|
gir.require "Gtk", nil
|
@@ -119,7 +118,7 @@ class BuilderTest < Test::Unit::TestCase
|
|
119
118
|
end
|
120
119
|
|
121
120
|
GirFFI::Builder.send :attach_ffi_function, libmod, @go
|
122
|
-
|
121
|
+
assert libmod.public_methods.map(&:to_sym).include? :gtk_main
|
123
122
|
end
|
124
123
|
end
|
125
124
|
|
@@ -130,8 +129,6 @@ class BuilderTest < Test::Unit::TestCase
|
|
130
129
|
end
|
131
130
|
|
132
131
|
should "have :pointer, :pointer as types of the arguments for the attached function" do
|
133
|
-
# FIXME: Ideally, we attach the function and test that it requires
|
134
|
-
# the correct argument types.
|
135
132
|
assert_equal [:pointer, :pointer], GirFFI::Builder.send(:ffi_function_argument_types, @go)
|
136
133
|
end
|
137
134
|
|
@@ -160,7 +157,7 @@ class BuilderTest < Test::Unit::TestCase
|
|
160
157
|
|
161
158
|
should "have the correct types of the arguments for the attached function" do
|
162
159
|
argtypes = GirFFI::Builder.send(:ffi_function_argument_types, @go)
|
163
|
-
assert_equal [:pointer, :
|
160
|
+
assert_equal [:pointer, :pointer, GObject::Callback, :pointer, GObject::ClosureNotify, GObject::ConnectFlags],
|
164
161
|
argtypes
|
165
162
|
end
|
166
163
|
|
@@ -182,11 +179,12 @@ class BuilderTest < Test::Unit::TestCase
|
|
182
179
|
|
183
180
|
context "building Everything::TestStructA" do
|
184
181
|
setup do
|
182
|
+
@fieldnames = [:some_int, :some_int8, :some_double, :some_enum]
|
185
183
|
GirFFI::Builder.build_class 'Everything', 'TestStructA'
|
186
184
|
end
|
187
185
|
|
188
186
|
should "set up the correct struct members" do
|
189
|
-
assert_equal
|
187
|
+
assert_equal @fieldnames,
|
190
188
|
Everything::TestStructA::Struct.members
|
191
189
|
end
|
192
190
|
|
@@ -199,7 +197,7 @@ class BuilderTest < Test::Unit::TestCase
|
|
199
197
|
should "set up struct members with the correct types" do
|
200
198
|
tags = [:int, :int8, :double, Everything::TestEnum]
|
201
199
|
assert_equal tags.map {|t| FFI.find_type t},
|
202
|
-
Everything::TestStructA::Struct.layout.
|
200
|
+
@fieldnames.map {|f| Everything::TestStructA::Struct.layout[f].type}
|
203
201
|
end
|
204
202
|
end
|
205
203
|
|
@@ -215,7 +213,7 @@ class BuilderTest < Test::Unit::TestCase
|
|
215
213
|
|
216
214
|
should "set up union members with the correct offset" do
|
217
215
|
assert_equal [0, 0, 0, 0, 0],
|
218
|
-
GObject::TypeCValue::Struct.
|
216
|
+
GObject::TypeCValue::Struct.offsets.map {|o| o[1]}
|
219
217
|
end
|
220
218
|
|
221
219
|
should "set up the inner class as derived from FFI::Union" do
|
@@ -237,12 +235,14 @@ class BuilderTest < Test::Unit::TestCase
|
|
237
235
|
GirFFI::Builder.build_class 'Everything', 'TestBoxed'
|
238
236
|
end
|
239
237
|
|
240
|
-
should "set up #
|
241
|
-
assert Everything::TestBoxed.respond_to? "
|
238
|
+
should "set up #wrap" do
|
239
|
+
assert Everything::TestBoxed.respond_to? "wrap"
|
242
240
|
end
|
243
|
-
end
|
244
241
|
|
245
|
-
|
242
|
+
should "set up #allocate" do
|
243
|
+
assert Everything::TestBoxed.respond_to? "allocate"
|
244
|
+
end
|
245
|
+
end
|
246
246
|
|
247
247
|
context "built Everything module" do
|
248
248
|
setup do
|
@@ -252,7 +252,7 @@ class BuilderTest < Test::Unit::TestCase
|
|
252
252
|
|
253
253
|
should "have a method_missing method" do
|
254
254
|
ms = (Everything.public_methods - Module.public_methods).map(&:to_sym)
|
255
|
-
|
255
|
+
assert ms.include? :method_missing
|
256
256
|
end
|
257
257
|
|
258
258
|
should "autocreate the TestObj class" do
|
@@ -266,8 +266,6 @@ class BuilderTest < Test::Unit::TestCase
|
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
269
|
-
# TODO: Turn this into full test of instance method creation, including
|
270
|
-
# inheritance issues.
|
271
269
|
context "built Everything::TestObj" do
|
272
270
|
setup do
|
273
271
|
cleanup_module :Everything
|
@@ -306,7 +304,7 @@ class BuilderTest < Test::Unit::TestCase
|
|
306
304
|
should "have the correct types of the arguments for the attached function" do
|
307
305
|
info = get_method_introspection_data 'Everything', 'TestObj',
|
308
306
|
'torture_signature_0'
|
309
|
-
assert_equal [:pointer, :int, :pointer, :pointer, :
|
307
|
+
assert_equal [:pointer, :int, :pointer, :pointer, :pointer, :pointer, :uint],
|
310
308
|
GirFFI::Builder.send(:ffi_function_argument_types, info)
|
311
309
|
end
|
312
310
|
end
|
@@ -338,5 +336,22 @@ class BuilderTest < Test::Unit::TestCase
|
|
338
336
|
assert_equal 0, subobj.instance_method
|
339
337
|
end
|
340
338
|
end
|
339
|
+
|
340
|
+
context "built Gio::ThreadedSocketService" do
|
341
|
+
setup do
|
342
|
+
cleanup_module :Gio
|
343
|
+
GirFFI::Builder.build_module 'Gio'
|
344
|
+
end
|
345
|
+
|
346
|
+
context "when parent constructor has been called" do
|
347
|
+
setup do
|
348
|
+
Gio::SocketService.new
|
349
|
+
end
|
350
|
+
|
351
|
+
should "still use its own constructor" do
|
352
|
+
assert_nothing_raised { Gio::ThreadedSocketService.new 2 }
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
341
356
|
end
|
342
357
|
end
|
data/test/class_base_test.rb
CHANGED
@@ -3,13 +3,6 @@ require 'gir_ffi/class_base'
|
|
3
3
|
|
4
4
|
class ClassBaseTest < Test::Unit::TestCase
|
5
5
|
context "A class derived from GirFFI::Base" do
|
6
|
-
setup do
|
7
|
-
@klass = Class.new(GirFFI::ClassBase) do
|
8
|
-
# Boilerplate to make regular #new work again.
|
9
|
-
def initialize; end
|
10
|
-
def self.new; self._real_new; end
|
11
|
-
end
|
12
|
-
end
|
13
6
|
# TODO: See if we can test some part of Base again.
|
14
7
|
should "pass" do
|
15
8
|
assert true
|
data/test/class_builder_test.rb
CHANGED
@@ -49,6 +49,12 @@ class ClassBuilderTest < Test::Unit::TestCase
|
|
49
49
|
sig = builder.find_signal 'test'
|
50
50
|
assert_equal 'test', sig.name
|
51
51
|
end
|
52
|
+
|
53
|
+
should 'find the signal "changed" for Gtk::Entry' do
|
54
|
+
builder = GirFFI::ClassBuilder.new 'Gtk', 'Entry'
|
55
|
+
sig = builder.find_signal 'changed'
|
56
|
+
assert_equal 'changed', sig.name
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
60
|
context "for GObject::TypeCValue (a union)" do
|