glib2 2.2.5 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,7 +64,7 @@ module GNOME2
64
64
  task :build => built_file.to_s
65
65
  else
66
66
  task :build => [download_task] do
67
- build_patckage_task_body(package)
67
+ build_package_task_body(package)
68
68
  end
69
69
  end
70
70
  end
@@ -163,23 +163,13 @@ class GNOME2WindowsBinaryBuildTask
163
163
  end
164
164
 
165
165
  def cmake(package)
166
- toolchain_cmake_path = "toolchain.cmake"
167
- File.open(toolchain_cmake_path, "w") do |toolchain|
168
- toolchain.puts(<<-CMAKE)
169
- SET(CMAKE_SYSTEM_NAME Windows)
170
- SET(MSVC_CXX_ARCHITECTURE_ID #{@package.windows.build_architecture})
171
- SET(CMAKE_SYSTEM_PROCESSOR #{@package.windows.build_architecture})
172
-
173
- SET(CMAKE_C_COMPILER #{@package.windows.build_host}-gcc)
174
- SET(CMAKE_CXX_COMPILER #{@package.windows.build_host}-g++)
175
- SET(CMAKE_RC_COMPILER #{@package.windows.build_host}-windres)
176
-
177
- SET(CMAKE_FIND_ROOT_PATH #{cmake_root_paths.join(" ")})
178
- CMAKE
179
- end
180
166
  sh("cmake",
181
167
  ".",
182
- "-DCMAKE_TOOLCHAIN_FILE=#{toolchain_cmake_path}",
168
+ "-DCMAKE_INSTALL_PREFIX=#{dist_dir}",
169
+ "-DCMAKE_SYSTEM_NAME=Windows",
170
+ "-DCMAKE_SYSTEM_PROCESSOR=#{@package.windows.build_architecture}",
171
+ "-DCMAKE_C_COMPILER=#{cc(package)}",
172
+ "-DCMAKE_CXX_COMPILER=#{cxx(package)}",
183
173
  *package.windows.cmake_args) or exit(false)
184
174
  end
185
175
 
@@ -244,6 +234,13 @@ SET(CMAKE_FIND_ROOT_PATH #{cmake_root_paths.join(" ")})
244
234
  cc_command_line.compact.join(" ")
245
235
  end
246
236
 
237
+ def cxx(package)
238
+ cxx_command_line = [
239
+ "#{@package.windows.build_host}-g++",
240
+ ]
241
+ cxx_command_line.compact.join(" ")
242
+ end
243
+
247
244
  def cppflags(package)
248
245
  include_paths = package.windows.include_paths
249
246
  if @package.windows.build_dependencies.include?("glib2")
@@ -30,7 +30,7 @@ end
30
30
 
31
31
  def enable_debug_build_flag(flags)
32
32
  if gcc?
33
- debug_option_pattern = /(^|\s)?-g\d?(\s|$)?/
33
+ debug_option_pattern = /(^|\s)-g\d?(\s|$)/
34
34
  if debug_option_pattern =~ flags
35
35
  flags.gsub(debug_option_pattern, '\\1-g3\\2')
36
36
  else
@@ -109,10 +109,13 @@ if ENV['GTK_BASEPATH'] and /cygwin/ !~ RUBY_PLATFORM
109
109
  $CFLAGS += " -I#{include_path} "
110
110
  end
111
111
 
112
+ def windows_platform?
113
+ /cygwin|mingw|mswin/ === RUBY_PLATFORM
114
+ end
115
+
112
116
  def setup_windows(target_name, base_dir=nil)
113
117
  checking_for(checking_message("Windows")) do
114
- case RUBY_PLATFORM
115
- when /cygwin|mingw|mswin/
118
+ if windows_platform?
116
119
  import_library_name = "libruby-#{target_name}.a"
117
120
  $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}"
118
121
  $cleanfiles << import_library_name
@@ -189,8 +192,7 @@ def add_depend_package_path(target_name, target_source_dir, target_build_dir)
189
192
  $INCFLAGS = "-I#{target_source_dir} #{$INCFLAGS}"
190
193
  end
191
194
 
192
- case RUBY_PLATFORM
193
- when /cygwin|mingw|mswin/
195
+ if windows_platform?
194
196
  target_base_dir = Pathname.new(target_source_dir).parent.parent
195
197
  target_binary_base_dir = target_base_dir + "vendor" + "local"
196
198
  if target_binary_base_dir.exist?
@@ -205,8 +207,7 @@ def add_depend_package_path(target_name, target_source_dir, target_build_dir)
205
207
  $INCFLAGS = "-I#{target_build_dir} #{$INCFLAGS}"
206
208
  end
207
209
 
208
- case RUBY_PLATFORM
209
- when /cygwin|mingw|mswin/
210
+ if windows_platform?
210
211
  library_base_name = "ruby-#{target_name.gsub(/-/, '_')}"
211
212
  case RUBY_PLATFORM
212
213
  when /cygwin|mingw/
@@ -450,12 +451,10 @@ def glib_mkenums(prefix, files, g_type_prefix, include_files, options={})
450
451
  end
451
452
 
452
453
  def check_cairo(options={})
453
- is_windows = (/mingw|cygwin|mswin/ === RUBY_PLATFORM)
454
-
455
454
  rcairo_source_dir = options[:rcairo_source_dir]
456
455
  if rcairo_source_dir.nil?
457
456
  suffix = nil
458
- if is_windows
457
+ if windows_platform?
459
458
  case RUBY_PLATFORM
460
459
  when /\Ax86-mingw/
461
460
  suffix = "win32"
@@ -480,7 +479,7 @@ def check_cairo(options={})
480
479
  end
481
480
 
482
481
  unless rcairo_source_dir.nil?
483
- if is_windows
482
+ if windows_platform?
484
483
  options = {}
485
484
  build_dir = "tmp/#{RUBY_PLATFORM}/cairo/#{RUBY_VERSION}"
486
485
  if File.exist?(File.join(rcairo_source_dir, build_dir))
@@ -0,0 +1,97 @@
1
+ # Copyright (C) 2015 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
+ class TestGLibBinding < Test::Unit::TestCase
18
+ include GLibTestUtils
19
+
20
+ class DataObject < GLib::Object
21
+ type_register
22
+
23
+ install_property(GLib::Param::Int.new("source", # name
24
+ "Source", # nick
25
+ "The source data", # blurb
26
+ 0, # min
27
+ 100, # max
28
+ 0, # default
29
+ GLib::Param::READABLE |
30
+ GLib::Param::WRITABLE))
31
+ install_property(GLib::Param::Int.new("target", # name
32
+ "Target", # nick
33
+ "The target data", # blurb
34
+ 0, # min
35
+ 100, # max
36
+ 0, # default
37
+ GLib::Param::READABLE |
38
+ GLib::Param::WRITABLE))
39
+
40
+ attr_reader :source, :target
41
+ def initialize
42
+ @source = 0
43
+ @target = 0
44
+ super
45
+ end
46
+
47
+ def source=(value)
48
+ @source = value
49
+ notify("source")
50
+ end
51
+
52
+ def target=(value)
53
+ @target = value
54
+ notify("target")
55
+ end
56
+ end
57
+
58
+ setup do
59
+ only_glib_version(2, 26, 0)
60
+ end
61
+
62
+ setup do
63
+ @source = DataObject.new
64
+ @target = DataObject.new
65
+ @binding = @source.bind_property("source", @target, "target", :default)
66
+ end
67
+
68
+ test "#source" do
69
+ assert_equal(@source, @binding.source)
70
+ end
71
+
72
+ test "#source_property" do
73
+ assert_equal("source", @binding.source_property)
74
+ end
75
+
76
+ test "#target" do
77
+ assert_equal(@target, @binding.target)
78
+ end
79
+
80
+ test "#target_property" do
81
+ assert_equal("target", @binding.target_property)
82
+ end
83
+
84
+ test "#flags" do
85
+ assert_equal(GLib::BindingFlags::DEFAULT, @binding.flags)
86
+ end
87
+
88
+ test "#unbind" do
89
+ only_glib_version(2, 38, 0)
90
+ assert_equal(0, @target.target)
91
+ @source.source = 10
92
+ assert_equal(10, @target.target)
93
+ @binding.unbind
94
+ @source.source = 20
95
+ assert_equal(10, @target.target)
96
+ end
97
+ end
@@ -0,0 +1,357 @@
1
+ # Copyright (C) 2015 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
+ class TestGLibVariantType < Test::Unit::TestCase
18
+ include GLibTestUtils
19
+
20
+ sub_test_case "constants" do
21
+ test "BOOLEAN" do
22
+ assert_equal("b", GLib::VariantType::BOOLEAN.to_s)
23
+ end
24
+
25
+ test "BYTE" do
26
+ assert_equal("y", GLib::VariantType::BYTE.to_s)
27
+ end
28
+
29
+ test "INT16" do
30
+ assert_equal("n", GLib::VariantType::INT16.to_s)
31
+ end
32
+
33
+ test "UINT16" do
34
+ assert_equal("q", GLib::VariantType::UINT16.to_s)
35
+ end
36
+
37
+ test "INT32" do
38
+ assert_equal("i", GLib::VariantType::INT32.to_s)
39
+ end
40
+
41
+ test "UINT32" do
42
+ assert_equal("u", GLib::VariantType::UINT32.to_s)
43
+ end
44
+
45
+ test "INT64" do
46
+ assert_equal("x", GLib::VariantType::INT64.to_s)
47
+ end
48
+
49
+ test "UINT64" do
50
+ assert_equal("t", GLib::VariantType::UINT64.to_s)
51
+ end
52
+
53
+ test "HANDLE" do
54
+ assert_equal("h", GLib::VariantType::HANDLE.to_s)
55
+ end
56
+
57
+ test "DOUBLE" do
58
+ assert_equal("d", GLib::VariantType::DOUBLE.to_s)
59
+ end
60
+
61
+ test "STRING" do
62
+ assert_equal("s", GLib::VariantType::STRING.to_s)
63
+ end
64
+
65
+ test "OBJECT_PATH" do
66
+ assert_equal("o", GLib::VariantType::OBJECT_PATH.to_s)
67
+ end
68
+
69
+ test "SIGNATURE" do
70
+ assert_equal("g", GLib::VariantType::SIGNATURE.to_s)
71
+ end
72
+
73
+ test "VARIANT" do
74
+ assert_equal("v", GLib::VariantType::VARIANT.to_s)
75
+ end
76
+
77
+ test "ANY" do
78
+ assert_equal("*", GLib::VariantType::ANY.to_s)
79
+ end
80
+
81
+ test "BASIC" do
82
+ assert_equal("?", GLib::VariantType::BASIC.to_s)
83
+ end
84
+
85
+ test "MAYBE" do
86
+ assert_equal("m*", GLib::VariantType::MAYBE.to_s)
87
+ end
88
+
89
+ test "ARRAY" do
90
+ assert_equal("a*", GLib::VariantType::ARRAY.to_s)
91
+ end
92
+
93
+ test "TUPLE" do
94
+ assert_equal("r", GLib::VariantType::TUPLE.to_s)
95
+ end
96
+
97
+ test "UNIT" do
98
+ assert_equal("()", GLib::VariantType::UNIT.to_s)
99
+ end
100
+
101
+ test "DICT_ENTRY" do
102
+ assert_equal("{?*}", GLib::VariantType::DICT_ENTRY.to_s)
103
+ end
104
+
105
+ test "DICTIONARY" do
106
+ assert_equal("a{?*}", GLib::VariantType::DICTIONARY.to_s)
107
+ end
108
+
109
+ test "STRING_ARRAY" do
110
+ assert_equal("as", GLib::VariantType::STRING_ARRAY.to_s)
111
+ end
112
+
113
+ test "OBJECT_PATH_ARRAY" do
114
+ assert_equal("ao", GLib::VariantType::OBJECT_PATH_ARRAY.to_s)
115
+ end
116
+
117
+ test "BYTESTRING" do
118
+ assert_equal("ay", GLib::VariantType::BYTESTRING.to_s)
119
+ end
120
+
121
+ test "BYTESTRING_ARRAY" do
122
+ assert_equal("aay", GLib::VariantType::BYTESTRING_ARRAY.to_s)
123
+ end
124
+
125
+ test "VARDICT" do
126
+ assert_equal("a{sv}", GLib::VariantType::VARDICT.to_s)
127
+ end
128
+ end
129
+
130
+ sub_test_case ".valid?" do
131
+ test "valid" do
132
+ assert do
133
+ GLib::VariantType.valid?("s")
134
+ end
135
+ end
136
+
137
+ test "invalid" do
138
+ assert do
139
+ !GLib::VariantType.valid?("X")
140
+ end
141
+ end
142
+ end
143
+
144
+ sub_test_case ".scan" do
145
+ test "found" do
146
+ assert_equal("X", GLib::VariantType.scan("sX"))
147
+ end
148
+
149
+ test "not found" do
150
+ assert_nil(GLib::VariantType.scan("X"))
151
+ end
152
+ end
153
+
154
+ sub_test_case "#initialize" do
155
+ test "invalid" do
156
+ assert_raise(ArgumentError.new("invalid type string: \"X\"")) do
157
+ GLib::VariantType.new("X")
158
+ end
159
+ end
160
+ end
161
+
162
+ test "#to_s" do
163
+ variant_type = GLib::VariantType.new("s")
164
+ assert_equal("s", variant_type.to_s)
165
+ end
166
+
167
+ sub_test_case "#definite?" do
168
+ test "definite" do
169
+ variant_type = GLib::VariantType.new("s")
170
+ assert do
171
+ variant_type.definite?
172
+ end
173
+ end
174
+
175
+ test "not definite" do
176
+ variant_type = GLib::VariantType.new("?")
177
+ assert do
178
+ !variant_type.definite?
179
+ end
180
+ end
181
+ end
182
+
183
+ sub_test_case "#container?" do
184
+ test "container" do
185
+ variant_type = GLib::VariantType.new("a*")
186
+ assert do
187
+ variant_type.container?
188
+ end
189
+ end
190
+
191
+ test "not container" do
192
+ variant_type = GLib::VariantType.new("s")
193
+ assert do
194
+ !variant_type.container?
195
+ end
196
+ end
197
+ end
198
+
199
+ sub_test_case "#basic?" do
200
+ test "basic" do
201
+ variant_type = GLib::VariantType.new("s")
202
+ assert do
203
+ variant_type.basic?
204
+ end
205
+ end
206
+
207
+ test "not basic" do
208
+ variant_type = GLib::VariantType.new("as")
209
+ assert do
210
+ !variant_type.basic?
211
+ end
212
+ end
213
+ end
214
+
215
+ sub_test_case "#maybe?" do
216
+ test "maybe" do
217
+ variant_type = GLib::VariantType.new("ms")
218
+ assert do
219
+ variant_type.maybe?
220
+ end
221
+ end
222
+
223
+ test "not maybe" do
224
+ variant_type = GLib::VariantType.new("s")
225
+ assert do
226
+ !variant_type.maybe?
227
+ end
228
+ end
229
+ end
230
+
231
+ sub_test_case "#array?" do
232
+ test "array" do
233
+ variant_type = GLib::VariantType.new("as")
234
+ assert do
235
+ variant_type.array?
236
+ end
237
+ end
238
+
239
+ test "not array" do
240
+ variant_type = GLib::VariantType.new("s")
241
+ assert do
242
+ !variant_type.array?
243
+ end
244
+ end
245
+ end
246
+
247
+ sub_test_case "#tuple?" do
248
+ test "tuple" do
249
+ variant_type = GLib::VariantType.new("(s)")
250
+ assert do
251
+ variant_type.tuple?
252
+ end
253
+ end
254
+
255
+ test "not tuple" do
256
+ variant_type = GLib::VariantType.new("s")
257
+ assert do
258
+ !variant_type.tuple?
259
+ end
260
+ end
261
+ end
262
+
263
+ sub_test_case "#dict_entry?" do
264
+ test "dictionary entry" do
265
+ variant_type = GLib::VariantType.new("{ss}")
266
+ assert do
267
+ variant_type.dict_entry?
268
+ end
269
+ end
270
+
271
+ test "not dictionary entry" do
272
+ variant_type = GLib::VariantType.new("s")
273
+ assert do
274
+ !variant_type.dict_entry?
275
+ end
276
+ end
277
+ end
278
+
279
+ sub_test_case "#variant?" do
280
+ test "variant" do
281
+ variant_type = GLib::VariantType.new("v")
282
+ assert do
283
+ variant_type.variant?
284
+ end
285
+ end
286
+
287
+ test "not variant" do
288
+ variant_type = GLib::VariantType.new("s")
289
+ assert do
290
+ !variant_type.variant?
291
+ end
292
+ end
293
+ end
294
+
295
+ sub_test_case "#==" do
296
+ test "same" do
297
+ variant_type = GLib::VariantType.new("s")
298
+ assert_equal(variant_type,
299
+ variant_type)
300
+ end
301
+
302
+ test "equivalence" do
303
+ assert_equal(GLib::VariantType.new("s"),
304
+ GLib::VariantType.new("s"))
305
+ end
306
+
307
+ test "not VariantType" do
308
+ assert_not_equal(GLib::VariantType.new("s"),
309
+ "s")
310
+ end
311
+ end
312
+
313
+ sub_test_case "#hash and #eql?" do
314
+ test "Hash key" do
315
+ hash = {
316
+ GLib::VariantType.new("s") => :s,
317
+ }
318
+ assert_equal(:s, hash[GLib::VariantType.new("s")])
319
+ end
320
+ end
321
+
322
+ sub_test_case "#is_subtype_of?" do
323
+ test "subtype" do
324
+ string = GLib::VariantType.new("s")
325
+ basic = GLib::VariantType.new("?")
326
+ assert do
327
+ string.is_subtype_of?(basic)
328
+ end
329
+ end
330
+
331
+ test "not subtype" do
332
+ string = GLib::VariantType.new("s")
333
+ int32 = GLib::VariantType.new("i")
334
+ assert do
335
+ !string.is_subtype_of?(int32)
336
+ end
337
+ end
338
+ end
339
+
340
+ sub_test_case "#element" do
341
+ test "array" do
342
+ assert_equal(GLib::VariantType.new("s"),
343
+ GLib::VariantType.new("as").element)
344
+ end
345
+
346
+ test "maybe" do
347
+ assert_equal(GLib::VariantType.new("s"),
348
+ GLib::VariantType.new("ms").element)
349
+ end
350
+
351
+ test "unexpected" do
352
+ assert_raise(ArgumentError.new("must be array or maybe type: <s>")) do
353
+ GLib::VariantType.new("s").element
354
+ end
355
+ end
356
+ end
357
+ end