glib2 3.2.1 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: '02369ea278700a7eb9a86d3d262c1285e20ec17e'
4
- data.tar.gz: ff3fa9197fd8bdc49974be2694c7cba5a56c554d
2
+ SHA256:
3
+ metadata.gz: 6fbf19f5f9864d9781239ddb41fd1fcd43c59a8680e0782f2c46c385f025c093
4
+ data.tar.gz: 969f873a3454bbdb99e821c32555fd6cb89bdeaace83f85163a40dbc1c364340
5
5
  SHA512:
6
- metadata.gz: 3dde83bcd8b3546d1db154aa76e99d7d63b7d4c5942168b6f5de287969d85e0d425e9d3e95f663a7fca2d99024aadcc8e33f4837d34a41d93668161c1411ba46
7
- data.tar.gz: 3026321f0348810656ec618752da8d0dc2821ef17feb7897bab8ae53def124b2e3bf85c1b1e9f368e5efe8d833c450e1ec18c54194c7077f42847e48d1271359
6
+ metadata.gz: 614bd21a3057319d9ffa518e8e861cdafa1e1cbbf849d22962b3f1f2cbce0d8140e7a0f90fa685c4513978c3b0e0e072b94cf643acf99d38b866f5d8d497add9
7
+ data.tar.gz: cc89b4781a3e048a5a70ff03956bbed2d71f951ed5d17d64cd851f68f7fb06f5630314103a7c9822e9dbe70183bb55957885006b775a0cfaee03310d2868adc7
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- ruby -*-
2
2
  #
3
- # Copyright (C) 2011-2017 Ruby-GNOME2 Project Team
3
+ # Copyright (C) 2011-2018 Ruby-GNOME2 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
@@ -88,12 +88,13 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
88
88
  :name => "glib",
89
89
  :download_site => :gnome,
90
90
  :label => "GLib",
91
- :version => "2.54.1",
91
+ :version => "2.56.0",
92
92
  :compression_method => "xz",
93
93
  :windows => {
94
94
  :need_autoreconf => true,
95
95
  :patches => [
96
96
  "glib-2.54.1-add-missing-exeext.diff",
97
+ "glib-2.56.0-add-missing-weekday-full-is-locale.patch",
97
98
  ],
98
99
  :built_file => "bin/libglib-2.0-0.dll",
99
100
  },
@@ -126,32 +127,33 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
126
127
  :name => "libtasn1",
127
128
  :download_site => :gnu,
128
129
  :label => "Libtasn1",
129
- :version => "4.12",
130
+ :version => "4.13",
130
131
  :windows => {
131
132
  :built_file => "bin/libtasn1-6.dll",
132
133
  },
133
134
  },
134
135
  {
135
- :name => "libidn",
136
+ :name => "libidn2",
136
137
  :download_site => :gnu,
137
- :label => "Libidn",
138
- :version => "1.33",
138
+ :download_name => "libidn",
139
+ :label => "Libidn2",
140
+ :version => "2.0.4",
139
141
  :windows => {
140
- :built_file => "bin/libidn-11.dll",
142
+ :built_file => "bin/libidn2-0.dll",
141
143
  },
142
144
  },
143
145
  {
144
- :name => "p11-kit",
145
- :download_base_url => "https://p11-glue.freedesktop.org/releases",
146
+ :name => "p11-glue/p11-kit",
147
+ :download_site => :github,
146
148
  :label => "p11-kit",
147
- :version => "0.23.2",
149
+ :version => "0.23.3",
148
150
  :windows => {
149
151
  :built_file => "bin/libp11-kit-0.dll",
150
152
  },
151
153
  },
152
154
  {
153
155
  :name => "gnutls",
154
- :download_base_url => "ftp://ftp.gnutls.org/gcrypt/gnutls/v3.4",
156
+ :download_base_url => "https://www.gnupg.org/ftp/gcrypt/gnutls/v3.4",
155
157
  :label => "GnuTLS",
156
158
  :version => "3.4.10",
157
159
  :compression_method => "xz",
@@ -171,13 +173,12 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
171
173
  :name => "glib-networking",
172
174
  :download_site => :gnome,
173
175
  :label => "glib-networking",
174
- :version => "2.54.0",
176
+ :version => "2.56.0",
175
177
  :compression_method => "xz",
176
178
  :windows => {
177
- :configure_args => [
178
- "--without-libproxy",
179
- "--without-gnome-proxy",
180
- "--without-ca-certificates",
179
+ :meson_args => [
180
+ "-Dlibproxy_support=false",
181
+ "-Dgnome_proxy_support=false",
181
182
  ],
182
183
  :built_file => "lib/gio/modules/libgiognutls.dll",
183
184
  },
data/ext/glib2/glib2.def CHANGED
@@ -39,6 +39,9 @@ EXPORTS
39
39
  rbgobj_rvalue_to_gvalue
40
40
  rbgobj_initialize_gvalue
41
41
  rbgobj_initialize_object
42
+ rbgobj_class_info_lookup
43
+ rbgobj_class_info_lookup_by_gtype
44
+ rbgobj_class_info_define
42
45
  rbgobj_lookup_class
43
46
  rbgobj_lookup_class_by_gtype
44
47
  rbgobj_gtype_to_ruby_class
@@ -66,6 +66,7 @@ rg_to_s(VALUE self)
66
66
  # else
67
67
  rb_data = rb_enc_str_new(data, size, rb_ascii8bit_encoding());
68
68
  # endif
69
+ rb_obj_freeze(rb_data);
69
70
  return rb_data;
70
71
  }
71
72
 
data/ext/glib2/rbglib.h CHANGED
@@ -36,7 +36,7 @@ extern "C" {
36
36
 
37
37
  #define RBGLIB_MAJOR_VERSION 3
38
38
  #define RBGLIB_MINOR_VERSION 2
39
- #define RBGLIB_MICRO_VERSION 1
39
+ #define RBGLIB_MICRO_VERSION 2
40
40
 
41
41
  #ifndef RB_ZALLOC
42
42
  # ifdef ZALLOC
@@ -46,6 +46,10 @@ extern "C" {
46
46
  # endif
47
47
  #endif
48
48
 
49
+ #ifndef RB_ALLOC_N
50
+ # define RB_ALLOC_N(type, n) ALLOC_N(type, n)
51
+ #endif
52
+
49
53
  /* For Ruby < 2.3 */
50
54
  #ifndef RB_OBJ_FROZEN
51
55
  # define RB_OBJ_FROZEN(obj) OBJ_FROZEN(obj)
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2017 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2011-2018 Ruby-GNOME2 Project Team
4
4
  * Copyright (C) 2002-2004 Ruby-GNOME2 Project Team
5
5
  * Copyright (C) 2002-2003 Masahiro Sakai
6
6
  * Copyright (C) 1998-2000 Yukihiro Matsumoto,
@@ -58,8 +58,9 @@ holder_mark(gobj_holder *holder)
58
58
  }
59
59
 
60
60
  static void
61
- holder_unref(gobj_holder *holder)
61
+ holder_unref(void *data)
62
62
  {
63
+ gobj_holder *holder = data;
63
64
  if (holder->gobj) {
64
65
  if (!holder->destroyed) {
65
66
  g_object_set_qdata(holder->gobj, RUBY_GOBJECT_OBJ_KEY, NULL);
@@ -71,19 +72,37 @@ holder_unref(gobj_holder *holder)
71
72
  }
72
73
 
73
74
  static void
74
- holder_free(gobj_holder *holder)
75
+ holder_free(void *data)
75
76
  {
77
+ gobj_holder *holder = data;
76
78
  holder_unref(holder);
77
79
  xfree(holder);
78
80
  }
79
81
 
82
+ static const rb_data_type_t rg_glib_object_type = {
83
+ "GLib::Object",
84
+ {
85
+ holder_mark,
86
+ holder_free,
87
+ NULL,
88
+ NULL,
89
+ NULL,
90
+ },
91
+ NULL,
92
+ NULL,
93
+ RUBY_TYPED_FREE_IMMEDIATELY,
94
+ };
95
+
80
96
  VALUE
81
97
  rbgobj_object_alloc_func(VALUE klass)
82
98
  {
83
99
  gobj_holder* holder;
84
100
  VALUE result;
85
101
 
86
- result = Data_Make_Struct(klass, gobj_holder, holder_mark, holder_free, holder);
102
+ result = TypedData_Make_Struct(klass,
103
+ gobj_holder,
104
+ &rg_glib_object_type,
105
+ holder);
87
106
  holder->self = result;
88
107
  holder->gobj = NULL;
89
108
  holder->cinfo = NULL;
@@ -105,7 +124,7 @@ rbgobj_gobject_initialize(VALUE obj, gpointer cobj)
105
124
  gobj_holder* holder = g_object_get_qdata((GObject*)cobj, RUBY_GOBJECT_OBJ_KEY);
106
125
  if (holder)
107
126
  rb_raise(rb_eRuntimeError, "ruby wrapper for this GObject* already exists.");
108
- Data_Get_Struct(obj, gobj_holder, holder);
127
+ TypedData_Get_Struct(obj, gobj_holder, &rg_glib_object_type, holder);
109
128
  holder->cinfo = RVAL2CINFO(obj);
110
129
  holder->gobj = (GObject*)cobj;
111
130
  holder->destroyed = FALSE;
@@ -149,10 +168,7 @@ rbgobj_get_gobject(VALUE obj)
149
168
  {
150
169
  gobj_holder* holder;
151
170
 
152
- if (!RVAL2CBOOL(rb_obj_is_kind_of(obj, GTYPE2CLASS(G_TYPE_OBJECT))))
153
- rb_raise(rb_eTypeError, "not a GLib::Object");
154
-
155
- Data_Get_Struct(obj, gobj_holder, holder);
171
+ TypedData_Get_Struct(obj, gobj_holder, &rg_glib_object_type, holder);
156
172
 
157
173
  if (holder->destroyed)
158
174
  rb_raise(rb_eTypeError, "destroyed GLib::Object");
@@ -566,10 +582,7 @@ rg_destroyed_p(VALUE self)
566
582
  {
567
583
  gobj_holder* holder;
568
584
 
569
- if (!RVAL2CBOOL(rb_obj_is_kind_of(self, GTYPE2CLASS(G_TYPE_OBJECT))))
570
- rb_raise(rb_eTypeError, "not a GLib::Object");
571
-
572
- Data_Get_Struct(self, gobj_holder, holder);
585
+ TypedData_Get_Struct(self, gobj_holder, &rg_glib_object_type, holder);
573
586
 
574
587
  return CBOOL2RVAL(holder->destroyed);
575
588
  }
@@ -582,7 +595,7 @@ rg_inspect(VALUE self)
582
595
  char *s;
583
596
  VALUE result;
584
597
 
585
- Data_Get_Struct(self, gobj_holder, holder);
598
+ TypedData_Get_Struct(self, gobj_holder, &rg_glib_object_type, holder);
586
599
 
587
600
  class_name = rb_class2name(CLASS_OF(self));
588
601
  if (!holder->destroyed)
@@ -602,7 +615,7 @@ rg_unref(VALUE self)
602
615
  {
603
616
  gobj_holder* holder;
604
617
 
605
- Data_Get_Struct(self, gobj_holder, holder);
618
+ TypedData_Get_Struct(self, gobj_holder, &rg_glib_object_type, holder);
606
619
 
607
620
  if (holder->destroyed)
608
621
  rb_raise(rb_eTypeError, "destroyed GLib::Object");
@@ -780,7 +793,7 @@ static VALUE
780
793
  gobj_ref_count(VALUE self)
781
794
  {
782
795
  gobj_holder* holder;
783
- Data_Get_Struct(self, gobj_holder, holder);
796
+ TypedData_Get_Struct(self, gobj_holder, &rg_glib_object_type, holder);
784
797
  return INT2NUM(holder->gobj ? holder->gobj->ref_count : 0);
785
798
  }
786
799
 
@@ -788,7 +801,7 @@ static VALUE
788
801
  rg_floating_p(VALUE self)
789
802
  {
790
803
  gobj_holder* holder;
791
- Data_Get_Struct(self, gobj_holder, holder);
804
+ TypedData_Get_Struct(self, gobj_holder, &rg_glib_object_type, holder);
792
805
  if (holder->gobj) {
793
806
  return CBOOL2RVAL(g_object_is_floating(holder->gobj));
794
807
  } else {
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2002-2017 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2002-2018 Ruby-GNOME2 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
@@ -48,133 +48,93 @@ typedef struct {
48
48
  } RGObjClassInfoDynamic;
49
49
 
50
50
  typedef struct {
51
- VALUE parent;
52
51
  GType gtype;
53
- gboolean create_class;
54
- } RGObjClassByGtypeData;
52
+ const gchar *name;
53
+ VALUE module;
54
+ VALUE parent;
55
+ } RGObjDefineClassData;
55
56
 
56
57
  static void
57
- cinfo_mark(RGObjClassInfo* cinfo)
58
+ cinfo_mark(void *data)
58
59
  {
60
+ RGObjClassInfo *cinfo = data;
59
61
  rb_gc_mark(cinfo->klass);
60
62
  }
61
63
 
62
- const RGObjClassInfo *
63
- rbgobj_lookup_class(VALUE klass)
64
+ static void
65
+ cinfo_free(void *data)
64
66
  {
65
- VALUE data = rb_hash_aref(klass_to_cinfo, klass);
66
- if (!NIL_P(data)){
67
- RGObjClassInfo* cinfo;
68
- Data_Get_Struct(data, RGObjClassInfo, cinfo);
69
- return cinfo;
70
- }
71
-
72
- if (TYPE(klass) == T_CLASS) {
73
- VALUE super;
74
- super = rb_funcall(klass, id_superclass, 0);
75
- return rbgobj_lookup_class(super);
76
- }
77
-
78
- rb_raise(rb_eRuntimeError, "can't get gobject class information");
67
+ RGObjClassInfo *cinfo = data;
68
+ xfree(cinfo->name);
69
+ xfree(cinfo->data_type);
79
70
  }
80
71
 
81
- static const RGObjClassInfo *rbgobj_lookup_class_by_gtype_without_lock(GType gtype,
82
- VALUE parent,
83
- gboolean create_class);
72
+ static RGObjClassInfo *
73
+ rbgobj_class_info_define_without_lock(GType gtype,
74
+ const gchar *name,
75
+ VALUE module,
76
+ VALUE parent);
84
77
 
85
- static VALUE
86
- get_superclass(GType gtype)
78
+ static void
79
+ rbgobj_class_info_fill_name(RGObjClassInfo *cinfo)
87
80
  {
88
- VALUE super_class;
81
+ VALUE rb_name;
89
82
 
90
- if (rbgobj_convert_get_superclass(gtype, &super_class))
91
- return super_class;
83
+ if (cinfo->name) {
84
+ return;
85
+ }
92
86
 
93
- switch (gtype) {
94
- case G_TYPE_PARAM:
95
- case G_TYPE_OBJECT:
96
- return cInstantiatable;
97
- case G_TYPE_BOXED:
98
- return rb_cObject;
99
- case G_TYPE_POINTER:
100
- return rb_cData;
101
- case G_TYPE_ENUM:
102
- case G_TYPE_FLAGS:
103
- return rb_cObject;
104
- default:
105
- {
106
- GType parent_type;
87
+ if (!RB_TYPE_P(cinfo->klass, RUBY_T_CLASS)) {
88
+ return;
89
+ }
107
90
 
108
- parent_type = g_type_parent(gtype);
109
- if (parent_type == G_TYPE_INVALID) {
110
- return cInstantiatable;
111
- } else {
112
- const RGObjClassInfo *cinfo_super;
113
- cinfo_super =
114
- rbgobj_lookup_class_by_gtype_without_lock(parent_type,
115
- Qnil,
116
- TRUE);
117
- return cinfo_super->klass;
118
- }
119
- }
91
+ rb_name = rb_funcall(cinfo->klass, rb_intern("name"), 0);
92
+ if (NIL_P(rb_name)) {
93
+ return;
120
94
  }
95
+
96
+ cinfo->name = RB_ALLOC_N(char, RSTRING_LEN(rb_name) + 1);
97
+ memcpy(cinfo->name, RSTRING_PTR(rb_name), RSTRING_LEN(rb_name));
98
+ cinfo->name[RSTRING_LEN(rb_name)] = '\0';
99
+ cinfo->data_type->wrap_struct_name = cinfo->name;
121
100
  }
122
101
 
123
- static const RGObjClassInfo *
124
- rbgobj_lookup_class_by_gtype_without_lock(GType gtype, VALUE parent,
125
- gboolean create_class)
102
+ static RGObjClassInfo *
103
+ rbgobj_class_info_register_without_lock(GType gtype, VALUE klass)
126
104
  {
105
+ rb_data_type_t *data_type;
106
+ RGObjClassInfo *cinfo;
127
107
  GType fundamental_type;
128
- RGObjClassInfo* cinfo;
129
- RGObjClassInfoDynamic* cinfod;
130
- void* gclass = NULL;
108
+ RGObjClassInfoDynamic *cinfod;
109
+ void *gclass = NULL;
131
110
  VALUE c;
132
111
 
133
- if (gtype == G_TYPE_INVALID)
134
- return NULL;
135
-
136
- cinfo = g_hash_table_lookup(gtype_to_cinfo, GUINT_TO_POINTER(gtype));
137
- if (cinfo)
138
- return cinfo;
139
-
140
- if (!create_class)
141
- return NULL;
112
+ data_type = RB_ZALLOC(rb_data_type_t);
113
+ data_type->function.dmark = cinfo_mark;
114
+ data_type->function.dfree = cinfo_free;
115
+ if (RB_TYPE_P(klass, RUBY_T_CLASS)) {
116
+ VALUE p = RCLASS_SUPER(klass);
117
+ while (p != rb_cObject) {
118
+ if (RTYPEDDATA_P(p)) {
119
+ data_type->parent = RTYPEDDATA_TYPE(p);
120
+ break;
121
+ }
122
+ p = RCLASS_SUPER(p);
123
+ }
124
+ }
125
+ data_type->flags = RUBY_TYPED_FREE_IMMEDIATELY;
142
126
 
143
- c = Data_Make_Struct(rb_cData, RGObjClassInfo, cinfo_mark, NULL, cinfo);
127
+ c = TypedData_Make_Struct(rb_cData, RGObjClassInfo, data_type, cinfo);
128
+ cinfo->klass = klass;
144
129
  cinfo->gtype = gtype;
145
130
  cinfo->mark = NULL;
146
131
  cinfo->free = NULL;
147
132
  cinfo->flags = 0;
133
+ cinfo->name = NULL;
134
+ cinfo->data_type = data_type;
135
+ rbgobj_class_info_fill_name(cinfo);
148
136
 
149
137
  fundamental_type = G_TYPE_FUNDAMENTAL(gtype);
150
- switch (fundamental_type){
151
- case G_TYPE_POINTER:
152
- case G_TYPE_BOXED:
153
- case G_TYPE_PARAM:
154
- case G_TYPE_OBJECT:
155
- case G_TYPE_ENUM:
156
- case G_TYPE_FLAGS:
157
- if (NIL_P(parent)) parent = get_superclass(gtype);
158
- cinfo->klass = rb_funcall(rb_cClass, id_new, 1, parent);
159
- break;
160
-
161
- case G_TYPE_INTERFACE:
162
- cinfo->klass = rb_module_new();
163
- break;
164
-
165
- default:
166
- if (NIL_P(parent)) parent = get_superclass(gtype);
167
- if (NIL_P(parent)) {
168
- fprintf(stderr,
169
- "%s: %s's fundamental type %s isn't supported\n",
170
- "rbgobj_lookup_class_by_gtype",
171
- g_type_name(gtype),
172
- g_type_name(fundamental_type));
173
- return NULL;
174
- }
175
- cinfo->klass = rb_funcall(rb_cClass, id_new, 1, parent);
176
- }
177
-
178
138
  switch (fundamental_type){
179
139
  case G_TYPE_BOXED:
180
140
  rb_define_alloc_func(cinfo->klass, rbgobj_boxed_alloc_func);
@@ -217,10 +177,14 @@ rbgobj_lookup_class_by_gtype_without_lock(GType gtype, VALUE parent,
217
177
  interfaces = g_type_interfaces(gtype, &n_interfaces);
218
178
  for (i = 0; i < n_interfaces; i++){
219
179
  const RGObjClassInfo *iface_cinfo;
220
- iface_cinfo =
221
- rbgobj_lookup_class_by_gtype_without_lock(interfaces[i],
222
- Qnil,
223
- TRUE);
180
+ iface_cinfo = rbgobj_class_info_lookup_by_gtype(interfaces[i]);
181
+ if (!iface_cinfo) {
182
+ iface_cinfo =
183
+ rbgobj_class_info_define_without_lock(interfaces[i],
184
+ NULL,
185
+ rb_cObject,
186
+ Qnil);
187
+ }
224
188
  rb_include_module(cinfo->klass, iface_cinfo->klass);
225
189
  }
226
190
  g_free(interfaces);
@@ -253,55 +217,198 @@ rbgobj_lookup_class_by_gtype_without_lock(GType gtype, VALUE parent,
253
217
  }
254
218
 
255
219
  static VALUE
256
- rbgobj_lookup_class_by_gtype_body(VALUE data)
220
+ get_superclass(GType gtype, VALUE module)
221
+ {
222
+ VALUE super_class;
223
+
224
+ if (rbgobj_convert_get_superclass(gtype, &super_class))
225
+ return super_class;
226
+
227
+ switch (gtype) {
228
+ case G_TYPE_PARAM:
229
+ case G_TYPE_OBJECT:
230
+ return cInstantiatable;
231
+ case G_TYPE_BOXED:
232
+ return rb_cObject;
233
+ case G_TYPE_POINTER:
234
+ return rb_cData;
235
+ case G_TYPE_ENUM:
236
+ case G_TYPE_FLAGS:
237
+ return rb_cObject;
238
+ default:
239
+ {
240
+ GType parent_type;
241
+
242
+ parent_type = g_type_parent(gtype);
243
+ if (parent_type == G_TYPE_INVALID) {
244
+ return cInstantiatable;
245
+ } else {
246
+ const RGObjClassInfo *cinfo_super;
247
+ cinfo_super = rbgobj_class_info_lookup_by_gtype(parent_type);
248
+ if (!cinfo_super) {
249
+ cinfo_super = rbgobj_class_info_define_without_lock(parent_type,
250
+ NULL,
251
+ module,
252
+ Qnil);
253
+ }
254
+ return cinfo_super->klass;
255
+ }
256
+ }
257
+ }
258
+ }
259
+
260
+ static RGObjClassInfo *
261
+ rbgobj_class_info_define_without_lock(GType gtype,
262
+ const gchar *name,
263
+ VALUE module,
264
+ VALUE parent)
265
+ {
266
+ GType fundamental_type;
267
+ VALUE klass;
268
+
269
+ fundamental_type = G_TYPE_FUNDAMENTAL(gtype);
270
+ switch (fundamental_type){
271
+ case G_TYPE_POINTER:
272
+ case G_TYPE_BOXED:
273
+ case G_TYPE_PARAM:
274
+ case G_TYPE_OBJECT:
275
+ case G_TYPE_ENUM:
276
+ case G_TYPE_FLAGS:
277
+ if (NIL_P(parent)) parent = get_superclass(gtype, module);
278
+ klass = rb_funcall(rb_cClass, id_new, 1, parent);
279
+ break;
280
+
281
+ case G_TYPE_INTERFACE:
282
+ klass = rb_module_new();
283
+ break;
284
+
285
+ default:
286
+ if (NIL_P(parent)) parent = get_superclass(gtype, module);
287
+ if (NIL_P(parent)) {
288
+ fprintf(stderr,
289
+ "rbgobj_class_info_define: "
290
+ "Unsupported fundamental type: <%s>(%s)\n",
291
+ g_type_name(fundamental_type),
292
+ g_type_name(gtype));
293
+ return NULL;
294
+ }
295
+ klass = rb_funcall(rb_cClass, id_new, 1, parent);
296
+ }
297
+
298
+ if (name) {
299
+ rb_define_const(module, name, klass);
300
+ }
301
+ return rbgobj_class_info_register_without_lock(gtype, klass);
302
+ }
303
+
304
+ static VALUE
305
+ rbgobj_class_info_define_body(VALUE data)
257
306
  {
258
- RGObjClassByGtypeData *cdata = (RGObjClassByGtypeData *)data;
307
+ RGObjDefineClassData *cdata = (RGObjDefineClassData *)data;
259
308
  const RGObjClassInfo *cinfo;
260
309
 
261
- cinfo = rbgobj_lookup_class_by_gtype_without_lock(cdata->gtype,
262
- cdata->parent,
263
- cdata->create_class);
310
+ cinfo = rbgobj_class_info_define_without_lock(cdata->gtype,
311
+ cdata->name,
312
+ cdata->module,
313
+ cdata->parent);
264
314
  return (VALUE)cinfo;
265
315
  }
266
316
 
267
317
  static VALUE
268
- rbgobj_lookup_class_by_gtype_ensure(G_GNUC_UNUSED VALUE data)
318
+ rbgobj_class_info_define_ensure(G_GNUC_UNUSED VALUE data)
269
319
  {
270
320
  rb_funcall(lookup_class_mutex, id_unlock, 0);
271
321
  return Qundef;
272
322
  }
273
323
 
324
+ RGObjClassInfo *
325
+ rbgobj_class_info_define(GType gtype,
326
+ const gchar *name,
327
+ VALUE module,
328
+ VALUE parent)
329
+ {
330
+ RGObjDefineClassData data;
331
+
332
+ data.gtype = gtype;
333
+ data.name = name;
334
+ data.module = module;
335
+ data.parent = parent;
336
+
337
+ rb_funcall(lookup_class_mutex, id_lock, 0);
338
+ return (RGObjClassInfo *)rb_ensure(rbgobj_class_info_define_body,
339
+ (VALUE)&data,
340
+ rbgobj_class_info_define_ensure,
341
+ (VALUE)&data);
342
+ }
343
+
344
+ /* deprecated */
345
+ const RGObjClassInfo *
346
+ rbgobj_lookup_class(VALUE klass)
347
+ {
348
+ return rbgobj_class_info_lookup(klass);
349
+ }
350
+
351
+ const RGObjClassInfo *
352
+ rbgobj_class_info_lookup(VALUE klass)
353
+ {
354
+ VALUE data = rb_hash_aref(klass_to_cinfo, klass);
355
+ if (!NIL_P(data)) {
356
+ RGObjClassInfo *cinfo;
357
+ if (RTYPEDDATA_P(data)) {
358
+ TypedData_Get_Struct(data,
359
+ RGObjClassInfo,
360
+ RTYPEDDATA_TYPE(data),
361
+ cinfo);
362
+ } else {
363
+ Data_Get_Struct(data, RGObjClassInfo, cinfo);
364
+ }
365
+ return cinfo;
366
+ }
367
+
368
+ if (TYPE(klass) == T_CLASS) {
369
+ VALUE super;
370
+ super = rb_funcall(klass, id_superclass, 0);
371
+ return rbgobj_lookup_class(super);
372
+ }
373
+
374
+ rb_raise(rb_eRuntimeError, "can't get gobject class information");
375
+ return NULL;
376
+ }
377
+
378
+ const RGObjClassInfo *
379
+ rbgobj_class_info_lookup_by_gtype(GType gtype)
380
+ {
381
+ if (gtype == G_TYPE_INVALID)
382
+ return NULL;
383
+
384
+ return g_hash_table_lookup(gtype_to_cinfo, GUINT_TO_POINTER(gtype));
385
+ }
386
+
387
+ /* deprecated */
274
388
  const RGObjClassInfo *
275
389
  rbgobj_lookup_class_by_gtype(GType gtype, VALUE parent)
276
390
  {
277
391
  return rbgobj_lookup_class_by_gtype_full(gtype, parent, TRUE);
278
392
  }
279
393
 
394
+ /* deprecated */
280
395
  const RGObjClassInfo *
281
396
  rbgobj_lookup_class_by_gtype_full(GType gtype, VALUE parent,
282
397
  gboolean create_class)
283
398
  {
284
399
  const RGObjClassInfo *info;
285
- RGObjClassByGtypeData data;
286
400
 
287
- info = rbgobj_lookup_class_by_gtype_without_lock(gtype, parent, FALSE);
288
- if (info) {
401
+ if (gtype == G_TYPE_INVALID)
402
+ return NULL;
403
+
404
+ info = rbgobj_class_info_lookup_by_gtype(gtype);
405
+ if (info)
289
406
  return info;
290
- }
291
407
 
292
- if (!create_class) {
408
+ if (!create_class)
293
409
  return NULL;
294
- }
295
-
296
- data.gtype = gtype;
297
- data.parent = parent;
298
- data.create_class = create_class;
299
410
 
300
- rb_funcall(lookup_class_mutex, id_lock, 0);
301
- return (RGObjClassInfo *)rb_ensure(rbgobj_lookup_class_by_gtype_body,
302
- (VALUE)&data,
303
- rbgobj_lookup_class_by_gtype_ensure,
304
- (VALUE)&data);
411
+ return rbgobj_class_info_define(gtype, NULL, rb_cObject, parent);
305
412
  }
306
413
 
307
414
  VALUE
@@ -317,14 +424,22 @@ VALUE
317
424
  rbgobj_define_class(GType gtype, const gchar *name, VALUE module,
318
425
  RGMarkFunc mark, RGFreeFunc free, VALUE parent)
319
426
  {
320
- RGObjClassInfo* cinfo;
321
- if (gtype == 0)
322
- rb_bug("rbgobj_define_class: Invalid gtype [%s]\n", name);
427
+ RGObjClassInfo *cinfo;
428
+
429
+ if (gtype == G_TYPE_INVALID)
430
+ rb_bug("rbgobj_define_class: Invalid GType: <%s>\n", name);
323
431
 
324
- cinfo = (RGObjClassInfo*)rbgobj_lookup_class_by_gtype(gtype, parent);
432
+ cinfo = (RGObjClassInfo *)rbgobj_class_info_lookup_by_gtype(gtype);
433
+ if (cinfo) {
434
+ if (!rb_const_defined(module, rb_intern(name))) {
435
+ rb_define_const(module, name, cinfo->klass);
436
+ rbgobj_class_info_fill_name(cinfo);
437
+ }
438
+ } else {
439
+ cinfo = rbgobj_class_info_define(gtype, name, module, parent);
440
+ }
325
441
  cinfo->mark = mark;
326
442
  cinfo->free = free;
327
- rb_define_const(module, name, cinfo->klass);
328
443
  return cinfo->klass;
329
444
  }
330
445
 
@@ -381,8 +496,9 @@ rbgobj_register_class(VALUE klass,
381
496
  RGObjClassInfo* cinfo = NULL;
382
497
  VALUE c = Qnil;
383
498
 
384
- if (klass2gtype)
499
+ if (klass2gtype) {
385
500
  c = Data_Make_Struct(rb_cData, RGObjClassInfo, cinfo_mark, NULL, cinfo);
501
+ }
386
502
  if (gtype2klass && !cinfo)
387
503
  cinfo = g_new(RGObjClassInfo, 1);
388
504
 
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2017 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2011-2018 Ruby-GNOME2 Project Team
4
4
  * Copyright (C) 2003,2006 Ruby-GNOME2 Project Team
5
5
  * Copyright (C) 2002,2003 Masahiro Sakai
6
6
  *
@@ -134,6 +134,8 @@ typedef struct {
134
134
  RGMarkFunc mark;
135
135
  RGFreeFunc free;
136
136
  int flags; /* RGObjClassFlag */
137
+ gchar *name;
138
+ rb_data_type_t *data_type;
137
139
  } RGObjClassInfo;
138
140
 
139
141
  /* rbgobject.c */
@@ -170,8 +172,17 @@ extern gboolean rbgobj_gc_mark_instance(gpointer instance);
170
172
 
171
173
 
172
174
  /* rbgobj_type.c */
175
+ extern const RGObjClassInfo *rbgobj_class_info_lookup(VALUE klass);
176
+ extern const RGObjClassInfo *rbgobj_class_info_lookup_by_gtype(GType gtype);
177
+ extern RGObjClassInfo *rbgobj_class_info_define(GType gtype,
178
+ const gchar *name,
179
+ VALUE module,
180
+ VALUE parent);
181
+ /* deprecated */
173
182
  extern const RGObjClassInfo *rbgobj_lookup_class(VALUE klass);
183
+ /* deprecated */
174
184
  extern const RGObjClassInfo *rbgobj_lookup_class_by_gtype(GType gtype, VALUE parent);
185
+ /* deprecated */
175
186
  extern const RGObjClassInfo *rbgobj_lookup_class_by_gtype_full(GType gtype,
176
187
  VALUE parent,
177
188
  gboolean create_object);
@@ -1,6 +1,4 @@
1
- # -*- ruby -*-
2
- #
3
- # Copyright (C) 2013-2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2013-2018 Ruby-GNOME2 Project Team
4
2
  #
5
3
  # This library is free software; you can redistribute it and/or
6
4
  # modify it under the terms of the GNU Lesser General Public
@@ -21,6 +19,7 @@ require "open-uri"
21
19
  module GNOME2
22
20
  module Rake
23
21
  class ExternalPackage < Struct.new(:name,
22
+ :download_name,
24
23
  :base_name,
25
24
  :archive_base_name,
26
25
  :label,
@@ -47,8 +46,13 @@ module GNOME2
47
46
  resolve_value(super) || "gz"
48
47
  end
49
48
 
49
+ def download_name
50
+ resolve_value(super) || name
51
+ end
52
+
50
53
  def base_name
51
- resolve_value(super) || "#{name}-#{version}"
54
+ resolve_value(super) ||
55
+ "#{name.split('/').last}-#{version.gsub(/\Av/, '')}"
52
56
  end
53
57
 
54
58
  def archive_base_name
@@ -113,6 +117,8 @@ module GNOME2
113
117
  latest_version_webkitgtk
114
118
  when :icu
115
119
  latest_version_icu
120
+ when :github
121
+ latest_version_github
116
122
  else
117
123
  nil
118
124
  end
@@ -132,20 +138,23 @@ module GNOME2
132
138
  when :gnome
133
139
  base_url = gnome_base_url
134
140
  release_series = version.gsub(/\A(\d+\.\d+)(?:[^\d].*)?\z/, '\1')
135
- base_url << "/#{name}/#{release_series}"
141
+ base_url << "/#{download_name}/#{release_series}"
136
142
  when :freedesktop
137
143
  base_url = freedesktop_base_url
138
- base_url << "/#{name}/release"
144
+ base_url << "/#{download_name}/release"
139
145
  when :freedesktop_gstreamer
140
146
  base_url = freedesktop_gstreamer_base_url
141
- base_url << "/#{name}"
147
+ base_url << "/#{download_name}"
142
148
  when :gnu
143
149
  base_url = gnu_base_url
144
- base_url << "/#{name}"
150
+ base_url << "/#{download_name}"
145
151
  when :webkitgtk
146
152
  base_url = webkitgtk_base_url
147
153
  when :icu
148
154
  base_url = "#{icu_base_url}/#{version}"
155
+ when :github
156
+ base_url = github_base_url
157
+ base_url << "/#{download_name}/releases/download/#{version}"
149
158
  else
150
159
  base_url = nil
151
160
  end
@@ -176,6 +185,10 @@ module GNOME2
176
185
  "http://download.icu-project.org/files/icu4c"
177
186
  end
178
187
 
188
+ def github_base_url
189
+ "https://github.com"
190
+ end
191
+
179
192
  def sort_versions(versions)
180
193
  versions.sort_by do |version|
181
194
  version.split(".").collect(&:to_i)
@@ -183,7 +196,7 @@ module GNOME2
183
196
  end
184
197
 
185
198
  def latest_version_gnome
186
- base_url = "#{gnome_base_url}/#{name}"
199
+ base_url = "#{gnome_base_url}/#{download_name}"
187
200
  minor_versions = []
188
201
  open(base_url) do |index|
189
202
  index.read.scan(/<a (.+?)>/) do |content,|
@@ -217,7 +230,7 @@ module GNOME2
217
230
  end
218
231
 
219
232
  def latest_version_freedesktop
220
- base_url = "#{freedesktop_base_url}/#{name}/release"
233
+ base_url = "#{freedesktop_base_url}/#{download_name}/release"
221
234
  versions = []
222
235
  open(base_url) do |index|
223
236
  index.read.scan(/<a (.+?)>/) do |content,|
@@ -233,7 +246,7 @@ module GNOME2
233
246
  end
234
247
 
235
248
  def latest_version_freedesktop_gstreamer
236
- base_url = "#{freedesktop_gstreamer_base_url}/#{name}"
249
+ base_url = "#{freedesktop_gstreamer_base_url}/#{download_name}"
237
250
  versions = []
238
251
  open(base_url) do |index|
239
252
  index.read.scan(/<a (.+?)>/) do |content,|
@@ -255,7 +268,7 @@ module GNOME2
255
268
  end
256
269
 
257
270
  def latest_version_gnu
258
- base_url = "#{gnu_base_url}/#{name}"
271
+ base_url = "#{gnu_base_url}/#{download_name}"
259
272
  versions = []
260
273
  open(base_url) do |index|
261
274
  index.read.scan(/<a (.+?)>/) do |content,|
@@ -301,6 +314,13 @@ module GNOME2
301
314
  sort_versions(versions).last
302
315
  end
303
316
 
317
+ def latest_version_github
318
+ latest_url = "#{github_base_url}/#{download_name}/releases/latest"
319
+ open(latest_url) do |latest_page|
320
+ return latest_page.base_uri.path.split("/").last
321
+ end
322
+ end
323
+
304
324
  class WindowsConfiguration < Struct.new(:build,
305
325
  :include_paths,
306
326
  :library_paths,
@@ -49,32 +49,7 @@ module GNOME2
49
49
  private
50
50
  def define_build_tasks
51
51
  namespace :build do
52
- prepare_task_names = []
53
- namespace :prepare do
54
- prepare_task_names << "pkg_config"
55
- task :pkg_config do
56
- depended_packages = @package.windows.build_dependencies
57
- use_packages = [@package.name] + depended_packages
58
- pkg_config_path = use_packages.collect do |package|
59
- "../#{package}/#{@package.windows.relative_binary_dir}/lib/pkgconfig"
60
- end
61
- ENV["PKG_CONFIG_PATH"] = pkg_config_path.collect do |path|
62
- File.expand_path(path)
63
- end.join(":")
64
- ENV["PKG_CONFIG_LIBDIR"] = rcairo_pkgconfig_path
65
- end
66
-
67
- prepare_task_names << "pkg_config_for_build"
68
- task :pkg_config_for_build do
69
- # XXX: Is it needless?
70
- # ENV["PKG_CONFIG_FOR_BUILD"] = "env - pkg-config"
71
- end
72
- end
73
-
74
- full_prepare_task_names = prepare_task_names.collect do |name|
75
- "windows:builder:build:prepare:#{name}"
76
- end
77
- task :prepare => full_prepare_task_names
52
+ task :prepare
78
53
 
79
54
  build_packages.each do |package|
80
55
  namespace package.name do
@@ -118,6 +93,7 @@ module GNOME2
118
93
  sh("tar", "xf", tar_full_path.to_s)
119
94
  end
120
95
 
96
+ env = build_env
121
97
  package_dir_path =
122
98
  package_tmp_dir + package.base_name + package.base_dir_in_package
123
99
  Dir.chdir(package_dir_path.to_s) do
@@ -137,30 +113,29 @@ module GNOME2
137
113
  make_n_jobs = ENV["MAKE_N_JOBS"]
138
114
  build_make_args << "-j#{make_n_jobs}" if make_n_jobs
139
115
  end
140
- ENV["GREP_OPTIONS"] = "--text"
141
- # ENV["GI_SCANNER_DEBUG"] = "save-temps"
116
+ # build_make_args << "--debug"
117
+ # build_make_args << "V=1"
118
+ # build_make_args << "VERBOSE=1"
119
+ # env["GI_SCANNER_DEBUG"] = "save-temps"
142
120
  if File.exist?("meson.build") and not File.exist?("Makefile.am")
143
121
  source_dir = Dir.pwd
144
122
  build_dir = "build"
145
123
  mkdir_p(build_dir)
146
124
  Dir.chdir(build_dir) do
147
- meson(package, source_dir)
148
- sh(make_args_to_env(build_make_args),
125
+ meson(env, package, source_dir)
126
+ sh(env.merge(make_args_to_env(build_make_args)),
149
127
  "nice", "ninja") or exit(false)
150
- sh(make_args_to_env(install_make_args),
128
+ sh(env.merge(make_args_to_env(install_make_args)),
151
129
  "ninja", "install") or exit(false)
152
130
  end
153
131
  else
154
132
  if File.exist?("Makefile.in")
155
- configure(package)
133
+ configure(env, package)
156
134
  else
157
- cmake(package)
135
+ cmake(env, package)
158
136
  end
159
- # build_make_args << "--debug"
160
- # build_make_args << "V=1"
161
- # build_make_args << "VERBOSE=1"
162
- sh("nice", "make", *build_make_args) or exit(false)
163
- sh("make", "install", *install_make_args) or exit(false)
137
+ sh(env, "nice", "make", *build_make_args) or exit(false)
138
+ sh(env, "make", "install", *install_make_args) or exit(false)
164
139
  end
165
140
 
166
141
  package_license_dir = license_dir + package.name
@@ -182,20 +157,46 @@ module GNOME2
182
157
  end
183
158
  end
184
159
 
185
- def configure(package)
186
- sh("./autogen.sh") if package.windows.need_autogen?
187
- sh("autoreconf", "--install", "--force") if package.windows.need_autoreconf?
188
- sh("./configure",
160
+ def build_env
161
+ path = "#{g_ir_scanner_bin_dir}:#{ENV["PATH"]}"
162
+ env = {
163
+ "GI_HOST_OS" => "nt",
164
+ "MSYSTEM" => "MINGW64",
165
+ "GREP_OPTIONS" => "--text",
166
+ "PATH" => path,
167
+ }
168
+ depended_packages = @package.windows.build_dependencies
169
+ use_packages = [@package.name] + depended_packages
170
+ pkg_config_path = use_packages.collect do |package|
171
+ "../#{package}/#{@package.windows.relative_binary_dir}/lib/pkgconfig"
172
+ end
173
+ env["PKG_CONFIG_PATH"] = pkg_config_path.collect do |path|
174
+ File.expand_path(path)
175
+ end.join(":")
176
+ env["PKG_CONFIG_LIBDIR"] = rcairo_pkgconfig_path
177
+ env
178
+ end
179
+
180
+ def configure(env, package)
181
+ sh(env, "./autogen.sh") if package.windows.need_autogen?
182
+ if package.windows.need_autoreconf?
183
+ sh(env, "autoreconf", "--install", "--force")
184
+ end
185
+ sh(env, "env")
186
+ sh(env,
187
+ "./configure",
189
188
  cc_env(package),
190
189
  dlltool_env,
191
190
  "CPPFLAGS=#{cppflags(package)}",
192
191
  "LDFLAGS=#{ldflags(package)}",
193
192
  "--prefix=#{dist_dir}",
194
193
  "--host=#{@package.windows.build_host}",
194
+ # "--target=#{@package.windows.build_host}",
195
+ # "--build=x86_64-pc-linux-gnu",
195
196
  *package.windows.configure_args) or exit(false)
196
197
  end
197
198
 
198
- def meson(package, source_dir)
199
+ def meson(env, package, source_dir)
199
200
  cross_file = Tempfile.new("meson-cross-file")
200
201
  cross_file.puts(<<-CROSS_FILE)
201
202
  [host_machine]
@@ -213,21 +214,22 @@ dlltool = '/usr/bin/#{dlltool}'
213
214
  pkgconfig = '/usr/bin/pkg-config'
214
215
  CROSS_FILE
215
216
  cross_file.close
216
- sh({
217
- "PATH" => "#{g_ir_scanner_bin_dir}:#{ENV["PATH"]}",
218
- "CPPFLAGS" => cppflags(package),
219
- "LDFLAGS" => ldflags(package),
220
- },
217
+ sh(env.merge({
218
+ "CPPFLAGS" => cppflags(package),
219
+ "LDFLAGS" => ldflags(package),
220
+ }),
221
221
  "meson",
222
222
  source_dir,
223
223
  ".",
224
224
  "--prefix=#{dist_dir}",
225
+ "--libdir=lib",
225
226
  "--cross-file=#{cross_file.path}",
226
227
  *package.windows.meson_args) or exit(false)
227
228
  end
228
229
 
229
- def cmake(package)
230
- sh("cmake",
230
+ def cmake(env, package)
231
+ sh(env,
232
+ "cmake",
231
233
  ".",
232
234
  "-DCMAKE_INSTALL_PREFIX=#{dist_dir}",
233
235
  "-DCMAKE_SYSTEM_NAME=Windows",
@@ -270,8 +272,7 @@ pkgconfig = '/usr/bin/pkg-config'
270
272
  end
271
273
 
272
274
  def rcairo_dir
273
- suffix = @package.windows.build_architecture_suffix
274
- @package.project_root_dir.parent + "rcairo.#{suffix}"
275
+ @package.project_root_dir.parent + "rcairo"
275
276
  end
276
277
 
277
278
  def rcairo_pkgconfig_path
data/lib/mkmf-gnome2.rb CHANGED
@@ -431,17 +431,7 @@ end
431
431
  def check_cairo(options={})
432
432
  rcairo_source_dir = options[:rcairo_source_dir]
433
433
  if rcairo_source_dir.nil?
434
- suffix = nil
435
- if windows_platform?
436
- case RUBY_PLATFORM
437
- when /\Ax86-mingw/
438
- suffix = "win32"
439
- when /\Ax64-mingw/
440
- suffix = "win64"
441
- end
442
- end
443
434
  rcairo_source_base_dir = "rcairo"
444
- rcairo_source_base_dir << ".#{suffix}" if suffix
445
435
  top_dir = options[:top_dir]
446
436
  if top_dir
447
437
  rcairo_source_dir = File.join(top_dir, "..", rcairo_source_base_dir)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib2
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME2 Project Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-19 00:00:00.000000000 Z
11
+ date: 2018-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pkg-config
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  requirements: []
215
215
  rubyforge_project:
216
- rubygems_version: 2.5.2.1
216
+ rubygems_version: 2.7.6
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: Ruby/GLib2 is a Ruby binding of GLib-2.x.