glib2 3.4.0 → 3.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/Rakefile +6 -4
  4. data/ext/glib2/extconf.rb +1 -5
  5. data/ext/glib2/glib2.def +1 -0
  6. data/ext/glib2/rbglib-bytes.c +1 -5
  7. data/ext/glib2/rbglib-gc.c +98 -52
  8. data/ext/glib2/rbglib-variant-type.c +1 -5
  9. data/ext/glib2/rbglib-variant.c +3 -5
  10. data/ext/glib2/rbglib.c +4 -0
  11. data/ext/glib2/rbglib.h +13 -3
  12. data/ext/glib2/rbglib_bookmarkfile.c +4 -4
  13. data/ext/glib2/rbglib_datetime.c +1 -5
  14. data/ext/glib2/rbglib_error.c +3 -1
  15. data/ext/glib2/rbglib_fileutils.c +1 -17
  16. data/ext/glib2/rbglib_iochannel.c +4 -4
  17. data/ext/glib2/rbglib_keyfile.c +16 -41
  18. data/ext/glib2/rbglib_maincontext.c +6 -32
  19. data/ext/glib2/rbglib_mainloop.c +2 -17
  20. data/ext/glib2/rbglib_matchinfo.c +1 -5
  21. data/ext/glib2/rbglib_pollfd.c +1 -25
  22. data/ext/glib2/rbglib_regex.c +1 -13
  23. data/ext/glib2/rbglib_source.c +1 -39
  24. data/ext/glib2/rbglib_spawn.c +5 -10
  25. data/ext/glib2/rbglib_spawnerror.c +2 -2
  26. data/ext/glib2/rbglib_threads.c +2 -15
  27. data/ext/glib2/rbglib_timezone.c +1 -5
  28. data/ext/glib2/rbglib_unichar.c +46 -5
  29. data/ext/glib2/rbglib_unicode.c +1 -18
  30. data/ext/glib2/rbglib_utils.c +1 -14
  31. data/ext/glib2/rbglib_win32.c +3 -7
  32. data/ext/glib2/rbgobj_binding.c +1 -7
  33. data/ext/glib2/rbgobj_closure.c +22 -9
  34. data/ext/glib2/rbgobj_object.c +113 -104
  35. data/ext/glib2/rbgobj_param.c +2 -8
  36. data/ext/glib2/rbgobj_paramspecs.c +6 -24
  37. data/ext/glib2/rbgobj_signal.c +104 -92
  38. data/ext/glib2/rbgobj_strv.c +2 -2
  39. data/ext/glib2/rbgobj_type.c +58 -68
  40. data/ext/glib2/rbgobj_typeinterface.c +38 -2
  41. data/ext/glib2/rbgobj_value.c +3 -7
  42. data/ext/glib2/rbgobj_valuetypes.c +14 -62
  43. data/ext/glib2/rbgobject.c +4 -6
  44. data/ext/glib2/rbgobject.h +2 -27
  45. data/ext/glib2/rbgprivate.h +6 -6
  46. data/ext/glib2/rbgutil_callback.c +23 -26
  47. data/lib/glib2.rb +32 -3
  48. data/lib/glib2/deprecated.rb +22 -1
  49. data/lib/mkmf-gnome.rb +4 -4
  50. data/test/glib-test-utils.rb +18 -3
  51. data/test/run-test.rb +49 -14
  52. data/test/test-binding.rb +1 -11
  53. data/test/test-bytes.rb +1 -5
  54. data/test/test-date-time.rb +1 -3
  55. data/test/test-file-utils.rb +1 -32
  56. data/test/test-iochannel.rb +3 -5
  57. data/test/test-key-file.rb +5 -6
  58. data/test/test-match-info.rb +1 -5
  59. data/test/test-regex.rb +1 -5
  60. data/test/test-source.rb +1 -14
  61. data/test/test-spawn.rb +2 -1
  62. data/test/test-time-zone.rb +1 -5
  63. data/test/test-timeout.rb +2 -3
  64. data/test/test-unicode.rb +16 -12
  65. data/test/test-utils.rb +2 -8
  66. data/test/test-variant-type.rb +1 -3
  67. data/test/test-win32.rb +6 -6
  68. metadata +3 -7
  69. data/ext/glib2/glib-enum-types.c +0 -1233
  70. data/ext/glib2/glib-enum-types.h +0 -154
  71. data/ext/glib2/rbgobj_valuearray.c +0 -100
  72. data/test/glib-test-init.rb +0 -21
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2011-2020 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2005 Masao Mutoh
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -30,7 +30,7 @@ strv_to_ruby(const GValue *from)
30
30
  static void
31
31
  strv_from_ruby(VALUE from, GValue *to)
32
32
  {
33
- const gchar **strings = RVAL2STRV(from);
33
+ gchar **strings = RVAL2STRV(from);
34
34
  g_value_set_boxed(to, strings);
35
35
  g_free(strings);
36
36
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2002-2019 Ruby-GNOME Project Team
3
+ * Copyright (C) 2002-2021 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
@@ -31,9 +31,10 @@ static VALUE rb_cMutex;
31
31
  #endif
32
32
  static VALUE lookup_class_mutex;
33
33
 
34
+ static ID id_gtype;
35
+ static ID id_lock;
34
36
  static ID id_new;
35
37
  static ID id_superclass;
36
- static ID id_lock;
37
38
  static ID id_unlock;
38
39
  static GHashTable *gtype_to_cinfo;
39
40
  static VALUE klass_to_cinfo;
@@ -110,7 +111,7 @@ rbgobj_class_info_create_data_type(VALUE klass)
110
111
  if (RB_TYPE_P(klass, RUBY_T_CLASS) && klass != rb_cObject) {
111
112
  VALUE p = RCLASS_SUPER(klass);
112
113
  while (p != rb_cObject) {
113
- if (RTYPEDDATA_P(p)) {
114
+ if (RB_TYPE_P(p, RUBY_T_DATA) && RTYPEDDATA_P(p)) {
114
115
  data_type->parent = RTYPEDDATA_TYPE(p);
115
116
  break;
116
117
  }
@@ -133,7 +134,7 @@ rbgobj_class_info_register_without_lock(GType gtype, VALUE klass)
133
134
  VALUE c;
134
135
 
135
136
  data_type = rbgobj_class_info_create_data_type(klass);
136
- c = TypedData_Make_Struct(rb_cData, RGObjClassInfo, data_type, cinfo);
137
+ c = TypedData_Make_Struct(rb_cObject, RGObjClassInfo, data_type, cinfo);
137
138
  cinfo->klass = klass;
138
139
  cinfo->gtype = gtype;
139
140
  cinfo->mark = NULL;
@@ -238,9 +239,7 @@ get_superclass(GType gtype, VALUE module)
238
239
  case G_TYPE_OBJECT:
239
240
  return cInstantiatable;
240
241
  case G_TYPE_BOXED:
241
- return rb_cObject;
242
242
  case G_TYPE_POINTER:
243
- return rb_cData;
244
243
  case G_TYPE_ENUM:
245
244
  case G_TYPE_FLAGS:
246
245
  return rb_cObject;
@@ -432,9 +431,9 @@ rbgobj_gtype_to_ruby_class(GType gtype)
432
431
  GType
433
432
  rbgobj_gtype_from_ruby(VALUE rb_gtype)
434
433
  {
435
- ID id_gtype;
436
-
437
- if (RB_TYPE_P(rb_gtype, RUBY_T_STRING)) {
434
+ if (NIL_P(rb_gtype)) {
435
+ return G_TYPE_NONE;
436
+ } else if (RB_TYPE_P(rb_gtype, RUBY_T_STRING)) {
438
437
  GType gtype;
439
438
  gtype = g_type_from_name(RVAL2CSTR(rb_gtype));
440
439
  if (gtype == G_TYPE_INVALID) {
@@ -443,14 +442,13 @@ rbgobj_gtype_from_ruby(VALUE rb_gtype)
443
442
  RVAL2CSTR(rb_gtype));
444
443
  }
445
444
  return gtype;
445
+ } else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_gtype, RG_TARGET_NAMESPACE))) {
446
+ return NUM2SIZET(rb_ivar_get(rb_gtype, id_gtype));
447
+ } else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_gtype, rb_cClass))) {
448
+ return CLASS2GTYPE(rb_gtype);
449
+ } else {
450
+ return NUM2SIZET(rb_to_int(rb_gtype));
446
451
  }
447
-
448
- CONST_ID(id_gtype, "gtype");
449
- if (rb_respond_to(rb_gtype, id_gtype)) {
450
- rb_gtype = rb_funcall(rb_gtype, id_gtype, 0);
451
- }
452
-
453
- return NUM2ULONG(rb_gtype);
454
452
  }
455
453
 
456
454
  VALUE
@@ -532,7 +530,7 @@ rbgobj_register_class(VALUE klass,
532
530
 
533
531
  if (klass2gtype) {
534
532
  data_type = rbgobj_class_info_create_data_type(klass);
535
- c = TypedData_Make_Struct(rb_cData, RGObjClassInfo, data_type, cinfo);
533
+ c = TypedData_Make_Struct(rb_cObject, RGObjClassInfo, data_type, cinfo);
536
534
  }
537
535
  if (gtype2klass && !cinfo)
538
536
  cinfo = g_new(RGObjClassInfo, 1);
@@ -607,26 +605,21 @@ init_typemap(void)
607
605
  /* GLib::Type */
608
606
 
609
607
  VALUE RG_TARGET_NAMESPACE;
610
- static ID id_gtype;
611
608
 
612
609
  VALUE
613
610
  rbgobj_gtype_new(GType gtype)
614
611
  {
615
612
  VALUE result = rb_obj_alloc(RG_TARGET_NAMESPACE);
616
- VALUE arg = ULONG2NUM(gtype);
613
+ VALUE arg = SIZET2NUM(gtype);
617
614
  rb_obj_call_init(result, 1, &arg);
618
615
  return result;
619
616
  }
620
617
 
618
+ /* Deprecated. Use rbgobj_gtype_from_ruby() instead. */
621
619
  GType
622
- rbgobj_gtype_get(VALUE self)
620
+ rbgobj_gtype_get(VALUE rb_gtype)
623
621
  {
624
- if (RVAL2CBOOL(rb_obj_is_kind_of(self, RG_TARGET_NAMESPACE))) {
625
- return NUM2ULONG(rb_ivar_get(self, id_gtype));
626
- } else {
627
- return CLASS2GTYPE(self);
628
- }
629
- rb_raise(rb_eTypeError, "Not a GLib::Type");
622
+ return rbgobj_gtype_from_ruby(rb_gtype);
630
623
  }
631
624
 
632
625
  static VALUE
@@ -690,7 +683,7 @@ rg_initialize(VALUE self, VALUE type)
690
683
  GType gtype;
691
684
 
692
685
  if (RVAL2CBOOL(rb_obj_is_kind_of(type, rb_cInteger))) {
693
- gtype = NUM2ULONG(type);
686
+ gtype = NUM2SIZET(type);
694
687
  if (!g_type_name(gtype))
695
688
  gtype = G_TYPE_INVALID;
696
689
  } else {
@@ -700,7 +693,7 @@ rg_initialize(VALUE self, VALUE type)
700
693
  if (G_TYPE_INVALID == gtype)
701
694
  rb_raise(rb_eArgError, "invalid GType");
702
695
 
703
- rb_ivar_set(self, id_gtype, ULONG2NUM(gtype));
696
+ rb_ivar_set(self, id_gtype, SIZET2NUM(gtype));
704
697
 
705
698
  return Qnil;
706
699
  }
@@ -708,7 +701,7 @@ rg_initialize(VALUE self, VALUE type)
708
701
  static VALUE
709
702
  rg_inspect(VALUE self)
710
703
  {
711
- GType gtype = rbgobj_gtype_get(self);
704
+ GType gtype = rbgobj_gtype_from_ruby(self);
712
705
  gchar* str;
713
706
  VALUE result;
714
707
 
@@ -725,8 +718,8 @@ rg_operator_type_compare(VALUE self, VALUE other)
725
718
  if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE)))
726
719
  return Qnil;
727
720
  else {
728
- GType a = rbgobj_gtype_get(self);
729
- GType b = rbgobj_gtype_get(other);
721
+ GType a = rbgobj_gtype_from_ruby(self);
722
+ GType b = rbgobj_gtype_from_ruby(other);
730
723
 
731
724
  if (a==b)
732
725
  return INT2FIX(0);
@@ -745,8 +738,8 @@ rg_operator_type_eq(VALUE self, VALUE other)
745
738
  if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE)))
746
739
  return Qnil;
747
740
  else {
748
- GType a = rbgobj_gtype_get(self);
749
- GType b = rbgobj_gtype_get(other);
741
+ GType a = rbgobj_gtype_from_ruby(self);
742
+ GType b = rbgobj_gtype_from_ruby(other);
750
743
  return CBOOL2RVAL(a == b);
751
744
  }
752
745
  }
@@ -757,8 +750,8 @@ rg_operator_type_lt_eq(VALUE self, VALUE other)
757
750
  if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE)))
758
751
  return Qnil;
759
752
  else {
760
- GType a = rbgobj_gtype_get(self);
761
- GType b = rbgobj_gtype_get(other);
753
+ GType a = rbgobj_gtype_from_ruby(self);
754
+ GType b = rbgobj_gtype_from_ruby(other);
762
755
  return CBOOL2RVAL(g_type_is_a(a, b));
763
756
  }
764
757
  }
@@ -769,8 +762,8 @@ rg_operator_type_gt_eq(VALUE self, VALUE other)
769
762
  if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE)))
770
763
  return Qnil;
771
764
  else {
772
- GType a = rbgobj_gtype_get(self);
773
- GType b = rbgobj_gtype_get(other);
765
+ GType a = rbgobj_gtype_from_ruby(self);
766
+ GType b = rbgobj_gtype_from_ruby(other);
774
767
  return CBOOL2RVAL(g_type_is_a(b, a));
775
768
  }
776
769
  }
@@ -781,8 +774,8 @@ rg_operator_type_lt(VALUE self, VALUE other)
781
774
  if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE)))
782
775
  return Qnil;
783
776
  else {
784
- GType a = rbgobj_gtype_get(self);
785
- GType b = rbgobj_gtype_get(other);
777
+ GType a = rbgobj_gtype_from_ruby(self);
778
+ GType b = rbgobj_gtype_from_ruby(other);
786
779
  return CBOOL2RVAL(g_type_is_a(a, b) && a != b);
787
780
  }
788
781
  }
@@ -793,8 +786,8 @@ rg_operator_type_gt(VALUE self, VALUE other)
793
786
  if (!RVAL2CBOOL(rb_obj_is_kind_of(other, RG_TARGET_NAMESPACE)))
794
787
  return Qnil;
795
788
  else {
796
- GType a = rbgobj_gtype_get(self);
797
- GType b = rbgobj_gtype_get(other);
789
+ GType a = rbgobj_gtype_from_ruby(self);
790
+ GType b = rbgobj_gtype_from_ruby(other);
798
791
  return CBOOL2RVAL(g_type_is_a(b, a) && a != b);
799
792
  }
800
793
  }
@@ -808,112 +801,113 @@ rg_hash(VALUE self)
808
801
  static VALUE
809
802
  rg_to_class(VALUE self)
810
803
  {
811
- return GTYPE2CLASS(rbgobj_gtype_get(self));
804
+ return GTYPE2CLASS(rbgobj_gtype_from_ruby(self));
812
805
  }
813
806
 
814
807
  static VALUE
815
808
  rg_fundamental(VALUE self)
816
809
  {
817
- return rbgobj_gtype_new(G_TYPE_FUNDAMENTAL(rbgobj_gtype_get(self)));
810
+ return rbgobj_gtype_new(G_TYPE_FUNDAMENTAL(rbgobj_gtype_from_ruby(self)));
818
811
  }
819
812
 
820
813
  static VALUE
821
814
  rg_fundamental_p(VALUE self)
822
815
  {
823
- return CBOOL2RVAL(G_TYPE_IS_FUNDAMENTAL(rbgobj_gtype_get(self)));
816
+ return CBOOL2RVAL(G_TYPE_IS_FUNDAMENTAL(rbgobj_gtype_from_ruby(self)));
824
817
  }
825
818
 
826
819
  static VALUE
827
820
  rg_derived_p(VALUE self)
828
821
  {
829
- return CBOOL2RVAL(G_TYPE_IS_DERIVED(rbgobj_gtype_get(self)));
822
+ return CBOOL2RVAL(G_TYPE_IS_DERIVED(rbgobj_gtype_from_ruby(self)));
830
823
  }
831
824
 
832
825
  static VALUE
833
826
  rg_interface_p(VALUE self)
834
827
  {
835
- return CBOOL2RVAL(G_TYPE_IS_INTERFACE(rbgobj_gtype_get(self)));
828
+ return CBOOL2RVAL(G_TYPE_IS_INTERFACE(rbgobj_gtype_from_ruby(self)));
836
829
  }
837
830
 
838
831
  static VALUE
839
832
  rg_classed_p(VALUE self)
840
833
  {
841
- return CBOOL2RVAL(G_TYPE_IS_CLASSED(rbgobj_gtype_get(self)));
834
+ return CBOOL2RVAL(G_TYPE_IS_CLASSED(rbgobj_gtype_from_ruby(self)));
842
835
  }
843
836
 
844
837
  static VALUE
845
838
  rg_instantiatable_p(VALUE self)
846
839
  {
847
- return CBOOL2RVAL(G_TYPE_IS_INSTANTIATABLE(rbgobj_gtype_get(self)));
840
+ return CBOOL2RVAL(G_TYPE_IS_INSTANTIATABLE(rbgobj_gtype_from_ruby(self)));
848
841
  }
849
842
 
850
843
  static VALUE
851
844
  rg_derivable_p(VALUE self)
852
845
  {
853
- return CBOOL2RVAL(G_TYPE_IS_DERIVABLE(rbgobj_gtype_get(self)));
846
+ return CBOOL2RVAL(G_TYPE_IS_DERIVABLE(rbgobj_gtype_from_ruby(self)));
854
847
  }
855
848
 
856
849
  static VALUE
857
850
  rg_deep_derivable_p(VALUE self)
858
851
  {
859
- return CBOOL2RVAL(G_TYPE_IS_DEEP_DERIVABLE(rbgobj_gtype_get(self)));
852
+ return CBOOL2RVAL(G_TYPE_IS_DEEP_DERIVABLE(rbgobj_gtype_from_ruby(self)));
860
853
  }
861
854
 
862
855
  static VALUE
863
856
  rg_abstract_p(VALUE self)
864
857
  {
865
- return CBOOL2RVAL(G_TYPE_IS_ABSTRACT(rbgobj_gtype_get(self)));
858
+ return CBOOL2RVAL(G_TYPE_IS_ABSTRACT(rbgobj_gtype_from_ruby(self)));
866
859
  }
867
860
 
868
861
  static VALUE
869
862
  rg_value_abstract_p(VALUE self)
870
863
  {
871
- return CBOOL2RVAL(G_TYPE_IS_VALUE_ABSTRACT(rbgobj_gtype_get(self)));
864
+ return CBOOL2RVAL(G_TYPE_IS_VALUE_ABSTRACT(rbgobj_gtype_from_ruby(self)));
872
865
  }
873
866
 
874
867
  static VALUE
875
868
  rg_value_type_p(VALUE self)
876
869
  {
877
- return CBOOL2RVAL(G_TYPE_IS_VALUE_TYPE(rbgobj_gtype_get(self)));
870
+ return CBOOL2RVAL(G_TYPE_IS_VALUE_TYPE(rbgobj_gtype_from_ruby(self)));
878
871
  }
879
872
 
880
873
  static VALUE
881
874
  rg_has_value_table(VALUE self)
882
875
  {
883
- return CBOOL2RVAL(G_TYPE_HAS_VALUE_TABLE(rbgobj_gtype_get(self)));
876
+ return CBOOL2RVAL(G_TYPE_HAS_VALUE_TABLE(rbgobj_gtype_from_ruby(self)));
884
877
  }
885
878
 
886
879
  static VALUE
887
880
  rg_name(VALUE self)
888
881
  {
889
- return rb_str_new2(g_type_name(rbgobj_gtype_get(self)));
882
+ return rb_str_new2(g_type_name(rbgobj_gtype_from_ruby(self)));
890
883
  }
891
884
 
892
885
  static VALUE
893
886
  rg_parent(VALUE self)
894
887
  {
895
- GType parent = g_type_parent(rbgobj_gtype_get(self));
888
+ GType parent = g_type_parent(rbgobj_gtype_from_ruby(self));
896
889
  return parent ? rbgobj_gtype_new(parent) : Qnil;
897
890
  }
898
891
 
899
892
  static VALUE
900
893
  rg_depth(VALUE self)
901
894
  {
902
- return UINT2NUM(g_type_depth(rbgobj_gtype_get(self)));
895
+ return UINT2NUM(g_type_depth(rbgobj_gtype_from_ruby(self)));
903
896
  }
904
897
 
905
898
  static VALUE
906
899
  rg_next_base(VALUE leaf_type, VALUE root_type)
907
900
  {
908
- GType ret = g_type_next_base(rbgobj_gtype_get(leaf_type),
909
- rbgobj_gtype_get(root_type));
901
+ GType ret = g_type_next_base(rbgobj_gtype_from_ruby(leaf_type),
902
+ rbgobj_gtype_from_ruby(root_type));
910
903
  return ret ? rbgobj_gtype_new(ret) : Qnil;
911
904
  }
912
905
 
913
906
  static VALUE
914
907
  rg_type_is_a_p(VALUE self, VALUE is_a_type)
915
908
  {
916
- return CBOOL2RVAL(g_type_is_a(rbgobj_gtype_get(self), rbgobj_gtype_get(is_a_type)));
909
+ return CBOOL2RVAL(g_type_is_a(rbgobj_gtype_from_ruby(self),
910
+ rbgobj_gtype_from_ruby(is_a_type)));
917
911
  }
918
912
 
919
913
  #if 0
@@ -934,7 +928,7 @@ rg_children(VALUE self)
934
928
  VALUE result;
935
929
  guint i;
936
930
 
937
- types = g_type_children(rbgobj_gtype_get(self), &n_children);
931
+ types = g_type_children(rbgobj_gtype_from_ruby(self), &n_children);
938
932
  result = rb_ary_new2(n_children);
939
933
  for (i = 0; i < n_children; i++)
940
934
  rb_ary_store(result, i, rbgobj_gtype_new(types[i]));
@@ -951,7 +945,7 @@ rg_interfaces(VALUE self)
951
945
  VALUE result;
952
946
  guint i;
953
947
 
954
- types = g_type_interfaces(rbgobj_gtype_get(self), &n_interfaces);
948
+ types = g_type_interfaces(rbgobj_gtype_from_ruby(self), &n_interfaces);
955
949
  result = rb_ary_new2(n_interfaces);
956
950
  for (i = 0; i < n_interfaces; i++)
957
951
  rb_ary_store(result, i, rbgobj_gtype_new(types[i]));
@@ -964,7 +958,7 @@ static VALUE
964
958
  rg_class_size(VALUE self)
965
959
  {
966
960
  GTypeQuery query;
967
- g_type_query(rbgobj_gtype_get(self), &query);
961
+ g_type_query(rbgobj_gtype_from_ruby(self), &query);
968
962
  return UINT2NUM(query.class_size);
969
963
  }
970
964
 
@@ -972,7 +966,7 @@ static VALUE
972
966
  rg_instance_size(VALUE self)
973
967
  {
974
968
  GTypeQuery query;
975
- g_type_query(rbgobj_gtype_get(self), &query);
969
+ g_type_query(rbgobj_gtype_from_ruby(self), &query);
976
970
  return UINT2NUM(query.instance_size);
977
971
  }
978
972
 
@@ -989,10 +983,6 @@ _def_fundamental_type(VALUE ary, GType gtype, const char* name)
989
983
  void
990
984
  Init_gobject_gtype(void)
991
985
  {
992
- #if !GLIB_CHECK_VERSION(2, 35, 1)
993
- g_type_init();
994
- #endif
995
-
996
986
  init_typemap();
997
987
 
998
988
  /* type */
@@ -1,7 +1,7 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011,2017 Ruby-GNOME2 Project Team
4
- * Copyright (C) 2002-2006 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2011,2021 Ruby-GNOME Project Team
4
+ * Copyright (C) 2002-2006 Ruby-GNOME Project Team
5
5
  * Copyright (C) 2002,2003 Masahiro Sakai
6
6
  *
7
7
  * This library is free software; you can redistribute it and/or
@@ -35,6 +35,41 @@ rg_append_features(G_GNUC_UNUSED VALUE self, VALUE klass)
35
35
  return rb_call_super(1, &klass);
36
36
  }
37
37
 
38
+ static void
39
+ interface_init(G_GNUC_UNUSED gpointer g_iface,
40
+ G_GNUC_UNUSED gpointer iface_data)
41
+ {
42
+ }
43
+
44
+ static VALUE
45
+ rg_included(VALUE self, VALUE class_or_module)
46
+ {
47
+ const GInterfaceInfo interface_info = {
48
+ interface_init, NULL, NULL
49
+ };
50
+ const RGObjClassInfo *interface_cinfo;
51
+ const RGObjClassInfo *class_cinfo;
52
+ if (RVAL2CBOOL(rb_obj_is_instance_of(class_or_module, rb_cModule))) {
53
+ rb_raise(rb_eTypeError,
54
+ "GLib::Interface based module (%" PRIsVALUE ") "
55
+ "must be included into a class directly: %" PRIsVALUE,
56
+ self,
57
+ class_or_module);
58
+ }
59
+ interface_cinfo = rbgobj_lookup_class(self);
60
+ class_cinfo = rbgobj_lookup_class(class_or_module);
61
+ if (class_cinfo->klass != class_or_module) {
62
+ return Qnil;
63
+ }
64
+ if (g_type_is_a(class_cinfo->gtype, interface_cinfo->gtype)) {
65
+ return Qnil;
66
+ }
67
+ g_type_add_interface_static(class_cinfo->gtype,
68
+ interface_cinfo->gtype,
69
+ &interface_info);
70
+ return Qnil;
71
+ }
72
+
38
73
  static VALUE
39
74
  rg_install_property(VALUE self, VALUE pspec_obj)
40
75
  {
@@ -141,6 +176,7 @@ Init_gobject_typeinterface(void)
141
176
  RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "MetaInterface");
142
177
  rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0);
143
178
  RG_DEF_METHOD(append_features, 1);
179
+ RG_DEF_METHOD(included, 1);
144
180
  RG_DEF_METHOD(install_property, 1);
145
181
  RG_DEF_METHOD(property, 1);
146
182
  RG_DEF_METHOD(properties, -1);