gio2 2.2.4-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +31 -0
- data/ext/gio2/depend +6 -0
- data/ext/gio2/extconf.rb +77 -0
- data/ext/gio2/rb-gio2-pollable-source.c +59 -0
- data/ext/gio2/rb-gio2.c +32 -0
- data/ext/gio2/rb-gio2.h +26 -0
- data/extconf.rb +65 -0
- data/lib/2.0/gio2.so +0 -0
- data/lib/2.1/gio2.so +0 -0
- data/lib/2.2/gio2.so +0 -0
- data/lib/gio2.rb +56 -0
- data/lib/gio2/deprecated.rb +118 -0
- data/lib/gio2/inet-address.rb +33 -0
- data/lib/gio2/input-stream.rb +48 -0
- data/lib/gio2/loader.rb +240 -0
- data/lib/gio2/pollable-input-stream.rb +60 -0
- data/lib/gio2/pollable-output-stream.rb +27 -0
- data/lib/gio2/resources.rb +62 -0
- data/test/fixture/content-type/x-content/unix-software/autorun.sh +1 -0
- data/test/fixture/resource/Rakefile +32 -0
- data/test/fixture/resource/logo.png +0 -0
- data/test/fixture/resource/ruby-gio2.gresource +0 -0
- data/test/fixture/resource/ruby-gio2.gresource.xml +6 -0
- data/test/gio2-test-utils.rb +22 -0
- data/test/gio2-test-utils/fixture.rb +24 -0
- data/test/gio2-test-utils/omissions.rb +23 -0
- data/test/gio2-test-utils/socket-client.rb +59 -0
- data/test/run-test.rb +51 -0
- data/test/test-buffered-input-stream.rb +23 -0
- data/test/test-charset-converter.rb +23 -0
- data/test/test-content-type.rb +39 -0
- data/test/test-data-input-stream.rb +21 -0
- data/test/test-dbus.rb +42 -0
- data/test/test-file-enumerator.rb +26 -0
- data/test/test-file-monitor.rb +33 -0
- data/test/test-file.rb +30 -0
- data/test/test-inet-address.rb +34 -0
- data/test/test-input-stream.rb +36 -0
- data/test/test-memory-input-stream.rb +23 -0
- data/test/test-memory-output-stream.rb +23 -0
- data/test/test-output-stream.rb +39 -0
- data/test/test-pollable-input-stream.rb +54 -0
- data/test/test-pollable-output-stream.rb +53 -0
- data/test/test-resources.rb +58 -0
- metadata +115 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gio
|
18
|
+
class InetAddress
|
19
|
+
class << self
|
20
|
+
def any(family)
|
21
|
+
address = allocate
|
22
|
+
address.__send__(:initialize_new_any, family)
|
23
|
+
address
|
24
|
+
end
|
25
|
+
|
26
|
+
def loopback(family)
|
27
|
+
address = allocate
|
28
|
+
address.__send__(:initialize_new_loopback, family)
|
29
|
+
address
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gio
|
18
|
+
class InputStream
|
19
|
+
alias_method :read_raw, :read
|
20
|
+
def read(size=nil)
|
21
|
+
if size.nil?
|
22
|
+
all = "".force_encoding("ASCII-8BIT")
|
23
|
+
buffer_size = 8192
|
24
|
+
buffer = " ".force_encoding("ASCII-8BIT") * buffer_size
|
25
|
+
loop do
|
26
|
+
read_bytes = read_raw_compatible(buffer)
|
27
|
+
all << buffer.byteslice(0, read_bytes)
|
28
|
+
break if read_bytes != buffer_size
|
29
|
+
end
|
30
|
+
all
|
31
|
+
else
|
32
|
+
buffer = " " * size
|
33
|
+
read_bytes = read_raw_compatible(buffer)
|
34
|
+
buffer.replace(buffer.byteslice(0, read_bytes))
|
35
|
+
buffer
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def read_raw_compatible(buffer)
|
41
|
+
if (GLib::VERSION <=> [2, 36, 0]) >= 0
|
42
|
+
read_raw(buffer)
|
43
|
+
else
|
44
|
+
read_raw(buffer, buffer.bytesize)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/gio2/loader.rb
ADDED
@@ -0,0 +1,240 @@
|
|
1
|
+
# Copyright (C) 2013-2014 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gio
|
18
|
+
class Loader < GObjectIntrospection::Loader
|
19
|
+
private
|
20
|
+
def pre_load(repository, namespace)
|
21
|
+
define_content_type_class
|
22
|
+
define_mime_type_class
|
23
|
+
define_dbus_module
|
24
|
+
define_resources_module
|
25
|
+
@content_type_guess_for_tree_info = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def post_load(repository, namespace)
|
29
|
+
if @content_type_guess_for_tree_info
|
30
|
+
content_type_class = @content_type_class
|
31
|
+
info = @content_type_guess_for_tree_info
|
32
|
+
file_module = @base_module.const_get("File")
|
33
|
+
file_module.__send__(:define_method, "guess_content_types") do
|
34
|
+
info.invoke(:arguments => [self]).collect do |type|
|
35
|
+
content_type_class.new(type)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
require_extension
|
40
|
+
require_libraries
|
41
|
+
end
|
42
|
+
|
43
|
+
def require_extension
|
44
|
+
begin
|
45
|
+
major, minor, _ = RUBY_VERSION.split(/\./)
|
46
|
+
require "#{major}.#{minor}/gio2.so"
|
47
|
+
rescue LoadError
|
48
|
+
require "gio2.so"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def require_libraries
|
53
|
+
require "gio2/resources"
|
54
|
+
require "gio2/inet-address"
|
55
|
+
require "gio2/input-stream"
|
56
|
+
require "gio2/pollable-input-stream"
|
57
|
+
require "gio2/pollable-output-stream"
|
58
|
+
end
|
59
|
+
|
60
|
+
def define_content_type_class
|
61
|
+
@content_type_class = Class.new do
|
62
|
+
def initialize(type)
|
63
|
+
@type = type
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_s
|
67
|
+
@type
|
68
|
+
end
|
69
|
+
end
|
70
|
+
@base_module.const_set("ContentType", @content_type_class)
|
71
|
+
end
|
72
|
+
|
73
|
+
def define_mime_type_class
|
74
|
+
@mime_type_class = Class.new do
|
75
|
+
def initialize(type)
|
76
|
+
@type = type
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_s
|
80
|
+
@type
|
81
|
+
end
|
82
|
+
end
|
83
|
+
@base_module.const_set("MimeType", @mime_type_class)
|
84
|
+
end
|
85
|
+
|
86
|
+
def define_dbus_module
|
87
|
+
@dbus_module = Module.new
|
88
|
+
@base_module.const_set("DBus", @dbus_module)
|
89
|
+
end
|
90
|
+
|
91
|
+
def define_resources_module
|
92
|
+
@resources_module = Module.new
|
93
|
+
@base_module.const_set("Resources", @resources_module)
|
94
|
+
end
|
95
|
+
|
96
|
+
def load_function_info(info)
|
97
|
+
name = info.name
|
98
|
+
case name
|
99
|
+
when "init"
|
100
|
+
# ignore
|
101
|
+
when /\Acontent_type_/
|
102
|
+
load_function_info_content_type(info)
|
103
|
+
when "content_types_get_registered"
|
104
|
+
@content_type_class.define_singleton_method(:registered) do
|
105
|
+
info.invoke(:arguments => []).collect do |type|
|
106
|
+
new(type)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
when /\Aresources_/
|
110
|
+
name = rubyish_method_name(info, :prefix => "resources_")
|
111
|
+
define_module_function(@resources_module, name, info)
|
112
|
+
when /\Adbus_/
|
113
|
+
name = rubyish_method_name(info, :prefix => "dbus_")
|
114
|
+
define_module_function(@dbus_module, name, info)
|
115
|
+
else
|
116
|
+
super
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def load_function_info_content_type(info)
|
121
|
+
name = info.name.gsub(/\Acontent_type_/, "")
|
122
|
+
case name
|
123
|
+
when "equals", "is_a"
|
124
|
+
case name
|
125
|
+
when "equals"
|
126
|
+
method_name = "=="
|
127
|
+
when "is_a"
|
128
|
+
method_name = "#{name}?"
|
129
|
+
end
|
130
|
+
@content_type_class.__send__(:define_method, method_name) do |other|
|
131
|
+
if other.is_a?(self.class)
|
132
|
+
other = other.to_s
|
133
|
+
end
|
134
|
+
if other.is_a?(String)
|
135
|
+
info.invoke(:arguments => [to_s, other])
|
136
|
+
else
|
137
|
+
false
|
138
|
+
end
|
139
|
+
end
|
140
|
+
when "from_mime_type"
|
141
|
+
@mime_type_class.__send__(:define_method, "content_type") do
|
142
|
+
info.invoke(:arguments => [to_s])
|
143
|
+
end
|
144
|
+
when "get_mime_type"
|
145
|
+
mime_type_class = @mime_type_class
|
146
|
+
@content_type_class.__send__(:define_method, "mime_type") do
|
147
|
+
mime_type = info.invoke(:arguments => [to_s])
|
148
|
+
if mime_type
|
149
|
+
mime_type_class.new(mime_type)
|
150
|
+
else
|
151
|
+
nil
|
152
|
+
end
|
153
|
+
end
|
154
|
+
when "guess_for_tree"
|
155
|
+
@content_type_guess_for_tree_info = info
|
156
|
+
when "guess"
|
157
|
+
validate = lambda do |arguments|
|
158
|
+
method_name = "#{@content_type_class}.#{name}"
|
159
|
+
validate_arguments(info, method_name, arguments)
|
160
|
+
end
|
161
|
+
@content_type_class.define_singleton_method(:guess) do |*arguments|
|
162
|
+
validate.call(arguments)
|
163
|
+
info.invoke(:arguments => arguments)
|
164
|
+
end
|
165
|
+
else
|
166
|
+
case name
|
167
|
+
when /\Acan_be_/
|
168
|
+
method_name = "#{$POSTMATCH}?"
|
169
|
+
when /\Ais_/
|
170
|
+
method_name = "#{$POSTMATCH}?"
|
171
|
+
when /\Aget_/
|
172
|
+
method_name = $POSTMATCH
|
173
|
+
else
|
174
|
+
method_name = name
|
175
|
+
end
|
176
|
+
@content_type_class.__send__(:define_method, method_name) do
|
177
|
+
info.invoke(:arguments => [to_s])
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def load_function_infos(infos, klass)
|
183
|
+
case klass.name
|
184
|
+
when "Gio::File"
|
185
|
+
load_function_infos_file(infos, klass)
|
186
|
+
super
|
187
|
+
else
|
188
|
+
super
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def load_function_infos_file(infos, klass)
|
193
|
+
new_for_commandline_arg_infos = []
|
194
|
+
|
195
|
+
infos.each do |info|
|
196
|
+
name = info.name
|
197
|
+
case name
|
198
|
+
when /\Anew_for_commandline_arg/
|
199
|
+
new_for_commandline_arg_infos << info
|
200
|
+
when /\Anew_(?:for_)?/
|
201
|
+
method_name = $POSTMATCH
|
202
|
+
define_singleton_method(klass, method_name, info)
|
203
|
+
else
|
204
|
+
define_singleton_method(klass, name, info)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
define_file_commandline_arg(new_for_commandline_arg_infos, klass)
|
209
|
+
end
|
210
|
+
|
211
|
+
def define_file_commandline_arg(infos, klass)
|
212
|
+
method_name = "commandline_arg"
|
213
|
+
find_info = lambda do |arguments|
|
214
|
+
find_suitable_callable_info(infos, arguments)
|
215
|
+
end
|
216
|
+
validate = lambda do |info, arguments|
|
217
|
+
validate_arguments(info, "#{klass}.#{method_name}", arguments)
|
218
|
+
end
|
219
|
+
klass.__send__(:define_method, method_name) do |*arguments|
|
220
|
+
info = find_info.call(arguments)
|
221
|
+
validate.call(info, arguments)
|
222
|
+
info.invoke(:arguments => arguments)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def error_class_name(info)
|
227
|
+
name = info.name
|
228
|
+
case name
|
229
|
+
when /Enum\z/
|
230
|
+
$PREMATCH
|
231
|
+
else
|
232
|
+
name
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def error_parent_class(info)
|
237
|
+
Error
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gio
|
18
|
+
module PollableInputStream
|
19
|
+
alias_method :create_source_raw, :create_source
|
20
|
+
def create_source(&block)
|
21
|
+
source = create_source_raw
|
22
|
+
source.extend(PollableSource)
|
23
|
+
source.set_callback(&block)
|
24
|
+
source
|
25
|
+
end
|
26
|
+
|
27
|
+
alias_method :read_nonblocking_raw, :read_nonblocking
|
28
|
+
def read_nonblocking(size=nil)
|
29
|
+
if size.nil?
|
30
|
+
all = "".force_encoding("ASCII-8BIT")
|
31
|
+
buffer_size = 8192
|
32
|
+
buffer = " ".force_encoding("ASCII-8BIT") * buffer_size
|
33
|
+
loop do
|
34
|
+
begin
|
35
|
+
read_bytes = read_nonblocking_raw_compatible(buffer)
|
36
|
+
rescue IOError::WouldBlock
|
37
|
+
break
|
38
|
+
end
|
39
|
+
all << buffer.byteslice(0, read_bytes)
|
40
|
+
break if read_bytes != buffer_size
|
41
|
+
end
|
42
|
+
all
|
43
|
+
else
|
44
|
+
buffer = " " * size
|
45
|
+
read_bytes = read_nonblocking_raw_compatible(buffer)
|
46
|
+
buffer.replace(buffer.byteslice(0, read_bytes))
|
47
|
+
buffer
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def read_nonblocking_raw_compatible(buffer)
|
53
|
+
if (GLib::VERSION <=> [2, 42, 0]) >= 0
|
54
|
+
read_nonblocking_raw(buffer)
|
55
|
+
else
|
56
|
+
read_nonblocking_raw(buffer, buffer.bytesize)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gio
|
18
|
+
module PollableOutputStream
|
19
|
+
alias_method :create_source_raw, :create_source
|
20
|
+
def create_source(&block)
|
21
|
+
source = create_source_raw
|
22
|
+
source.extend(PollableSource)
|
23
|
+
source.set_callback(&block)
|
24
|
+
source
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gio
|
18
|
+
module Resources
|
19
|
+
class << self
|
20
|
+
def register(resource)
|
21
|
+
resource._register
|
22
|
+
end
|
23
|
+
|
24
|
+
def unregister(resource)
|
25
|
+
resource._unregister
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method :lookup_data_raw, :lookup_data
|
29
|
+
def lookup_data(path, flags=nil)
|
30
|
+
flags ||= ResourceLookupFlags::NONE
|
31
|
+
lookup_data_raw(path, flags)
|
32
|
+
end
|
33
|
+
|
34
|
+
alias_method :open_stream_raw, :open_stream
|
35
|
+
def open_stream(path, flags=nil)
|
36
|
+
flags ||= ResourceLookupFlags::NONE
|
37
|
+
input_stream = open_stream_raw(path, flags)
|
38
|
+
if block_given?
|
39
|
+
begin
|
40
|
+
yield(input_stream)
|
41
|
+
ensure
|
42
|
+
input_stream.close
|
43
|
+
end
|
44
|
+
else
|
45
|
+
input_stream
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
alias_method :enumerate_children_raw, :enumerate_children
|
50
|
+
def enumerate_children(path, flags=nil)
|
51
|
+
flags ||= ResourceLookupFlags::NONE
|
52
|
+
enumerate_children_raw(path, flags)
|
53
|
+
end
|
54
|
+
|
55
|
+
alias_method :get_info_raw, :get_info
|
56
|
+
def get_info(path, flags=nil)
|
57
|
+
flags ||= ResourceLookupFlags::NONE
|
58
|
+
get_info_raw(path, flags)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|