gobject-introspection 3.3.0 → 3.3.1

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
2
  SHA256:
3
- metadata.gz: b5e708d02e27a80e2c6f6c93ed0c283011b264547f8523575d8b2038bf08039e
4
- data.tar.gz: 1cb3f367205cf4ff8b826f755354c134071740e09211cbb2377f4907714e1cab
3
+ metadata.gz: 4c6caefd72069125350637fc2a07a444c90ae74ba5175b1e5031e84e5a4349ae
4
+ data.tar.gz: 9f1ed91b438bd00f424f283c797af9834c85f2ddc88441019b1781ab40145c6e
5
5
  SHA512:
6
- metadata.gz: c38badd7944d4278121ec7085b0f6bbeb1ded582941c1347babe6f21535ebc67bd7897bda77ad89d31d2df27abf50a18fee497150942d67e5c56f6bbf32513e2
7
- data.tar.gz: c917b854af7ebec5cd473dc3b6b3f948c14e591ad41111a0a8d9df431011e5d91bdce2d01d91ec9d17083e790120433eb211ab27b4cbe3390f34bc269dca9625
6
+ metadata.gz: 3f4bb16322d279941ac6ed04b236291d457b1e086dfbefdb0e9fdd343441eaa9df553cc497c771d377231ad8dda2ea80bea1709c46f4e101d7636761f7de0239
7
+ data.tar.gz: c710f5412c54f621502f45fcc70f6ea4a9ad7d901bc5b1acebd72aee45aae2d7a31e7319e8c660297db1e8f2bb01afb83bbc082a8f57a62d6d0ad0cbd174953d
data/Rakefile CHANGED
@@ -22,77 +22,5 @@ require "gnome2/rake/package-task"
22
22
  package_name = File.basename(__dir__)
23
23
  spec = Gem::Specification.load("#{package_name}.gemspec")
24
24
 
25
- package_task = GNOME2::Rake::PackageTask.new(spec, __dir__) do |package|
26
- package.windows.packages = []
27
- package.windows.dependencies = []
28
- package.windows.build_dependencies = ["glib2"]
29
- package.external_packages = [
30
- {
31
- :name => "glib",
32
- :download_site => :gnome,
33
- :label => "GLib",
34
- :version => "2.58.1",
35
- :compression_method => "xz",
36
- :windows => {
37
- :build => false,
38
- },
39
- :native => {
40
- :build => true,
41
- :need_autoreconf => true,
42
- :built_file => "lib/libglib-2.0.so",
43
- },
44
- },
45
- {
46
- :name => "gobject-introspection",
47
- :download_site => :gnome,
48
- :label => "gobject-introspection",
49
- :version => "1.58.0",
50
- :compression_method => "xz",
51
- :windows => {
52
- :configure_args => [
53
- "--with-g-ir-scanner=#{package.native.absolute_binary_dir}/bin/g-ir-scanner",
54
- "--disable-tests",
55
- ],
56
- :patches => [
57
- "support-external-g-ir-scanner.diff",
58
- ],
59
- :need_autoreconf => true,
60
- :build_concurrently => false,
61
- :built_file => "bin/libgirepository-1.0-1.dll",
62
- },
63
- :native => {
64
- :build => true,
65
- :patches => [
66
- ],
67
- :built_file => "bin/g-ir-scanner",
68
- }
69
- },
70
- ]
71
- end
72
- package_task.define
73
-
74
- namespace :native do
75
- namespace :"gobject-introspection" do
76
- patched_paths = []
77
-
78
- g_ir_scanner_dir = package_task.native.absolute_binary_dir
79
- g_ir_scanner_dir += "lib/gobject-introspection/giscanner"
80
- g_ir_scanner_patched_path = g_ir_scanner_dir + "patched"
81
- patched_paths << g_ir_scanner_patched_path
82
- file g_ir_scanner_patched_path.to_s do
83
- Dir.chdir(g_ir_scanner_dir.to_s) do
84
- patch = "#{package_task.package.patches_dir}/cross-g-ir-scanner.diff"
85
- sh("patch -p2 < #{patch}")
86
- rm_f(Dir.glob("*.{pyc,pyo}"))
87
- end
88
- touch(g_ir_scanner_patched_path)
89
- end
90
-
91
- desc "Make g-ir-scanner workable for Windows on non Windows"
92
- task :cross => patched_paths
93
- end
94
-
95
- namespace :builder do
96
- task :after => "native:gobject-introspection:cross"
97
- end
25
+ GNOME2::Rake::PackageTask.define(spec, __dir__) do |package|
98
26
  end
@@ -1128,47 +1128,25 @@ rb_gi_argument_to_ruby_gslist(GIArgument *argument, GITypeInfo *type_info)
1128
1128
  return rb_argument;
1129
1129
  }
1130
1130
 
1131
- static void
1132
- rb_gi_argument_to_ruby_ghash_utf8_utf8_body(gpointer key,
1133
- gpointer value,
1134
- gpointer user_data)
1135
- {
1136
- VALUE rb_table = (VALUE)user_data;
1137
- VALUE rb_key;
1138
- VALUE rb_value;
1139
-
1140
- rb_key = CSTR2RVAL(key);
1141
- rb_value = CSTR2RVAL(value);
1142
- rb_hash_aset(rb_table, rb_key, rb_value);
1143
- }
1144
-
1145
- static VALUE
1146
- rb_gi_argument_to_ruby_ghash_utf8_utf8(GHashTable *table)
1147
- {
1131
+ typedef struct {
1132
+ GIArgument *argument;
1148
1133
  VALUE rb_table;
1149
-
1150
- rb_table = rb_hash_new();
1151
- g_hash_table_foreach(table,
1152
- rb_gi_argument_to_ruby_ghash_utf8_utf8_body,
1153
- (gpointer)(rb_table));
1154
- return rb_table;
1155
- }
1156
-
1157
- static VALUE
1158
- rb_gi_argument_to_ruby_ghash(GIArgument *argument, GITypeInfo *type_info)
1159
- {
1160
- VALUE rb_argument;
1161
1134
  GITypeInfo *key_type_info;
1162
1135
  GITypeTag key_type_tag;
1163
1136
  GITypeInfo *value_type_info;
1164
1137
  GITypeTag value_type_tag;
1138
+ } GHashToRubyData;
1165
1139
 
1166
- key_type_info = g_type_info_get_param_type(type_info, 0);
1167
- key_type_tag = g_type_info_get_tag(key_type_info);
1168
- value_type_info = g_type_info_get_param_type(type_info, 1);
1169
- value_type_tag = g_type_info_get_tag(value_type_info);
1140
+ static void
1141
+ rb_gi_argument_to_ruby_ghash_foreach_body(gpointer key,
1142
+ gpointer value,
1143
+ gpointer user_data)
1144
+ {
1145
+ GHashToRubyData *data = user_data;
1146
+ VALUE rb_key;
1147
+ VALUE rb_value;
1170
1148
 
1171
- switch (key_type_tag) {
1149
+ switch (data->key_type_tag) {
1172
1150
  case GI_TYPE_TAG_VOID:
1173
1151
  case GI_TYPE_TAG_BOOLEAN:
1174
1152
  case GI_TYPE_TAG_INT8:
@@ -1182,51 +1160,140 @@ rb_gi_argument_to_ruby_ghash(GIArgument *argument, GITypeInfo *type_info)
1182
1160
  case GI_TYPE_TAG_FLOAT:
1183
1161
  case GI_TYPE_TAG_DOUBLE:
1184
1162
  case GI_TYPE_TAG_GTYPE:
1185
- g_base_info_unref(key_type_info);
1186
- g_base_info_unref(value_type_info);
1187
1163
  rb_raise(rb_eNotImpError,
1188
1164
  "TODO: GIArgument(GHash)[%s][%s] -> Ruby",
1189
- g_type_tag_to_string(key_type_tag),
1190
- g_type_tag_to_string(value_type_tag));
1165
+ g_type_tag_to_string(data->key_type_tag),
1166
+ g_type_tag_to_string(data->value_type_tag));
1191
1167
  break;
1192
1168
  case GI_TYPE_TAG_UTF8:
1193
- if (value_type_tag == GI_TYPE_TAG_UTF8) {
1194
- g_base_info_unref(key_type_info);
1195
- g_base_info_unref(value_type_info);
1196
- rb_argument =
1197
- rb_gi_argument_to_ruby_ghash_utf8_utf8(argument->v_pointer);
1198
- } else {
1199
- g_base_info_unref(key_type_info);
1200
- g_base_info_unref(value_type_info);
1201
- rb_raise(rb_eNotImpError,
1202
- "TODO: GIArgument(GHash)[%s][%s] -> Ruby",
1203
- g_type_tag_to_string(key_type_tag),
1204
- g_type_tag_to_string(value_type_tag));
1169
+ rb_key = CSTR2RVAL(key);
1170
+ break;
1171
+ case GI_TYPE_TAG_FILENAME:
1172
+ case GI_TYPE_TAG_ARRAY:
1173
+ rb_raise(rb_eNotImpError,
1174
+ "TODO: GIArgument(GHash)[%s][%s] -> Ruby",
1175
+ g_type_tag_to_string(data->key_type_tag),
1176
+ g_type_tag_to_string(data->value_type_tag));
1177
+ break;
1178
+ case GI_TYPE_TAG_INTERFACE:
1179
+ {
1180
+ GIArgument key_argument;
1181
+ key_argument.v_pointer = key;
1182
+ rb_key = rb_gi_argument_to_ruby_interface(&key_argument,
1183
+ FALSE,
1184
+ data->key_type_info);
1205
1185
  }
1206
1186
  break;
1187
+ case GI_TYPE_TAG_GLIST:
1188
+ case GI_TYPE_TAG_GSLIST:
1189
+ case GI_TYPE_TAG_GHASH:
1190
+ case GI_TYPE_TAG_ERROR:
1191
+ case GI_TYPE_TAG_UNICHAR:
1192
+ rb_raise(rb_eNotImpError,
1193
+ "TODO: GIArgument(GHash)[%s][%s] -> Ruby",
1194
+ g_type_tag_to_string(data->key_type_tag),
1195
+ g_type_tag_to_string(data->value_type_tag));
1196
+ break;
1197
+ default:
1198
+ g_assert_not_reached();
1199
+ break;
1200
+ }
1201
+
1202
+ switch (data->value_type_tag) {
1203
+ case GI_TYPE_TAG_VOID:
1204
+ case GI_TYPE_TAG_BOOLEAN:
1205
+ case GI_TYPE_TAG_INT8:
1206
+ case GI_TYPE_TAG_UINT8:
1207
+ case GI_TYPE_TAG_INT16:
1208
+ case GI_TYPE_TAG_UINT16:
1209
+ case GI_TYPE_TAG_INT32:
1210
+ case GI_TYPE_TAG_UINT32:
1211
+ case GI_TYPE_TAG_INT64:
1212
+ case GI_TYPE_TAG_UINT64:
1213
+ case GI_TYPE_TAG_FLOAT:
1214
+ case GI_TYPE_TAG_DOUBLE:
1215
+ case GI_TYPE_TAG_GTYPE:
1216
+ rb_raise(rb_eNotImpError,
1217
+ "TODO: GIArgument(GHash)[%s][%s] -> Ruby",
1218
+ g_type_tag_to_string(data->key_type_tag),
1219
+ g_type_tag_to_string(data->value_type_tag));
1220
+ break;
1221
+ case GI_TYPE_TAG_UTF8:
1222
+ rb_value = CSTR2RVAL(value);
1223
+ break;
1207
1224
  case GI_TYPE_TAG_FILENAME:
1208
1225
  case GI_TYPE_TAG_ARRAY:
1226
+ rb_raise(rb_eNotImpError,
1227
+ "TODO: GIArgument(GHash)[%s][%s] -> Ruby",
1228
+ g_type_tag_to_string(data->key_type_tag),
1229
+ g_type_tag_to_string(data->value_type_tag));
1230
+ break;
1209
1231
  case GI_TYPE_TAG_INTERFACE:
1232
+ {
1233
+ GIArgument value_argument;
1234
+ value_argument.v_pointer = value;
1235
+ rb_value = rb_gi_argument_to_ruby_interface(&value_argument,
1236
+ FALSE,
1237
+ data->value_type_info);
1238
+ }
1239
+ break;
1210
1240
  case GI_TYPE_TAG_GLIST:
1211
1241
  case GI_TYPE_TAG_GSLIST:
1212
1242
  case GI_TYPE_TAG_GHASH:
1213
1243
  case GI_TYPE_TAG_ERROR:
1214
1244
  case GI_TYPE_TAG_UNICHAR:
1215
- g_base_info_unref(key_type_info);
1216
- g_base_info_unref(value_type_info);
1217
1245
  rb_raise(rb_eNotImpError,
1218
1246
  "TODO: GIArgument(GHash)[%s][%s] -> Ruby",
1219
- g_type_tag_to_string(key_type_tag),
1220
- g_type_tag_to_string(value_type_tag));
1247
+ g_type_tag_to_string(data->key_type_tag),
1248
+ g_type_tag_to_string(data->value_type_tag));
1221
1249
  break;
1222
1250
  default:
1223
- g_base_info_unref(key_type_info);
1224
- g_base_info_unref(value_type_info);
1225
1251
  g_assert_not_reached();
1226
1252
  break;
1227
1253
  }
1228
1254
 
1229
- return rb_argument;
1255
+ rb_hash_aset(data->rb_table, rb_key, rb_value);
1256
+ }
1257
+
1258
+ static VALUE
1259
+ rb_gi_argument_to_ruby_ghash_body(VALUE user_data)
1260
+ {
1261
+ GHashToRubyData *data = (GHashToRubyData *)user_data;
1262
+
1263
+ g_hash_table_foreach(data->argument->v_pointer,
1264
+ rb_gi_argument_to_ruby_ghash_foreach_body,
1265
+ data);
1266
+
1267
+ return data->rb_table;
1268
+ }
1269
+
1270
+ static VALUE
1271
+ rb_gi_argument_to_ruby_ghash_ensure(VALUE user_data)
1272
+ {
1273
+ GHashToRubyData *data = (GHashToRubyData *)user_data;
1274
+
1275
+ g_base_info_unref(data->key_type_info);
1276
+ g_base_info_unref(data->value_type_info);
1277
+
1278
+ return Qnil;
1279
+ }
1280
+
1281
+ static VALUE
1282
+ rb_gi_argument_to_ruby_ghash(GIArgument *argument, GITypeInfo *type_info)
1283
+ {
1284
+ GHashToRubyData data;
1285
+
1286
+ data.argument = argument;
1287
+ data.rb_table = rb_hash_new();
1288
+
1289
+ data.key_type_info = g_type_info_get_param_type(type_info, 0);
1290
+ data.key_type_tag = g_type_info_get_tag(data.key_type_info);
1291
+
1292
+ data.value_type_info = g_type_info_get_param_type(type_info, 1);
1293
+ data.value_type_tag = g_type_info_get_tag(data.value_type_info);
1294
+
1295
+ return rb_ensure(rb_gi_argument_to_ruby_ghash_body, (VALUE)&data,
1296
+ rb_gi_argument_to_ruby_ghash_ensure, (VALUE)&data);
1230
1297
  }
1231
1298
 
1232
1299
  static VALUE
@@ -2293,15 +2360,13 @@ rb_gi_return_argument_free_everything_array_c(GIArgument *argument,
2293
2360
 
2294
2361
  switch (element_type_tag) {
2295
2362
  case GI_TYPE_TAG_VOID:
2296
- case GI_TYPE_TAG_BOOLEAN:
2297
- case GI_TYPE_TAG_INT8:
2298
2363
  rb_raise(rb_eNotImpError,
2299
2364
  "TODO: free GIArgument(array)[c][%s] everything",
2300
2365
  g_type_tag_to_string(element_type_tag));
2301
2366
  break;
2367
+ case GI_TYPE_TAG_BOOLEAN:
2368
+ case GI_TYPE_TAG_INT8:
2302
2369
  case GI_TYPE_TAG_UINT8:
2303
- g_free(argument->v_pointer);
2304
- break;
2305
2370
  case GI_TYPE_TAG_INT16:
2306
2371
  case GI_TYPE_TAG_UINT16:
2307
2372
  case GI_TYPE_TAG_INT32:
@@ -2310,6 +2375,8 @@ rb_gi_return_argument_free_everything_array_c(GIArgument *argument,
2310
2375
  case GI_TYPE_TAG_UINT64:
2311
2376
  case GI_TYPE_TAG_FLOAT:
2312
2377
  case GI_TYPE_TAG_DOUBLE:
2378
+ g_free(argument->v_pointer);
2379
+ break;
2313
2380
  case GI_TYPE_TAG_GTYPE:
2314
2381
  rb_raise(rb_eNotImpError,
2315
2382
  "TODO: free GIArgument(array)[c][%s] everything",
@@ -2788,50 +2855,52 @@ rb_gi_return_argument_free_everything(GIArgument *argument,
2788
2855
 
2789
2856
  type_tag = g_type_info_get_tag(type_info);
2790
2857
  switch (type_tag) {
2791
- case GI_TYPE_TAG_VOID:
2858
+ case GI_TYPE_TAG_VOID:
2792
2859
  break;
2793
- case GI_TYPE_TAG_BOOLEAN:
2794
- case GI_TYPE_TAG_INT8:
2795
- case GI_TYPE_TAG_UINT8:
2796
- case GI_TYPE_TAG_INT16:
2797
- case GI_TYPE_TAG_UINT16:
2798
- case GI_TYPE_TAG_INT32:
2799
- case GI_TYPE_TAG_UINT32:
2800
- case GI_TYPE_TAG_INT64:
2801
- case GI_TYPE_TAG_UINT64:
2802
- case GI_TYPE_TAG_FLOAT:
2803
- case GI_TYPE_TAG_DOUBLE:
2804
- case GI_TYPE_TAG_GTYPE:
2860
+ case GI_TYPE_TAG_BOOLEAN:
2861
+ case GI_TYPE_TAG_INT8:
2862
+ case GI_TYPE_TAG_UINT8:
2863
+ case GI_TYPE_TAG_INT16:
2864
+ case GI_TYPE_TAG_UINT16:
2865
+ case GI_TYPE_TAG_INT32:
2866
+ case GI_TYPE_TAG_UINT32:
2867
+ case GI_TYPE_TAG_INT64:
2868
+ case GI_TYPE_TAG_UINT64:
2869
+ case GI_TYPE_TAG_FLOAT:
2870
+ case GI_TYPE_TAG_DOUBLE:
2871
+ case GI_TYPE_TAG_GTYPE:
2805
2872
  rb_raise(rb_eNotImpError,
2806
2873
  "TODO: free GIArgument(%s) everything",
2807
2874
  g_type_tag_to_string(type_tag));
2808
2875
  break;
2809
- case GI_TYPE_TAG_UTF8:
2876
+ case GI_TYPE_TAG_UTF8:
2810
2877
  g_free(argument->v_string);
2811
2878
  break;
2812
- case GI_TYPE_TAG_FILENAME:
2879
+ case GI_TYPE_TAG_FILENAME:
2813
2880
  g_free(argument->v_string);
2814
2881
  break;
2815
- case GI_TYPE_TAG_ARRAY:
2882
+ case GI_TYPE_TAG_ARRAY:
2816
2883
  rb_gi_return_argument_free_everything_array(argument, type_info);
2817
2884
  break;
2818
- case GI_TYPE_TAG_INTERFACE:
2885
+ case GI_TYPE_TAG_INTERFACE:
2819
2886
  rb_gi_return_argument_free_everything_interface(argument, type_info);
2820
2887
  break;
2821
- case GI_TYPE_TAG_GLIST:
2888
+ case GI_TYPE_TAG_GLIST:
2822
2889
  rb_gi_return_argument_free_everything_glist(argument, type_info);
2823
2890
  break;
2824
- case GI_TYPE_TAG_GSLIST:
2891
+ case GI_TYPE_TAG_GSLIST:
2825
2892
  rb_gi_return_argument_free_everything_gslist(argument, type_info);
2826
2893
  break;
2827
- case GI_TYPE_TAG_GHASH:
2828
- case GI_TYPE_TAG_ERROR:
2829
- case GI_TYPE_TAG_UNICHAR:
2894
+ case GI_TYPE_TAG_GHASH:
2895
+ g_hash_table_unref(argument->v_pointer);
2896
+ break;
2897
+ case GI_TYPE_TAG_ERROR:
2898
+ case GI_TYPE_TAG_UNICHAR:
2830
2899
  rb_raise(rb_eNotImpError,
2831
2900
  "TODO: free GIArgument(%s) everything",
2832
2901
  g_type_tag_to_string(type_tag));
2833
2902
  break;
2834
- default:
2903
+ default:
2835
2904
  g_assert_not_reached();
2836
2905
  break;
2837
2906
  }
@@ -2957,7 +3026,16 @@ rb_gi_value_argument_from_ruby_interface(GIArgument *argument,
2957
3026
  break;
2958
3027
  case GI_INFO_TYPE_OBJECT:
2959
3028
  case GI_INFO_TYPE_INTERFACE:
3029
+ gtype = g_registered_type_info_get_g_type(interface_info);
2960
3030
  argument->v_pointer = RVAL2GOBJ(rb_argument);
3031
+ if (argument->v_pointer &&
3032
+ gtype != G_TYPE_NONE &&
3033
+ !G_TYPE_CHECK_INSTANCE_TYPE(argument->v_pointer, gtype)) {
3034
+ rb_raise(rb_eArgError,
3035
+ "must be <%s> object: <%" PRIsVALUE ">",
3036
+ g_type_name(gtype),
3037
+ rb_argument);
3038
+ }
2961
3039
  break;
2962
3040
  case GI_INFO_TYPE_CONSTANT:
2963
3041
  rb_raise(rb_eNotImpError,
@@ -3007,9 +3085,16 @@ rb_gi_value_argument_from_ruby_glist(GIArgument *argument,
3007
3085
  {
3008
3086
  GITypeInfo *element_type_info;
3009
3087
  GITypeTag element_type_tag;
3088
+ GType gtype = G_TYPE_NONE;
3010
3089
 
3011
3090
  element_type_info = g_type_info_get_param_type(type_info, 0);
3012
3091
  element_type_tag = g_type_info_get_tag(element_type_info);
3092
+ if (element_type_tag == GI_TYPE_TAG_INTERFACE) {
3093
+ GIBaseInfo *interface_info;
3094
+ interface_info = g_type_info_get_interface(element_type_info);
3095
+ gtype = g_registered_type_info_get_g_type(interface_info);
3096
+ g_base_info_unref(interface_info);
3097
+ }
3013
3098
  g_base_info_unref(element_type_info);
3014
3099
 
3015
3100
  switch (element_type_tag) {
@@ -3035,6 +3120,19 @@ rb_gi_value_argument_from_ruby_glist(GIArgument *argument,
3035
3120
  break;
3036
3121
  case GI_TYPE_TAG_INTERFACE:
3037
3122
  argument->v_pointer = RVAL2GOBJGLIST(rb_argument);
3123
+ if (gtype != G_TYPE_NONE) {
3124
+ GList *node;
3125
+ for (node = argument->v_pointer; node; node = g_list_next(node)) {
3126
+ GObject *object = node->data;
3127
+ if (!G_TYPE_CHECK_INSTANCE_TYPE(object, gtype)) {
3128
+ g_list_free(argument->v_pointer);
3129
+ rb_raise(rb_eArgError,
3130
+ "must be <%s> objects: <%" PRIsVALUE ">",
3131
+ g_type_name(gtype),
3132
+ rb_argument);
3133
+ }
3134
+ }
3135
+ }
3038
3136
  break;
3039
3137
  case GI_TYPE_TAG_GLIST:
3040
3138
  case GI_TYPE_TAG_GSLIST:
@@ -3059,9 +3157,16 @@ rb_gi_value_argument_from_ruby_gslist(GIArgument *argument,
3059
3157
  {
3060
3158
  GITypeInfo *element_type_info;
3061
3159
  GITypeTag element_type_tag;
3160
+ GType gtype = G_TYPE_NONE;
3062
3161
 
3063
3162
  element_type_info = g_type_info_get_param_type(type_info, 0);
3064
3163
  element_type_tag = g_type_info_get_tag(element_type_info);
3164
+ if (element_type_tag == GI_TYPE_TAG_INTERFACE) {
3165
+ GIBaseInfo *interface_info;
3166
+ interface_info = g_type_info_get_interface(element_type_info);
3167
+ gtype = g_registered_type_info_get_g_type(interface_info);
3168
+ g_base_info_unref(interface_info);
3169
+ }
3065
3170
  g_base_info_unref(element_type_info);
3066
3171
 
3067
3172
  switch (element_type_tag) {
@@ -3087,6 +3192,19 @@ rb_gi_value_argument_from_ruby_gslist(GIArgument *argument,
3087
3192
  break;
3088
3193
  case GI_TYPE_TAG_INTERFACE:
3089
3194
  argument->v_pointer = RVAL2GOBJGSLIST(rb_argument);
3195
+ if (gtype != G_TYPE_NONE) {
3196
+ GSList *node;
3197
+ for (node = argument->v_pointer; node; node = g_slist_next(node)) {
3198
+ GObject *object = node->data;
3199
+ if (!G_TYPE_CHECK_INSTANCE_TYPE(object, gtype)) {
3200
+ g_slist_free(argument->v_pointer);
3201
+ rb_raise(rb_eArgError,
3202
+ "must be <%s> objects: <%" PRIsVALUE ">",
3203
+ g_type_name(gtype),
3204
+ rb_argument);
3205
+ }
3206
+ }
3207
+ }
3090
3208
  break;
3091
3209
  case GI_TYPE_TAG_GLIST:
3092
3210
  case GI_TYPE_TAG_GSLIST:
@@ -3766,7 +3884,6 @@ set_in_array_gtype_arguments_from_ruby(GIArgument *array_argument,
3766
3884
  }
3767
3885
 
3768
3886
  typedef struct {
3769
- GType element_gtype;
3770
3887
  GIStructInfo *struct_info;
3771
3888
  VALUE rb_argument;
3772
3889
  gint n_args;
@@ -3828,6 +3945,58 @@ set_in_array_interface_struct_arguments_from_ruby(GIArgument *array_argument,
3828
3945
  array_argument->v_pointer = data.values;
3829
3946
  }
3830
3947
 
3948
+ typedef struct {
3949
+ VALUE rb_argument;
3950
+ gint n_args;
3951
+ gpointer *values;
3952
+ } ArrayInterfaceObjectFromRubyData;
3953
+
3954
+ static VALUE
3955
+ set_in_array_interface_object_arguments_from_ruby_body(VALUE value)
3956
+ {
3957
+ ArrayInterfaceObjectFromRubyData *data;
3958
+ gint i;
3959
+
3960
+ data = (ArrayInterfaceObjectFromRubyData *)value;
3961
+ data->values = xmalloc(sizeof(gpointer) * data->n_args);
3962
+
3963
+ for (i = 0; i < data->n_args; i++) {
3964
+ VALUE rb_element;
3965
+
3966
+ rb_element = RARRAY_AREF(data->rb_argument, i);
3967
+ data->values[i] = RVAL2GOBJ(rb_element);
3968
+ }
3969
+
3970
+ return Qnil;
3971
+ }
3972
+
3973
+ static G_GNUC_NORETURN VALUE
3974
+ set_in_array_interface_object_arguments_from_ruby_rescue(VALUE value)
3975
+ {
3976
+ ArrayInterfaceObjectFromRubyData *data;
3977
+
3978
+ data = (ArrayInterfaceObjectFromRubyData *)value;
3979
+ xfree(data->values);
3980
+
3981
+ rb_exc_raise(rb_errinfo());
3982
+ }
3983
+
3984
+ static void
3985
+ set_in_array_interface_object_arguments_from_ruby(GIArgument *array_argument,
3986
+ VALUE rb_argument)
3987
+ {
3988
+ ArrayInterfaceObjectFromRubyData data;
3989
+
3990
+ data.rb_argument = rb_argument;
3991
+ data.n_args = RARRAY_LEN(rb_argument);
3992
+ data.values = NULL;
3993
+ rb_rescue(set_in_array_interface_object_arguments_from_ruby_body,
3994
+ (VALUE)&data,
3995
+ set_in_array_interface_object_arguments_from_ruby_rescue,
3996
+ (VALUE)&data);
3997
+ array_argument->v_pointer = data.values;
3998
+ }
3999
+
3831
4000
  static void
3832
4001
  set_in_array_interface_arguments_from_ruby(GIArgument *array_argument,
3833
4002
  GITypeInfo *element_type_info,
@@ -3864,7 +4033,17 @@ set_in_array_interface_arguments_from_ruby(GIArgument *array_argument,
3864
4033
  case GI_INFO_TYPE_BOXED:
3865
4034
  case GI_INFO_TYPE_ENUM:
3866
4035
  case GI_INFO_TYPE_FLAGS:
4036
+ interface_name = g_info_type_to_string(interface_type);
4037
+ g_base_info_unref(interface_info);
4038
+ rb_raise(rb_eNotImpError,
4039
+ "TODO: Ruby -> GIArgument(array)[interface(%s)](%s)",
4040
+ interface_name,
4041
+ g_type_name(gtype));
4042
+ break;
3867
4043
  case GI_INFO_TYPE_OBJECT:
4044
+ set_in_array_interface_object_arguments_from_ruby(array_argument,
4045
+ rb_argument);
4046
+ break;
3868
4047
  case GI_INFO_TYPE_INTERFACE:
3869
4048
  case GI_INFO_TYPE_CONSTANT:
3870
4049
  case GI_INFO_TYPE_INVALID_0:
@@ -47,6 +47,7 @@ struct RBGICallbackData_ {
47
47
  RBGIArgMetadata *metadata;
48
48
  VALUE rb_callback;
49
49
  GObject *owner;
50
+ VALUE rb_owner;
50
51
  };
51
52
 
52
53
  static VALUE RG_TARGET_NAMESPACE;
@@ -338,6 +339,11 @@ rb_gi_callback_data_free(RBGICallbackData *callback_data)
338
339
  rbgobj_object_remove_relative(rb_owner, callback_data->rb_callback);
339
340
  }
340
341
  }
342
+ if (callback_data->rb_owner) {
343
+ rbgobj_remove_relative(callback_data->rb_owner,
344
+ (ID)0,
345
+ callback_data->rb_callback);
346
+ }
341
347
  xfree(callback_data->metadata);
342
348
  xfree(callback_data);
343
349
  }
@@ -1149,35 +1155,42 @@ in_callback_argument_from_ruby(RBGIArgMetadata *metadata,
1149
1155
 
1150
1156
  if (closure_argument) {
1151
1157
  RBGICallbackData *callback_data;
1152
- VALUE rb_owner;
1158
+ VALUE rb_owner = self;
1159
+ static VALUE mGLibObject = Qnil;
1153
1160
 
1154
1161
  callback_data = ALLOC(RBGICallbackData);
1155
1162
  callback_data->callback = callback;
1156
1163
  callback_data->metadata = metadata;
1157
1164
  callback_data->rb_callback = rb_block_proc();
1158
- if (NIL_P(self)) {
1159
- rb_owner = rb_ary_entry(rb_arguments, 0);
1160
- } else {
1161
- rb_owner = self;
1165
+ if (NIL_P(mGLibObject)) {
1166
+ mGLibObject = rb_const_get(mGLib, rb_intern("Object"));
1162
1167
  }
1163
- {
1164
- static VALUE mGLibObject = Qnil;
1165
- if (NIL_P(mGLibObject)) {
1166
- mGLibObject = rb_const_get(mGLib, rb_intern("Object"));
1167
- }
1168
- if (rb_obj_is_kind_of(rb_owner, mGLibObject)) {
1169
- rbgobj_object_add_relative(rb_owner, callback_data->rb_callback);
1170
- callback_data->owner = RVAL2GOBJ(rb_owner);
1171
- g_object_weak_ref(callback_data->owner,
1172
- rb_gi_callback_data_weak_notify,
1173
- callback_data);
1168
+ if (rb_obj_is_kind_of(rb_owner, mGLibObject)) {
1169
+ rbgobj_object_add_relative(rb_owner, callback_data->rb_callback);
1170
+ callback_data->owner = RVAL2GOBJ(rb_owner);
1171
+ g_object_weak_ref(callback_data->owner,
1172
+ rb_gi_callback_data_weak_notify,
1173
+ callback_data);
1174
+ callback_data->rb_owner = Qnil;
1175
+ } else {
1176
+ /* Callback is GC-ed only when callback is invalidated. */
1177
+ if (NIL_P(rb_owner)) {
1178
+ /* Module function case. */
1179
+ static VALUE rb_mGI = Qnil;
1180
+ if (NIL_P(rb_mGI)) {
1181
+ rb_mGI = rb_const_get(rb_cObject,
1182
+ rb_intern("GObjectIntrospection"));
1183
+ }
1184
+ rbgobj_add_relative(rb_mGI, callback_data->rb_callback);
1185
+ callback_data->rb_owner = rb_mGI;
1174
1186
  } else {
1175
- /* Class method case. Callback is never GC-ed. (OK?) */
1187
+ /* Class method case. */
1176
1188
  rbgobj_add_relative(rb_owner, callback_data->rb_callback);
1177
- callback_data->owner = NULL;
1189
+ callback_data->rb_owner = rb_owner;
1178
1190
  }
1179
- closure_argument->v_pointer = callback_data;
1191
+ callback_data->owner = NULL;
1180
1192
  }
1193
+ closure_argument->v_pointer = callback_data;
1181
1194
  }
1182
1195
 
1183
1196
  if (destroy_argument) {
@@ -31,19 +31,7 @@ module GObjectIntrospection
31
31
  end
32
32
  end
33
33
 
34
- base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path
35
- vendor_dir = base_dir + "vendor" + "local"
36
- vendor_bin_dir = vendor_dir + "bin"
37
- GLib.prepend_dll_path(vendor_bin_dir)
38
- begin
39
- major, minor, _ = RUBY_VERSION.split(/\./)
40
- require "#{major}.#{minor}/gobject_introspection.so"
41
- rescue LoadError
42
- require "gobject_introspection.so"
43
- end
44
-
45
- vendor_girepository_dir = vendor_dir + "lib" + "girepository-1.0"
46
- GObjectIntrospection.prepend_typelib_path(vendor_girepository_dir)
34
+ require "gobject_introspection.so"
47
35
 
48
36
  module GObjectIntrospection
49
37
  LOG_DOMAIN = "GObjectIntrospection"
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2017 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2012-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
@@ -365,13 +365,10 @@ module GObjectIntrospection
365
365
  raise ArgumentError, "wrong number of arguments (#{detail})"
366
366
  end
367
367
 
368
- def match_argument?(arg_info, argument)
369
- return true if argument.nil? and arg_info.may_be_null?
370
-
371
- type = arg_info.type
372
- case type.tag
368
+ def match_type?(type_info, value)
369
+ case type_info.tag
373
370
  when TypeTag::BOOLEAN
374
- argument == true or argument == false
371
+ value == true or value == false
375
372
  when TypeTag::INT8,
376
373
  TypeTag::UINT8,
377
374
  TypeTag::INT16,
@@ -382,39 +379,41 @@ module GObjectIntrospection
382
379
  TypeTag::UINT64,
383
380
  TypeTag::FLOAT,
384
381
  TypeTag::DOUBLE
385
- argument.is_a?(Numeric)
382
+ value.is_a?(Numeric)
386
383
  when TypeTag::GTYPE
387
- argument.is_a?(GLib::Type)
384
+ value.is_a?(GLib::Type)
388
385
  when TypeTag::UTF8
389
- argument.is_a?(String)
386
+ value.is_a?(String)
390
387
  when TypeTag::FILENAME
391
- argument.is_a?(String)
388
+ value.is_a?(String)
392
389
  when TypeTag::ARRAY
393
- argument.is_a?(Array)
390
+ element_type_info = type_info.get_param_type(0)
391
+ value.is_a?(Array) and value.all? {|v| match_type?(element_type_info, v)}
394
392
  when TypeTag::INTERFACE
395
- interface = type.interface
393
+ interface = type_info.interface
396
394
  case interface.type
397
395
  when InfoType::STRUCT
398
- match_argument_interface_struct?(arg_info, interface, argument)
396
+ match_type_interface_struct?(interface, value)
399
397
  when InfoType::OBJECT,
400
398
  InfoType::INTERFACE,
401
399
  InfoType::FLAGS,
402
400
  InfoType::ENUM
403
- argument.is_a?(interface.gtype.to_class)
401
+ value.is_a?(interface.gtype.to_class)
404
402
  else
405
403
  # TODO
406
404
  false
407
405
  end
408
406
  when TypeTag::GLIST,
409
407
  TypeTag::GSLIST
410
- argument.is_a?(Array)
408
+ element_type_info = type_info.get_param_type(0)
409
+ value.is_a?(Array) and value.all? {|v| match_type?(element_type_info, v)}
411
410
  else
412
411
  # TODO
413
412
  false
414
413
  end
415
414
  end
416
415
 
417
- def match_argument_interface_struct?(arg_info, interface, argument)
416
+ def match_type_interface_struct?(interface, value)
418
417
  gtype = interface.gtype
419
418
  case gtype.name
420
419
  when "void"
@@ -422,15 +421,21 @@ module GObjectIntrospection
422
421
  false
423
422
  when "CairoSurface"
424
423
  if Object.const_defined?(:Cairo)
425
- argument.is_a?(Cairo::Surface)
424
+ value.is_a?(Cairo::Surface)
426
425
  else
427
426
  false
428
427
  end
429
428
  else
430
- argument.is_a?(gtype.to_class)
429
+ value.is_a?(gtype.to_class)
431
430
  end
432
431
  end
433
432
 
433
+ def match_argument?(arg_info, argument)
434
+ return true if argument.nil? and arg_info.may_be_null?
435
+
436
+ match_type?(arg_info.type, argument)
437
+ end
438
+
434
439
  def rubyish_method_name(function_info, options={})
435
440
  name = function_info.name
436
441
  if options[:prefix]
@@ -463,6 +468,36 @@ module GObjectIntrospection
463
468
  else
464
469
  name
465
470
  end
471
+ when "not_equal"
472
+ if n_in_args == 1
473
+ "!="
474
+ else
475
+ name
476
+ end
477
+ when "less_than"
478
+ if n_in_args == 1
479
+ "<"
480
+ else
481
+ name
482
+ end
483
+ when "less_than_or_equal"
484
+ if n_in_args == 1
485
+ "<="
486
+ else
487
+ name
488
+ end
489
+ when "greater_than"
490
+ if n_in_args == 1
491
+ ">"
492
+ else
493
+ name
494
+ end
495
+ when "greater_than_or_equal"
496
+ if n_in_args == 1
497
+ ">="
498
+ else
499
+ name
500
+ end
466
501
  when /\A(?:is|get_is|can_be)_/
467
502
  "#{$POSTMATCH}?"
468
503
  when /\Aget_/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gobject-introspection
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.3.1
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: 2018-10-31 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glib2
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.3.0
19
+ version: 3.3.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.3.0
26
+ version: 3.3.1
27
27
  description: Ruby/GObjectIntrospection provides bindings of GObject Introspection
28
28
  and a loader module that can generate dynamically Ruby bindings of any GObject C
29
29
  libraries
@@ -135,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 3.0.0.beta1
138
+ rubygems_version: 3.0.2
140
139
  signing_key:
141
140
  specification_version: 4
142
141
  summary: Ruby/GObjectIntrospection is a Ruby binding of GObject Introspection.