glib2 3.2.5 → 3.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING.LIB +502 -0
  3. data/README.md +42 -0
  4. data/Rakefile +8 -7
  5. data/ext/glib2/glib2.def +5 -0
  6. data/ext/glib2/rbglib-gc.c +89 -0
  7. data/ext/glib2/rbglib-variant-type.c +17 -0
  8. data/ext/glib2/rbglib.c +3 -0
  9. data/ext/glib2/rbglib.h +6 -1
  10. data/ext/glib2/rbglib2conversions.h +1 -1
  11. data/ext/glib2/rbgobj_boxed.c +49 -30
  12. data/ext/glib2/rbgobj_closure.c +3 -2
  13. data/ext/glib2/rbgobj_convert.c +1 -2
  14. data/ext/glib2/rbgobj_enums.c +32 -14
  15. data/ext/glib2/rbgobj_flags.c +31 -14
  16. data/ext/glib2/rbgobj_param.c +43 -23
  17. data/ext/glib2/rbgobj_signal.c +78 -66
  18. data/ext/glib2/rbgobj_type.c +22 -10
  19. data/ext/glib2/rbgobject.h +2 -0
  20. data/ext/glib2/rbgprivate.h +11 -0
  21. data/glib2.gemspec +48 -0
  22. data/lib/gnome2/rake/package-task.rb +17 -5
  23. data/lib/gnome2/rake/package.rb +2 -2
  24. data/lib/gnome2/rake/windows-binary-build-task.rb +39 -6
  25. data/lib/mkmf-gnome2.rb +4 -3
  26. data/sample/bookmarkfile.rb +2 -2
  27. data/sample/type-register.rb +6 -6
  28. data/sample/type-register2.rb +6 -6
  29. data/test/{test_enum.rb → test-enum.rb} +0 -0
  30. data/test/{test_file_utils.rb → test-file-utils.rb} +0 -0
  31. data/test/{test_flags.rb → test-flags.rb} +0 -0
  32. data/test/{test_glib2.rb → test-glib2.rb} +0 -0
  33. data/test/{test_key_file.rb → test-key-file.rb} +0 -0
  34. data/test/{test_mkenums.rb → test-mkenums.rb} +0 -0
  35. data/test/{test_poll_fd.rb → test-poll-fd.rb} +0 -0
  36. data/test/{test_signal.rb → test-signal.rb} +34 -2
  37. data/test/{test_source.rb → test-source.rb} +0 -0
  38. data/test/{test_spawn.rb → test-spawn.rb} +0 -0
  39. data/test/{test_timeout.rb → test-timeout.rb} +0 -0
  40. data/test/{test_unicode.rb → test-unicode.rb} +0 -0
  41. data/test/{test_utils.rb → test-utils.rb} +0 -0
  42. data/test/{test_value.rb → test-value.rb} +0 -0
  43. data/test/test-variant.rb +27 -0
  44. data/test/{test_win32.rb → test-win32.rb} +0 -0
  45. data/version.rb +30 -0
  46. metadata +29 -64
@@ -99,20 +99,15 @@ rbgobj_class_info_fill_name(RGObjClassInfo *cinfo)
99
99
  cinfo->data_type->wrap_struct_name = cinfo->name;
100
100
  }
101
101
 
102
- static RGObjClassInfo *
103
- rbgobj_class_info_register_without_lock(GType gtype, VALUE klass)
102
+ static rb_data_type_t *
103
+ rbgobj_class_info_create_data_type(VALUE klass)
104
104
  {
105
105
  rb_data_type_t *data_type;
106
- RGObjClassInfo *cinfo;
107
- GType fundamental_type;
108
- RGObjClassInfoDynamic *cinfod;
109
- void *gclass = NULL;
110
- VALUE c;
111
106
 
112
107
  data_type = RB_ZALLOC(rb_data_type_t);
113
108
  data_type->function.dmark = cinfo_mark;
114
109
  data_type->function.dfree = cinfo_free;
115
- if (RB_TYPE_P(klass, RUBY_T_CLASS)) {
110
+ if (RB_TYPE_P(klass, RUBY_T_CLASS) && klass != rb_cObject) {
116
111
  VALUE p = RCLASS_SUPER(klass);
117
112
  while (p != rb_cObject) {
118
113
  if (RTYPEDDATA_P(p)) {
@@ -124,6 +119,20 @@ rbgobj_class_info_register_without_lock(GType gtype, VALUE klass)
124
119
  }
125
120
  data_type->flags = RUBY_TYPED_FREE_IMMEDIATELY;
126
121
 
122
+ return data_type;
123
+ }
124
+
125
+ static RGObjClassInfo *
126
+ rbgobj_class_info_register_without_lock(GType gtype, VALUE klass)
127
+ {
128
+ rb_data_type_t *data_type;
129
+ RGObjClassInfo *cinfo;
130
+ GType fundamental_type;
131
+ RGObjClassInfoDynamic *cinfod;
132
+ void *gclass = NULL;
133
+ VALUE c;
134
+
135
+ data_type = rbgobj_class_info_create_data_type(klass);
127
136
  c = TypedData_Make_Struct(rb_cData, RGObjClassInfo, data_type, cinfo);
128
137
  cinfo->klass = klass;
129
138
  cinfo->gtype = gtype;
@@ -493,11 +502,13 @@ rbgobj_register_class(VALUE klass,
493
502
  gboolean klass2gtype,
494
503
  gboolean gtype2klass)
495
504
  {
496
- RGObjClassInfo* cinfo = NULL;
505
+ rb_data_type_t *data_type = NULL;
506
+ RGObjClassInfo *cinfo = NULL;
497
507
  VALUE c = Qnil;
498
508
 
499
509
  if (klass2gtype) {
500
- c = Data_Make_Struct(rb_cData, RGObjClassInfo, cinfo_mark, NULL, cinfo);
510
+ data_type = rbgobj_class_info_create_data_type(klass);
511
+ c = TypedData_Make_Struct(rb_cData, RGObjClassInfo, data_type, cinfo);
501
512
  }
502
513
  if (gtype2klass && !cinfo)
503
514
  cinfo = g_new(RGObjClassInfo, 1);
@@ -508,6 +519,7 @@ rbgobj_register_class(VALUE klass,
508
519
  cinfo->mark = NULL;
509
520
  cinfo->free = NULL;
510
521
  cinfo->flags = 0;
522
+ cinfo->data_type = data_type;
511
523
  }
512
524
 
513
525
  if (klass2gtype)
@@ -214,6 +214,8 @@ extern GType rbgobj_gtype_get(VALUE obj);
214
214
  typedef VALUE (*GValToRValSignalFunc)(guint num,const GValue* values);
215
215
  extern void rbgobj_set_signal_func(VALUE klass, const gchar *sig_name, GValToRValSignalFunc func);
216
216
  extern GValToRValSignalFunc rbgobj_get_signal_func(guint signal_id);
217
+ extern VALUE rbgobj_signal_new(guint id);
218
+ /* Deprecated. Use rbgobj_signal_new() instead. */
217
219
  extern VALUE rbgobj_signal_wrap(guint sig_id);
218
220
 
219
221
  typedef struct {
@@ -21,6 +21,15 @@
21
21
  #ifndef __RBGPRIVATE_H__
22
22
  #define __RBGPRIVATE_H__
23
23
 
24
+ /*
25
+ * CentOS 6: GLib 2.28
26
+ * CentOS 7: GLib 2.50
27
+ * Ubuntu 14.04: GLib 2.40
28
+ * Ubuntu 16.04: GLib 2.48
29
+ * Ubuntu 18.04: GLib 2.54
30
+ */
31
+ #define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_28
32
+
24
33
  #include "rbgobject.h"
25
34
 
26
35
  #ifndef HAVE_RB_ERRINFO
@@ -114,6 +123,8 @@ G_GNUC_INTERNAL void rg_enum_add_constants(VALUE mod, GType enum_type, const gch
114
123
  G_GNUC_INTERNAL void rg_flags_add_constants(VALUE mod, GType flags_type, const gchar *strip_prefix);
115
124
  G_GNUC_INTERNAL char *rg_obj_constant_lookup(const char *name);
116
125
 
126
+ G_GNUC_INTERNAL void Init_glib_gc(void);
127
+
117
128
  G_GNUC_INTERNAL void Init_gutil(void);
118
129
  G_GNUC_INTERNAL void Init_gutil_callback(void);
119
130
  G_GNUC_INTERNAL void Init_glib_gettext(void);
data/glib2.gemspec ADDED
@@ -0,0 +1,48 @@
1
+ # -*- ruby -*-
2
+ #
3
+ # Copyright (C) 2018 Ruby-GNOME2 Project Team
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ require_relative "version"
20
+
21
+ Gem::Specification.new do |s|
22
+ s.name = "glib2"
23
+ s.summary = "Ruby/GLib2 is a Ruby binding of GLib-2.x."
24
+ s.description =
25
+ "Ruby/GLib2 provides " +
26
+ "base features for GLib2 based bindings and " +
27
+ "many useful utility features."
28
+ s.author = "The Ruby-GNOME2 Project Team"
29
+ s.email = "ruby-gnome2-devel-en@lists.sourceforge.net"
30
+ s.homepage = "https://ruby-gnome2.osdn.jp/"
31
+ s.licenses = ["LGPL-2.1+"]
32
+ s.version = ruby_glib2_version
33
+ s.extensions = ["ext/#{s.name}/extconf.rb"]
34
+ s.require_paths = ["lib"]
35
+ s.files = [
36
+ "COPYING.LIB",
37
+ "README.md",
38
+ "Rakefile",
39
+ "#{s.name}.gemspec",
40
+ "extconf.rb",
41
+ "version.rb",
42
+ "ext/#{s.name}/depend",
43
+ ]
44
+ s.files += Dir.glob("lib/**/*.rb")
45
+ s.files += Dir.glob("ext/#{s.name}/*.{c,h,def,rb}")
46
+ s.files += Dir.glob("sample/**/*")
47
+ s.files += Dir.glob("test/**/*")
48
+ end
@@ -20,15 +20,27 @@ require "gnome2/rake/windows-binary-build-task"
20
20
  module GNOME2
21
21
  module Rake
22
22
  class PackageTask
23
+ class << self
24
+ def define(spec, root_dir, &block)
25
+ new(spec, root_dir, &block).define
26
+ end
27
+ end
28
+
23
29
  include ::Rake::DSL
24
30
 
25
31
  attr_accessor :name, :summary, :description, :author, :email, :homepage, :required_ruby_version, :post_install_message
26
32
  attr_reader :root_dir
27
- def initialize
33
+ def initialize(spec=nil, root_dir=nil)
34
+ @spec = spec
28
35
  initialize_variables
29
36
  initialize_configurations
30
- file, line, method = caller[1].scan(/^(.*):(\d+)(?::.*`(.*)')?\Z/).first
31
- @package = Package.new(File.dirname(file))
37
+ if @spec
38
+ @package = Package.new(@spec.name, root_dir)
39
+ else
40
+ file, line, method = caller[1].scan(/^(.*):(\d+)(?::.*`(.*)')?\Z/).first
41
+ root_dir = File.dirname(file)
42
+ @package = Package.new(File.basename(root_dir), root_dir)
43
+ end
32
44
  @packages = FileList["#{@package.root_dir.parent}/*"].map{|f| File.directory?(f) ? File.basename(f) : nil}.compact
33
45
  @name = @package.name
34
46
  @cross_compiling_hooks = []
@@ -107,7 +119,7 @@ module GNOME2
107
119
  @description = ""
108
120
  @author = "The Ruby-GNOME2 Project Team"
109
121
  @email = "ruby-gnome2-devel-en@lists.sourceforge.net"
110
- @homepage = "http://ruby-gnome2.sourceforge.jp/"
122
+ @homepage = "https://ruby-gnome2.osdn.jp/"
111
123
  @external_packages = []
112
124
  end
113
125
 
@@ -120,7 +132,7 @@ module GNOME2
120
132
  end
121
133
 
122
134
  def define_spec
123
- @spec = Gem::Specification.new do |s|
135
+ @spec ||= Gem::Specification.new do |s|
124
136
  s.name = @name
125
137
  s.summary = @summary
126
138
  s.description = @description
@@ -26,9 +26,9 @@ module GNOME2
26
26
  attr_reader :windows
27
27
  attr_reader :native
28
28
  attr_writer :external_packages
29
- def initialize(root_dir)
29
+ def initialize(name, root_dir)
30
+ @name = name
30
31
  @root_dir = Pathname.new(root_dir).expand_path
31
- @name = @root_dir.basename.to_s
32
32
  @windows = WindowsConfiguration.new
33
33
  @native = NativeConfiguration.new
34
34
  @external_packages = []
@@ -165,16 +165,18 @@ module GNOME2
165
165
  "MSYSTEM" => "MINGW64",
166
166
  "GREP_OPTIONS" => "--text",
167
167
  "PATH" => path,
168
+ "PKG_CONFIG" => pkg_config,
168
169
  }
169
170
  depended_packages = @package.windows.build_dependencies
170
171
  use_packages = [@package.name] + depended_packages
171
- pkg_config_path = use_packages.collect do |package|
172
- "../#{package}/#{@package.windows.relative_binary_dir}/lib/pkgconfig"
172
+ pkg_config_path = [rcairo_pkgconfig_path]
173
+ use_packages.each do |package|
174
+ path = "../#{package}/#{@package.windows.relative_binary_dir}/lib/pkgconfig"
175
+ pkg_config_path << path
173
176
  end
174
177
  env["PKG_CONFIG_PATH"] = pkg_config_path.collect do |path|
175
178
  File.expand_path(path)
176
179
  end.join(":")
177
- env["PKG_CONFIG_LIBDIR"] = rcairo_pkgconfig_path
178
180
  env
179
181
  end
180
182
 
@@ -209,8 +211,8 @@ module GNOME2
209
211
  cross_file.puts(<<-CROSS_FILE)
210
212
  [host_machine]
211
213
  system = 'windows'
212
- cpu_family = 'x86_64'
213
- cpu = 'x86_64'
214
+ cpu_family = '#{meson_cpu_family}'
215
+ cpu = '#{meson_cpu}'
214
216
  endian = 'littel'
215
217
 
216
218
  [binaries]
@@ -219,7 +221,12 @@ cpp = '/usr/bin/#{cxx(package)}'
219
221
  ar = '/usr/bin/#{ar}'
220
222
  strip = '/usr/bin/#{strip}'
221
223
  dlltool = '/usr/bin/#{dlltool}'
222
- pkgconfig = '/usr/bin/pkg-config'
224
+ pkgconfig = '/usr/bin/#{pkg_config}'
225
+ windres = '/usr/bin/#{windres}'
226
+ exe_wrapper = 'wine'
227
+
228
+ [properties]
229
+ root = '/usr/#{@package.windows.build_host}'
223
230
  CROSS_FILE
224
231
  cross_file.close
225
232
  sh(env.merge({
@@ -235,6 +242,24 @@ pkgconfig = '/usr/bin/pkg-config'
235
242
  *package.windows.meson_args) or exit(false)
236
243
  end
237
244
 
245
+ def meson_cpu_family
246
+ case @package.windows.build_architecture
247
+ when "x86"
248
+ "x86"
249
+ when "x86_64"
250
+ "x86_64"
251
+ end
252
+ end
253
+
254
+ def meson_cpu
255
+ case @package.windows.build_architecture
256
+ when "x86"
257
+ "i686"
258
+ when "x86_64"
259
+ "x86_64"
260
+ end
261
+ end
262
+
238
263
  def cmake(env, package)
239
264
  sh(env,
240
265
  "cmake",
@@ -322,6 +347,14 @@ pkgconfig = '/usr/bin/pkg-config'
322
347
  "#{@package.windows.build_host}-dlltool"
323
348
  end
324
349
 
350
+ def pkg_config
351
+ "#{@package.windows.build_host}-pkg-config"
352
+ end
353
+
354
+ def windres
355
+ "#{@package.windows.build_host}-windres"
356
+ end
357
+
325
358
  def g_ir_scanner_bin_dir
326
359
  "#{@package.project_root_dir}/gobject-introspection/" +
327
360
  "#{@package.native.relative_binary_dir}/bin"
data/lib/mkmf-gnome2.rb CHANGED
@@ -23,7 +23,7 @@ end
23
23
 
24
24
  def disable_optimization_build_flag(flags)
25
25
  if gcc?
26
- flags.gsub(/(^|\s)?-O\d(\s|$)?/, '\\1-O0\\2')
26
+ RbConfig.expand(flags.dup).gsub(/(^|\s)?-O\d(\s|$)?/, '\\1-O0\\2')
27
27
  else
28
28
  flags
29
29
  end
@@ -31,9 +31,10 @@ end
31
31
 
32
32
  def enable_debug_build_flag(flags)
33
33
  if gcc?
34
+ expanded_flags = RbConfig.expand(flags.dup)
34
35
  debug_option_pattern = /(^|\s)-g\d?(\s|$)/
35
- if debug_option_pattern =~ flags
36
- flags.gsub(debug_option_pattern, '\\1-g3\\2')
36
+ if debug_option_pattern =~ expanded_flags
37
+ expanded_flags.gsub(debug_option_pattern, '\\1-g3\\2')
37
38
  else
38
39
  flags + " -g3"
39
40
  end
@@ -14,13 +14,13 @@ $KCODE = "U"
14
14
  #
15
15
  # Create bookmarkfile data.
16
16
  #
17
- URI = "http://ruby-gnome2.sourceforge.jp/"
17
+ URI = "https://ruby-gnome2.osdn.jp/"
18
18
  bf = GLib::BookmarkFile.new
19
19
  bf.set_title(URI, "Ruby-GNOME2 sample")
20
20
  bf.set_description(URI, "Ruby-GNOME2 Sampe for GLib::BookmarkFile")
21
21
  bf.set_mime_type(URI, "text/html")
22
22
  bf.set_private(URI, false)
23
- bf.set_icon(URI, "http://ruby-gnome2.sourceforge.jp/logo-gy.png", "image/png")
23
+ bf.set_icon(URI, "https://ruby-gnome2.osdn.jp/logo-gy.png", "image/png")
24
24
  bf.set_added(URI, Time.now)
25
25
  bf.set_modified(URI, Time.now)
26
26
  bf.set_visited(URI, Time.now)
@@ -32,12 +32,12 @@ class MyButton < Gtk::Button
32
32
  end
33
33
 
34
34
  # define new signal "hoge"
35
- signal_new("hoge", # name
36
- GLib::Signal::RUN_FIRST, # flags
37
- nil, # accumulator (XXX: not supported yet)
38
- nil, # return type (void == nil)
39
- Integer, Integer # parameter types
40
- )
35
+ define_signal("hoge", # name
36
+ GLib::Signal::RUN_FIRST, # flags
37
+ nil, # accumulator (XXX: not supported yet)
38
+ nil, # return type (void == nil)
39
+ Integer, Integer # parameter types
40
+ )
41
41
  # define default handler of "hoge" signal
42
42
  def signal_do_hoge(a, b)
43
43
  puts "MyButton#signal_do_hoge enter"
@@ -32,12 +32,12 @@ class MyButton < Gtk::Button
32
32
  end
33
33
 
34
34
  # define new signal "hoge"
35
- signal_new("hoge", # name
36
- GLib::Signal::RUN_FIRST, # flags
37
- nil, # accumulator (XXX: not supported yet)
38
- GLib::Type["void"], # return type
39
- GLib::Type["gint"], GLib::Type["gint"] # parameter types
40
- )
35
+ define_signal("hoge", # name
36
+ GLib::Signal::RUN_FIRST, # flags
37
+ nil, # accumulator (XXX: not supported yet)
38
+ GLib::Type["void"], # return type
39
+ GLib::Type["gint"], GLib::Type["gint"] # parameter types
40
+ )
41
41
  # define default handler of "hoge" signal
42
42
  def signal_do_hoge(a, b)
43
43
  puts "MyButton#signal_do_hoge enter"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2018 Ruby-GNOME2 Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -13,7 +13,7 @@
13
13
  # You should have received a copy of the GNU Lesser General Public
14
14
  # License along with this library; if not, write to the Free Software
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
-
16
+
17
17
  class TestSignal < Test::Unit::TestCase
18
18
  def test_signal_flags
19
19
  assert_const_defined(GLib, :SignalFlags)
@@ -31,4 +31,36 @@ class TestSignal < Test::Unit::TestCase
31
31
  assert_kind_of(GLib::SignalMatchType, GLib::Signal::MATCH_ID)
32
32
  assert_equal(GLib::SignalMatchType::MASK, GLib::Signal::MATCH_MASK)
33
33
  end
34
+
35
+ class CustomSignalObject < GLib::Object
36
+ type_register
37
+
38
+ define_signal(:changed, :run_first, nil, nil)
39
+
40
+ attr_reader :n_changed
41
+ def initialize
42
+ super
43
+ @n_changed = 0
44
+ end
45
+
46
+ def signal_do_changed
47
+ @n_changed += 1
48
+ end
49
+ end
50
+
51
+ def test_gc
52
+ n = 10
53
+ custom_signal_object = CustomSignalObject.new
54
+ n.times do
55
+ custom_signal_object.signal_emit(:changed)
56
+ GC.start
57
+ end
58
+ assert_equal(n, custom_signal_object.n_changed)
59
+ end
60
+
61
+ def test_inspect
62
+ signal = CustomSignalObject.signal(:changed)
63
+ assert_equal("\#<GLib::Signal TestSignal::CustomSignalObject\#changed>",
64
+ signal.inspect)
65
+ end
34
66
  end