gobject-introspection 3.4.4 → 3.4.5

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.
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2012 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2012-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
@@ -160,6 +160,15 @@ rg_namespace(VALUE self)
160
160
  return CSTR2RVAL(g_base_info_get_namespace(info));
161
161
  }
162
162
 
163
+ static VALUE
164
+ rg_container(VALUE self)
165
+ {
166
+ GIBaseInfo *info;
167
+
168
+ info = SELF(self);
169
+ return rb_gi_base_info_to_ruby(g_base_info_get_container(info));
170
+ }
171
+
163
172
  static VALUE
164
173
  rg_operator_aref(VALUE self, VALUE name)
165
174
  {
@@ -201,6 +210,7 @@ rb_gi_base_info_init(VALUE rb_mGI)
201
210
  RG_DEF_METHOD(type, 0);
202
211
  RG_DEF_METHOD(name, 0);
203
212
  RG_DEF_METHOD(namespace, 0);
213
+ RG_DEF_METHOD(container, 0);
204
214
  RG_DEF_METHOD_OPERATOR("[]", aref, 1);
205
215
  RG_DEF_METHOD(each, 0);
206
216
 
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2012 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2012-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
@@ -21,7 +21,7 @@
21
21
  #include "rb-gi-private.h"
22
22
 
23
23
  #define RG_TARGET_NAMESPACE rb_cGICallableInfo
24
- #define SELF(self) ((GICallableInfo *)(RVAL2GI_BASE_INFO(self)))
24
+ #define SELF(self) RVAL2GI_CALLABLE_INFO(self)
25
25
 
26
26
  GType
27
27
  gi_callable_info_get_type(void)
@@ -35,6 +35,13 @@ gi_callable_info_get_type(void)
35
35
  return type;
36
36
  }
37
37
 
38
+ static VALUE
39
+ rg_can_throw_gerror_p(VALUE self)
40
+ {
41
+ GICallableInfo *info = SELF(self);
42
+ return CBOOL2RVAL(g_callable_info_can_throw_gerror(info));
43
+ }
44
+
38
45
  static VALUE
39
46
  rg_return_type(VALUE self)
40
47
  {
@@ -91,6 +98,7 @@ rb_gi_callable_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo)
91
98
  G_DEF_CLASS_WITH_PARENT(GI_TYPE_CALLABLE_INFO, "CallableInfo", rb_mGI,
92
99
  rb_cGIBaseInfo);
93
100
 
101
+ RG_DEF_METHOD_P(can_throw_gerror, 0);
94
102
  RG_DEF_METHOD(return_type, 0);
95
103
  RG_DEF_METHOD(caller_owns, 0);
96
104
  RG_DEF_METHOD_P(may_return_null, 0);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2012-2019 Ruby-GNOME Project Team
3
+ * Copyright (C) 2012-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
@@ -28,17 +28,171 @@ struct RBGICallbackData_ {
28
28
  VALUE rb_owner;
29
29
  };
30
30
 
31
+ typedef struct {
32
+ RBGIArguments *args;
33
+ RBGICallback *callback;
34
+ RBGICallbackData *callback_data;
35
+ void *return_value;
36
+ VALUE rb_return_value;
37
+ } RBGICallbackInvokeData;
38
+
31
39
  static GPtrArray *callback_finders;
32
40
  static VALUE mGLibObject = Qnil;
33
41
  static VALUE mGI = Qnil;
34
42
 
43
+ static VALUE
44
+ rb_gi_callback_invoke_without_protect(VALUE user_data)
45
+ {
46
+ RBGICallbackInvokeData *data = (RBGICallbackInvokeData *)user_data;
47
+ VALUE rb_args = rb_gi_arguments_in_to_ruby(data->args);
48
+
49
+ if (data->callback->method_name) {
50
+ ID id___send__;
51
+ VALUE rb_receiver = rb_ary_shift(rb_args);
52
+ CONST_ID(id___send__, "__send__");
53
+ rb_ary_unshift(rb_args, rb_str_new_cstr(data->callback->method_name));
54
+ data->rb_return_value =
55
+ rb_funcallv(rb_receiver,
56
+ id___send__,
57
+ RARRAY_LENINT(rb_args),
58
+ RARRAY_CONST_PTR(rb_args));
59
+ } else {
60
+ ID id_call;
61
+ CONST_ID(id_call, "call");
62
+ VALUE rb_callback =
63
+ rb_gi_callback_data_get_rb_callback(data->callback_data);
64
+ data->rb_return_value =
65
+ rb_funcallv(rb_callback,
66
+ id_call,
67
+ RARRAY_LENINT(rb_args),
68
+ RARRAY_CONST_PTR(rb_args));
69
+ }
70
+
71
+ return Qnil;
72
+ }
73
+
74
+ static VALUE
75
+ rb_gi_callback_invoke_fill_raw_results(VALUE user_data)
76
+ {
77
+ RBGICallbackInvokeData *data = (RBGICallbackInvokeData *)user_data;
78
+ rb_gi_arguments_fill_raw_results(data->args,
79
+ data->rb_return_value,
80
+ data->return_value);
81
+ return Qnil;
82
+ }
83
+
84
+ static VALUE
85
+ rb_gi_callback_invoke(VALUE user_data)
86
+ {
87
+ RBGICallbackInvokeData *data = (RBGICallbackInvokeData *)user_data;
88
+ int state = 0;
89
+ rb_protect(rb_gi_callback_invoke_without_protect,
90
+ user_data,
91
+ &state);
92
+ if (state != 0) {
93
+ VALUE error = rb_errinfo();
94
+ rb_gi_arguments_fill_raw_out_gerror(data->args, error);
95
+ rb_protect(rb_gi_callback_invoke_fill_raw_results,
96
+ user_data,
97
+ &state);
98
+ } else {
99
+ rb_protect(rb_gi_callback_invoke_fill_raw_results,
100
+ user_data,
101
+ &state);
102
+ if (state != 0) {
103
+ VALUE error = rb_errinfo();
104
+ rb_gi_arguments_fill_raw_out_gerror(data->args, error);
105
+ }
106
+ }
107
+ return Qnil;
108
+ }
109
+
110
+ static void
111
+ rb_gi_ffi_closure_callback(G_GNUC_UNUSED ffi_cif *cif,
112
+ void *return_value,
113
+ void **raw_args,
114
+ void *data)
115
+ {
116
+ RBGICallback *callback = data;
117
+ RBGICallbackData *callback_data = NULL;
118
+ RBGIArguments args;
119
+
120
+ rb_gi_arguments_init(&args,
121
+ callback->callback_info,
122
+ Qnil,
123
+ Qnil,
124
+ raw_args);
125
+ {
126
+ guint i;
127
+
128
+ for (i = 0; i < args.metadata->len; i++) {
129
+ RBGIArgMetadata *metadata;
130
+
131
+ metadata = g_ptr_array_index(args.metadata, i);
132
+ if (!metadata->closure_p) {
133
+ continue;
134
+ }
135
+
136
+ callback_data = *((RBGICallbackData **)(raw_args[i]));
137
+ break;
138
+ }
139
+
140
+ if (!callback_data && args.metadata->len > 0) {
141
+ RBGIArgMetadata *metadata;
142
+
143
+ i = args.metadata->len - 1;
144
+ metadata = g_ptr_array_index(args.metadata, i);
145
+ if (metadata->type.tag == GI_TYPE_TAG_VOID &&
146
+ metadata->type.pointer_p &&
147
+ strcmp(metadata->name, "data") == 0) {
148
+ callback_data = *((RBGICallbackData **)(raw_args[i]));
149
+ }
150
+ }
151
+ }
152
+
153
+ {
154
+ RBGICallbackInvokeData data;
155
+ data.args = &args;
156
+ data.callback = callback;
157
+ data.callback_data = callback_data;
158
+ data.return_value = return_value;
159
+ data.rb_return_value = Qnil;
160
+ rbgutil_invoke_callback(rb_gi_callback_invoke, (VALUE)&data);
161
+ }
162
+ rb_gi_arguments_clear(&args);
163
+
164
+ if (callback_data) {
165
+ RBGIArgMetadata *callback_metadata =
166
+ rb_gi_callback_data_get_metadata(callback_data);
167
+ if (callback_metadata->scope_type == GI_SCOPE_TYPE_ASYNC) {
168
+ rb_gi_callback_data_free(callback_data);
169
+ }
170
+ }
171
+ }
172
+
173
+ RBGICallback *
174
+ rb_gi_callback_new(GICallbackInfo *callback_info,
175
+ const gchar *method_name)
176
+ {
177
+ RBGICallback *callback = RB_ZALLOC(RBGICallback);
178
+ callback->callback_info = callback_info;
179
+ g_base_info_ref(callback->callback_info);
180
+ callback->method_name = g_strdup(method_name);
181
+ callback->closure =
182
+ g_callable_info_prepare_closure(callback->callback_info,
183
+ &(callback->cif),
184
+ rb_gi_ffi_closure_callback,
185
+ callback);
186
+ return callback;
187
+ }
188
+
35
189
  static void
36
190
  rb_gi_callback_free(RBGICallback *callback)
37
191
  {
38
192
  g_callable_info_free_closure(callback->callback_info,
39
193
  callback->closure);
194
+ g_free(callback->method_name);
40
195
  g_base_info_unref(callback->callback_info);
41
- g_base_info_unref(callback->type_info);
42
196
  xfree(callback);
43
197
  }
44
198
 
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2012-2014 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2012-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
@@ -18,8 +18,7 @@
18
18
  * MA 02110-1301 USA
19
19
  */
20
20
 
21
- #ifndef RB_GI_CONVERSIONS_H
22
- #define RB_GI_CONVERSIONS_H
21
+ #pragma once
23
22
 
24
23
  #define RVAL2GI_REPOSITORY(rb_object) (G_IREPOSITORY(RVAL2GOBJ(rb_object)))
25
24
  #define RVAL2GI_REPOSITORY_LOAD_FLAGS(rb_flags) \
@@ -65,6 +64,10 @@
65
64
  ((GIFieldInfo *)RVAL2GI_BASE_INFO(rb_object))
66
65
  #define RVAL2GI_TYPE_INFO(rb_object) \
67
66
  ((GITypeInfo *)RVAL2GI_BASE_INFO(rb_object))
67
+ #define RVAL2GI_CALLABLE_INFO(rb_object) \
68
+ ((GICallableInfo *)RVAL2GI_BASE_INFO(rb_object))
69
+ #define RVAL2GI_VFUNC_INFO(rb_object) \
70
+ ((GIVFuncInfo *)RVAL2GI_BASE_INFO(rb_object))
68
71
 
69
72
  #define GI_INFO_TYPE2RVAL(type) (GENUM2RVAL(type, G_TYPE_I_INFO_TYPE))
70
73
  #define GI_TRANSFER2RVAL(transfer) (GENUM2RVAL(transfer, G_TYPE_I_TRANSFER))
@@ -100,6 +103,3 @@ VALUE rb_gi_return_argument_to_ruby (GICallableInfo *callable_info,
100
103
  GPtrArray *args_metadata);
101
104
 
102
105
  VALUE rb_gi_array_type_to_ruby (GIArrayType type);
103
-
104
- #endif
105
-
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2012-2018 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2012-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
@@ -139,6 +139,57 @@ rg_s_define_error(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
139
139
  return G_DEF_ERROR(domain, name, rb_module, rb_parent, gtype);
140
140
  }
141
141
 
142
+ static VALUE
143
+ rg_s_implement_virtual_function(G_GNUC_UNUSED VALUE klass,
144
+ VALUE rb_field_info,
145
+ VALUE rb_implementor_gtype,
146
+ VALUE rb_vtable_gtype,
147
+ VALUE rb_method_name)
148
+ {
149
+ GIFieldInfo *field_info;
150
+ GType implementor_gtype;
151
+ GType vtable_gtype;
152
+ const gchar *method_name;
153
+ RBGICallback *callback;
154
+
155
+ field_info = RVAL2GI_FIELD_INFO(rb_field_info);
156
+ implementor_gtype = rbgobj_gtype_from_ruby(rb_implementor_gtype);
157
+ vtable_gtype = rbgobj_gtype_from_ruby(rb_vtable_gtype);
158
+ method_name = RVAL2CSTR(rb_method_name);
159
+
160
+ {
161
+ GITypeInfo *type_info;
162
+ GICallbackInfo *callback_info;
163
+
164
+ type_info = g_field_info_get_type(field_info);
165
+ callback_info = g_type_info_get_interface(type_info);
166
+ callback = rb_gi_callback_new(callback_info, method_name);
167
+ g_base_info_unref(callback_info);
168
+ g_base_info_unref(type_info);
169
+ }
170
+
171
+ {
172
+ gpointer implementor_struct;
173
+ gpointer vtable_struct;
174
+ gint offset;
175
+ gpointer *method_address;
176
+
177
+ implementor_struct = g_type_class_ref(implementor_gtype);
178
+ if (G_TYPE_IS_INTERFACE(vtable_gtype)) {
179
+ vtable_struct = g_type_interface_peek(implementor_struct,
180
+ vtable_gtype);
181
+ } else {
182
+ vtable_struct = implementor_struct;
183
+ }
184
+ offset = g_field_info_get_offset(field_info);
185
+ method_address = G_STRUCT_MEMBER_P(vtable_struct, offset);
186
+ *method_address = callback->closure;
187
+ g_type_class_unref(implementor_struct);
188
+ }
189
+
190
+ return Qnil;
191
+ }
192
+
142
193
  typedef struct {
143
194
  GType type;
144
195
  VALUE rb_converters;
@@ -333,6 +384,7 @@ rb_gi_loader_init(VALUE rb_mGI)
333
384
  RG_DEF_SMETHOD(define_interface, 3);
334
385
  RG_DEF_SMETHOD(define_struct, -1);
335
386
  RG_DEF_SMETHOD(define_error, -1);
387
+ RG_DEF_SMETHOD(implement_virtual_function, 4);
336
388
  RG_DEF_SMETHOD(register_boxed_class_converter, 1);
337
389
  RG_DEF_SMETHOD(register_object_class_converter, 1);
338
390
  RG_DEF_SMETHOD(register_constant_rename_map, 2);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2012 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2012-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
@@ -272,6 +272,15 @@ rg_get_constant(VALUE self, VALUE rb_n)
272
272
  return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_constant(info, n));
273
273
  }
274
274
 
275
+ static VALUE
276
+ rg_class_struct(VALUE self)
277
+ {
278
+ GIObjectInfo *info;
279
+
280
+ info = SELF(self);
281
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_class_struct(info));
282
+ }
283
+
275
284
  static VALUE
276
285
  rg_unref_function(VALUE self)
277
286
  {
@@ -338,6 +347,7 @@ rb_gi_object_info_init(VALUE rb_mGI, VALUE rb_cGIRegisteredTypeInfo)
338
347
  RG_DEF_METHOD(get_vfunc, 1);
339
348
  RG_DEF_METHOD(n_constants, 0);
340
349
  RG_DEF_METHOD(get_constant, 1);
350
+ RG_DEF_METHOD(class_struct, 0);
341
351
  RG_DEF_METHOD(unref_function, 0);
342
352
  RG_DEF_METHOD(ref_function, 0);
343
353
  RG_DEF_METHOD(set_value_function, 0);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2019 Ruby-GNOME Project Team
3
+ * Copyright (C) 2019-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
@@ -20,6 +20,8 @@
20
20
 
21
21
  #pragma once
22
22
 
23
+ G_GNUC_INTERNAL VALUE
24
+ rb_gi_arguments_in_to_ruby(RBGIArguments *args);
23
25
  G_GNUC_INTERNAL void
24
26
  rb_gi_arguments_in_init(RBGIArguments *args);
25
27
  G_GNUC_INTERNAL void
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2019 Ruby-GNOME Project Team
3
+ * Copyright (C) 2019-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
@@ -101,6 +101,10 @@ G_GNUC_INTERNAL VALUE
101
101
  rb_gi_arguments_get_rb_return_value(RBGIArguments *args,
102
102
  GIArgument *return_value);
103
103
 
104
+ G_GNUC_INTERNAL void
105
+ rb_gi_arguments_fill_raw_out_gerror(RBGIArguments *args,
106
+ VALUE rb_error);
107
+
104
108
  G_GNUC_INTERNAL void
105
109
  rb_gi_arguments_fill_raw_results(RBGIArguments *args,
106
110
  VALUE rb_results,
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2019 Ruby-GNOME Project Team
3
+ * Copyright (C) 2019-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
@@ -22,8 +22,8 @@
22
22
 
23
23
  typedef struct RBGICallback_ {
24
24
  GIArgInfo *arg_info;
25
- GITypeInfo *type_info;
26
25
  GICallbackInfo *callback_info;
26
+ gchar *method_name;
27
27
  ffi_cif cif;
28
28
  ffi_closure *closure;
29
29
  } RBGICallback;
@@ -34,8 +34,11 @@ rb_gi_callback_init(VALUE rb_mGI);
34
34
  G_GNUC_INTERNAL gpointer
35
35
  rb_gi_callback_find(GIArgInfo *info);
36
36
 
37
+ G_GNUC_INTERNAL RBGICallback *
38
+ rb_gi_callback_new(GICallbackInfo *callback_info,
39
+ const gchar *method_name);
40
+
37
41
  G_GNUC_INTERNAL RBGICallbackData *
38
42
  rb_gi_callback_data_new(RBGIArguments *args,
39
43
  RBGICallback *callback,
40
44
  RBGIArgMetadata *metadata);
41
-