rmagick 4.2.2 → 5.3.0

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.
data/ext/RMagick/rminfo.c CHANGED
@@ -12,6 +12,16 @@
12
12
 
13
13
  #include "rmagick.h"
14
14
 
15
+ static void Info_free(void *infoptr);
16
+ static size_t Info_memsize(const void *infoptr);
17
+
18
+ const rb_data_type_t rm_info_data_type = {
19
+ "Magick::Image::Info",
20
+ { NULL, Info_free, Info_memsize, },
21
+ 0, 0,
22
+ RUBY_TYPED_FROZEN_SHAREABLE,
23
+ };
24
+
15
25
 
16
26
  /**
17
27
  * Return the value of the specified option.
@@ -28,7 +38,7 @@ get_option(VALUE self, const char *key)
28
38
  Info *info;
29
39
  const char *value;
30
40
 
31
- Data_Get_Struct(self, Info, info);
41
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
32
42
 
33
43
  value = GetImageOption(info, key);
34
44
  if (value)
@@ -54,7 +64,7 @@ set_option(VALUE self, const char *key, VALUE string)
54
64
  {
55
65
  Info *info;
56
66
 
57
- Data_Get_Struct(self, Info, info);
67
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
58
68
 
59
69
  if (NIL_P(string))
60
70
  {
@@ -90,7 +100,7 @@ static VALUE set_color_option(VALUE self, const char *option, VALUE color)
90
100
  PixelColor pp;
91
101
  MagickBooleanType okay;
92
102
 
93
- Data_Get_Struct(self, Info, info);
103
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
94
104
 
95
105
  if (NIL_P(color))
96
106
  {
@@ -136,7 +146,7 @@ static VALUE get_dbl_option(VALUE self, const char *option)
136
146
  double d;
137
147
  long n;
138
148
 
139
- Data_Get_Struct(self, Info, info);
149
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
140
150
 
141
151
  value = GetImageOption(info, option);
142
152
  if (!value)
@@ -167,7 +177,7 @@ static VALUE set_dbl_option(VALUE self, const char *option, VALUE value)
167
177
  {
168
178
  Info *info;
169
179
 
170
- Data_Get_Struct(self, Info, info);
180
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
171
181
 
172
182
  if (NIL_P(value))
173
183
  {
@@ -206,7 +216,7 @@ static VALUE set_dbl_option(VALUE self, const char *option, VALUE value)
206
216
  VALUE
207
217
  Info_antialias(VALUE self)
208
218
  {
209
- IMPLEMENT_ATTR_READER(Info, antialias, boolean);
219
+ IMPLEMENT_TYPED_ATTR_READER(Info, antialias, boolean, &rm_info_data_type);
210
220
  }
211
221
 
212
222
  /**
@@ -218,7 +228,7 @@ Info_antialias(VALUE self)
218
228
  VALUE
219
229
  Info_antialias_eq(VALUE self, VALUE val)
220
230
  {
221
- IMPLEMENT_ATTR_WRITER(Info, antialias, boolean);
231
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, antialias, boolean, &rm_info_data_type);
222
232
  }
223
233
 
224
234
  /** Maximum length of a format (@see Info_aref) */
@@ -272,7 +282,7 @@ Info_aref(int argc, VALUE *argv, VALUE self)
272
282
 
273
283
  }
274
284
 
275
- Data_Get_Struct(self, Info, info);
285
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
276
286
  value = GetImageOption(info, fkey);
277
287
  if (!value)
278
288
  {
@@ -311,7 +321,7 @@ Info_aset(int argc, VALUE *argv, VALUE self)
311
321
  long format_l, key_l;
312
322
  char ckey[MaxTextExtent];
313
323
 
314
- Data_Get_Struct(self, Info, info);
324
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
315
325
 
316
326
  switch (argc)
317
327
  {
@@ -401,7 +411,7 @@ Info_authenticate(VALUE self)
401
411
  {
402
412
  Info *info;
403
413
 
404
- Data_Get_Struct(self, Info, info);
414
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
405
415
  #if defined(IMAGEMAGICK_7)
406
416
  return C_str_to_R_str(GetImageOption(info, "authenticate"));
407
417
  #else
@@ -422,7 +432,7 @@ Info_authenticate_eq(VALUE self, VALUE passwd_arg)
422
432
  Info *info;
423
433
  char *passwd = NULL;
424
434
 
425
- Data_Get_Struct(self, Info, info);
435
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
426
436
 
427
437
  if (!NIL_P(passwd_arg))
428
438
  {
@@ -465,7 +475,7 @@ Info_background_color(VALUE self)
465
475
  {
466
476
  Info *info;
467
477
 
468
- Data_Get_Struct(self, Info, info);
478
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
469
479
  return rm_pixelcolor_to_color_name_info(info, &info->background_color);
470
480
  }
471
481
 
@@ -481,7 +491,7 @@ Info_background_color_eq(VALUE self, VALUE bc_arg)
481
491
  {
482
492
  Info *info;
483
493
 
484
- Data_Get_Struct(self, Info, info);
494
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
485
495
  Color_to_PixelColor(&info->background_color, bc_arg);
486
496
 
487
497
  return bc_arg;
@@ -498,7 +508,7 @@ Info_border_color(VALUE self)
498
508
  {
499
509
  Info *info;
500
510
 
501
- Data_Get_Struct(self, Info, info);
511
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
502
512
  return rm_pixelcolor_to_color_name_info(info, &info->border_color);
503
513
  }
504
514
 
@@ -513,7 +523,7 @@ Info_border_color_eq(VALUE self, VALUE bc_arg)
513
523
  {
514
524
  Info *info;
515
525
 
516
- Data_Get_Struct(self, Info, info);
526
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
517
527
  Color_to_PixelColor(&info->border_color, bc_arg);
518
528
 
519
529
  return bc_arg;
@@ -572,7 +582,7 @@ Info_channel(int argc, VALUE *argv, VALUE self)
572
582
  raise_ChannelType_error(argv[argc-1]);
573
583
  }
574
584
 
575
- Data_Get_Struct(self, Info, info);
585
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
576
586
 
577
587
  info->channel = channels;
578
588
  return self;
@@ -589,7 +599,7 @@ Info_colorspace(VALUE self)
589
599
  {
590
600
  Info *info;
591
601
 
592
- Data_Get_Struct(self, Info, info);
602
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
593
603
  return ColorspaceType_find(info->colorspace);
594
604
  }
595
605
 
@@ -604,7 +614,7 @@ Info_colorspace_eq(VALUE self, VALUE colorspace)
604
614
  {
605
615
  Info *info;
606
616
 
607
- Data_Get_Struct(self, Info, info);
617
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
608
618
  VALUE_TO_ENUM(colorspace, info->colorspace, ColorspaceType);
609
619
  return colorspace;
610
620
  }
@@ -640,7 +650,7 @@ Info_compression(VALUE self)
640
650
  {
641
651
  Info *info;
642
652
 
643
- Data_Get_Struct(self, Info, info);
653
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
644
654
  return CompressionType_find(info->compression);
645
655
  }
646
656
 
@@ -655,7 +665,7 @@ Info_compression_eq(VALUE self, VALUE type)
655
665
  {
656
666
  Info *info;
657
667
 
658
- Data_Get_Struct(self, Info, info);
668
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
659
669
  VALUE_TO_ENUM(type, info->compression, CompressionType);
660
670
  return type;
661
671
  }
@@ -681,7 +691,7 @@ Info_define(int argc, VALUE *argv, VALUE self)
681
691
  unsigned int okay;
682
692
  VALUE fmt_arg;
683
693
 
684
- Data_Get_Struct(self, Info, info);
694
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
685
695
 
686
696
  switch (argc)
687
697
  {
@@ -728,7 +738,7 @@ Info_delay(VALUE self)
728
738
  const char *delay;
729
739
  char *p;
730
740
 
731
- Data_Get_Struct(self, Info, info);
741
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
732
742
 
733
743
  delay = GetImageOption(info, "delay");
734
744
  if (delay)
@@ -771,7 +781,7 @@ Info_delay_eq(VALUE self, VALUE string)
771
781
  Info *info;
772
782
  int not_num;
773
783
 
774
- Data_Get_Struct(self, Info, info);
784
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
775
785
 
776
786
  if (NIL_P(string))
777
787
  {
@@ -803,7 +813,7 @@ Info_delay_eq(VALUE self, VALUE string)
803
813
  VALUE
804
814
  Info_density(VALUE self)
805
815
  {
806
- IMPLEMENT_ATTR_READER(Info, density, str);
816
+ IMPLEMENT_TYPED_ATTR_READER(Info, density, str, &rm_info_data_type);
807
817
  }
808
818
 
809
819
  /**
@@ -820,7 +830,7 @@ Info_density_eq(VALUE self, VALUE density_arg)
820
830
  VALUE density;
821
831
  char *dens;
822
832
 
823
- Data_Get_Struct(self, Info, info);
833
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
824
834
 
825
835
  if (NIL_P(density_arg))
826
836
  {
@@ -851,7 +861,7 @@ Info_density_eq(VALUE self, VALUE density_arg)
851
861
  VALUE
852
862
  Info_depth(VALUE self)
853
863
  {
854
- IMPLEMENT_ATTR_READER(Info, depth, int);
864
+ IMPLEMENT_TYPED_ATTR_READER(Info, depth, int, &rm_info_data_type);
855
865
  }
856
866
 
857
867
  /**
@@ -866,7 +876,7 @@ Info_depth_eq(VALUE self, VALUE depth)
866
876
  Info *info;
867
877
  unsigned long d;
868
878
 
869
- Data_Get_Struct(self, Info, info);
879
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
870
880
  d = NUM2ULONG(depth);
871
881
  switch (d)
872
882
  {
@@ -950,7 +960,7 @@ Info_dispose(VALUE self)
950
960
  ID dispose_id;
951
961
  const char *dispose;
952
962
 
953
- Data_Get_Struct(self, Info, info);
963
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
954
964
 
955
965
  dispose_id = rb_intern("UndefinedDispose");
956
966
 
@@ -985,7 +995,7 @@ Info_dispose_eq(VALUE self, VALUE disp)
985
995
  const char *option;
986
996
  int x;
987
997
 
988
- Data_Get_Struct(self, Info, info);
998
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
989
999
 
990
1000
  if (NIL_P(disp))
991
1001
  {
@@ -1017,7 +1027,7 @@ Info_dispose_eq(VALUE self, VALUE disp)
1017
1027
  VALUE
1018
1028
  Info_dither(VALUE self)
1019
1029
  {
1020
- IMPLEMENT_ATTR_READER(Info, dither, boolean);
1030
+ IMPLEMENT_TYPED_ATTR_READER(Info, dither, boolean, &rm_info_data_type);
1021
1031
  }
1022
1032
 
1023
1033
  /**
@@ -1029,7 +1039,7 @@ Info_dither(VALUE self)
1029
1039
  VALUE
1030
1040
  Info_dither_eq(VALUE self, VALUE val)
1031
1041
  {
1032
- IMPLEMENT_ATTR_WRITER(Info, dither, boolean);
1042
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, dither, boolean, &rm_info_data_type);
1033
1043
  }
1034
1044
 
1035
1045
 
@@ -1043,7 +1053,7 @@ Info_endian(VALUE self)
1043
1053
  {
1044
1054
  Info *info;
1045
1055
 
1046
- Data_Get_Struct(self, Info, info);
1056
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1047
1057
  return EndianType_find(info->endian);
1048
1058
  }
1049
1059
 
@@ -1065,7 +1075,7 @@ Info_endian_eq(VALUE self, VALUE endian)
1065
1075
  VALUE_TO_ENUM(endian, type, EndianType);
1066
1076
  }
1067
1077
 
1068
- Data_Get_Struct(self, Info, info);
1078
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1069
1079
  info->endian = type;
1070
1080
  return endian;
1071
1081
  }
@@ -1080,7 +1090,7 @@ Info_endian_eq(VALUE self, VALUE endian)
1080
1090
  VALUE
1081
1091
  Info_extract(VALUE self)
1082
1092
  {
1083
- IMPLEMENT_ATTR_READER(Info, extract, str);
1093
+ IMPLEMENT_TYPED_ATTR_READER(Info, extract, str, &rm_info_data_type);
1084
1094
  }
1085
1095
 
1086
1096
  /**
@@ -1097,7 +1107,7 @@ Info_extract_eq(VALUE self, VALUE extract_arg)
1097
1107
  char *extr;
1098
1108
  VALUE extract;
1099
1109
 
1100
- Data_Get_Struct(self, Info, info);
1110
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1101
1111
 
1102
1112
  if (NIL_P(extract_arg))
1103
1113
  {
@@ -1133,7 +1143,7 @@ Info_filename(VALUE self)
1133
1143
  {
1134
1144
  Info *info;
1135
1145
 
1136
- Data_Get_Struct(self, Info, info);
1146
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1137
1147
  return rb_str_new2(info->filename);
1138
1148
  }
1139
1149
 
@@ -1150,7 +1160,7 @@ Info_filename_eq(VALUE self, VALUE filename)
1150
1160
  {
1151
1161
  Info *info;
1152
1162
 
1153
- Data_Get_Struct(self, Info, info);
1163
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1154
1164
 
1155
1165
  // Allow "nil" - remove current filename
1156
1166
  if (NIL_P(filename) || StringValueCStr(filename) == NULL)
@@ -1201,7 +1211,7 @@ Info_fill_eq(VALUE self, VALUE color)
1201
1211
  VALUE
1202
1212
  Info_font(VALUE self)
1203
1213
  {
1204
- IMPLEMENT_ATTR_READER(Info, font, str);
1214
+ IMPLEMENT_TYPED_ATTR_READER(Info, font, str, &rm_info_data_type);
1205
1215
  }
1206
1216
 
1207
1217
  /**
@@ -1215,7 +1225,7 @@ Info_font_eq(VALUE self, VALUE font_arg)
1215
1225
  {
1216
1226
  Info *info;
1217
1227
 
1218
- Data_Get_Struct(self, Info, info);
1228
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1219
1229
  if (NIL_P(font_arg) || StringValueCStr(font_arg) == NULL)
1220
1230
  {
1221
1231
  magick_free(info->font);
@@ -1240,7 +1250,7 @@ VALUE Info_format(VALUE self)
1240
1250
  {
1241
1251
  Info *info;
1242
1252
 
1243
- Data_Get_Struct(self, Info, info);
1253
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1244
1254
  if (*info->magick)
1245
1255
  {
1246
1256
  const MagickInfo *magick_info;
@@ -1270,7 +1280,7 @@ Info_format_eq(VALUE self, VALUE magick)
1270
1280
  char *mgk;
1271
1281
  ExceptionInfo *exception;
1272
1282
 
1273
- Data_Get_Struct(self, Info, info);
1283
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1274
1284
 
1275
1285
  mgk = StringValueCStr(magick);
1276
1286
 
@@ -1297,7 +1307,7 @@ Info_format_eq(VALUE self, VALUE magick)
1297
1307
  VALUE
1298
1308
  Info_fuzz(VALUE self)
1299
1309
  {
1300
- IMPLEMENT_ATTR_READER(Info, fuzz, dbl);
1310
+ IMPLEMENT_TYPED_ATTR_READER(Info, fuzz, dbl, &rm_info_data_type);
1301
1311
  }
1302
1312
 
1303
1313
  /**
@@ -1313,7 +1323,7 @@ Info_fuzz_eq(VALUE self, VALUE fuzz)
1313
1323
  {
1314
1324
  Info *info;
1315
1325
 
1316
- Data_Get_Struct(self, Info, info);
1326
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1317
1327
  info->fuzz = rm_fuzz_to_dbl(fuzz);
1318
1328
  return fuzz;
1319
1329
  }
@@ -1380,7 +1390,7 @@ VALUE Info_gravity(VALUE self)
1380
1390
  const char *gravity;
1381
1391
  ID gravity_id;
1382
1392
 
1383
- Data_Get_Struct(self, Info, info);
1393
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1384
1394
 
1385
1395
  gravity_id = rb_intern("UndefinedGravity");
1386
1396
 
@@ -1416,7 +1426,7 @@ Info_gravity_eq(VALUE self, VALUE grav)
1416
1426
  const char *option;
1417
1427
  int x;
1418
1428
 
1419
- Data_Get_Struct(self, Info, info);
1429
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1420
1430
 
1421
1431
  if (NIL_P(grav))
1422
1432
  {
@@ -1451,7 +1461,7 @@ Info_image_type(VALUE self)
1451
1461
  {
1452
1462
  Info *info;
1453
1463
 
1454
- Data_Get_Struct(self, Info, info);
1464
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1455
1465
  return ImageType_find(info->type);
1456
1466
  }
1457
1467
 
@@ -1466,7 +1476,7 @@ Info_image_type_eq(VALUE self, VALUE type)
1466
1476
  {
1467
1477
  Info *info;
1468
1478
 
1469
- Data_Get_Struct(self, Info, info);
1479
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1470
1480
  VALUE_TO_ENUM(type, info->type, ImageType);
1471
1481
  return type;
1472
1482
  }
@@ -1481,7 +1491,7 @@ Info_interlace(VALUE self)
1481
1491
  {
1482
1492
  Info *info;
1483
1493
 
1484
- Data_Get_Struct(self, Info, info);
1494
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1485
1495
  return InterlaceType_find(info->interlace);
1486
1496
  }
1487
1497
 
@@ -1496,7 +1506,7 @@ Info_interlace_eq(VALUE self, VALUE inter)
1496
1506
  {
1497
1507
  Info *info;
1498
1508
 
1499
- Data_Get_Struct(self, Info, info);
1509
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1500
1510
  VALUE_TO_ENUM(inter, info->interlace, InterlaceType);
1501
1511
  return inter;
1502
1512
  }
@@ -1533,7 +1543,7 @@ Info_matte_color(VALUE self)
1533
1543
  {
1534
1544
  Info *info;
1535
1545
 
1536
- Data_Get_Struct(self, Info, info);
1546
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1537
1547
  return rm_pixelcolor_to_color_name_info(info, &info->matte_color);
1538
1548
  }
1539
1549
 
@@ -1548,38 +1558,12 @@ Info_matte_color_eq(VALUE self, VALUE matte_arg)
1548
1558
  {
1549
1559
  Info *info;
1550
1560
 
1551
- Data_Get_Struct(self, Info, info);
1561
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1552
1562
  Color_to_PixelColor(&info->matte_color, matte_arg);
1553
1563
 
1554
1564
  return matte_arg;
1555
1565
  }
1556
1566
 
1557
- /**
1558
- * Establish a progress monitor.
1559
- *
1560
- * @param monitor [Proc] the monitor
1561
- * @return [Proc] monitor
1562
- * @see Image#monitor=
1563
- */
1564
- VALUE
1565
- Info_monitor_eq(VALUE self, VALUE monitor)
1566
- {
1567
- Info *info;
1568
-
1569
- Data_Get_Struct(self, Info, info);
1570
-
1571
- if (NIL_P(monitor))
1572
- {
1573
- info->progress_monitor = NULL;
1574
- }
1575
- else
1576
- {
1577
- SetImageInfoProgressMonitor(info, rm_progress_monitor, (void *)monitor);
1578
- }
1579
-
1580
- return monitor;
1581
- }
1582
-
1583
1567
  /**
1584
1568
  * Get the monochrome value.
1585
1569
  *
@@ -1588,7 +1572,7 @@ Info_monitor_eq(VALUE self, VALUE monitor)
1588
1572
  VALUE
1589
1573
  Info_monochrome(VALUE self)
1590
1574
  {
1591
- IMPLEMENT_ATTR_READER(Info, monochrome, boolean);
1575
+ IMPLEMENT_TYPED_ATTR_READER(Info, monochrome, boolean, &rm_info_data_type);
1592
1576
  }
1593
1577
 
1594
1578
  /**
@@ -1600,7 +1584,7 @@ Info_monochrome(VALUE self)
1600
1584
  VALUE
1601
1585
  Info_monochrome_eq(VALUE self, VALUE val)
1602
1586
  {
1603
- IMPLEMENT_ATTR_WRITER(Info, monochrome, boolean);
1587
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, monochrome, boolean, &rm_info_data_type);
1604
1588
  }
1605
1589
 
1606
1590
  /**
@@ -1611,7 +1595,7 @@ Info_monochrome_eq(VALUE self, VALUE val)
1611
1595
  VALUE
1612
1596
  Info_number_scenes(VALUE self)
1613
1597
  {
1614
- IMPLEMENT_ATTR_READER(Info, number_scenes, ulong);
1598
+ IMPLEMENT_TYPED_ATTR_READER(Info, number_scenes, ulong, &rm_info_data_type);
1615
1599
  }
1616
1600
 
1617
1601
  /**
@@ -1623,7 +1607,7 @@ Info_number_scenes(VALUE self)
1623
1607
  VALUE
1624
1608
  Info_number_scenes_eq(VALUE self, VALUE val)
1625
1609
  {
1626
- IMPLEMENT_ATTR_WRITER(Info, number_scenes, ulong);
1610
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, number_scenes, ulong, &rm_info_data_type);
1627
1611
  }
1628
1612
 
1629
1613
  /**
@@ -1636,7 +1620,7 @@ Info_orientation(VALUE self)
1636
1620
  {
1637
1621
  Info *info;
1638
1622
 
1639
- Data_Get_Struct(self, Info, info);
1623
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1640
1624
  return OrientationType_find(info->orientation);
1641
1625
  }
1642
1626
 
@@ -1652,7 +1636,7 @@ Info_orientation_eq(VALUE self, VALUE inter)
1652
1636
  {
1653
1637
  Info *info;
1654
1638
 
1655
- Data_Get_Struct(self, Info, info);
1639
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1656
1640
  VALUE_TO_ENUM(inter, info->orientation, OrientationType);
1657
1641
  return inter;
1658
1642
  }
@@ -1670,7 +1654,7 @@ Info_origin(VALUE self)
1670
1654
  Info *info;
1671
1655
  const char *origin;
1672
1656
 
1673
- Data_Get_Struct(self, Info, info);
1657
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1674
1658
 
1675
1659
  origin = GetImageOption(info, "origin");
1676
1660
  return origin ? rb_str_new2(origin) : Qnil;
@@ -1695,7 +1679,7 @@ Info_origin_eq(VALUE self, VALUE origin_arg)
1695
1679
  VALUE origin_str;
1696
1680
  char *origin;
1697
1681
 
1698
- Data_Get_Struct(self, Info, info);
1682
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1699
1683
 
1700
1684
  if (NIL_P(origin_arg))
1701
1685
  {
@@ -1731,7 +1715,7 @@ Info_page(VALUE self)
1731
1715
  {
1732
1716
  Info *info;
1733
1717
 
1734
- Data_Get_Struct(self, Info, info);
1718
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1735
1719
  return info->page ? rb_str_new2(info->page) : Qnil;
1736
1720
 
1737
1721
  }
@@ -1751,7 +1735,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
1751
1735
  VALUE geom_str;
1752
1736
  char *geometry;
1753
1737
 
1754
- Data_Get_Struct(self, Info, info);
1738
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1755
1739
  if (NIL_P(page_arg))
1756
1740
  {
1757
1741
  magick_free(info->page);
@@ -1781,7 +1765,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
1781
1765
  VALUE
1782
1766
  Info_pointsize(VALUE self)
1783
1767
  {
1784
- IMPLEMENT_ATTR_READER(Info, pointsize, dbl);
1768
+ IMPLEMENT_TYPED_ATTR_READER(Info, pointsize, dbl, &rm_info_data_type);
1785
1769
  }
1786
1770
 
1787
1771
  /**
@@ -1793,7 +1777,7 @@ Info_pointsize(VALUE self)
1793
1777
  VALUE
1794
1778
  Info_pointsize_eq(VALUE self, VALUE val)
1795
1779
  {
1796
- IMPLEMENT_ATTR_WRITER(Info, pointsize, dbl);
1780
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, pointsize, dbl, &rm_info_data_type);
1797
1781
  }
1798
1782
 
1799
1783
  /**
@@ -1804,7 +1788,7 @@ Info_pointsize_eq(VALUE self, VALUE val)
1804
1788
  VALUE
1805
1789
  Info_quality(VALUE self)
1806
1790
  {
1807
- IMPLEMENT_ATTR_READER(Info, quality, ulong);
1791
+ IMPLEMENT_TYPED_ATTR_READER(Info, quality, ulong, &rm_info_data_type);
1808
1792
  }
1809
1793
 
1810
1794
  /**
@@ -1816,7 +1800,7 @@ Info_quality(VALUE self)
1816
1800
  VALUE
1817
1801
  Info_quality_eq(VALUE self, VALUE val)
1818
1802
  {
1819
- IMPLEMENT_ATTR_WRITER(Info, quality, ulong);
1803
+ IMPLEMENT_TYPED_ATTR_WRITER(Info, quality, ulong, &rm_info_data_type);
1820
1804
  }
1821
1805
 
1822
1806
  /**
@@ -1829,7 +1813,7 @@ Info_sampling_factor(VALUE self)
1829
1813
  {
1830
1814
  Info *info;
1831
1815
 
1832
- Data_Get_Struct(self, Info, info);
1816
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1833
1817
  if (info->sampling_factor)
1834
1818
  {
1835
1819
  return rb_str_new2(info->sampling_factor);
@@ -1853,7 +1837,7 @@ Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
1853
1837
  char *sampling_factor_p = NULL;
1854
1838
  long sampling_factor_len = 0;
1855
1839
 
1856
- Data_Get_Struct(self, Info, info);
1840
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1857
1841
 
1858
1842
  if (!NIL_P(sampling_factor))
1859
1843
  {
@@ -1884,7 +1868,7 @@ Info_scene(VALUE self)
1884
1868
  {
1885
1869
  Info *info;
1886
1870
 
1887
- Data_Get_Struct(self, Info, info);
1871
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1888
1872
  return ULONG2NUM(info->scene);
1889
1873
  }
1890
1874
 
@@ -1901,7 +1885,7 @@ Info_scene_eq(VALUE self, VALUE scene)
1901
1885
  Info *info;
1902
1886
  char buf[25];
1903
1887
 
1904
- Data_Get_Struct(self, Info, info);
1888
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1905
1889
  info->scene = NUM2ULONG(scene);
1906
1890
 
1907
1891
  snprintf(buf, sizeof(buf), "%"RMIuSIZE"", info->scene);
@@ -1919,7 +1903,7 @@ Info_scene_eq(VALUE self, VALUE scene)
1919
1903
  VALUE
1920
1904
  Info_server_name(VALUE self)
1921
1905
  {
1922
- IMPLEMENT_ATTR_READER(Info, server_name, str);
1906
+ IMPLEMENT_TYPED_ATTR_READER(Info, server_name, str, &rm_info_data_type);
1923
1907
  }
1924
1908
 
1925
1909
 
@@ -1934,7 +1918,7 @@ Info_server_name_eq(VALUE self, VALUE server_arg)
1934
1918
  {
1935
1919
  Info *info;
1936
1920
 
1937
- Data_Get_Struct(self, Info, info);
1921
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1938
1922
  if (NIL_P(server_arg) || StringValueCStr(server_arg) == NULL)
1939
1923
  {
1940
1924
  magick_free(info->server_name);
@@ -1959,7 +1943,7 @@ Info_server_name_eq(VALUE self, VALUE server_arg)
1959
1943
  VALUE
1960
1944
  Info_size(VALUE self)
1961
1945
  {
1962
- IMPLEMENT_ATTR_READER(Info, size, str);
1946
+ IMPLEMENT_TYPED_ATTR_READER(Info, size, str, &rm_info_data_type);
1963
1947
  }
1964
1948
 
1965
1949
  /**
@@ -1976,7 +1960,7 @@ Info_size_eq(VALUE self, VALUE size_arg)
1976
1960
  VALUE size;
1977
1961
  char *sz;
1978
1962
 
1979
- Data_Get_Struct(self, Info, info);
1963
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
1980
1964
 
1981
1965
  if (NIL_P(size_arg))
1982
1966
  {
@@ -2062,7 +2046,7 @@ Info_texture_eq(VALUE self, VALUE texture)
2062
2046
  Image *image;
2063
2047
  char name[MaxTextExtent];
2064
2048
 
2065
- Data_Get_Struct(self, Info, info);
2049
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2066
2050
 
2067
2051
  // Delete any existing texture file
2068
2052
  if (info->texture)
@@ -2100,7 +2084,7 @@ Info_tile_offset(VALUE self)
2100
2084
  Info *info;
2101
2085
  const char *tile_offset;
2102
2086
 
2103
- Data_Get_Struct(self, Info, info);
2087
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2104
2088
 
2105
2089
  tile_offset = GetImageOption(info, "tile-offset");
2106
2090
 
@@ -2134,7 +2118,7 @@ Info_tile_offset_eq(VALUE self, VALUE offset)
2134
2118
  rb_raise(rb_eArgError, "invalid tile offset geometry: %s", tile_offset);
2135
2119
  }
2136
2120
 
2137
- Data_Get_Struct(self, Info, info);
2121
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2138
2122
 
2139
2123
  DeleteImageOption(info, "tile-offset");
2140
2124
  SetImageOption(info, "tile-offset", tile_offset);
@@ -2156,7 +2140,7 @@ Info_transparent_color(VALUE self)
2156
2140
  {
2157
2141
  Info *info;
2158
2142
 
2159
- Data_Get_Struct(self, Info, info);
2143
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2160
2144
  return rm_pixelcolor_to_color_name_info(info, &info->transparent_color);
2161
2145
  }
2162
2146
 
@@ -2172,7 +2156,7 @@ Info_transparent_color_eq(VALUE self, VALUE tc_arg)
2172
2156
  {
2173
2157
  Info *info;
2174
2158
 
2175
- Data_Get_Struct(self, Info, info);
2159
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2176
2160
  Color_to_PixelColor(&info->transparent_color, tc_arg);
2177
2161
 
2178
2162
  return tc_arg;
@@ -2204,7 +2188,7 @@ Info_undefine(VALUE self, VALUE format, VALUE key)
2204
2188
 
2205
2189
  snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
2206
2190
 
2207
- Data_Get_Struct(self, Info, info);
2191
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2208
2192
  DeleteImageOption(info, fkey);
2209
2193
 
2210
2194
  return self;
@@ -2244,7 +2228,7 @@ Info_units(VALUE self)
2244
2228
  {
2245
2229
  Info *info;
2246
2230
 
2247
- Data_Get_Struct(self, Info, info);
2231
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2248
2232
  return ResolutionType_find(info->units);
2249
2233
  }
2250
2234
 
@@ -2259,7 +2243,7 @@ Info_units_eq(VALUE self, VALUE units)
2259
2243
  {
2260
2244
  Info *info;
2261
2245
 
2262
- Data_Get_Struct(self, Info, info);
2246
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2263
2247
  VALUE_TO_ENUM(units, info->units, ResolutionType);
2264
2248
  return units;
2265
2249
  }
@@ -2274,7 +2258,7 @@ Info_view(VALUE self)
2274
2258
  {
2275
2259
  Info *info;
2276
2260
 
2277
- Data_Get_Struct(self, Info, info);
2261
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2278
2262
  #if defined(IMAGEMAGICK_7)
2279
2263
  return C_str_to_R_str(GetImageOption(info, "fpx:view"));
2280
2264
  #else
@@ -2294,7 +2278,7 @@ Info_view_eq(VALUE self, VALUE view_arg)
2294
2278
  Info *info;
2295
2279
  char *view = NULL;
2296
2280
 
2297
- Data_Get_Struct(self, Info, info);
2281
+ TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
2298
2282
 
2299
2283
  if (!NIL_P(view_arg))
2300
2284
  {
@@ -2334,7 +2318,7 @@ Info_view_eq(VALUE self, VALUE view_arg)
2334
2318
  * @param infoptr pointer to the Info object
2335
2319
  */
2336
2320
  static void
2337
- destroy_Info(void *infoptr)
2321
+ Info_free(void *infoptr)
2338
2322
  {
2339
2323
  Info *info = (Info *)infoptr;
2340
2324
 
@@ -2348,6 +2332,18 @@ destroy_Info(void *infoptr)
2348
2332
  DestroyImageInfo(info);
2349
2333
  }
2350
2334
 
2335
+ /**
2336
+ * Get Info object size.
2337
+ *
2338
+ * No Ruby usage (internal function)
2339
+ *
2340
+ * @param infoptr pointer to the Info object
2341
+ */
2342
+ static size_t
2343
+ Info_memsize(const void *infoptr)
2344
+ {
2345
+ return sizeof(Info);
2346
+ }
2351
2347
 
2352
2348
  /**
2353
2349
  * Create an Image::Info object.
@@ -2368,7 +2364,7 @@ Info_alloc(VALUE class)
2368
2364
  {
2369
2365
  rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
2370
2366
  }
2371
- info_obj = Data_Wrap_Struct(class, NULL, destroy_Info, info);
2367
+ info_obj = TypedData_Wrap_Struct(class, &rm_info_data_type, info);
2372
2368
 
2373
2369
  RB_GC_GUARD(info_obj);
2374
2370
 
@@ -2405,7 +2401,7 @@ rm_info_new(void)
2405
2401
  * @overload initialize
2406
2402
  *
2407
2403
  * @overload initialize
2408
- * @yield []
2404
+ * @yield [Magick::Image::Info]
2409
2405
  *
2410
2406
  * @return self
2411
2407
  */
@@ -2414,15 +2410,7 @@ Info_initialize(VALUE self)
2414
2410
  {
2415
2411
  if (rb_block_given_p())
2416
2412
  {
2417
- if (rb_proc_arity(rb_block_proc()) == 0)
2418
- {
2419
- // Run the block in self's context
2420
- rb_obj_instance_eval(0, NULL, self);
2421
- }
2422
- else
2423
- {
2424
- rb_yield(self);
2425
- }
2413
+ rb_yield(self);
2426
2414
  }
2427
2415
  return self;
2428
2416
  }