gobject-introspection 3.3.2 → 3.3.3
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.
- checksums.yaml +4 -4
- data/ext/gobject-introspection/extconf.rb +0 -2
- data/ext/gobject-introspection/rb-gi-argument.c +22 -20
- data/ext/gobject-introspection/rb-gi-function-info.c +3 -2
- data/lib/gobject-introspection.rb +7 -4
- data/lib/gobject-introspection/loader.rb +92 -145
- data/lib/gobject-introspection/registered-type-info.rb +23 -0
- data/lib/gobject-introspection/struct-info.rb +17 -1
- data/lib/gobject-introspection/type-info.rb +55 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc76064c1fdd49d5158174b7377a27e81db7c090894d67c8009c203155cc8a07
|
4
|
+
data.tar.gz: 478e324f530b7f64261ed38f61c3ba3095c5b4192b8c5aa1f660921f8116a911
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66c719e89a49879e05930cd0d98487081ebbaee693b7b15c670436c07b89b84bf968b78354aca555f871dcc769eca9961043c56a0ea29a8bd65d0c61bd09f96f
|
7
|
+
data.tar.gz: 76c172765527cdabfca614a2728948b125b6043d0cc139b049e8b57f7303b0b71ec8adc301775b376129073ed765809421b9aa57156785e530915edc5337136c
|
@@ -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-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
|
@@ -580,7 +580,7 @@ rb_gi_array_argument_to_ruby(GIArgument *array_argument,
|
|
580
580
|
{
|
581
581
|
VALUE rb_array;
|
582
582
|
GIArrayType array_type;
|
583
|
-
|
583
|
+
gint64 n_elements;
|
584
584
|
|
585
585
|
array_type = g_type_info_get_array_type(array_type_info);
|
586
586
|
n_elements = get_array_length(length_argument, length_type_info);
|
@@ -1513,9 +1513,11 @@ rb_gi_out_argument_init_array_array_interface(GIArgument *argument,
|
|
1513
1513
|
break;
|
1514
1514
|
case GI_INFO_TYPE_STRUCT:
|
1515
1515
|
{
|
1516
|
-
gsize
|
1516
|
+
gsize raw_struct_size;
|
1517
|
+
guint struct_size;
|
1517
1518
|
|
1518
|
-
|
1519
|
+
raw_struct_size = g_struct_info_get_size(interface_info);
|
1520
|
+
struct_size = (guint)raw_struct_size;
|
1519
1521
|
argument->v_pointer = g_array_new(zero_terminated_p,
|
1520
1522
|
TRUE,
|
1521
1523
|
struct_size);
|
@@ -3658,10 +3660,10 @@ set_in_array_length_argument(GIArgument *argument,
|
|
3658
3660
|
argument->v_uint16 = length;
|
3659
3661
|
break;
|
3660
3662
|
case GI_TYPE_TAG_INT32:
|
3661
|
-
argument->v_int32 = length;
|
3663
|
+
argument->v_int32 = (gint32)length;
|
3662
3664
|
break;
|
3663
3665
|
case GI_TYPE_TAG_UINT32:
|
3664
|
-
argument->v_uint32 = length;
|
3666
|
+
argument->v_uint32 = (guint32)length;
|
3665
3667
|
break;
|
3666
3668
|
case GI_TYPE_TAG_INT64:
|
3667
3669
|
argument->v_int64 = length;
|
@@ -3696,7 +3698,7 @@ set_in_array_boolean_arguments_from_ruby(GIArgument *array_argument,
|
|
3696
3698
|
VALUE rb_boolean_array)
|
3697
3699
|
{
|
3698
3700
|
gboolean *booleans;
|
3699
|
-
|
3701
|
+
long i, n_args;
|
3700
3702
|
|
3701
3703
|
n_args = RARRAY_LEN(rb_boolean_array);
|
3702
3704
|
booleans = ALLOC_N(gboolean, n_args);
|
@@ -3712,7 +3714,7 @@ set_in_array_int8_arguments_from_ruby(GIArgument *array_argument,
|
|
3712
3714
|
VALUE rb_number_array)
|
3713
3715
|
{
|
3714
3716
|
gint8 *numbers;
|
3715
|
-
|
3717
|
+
long i, n_args;
|
3716
3718
|
|
3717
3719
|
n_args = RARRAY_LEN(rb_number_array);
|
3718
3720
|
numbers = ALLOC_N(gint8, n_args);
|
@@ -3728,7 +3730,7 @@ set_in_array_uint8_arguments_from_ruby(GIArgument *array_argument,
|
|
3728
3730
|
VALUE rb_number_array)
|
3729
3731
|
{
|
3730
3732
|
guint8 *numbers;
|
3731
|
-
|
3733
|
+
long i, n_args;
|
3732
3734
|
|
3733
3735
|
n_args = RARRAY_LEN(rb_number_array);
|
3734
3736
|
numbers = ALLOC_N(guint8, n_args);
|
@@ -3744,7 +3746,7 @@ set_in_array_int16_arguments_from_ruby(GIArgument *array_argument,
|
|
3744
3746
|
VALUE rb_number_array)
|
3745
3747
|
{
|
3746
3748
|
gint16 *numbers;
|
3747
|
-
|
3749
|
+
long i, n_args;
|
3748
3750
|
|
3749
3751
|
n_args = RARRAY_LEN(rb_number_array);
|
3750
3752
|
numbers = ALLOC_N(gint16, n_args);
|
@@ -3760,7 +3762,7 @@ set_in_array_uint16_arguments_from_ruby(GIArgument *array_argument,
|
|
3760
3762
|
VALUE rb_number_array)
|
3761
3763
|
{
|
3762
3764
|
guint16 *numbers;
|
3763
|
-
|
3765
|
+
long i, n_args;
|
3764
3766
|
|
3765
3767
|
n_args = RARRAY_LEN(rb_number_array);
|
3766
3768
|
numbers = ALLOC_N(guint16, n_args);
|
@@ -3776,7 +3778,7 @@ set_in_array_int32_arguments_from_ruby(GIArgument *array_argument,
|
|
3776
3778
|
VALUE rb_number_array)
|
3777
3779
|
{
|
3778
3780
|
gint32 *numbers;
|
3779
|
-
|
3781
|
+
long i, n_args;
|
3780
3782
|
|
3781
3783
|
n_args = RARRAY_LEN(rb_number_array);
|
3782
3784
|
numbers = ALLOC_N(gint32, n_args);
|
@@ -3792,7 +3794,7 @@ set_in_array_uint32_arguments_from_ruby(GIArgument *array_argument,
|
|
3792
3794
|
VALUE rb_number_array)
|
3793
3795
|
{
|
3794
3796
|
guint32 *numbers;
|
3795
|
-
|
3797
|
+
long i, n_args;
|
3796
3798
|
|
3797
3799
|
n_args = RARRAY_LEN(rb_number_array);
|
3798
3800
|
numbers = ALLOC_N(guint32, n_args);
|
@@ -3808,7 +3810,7 @@ set_in_array_int64_arguments_from_ruby(GIArgument *array_argument,
|
|
3808
3810
|
VALUE rb_number_array)
|
3809
3811
|
{
|
3810
3812
|
gint64 *numbers;
|
3811
|
-
|
3813
|
+
long i, n_args;
|
3812
3814
|
|
3813
3815
|
n_args = RARRAY_LEN(rb_number_array);
|
3814
3816
|
numbers = ALLOC_N(gint64, n_args);
|
@@ -3824,7 +3826,7 @@ set_in_array_uint64_arguments_from_ruby(GIArgument *array_argument,
|
|
3824
3826
|
VALUE rb_number_array)
|
3825
3827
|
{
|
3826
3828
|
guint64 *numbers;
|
3827
|
-
|
3829
|
+
long i, n_args;
|
3828
3830
|
|
3829
3831
|
n_args = RARRAY_LEN(rb_number_array);
|
3830
3832
|
numbers = ALLOC_N(guint64, n_args);
|
@@ -3840,7 +3842,7 @@ set_in_array_float_arguments_from_ruby(GIArgument *array_argument,
|
|
3840
3842
|
VALUE rb_number_array)
|
3841
3843
|
{
|
3842
3844
|
gfloat *numbers;
|
3843
|
-
|
3845
|
+
long i, n_args;
|
3844
3846
|
|
3845
3847
|
n_args = RARRAY_LEN(rb_number_array);
|
3846
3848
|
numbers = ALLOC_N(gfloat, n_args);
|
@@ -3856,7 +3858,7 @@ set_in_array_double_arguments_from_ruby(GIArgument *array_argument,
|
|
3856
3858
|
VALUE rb_number_array)
|
3857
3859
|
{
|
3858
3860
|
gdouble *numbers;
|
3859
|
-
|
3861
|
+
long i, n_args;
|
3860
3862
|
|
3861
3863
|
n_args = RARRAY_LEN(rb_number_array);
|
3862
3864
|
numbers = ALLOC_N(gdouble, n_args);
|
@@ -3872,7 +3874,7 @@ set_in_array_gtype_arguments_from_ruby(GIArgument *array_argument,
|
|
3872
3874
|
VALUE rb_class_array)
|
3873
3875
|
{
|
3874
3876
|
GType *types;
|
3875
|
-
|
3877
|
+
long i, n_args;
|
3876
3878
|
|
3877
3879
|
n_args = RARRAY_LEN(rb_class_array);
|
3878
3880
|
types = ALLOC_N(GType, n_args);
|
@@ -3886,7 +3888,7 @@ set_in_array_gtype_arguments_from_ruby(GIArgument *array_argument,
|
|
3886
3888
|
typedef struct {
|
3887
3889
|
GIStructInfo *struct_info;
|
3888
3890
|
VALUE rb_argument;
|
3889
|
-
|
3891
|
+
long n_args;
|
3890
3892
|
gchar *values;
|
3891
3893
|
} ArrayInterfaceStructFromRubyData;
|
3892
3894
|
|
@@ -3947,7 +3949,7 @@ set_in_array_interface_struct_arguments_from_ruby(GIArgument *array_argument,
|
|
3947
3949
|
|
3948
3950
|
typedef struct {
|
3949
3951
|
VALUE rb_argument;
|
3950
|
-
|
3952
|
+
long n_args;
|
3951
3953
|
gpointer *values;
|
3952
3954
|
} ArrayInterfaceObjectFromRubyData;
|
3953
3955
|
|
@@ -317,7 +317,8 @@ rb_gi_callback_free(RBGICallback *callback)
|
|
317
317
|
}
|
318
318
|
|
319
319
|
static void
|
320
|
-
rb_gi_callback_data_weak_notify(gpointer data,
|
320
|
+
rb_gi_callback_data_weak_notify(gpointer data,
|
321
|
+
G_GNUC_UNUSED GObject *where_the_object_was)
|
321
322
|
{
|
322
323
|
RBGICallbackData *callback_data = data;
|
323
324
|
callback_data->owner = NULL;
|
@@ -1084,7 +1085,7 @@ ffi_closure_callback(G_GNUC_UNUSED ffi_cif *cif,
|
|
1084
1085
|
rb_results = rb_funcallv(callback_data->rb_callback,
|
1085
1086
|
id_call,
|
1086
1087
|
rb_args->len,
|
1087
|
-
(VALUE *)(rb_args->data));
|
1088
|
+
(VALUE *)(void *)(rb_args->data));
|
1088
1089
|
g_array_free(rb_args, TRUE);
|
1089
1090
|
}
|
1090
1091
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2019 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
|
@@ -48,13 +48,16 @@ module GObjectIntrospection
|
|
48
48
|
end
|
49
49
|
GLib::Log.set_log_domain(GObjectIntrospection::LOG_DOMAIN)
|
50
50
|
|
51
|
-
require "gobject-introspection/repository"
|
52
51
|
require "gobject-introspection/arg-info"
|
52
|
+
require "gobject-introspection/boxed-info"
|
53
53
|
require "gobject-introspection/callable-info"
|
54
|
-
require "gobject-introspection/object-info"
|
55
54
|
require "gobject-introspection/interface-info"
|
55
|
+
require "gobject-introspection/object-info"
|
56
|
+
require "gobject-introspection/registered-type-info"
|
57
|
+
require "gobject-introspection/repository"
|
56
58
|
require "gobject-introspection/struct-info"
|
57
|
-
require "gobject-introspection/
|
59
|
+
require "gobject-introspection/type-info"
|
58
60
|
require "gobject-introspection/union-info"
|
61
|
+
|
59
62
|
require "gobject-introspection/version"
|
60
63
|
require "gobject-introspection/loader"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2019 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
|
@@ -82,14 +82,11 @@ module GObjectIntrospection
|
|
82
82
|
|
83
83
|
def define_module_function(target_module, name, function_info)
|
84
84
|
function_info.unlock_gvl = should_unlock_gvl?(function_info, target_module)
|
85
|
-
|
86
|
-
|
85
|
+
full_method_name = "#{target_module}\#.#{name}"
|
86
|
+
invoker = Invoker.new(function_info, name, full_method_name)
|
87
87
|
target_module.module_eval do
|
88
88
|
define_method(name) do |*arguments, &block|
|
89
|
-
|
90
|
-
arguments = arguments_builder.arguments
|
91
|
-
block = arguments_builder.block
|
92
|
-
function_info.invoke(arguments, &block)
|
89
|
+
invoker.invoke(nil, arguments, block)
|
93
90
|
end
|
94
91
|
module_function(name)
|
95
92
|
end
|
@@ -97,18 +94,9 @@ module GObjectIntrospection
|
|
97
94
|
|
98
95
|
def define_singleton_method(klass, name, info)
|
99
96
|
info.unlock_gvl = should_unlock_gvl?(info, klass)
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
singleton_class.__send__(:define_method, name) do |*arguments, &block|
|
104
|
-
arguments_builder.build(arguments, block)
|
105
|
-
arguments = arguments_builder.arguments
|
106
|
-
block = arguments_builder.block
|
107
|
-
if block.nil? and require_callback_p
|
108
|
-
to_enum(name, *arguments)
|
109
|
-
else
|
110
|
-
info.invoke(arguments, &block)
|
111
|
-
end
|
97
|
+
invoker = Invoker.new(info, name, "#{klass}.#{name}")
|
98
|
+
klass.singleton_class.__send__(:define_method, name) do |*arguments, &block|
|
99
|
+
invoker.invoke(nil, arguments, block)
|
112
100
|
end
|
113
101
|
end
|
114
102
|
|
@@ -309,12 +297,9 @@ module GObjectIntrospection
|
|
309
297
|
infos.each do |info|
|
310
298
|
name = "initialize_#{info.name}"
|
311
299
|
info.unlock_gvl = should_unlock_gvl?(info, klass)
|
312
|
-
|
300
|
+
invoker = Invoker.new(info, name, "#{klass}\##{name}")
|
313
301
|
klass.__send__(:define_method, name) do |*arguments, &block|
|
314
|
-
|
315
|
-
arguments = arguments_builder.arguments
|
316
|
-
block = arguments_builder.block
|
317
|
-
info.invoke(self, arguments, &block)
|
302
|
+
invoker.invoke(self, arguments, block)
|
318
303
|
call_initialize_post.call(self)
|
319
304
|
end
|
320
305
|
klass.__send__(:private, name)
|
@@ -365,75 +350,10 @@ module GObjectIntrospection
|
|
365
350
|
raise ArgumentError, "wrong number of arguments (#{detail})"
|
366
351
|
end
|
367
352
|
|
368
|
-
def match_type?(type_info, value)
|
369
|
-
case type_info.tag
|
370
|
-
when TypeTag::BOOLEAN
|
371
|
-
value == true or value == false
|
372
|
-
when TypeTag::INT8,
|
373
|
-
TypeTag::UINT8,
|
374
|
-
TypeTag::INT16,
|
375
|
-
TypeTag::UINT16,
|
376
|
-
TypeTag::INT32,
|
377
|
-
TypeTag::UINT32,
|
378
|
-
TypeTag::INT64,
|
379
|
-
TypeTag::UINT64,
|
380
|
-
TypeTag::FLOAT,
|
381
|
-
TypeTag::DOUBLE
|
382
|
-
value.is_a?(Numeric)
|
383
|
-
when TypeTag::GTYPE
|
384
|
-
value.is_a?(GLib::Type)
|
385
|
-
when TypeTag::UTF8
|
386
|
-
value.is_a?(String)
|
387
|
-
when TypeTag::FILENAME
|
388
|
-
value.is_a?(String)
|
389
|
-
when TypeTag::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)}
|
392
|
-
when TypeTag::INTERFACE
|
393
|
-
interface = type_info.interface
|
394
|
-
case interface.type
|
395
|
-
when InfoType::STRUCT
|
396
|
-
match_type_interface_struct?(interface, value)
|
397
|
-
when InfoType::OBJECT,
|
398
|
-
InfoType::INTERFACE,
|
399
|
-
InfoType::FLAGS,
|
400
|
-
InfoType::ENUM
|
401
|
-
value.is_a?(interface.gtype.to_class)
|
402
|
-
else
|
403
|
-
# TODO
|
404
|
-
false
|
405
|
-
end
|
406
|
-
when TypeTag::GLIST,
|
407
|
-
TypeTag::GSLIST
|
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)}
|
410
|
-
else
|
411
|
-
# TODO
|
412
|
-
false
|
413
|
-
end
|
414
|
-
end
|
415
|
-
|
416
|
-
def match_type_interface_struct?(interface, value)
|
417
|
-
gtype = interface.gtype
|
418
|
-
case gtype.name
|
419
|
-
when "void"
|
420
|
-
# TODO
|
421
|
-
false
|
422
|
-
when "CairoSurface"
|
423
|
-
if Object.const_defined?(:Cairo)
|
424
|
-
value.is_a?(Cairo::Surface)
|
425
|
-
else
|
426
|
-
false
|
427
|
-
end
|
428
|
-
else
|
429
|
-
value.is_a?(gtype.to_class)
|
430
|
-
end
|
431
|
-
end
|
432
|
-
|
433
353
|
def match_argument?(arg_info, argument)
|
434
354
|
return true if argument.nil? and arg_info.may_be_null?
|
435
355
|
|
436
|
-
|
356
|
+
arg_info.type.match?(argument)
|
437
357
|
end
|
438
358
|
|
439
359
|
def rubyish_method_name(function_info, options={})
|
@@ -604,29 +524,9 @@ module GObjectIntrospection
|
|
604
524
|
def define_method(info, klass, method_name)
|
605
525
|
info.unlock_gvl = should_unlock_gvl?(info, klass)
|
606
526
|
remove_existing_method(klass, method_name)
|
607
|
-
|
608
|
-
have_return_value_p = info.have_return_value?
|
609
|
-
arguments_builder = ArgumentsBuilder.new(info, "#{klass}\##{method_name}")
|
610
|
-
require_callback_p = info.require_callback?
|
527
|
+
invoker = Invoker.new(info, method_name, "#{klass}\##{method_name}")
|
611
528
|
klass.__send__(:define_method, method_name) do |*arguments, &block|
|
612
|
-
|
613
|
-
arguments_builder.build(arguments, block)
|
614
|
-
arguments = arguments_builder.arguments
|
615
|
-
block = arguments_builder.block
|
616
|
-
if block.nil? and require_callback_p
|
617
|
-
to_enum(method_name, *arguments)
|
618
|
-
else
|
619
|
-
if function_info_p
|
620
|
-
return_value = info.invoke(arguments, &block)
|
621
|
-
else
|
622
|
-
return_value = info.invoke(self, arguments, &block)
|
623
|
-
end
|
624
|
-
if have_return_value_p
|
625
|
-
return_value
|
626
|
-
else
|
627
|
-
self
|
628
|
-
end
|
629
|
-
end
|
529
|
+
invoker.invoke(self, arguments, block)
|
630
530
|
end
|
631
531
|
end
|
632
532
|
|
@@ -677,31 +577,48 @@ module GObjectIntrospection
|
|
677
577
|
load_methods(info, klass)
|
678
578
|
end
|
679
579
|
|
680
|
-
class
|
681
|
-
|
682
|
-
attr_reader :block
|
683
|
-
def initialize(info, method_name)
|
580
|
+
class Invoker
|
581
|
+
def initialize(info, method_name, full_method_name)
|
684
582
|
@info = info
|
685
583
|
@method_name = method_name
|
686
|
-
|
584
|
+
@full_method_name = full_method_name
|
687
585
|
@prepared = false
|
688
|
-
|
689
|
-
@arguments = nil
|
690
|
-
@block = nil
|
691
586
|
end
|
692
587
|
|
693
|
-
def
|
694
|
-
|
588
|
+
def invoke(receiver, arguments, block)
|
589
|
+
ensure_prepared
|
695
590
|
|
696
|
-
|
697
|
-
|
591
|
+
if receiver and @function_info_p
|
592
|
+
arguments.unshift(receiver)
|
593
|
+
end
|
698
594
|
|
699
|
-
|
700
|
-
|
595
|
+
arguments, block = build(receiver, arguments, block)
|
596
|
+
unless valid?(arguments)
|
597
|
+
if @on_invalid == :fallback
|
598
|
+
return @value_on_invalid
|
599
|
+
else
|
600
|
+
raise ArgumentError, invalid_error_message(invoke_arguments)
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
604
|
+
if block.nil? and @require_callback_p
|
605
|
+
receiver.to_enum(@method_name, *arguments)
|
606
|
+
else
|
607
|
+
if @function_info_p
|
608
|
+
return_value = @info.invoke(arguments, &block)
|
609
|
+
else
|
610
|
+
return_value = @info.invoke(receiver, arguments, &block)
|
611
|
+
end
|
612
|
+
if @have_return_value_p
|
613
|
+
return_value
|
614
|
+
else
|
615
|
+
receiver
|
616
|
+
end
|
617
|
+
end
|
701
618
|
end
|
702
619
|
|
703
620
|
private
|
704
|
-
def
|
621
|
+
def ensure_prepared
|
705
622
|
return if @prepared
|
706
623
|
|
707
624
|
@in_args = @info.in_args
|
@@ -715,40 +632,70 @@ module GObjectIntrospection
|
|
715
632
|
end
|
716
633
|
@valid_n_args_range = (@n_required_in_args..@n_in_args)
|
717
634
|
|
635
|
+
@in_arg_types = []
|
636
|
+
@in_arg_nil_indexes = []
|
637
|
+
@in_args.each_with_index do |arg, i|
|
638
|
+
@in_arg_types << arg.type
|
639
|
+
@in_arg_nil_indexes << i if arg.may_be_null?
|
640
|
+
end
|
641
|
+
|
642
|
+
@function_info_p = (@info.class == FunctionInfo)
|
643
|
+
@have_return_value_p = @info.have_return_value?
|
644
|
+
@require_callback_p = @info.require_callback?
|
645
|
+
|
646
|
+
prepare_on_invalid
|
647
|
+
|
718
648
|
@prepared = true
|
719
649
|
end
|
720
650
|
|
721
|
-
def
|
722
|
-
|
723
|
-
|
724
|
-
@
|
651
|
+
def prepare_on_invalid
|
652
|
+
case @method_name
|
653
|
+
when "=="
|
654
|
+
@value_on_invalid = false
|
655
|
+
@on_invalid = :fallback
|
656
|
+
when "!="
|
657
|
+
@value_on_invalid = true
|
658
|
+
@on_invalid = :fallback
|
659
|
+
else
|
660
|
+
@on_invalid = :raise
|
725
661
|
end
|
662
|
+
end
|
726
663
|
|
727
|
-
|
728
|
-
if
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
664
|
+
def build(receiver, arguments, block)
|
665
|
+
if block and @last_in_arg_is_gclosure
|
666
|
+
arguments << block
|
667
|
+
block = nil
|
668
|
+
end
|
669
|
+
|
670
|
+
n_missing_arguments = @n_in_args - arguments.size
|
671
|
+
if 0 < n_missing_arguments
|
672
|
+
@in_arg_nil_indexes.each_with_index do |nil_index, i|
|
735
673
|
next if i <= n_missing_arguments
|
736
|
-
|
674
|
+
arguments.insert(nil_index, nil)
|
737
675
|
end
|
738
676
|
end
|
677
|
+
|
678
|
+
return arguments, block
|
739
679
|
end
|
740
680
|
|
741
|
-
def
|
742
|
-
return
|
681
|
+
def valid?(arguments)
|
682
|
+
return false unless @valid_n_args_range.cover?(arguments.size)
|
683
|
+
if @on_invalid == :fallback
|
684
|
+
arguments.zip(@in_arg_types) do |argument, type|
|
685
|
+
return false unless type.match?(argument)
|
686
|
+
end
|
687
|
+
end
|
688
|
+
true
|
689
|
+
end
|
743
690
|
|
744
|
-
|
691
|
+
def invalid_error_message(argumetns)
|
692
|
+
detail = "#{arguments.size} for "
|
745
693
|
if @n_in_args == @n_required_in_args
|
746
694
|
detail << "#{@n_in_args}"
|
747
695
|
else
|
748
696
|
detail << "#{@n_required_in_args}..#{@n_in_args}"
|
749
697
|
end
|
750
|
-
|
751
|
-
raise ArgumentError, message
|
698
|
+
"#{@full_method_name}: wrong number of arguments (#{detail})"
|
752
699
|
end
|
753
700
|
end
|
754
701
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Copyright (C) 2019 Ruby-GNOME2 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 RegisteredTypeInfo
|
19
|
+
def match?(value)
|
20
|
+
value.is_a?(gtype.to_class)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012 Ruby-GNOME2 Project Team
|
1
|
+
# Copyright (C) 2012-2019 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
|
@@ -24,5 +24,21 @@ 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
|
27
43
|
end
|
28
44
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright (C) 2019 Ruby-GNOME2 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 TypeInfo
|
19
|
+
def match?(value)
|
20
|
+
case tag
|
21
|
+
when TypeTag::BOOLEAN
|
22
|
+
value == true or value == false
|
23
|
+
when TypeTag::INT8,
|
24
|
+
TypeTag::UINT8,
|
25
|
+
TypeTag::INT16,
|
26
|
+
TypeTag::UINT16,
|
27
|
+
TypeTag::INT32,
|
28
|
+
TypeTag::UINT32,
|
29
|
+
TypeTag::INT64,
|
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
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
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.
|
4
|
+
version: 3.3.3
|
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: 2019-
|
11
|
+
date: 2019-03-09 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.
|
19
|
+
version: 3.3.3
|
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.
|
26
|
+
version: 3.3.3
|
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
|
@@ -85,8 +85,10 @@ files:
|
|
85
85
|
- lib/gobject-introspection/interface-info.rb
|
86
86
|
- lib/gobject-introspection/loader.rb
|
87
87
|
- lib/gobject-introspection/object-info.rb
|
88
|
+
- lib/gobject-introspection/registered-type-info.rb
|
88
89
|
- lib/gobject-introspection/repository.rb
|
89
90
|
- lib/gobject-introspection/struct-info.rb
|
91
|
+
- lib/gobject-introspection/type-info.rb
|
90
92
|
- lib/gobject-introspection/union-info.rb
|
91
93
|
- lib/gobject-introspection/version.rb
|
92
94
|
- test/gobject-introspection-test-utils.rb
|