gir_ffi 0.8.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +18 -0
  3. data/README.md +3 -4
  4. data/lib/ffi-glib.rb +1 -0
  5. data/lib/ffi-glib/container_class_methods.rb +12 -0
  6. data/lib/ffi-glib/destroy_notify.rb +15 -0
  7. data/lib/ffi-glib/main_loop.rb +23 -4
  8. data/lib/ffi-gobject.rb +4 -2
  9. data/lib/ffi-gobject/object.rb +31 -16
  10. data/lib/ffi-gobject/object_class.rb +4 -0
  11. data/lib/ffi-gobject/value.rb +3 -3
  12. data/lib/ffi-gobject_introspection/i_flags_info.rb +0 -1
  13. data/lib/gir_ffi-base/gobject/lib.rb +10 -0
  14. data/lib/gir_ffi/arg_helper.rb +1 -22
  15. data/lib/gir_ffi/boxed_base.rb +1 -0
  16. data/lib/gir_ffi/builder.rb +7 -1
  17. data/lib/gir_ffi/builders/argument_builder.rb +21 -9
  18. data/lib/gir_ffi/builders/argument_builder_collection.rb +28 -9
  19. data/lib/gir_ffi/builders/base_argument_builder.rb +36 -12
  20. data/lib/gir_ffi/builders/base_method_builder.rb +1 -1
  21. data/lib/gir_ffi/builders/callback_argument_builder.rb +4 -0
  22. data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +3 -2
  23. data/lib/gir_ffi/builders/constructor_builder.rb +1 -1
  24. data/lib/gir_ffi/builders/enum_builder.rb +4 -4
  25. data/lib/gir_ffi/builders/error_argument_builder.rb +4 -0
  26. data/lib/gir_ffi/builders/field_builder.rb +23 -9
  27. data/lib/gir_ffi/builders/flags_builder.rb +28 -0
  28. data/lib/gir_ffi/builders/full_c_to_ruby_convertor.rb +18 -0
  29. data/lib/gir_ffi/builders/module_builder.rb +1 -0
  30. data/lib/gir_ffi/builders/null_argument_builder.rb +9 -1
  31. data/lib/gir_ffi/builders/object_builder.rb +7 -4
  32. data/lib/gir_ffi/builders/property_builder.rb +2 -2
  33. data/lib/gir_ffi/builders/return_value_builder.rb +4 -4
  34. data/lib/gir_ffi/builders/struct_builder.rb +10 -2
  35. data/lib/gir_ffi/builders/type_builder.rb +12 -9
  36. data/lib/gir_ffi/builders/unintrospectable_boxed_builder.rb +26 -0
  37. data/lib/gir_ffi/builders/user_defined_builder.rb +2 -2
  38. data/lib/gir_ffi/builders/with_layout.rb +1 -1
  39. data/lib/gir_ffi/callback_base.rb +13 -5
  40. data/lib/gir_ffi/core.rb +1 -0
  41. data/lib/gir_ffi/error_argument_info.rb +4 -0
  42. data/lib/gir_ffi/flags_base.rb +63 -0
  43. data/lib/gir_ffi/in_pointer.rb +1 -3
  44. data/lib/gir_ffi/info_ext/i_type_info.rb +6 -0
  45. data/lib/gir_ffi/object_base.rb +9 -1
  46. data/lib/gir_ffi/object_store.rb +26 -0
  47. data/lib/gir_ffi/unintrospectable_boxed_info.rb +31 -0
  48. data/lib/gir_ffi/unintrospectable_type_info.rb +5 -0
  49. data/lib/gir_ffi/user_defined_type_info.rb +19 -0
  50. data/lib/gir_ffi/version.rb +1 -1
  51. data/test/ffi-glib/destroy_notify_test.rb +13 -0
  52. data/test/ffi-glib/main_loop_test.rb +3 -3
  53. data/test/ffi-gobject/object_class_test.rb +8 -0
  54. data/test/ffi-gobject/object_test.rb +23 -5
  55. data/test/ffi-gobject/value_test.rb +19 -5
  56. data/test/ffi-gobject_test.rb +2 -2
  57. data/test/gir_ffi/builders/argument_builder_test.rb +12 -2
  58. data/test/gir_ffi/builders/constructor_builder_test.rb +4 -4
  59. data/test/gir_ffi/builders/function_builder_test.rb +46 -3
  60. data/test/gir_ffi/builders/object_builder_test.rb +25 -0
  61. data/test/gir_ffi/builders/property_builder_test.rb +4 -4
  62. data/test/gir_ffi/builders/struct_builder_test.rb +15 -13
  63. data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +33 -0
  64. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +6 -0
  65. data/test/gir_ffi/builders/user_defined_builder_test.rb +7 -1
  66. data/test/gir_ffi/callback_base_test.rb +12 -2
  67. data/test/gir_ffi/object_base_test.rb +14 -0
  68. data/test/integration/callback_exceptions_test.rb +61 -0
  69. data/test/integration/generated_gimarshallingtests_test.rb +70 -70
  70. data/test/integration/generated_gio_test.rb +1 -1
  71. data/test/integration/generated_gobject_test.rb +1 -1
  72. data/test/integration/generated_gtop_test.rb +5 -1
  73. data/test/integration/generated_regress_test.rb +83 -102
  74. data/test/integration/generated_warnlib_test.rb +2 -2
  75. metadata +42 -4
@@ -101,7 +101,7 @@ describe 'The generated Gio module' do
101
101
  let(:simple_action) { Gio::SimpleAction.new('test', 'd') }
102
102
 
103
103
  it 'can read the property "state-type" with #get_property' do
104
- simple_action.get_property('state-type').get_value.must_be_nil
104
+ simple_action.get_property('state-type').must_be_nil
105
105
  end
106
106
 
107
107
  it 'can read the property "state-type" with #state_type' do
@@ -89,7 +89,7 @@ describe GObject do
89
89
  let(:binding) { source.bind_property 'double', target, 'double', :default }
90
90
 
91
91
  it 'can read the property "target-property" with #get_property' do
92
- binding.get_property('target-property').get_value.must_equal 'double'
92
+ binding.get_property('target-property').must_equal 'double'
93
93
  end
94
94
 
95
95
  it 'can read the property "target-property" with #target_property' do
@@ -4,7 +4,11 @@ require 'gir_ffi_test_helper'
4
4
  # contains types with bad names, like 'glibtop_cpu'.
5
5
  describe 'The generated GTop module' do
6
6
  before do
7
- GirFFI.setup :GTop
7
+ begin
8
+ GirFFI.setup :GTop
9
+ rescue
10
+ skip 'No GIR data for GTop available'
11
+ end
8
12
  end
9
13
 
10
14
  describe 'Glibtop' do
@@ -5,9 +5,6 @@ GirFFI.setup :Regress
5
5
 
6
6
  if IntrospectionTestExtensions.get_introspection_data 'Regress', 'TestInheritDrawable'
7
7
  class ConcreteDrawable < Regress::TestInheritDrawable
8
- def initialize
9
- super(self.class.gtype, [])
10
- end
11
8
  end
12
9
 
13
10
  GirFFI.define_type ConcreteDrawable
@@ -1149,7 +1146,7 @@ describe Regress do
1149
1146
 
1150
1147
  it 'creates an instance using #new_callback' do
1151
1148
  a = 1
1152
- o = Regress::TestObj.new_callback proc { a = 2 }, nil, nil
1149
+ o = Regress::TestObj.new_callback { a = 2 }
1153
1150
  assert_instance_of Regress::TestObj, o
1154
1151
  a.must_equal 2
1155
1152
 
@@ -1177,7 +1174,7 @@ describe Regress do
1177
1174
 
1178
1175
  it 'has a working function #static_method_callback' do
1179
1176
  a = 1
1180
- Regress::TestObj.static_method_callback proc { a = 2 }
1177
+ Regress::TestObj.static_method_callback { a = 2 }
1181
1178
  assert_equal 2, a
1182
1179
  end
1183
1180
 
@@ -1257,7 +1254,7 @@ describe Regress do
1257
1254
 
1258
1255
  it 'has a working method #instance_method_callback' do
1259
1256
  a = 1
1260
- instance.instance_method_callback proc { a = 2 }
1257
+ instance.instance_method_callback { a = 2 }
1261
1258
  assert_equal 2, a
1262
1259
  end
1263
1260
 
@@ -1344,7 +1341,7 @@ describe Regress do
1344
1341
 
1345
1342
  describe "its 'bare' property" do
1346
1343
  it 'can be retrieved with #get_property' do
1347
- instance.get_property('bare').get_value.must_be_nil
1344
+ instance.get_property('bare').must_be_nil
1348
1345
  end
1349
1346
 
1350
1347
  it 'can be retrieved with #bare' do
@@ -1354,7 +1351,7 @@ describe Regress do
1354
1351
  it 'can be set with #set_property' do
1355
1352
  obj = Regress::TestObj.new_from_file('bar')
1356
1353
  instance.set_property 'bare', obj
1357
- instance.get_property('bare').get_value.must_equal obj
1354
+ instance.get_property('bare').must_equal obj
1358
1355
  end
1359
1356
 
1360
1357
  it 'can be set with #bare=' do
@@ -1362,13 +1359,13 @@ describe Regress do
1362
1359
  instance.bare = obj
1363
1360
 
1364
1361
  instance.bare.must_equal obj
1365
- instance.get_property('bare').get_value.must_equal obj
1362
+ instance.get_property('bare').must_equal obj
1366
1363
  end
1367
1364
  end
1368
1365
 
1369
1366
  describe "its 'boxed' property" do
1370
1367
  it 'can be retrieved with #get_property' do
1371
- instance.get_property('boxed').get_value.must_be_nil
1368
+ instance.get_property('boxed').must_be_nil
1372
1369
  end
1373
1370
 
1374
1371
  it 'can be retrieved with #boxed' do
@@ -1378,20 +1375,20 @@ describe Regress do
1378
1375
  it 'can be set with #set_property' do
1379
1376
  tb = Regress::TestBoxed.new_alternative_constructor1 75
1380
1377
  instance.set_property 'boxed', tb
1381
- instance.get_property('boxed').get_value.some_int8.must_equal 75
1378
+ instance.get_property('boxed').some_int8.must_equal 75
1382
1379
  end
1383
1380
 
1384
1381
  it 'can be set with #boxed=' do
1385
1382
  tb = Regress::TestBoxed.new_alternative_constructor1 75
1386
1383
  instance.boxed = tb
1387
1384
  instance.boxed.some_int8.must_equal tb.some_int8
1388
- instance.get_property('boxed').get_value.some_int8.must_equal tb.some_int8
1385
+ instance.get_property('boxed').some_int8.must_equal tb.some_int8
1389
1386
  end
1390
1387
  end
1391
1388
 
1392
1389
  describe "its 'double' property" do
1393
1390
  it 'can be retrieved with #get_property' do
1394
- instance.get_property('double').get_value.must_equal 0.0
1391
+ instance.get_property('double').must_equal 0.0
1395
1392
  end
1396
1393
 
1397
1394
  it 'can be retrieved with #double' do
@@ -1400,19 +1397,19 @@ describe Regress do
1400
1397
 
1401
1398
  it 'can be set with #set_property' do
1402
1399
  instance.set_property 'double', 3.14
1403
- instance.get_property('double').get_value.must_equal 3.14
1400
+ instance.get_property('double').must_equal 3.14
1404
1401
  end
1405
1402
 
1406
1403
  it 'can be set with #double=' do
1407
1404
  instance.double = 3.14
1408
1405
  instance.double.must_equal 3.14
1409
- instance.get_property('double').get_value.must_equal 3.14
1406
+ instance.get_property('double').must_equal 3.14
1410
1407
  end
1411
1408
  end
1412
1409
 
1413
1410
  describe "its 'float' property" do
1414
1411
  it 'can be retrieved with #get_property' do
1415
- instance.get_property('float').get_value.must_equal 0.0
1412
+ instance.get_property('float').must_equal 0.0
1416
1413
  end
1417
1414
 
1418
1415
  it 'can be retrieved with #float' do
@@ -1421,13 +1418,13 @@ describe Regress do
1421
1418
 
1422
1419
  it 'can be set with #set_property' do
1423
1420
  instance.set_property 'float', 3.14
1424
- instance.get_property('float').get_value.must_be_close_to 3.14
1421
+ instance.get_property('float').must_be_close_to 3.14
1425
1422
  end
1426
1423
 
1427
1424
  it 'can be set with #float=' do
1428
1425
  instance.float = 3.14
1429
1426
  instance.float.must_be_close_to 3.14
1430
- instance.get_property('float').get_value.must_be_close_to 3.14
1427
+ instance.get_property('float').must_be_close_to 3.14
1431
1428
  end
1432
1429
  end
1433
1430
 
@@ -1437,7 +1434,7 @@ describe Regress do
1437
1434
  end
1438
1435
 
1439
1436
  it 'can be retrieved with #get_property' do
1440
- instance.get_property('gtype').get_value.must_equal 0
1437
+ instance.get_property('gtype').must_equal 0
1441
1438
  end
1442
1439
 
1443
1440
  it 'can be retrieved with #gtype' do
@@ -1446,19 +1443,19 @@ describe Regress do
1446
1443
 
1447
1444
  it 'can be set with #set_property' do
1448
1445
  instance.set_property 'gtype', GObject::TYPE_INT64
1449
- instance.get_property('gtype').get_value.must_equal GObject::TYPE_INT64
1446
+ instance.get_property('gtype').must_equal GObject::TYPE_INT64
1450
1447
  end
1451
1448
 
1452
1449
  it 'can be set with #gtype=' do
1453
1450
  instance.gtype = GObject::TYPE_STRING
1454
1451
  instance.gtype.must_equal GObject::TYPE_STRING
1455
- instance.get_property('gtype').get_value.must_equal GObject::TYPE_STRING
1452
+ instance.get_property('gtype').must_equal GObject::TYPE_STRING
1456
1453
  end
1457
1454
  end
1458
1455
 
1459
1456
  describe "its 'hash-table' property" do
1460
1457
  it 'can be retrieved with #get_property' do
1461
- instance.get_property('hash-table').get_value.must_be_nil
1458
+ instance.get_property('hash-table').must_be_nil
1462
1459
  end
1463
1460
 
1464
1461
  it 'can be retrieved with #hash_table' do
@@ -1480,7 +1477,7 @@ describe Regress do
1480
1477
 
1481
1478
  describe "its 'hash-table-old' property" do
1482
1479
  it 'can be retrieved with #get_property' do
1483
- instance.get_property('hash-table-old').get_value.must_be_nil
1480
+ instance.get_property('hash-table-old').must_be_nil
1484
1481
  end
1485
1482
 
1486
1483
  it 'can be retrieved with #hash_table_old' do
@@ -1502,7 +1499,7 @@ describe Regress do
1502
1499
 
1503
1500
  describe "its 'int' property" do
1504
1501
  it 'can be retrieved with #get_property' do
1505
- assert_equal 0, instance.get_property('int').get_value
1502
+ assert_equal 0, instance.get_property('int')
1506
1503
  end
1507
1504
 
1508
1505
  it 'can be retrieved with #int' do
@@ -1511,12 +1508,12 @@ describe Regress do
1511
1508
 
1512
1509
  it 'can be set with #set_property' do
1513
1510
  instance.set_property 'int', 42
1514
- assert_equal 42, instance.get_property('int').get_value
1511
+ assert_equal 42, instance.get_property('int')
1515
1512
  end
1516
1513
 
1517
1514
  it 'can be set with #int=' do
1518
1515
  instance.int = 41
1519
- assert_equal 41, instance.get_property('int').get_value
1516
+ assert_equal 41, instance.get_property('int')
1520
1517
  assert_equal 41, instance.int
1521
1518
  end
1522
1519
  end
@@ -1591,7 +1588,7 @@ describe Regress do
1591
1588
  end
1592
1589
  describe "its 'string' property" do
1593
1590
  it 'can be retrieved with #get_property' do
1594
- assert_nil instance.get_property('string').get_value
1591
+ assert_nil instance.get_property('string')
1595
1592
  end
1596
1593
 
1597
1594
  it 'can be retrieved with #string' do
@@ -1600,13 +1597,13 @@ describe Regress do
1600
1597
 
1601
1598
  it 'can be set with #set_property' do
1602
1599
  instance.set_property 'string', 'foobar'
1603
- assert_equal 'foobar', instance.get_property('string').get_value
1600
+ assert_equal 'foobar', instance.get_property('string')
1604
1601
  end
1605
1602
 
1606
1603
  it 'can be set with #string=' do
1607
1604
  instance.string = 'foobar'
1608
1605
  assert_equal 'foobar', instance.string
1609
- assert_equal 'foobar', instance.get_property('string').get_value
1606
+ assert_equal 'foobar', instance.get_property('string')
1610
1607
  end
1611
1608
  end
1612
1609
 
@@ -1698,7 +1695,7 @@ describe Regress do
1698
1695
  result = GObject.signal_emit instance, 'sig-with-int64-prop', 0x7fff_ffff_ffff_ffff
1699
1696
 
1700
1697
  a.must_equal 0x7fff_ffff_ffff_ffff
1701
- result.get_value.must_equal 0x7fff_ffff_ffff_ffff
1698
+ result.must_equal 0x7fff_ffff_ffff_ffff
1702
1699
  end
1703
1700
 
1704
1701
  it "handles the 'sig-with-intarray-ret' signal" do
@@ -1715,8 +1712,7 @@ describe Regress do
1715
1712
 
1716
1713
  a.must_equal 3
1717
1714
 
1718
- # TODO: Use signal info to convert return value
1719
- GLib::Array.wrap(:gint32, result.get_value_plain).to_a.must_equal [3, 2, 1]
1715
+ result.to_a.must_equal [3, 2, 1]
1720
1716
  end
1721
1717
 
1722
1718
  it "handles the 'sig-with-obj' signal" do
@@ -1756,7 +1752,7 @@ describe Regress do
1756
1752
  result = GObject.signal_emit instance, 'sig-with-uint64-prop', 0xffff_ffff_ffff_ffff
1757
1753
 
1758
1754
  a.must_equal 0xffff_ffff_ffff_ffff
1759
- result.get_value.must_equal 0xffff_ffff_ffff_ffff
1755
+ result.must_equal 0xffff_ffff_ffff_ffff
1760
1756
  end
1761
1757
 
1762
1758
  it "handles the 'test' signal" do
@@ -2276,7 +2272,7 @@ describe Regress do
2276
2272
 
2277
2273
  describe "its 'testbool' property" do
2278
2274
  it 'can be retrieved with #get_property' do
2279
- instance.get_property('testbool').get_value.must_equal true
2275
+ instance.get_property('testbool').must_equal true
2280
2276
  end
2281
2277
 
2282
2278
  it 'can be retrieved with #testbool' do
@@ -2286,23 +2282,23 @@ describe Regress do
2286
2282
  it 'can be set with #set_property' do
2287
2283
  instance.set_property 'testbool', true
2288
2284
  instance.get_testbool.must_equal true
2289
- instance.get_property('testbool').get_value.must_equal true
2285
+ instance.get_property('testbool').must_equal true
2290
2286
 
2291
2287
  instance.set_property 'testbool', false
2292
2288
  instance.get_testbool.must_equal false
2293
- instance.get_property('testbool').get_value.must_equal false
2289
+ instance.get_property('testbool').must_equal false
2294
2290
  end
2295
2291
 
2296
2292
  it 'can be set with #testbool=' do
2297
2293
  instance.testbool = true
2298
2294
  instance.testbool.must_equal true
2299
2295
  instance.get_testbool.must_equal true
2300
- instance.get_property('testbool').get_value.must_equal true
2296
+ instance.get_property('testbool').must_equal true
2301
2297
 
2302
2298
  instance.testbool = false
2303
2299
  instance.testbool.must_equal false
2304
2300
  instance.get_testbool.must_equal false
2305
- instance.get_property('testbool').get_value.must_equal false
2301
+ instance.get_property('testbool').must_equal false
2306
2302
  end
2307
2303
  end
2308
2304
  end
@@ -2438,7 +2434,7 @@ describe Regress do
2438
2434
 
2439
2435
  it 'has a working function #global_get_flags_out' do
2440
2436
  result = Regress.global_get_flags_out
2441
- result.must_equal Regress::TestFlags[:flag1] | Regress::TestFlags[:flag3]
2437
+ result.must_equal(flag1: true, flag3: true)
2442
2438
  end
2443
2439
 
2444
2440
  it 'has a working function #has_parameter_named_attrs' do
@@ -2470,14 +2466,12 @@ describe Regress do
2470
2466
  b = nil
2471
2467
  c = 95
2472
2468
 
2473
- callback = proc do |one, two|
2469
+ result = Regress.test_array_callback do |one, two|
2474
2470
  a = one
2475
2471
  b = two
2476
2472
  c
2477
2473
  end
2478
2474
 
2479
- result = Regress.test_array_callback callback
2480
-
2481
2475
  result.must_equal 2 * c
2482
2476
  a.to_a.must_equal [-1, 0, 1, 2]
2483
2477
  b.to_a.must_equal %w(one two three)
@@ -2539,11 +2533,11 @@ describe Regress do
2539
2533
 
2540
2534
  it 'has a working function #test_array_inout_callback' do
2541
2535
  skip unless get_introspection_data 'Regress', 'test_array_inout_callback'
2542
- Regress.test_array_inout_callback proc { |ints|
2536
+ Regress.test_array_inout_callback do |ints|
2543
2537
  arr = ints.to_a
2544
2538
  arr.shift
2545
2539
  arr
2546
- }
2540
+ end
2547
2541
  pass
2548
2542
  end
2549
2543
 
@@ -2580,10 +2574,10 @@ describe Regress do
2580
2574
  main_loop = GLib::MainLoop.new nil, false
2581
2575
 
2582
2576
  a = 1
2583
- Regress.test_async_ready_callback proc {
2577
+ Regress.test_async_ready_callback do
2584
2578
  main_loop.quit
2585
2579
  a = 2
2586
- }
2580
+ end
2587
2581
 
2588
2582
  main_loop.run
2589
2583
 
@@ -2647,57 +2641,55 @@ describe Regress do
2647
2641
  end
2648
2642
 
2649
2643
  it 'has a working function #test_callback' do
2650
- result = Regress.test_callback proc { 5 }
2644
+ result = Regress.test_callback { 5 }
2651
2645
  assert_equal 5, result
2652
2646
  end
2653
2647
 
2654
2648
  it 'has a working function #test_callback_async' do
2655
2649
  a = 1
2656
- Regress.test_callback_async(proc { |b| a = 2; b },
2657
- 44)
2658
- r = Regress.test_callback_thaw_async
2659
- assert_equal 44, r
2660
- assert_equal 2, a
2650
+ stored_id = nil
2651
+ Regress.test_callback_async { |user_data| stored_id = user_data; a = 2 }
2652
+ result = Regress.test_callback_thaw_async
2653
+ a.must_equal 2
2654
+ stored_id.wont_be_nil
2655
+ result.must_equal 2
2656
+ # TODO: See when we can clean up the stored callback for async callbacks.
2657
+ GirFFI::CallbackBase::CALLBACKS[stored_id].wont_be_nil
2661
2658
  end
2662
2659
 
2663
2660
  it 'has a working function #test_callback_destroy_notify' do
2664
2661
  a = 1
2665
- r1 = Regress.test_callback_destroy_notify(proc { |b| a = 2; b },
2666
- 42,
2667
- proc { a = 3 })
2668
- assert_equal 2, a
2669
- assert_equal 42, r1
2662
+ stored_id = nil
2663
+ r1 = Regress.test_callback_destroy_notify { |user_data| stored_id = user_data; a = 2 }
2664
+ a.must_equal 2
2665
+ GirFFI::CallbackBase::CALLBACKS[stored_id].wont_be_nil
2666
+
2667
+ a = 3
2670
2668
  r2 = Regress.test_callback_thaw_notifications
2671
- assert_equal 3, a
2672
- assert_equal 42, r2
2669
+ a.must_equal 2
2670
+ r1.must_equal r2
2671
+ GirFFI::CallbackBase::CALLBACKS[stored_id].must_be_nil
2673
2672
  end
2674
2673
 
2675
2674
  it 'has a working function #test_callback_destroy_notify_no_user_data' do
2676
2675
  skip unless get_introspection_data 'Regress', 'test_callback_destroy_notify_no_user_data'
2677
2676
 
2678
2677
  callback_times_called = 0
2679
- notify_times_called = 0
2680
2678
  b = :not_nil
2681
2679
 
2682
- callback = proc do|user_data|
2680
+ result = Regress.test_callback_destroy_notify_no_user_data do |user_data|
2683
2681
  callback_times_called += 1
2684
2682
  b = user_data
2685
2683
  callback_times_called * 5
2686
2684
  end
2687
2685
 
2688
- notify = proc { notify_times_called += 1 }
2689
-
2690
- result = Regress.test_callback_destroy_notify_no_user_data callback, notify
2691
-
2692
2686
  callback_times_called.must_equal 1
2693
- notify_times_called.must_equal 0
2694
2687
  result.must_equal 5
2695
2688
  b.must_be_nil
2696
2689
 
2697
2690
  result = Regress.test_callback_thaw_notifications
2698
2691
 
2699
2692
  callback_times_called.must_equal 2
2700
- notify_times_called.must_equal 1
2701
2693
  result.must_equal 10
2702
2694
  b.must_be_nil
2703
2695
  end
@@ -2705,44 +2697,35 @@ describe Regress do
2705
2697
  it 'has a working function #test_callback_return_full' do
2706
2698
  skip unless get_introspection_data 'Regress', 'test_callback_return_full'
2707
2699
  obj = Regress::TestObj.constructor
2708
- Regress.test_callback_return_full proc { obj }
2700
+ Regress.test_callback_return_full { obj }
2709
2701
  ref_count(obj).must_equal 1
2710
2702
  end
2711
2703
 
2712
2704
  it 'has a working function #test_callback_thaw_async' do
2713
2705
  invoked = []
2714
- Regress.test_callback_async proc { invoked << 1; 1 }, nil
2715
- Regress.test_callback_async proc { invoked << 2; 2 }, nil
2716
- Regress.test_callback_async proc { invoked << 3; 3 }, nil
2706
+ Regress.test_callback_async { invoked << 1; 1 }
2707
+ Regress.test_callback_async { invoked << 2; 2 }
2708
+ Regress.test_callback_async { invoked << 3; 3 }
2717
2709
  result = Regress.test_callback_thaw_async
2718
2710
  invoked.must_equal [3, 2, 1]
2719
2711
  result.must_equal 1
2720
2712
  end
2721
2713
 
2722
2714
  it 'has a working function #test_callback_thaw_notifications' do
2723
- invoked = false
2724
- Regress.test_callback_destroy_notify proc { 42 }, nil, nil
2725
- Regress.test_callback_destroy_notify proc { 24 }, nil, proc { invoked = true }
2715
+ Regress.test_callback_destroy_notify { 42 }
2716
+ Regress.test_callback_destroy_notify { 24 }
2726
2717
  result = Regress.test_callback_thaw_notifications
2727
2718
  result.must_equal 66
2728
- invoked.must_equal true
2729
2719
  end
2730
2720
 
2731
2721
  it 'has a working function #test_callback_user_data' do
2732
- a = 'old-value'
2733
- result = Regress.test_callback_user_data proc { |u| a = u; 5 }, 'new-value'
2734
- a.must_equal 'new-value'
2722
+ stored_id = nil
2723
+ result = Regress.test_callback_user_data { |u| stored_id = u; 5 }
2724
+ # TODO: Ensure that the key stored_id is no longer in the callback store
2725
+ stored_id.wont_be_nil
2735
2726
  result.must_equal 5
2736
2727
  end
2737
2728
 
2738
- describe 'the #test_callback_user_data function' do
2739
- it 'handles boolean user_data' do
2740
- a = false
2741
- Regress.test_callback_user_data proc { |u| a = u; 5 }, true
2742
- assert_equal true, a
2743
- end
2744
- end
2745
-
2746
2729
  it 'has a working function #test_closure' do
2747
2730
  c = GObject::RubyClosure.new { 5235 }
2748
2731
  r = Regress.test_closure c
@@ -2774,8 +2757,7 @@ describe Regress do
2774
2757
  end
2775
2758
 
2776
2759
  it 'has a working function #test_date_in_gvalue' do
2777
- r = Regress.test_date_in_gvalue
2778
- date = r.get_value
2760
+ date = Regress.test_date_in_gvalue
2779
2761
  skip unless date.respond_to? :get_year
2780
2762
  assert_equal [1984, :december, 5],
2781
2763
  [date.get_year, date.get_month, date.get_day]
@@ -2830,7 +2812,7 @@ describe Regress do
2830
2812
 
2831
2813
  it 'has a working function #test_gerror_callback' do
2832
2814
  result = nil
2833
- Regress.test_gerror_callback proc { |err| result = err.message }
2815
+ Regress.test_gerror_callback { |err| result = err.message }
2834
2816
  result.must_equal 'regression test error'
2835
2817
  end
2836
2818
 
@@ -3059,7 +3041,7 @@ describe Regress do
3059
3041
 
3060
3042
  it 'has a working function #test_hash_table_callback' do
3061
3043
  value = nil
3062
- Regress.test_hash_table_callback({ 'foo' => 42 }, proc { |hash| value = hash })
3044
+ Regress.test_hash_table_callback('foo' => 42) { |hash| value = hash }
3063
3045
  value.to_hash.must_equal('foo' => 42)
3064
3046
  end
3065
3047
 
@@ -3109,10 +3091,10 @@ describe Regress do
3109
3091
 
3110
3092
  it 'has a working function #test_multi_callback' do
3111
3093
  a = 1
3112
- result = Regress.test_multi_callback proc {
3094
+ result = Regress.test_multi_callback do
3113
3095
  a += 1
3114
3096
  23
3115
- }
3097
+ end
3116
3098
  assert_equal 2 * 23, result
3117
3099
  assert_equal 3, a
3118
3100
  end
@@ -3133,13 +3115,13 @@ describe Regress do
3133
3115
 
3134
3116
  it 'has a working function #test_null_gerror_callback' do
3135
3117
  value = nil
3136
- Regress.test_owned_gerror_callback proc { |err| value = err }
3118
+ Regress.test_owned_gerror_callback { |err| value = err }
3137
3119
  value.message.must_equal 'regression test owned error'
3138
3120
  end
3139
3121
 
3140
3122
  it 'has a working function #test_owned_gerror_callback' do
3141
3123
  value = nil
3142
- Regress.test_owned_gerror_callback proc { |err| value = err }
3124
+ Regress.test_owned_gerror_callback { |err| value = err }
3143
3125
  value.message.must_equal 'regression test owned error'
3144
3126
  end
3145
3127
 
@@ -3155,7 +3137,7 @@ describe Regress do
3155
3137
 
3156
3138
  it 'has a working function #test_simple_callback' do
3157
3139
  a = 0
3158
- Regress.test_simple_callback proc { a = 1 }
3140
+ Regress.test_simple_callback { a = 1 }
3159
3141
  assert_equal 1, a
3160
3142
  end
3161
3143
 
@@ -3179,8 +3161,8 @@ describe Regress do
3179
3161
  end
3180
3162
 
3181
3163
  it 'has a working function #test_strv_in_gvalue' do
3182
- gv = Regress.test_strv_in_gvalue
3183
- gv.get_value.must_be :==, %w(one two three)
3164
+ arr = Regress.test_strv_in_gvalue
3165
+ arr.must_be :==, %w(one two three)
3184
3166
  end
3185
3167
 
3186
3168
  it 'has a working function #test_strv_out' do
@@ -3225,11 +3207,10 @@ describe Regress do
3225
3207
 
3226
3208
  it 'has a working function #test_torture_signature_2' do
3227
3209
  a = 1
3228
- y, z, q = Regress.test_torture_signature_2 244,
3229
- proc { |u| a = u }, 2, proc { a = 3 },
3230
- 'foofoo', 31
3210
+ y, z, q = Regress.test_torture_signature_2 244, 'foofoo', 31 do |u|
3211
+ a = u
3212
+ end
3231
3213
  assert_equal [244, 2 * 244, 6 + 31], [y, z, q]
3232
- assert_equal 3, a
3233
3214
  end
3234
3215
 
3235
3216
  it 'has a working function #test_uint' do
@@ -3322,7 +3303,7 @@ describe Regress do
3322
3303
 
3323
3304
  it 'has a working function #test_value_return' do
3324
3305
  result = Regress.test_value_return 3423
3325
- assert_equal 3423, result.get_int
3306
+ result.must_equal 3423
3326
3307
  end
3327
3308
 
3328
3309
  it 'has a working function #test_versioning' do