rmagick 4.2.2 → 5.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/Dockerfile +14 -0
  3. data/.devcontainer/ImageMagick6/devcontainer.json +11 -0
  4. data/.devcontainer/devcontainer.json +11 -0
  5. data/.devcontainer/setup-repo.sh +10 -0
  6. data/.devcontainer/setup-user.sh +45 -0
  7. data/.editorconfig +1 -1
  8. data/.github/workflows/ci.yml +59 -24
  9. data/.gitignore +3 -0
  10. data/.rubocop_todo.yml +0 -1
  11. data/.yardopts +1 -1
  12. data/CHANGELOG.md +131 -0
  13. data/README.md +12 -17
  14. data/Rakefile +53 -81
  15. data/before_install_linux.sh +4 -4
  16. data/before_install_osx.sh +7 -6
  17. data/ext/RMagick/extconf.rb +94 -45
  18. data/ext/RMagick/{rmagick.c → rmagick.cpp} +19 -22
  19. data/ext/RMagick/rmagick.h +90 -60
  20. data/ext/RMagick/rmagick_gvl.h +224 -0
  21. data/ext/RMagick/{rmdraw.c → rmdraw.cpp} +160 -146
  22. data/ext/RMagick/{rmenum.c → rmenum.cpp} +69 -50
  23. data/ext/RMagick/{rmfill.c → rmfill.cpp} +81 -20
  24. data/ext/RMagick/{rmilist.c → rmilist.cpp} +184 -93
  25. data/ext/RMagick/{rmimage.c → rmimage.cpp} +1276 -731
  26. data/ext/RMagick/{rminfo.c → rminfo.cpp} +119 -131
  27. data/ext/RMagick/{rmkinfo.c → rmkinfo.cpp} +41 -16
  28. data/ext/RMagick/rmmain.cpp +1957 -0
  29. data/ext/RMagick/{rmmontage.c → rmmontage.cpp} +49 -28
  30. data/ext/RMagick/{rmpixel.c → rmpixel.cpp} +109 -84
  31. data/ext/RMagick/{rmstruct.c → rmstruct.cpp} +12 -12
  32. data/ext/RMagick/{rmutil.c → rmutil.cpp} +52 -91
  33. data/lib/rmagick/version.rb +3 -1
  34. data/lib/rmagick.rb +2 -0
  35. data/lib/rmagick_internal.rb +9 -48
  36. data/lib/rvg/rvg.rb +2 -2
  37. data/rmagick.gemspec +8 -7
  38. metadata +54 -23
  39. data/.codeclimate.yml +0 -63
  40. data/deprecated/RMagick.rb +0 -6
  41. data/ext/RMagick/rmmain.c +0 -1951
@@ -5,13 +5,23 @@
5
5
  *
6
6
  * Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
7
7
  *
8
- * @file rminfo.c
9
- * @version $Id: rminfo.c,v 1.79 2009/12/20 02:33:33 baror Exp $
8
+ * @file rminfo.cpp
9
+ * @version $Id: rminfo.cpp,v 1.79 2009/12/20 02:33:33 baror Exp $
10
10
  * @author Tim Hunter
11
11
  ******************************************************************************/
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) */
@@ -245,7 +255,7 @@ Info_aref(int argc, VALUE *argv, VALUE self)
245
255
  {
246
256
  Info *info;
247
257
  char *format_p, *key_p;
248
- long format_l, key_l;
258
+ size_t format_l, key_l;
249
259
  const char *value;
250
260
  char fkey[MaxTextExtent];
251
261
 
@@ -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
  {
@@ -308,10 +318,10 @@ Info_aset(int argc, VALUE *argv, VALUE self)
308
318
  Info *info;
309
319
  VALUE value;
310
320
  char *format_p, *key_p, *value_p = NULL;
311
- long format_l, key_l;
321
+ size_t 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
  }
@@ -676,12 +686,12 @@ Info_define(int argc, VALUE *argv, VALUE self)
676
686
  Info *info;
677
687
  char *format, *key;
678
688
  const char *value = "";
679
- long format_l, key_l;
689
+ size_t format_l, key_l;
680
690
  char ckey[100];
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);
@@ -1851,9 +1835,9 @@ Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
1851
1835
  {
1852
1836
  Info *info;
1853
1837
  char *sampling_factor_p = NULL;
1854
- long sampling_factor_len = 0;
1838
+ size_t 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,10 +1885,10 @@ 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
- snprintf(buf, sizeof(buf), "%"RMIuSIZE"", info->scene);
1891
+ snprintf(buf, sizeof(buf), "%" RMIuSIZE "", info->scene);
1908
1892
  SetImageOption(info, "scene", buf);
1909
1893
 
1910
1894
  return 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;
@@ -2191,7 +2175,7 @@ Info_undefine(VALUE self, VALUE format, VALUE key)
2191
2175
  {
2192
2176
  Info *info;
2193
2177
  char *format_p, *key_p;
2194
- long format_l, key_l;
2178
+ size_t format_l, key_l;
2195
2179
  char fkey[MaxTextExtent];
2196
2180
 
2197
2181
  format_p = rm_str2cstr(format, &format_l);
@@ -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,17 +2332,29 @@ 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.
2354
2350
  *
2355
2351
  * No Ruby usage (internal function)
2356
2352
  *
2357
- * @param class the Ruby class to use
2353
+ * @param klass the Ruby class to use
2358
2354
  * @return a new ImageInfo object
2359
2355
  */
2360
2356
  VALUE
2361
- Info_alloc(VALUE class)
2357
+ Info_alloc(VALUE klass)
2362
2358
  {
2363
2359
  Info *info;
2364
2360
  VALUE info_obj;
@@ -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(klass, &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
  }