gobject-introspection 3.3.7 → 3.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/gobject-introspection/rb-gi-argument.c +16 -11
- data/ext/gobject-introspection/rb-gi-struct-info.c +3 -1
- data/gobject-introspection.gemspec +2 -2
- data/lib/gobject-introspection.rb +3 -1
- data/lib/gobject-introspection/arg-info.rb +18 -1
- data/lib/gobject-introspection/callable-info.rb +20 -1
- data/lib/gobject-introspection/function-info.rb +25 -0
- data/lib/gobject-introspection/loader.rb +65 -22
- data/lib/gobject-introspection/registered-type-info.rb +22 -3
- data/lib/gobject-introspection/struct-info.rb +1 -17
- data/lib/gobject-introspection/type-info.rb +12 -34
- data/lib/gobject-introspection/type-tag.rb +148 -0
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce2773caef8d28da88dd1ed2dfdf50fb20ada6db54107376328245119a7c43e1
|
4
|
+
data.tar.gz: e465986398c01171ea645d4e544abc2649bbffb1cd06ad00ede6ab4f903df981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 464ce3a16ac291fe676b7dc6bb8af918aa706cb3685985309b3bdf8dad13387349ebd4f243e599e89d95151edc927720a9d7cf46a6cabafc58d13a97c46894d8
|
7
|
+
data.tar.gz: 671033bd5e52f2bf7792ea7d86a2797a9c437bb62cc4da1c1ce8264fbc489398e7cc22823695abe7f3c4c2d07564a82800da3c0482452430ba7bb6338ddddafb
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2012-2019 Ruby-
|
3
|
+
* Copyright (C) 2012-2019 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,9 +20,10 @@
|
|
20
20
|
|
21
21
|
#include "rb-gi-private.h"
|
22
22
|
|
23
|
-
static VALUE rb_cGLibValue = Qnil;
|
24
|
-
static VALUE rb_cGLibBytes = Qnil;
|
25
23
|
static VALUE rb_cGLibBoxed = Qnil;
|
24
|
+
static VALUE rb_cGLibBytes = Qnil;
|
25
|
+
static VALUE rb_cGLibObject = Qnil;
|
26
|
+
static VALUE rb_cGLibValue = Qnil;
|
26
27
|
|
27
28
|
static gboolean
|
28
29
|
rb_gi_arg_info_may_be_null(GIArgInfo *arg_info)
|
@@ -3507,6 +3508,8 @@ rb_gi_value_argument_from_ruby_void(GIArgument *argument, GITypeInfo *type_info,
|
|
3507
3508
|
|
3508
3509
|
if (RB_TYPE_P(rb_argument, RUBY_T_STRING)) {
|
3509
3510
|
argument->v_pointer = RSTRING_PTR(rb_argument);
|
3511
|
+
} else if (RVAL2CBOOL(rb_obj_is_kind_of(rb_argument, rb_cGLibObject))) {
|
3512
|
+
argument->v_pointer = RVAL2GOBJ(rb_argument);
|
3510
3513
|
} else {
|
3511
3514
|
argument->v_pointer = GUINT_TO_POINTER(NUM2ULONG(rb_argument));
|
3512
3515
|
}
|
@@ -4148,15 +4151,16 @@ set_in_array_double_arguments_from_ruby(GIArgument *array_argument,
|
|
4148
4151
|
|
4149
4152
|
static void
|
4150
4153
|
set_in_array_gtype_arguments_from_ruby(GIArgument *array_argument,
|
4151
|
-
VALUE
|
4154
|
+
VALUE rb_types)
|
4152
4155
|
{
|
4153
4156
|
GType *types;
|
4154
|
-
long i,
|
4157
|
+
long i, n_types;
|
4155
4158
|
|
4156
|
-
|
4157
|
-
types = ALLOC_N(GType,
|
4158
|
-
for (i = 0; i <
|
4159
|
-
|
4159
|
+
n_types = RARRAY_LEN(rb_types);
|
4160
|
+
types = ALLOC_N(GType, n_types);
|
4161
|
+
for (i = 0; i < n_types; i++) {
|
4162
|
+
VALUE rb_type = RARRAY_PTR(rb_types)[i];
|
4163
|
+
types[i] = rbgobj_gtype_get(rb_type);
|
4160
4164
|
}
|
4161
4165
|
|
4162
4166
|
array_argument->v_pointer = types;
|
@@ -4940,7 +4944,8 @@ rb_gi_in_argument_free(VALUE rb_argument,
|
|
4940
4944
|
void
|
4941
4945
|
rb_gi_argument_init(void)
|
4942
4946
|
{
|
4943
|
-
rb_cGLibValue = rb_const_get(mGLib, rb_intern("Value"));
|
4944
|
-
rb_cGLibBytes = rb_const_get(mGLib, rb_intern("Bytes"));
|
4945
4947
|
rb_cGLibBoxed = rb_const_get(mGLib, rb_intern("Boxed"));
|
4948
|
+
rb_cGLibBytes = rb_const_get(mGLib, rb_intern("Bytes"));
|
4949
|
+
rb_cGLibObject = rb_const_get(mGLib, rb_intern("Object"));
|
4950
|
+
rb_cGLibValue = rb_const_get(mGLib, rb_intern("Value"));
|
4946
4951
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2012-
|
3
|
+
* Copyright (C) 2012-2019 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
|
@@ -125,6 +125,8 @@ rb_gi_struct_info_to_ruby(GIStructInfo *info,
|
|
125
125
|
namespace = g_base_info_get_namespace(base_info);
|
126
126
|
name = g_base_info_get_name(base_info);
|
127
127
|
|
128
|
+
/* Workaround for old cairo-gobject. 1.14.6 on Ubuntu 16.04
|
129
|
+
* doesn't provide GType for cairo_font_options_t. */
|
128
130
|
if (strcmp(namespace, "cairo") == 0) {
|
129
131
|
gchar *gtype_name;
|
130
132
|
GType gtype;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2018 Ruby-
|
3
|
+
# Copyright (C) 2018 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
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"Ruby/GObjectIntrospection provides bindings of GObject Introspection " +
|
28
28
|
"and a loader module that can generate dynamically Ruby bindings " +
|
29
29
|
"of any GObject C libraries"
|
30
|
-
s.author = "The Ruby-
|
30
|
+
s.author = "The Ruby-GNOME Project Team"
|
31
31
|
s.email = "ruby-gnome2-devel-en@lists.sourceforge.net"
|
32
32
|
s.homepage = "https://ruby-gnome2.osdn.jp/"
|
33
33
|
s.licenses = ["LGPL-2.1+"]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-2019 Ruby-
|
1
|
+
# Copyright (C) 2012-2019 Ruby-GNOME 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
|
@@ -51,12 +51,14 @@ GLib::Log.set_log_domain(GObjectIntrospection::LOG_DOMAIN)
|
|
51
51
|
require "gobject-introspection/arg-info"
|
52
52
|
require "gobject-introspection/boxed-info"
|
53
53
|
require "gobject-introspection/callable-info"
|
54
|
+
require "gobject-introspection/function-info"
|
54
55
|
require "gobject-introspection/interface-info"
|
55
56
|
require "gobject-introspection/object-info"
|
56
57
|
require "gobject-introspection/registered-type-info"
|
57
58
|
require "gobject-introspection/repository"
|
58
59
|
require "gobject-introspection/struct-info"
|
59
60
|
require "gobject-introspection/type-info"
|
61
|
+
require "gobject-introspection/type-tag"
|
60
62
|
require "gobject-introspection/union-info"
|
61
63
|
|
62
64
|
require "gobject-introspection/version"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015 Ruby-
|
1
|
+
# Copyright (C) 2015-2019 Ruby-GNOME 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
|
@@ -22,6 +22,23 @@ module GObjectIntrospection
|
|
22
22
|
@gclosure_p = compute_gclosure?
|
23
23
|
end
|
24
24
|
|
25
|
+
def signature
|
26
|
+
sig = "#{name}:"
|
27
|
+
sig << " (optional)" if optional?
|
28
|
+
sig << " (may be null)" if may_be_null?
|
29
|
+
sig << " #{type.description}"
|
30
|
+
sig
|
31
|
+
end
|
32
|
+
|
33
|
+
def inspect
|
34
|
+
super.gsub(/>\z/) do
|
35
|
+
" name=#{name.inspect}" +
|
36
|
+
" optional?=#{optional?.inspect}" +
|
37
|
+
" may_be_null?=#{may_be_null?.inspect}" +
|
38
|
+
" type=#{type.inspect}>"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
25
42
|
private
|
26
43
|
def compute_gclosure?
|
27
44
|
type_info = type
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Ruby-
|
1
|
+
# Copyright (C) 2013-2019 Ruby-GNOME 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
|
@@ -65,6 +65,25 @@ module GObjectIntrospection
|
|
65
65
|
not n_out_args.zero?
|
66
66
|
end
|
67
67
|
|
68
|
+
def description
|
69
|
+
signature
|
70
|
+
end
|
71
|
+
|
72
|
+
def signature
|
73
|
+
argument_signatures = args.collect(&:signature).join(", ")
|
74
|
+
"#{name}(#{argument_signatures}): #{return_type.description}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def inspect
|
78
|
+
super.gsub(/>\z/) do
|
79
|
+
" signature=<#{signature}>" +
|
80
|
+
" name=#{name.inspect}" +
|
81
|
+
" arguments=#{args.inspect}" +
|
82
|
+
" return_type=#{return_type.inspect}" +
|
83
|
+
" may_return_type_null=#{may_return_null?.inspect}>"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
68
87
|
private
|
69
88
|
def compute_in_args
|
70
89
|
array_length_indexes = []
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright (C) 2019 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module GObjectIntrospection
|
18
|
+
class FunctionInfo
|
19
|
+
def inspect
|
20
|
+
super.gsub(/>\z/) do
|
21
|
+
" unlock_gvl?=#{unlock_gvl?.inspect}>"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-2019 Ruby-
|
1
|
+
# Copyright (C) 2012-2019 Ruby-GNOME 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
|
@@ -80,6 +80,10 @@ module GObjectIntrospection
|
|
80
80
|
define_singleton_method(@base_module, name, info)
|
81
81
|
end
|
82
82
|
|
83
|
+
def load_function_info_singleton_method(info, klass, method_name)
|
84
|
+
define_singleton_method(klass, method_name, info)
|
85
|
+
end
|
86
|
+
|
83
87
|
def define_module_function(target_module, name, function_info)
|
84
88
|
function_info.unlock_gvl = should_unlock_gvl?(function_info, target_module)
|
85
89
|
full_method_name = "#{target_module}\#.#{name}"
|
@@ -125,7 +129,7 @@ module GObjectIntrospection
|
|
125
129
|
end
|
126
130
|
unless method_infos.empty?
|
127
131
|
base_class = @base_module.const_get(base_class_name)
|
128
|
-
|
132
|
+
load_methods_method(method_infos, base_class.singleton_class)
|
129
133
|
end
|
130
134
|
else
|
131
135
|
return if info.gtype_struct?
|
@@ -277,11 +281,11 @@ module GObjectIntrospection
|
|
277
281
|
next if method_infos.empty?
|
278
282
|
case method_infos.first
|
279
283
|
when ConstructorInfo
|
280
|
-
|
284
|
+
load_methods_constructor(method_infos, klass)
|
281
285
|
when MethodInfo
|
282
|
-
|
286
|
+
load_methods_method(method_infos, klass)
|
283
287
|
when FunctionInfo
|
284
|
-
|
288
|
+
load_methods_function(method_infos, klass)
|
285
289
|
else
|
286
290
|
raise "TODO: #{method_info_class}"
|
287
291
|
end
|
@@ -292,16 +296,18 @@ module GObjectIntrospection
|
|
292
296
|
end
|
293
297
|
end
|
294
298
|
|
295
|
-
def
|
299
|
+
def load_methods_constructor(infos, klass)
|
296
300
|
return if infos.empty?
|
297
301
|
|
298
302
|
call_initialize_post = lambda do |object|
|
299
303
|
initialize_post(object)
|
300
304
|
end
|
305
|
+
invokers = []
|
301
306
|
infos.each do |info|
|
302
307
|
name = "initialize_#{info.name}"
|
303
308
|
info.unlock_gvl = should_unlock_gvl?(info, klass)
|
304
309
|
invoker = Invoker.new(info, name, "#{klass}\##{name}")
|
310
|
+
invokers << invoker
|
305
311
|
klass.__send__(:define_method, name) do |*arguments, &block|
|
306
312
|
invoker.invoke(self, arguments, block)
|
307
313
|
call_initialize_post.call(self)
|
@@ -309,12 +315,26 @@ module GObjectIntrospection
|
|
309
315
|
klass.__send__(:private, name)
|
310
316
|
end
|
311
317
|
|
312
|
-
|
313
|
-
|
318
|
+
initialize = lambda do |receiver, arguments, block|
|
319
|
+
invokers.each do |invoker|
|
320
|
+
catch do |tag|
|
321
|
+
invoker.invoke(receiver, arguments.dup, block, tag)
|
322
|
+
call_initialize_post.call(receiver)
|
323
|
+
return
|
324
|
+
end
|
325
|
+
end
|
326
|
+
message = "wrong arguments: "
|
327
|
+
message << "#{klass.name}#initialize("
|
328
|
+
message << arguments.collect(&:inspect).join(", ")
|
329
|
+
message << "): "
|
330
|
+
message << "available signatures"
|
331
|
+
invokers.each do |invoker|
|
332
|
+
message << ": #{invoker.signature}"
|
333
|
+
end
|
334
|
+
raise ArgumentError, message
|
314
335
|
end
|
315
336
|
klass.__send__(:define_method, "initialize") do |*arguments, &block|
|
316
|
-
|
317
|
-
__send__("initialize_#{info.name}", *arguments, &block)
|
337
|
+
initialize.call(self, arguments, block)
|
318
338
|
end
|
319
339
|
end
|
320
340
|
|
@@ -506,7 +526,7 @@ module GObjectIntrospection
|
|
506
526
|
false
|
507
527
|
end
|
508
528
|
|
509
|
-
def
|
529
|
+
def load_methods_method(infos, klass)
|
510
530
|
infos.each do |info|
|
511
531
|
method_name = rubyish_method_name(info)
|
512
532
|
load_method_info(info, klass, method_name)
|
@@ -550,12 +570,12 @@ module GObjectIntrospection
|
|
550
570
|
end
|
551
571
|
end
|
552
572
|
|
553
|
-
def
|
573
|
+
def load_methods_function(infos, klass)
|
554
574
|
infos.each do |info|
|
555
575
|
name = rubyish_method_name(info)
|
556
576
|
next if name == "new"
|
557
577
|
next if name == "alloc"
|
558
|
-
|
578
|
+
load_function_info_singleton_method(info, klass, name)
|
559
579
|
end
|
560
580
|
end
|
561
581
|
|
@@ -591,7 +611,7 @@ module GObjectIntrospection
|
|
591
611
|
@prepared = false
|
592
612
|
end
|
593
613
|
|
594
|
-
def invoke(receiver, arguments, block)
|
614
|
+
def invoke(receiver, arguments, block, abort_tag=nil)
|
595
615
|
ensure_prepared
|
596
616
|
|
597
617
|
if receiver and @function_info_p
|
@@ -599,13 +619,16 @@ module GObjectIntrospection
|
|
599
619
|
end
|
600
620
|
|
601
621
|
arguments, block = build(receiver, arguments, block)
|
602
|
-
|
603
|
-
if
|
604
|
-
|
622
|
+
if wrong_number_of_arguments?(arguments)
|
623
|
+
if abort_tag
|
624
|
+
throw(abort_tag)
|
605
625
|
else
|
606
626
|
raise ArgumentError, invalid_error_message(arguments)
|
607
627
|
end
|
608
628
|
end
|
629
|
+
unless normalize_arguments!(arguments, abort_tag)
|
630
|
+
return @value_on_invalid
|
631
|
+
end
|
609
632
|
|
610
633
|
if block.nil? and @require_callback_p
|
611
634
|
receiver.to_enum(@method_name, *arguments)
|
@@ -623,6 +646,12 @@ module GObjectIntrospection
|
|
623
646
|
end
|
624
647
|
end
|
625
648
|
|
649
|
+
def signature
|
650
|
+
ensure_prepared
|
651
|
+
argument_signatures = @in_args.collect(&:signature)
|
652
|
+
"(" + argument_signatures.join(", ") + ")"
|
653
|
+
end
|
654
|
+
|
626
655
|
private
|
627
656
|
def ensure_prepared
|
628
657
|
return if @prepared
|
@@ -684,12 +713,26 @@ module GObjectIntrospection
|
|
684
713
|
return arguments, block
|
685
714
|
end
|
686
715
|
|
687
|
-
def
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
716
|
+
def wrong_number_of_arguments?(arguments)
|
717
|
+
not @valid_n_args_range.cover?(arguments.size)
|
718
|
+
end
|
719
|
+
|
720
|
+
def normalize_arguments!(arguments, abort_tag)
|
721
|
+
arguments.size.times do |i|
|
722
|
+
argument = arguments[i]
|
723
|
+
next if argument.nil?
|
724
|
+
type = @in_arg_types[i]
|
725
|
+
converted_argument = type.try_convert(argument)
|
726
|
+
if converted_argument.nil?
|
727
|
+
if abort_tag
|
728
|
+
throw(abort_tag)
|
729
|
+
elsif @on_invalid == :fallback
|
730
|
+
return false
|
731
|
+
else
|
732
|
+
next
|
733
|
+
end
|
692
734
|
end
|
735
|
+
arguments[i] = converted_argument
|
693
736
|
end
|
694
737
|
true
|
695
738
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2019 Ruby-
|
1
|
+
# Copyright (C) 2019 Ruby-GNOME 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
|
@@ -16,8 +16,27 @@
|
|
16
16
|
|
17
17
|
module GObjectIntrospection
|
18
18
|
class RegisteredTypeInfo
|
19
|
-
def
|
20
|
-
value.
|
19
|
+
def try_convert(value)
|
20
|
+
return nil if value.nil?
|
21
|
+
|
22
|
+
type = gtype
|
23
|
+
return value if type == GLib::Type::NONE
|
24
|
+
|
25
|
+
klass = type.to_class
|
26
|
+
case value
|
27
|
+
when klass
|
28
|
+
value
|
29
|
+
else
|
30
|
+
if klass.respond_to?(:try_convert)
|
31
|
+
klass.try_convert(value)
|
32
|
+
else
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def description
|
39
|
+
"#{gtype.to_class}(#{gtype.name})"
|
21
40
|
end
|
22
41
|
end
|
23
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-2019 Ruby-
|
1
|
+
# Copyright (C) 2012-2019 Ruby-GNOME 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
|
@@ -24,21 +24,5 @@ module GObjectIntrospection
|
|
24
24
|
|
25
25
|
collection_reader("fields")
|
26
26
|
collection_reader("methods")
|
27
|
-
|
28
|
-
def match?(value)
|
29
|
-
case gtype.name
|
30
|
-
when "void"
|
31
|
-
# TODO
|
32
|
-
false
|
33
|
-
when "CairoSurface"
|
34
|
-
if Object.const_defined?(:Cairo)
|
35
|
-
value.is_a?(Cairo::Surface)
|
36
|
-
else
|
37
|
-
false
|
38
|
-
end
|
39
|
-
else
|
40
|
-
super
|
41
|
-
end
|
42
|
-
end
|
43
27
|
end
|
44
28
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2019 Ruby-
|
1
|
+
# Copyright (C) 2019 Ruby-GNOME 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
|
@@ -16,39 +16,17 @@
|
|
16
16
|
|
17
17
|
module GObjectIntrospection
|
18
18
|
class TypeInfo
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
TypeTag::UINT64,
|
31
|
-
TypeTag::FLOAT,
|
32
|
-
TypeTag::DOUBLE
|
33
|
-
value.is_a?(Numeric)
|
34
|
-
when TypeTag::GTYPE
|
35
|
-
value.is_a?(GLib::Type)
|
36
|
-
when TypeTag::UTF8
|
37
|
-
value.is_a?(String)
|
38
|
-
when TypeTag::FILENAME
|
39
|
-
value.is_a?(String)
|
40
|
-
when TypeTag::ARRAY
|
41
|
-
element_type_info = get_param_type(0)
|
42
|
-
value.is_a?(Array) and value.all? {|v| element_type_info.match?(v)}
|
43
|
-
when TypeTag::INTERFACE
|
44
|
-
interface.match?(value)
|
45
|
-
when TypeTag::GLIST,
|
46
|
-
TypeTag::GSLIST
|
47
|
-
element_type_info = get_param_type(0)
|
48
|
-
value.is_a?(Array) and value.all? {|v| element_type_info.match?(v)}
|
49
|
-
else
|
50
|
-
# TODO
|
51
|
-
false
|
19
|
+
def try_convert(value)
|
20
|
+
tag.try_convert(self, value)
|
21
|
+
end
|
22
|
+
|
23
|
+
def description
|
24
|
+
tag.description(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def inspect
|
28
|
+
super.gsub(/>\z/) do
|
29
|
+
" tag=#{tag.inspect}>"
|
52
30
|
end
|
53
31
|
end
|
54
32
|
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# Copyright (C) 2019 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module GObjectIntrospection
|
18
|
+
class TypeTag
|
19
|
+
def try_convert(type_info, value)
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def description(type_info)
|
24
|
+
nick
|
25
|
+
end
|
26
|
+
|
27
|
+
class << BOOLEAN
|
28
|
+
def try_convert(type_info, value)
|
29
|
+
case value
|
30
|
+
when true, false
|
31
|
+
value
|
32
|
+
else
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module IntegerTypeTag
|
39
|
+
def try_convert(type_info, value)
|
40
|
+
if value.is_a?(Integer)
|
41
|
+
value
|
42
|
+
elsif value.respond_to?(:to_int)
|
43
|
+
value.to_int
|
44
|
+
else
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
INT8.extend(IntegerTypeTag)
|
51
|
+
UINT8.extend(IntegerTypeTag)
|
52
|
+
INT16.extend(IntegerTypeTag)
|
53
|
+
UINT16.extend(IntegerTypeTag)
|
54
|
+
INT32.extend(IntegerTypeTag)
|
55
|
+
UINT32.extend(IntegerTypeTag)
|
56
|
+
INT64.extend(IntegerTypeTag)
|
57
|
+
UINT64.extend(IntegerTypeTag)
|
58
|
+
|
59
|
+
module FloatTypeTag
|
60
|
+
def try_convert(type_info, value)
|
61
|
+
if value.is_a?(Float)
|
62
|
+
value
|
63
|
+
elsif value.respond_to?(:to_f) # TODO: Should we stop this?
|
64
|
+
value.to_f
|
65
|
+
else
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
FLOAT.extend(FloatTypeTag)
|
72
|
+
DOUBLE.extend(FloatTypeTag)
|
73
|
+
|
74
|
+
class << GTYPE
|
75
|
+
def try_convert(type_info, value)
|
76
|
+
GLib::Type.try_convert(value)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class << UTF8
|
81
|
+
def try_convert(type_info, value)
|
82
|
+
case value
|
83
|
+
when String
|
84
|
+
value.encode(Encoding::UTF_8)
|
85
|
+
when Symbol
|
86
|
+
value.to_s.encode(Encoding::UTF_8)
|
87
|
+
else
|
88
|
+
if value.respond_to?(:to_str)
|
89
|
+
value.to_str.encode(Encoding::UTF_8)
|
90
|
+
else
|
91
|
+
nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class << FILENAME
|
98
|
+
def try_convert(type_info, value)
|
99
|
+
case value
|
100
|
+
when String
|
101
|
+
value.encode(GLib::FILENAME_ENCODING)
|
102
|
+
else
|
103
|
+
if value.respond_to?(:to_path)
|
104
|
+
value.to_path.encode(GLib::FILENAME_ENCODING)
|
105
|
+
elsif value.respond_to?(:to_str)
|
106
|
+
value.to_str.encode(GLib::FILENAME_ENCODING)
|
107
|
+
else
|
108
|
+
nil
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
module ArrayTypeTag
|
115
|
+
def try_convert(type_info, value)
|
116
|
+
value = Array.try_convert(value)
|
117
|
+
return nil if value.nil?
|
118
|
+
element_type_info = type_info.get_param_type(0)
|
119
|
+
value.collect do |v|
|
120
|
+
unless v.nil?
|
121
|
+
v = element_type_info.try_convert(v)
|
122
|
+
return nil if v.nil?
|
123
|
+
end
|
124
|
+
v
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def description(type_info)
|
129
|
+
element_type_info = type_info.get_param_type(0)
|
130
|
+
"#{super}(#{element_type_info.description})"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
ARRAY.extend(ArrayTypeTag)
|
135
|
+
GLIST.extend(ArrayTypeTag)
|
136
|
+
GSLIST.extend(ArrayTypeTag)
|
137
|
+
|
138
|
+
class << INTERFACE
|
139
|
+
def try_convert(type_info, value)
|
140
|
+
type_info.interface.try_convert(value)
|
141
|
+
end
|
142
|
+
|
143
|
+
def description(type_info)
|
144
|
+
"#{super}(#{type_info.interface.description})"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gobject-introspection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- The Ruby-
|
7
|
+
- The Ruby-GNOME Project Team
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date: 2019-
|
11
|
+
date: 2019-09-09 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: glib2
|
@@ -15,14 +16,14 @@ dependencies:
|
|
15
16
|
requirements:
|
16
17
|
- - '='
|
17
18
|
- !ruby/object:Gem::Version
|
18
|
-
version: 3.3.
|
19
|
+
version: 3.3.8
|
19
20
|
type: :runtime
|
20
21
|
prerelease: false
|
21
22
|
version_requirements: !ruby/object:Gem::Requirement
|
22
23
|
requirements:
|
23
24
|
- - '='
|
24
25
|
- !ruby/object:Gem::Version
|
25
|
-
version: 3.3.
|
26
|
+
version: 3.3.8
|
26
27
|
description: Ruby/GObjectIntrospection provides bindings of GObject Introspection
|
27
28
|
and a loader module that can generate dynamically Ruby bindings of any GObject C
|
28
29
|
libraries
|
@@ -81,6 +82,7 @@ files:
|
|
81
82
|
- lib/gobject-introspection/boxed-info.rb
|
82
83
|
- lib/gobject-introspection/callable-info.rb
|
83
84
|
- lib/gobject-introspection/collection-reader.rb
|
85
|
+
- lib/gobject-introspection/function-info.rb
|
84
86
|
- lib/gobject-introspection/interface-info.rb
|
85
87
|
- lib/gobject-introspection/loader.rb
|
86
88
|
- lib/gobject-introspection/object-info.rb
|
@@ -88,6 +90,7 @@ files:
|
|
88
90
|
- lib/gobject-introspection/repository.rb
|
89
91
|
- lib/gobject-introspection/struct-info.rb
|
90
92
|
- lib/gobject-introspection/type-info.rb
|
93
|
+
- lib/gobject-introspection/type-tag.rb
|
91
94
|
- lib/gobject-introspection/union-info.rb
|
92
95
|
- lib/gobject-introspection/version.rb
|
93
96
|
- test/gobject-introspection-test-utils.rb
|