glib2 3.4.3 → 3.5.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/ext/glib2/extconf.rb +1 -5
  4. data/ext/glib2/glib-enum-types.c +1233 -0
  5. data/ext/glib2/glib-enum-types.h +154 -0
  6. data/ext/glib2/glib2.def +2 -0
  7. data/ext/glib2/rbglib-bytes.c +1 -5
  8. data/ext/glib2/rbglib-gc.c +98 -52
  9. data/ext/glib2/rbglib-variant-type.c +1 -5
  10. data/ext/glib2/rbglib-variant.c +6 -7
  11. data/ext/glib2/rbglib.c +68 -1
  12. data/ext/glib2/rbglib.h +13 -3
  13. data/ext/glib2/rbglib_bookmarkfile.c +1 -1
  14. data/ext/glib2/rbglib_datetime.c +1 -5
  15. data/ext/glib2/rbglib_error.c +39 -12
  16. data/ext/glib2/rbglib_fileutils.c +1 -17
  17. data/ext/glib2/rbglib_iochannel.c +4 -4
  18. data/ext/glib2/rbglib_keyfile.c +1 -35
  19. data/ext/glib2/rbglib_maincontext.c +6 -32
  20. data/ext/glib2/rbglib_mainloop.c +2 -17
  21. data/ext/glib2/rbglib_matchinfo.c +1 -5
  22. data/ext/glib2/rbglib_messages.c +4 -5
  23. data/ext/glib2/rbglib_pollfd.c +1 -25
  24. data/ext/glib2/rbglib_regex.c +1 -13
  25. data/ext/glib2/rbglib_source.c +1 -39
  26. data/ext/glib2/rbglib_spawn.c +5 -10
  27. data/ext/glib2/rbglib_spawnerror.c +2 -2
  28. data/ext/glib2/rbglib_threads.c +2 -15
  29. data/ext/glib2/rbglib_timezone.c +1 -5
  30. data/ext/glib2/rbglib_unichar.c +46 -5
  31. data/ext/glib2/rbglib_unicode.c +1 -18
  32. data/ext/glib2/rbglib_utils.c +1 -14
  33. data/ext/glib2/rbglib_win32.c +3 -7
  34. data/ext/glib2/rbgobj_binding.c +1 -7
  35. data/ext/glib2/rbgobj_boxed.c +1 -1
  36. data/ext/glib2/rbgobj_closure.c +22 -9
  37. data/ext/glib2/rbgobj_enums.c +3 -2
  38. data/ext/glib2/rbgobj_flags.c +1 -1
  39. data/ext/glib2/rbgobj_object.c +117 -106
  40. data/ext/glib2/rbgobj_param.c +3 -9
  41. data/ext/glib2/rbgobj_paramspecs.c +6 -24
  42. data/ext/glib2/rbgobj_signal.c +105 -93
  43. data/ext/glib2/rbgobj_strv.c +2 -2
  44. data/ext/glib2/rbgobj_type.c +58 -67
  45. data/ext/glib2/rbgobj_typeinterface.c +38 -2
  46. data/ext/glib2/rbgobj_value.c +23 -8
  47. data/ext/glib2/rbgobj_valuetypes.c +14 -62
  48. data/ext/glib2/rbgobject.c +4 -6
  49. data/ext/glib2/rbgobject.h +2 -27
  50. data/ext/glib2/rbgprivate.h +10 -6
  51. data/ext/glib2/rbgutil.h +3 -2
  52. data/ext/glib2/rbgutil_callback.c +30 -27
  53. data/lib/glib2/deprecated.rb +22 -1
  54. data/lib/glib2.rb +54 -3
  55. data/lib/mkmf-gnome.rb +7 -6
  56. data/test/glib-test-utils.rb +22 -3
  57. data/test/run-test.rb +49 -15
  58. data/test/test-binding.rb +1 -11
  59. data/test/test-bytes.rb +1 -5
  60. data/test/test-date-time.rb +1 -3
  61. data/test/{glib-test-init.rb → test-error.rb} +25 -3
  62. data/test/test-file-utils.rb +1 -32
  63. data/test/test-iochannel.rb +3 -5
  64. data/test/test-key-file.rb +5 -6
  65. data/test/test-match-info.rb +1 -5
  66. data/test/test-regex.rb +1 -5
  67. data/test/test-source.rb +1 -14
  68. data/test/test-spawn.rb +4 -1
  69. data/test/test-time-zone.rb +1 -5
  70. data/test/test-timeout.rb +2 -3
  71. data/test/test-unicode.rb +16 -12
  72. data/test/test-utils.rb +2 -8
  73. data/test/test-variant-type.rb +1 -3
  74. data/test/test-win32.rb +6 -6
  75. metadata +6 -5
  76. data/ext/glib2/rbgobj_valuearray.c +0 -100
@@ -0,0 +1,154 @@
1
+
2
+ /* Generated by glib-mkenums.rb ($Id$) */
3
+
4
+ #ifndef __GLIB_ENUM_TYPES_H__
5
+ #define __GLIB_ENUM_TYPES_H__
6
+
7
+ #include <glib-object.h>
8
+
9
+ G_BEGIN_DECLS
10
+
11
+ /* enumerations from "/usr/include/glib-2.0/glib/gvariant.h" */
12
+ GType g_variant_class_get_type (void);
13
+ #define G_TYPE_VARIANT_CLASS (g_variant_class_get_type())
14
+ GType g_variant_parse_error_get_type (void);
15
+ #define G_TYPE_VARIANT_PARSE_ERROR (g_variant_parse_error_get_type())
16
+
17
+ /* enumerations from "/usr/include/glib-2.0/glib/gspawn.h" */
18
+ GType g_spawn_error_get_type (void);
19
+ #define G_TYPE_SPAWN_ERROR (g_spawn_error_get_type())
20
+ GType g_spawn_flags_get_type (void);
21
+ #define G_TYPE_SPAWN_FLAGS (g_spawn_flags_get_type())
22
+
23
+ /* enumerations from "/usr/include/glib-2.0/glib/gkeyfile.h" */
24
+ GType g_key_file_error_get_type (void);
25
+ #define G_TYPE_KEY_FILE_ERROR (g_key_file_error_get_type())
26
+ GType g_key_file_flags_get_type (void);
27
+ #define G_TYPE_KEY_FILE_FLAGS (g_key_file_flags_get_type())
28
+
29
+ /* enumerations from "/usr/include/glib-2.0/glib/gnode.h" */
30
+ GType g_traverse_flags_get_type (void);
31
+ #define G_TYPE_TRAVERSE_FLAGS (g_traverse_flags_get_type())
32
+ GType g_traverse_type_get_type (void);
33
+ #define G_TYPE_TRAVERSE_TYPE (g_traverse_type_get_type())
34
+
35
+ /* enumerations from "/usr/include/glib-2.0/glib/gshell.h" */
36
+ GType g_shell_error_get_type (void);
37
+ #define G_TYPE_SHELL_ERROR (g_shell_error_get_type())
38
+
39
+ /* enumerations from "/usr/include/glib-2.0/glib/gslice.h" */
40
+ GType g_slice_config_get_type (void);
41
+ #define G_TYPE_SLICE_CONFIG (g_slice_config_get_type())
42
+
43
+ /* enumerations from "/usr/include/glib-2.0/glib/gregex.h" */
44
+ GType g_regex_error_get_type (void);
45
+ #define G_TYPE_REGEX_ERROR (g_regex_error_get_type())
46
+ GType g_regex_compile_flags_get_type (void);
47
+ #define G_TYPE_REGEX_COMPILE_FLAGS (g_regex_compile_flags_get_type())
48
+ GType g_regex_match_flags_get_type (void);
49
+ #define G_TYPE_REGEX_MATCH_FLAGS (g_regex_match_flags_get_type())
50
+
51
+ /* enumerations from "/usr/include/glib-2.0/glib/gmarkup.h" */
52
+ GType g_markup_error_get_type (void);
53
+ #define G_TYPE_MARKUP_ERROR (g_markup_error_get_type())
54
+ GType g_markup_parse_flags_get_type (void);
55
+ #define G_TYPE_MARKUP_PARSE_FLAGS (g_markup_parse_flags_get_type())
56
+ GType g_markup_collect_type_get_type (void);
57
+ #define G_TYPE_MARKUP_COLLECT_TYPE (g_markup_collect_type_get_type())
58
+
59
+ /* enumerations from "/usr/include/glib-2.0/glib/gtestutils.h" */
60
+ GType g_test_trap_flags_get_type (void);
61
+ #define G_TYPE_TEST_TRAP_FLAGS (g_test_trap_flags_get_type())
62
+ GType g_test_subprocess_flags_get_type (void);
63
+ #define G_TYPE_TEST_SUBPROCESS_FLAGS (g_test_subprocess_flags_get_type())
64
+ GType g_test_log_type_get_type (void);
65
+ #define G_TYPE_TEST_LOG_TYPE (g_test_log_type_get_type())
66
+ GType g_test_file_type_get_type (void);
67
+ #define G_TYPE_TEST_FILE_TYPE (g_test_file_type_get_type())
68
+
69
+ /* enumerations from "/usr/include/glib-2.0/glib/gfileutils.h" */
70
+ GType g_file_error_get_type (void);
71
+ #define G_TYPE_FILE_ERROR (g_file_error_get_type())
72
+ GType g_file_test_get_type (void);
73
+ #define G_TYPE_FILE_TEST (g_file_test_get_type())
74
+
75
+ /* enumerations from "/usr/include/glib-2.0/glib/gtimezone.h" */
76
+ GType g_time_type_get_type (void);
77
+ #define G_TYPE_TIME_TYPE (g_time_type_get_type())
78
+
79
+ /* enumerations from "/usr/include/glib-2.0/glib/gdate.h" */
80
+ GType g_date_dm_y_get_type (void);
81
+ #define G_TYPE_DATE_DM_Y (g_date_dm_y_get_type())
82
+ GType g_date_weekday_get_type (void);
83
+ #define G_TYPE_DATE_WEEKDAY (g_date_weekday_get_type())
84
+ GType g_date_month_get_type (void);
85
+ #define G_TYPE_DATE_MONTH (g_date_month_get_type())
86
+
87
+ /* enumerations from "/usr/include/glib-2.0/glib/gunicode.h" */
88
+ GType g_unicode_type_get_type (void);
89
+ #define G_TYPE_UNICODE_TYPE (g_unicode_type_get_type())
90
+ GType g_unicode_break_type_get_type (void);
91
+ #define G_TYPE_UNICODE_BREAK_TYPE (g_unicode_break_type_get_type())
92
+ GType g_unicode_script_get_type (void);
93
+ #define G_TYPE_UNICODE_SCRIPT (g_unicode_script_get_type())
94
+ GType g_normalize_mode_get_type (void);
95
+ #define G_TYPE_NORMALIZE_MODE (g_normalize_mode_get_type())
96
+
97
+ /* enumerations from "/usr/include/glib-2.0/glib/ghook.h" */
98
+ GType g_hook_flag_mask_get_type (void);
99
+ #define G_TYPE_HOOK_FLAG_MASK (g_hook_flag_mask_get_type())
100
+
101
+ /* enumerations from "/usr/include/glib-2.0/glib/gthread.h" */
102
+ GType g_thread_error_get_type (void);
103
+ #define G_TYPE_THREAD_ERROR (g_thread_error_get_type())
104
+ GType g_once_status_get_type (void);
105
+ #define G_TYPE_ONCE_STATUS (g_once_status_get_type())
106
+
107
+ /* enumerations from "/usr/include/glib-2.0/glib/gstrfuncs.h" */
108
+ GType g_ascii_type_get_type (void);
109
+ #define G_TYPE_ASCII_TYPE (g_ascii_type_get_type())
110
+
111
+ /* enumerations from "/usr/include/glib-2.0/glib/gmessages.h" */
112
+ GType g_log_level_flags_get_type (void);
113
+ #define G_TYPE_LOG_LEVEL_FLAGS (g_log_level_flags_get_type())
114
+
115
+ /* enumerations from "/usr/include/glib-2.0/glib/gchecksum.h" */
116
+ GType g_checksum_type_get_type (void);
117
+ #define G_TYPE_CHECKSUM_TYPE (g_checksum_type_get_type())
118
+
119
+ /* enumerations from "/usr/include/glib-2.0/glib/gutils.h" */
120
+ GType g_user_directory_get_type (void);
121
+ #define G_TYPE_USER_DIRECTORY (g_user_directory_get_type())
122
+ GType g_format_size_flags_get_type (void);
123
+ #define G_TYPE_FORMAT_SIZE_FLAGS (g_format_size_flags_get_type())
124
+
125
+ /* enumerations from "/usr/include/glib-2.0/glib/goption.h" */
126
+ GType g_option_flags_get_type (void);
127
+ #define G_TYPE_OPTION_FLAGS (g_option_flags_get_type())
128
+ GType g_option_arg_get_type (void);
129
+ #define G_TYPE_OPTION_ARG (g_option_arg_get_type())
130
+ GType g_option_error_get_type (void);
131
+ #define G_TYPE_OPTION_ERROR (g_option_error_get_type())
132
+
133
+ /* enumerations from "/usr/include/glib-2.0/glib/gconvert.h" */
134
+ GType g_convert_error_get_type (void);
135
+ #define G_TYPE_CONVERT_ERROR (g_convert_error_get_type())
136
+
137
+ /* enumerations from "/usr/include/glib-2.0/glib/gbookmarkfile.h" */
138
+ GType g_bookmark_file_error_get_type (void);
139
+ #define G_TYPE_BOOKMARK_FILE_ERROR (g_bookmark_file_error_get_type())
140
+
141
+ /* enumerations from "/usr/include/glib-2.0/gobject/gsignal.h" */
142
+ GType g_signal_flags_get_type (void);
143
+ #define G_TYPE_SIGNAL_FLAGS (g_signal_flags_get_type())
144
+ GType g_connect_flags_get_type (void);
145
+ #define G_TYPE_CONNECT_FLAGS (g_connect_flags_get_type())
146
+ GType g_signal_match_type_get_type (void);
147
+ #define G_TYPE_SIGNAL_MATCH_TYPE (g_signal_match_type_get_type())
148
+
149
+ G_END_DECLS
150
+
151
+ #endif /* __GLIB_ENUM_TYPES_H__ */
152
+
153
+ /* Generated data ends here */
154
+
data/ext/glib2/glib2.def CHANGED
@@ -153,11 +153,13 @@ EXPORTS
153
153
  rbgutil_glibid_r2g_func
154
154
  rbgutil_sym_g2r_func
155
155
  rbgutil_protect
156
+ rbgutil_on_callback_error
156
157
  rbgutil_invoke_callback
157
158
  rbgutil_start_callback_dispatch_thread
158
159
  rbgutil_stop_callback_dispatch_thread
159
160
  rbgutil_string_set_utf8_encoding
160
161
  rbgutil_key_equal
162
+ rbgerr_ruby_error_quark
161
163
  rbgerr_define_gerror
162
164
  rbgerr_gerror2exception
163
165
  rbgobj_convert_define
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2017-2019 Ruby-GNOME Project Team
3
+ * Copyright (C) 2017-2021 Ruby-GNOME Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -32,7 +32,6 @@ rbg_is_bytes(VALUE object)
32
32
  return RVAL2CBOOL(rb_obj_is_kind_of(object, RG_TARGET_NAMESPACE));
33
33
  }
34
34
 
35
- #if GLIB_CHECK_VERSION(2, 32, 0)
36
35
  static VALUE RG_TARGET_NAMESPACE;
37
36
 
38
37
  static VALUE
@@ -119,12 +118,10 @@ rg_pointer(VALUE self)
119
118
 
120
119
  return ULONG2NUM((guintptr)data);
121
120
  }
122
- #endif
123
121
 
124
122
  void
125
123
  Init_glib_bytes(void)
126
124
  {
127
- #if GLIB_CHECK_VERSION(2, 32, 0)
128
125
  RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BYTES, "Bytes", mGLib);
129
126
 
130
127
  RG_DEF_SMETHOD(try_convert, 1);
@@ -135,5 +132,4 @@ Init_glib_bytes(void)
135
132
  RG_DEF_METHOD(size, 0);
136
133
  RG_DEF_ALIAS("length", "size");
137
134
  RG_DEF_METHOD(pointer, 0);
138
- #endif
139
135
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2018-2019 Ruby-GNOME Project Team
3
+ * Copyright (C) 2018-2020 Ruby-GNOME Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -20,32 +20,45 @@
20
20
 
21
21
  #include "rbgprivate.h"
22
22
 
23
- static GHashTable *rbg_objects = NULL;
23
+ typedef struct {
24
+ VALUE object;
25
+ guint ref_count;
26
+ } RBGGCMarkItem;
27
+
28
+ typedef struct {
29
+ GHashTable *items;
30
+ GMutex mutex;
31
+ } RBGGCMarker;
32
+
33
+ static RBGGCMarker *rbg_gc_marker_raw = NULL;
24
34
 
25
35
  static void
26
36
  gc_marker_mark_each(G_GNUC_UNUSED gpointer key,
27
37
  gpointer value,
28
38
  G_GNUC_UNUSED gpointer user_data)
29
39
  {
30
- VALUE rb_object = (VALUE)value;
31
- rb_gc_mark(rb_object);
40
+ RBGGCMarkItem *item = value;
41
+ rb_gc_mark(item->object);
32
42
  }
33
43
 
34
44
  static void
35
45
  gc_marker_mark(void *data)
36
46
  {
37
- GHashTable *hash_table = data;
38
- g_hash_table_foreach(hash_table, gc_marker_mark_each, NULL);
47
+ RBGGCMarker *marker = data;
48
+ g_mutex_lock(&(marker->mutex));
49
+ g_hash_table_foreach(marker->items, gc_marker_mark_each, NULL);
50
+ g_mutex_unlock(&(marker->mutex));
39
51
  }
40
52
 
41
53
  static void
42
54
  gc_marker_free(void *data)
43
55
  {
44
- GHashTable *hash_table = data;
45
- g_hash_table_unref(hash_table);
46
- if (hash_table == rbg_objects) {
47
- rbg_objects = NULL;
56
+ RBGGCMarker *marker_raw = data;
57
+ if (marker_raw == rbg_gc_marker_raw) {
58
+ rbg_gc_marker_raw = NULL;
48
59
  }
60
+ g_hash_table_unref(marker_raw->items);
61
+ g_free(marker_raw);
49
62
  }
50
63
 
51
64
  static const rb_data_type_t rbg_gc_marker_type = {
@@ -59,95 +72,128 @@ static const rb_data_type_t rbg_gc_marker_type = {
59
72
  RUBY_TYPED_FREE_IMMEDIATELY,
60
73
  };
61
74
 
62
- void
63
- rbg_gc_guard(gpointer key, VALUE rb_object)
75
+ static VALUE
76
+ rbg_gc_marker_new_raw(void)
64
77
  {
65
- if (!rbg_objects)
66
- return;
78
+ RBGGCMarker *gc_marker_raw = g_new(RBGGCMarker, 1);
79
+ gc_marker_raw->items = g_hash_table_new_full(g_direct_hash,
80
+ g_direct_equal,
81
+ NULL,
82
+ g_free);
83
+ g_mutex_init(&(gc_marker_raw->mutex));
84
+
85
+ return TypedData_Wrap_Struct(rb_cObject,
86
+ &rbg_gc_marker_type,
87
+ gc_marker_raw);
88
+ }
89
+
90
+ static void
91
+ rbg_gc_guard_raw(RBGGCMarker *gc_marker, gpointer key, VALUE rb_object)
92
+ {
93
+ g_mutex_lock(&(gc_marker->mutex));
94
+ RBGGCMarkItem *item = g_hash_table_lookup(gc_marker->items, key);
95
+ if (item) {
96
+ item->ref_count++;
97
+ } else {
98
+ item = g_new(RBGGCMarkItem, 1);
99
+ item->object = rb_object;
100
+ item->ref_count = 1;
101
+ g_hash_table_insert(gc_marker->items, key, item);
102
+ }
103
+ g_mutex_unlock(&(gc_marker->mutex));
104
+ }
67
105
 
68
- g_hash_table_insert(rbg_objects,
69
- key,
70
- (gpointer)rb_object);
106
+ static void
107
+ rbg_gc_unguard_raw(RBGGCMarker *gc_marker, gpointer key)
108
+ {
109
+ g_mutex_lock(&(gc_marker->mutex));
110
+ RBGGCMarkItem *item = g_hash_table_lookup(gc_marker->items, key);
111
+ if (item) {
112
+ item->ref_count--;
113
+ if (item->ref_count == 0) {
114
+ g_hash_table_remove(gc_marker->items, key);
115
+ }
116
+ }
117
+ g_mutex_unlock(&(gc_marker->mutex));
118
+ }
119
+
120
+ static void
121
+ rbg_gc_unguard_all_raw(RBGGCMarker *gc_marker)
122
+ {
123
+ g_mutex_lock(&(gc_marker->mutex));
124
+ g_hash_table_remove_all(gc_marker->items);
125
+ g_mutex_unlock(&(gc_marker->mutex));
71
126
  }
72
127
 
73
128
  void
74
- rbg_gc_unguard(gpointer key)
129
+ rbg_gc_guard(gpointer key, VALUE rb_object)
75
130
  {
76
- if (!rbg_objects)
131
+ if (!rbg_gc_marker_raw)
77
132
  return;
78
133
 
79
- g_hash_table_remove(rbg_objects, key);
134
+ rbg_gc_guard_raw(rbg_gc_marker_raw, key, rb_object);
80
135
  }
81
136
 
82
- static VALUE
83
- rbg_gc_marker_new_raw(GHashTable *rb_objects)
137
+ void
138
+ rbg_gc_unguard(gpointer key)
84
139
  {
85
- VALUE gc_marker;
140
+ if (!rbg_gc_marker_raw)
141
+ return;
86
142
 
87
- gc_marker = TypedData_Wrap_Struct(rb_cData,
88
- &rbg_gc_marker_type,
89
- rb_objects);
90
- return gc_marker;
143
+ rbg_gc_unguard_raw(rbg_gc_marker_raw, key);
91
144
  }
92
145
 
93
146
  VALUE
94
147
  rbg_gc_marker_new(void)
95
148
  {
96
- GHashTable *rb_objects;
97
-
98
- rb_objects = g_hash_table_new(g_direct_hash, g_direct_equal);
99
- return rbg_gc_marker_new_raw(rb_objects);
149
+ return rbg_gc_marker_new_raw();
100
150
  }
101
151
 
102
152
  void
103
153
  rbg_gc_marker_guard(VALUE rb_gc_marker, VALUE rb_object)
104
154
  {
105
- GHashTable *rb_objects;
106
-
155
+ RBGGCMarker *gc_marker;
107
156
  TypedData_Get_Struct(rb_gc_marker,
108
- GHashTable,
157
+ RBGGCMarker,
109
158
  &rbg_gc_marker_type,
110
- rb_objects);
111
- g_hash_table_insert(rb_objects,
112
- (gpointer)rb_object,
113
- (gpointer)rb_object);
159
+ gc_marker);
160
+ rbg_gc_guard_raw(gc_marker, RVAL2POINTER(rb_object), rb_object);
114
161
  }
115
162
 
116
163
  void
117
164
  rbg_gc_marker_unguard(VALUE rb_gc_marker, VALUE rb_object)
118
165
  {
119
- GHashTable *rb_objects;
120
-
121
166
  if (!RB_TYPE_P(rb_gc_marker, RUBY_T_DATA))
122
167
  return;
123
168
  if (!RTYPEDDATA_P(rb_gc_marker))
124
169
  return;
125
170
 
171
+ RBGGCMarker *gc_marker;
126
172
  TypedData_Get_Struct(rb_gc_marker,
127
- GHashTable,
173
+ RBGGCMarker,
128
174
  &rbg_gc_marker_type,
129
- rb_objects);
130
- g_hash_table_remove(rb_objects, (gpointer)rb_object);
175
+ gc_marker);
176
+ rbg_gc_unguard_raw(gc_marker, RVAL2POINTER(rb_object));
131
177
  }
132
178
 
133
179
  void
134
180
  rbg_gc_marker_unguard_all(VALUE rb_gc_marker)
135
181
  {
136
- GHashTable *rb_objects;
137
-
182
+ RBGGCMarker *gc_marker;
138
183
  TypedData_Get_Struct(rb_gc_marker,
139
- GHashTable,
184
+ RBGGCMarker,
140
185
  &rbg_gc_marker_type,
141
- rb_objects);
142
- g_hash_table_remove_all(rb_objects);
186
+ gc_marker);
187
+ rbg_gc_unguard_all_raw(gc_marker);
143
188
  }
144
189
 
145
190
  void
146
191
  Init_glib_gc(void)
147
192
  {
148
- VALUE gc_marker;
149
-
150
- rbg_objects = g_hash_table_new(g_direct_hash, g_direct_equal);
151
- gc_marker = rbg_gc_marker_new_raw(rbg_objects);
193
+ VALUE gc_marker = rbg_gc_marker_new_raw();
152
194
  rb_ivar_set(mGLib, rb_intern("gc_marker"), gc_marker);
195
+ TypedData_Get_Struct(gc_marker,
196
+ RBGGCMarker,
197
+ &rbg_gc_marker_type,
198
+ rbg_gc_marker_raw);
153
199
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2015-2016 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2015-2021 Ruby-GNOME Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -303,14 +303,10 @@ Init_glib_variant_type(void)
303
303
  DEF_TYPE(DICT_ENTRY);
304
304
  DEF_TYPE(DICTIONARY);
305
305
  DEF_TYPE(STRING_ARRAY);
306
- # if GLIB_CHECK_VERSION(2, 30, 0)
307
306
  DEF_TYPE(OBJECT_PATH_ARRAY);
308
- # endif
309
307
  DEF_TYPE(BYTESTRING);
310
308
  DEF_TYPE(BYTESTRING_ARRAY);
311
- # if GLIB_CHECK_VERSION(2, 30, 0)
312
309
  DEF_TYPE(VARDICT);
313
- # endif
314
310
 
315
311
  #undef DEF_TYPE
316
312
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2015-2016 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2015-2022 Ruby-GNOME Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,7 @@
22
22
 
23
23
  #define RG_TARGET_NAMESPACE cVariant
24
24
 
25
- #define _SELF(s) (DATA_PTR(s))
25
+ #define _SELF(s) (RTYPEDDATA_DATA(s))
26
26
 
27
27
  static VALUE RG_TARGET_NAMESPACE;
28
28
 
@@ -69,9 +69,10 @@ rbg_variant_to_ruby(GVariant *variant)
69
69
  VALUE value = rbg_variant_to_ruby(val);
70
70
  g_variant_unref(val);
71
71
  return value;
72
- } else if (g_variant_type_is_array(type)) {
72
+ } else if (g_variant_type_is_array(type) ||
73
+ g_variant_type_is_tuple(type)) {
73
74
  gsize i, len = g_variant_n_children(variant);
74
- VALUE ary = rb_ary_new2(len);
75
+ VALUE ary = rb_ary_new_capa(len);
75
76
  for (i = 0; i < len; i++) {
76
77
  GVariant *val = g_variant_get_child_value(variant, i);
77
78
  rb_ary_store(ary, i, rbg_variant_to_ruby(val));
@@ -191,7 +192,6 @@ rg_ruby_to_variant(VALUE rb_value, VALUE rb_variant_type)
191
192
  }
192
193
  }
193
194
  return g_variant_new_strv(strings, length);
194
- #if GLIB_CHECK_VERSION(2, 30, 0)
195
195
  } else if (g_variant_type_equal(variant_type,
196
196
  G_VARIANT_TYPE_OBJECT_PATH_ARRAY)) {
197
197
  const gchar **paths;
@@ -210,7 +210,6 @@ rg_ruby_to_variant(VALUE rb_value, VALUE rb_variant_type)
210
210
  }
211
211
  }
212
212
  return g_variant_new_objv(paths, length);
213
- #endif
214
213
  } else if (g_variant_type_equal(variant_type, G_VARIANT_TYPE_ARRAY)) {
215
214
  int i;
216
215
  GVariantBuilder builder;
@@ -259,7 +258,7 @@ rg_initialize(int argc, VALUE *argv, VALUE self)
259
258
  rb_scan_args(argc, argv, "11", &rb_value, &rb_variant_type);
260
259
  variant = rg_ruby_to_variant(rb_value, rb_variant_type);
261
260
  g_variant_ref_sink(variant);
262
- DATA_PTR(self) = variant;
261
+ RTYPEDDATA_DATA(self) = variant;
263
262
 
264
263
  return Qnil;
265
264
  }
data/ext/glib2/rbglib.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2019 Ruby-GNOME Project Team
3
+ * Copyright (C) 2011-2022 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2002,2003 Masahiro Sakai
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -1067,11 +1067,78 @@ rg_s_os_unix_p(G_GNUC_UNUSED VALUE self)
1067
1067
  #endif
1068
1068
  }
1069
1069
 
1070
+ #ifdef _WIN32
1071
+ /* Workaround: I don't know why but DllMain() is required with
1072
+ * mingw-w64-x86_64-gettext-0.21-1 or later. We don't need DllMain()
1073
+ * with mingw-w64-x86_64-gettext-0.19.8.1-10 or earlier.
1074
+ *
1075
+ * If we don't define DllMain() with mingw-w64-x86_64-gettext-0.21-1
1076
+ * or later, we got "The specified procedure could not be found" error
1077
+ * when "require 'glib2'" is evaluated.
1078
+ *
1079
+ * Notes:
1080
+ *
1081
+ * * This isn't happen when we build glib2 gem (gem install glib2)
1082
+ * with mingw-w64-x86_64-gettext-0.19.8.1-10 or earlier and update
1083
+ * mingw-w64-x86_64-gettext to 0.21-1 or later. (DllMain() isn't
1084
+ * required.) It seems that this is a link time
1085
+ * problem. msys64\mingw64\lib\libintl.dll.a may be related. It
1086
+ * may require DllMain() with mingw-w64-x86_64-gettext-0.21-1 or
1087
+ * later.
1088
+ *
1089
+ * * libintl.dll is linked with empty source and
1090
+ * mingw-w64-x86_64-gettext-0.21-1 or later:
1091
+ *
1092
+ * void hello(void) {}
1093
+ *
1094
+ * cc -shared empty.c -o empty.dll -lintl
1095
+ *
1096
+ * libintl.dll is NOT linked with empty source and
1097
+ * mingw-w64-x86_64-gettext-0.19.8-1-10 or earlier.
1098
+ *
1099
+ * * This isn't happen without Ruby. (At least I couldn't reproduce
1100
+ * this without Ruby.)
1101
+ *
1102
+ * The following program isn't failed:
1103
+ *
1104
+ * #include <stdio.h>
1105
+ * #include <windows.h>
1106
+ *
1107
+ * int
1108
+ * main(void) {
1109
+ * HMODULE b = LoadLibrary("empty.dll");
1110
+ * if (b) {
1111
+ * printf("loaded\n");
1112
+ * FreeLibrary(b);
1113
+ * } else {
1114
+ * printf("failed to load: %d\n", GetLastError());
1115
+ * }
1116
+ * return 0;
1117
+ * }
1118
+ */
1119
+ BOOL WINAPI
1120
+ DllMain(G_GNUC_UNUSED HINSTANCE hinstDLL,
1121
+ G_GNUC_UNUSED DWORD fdwReason,
1122
+ G_GNUC_UNUSED LPVOID lpvReserved);
1123
+
1124
+ BOOL WINAPI
1125
+ DllMain(G_GNUC_UNUSED HINSTANCE hinstDLL,
1126
+ G_GNUC_UNUSED DWORD fdwReason,
1127
+ G_GNUC_UNUSED LPVOID lpvReserved)
1128
+ {
1129
+ return TRUE;
1130
+ }
1131
+ #endif
1132
+
1070
1133
  extern void Init_glib2(void);
1071
1134
 
1072
1135
  void
1073
1136
  Init_glib2(void)
1074
1137
  {
1138
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
1139
+ rb_ext_ractor_safe(true);
1140
+ #endif
1141
+
1075
1142
  const gchar **filename_charsets;
1076
1143
 
1077
1144
  id_inspect = rb_intern("inspect");
data/ext/glib2/rbglib.h CHANGED
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2002-2020 Ruby-GNOME Project Team
3
+ * Copyright (C) 2002-2022 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2002,2003 Masahiro Sakai
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -32,8 +32,8 @@
32
32
  G_BEGIN_DECLS
33
33
 
34
34
  #define RBGLIB_MAJOR_VERSION 3
35
- #define RBGLIB_MINOR_VERSION 4
36
- #define RBGLIB_MICRO_VERSION 3
35
+ #define RBGLIB_MINOR_VERSION 5
36
+ #define RBGLIB_MICRO_VERSION 1
37
37
 
38
38
  #ifndef RB_ZALLOC
39
39
  # ifdef ZALLOC
@@ -139,6 +139,9 @@ G_BEGIN_DECLS
139
139
  #define RVAL2GUINT32S(ary, n) rbg_rval2guint32s(&(ary), &(n))
140
140
  #define RVAL2GDOUBLES(ary, n) rbg_rval2gdoubles(&(ary), &(n))
141
141
 
142
+ #define RVAL2POINTER(value) ((gpointer)(value))
143
+ #define POINTER2RVAL(pointer) ((VALUE)(pointer))
144
+
142
145
  #define GINTS2RVAL(ary, n) rbg_gints2rval(ary, n)
143
146
  #define GINTS2RVAL_FREE(ary, n) rbg_gints2rval(ary, n)
144
147
 
@@ -219,6 +222,13 @@ extern VALUE rbg_check_hash_type(VALUE object);
219
222
  extern void rbg_scan_options(VALUE options, ...);
220
223
 
221
224
  /* rbgerror.h */
225
+ typedef enum {
226
+ RBG_RUBY_ERROR_UNKNOWN,
227
+ } RBGRubyError;
228
+
229
+ #define RBG_RUBY_ERROR rbgerr_ruby_error_quark()
230
+ extern GQuark rbgerr_ruby_error_quark(void);
231
+
222
232
  extern VALUE rbgerr_gerror2exception(GError *error);
223
233
  extern VALUE rbgerr_define_gerror(GQuark domain, const gchar* name, VALUE module, VALUE parent, GType gtype);
224
234
 
@@ -385,7 +385,7 @@ rg_set_groups(VALUE self, VALUE rburi, VALUE rbgroups)
385
385
  long n;
386
386
  gchar **groups = RVAL2STRS(rbgroups, n);
387
387
 
388
- g_bookmark_file_set_groups(bookmark, uri, groups, n);
388
+ g_bookmark_file_set_groups(bookmark, uri, (const gchar **)groups, n);
389
389
 
390
390
  g_free(groups);
391
391
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2016 Ruby-GNOME2 Project Team
2
+ * Copyright (C) 2016-2021 Ruby-GNOME Project Team
3
3
  *
4
4
  * This library is free software; you can redistribute it and/or
5
5
  * modify it under the terms of the GNU Lesser General Public
@@ -69,10 +69,8 @@ rg_s_now(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
69
69
  date = g_date_time_new_now_local();
70
70
  } else if (is_utc_timezone(rb_timezone)) {
71
71
  date = g_date_time_new_now_utc();
72
- #if GLIB_CHECK_VERSION(2, 34, 0)
73
72
  } else if (is_timezone(rb_timezone)) {
74
73
  date = g_date_time_new_now(RVAL2GTIMEZONE(rb_timezone));
75
- #endif
76
74
  } else {
77
75
  rb_raise(rb_eArgError,
78
76
  "timezone must be nil, :local, :utc or GLib::TimeZone: "
@@ -160,7 +158,6 @@ rg_initialize(int argc, VALUE *argv, VALUE self)
160
158
  hour,
161
159
  minute,
162
160
  second);
163
- #if GLIB_CHECK_VERSION(2, 34, 0)
164
161
  } else if (is_timezone(rb_timezone)) {
165
162
  GTimeZone *timezone = NULL;
166
163
 
@@ -172,7 +169,6 @@ rg_initialize(int argc, VALUE *argv, VALUE self)
172
169
  hour,
173
170
  minute,
174
171
  second);
175
- #endif
176
172
  } else {
177
173
  rb_raise(rb_eArgError,
178
174
  ":timezone must be nil, :local, :utc or GLib::TimeZone: "