rmagick 4.2.6 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/ImageMagick6/devcontainer.json +1 -1
  3. data/.devcontainer/{ImageMagick7/devcontainer.json → devcontainer.json} +2 -2
  4. data/.devcontainer/setup-user.sh +1 -1
  5. data/.editorconfig +1 -1
  6. data/.github/workflows/ci.yml +87 -9
  7. data/.gitignore +4 -0
  8. data/.rubocop_todo.yml +16 -9
  9. data/.yardopts +1 -1
  10. data/CHANGELOG.md +130 -0
  11. data/Gemfile +20 -0
  12. data/README.md +10 -17
  13. data/Rakefile +63 -80
  14. data/before_install_linux.sh +3 -3
  15. data/before_install_osx.sh +6 -5
  16. data/ext/RMagick/extconf.rb +112 -52
  17. data/ext/RMagick/{rmagick.c → rmagick.cpp} +19 -22
  18. data/ext/RMagick/rmagick.h +88 -59
  19. data/ext/RMagick/rmagick_gvl.h +224 -0
  20. data/ext/RMagick/{rmdraw.c → rmdraw.cpp} +170 -159
  21. data/ext/RMagick/{rmenum.c → rmenum.cpp} +69 -50
  22. data/ext/RMagick/{rmfill.c → rmfill.cpp} +85 -24
  23. data/ext/RMagick/{rmilist.c → rmilist.cpp} +191 -93
  24. data/ext/RMagick/{rmimage.c → rmimage.cpp} +1543 -989
  25. data/ext/RMagick/{rminfo.c → rminfo.cpp} +140 -152
  26. data/ext/RMagick/{rmkinfo.c → rmkinfo.cpp} +46 -34
  27. data/ext/RMagick/rmmain.cpp +1923 -0
  28. data/ext/RMagick/{rmmontage.c → rmmontage.cpp} +50 -29
  29. data/ext/RMagick/{rmpixel.c → rmpixel.cpp} +108 -83
  30. data/ext/RMagick/{rmstruct.c → rmstruct.cpp} +6 -6
  31. data/ext/RMagick/{rmutil.c → rmutil.cpp} +62 -161
  32. data/lib/rmagick/version.rb +3 -1
  33. data/lib/rmagick.rb +2 -0
  34. data/lib/rmagick_internal.rb +76 -110
  35. data/lib/rvg/embellishable.rb +6 -2
  36. data/lib/rvg/misc.rb +7 -7
  37. data/lib/rvg/rvg.rb +2 -0
  38. data/lib/rvg/stretchable.rb +2 -2
  39. data/lib/rvg/transformable.rb +1 -1
  40. data/rmagick.gemspec +4 -13
  41. data/sig/rmagick/_draw_common_methods.rbs +64 -0
  42. data/sig/rmagick/_image_common_methods.rbs +389 -0
  43. data/sig/rmagick/draw.rbs +38 -0
  44. data/sig/rmagick/draw_attribute.rbs +28 -0
  45. data/sig/rmagick/enum.rbs +814 -0
  46. data/sig/rmagick/error.rbs +11 -0
  47. data/sig/rmagick/fill.rbs +21 -0
  48. data/sig/rmagick/geometry.rbs +14 -0
  49. data/sig/rmagick/image.rbs +194 -0
  50. data/sig/rmagick/image_list.rbs +181 -0
  51. data/sig/rmagick/iptc.rbs +101 -0
  52. data/sig/rmagick/kernel_info.rbs +12 -0
  53. data/sig/rmagick/optional_method_arguments.rbs +10 -0
  54. data/sig/rmagick/pixel.rbs +46 -0
  55. data/sig/rmagick/struct.rbs +90 -0
  56. data/sig/rmagick.rbs +43 -0
  57. data/sig/rvg/clippath.rbs +34 -0
  58. data/sig/rvg/container.rbs +78 -0
  59. data/sig/rvg/deep_equal.rbs +48 -0
  60. data/sig/rvg/describable.rbs +30 -0
  61. data/sig/rvg/embellishable.rbs +226 -0
  62. data/sig/rvg/misc.rbs +145 -0
  63. data/sig/rvg/paint.rbs +55 -0
  64. data/sig/rvg/pathdata.rbs +77 -0
  65. data/sig/rvg/rvg.rbs +125 -0
  66. data/sig/rvg/stretchable.rbs +56 -0
  67. data/sig/rvg/stylable.rbs +66 -0
  68. data/sig/rvg/text.rbs +118 -0
  69. data/sig/rvg/transformable.rbs +59 -0
  70. data/sig/rvg/units.rbs +33 -0
  71. metadata +59 -129
  72. data/.codeclimate.yml +0 -63
  73. data/deprecated/RMagick.rb +0 -6
  74. data/ext/RMagick/rmmain.c +0 -1951
@@ -3,15 +3,30 @@
3
3
  *
4
4
  * Copyright © RMagick Project
5
5
  *
6
- * @file rmkinfo.c
7
- * @version $Id: rmkinfo.c,v 1.0 2011/11/29 15:33:14 naquad Exp $
6
+ * @file rmkinfo.cpp
7
+ * @version $Id: rmkinfo.cpp,v 1.0 2011/11/29 15:33:14 naquad Exp $
8
8
  * @author Naquad
9
9
  ****************************************************************************/
10
10
 
11
11
  #include "rmagick.h"
12
12
 
13
+ static void rm_kernel_info_destroy(void *kernel);
14
+ static size_t rm_kernel_info_memsize(const void *ptr);
15
+
16
+ const rb_data_type_t rm_kernel_info_data_type = {
17
+ "Magick::KernelInfo",
18
+ { NULL, rm_kernel_info_destroy, rm_kernel_info_memsize, },
19
+ 0, 0,
20
+ RUBY_TYPED_FROZEN_SHAREABLE,
21
+ };
22
+
23
+ DEFINE_GVL_VOID_STUB2(UnityAddKernelInfo, KernelInfo *, const double);
24
+ DEFINE_GVL_VOID_STUB3(ScaleKernelInfo, KernelInfo *, const double, const GeometryFlags);
25
+ DEFINE_GVL_VOID_STUB2(ScaleGeometryKernelInfo, KernelInfo *, const char *);
26
+
27
+
13
28
  /**
14
- * If there's a kernel info, delete it before destroying the KernelInfo
29
+ * If there's a kernel info, delete it before destroying the KernelInfo
15
30
  *
16
31
  * No Ruby usage (internal function)
17
32
  *
@@ -25,15 +40,28 @@ rm_kernel_info_destroy(void *kernel)
25
40
  DestroyKernelInfo((KernelInfo*)kernel);
26
41
  }
27
42
 
43
+ /**
44
+ * Get KernelInfo object size.
45
+ *
46
+ * No Ruby usage (internal function)
47
+ *
48
+ * @param ptr pointer to the KernelInfo object
49
+ */
50
+ static size_t
51
+ rm_kernel_info_memsize(const void *ptr)
52
+ {
53
+ return sizeof(KernelInfo);
54
+ }
55
+
28
56
  /**
29
57
  * Create a KernelInfo object.
30
58
  *
31
59
  * @return [Magick::KernelInfo] a new KernelInfo object
32
60
  */
33
61
  VALUE
34
- KernelInfo_alloc(VALUE class)
62
+ KernelInfo_alloc(VALUE klass)
35
63
  {
36
- return Data_Wrap_Struct(class, NULL, rm_kernel_info_destroy, NULL);
64
+ return TypedData_Wrap_Struct(klass, &rm_kernel_info_data_type, NULL);
37
65
  }
38
66
 
39
67
  /**
@@ -46,15 +74,13 @@ VALUE
46
74
  KernelInfo_initialize(VALUE self, VALUE kernel_string)
47
75
  {
48
76
  KernelInfo *kernel;
77
+ char *string = StringValueCStr(kernel_string);
78
+
49
79
  #if defined(IMAGEMAGICK_7)
50
80
  ExceptionInfo *exception;
51
- #endif
52
81
 
53
- Check_Type(kernel_string, T_STRING);
54
-
55
- #if defined(IMAGEMAGICK_7)
56
82
  exception = AcquireExceptionInfo();
57
- kernel = AcquireKernelInfo(StringValueCStr(kernel_string), exception);
83
+ kernel = AcquireKernelInfo(string, exception);
58
84
  if (rm_should_raise_exception(exception, DestroyExceptionRetention))
59
85
  {
60
86
  if (kernel != (KernelInfo *) NULL)
@@ -64,7 +90,7 @@ KernelInfo_initialize(VALUE self, VALUE kernel_string)
64
90
  rm_raise_exception(exception);
65
91
  }
66
92
  #else
67
- kernel = AcquireKernelInfo(StringValueCStr(kernel_string));
93
+ kernel = AcquireKernelInfo(string);
68
94
  #endif
69
95
 
70
96
  if (!kernel)
@@ -86,13 +112,8 @@ KernelInfo_initialize(VALUE self, VALUE kernel_string)
86
112
  VALUE
87
113
  KernelInfo_unity_add(VALUE self, VALUE scale)
88
114
  {
89
- if (!FIXNUM_P(scale))
90
- Check_Type(scale, T_FLOAT);
91
-
92
- /* UnityAddKernelInfo() was private function until IM 6.9 */
93
- MagickExport void UnityAddKernelInfo(KernelInfo *kernel, const double scale);
94
-
95
- UnityAddKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale));
115
+ GVL_STRUCT_TYPE(UnityAddKernelInfo) args = { (KernelInfo*)DATA_PTR(self), NUM2DBL(scale) };
116
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(UnityAddKernelInfo), &args);
96
117
  return Qnil;
97
118
  }
98
119
 
@@ -110,18 +131,10 @@ KernelInfo_scale(VALUE self, VALUE scale, VALUE flags)
110
131
  {
111
132
  GeometryFlags geoflags;
112
133
 
113
- if (!FIXNUM_P(scale))
114
- Check_Type(scale, T_FLOAT);
115
-
116
- if (rb_obj_is_instance_of(flags, Class_GeometryFlags))
117
- VALUE_TO_ENUM(flags, geoflags, GeometryFlags);
118
- else
119
- rb_raise(rb_eArgError, "expected Integer or Magick::GeometryFlags to specify flags");
120
-
121
- /* ScaleKernelInfo() was private function until IM 6.9 */
122
- MagickExport void ScaleKernelInfo(KernelInfo *kernel, const double scaling_factor, const GeometryFlags normalize_flags);
134
+ VALUE_TO_ENUM(flags, geoflags, GeometryFlags);
123
135
 
124
- ScaleKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale), geoflags);
136
+ GVL_STRUCT_TYPE(ScaleKernelInfo) args = { (KernelInfo*)DATA_PTR(self), NUM2DBL(scale), geoflags };
137
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ScaleKernelInfo), &args);
125
138
  return Qnil;
126
139
  }
127
140
 
@@ -134,8 +147,8 @@ KernelInfo_scale(VALUE self, VALUE scale, VALUE flags)
134
147
  VALUE
135
148
  KernelInfo_scale_geometry(VALUE self, VALUE geometry)
136
149
  {
137
- Check_Type(geometry, T_STRING);
138
- ScaleGeometryKernelInfo((KernelInfo*)DATA_PTR(self), StringValueCStr(geometry));
150
+ GVL_STRUCT_TYPE(ScaleGeometryKernelInfo) args = { (KernelInfo*)DATA_PTR(self), StringValueCStr(geometry) };
151
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ScaleGeometryKernelInfo), &args);
139
152
  return Qnil;
140
153
  }
141
154
 
@@ -148,7 +161,7 @@ VALUE
148
161
  KernelInfo_clone(VALUE self)
149
162
  {
150
163
  KernelInfo *kernel = CloneKernelInfo((KernelInfo*)DATA_PTR(self));
151
- return Data_Wrap_Struct(Class_KernelInfo, NULL, rm_kernel_info_destroy, kernel);
164
+ return TypedData_Wrap_Struct(Class_KernelInfo, &rm_kernel_info_data_type, kernel);
152
165
  }
153
166
 
154
167
  /**
@@ -170,7 +183,6 @@ KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
170
183
  ExceptionInfo *exception;
171
184
  #endif
172
185
 
173
- Check_Type(geometry, T_STRING);
174
186
  VALUE_TO_ENUM(what, kernel_type, KernelInfoType);
175
187
  ParseGeometry(StringValueCStr(geometry), &info);
176
188
 
@@ -194,5 +206,5 @@ KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
194
206
  rb_raise(rb_eRuntimeError, "failed to acquire builtin kernel");
195
207
  }
196
208
 
197
- return Data_Wrap_Struct(self, NULL, rm_kernel_info_destroy, kernel);
209
+ return TypedData_Wrap_Struct(self, &rm_kernel_info_data_type, kernel);
198
210
  }